Last active
January 3, 2016 09:49
-
-
Save lsegal/8445157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AWS SDK for JavaScript v2.0.0-rc8 | |
// Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
// License at https://sdk.amazonaws.com/js/BUNDLE_LICENSE.txt | |
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | |
},{}],2:[function(require,module,exports){ | |
var Buffer = require('buffer').Buffer; | |
var intSize = 4; | |
var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0); | |
var chrsz = 8; | |
function toArray(buf, bigEndian) { | |
if ((buf.length % intSize) !== 0) { | |
var len = buf.length + (intSize - (buf.length % intSize)); | |
buf = Buffer.concat([buf, zeroBuffer], len); | |
} | |
var arr = []; | |
var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE; | |
for (var i = 0; i < buf.length; i += intSize) { | |
arr.push(fn.call(buf, i)); | |
} | |
return arr; | |
} | |
function toBuffer(arr, size, bigEndian) { | |
var buf = new Buffer(size); | |
var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE; | |
for (var i = 0; i < arr.length; i++) { | |
fn.call(buf, arr[i], i * 4, true); | |
} | |
return buf; | |
} | |
function hash(buf, fn, hashSize, bigEndian) { | |
if (!Buffer.isBuffer(buf)) buf = new Buffer(buf); | |
var arr = fn(toArray(buf, bigEndian), buf.length * chrsz); | |
return toBuffer(arr, hashSize, bigEndian); | |
} | |
module.exports = { hash: hash }; | |
},{"buffer":12}],3:[function(require,module,exports){ | |
var Buffer = require('buffer').Buffer | |
var sha = require('./sha') | |
var sha256 = require('./sha256') | |
var rng = require('./rng') | |
var md5 = require('./md5') | |
var algorithms = { | |
sha1: sha, | |
sha256: sha256, | |
md5: md5 | |
} | |
var blocksize = 64 | |
var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0) | |
function hmac(fn, key, data) { | |
if(!Buffer.isBuffer(key)) key = new Buffer(key) | |
if(!Buffer.isBuffer(data)) data = new Buffer(data) | |
if(key.length > blocksize) { | |
key = fn(key) | |
} else if(key.length < blocksize) { | |
key = Buffer.concat([key, zeroBuffer], blocksize) | |
} | |
var ipad = new Buffer(blocksize), opad = new Buffer(blocksize) | |
for(var i = 0; i < blocksize; i++) { | |
ipad[i] = key[i] ^ 0x36 | |
opad[i] = key[i] ^ 0x5C | |
} | |
var hash = fn(Buffer.concat([ipad, data])) | |
return fn(Buffer.concat([opad, hash])) | |
} | |
function hash(alg, key) { | |
alg = alg || 'sha1' | |
var fn = algorithms[alg] | |
var bufs = [] | |
var length = 0 | |
if(!fn) error('algorithm:', alg, 'is not yet supported') | |
return { | |
update: function (data) { | |
if(!Buffer.isBuffer(data)) data = new Buffer(data) | |
bufs.push(data) | |
length += data.length | |
return this | |
}, | |
digest: function (enc) { | |
var buf = Buffer.concat(bufs) | |
var r = key ? hmac(fn, key, buf) : fn(buf) | |
bufs = null | |
return enc ? r.toString(enc) : r | |
} | |
} | |
} | |
function error () { | |
var m = [].slice.call(arguments).join(' ') | |
throw new Error([ | |
m, | |
'we accept pull requests', | |
'http://github.com/dominictarr/crypto-browserify' | |
].join('\n')) | |
} | |
exports.createHash = function (alg) { return hash(alg) } | |
exports.createHmac = function (alg, key) { return hash(alg, key) } | |
exports.randomBytes = function(size, callback) { | |
if (callback && callback.call) { | |
try { | |
callback.call(this, undefined, new Buffer(rng(size))) | |
} catch (err) { callback(err) } | |
} else { | |
return new Buffer(rng(size)) | |
} | |
} | |
function each(a, f) { | |
for(var i in a) | |
f(a[i], i) | |
} | |
each(['createCredentials' | |
, 'createCipher' | |
, 'createCipheriv' | |
, 'createDecipher' | |
, 'createDecipheriv' | |
, 'createSign' | |
, 'createVerify' | |
, 'createDiffieHellman' | |
, 'pbkdf2'], function (name) { | |
exports[name] = function () { | |
error('sorry,', name, 'is not implemented yet') | |
} | |
}) | |
},{"./md5":4,"./rng":5,"./sha":6,"./sha256":7,"buffer":12}],4:[function(require,module,exports){ | |
var helpers = require('./helpers'); | |
function md5_vm_test() | |
{ | |
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; | |
} | |
function core_md5(x, len) | |
{ | |
x[len >> 5] |= 0x80 << ((len) % 32); | |
x[(((len + 64) >>> 9) << 4) + 14] = len; | |
var a = 1732584193; | |
var b = -271733879; | |
var c = -1732584194; | |
var d = 271733878; | |
for(var i = 0; i < x.length; i += 16) | |
{ | |
var olda = a; | |
var oldb = b; | |
var oldc = c; | |
var oldd = d; | |
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); | |
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); | |
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); | |
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); | |
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); | |
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); | |
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); | |
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); | |
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); | |
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); | |
c = md5_ff(c, d, a, b, x[i+10], 17, -42063); | |
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); | |
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); | |
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); | |
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); | |
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); | |
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); | |
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); | |
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); | |
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); | |
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); | |
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); | |
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); | |
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); | |
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); | |
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); | |
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); | |
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); | |
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); | |
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); | |
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); | |
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); | |
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); | |
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); | |
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); | |
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); | |
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); | |
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); | |
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); | |
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); | |
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); | |
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); | |
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); | |
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); | |
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); | |
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); | |
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); | |
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); | |
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); | |
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); | |
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); | |
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); | |
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); | |
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); | |
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); | |
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); | |
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); | |
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); | |
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); | |
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); | |
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); | |
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); | |
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); | |
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); | |
a = safe_add(a, olda); | |
b = safe_add(b, oldb); | |
c = safe_add(c, oldc); | |
d = safe_add(d, oldd); | |
} | |
return Array(a, b, c, d); | |
} | |
function md5_cmn(q, a, b, x, s, t) | |
{ | |
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); | |
} | |
function md5_ff(a, b, c, d, x, s, t) | |
{ | |
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); | |
} | |
function md5_gg(a, b, c, d, x, s, t) | |
{ | |
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); | |
} | |
function md5_hh(a, b, c, d, x, s, t) | |
{ | |
return md5_cmn(b ^ c ^ d, a, b, x, s, t); | |
} | |
function md5_ii(a, b, c, d, x, s, t) | |
{ | |
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); | |
} | |
function safe_add(x, y) | |
{ | |
var lsw = (x & 0xFFFF) + (y & 0xFFFF); | |
var msw = (x >> 16) + (y >> 16) + (lsw >> 16); | |
return (msw << 16) | (lsw & 0xFFFF); | |
} | |
function bit_rol(num, cnt) | |
{ | |
return (num << cnt) | (num >>> (32 - cnt)); | |
} | |
module.exports = function md5(buf) { | |
return helpers.hash(buf, core_md5, 16); | |
}; | |
},{"./helpers":2}],5:[function(require,module,exports){ | |
(function() { | |
var _global = this; | |
var mathRNG, whatwgRNG; | |
mathRNG = function(size) { | |
var bytes = new Array(size); | |
var r; | |
for (var i = 0, r; i < size; i++) { | |
if ((i & 0x03) == 0) r = Math.random() * 0x100000000; | |
bytes[i] = r >>> ((i & 0x03) << 3) & 0xff; | |
} | |
return bytes; | |
} | |
if (_global.crypto && crypto.getRandomValues) { | |
whatwgRNG = function(size) { | |
var bytes = new Uint8Array(size); | |
crypto.getRandomValues(bytes); | |
return bytes; | |
} | |
} | |
module.exports = whatwgRNG || mathRNG; | |
}()) | |
},{}],6:[function(require,module,exports){ | |
var helpers = require('./helpers'); | |
function core_sha1(x, len) | |
{ | |
x[len >> 5] |= 0x80 << (24 - len % 32); | |
x[((len + 64 >> 9) << 4) + 15] = len; | |
var w = Array(80); | |
var a = 1732584193; | |
var b = -271733879; | |
var c = -1732584194; | |
var d = 271733878; | |
var e = -1009589776; | |
for(var i = 0; i < x.length; i += 16) | |
{ | |
var olda = a; | |
var oldb = b; | |
var oldc = c; | |
var oldd = d; | |
var olde = e; | |
for(var j = 0; j < 80; j++) | |
{ | |
if(j < 16) w[j] = x[i + j]; | |
else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1); | |
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), | |
safe_add(safe_add(e, w[j]), sha1_kt(j))); | |
e = d; | |
d = c; | |
c = rol(b, 30); | |
b = a; | |
a = t; | |
} | |
a = safe_add(a, olda); | |
b = safe_add(b, oldb); | |
c = safe_add(c, oldc); | |
d = safe_add(d, oldd); | |
e = safe_add(e, olde); | |
} | |
return Array(a, b, c, d, e); | |
} | |
function sha1_ft(t, b, c, d) | |
{ | |
if(t < 20) return (b & c) | ((~b) & d); | |
if(t < 40) return b ^ c ^ d; | |
if(t < 60) return (b & c) | (b & d) | (c & d); | |
return b ^ c ^ d; | |
} | |
function sha1_kt(t) | |
{ | |
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : | |
(t < 60) ? -1894007588 : -899497514; | |
} | |
function safe_add(x, y) | |
{ | |
var lsw = (x & 0xFFFF) + (y & 0xFFFF); | |
var msw = (x >> 16) + (y >> 16) + (lsw >> 16); | |
return (msw << 16) | (lsw & 0xFFFF); | |
} | |
function rol(num, cnt) | |
{ | |
return (num << cnt) | (num >>> (32 - cnt)); | |
} | |
module.exports = function sha1(buf) { | |
return helpers.hash(buf, core_sha1, 20, true); | |
}; | |
},{"./helpers":2}],7:[function(require,module,exports){ | |
var helpers = require('./helpers'); | |
var safe_add = function(x, y) { | |
var lsw = (x & 0xFFFF) + (y & 0xFFFF); | |
var msw = (x >> 16) + (y >> 16) + (lsw >> 16); | |
return (msw << 16) | (lsw & 0xFFFF); | |
}; | |
var S = function(X, n) { | |
return (X >>> n) | (X << (32 - n)); | |
}; | |
var R = function(X, n) { | |
return (X >>> n); | |
}; | |
var Ch = function(x, y, z) { | |
return ((x & y) ^ ((~x) & z)); | |
}; | |
var Maj = function(x, y, z) { | |
return ((x & y) ^ (x & z) ^ (y & z)); | |
}; | |
var Sigma0256 = function(x) { | |
return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); | |
}; | |
var Sigma1256 = function(x) { | |
return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); | |
}; | |
var Gamma0256 = function(x) { | |
return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); | |
}; | |
var Gamma1256 = function(x) { | |
return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); | |
}; | |
var core_sha256 = function(m, l) { | |
var K = new Array(0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0xFC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x6CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2); | |
var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19); | |
var W = new Array(64); | |
var a, b, c, d, e, f, g, h, i, j; | |
var T1, T2; | |
m[l >> 5] |= 0x80 << (24 - l % 32); | |
m[((l + 64 >> 9) << 4) + 15] = l; | |
for (var i = 0; i < m.length; i += 16) { | |
a = HASH[0]; b = HASH[1]; c = HASH[2]; d = HASH[3]; e = HASH[4]; f = HASH[5]; g = HASH[6]; h = HASH[7]; | |
for (var j = 0; j < 64; j++) { | |
if (j < 16) { | |
W[j] = m[j + i]; | |
} else { | |
W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]); | |
} | |
T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]); | |
T2 = safe_add(Sigma0256(a), Maj(a, b, c)); | |
h = g; g = f; f = e; e = safe_add(d, T1); d = c; c = b; b = a; a = safe_add(T1, T2); | |
} | |
HASH[0] = safe_add(a, HASH[0]); HASH[1] = safe_add(b, HASH[1]); HASH[2] = safe_add(c, HASH[2]); HASH[3] = safe_add(d, HASH[3]); | |
HASH[4] = safe_add(e, HASH[4]); HASH[5] = safe_add(f, HASH[5]); HASH[6] = safe_add(g, HASH[6]); HASH[7] = safe_add(h, HASH[7]); | |
} | |
return HASH; | |
}; | |
module.exports = function sha256(buf) { | |
return helpers.hash(buf, core_sha256, 32, true); | |
}; | |
},{"./helpers":2}],8:[function(require,module,exports){ | |
function EventEmitter() { | |
this._events = this._events || {}; | |
this._maxListeners = this._maxListeners || undefined; | |
} | |
module.exports = EventEmitter; | |
EventEmitter.EventEmitter = EventEmitter; | |
EventEmitter.prototype._events = undefined; | |
EventEmitter.prototype._maxListeners = undefined; | |
EventEmitter.defaultMaxListeners = 10; | |
EventEmitter.prototype.setMaxListeners = function(n) { | |
if (!isNumber(n) || n < 0 || isNaN(n)) | |
throw TypeError('n must be a positive number'); | |
this._maxListeners = n; | |
return this; | |
}; | |
EventEmitter.prototype.emit = function(type) { | |
var er, handler, len, args, i, listeners; | |
if (!this._events) | |
this._events = {}; | |
if (type === 'error') { | |
if (!this._events.error || | |
(isObject(this._events.error) && !this._events.error.length)) { | |
er = arguments[1]; | |
if (er instanceof Error) { | |
throw er; // Unhandled 'error' event | |
} else { | |
throw TypeError('Uncaught, unspecified "error" event.'); | |
} | |
return false; | |
} | |
} | |
handler = this._events[type]; | |
if (isUndefined(handler)) | |
return false; | |
if (isFunction(handler)) { | |
switch (arguments.length) { | |
case 1: | |
handler.call(this); | |
break; | |
case 2: | |
handler.call(this, arguments[1]); | |
break; | |
case 3: | |
handler.call(this, arguments[1], arguments[2]); | |
break; | |
default: | |
len = arguments.length; | |
args = new Array(len - 1); | |
for (i = 1; i < len; i++) | |
args[i - 1] = arguments[i]; | |
handler.apply(this, args); | |
} | |
} else if (isObject(handler)) { | |
len = arguments.length; | |
args = new Array(len - 1); | |
for (i = 1; i < len; i++) | |
args[i - 1] = arguments[i]; | |
listeners = handler.slice(); | |
len = listeners.length; | |
for (i = 0; i < len; i++) | |
listeners[i].apply(this, args); | |
} | |
return true; | |
}; | |
EventEmitter.prototype.addListener = function(type, listener) { | |
var m; | |
if (!isFunction(listener)) | |
throw TypeError('listener must be a function'); | |
if (!this._events) | |
this._events = {}; | |
if (this._events.newListener) | |
this.emit('newListener', type, | |
isFunction(listener.listener) ? | |
listener.listener : listener); | |
if (!this._events[type]) | |
this._events[type] = listener; | |
else if (isObject(this._events[type])) | |
this._events[type].push(listener); | |
else | |
this._events[type] = [this._events[type], listener]; | |
if (isObject(this._events[type]) && !this._events[type].warned) { | |
var m; | |
if (!isUndefined(this._maxListeners)) { | |
m = this._maxListeners; | |
} else { | |
m = EventEmitter.defaultMaxListeners; | |
} | |
if (m && m > 0 && this._events[type].length > m) { | |
this._events[type].warned = true; | |
console.error('(node) warning: possible EventEmitter memory ' + | |
'leak detected. %d listeners added. ' + | |
'Use emitter.setMaxListeners() to increase limit.', | |
this._events[type].length); | |
console.trace(); | |
} | |
} | |
return this; | |
}; | |
EventEmitter.prototype.on = EventEmitter.prototype.addListener; | |
EventEmitter.prototype.once = function(type, listener) { | |
if (!isFunction(listener)) | |
throw TypeError('listener must be a function'); | |
var fired = false; | |
function g() { | |
this.removeListener(type, g); | |
if (!fired) { | |
fired = true; | |
listener.apply(this, arguments); | |
} | |
} | |
g.listener = listener; | |
this.on(type, g); | |
return this; | |
}; | |
EventEmitter.prototype.removeListener = function(type, listener) { | |
var list, position, length, i; | |
if (!isFunction(listener)) | |
throw TypeError('listener must be a function'); | |
if (!this._events || !this._events[type]) | |
return this; | |
list = this._events[type]; | |
length = list.length; | |
position = -1; | |
if (list === listener || | |
(isFunction(list.listener) && list.listener === listener)) { | |
delete this._events[type]; | |
if (this._events.removeListener) | |
this.emit('removeListener', type, listener); | |
} else if (isObject(list)) { | |
for (i = length; i-- > 0;) { | |
if (list[i] === listener || | |
(list[i].listener && list[i].listener === listener)) { | |
position = i; | |
break; | |
} | |
} | |
if (position < 0) | |
return this; | |
if (list.length === 1) { | |
list.length = 0; | |
delete this._events[type]; | |
} else { | |
list.splice(position, 1); | |
} | |
if (this._events.removeListener) | |
this.emit('removeListener', type, listener); | |
} | |
return this; | |
}; | |
EventEmitter.prototype.removeAllListeners = function(type) { | |
var key, listeners; | |
if (!this._events) | |
return this; | |
if (!this._events.removeListener) { | |
if (arguments.length === 0) | |
this._events = {}; | |
else if (this._events[type]) | |
delete this._events[type]; | |
return this; | |
} | |
if (arguments.length === 0) { | |
for (key in this._events) { | |
if (key === 'removeListener') continue; | |
this.removeAllListeners(key); | |
} | |
this.removeAllListeners('removeListener'); | |
this._events = {}; | |
return this; | |
} | |
listeners = this._events[type]; | |
if (isFunction(listeners)) { | |
this.removeListener(type, listeners); | |
} else { | |
while (listeners.length) | |
this.removeListener(type, listeners[listeners.length - 1]); | |
} | |
delete this._events[type]; | |
return this; | |
}; | |
EventEmitter.prototype.listeners = function(type) { | |
var ret; | |
if (!this._events || !this._events[type]) | |
ret = []; | |
else if (isFunction(this._events[type])) | |
ret = [this._events[type]]; | |
else | |
ret = this._events[type].slice(); | |
return ret; | |
}; | |
EventEmitter.listenerCount = function(emitter, type) { | |
var ret; | |
if (!emitter._events || !emitter._events[type]) | |
ret = 0; | |
else if (isFunction(emitter._events[type])) | |
ret = 1; | |
else | |
ret = emitter._events[type].length; | |
return ret; | |
}; | |
function isFunction(arg) { | |
return typeof arg === 'function'; | |
} | |
function isNumber(arg) { | |
return typeof arg === 'number'; | |
} | |
function isObject(arg) { | |
return typeof arg === 'object' && arg !== null; | |
} | |
function isUndefined(arg) { | |
return arg === void 0; | |
} | |
},{}],9:[function(require,module,exports){ | |
if (typeof Object.create === 'function') { | |
module.exports = function inherits(ctor, superCtor) { | |
ctor.super_ = superCtor | |
ctor.prototype = Object.create(superCtor.prototype, { | |
constructor: { | |
value: ctor, | |
enumerable: false, | |
writable: true, | |
configurable: true | |
} | |
}); | |
}; | |
} else { | |
module.exports = function inherits(ctor, superCtor) { | |
ctor.super_ = superCtor | |
var TempCtor = function () {} | |
TempCtor.prototype = superCtor.prototype | |
ctor.prototype = new TempCtor() | |
ctor.prototype.constructor = ctor | |
} | |
} | |
},{}],10:[function(require,module,exports){ | |
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"PcZj9L":[function(require,module,exports){ | |
var base64 = require('base64-js') | |
var ieee754 = require('ieee754') | |
exports.Buffer = Buffer | |
exports.SlowBuffer = Buffer | |
exports.INSPECT_MAX_BYTES = 50 | |
Buffer.poolSize = 8192 | |
var browserSupport = (function () { | |
if (typeof Uint8Array === 'undefined' || typeof ArrayBuffer === 'undefined' || | |
typeof DataView === 'undefined') | |
return false | |
try { | |
var arr = new Uint8Array(0) | |
arr.foo = function () { return 42 } | |
return 42 === arr.foo() | |
} catch (e) { | |
return false | |
} | |
})() | |
function Buffer (subject, encoding, noZero) { | |
if (!(this instanceof Buffer)) | |
return new Buffer(subject, encoding, noZero) | |
var type = typeof subject | |
if (encoding === 'base64' && type === 'string') { | |
subject = stringtrim(subject) | |
while (subject.length % 4 !== 0) { | |
subject = subject + '=' | |
} | |
} | |
var length | |
if (type === 'number') | |
length = coerce(subject) | |
else if (type === 'string') | |
length = Buffer.byteLength(subject, encoding) | |
else if (type === 'object') | |
length = coerce(subject.length) // Assume object is an array | |
else | |
throw new Error('First argument needs to be a number, array or string.') | |
var buf | |
if (browserSupport) { | |
buf = augment(new Uint8Array(length)) | |
} else { | |
buf = this | |
buf.length = length | |
} | |
var i | |
if (Buffer.isBuffer(subject)) { | |
buf.set(subject) | |
} else if (isArrayish(subject)) { | |
for (i = 0; i < length; i++) { | |
if (Buffer.isBuffer(subject)) | |
buf[i] = subject.readUInt8(i) | |
else | |
buf[i] = subject[i] | |
} | |
} else if (type === 'string') { | |
buf.write(subject, 0, encoding) | |
} else if (type === 'number' && !browserSupport && !noZero) { | |
for (i = 0; i < length; i++) { | |
buf[i] = 0 | |
} | |
} | |
return buf | |
} | |
Buffer.isEncoding = function (encoding) { | |
switch (String(encoding).toLowerCase()) { | |
case 'hex': | |
case 'utf8': | |
case 'utf-8': | |
case 'ascii': | |
case 'binary': | |
case 'base64': | |
case 'raw': | |
return true | |
default: | |
return false | |
} | |
} | |
Buffer.isBuffer = function (b) { | |
return b && b._isBuffer | |
} | |
Buffer.byteLength = function (str, encoding) { | |
switch (encoding || 'utf8') { | |
case 'hex': | |
return str.length / 2 | |
case 'utf8': | |
case 'utf-8': | |
return utf8ToBytes(str).length | |
case 'ascii': | |
case 'binary': | |
return str.length | |
case 'base64': | |
return base64ToBytes(str).length | |
default: | |
throw new Error('Unknown encoding') | |
} | |
} | |
Buffer.concat = function (list, totalLength) { | |
if (!isArray(list)) { | |
throw new Error('Usage: Buffer.concat(list, [totalLength])\n' + | |
'list should be an Array.') | |
} | |
if (list.length === 0) { | |
return new Buffer(0) | |
} else if (list.length === 1) { | |
return list[0] | |
} | |
var i | |
if (typeof totalLength !== 'number') { | |
totalLength = 0 | |
for (i = 0; i < list.length; i++) { | |
totalLength += list[i].length | |
} | |
} | |
var buf = new Buffer(totalLength) | |
var pos = 0 | |
for (i = 0; i < list.length; i++) { | |
var item = list[i] | |
item.copy(buf, pos) | |
pos += item.length | |
} | |
return buf | |
} | |
function _hexWrite (buf, string, offset, length) { | |
offset = Number(offset) || 0 | |
var remaining = buf.length - offset | |
if (!length) { | |
length = remaining | |
} else { | |
length = Number(length) | |
if (length > remaining) { | |
length = remaining | |
} | |
} | |
var strLen = string.length | |
if (strLen % 2 !== 0) { | |
throw new Error('Invalid hex string') | |
} | |
if (length > strLen / 2) { | |
length = strLen / 2 | |
} | |
for (var i = 0; i < length; i++) { | |
var byte = parseInt(string.substr(i * 2, 2), 16) | |
if (isNaN(byte)) throw new Error('Invalid hex string') | |
buf[offset + i] = byte | |
} | |
Buffer._charsWritten = i * 2 | |
return i | |
} | |
function _utf8Write (buf, string, offset, length) { | |
var bytes, pos | |
return Buffer._charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length) | |
} | |
function _asciiWrite (buf, string, offset, length) { | |
var bytes, pos | |
return Buffer._charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length) | |
} | |
function _binaryWrite (buf, string, offset, length) { | |
return _asciiWrite(buf, string, offset, length) | |
} | |
function _base64Write (buf, string, offset, length) { | |
var bytes, pos | |
return Buffer._charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length) | |
} | |
Buffer.prototype.write = function (string, offset, length, encoding) { | |
if (isFinite(offset)) { | |
if (!isFinite(length)) { | |
encoding = length | |
length = undefined | |
} | |
} else { // legacy | |
var swap = encoding | |
encoding = offset | |
offset = length | |
length = swap | |
} | |
offset = Number(offset) || 0 | |
var remaining = this.length - offset | |
if (!length) { | |
length = remaining | |
} else { | |
length = Number(length) | |
if (length > remaining) { | |
length = remaining | |
} | |
} | |
encoding = String(encoding || 'utf8').toLowerCase() | |
switch (encoding) { | |
case 'hex': | |
return _hexWrite(this, string, offset, length) | |
case 'utf8': | |
case 'utf-8': | |
return _utf8Write(this, string, offset, length) | |
case 'ascii': | |
return _asciiWrite(this, string, offset, length) | |
case 'binary': | |
return _binaryWrite(this, string, offset, length) | |
case 'base64': | |
return _base64Write(this, string, offset, length) | |
default: | |
throw new Error('Unknown encoding') | |
} | |
} | |
Buffer.prototype.toString = function (encoding, start, end) { | |
var self = this | |
encoding = String(encoding || 'utf8').toLowerCase() | |
start = Number(start) || 0 | |
end = (end !== undefined) | |
? Number(end) | |
: end = self.length | |
if (end === start) | |
return '' | |
switch (encoding) { | |
case 'hex': | |
return _hexSlice(self, start, end) | |
case 'utf8': | |
case 'utf-8': | |
return _utf8Slice(self, start, end) | |
case 'ascii': | |
return _asciiSlice(self, start, end) | |
case 'binary': | |
return _binarySlice(self, start, end) | |
case 'base64': | |
return _base64Slice(self, start, end) | |
default: | |
throw new Error('Unknown encoding') | |
} | |
} | |
Buffer.prototype.toJSON = function () { | |
return { | |
type: 'Buffer', | |
data: Array.prototype.slice.call(this._arr || this, 0) | |
} | |
} | |
Buffer.prototype.copy = function (target, target_start, start, end) { | |
var source = this | |
if (!start) start = 0 | |
if (!end && end !== 0) end = this.length | |
if (!target_start) target_start = 0 | |
if (end === start) return | |
if (target.length === 0 || source.length === 0) return | |
if (end < start) | |
throw new Error('sourceEnd < sourceStart') | |
if (target_start < 0 || target_start >= target.length) | |
throw new Error('targetStart out of bounds') | |
if (start < 0 || start >= source.length) | |
throw new Error('sourceStart out of bounds') | |
if (end < 0 || end > source.length) | |
throw new Error('sourceEnd out of bounds') | |
if (end > this.length) | |
end = this.length | |
if (target.length - target_start < end - start) | |
end = target.length - target_start + start | |
for (var i = 0; i < end - start; i++) | |
target[i + target_start] = this[i + start] | |
} | |
function _base64Slice (buf, start, end) { | |
if (start === 0 && end === buf.length) { | |
return base64.fromByteArray(buf) | |
} else { | |
return base64.fromByteArray(buf.slice(start, end)) | |
} | |
} | |
function _utf8Slice (buf, start, end) { | |
var res = '' | |
var tmp = '' | |
end = Math.min(buf.length, end) | |
for (var i = start; i < end; i++) { | |
if (buf[i] <= 0x7F) { | |
res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) | |
tmp = '' | |
} else { | |
tmp += '%' + buf[i].toString(16) | |
} | |
} | |
return res + decodeUtf8Char(tmp) | |
} | |
function _asciiSlice (buf, start, end) { | |
var ret = '' | |
end = Math.min(buf.length, end) | |
for (var i = start; i < end; i++) | |
ret += String.fromCharCode(buf[i]) | |
return ret | |
} | |
function _binarySlice (buf, start, end) { | |
return _asciiSlice(buf, start, end) | |
} | |
function _hexSlice (buf, start, end) { | |
var len = buf.length | |
if (!start || start < 0) start = 0 | |
if (!end || end < 0 || end > len) end = len | |
var out = '' | |
for (var i = start; i < end; i++) { | |
out += toHex(buf[i]) | |
} | |
return out | |
} | |
Buffer.prototype.slice = function (start, end) { | |
var len = this.length | |
start = clamp(start, len, 0) | |
end = clamp(end, len, len) | |
if (browserSupport) { | |
return augment(this.subarray(start, end)) | |
} else { | |
var sliceLen = end - start | |
var newBuf = new Buffer(sliceLen, undefined, true) | |
for (var i = 0; i < sliceLen; i++) { | |
newBuf[i] = this[i + start] | |
} | |
return newBuf | |
} | |
} | |
Buffer.prototype.readUInt8 = function (offset, noAssert) { | |
var buf = this | |
if (!noAssert) { | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset < buf.length, 'Trying to read beyond buffer length') | |
} | |
if (offset >= buf.length) | |
return | |
return buf[offset] | |
} | |
function _readUInt16 (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (browserSupport) { | |
if (offset + 1 < len) { | |
return buf._dataview.getUint16(offset, littleEndian) | |
} else { | |
var dv = new DataView(new ArrayBuffer(2)) | |
dv.setUint8(0, buf[len - 1]) | |
return dv.getUint16(0, littleEndian) | |
} | |
} else { | |
var val | |
if (littleEndian) { | |
val = buf[offset] | |
if (offset + 1 < len) | |
val |= buf[offset + 1] << 8 | |
} else { | |
val = buf[offset] << 8 | |
if (offset + 1 < len) | |
val |= buf[offset + 1] | |
} | |
return val | |
} | |
} | |
Buffer.prototype.readUInt16LE = function (offset, noAssert) { | |
return _readUInt16(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readUInt16BE = function (offset, noAssert) { | |
return _readUInt16(this, offset, false, noAssert) | |
} | |
function _readUInt32 (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (browserSupport) { | |
if (offset + 3 < len) { | |
return buf._dataview.getUint32(offset, littleEndian) | |
} else { | |
var dv = new DataView(new ArrayBuffer(4)) | |
for (var i = 0; i + offset < len; i++) { | |
dv.setUint8(i, buf[i + offset]) | |
} | |
return dv.getUint32(0, littleEndian) | |
} | |
} else { | |
var val | |
if (littleEndian) { | |
if (offset + 2 < len) | |
val = buf[offset + 2] << 16 | |
if (offset + 1 < len) | |
val |= buf[offset + 1] << 8 | |
val |= buf[offset] | |
if (offset + 3 < len) | |
val = val + (buf[offset + 3] << 24 >>> 0) | |
} else { | |
if (offset + 1 < len) | |
val = buf[offset + 1] << 16 | |
if (offset + 2 < len) | |
val |= buf[offset + 2] << 8 | |
if (offset + 3 < len) | |
val |= buf[offset + 3] | |
val = val + (buf[offset] << 24 >>> 0) | |
} | |
return val | |
} | |
} | |
Buffer.prototype.readUInt32LE = function (offset, noAssert) { | |
return _readUInt32(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readUInt32BE = function (offset, noAssert) { | |
return _readUInt32(this, offset, false, noAssert) | |
} | |
Buffer.prototype.readInt8 = function (offset, noAssert) { | |
var buf = this | |
if (!noAssert) { | |
assert(offset !== undefined && offset !== null, | |
'missing offset') | |
assert(offset < buf.length, 'Trying to read beyond buffer length') | |
} | |
if (offset >= buf.length) | |
return | |
if (browserSupport) { | |
return buf._dataview.getInt8(offset) | |
} else { | |
var neg = buf[offset] & 0x80 | |
if (neg) | |
return (0xff - buf[offset] + 1) * -1 | |
else | |
return buf[offset] | |
} | |
} | |
function _readInt16 (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (browserSupport) { | |
if (offset + 1 === len) { | |
var dv = new DataView(new ArrayBuffer(2)) | |
dv.setUint8(0, buf[len - 1]) | |
return dv.getInt16(0, littleEndian) | |
} else { | |
return buf._dataview.getInt16(offset, littleEndian) | |
} | |
} else { | |
var val = _readUInt16(buf, offset, littleEndian, true) | |
var neg = val & 0x8000 | |
if (neg) | |
return (0xffff - val + 1) * -1 | |
else | |
return val | |
} | |
} | |
Buffer.prototype.readInt16LE = function (offset, noAssert) { | |
return _readInt16(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readInt16BE = function (offset, noAssert) { | |
return _readInt16(this, offset, false, noAssert) | |
} | |
function _readInt32 (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (browserSupport) { | |
if (offset + 3 >= len) { | |
var dv = new DataView(new ArrayBuffer(4)) | |
for (var i = 0; i + offset < len; i++) { | |
dv.setUint8(i, buf[i + offset]) | |
} | |
return dv.getInt32(0, littleEndian) | |
} else { | |
return buf._dataview.getInt32(offset, littleEndian) | |
} | |
} else { | |
var val = _readUInt32(buf, offset, littleEndian, true) | |
var neg = val & 0x80000000 | |
if (neg) | |
return (0xffffffff - val + 1) * -1 | |
else | |
return val | |
} | |
} | |
Buffer.prototype.readInt32LE = function (offset, noAssert) { | |
return _readInt32(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readInt32BE = function (offset, noAssert) { | |
return _readInt32(this, offset, false, noAssert) | |
} | |
function _readFloat (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') | |
} | |
if (browserSupport) { | |
return buf._dataview.getFloat32(offset, littleEndian) | |
} else { | |
return ieee754.read(buf, offset, littleEndian, 23, 4) | |
} | |
} | |
Buffer.prototype.readFloatLE = function (offset, noAssert) { | |
return _readFloat(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readFloatBE = function (offset, noAssert) { | |
return _readFloat(this, offset, false, noAssert) | |
} | |
function _readDouble (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset + 7 < buf.length, 'Trying to read beyond buffer length') | |
} | |
if (browserSupport) { | |
return buf._dataview.getFloat64(offset, littleEndian) | |
} else { | |
return ieee754.read(buf, offset, littleEndian, 52, 8) | |
} | |
} | |
Buffer.prototype.readDoubleLE = function (offset, noAssert) { | |
return _readDouble(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readDoubleBE = function (offset, noAssert) { | |
return _readDouble(this, offset, false, noAssert) | |
} | |
Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { | |
var buf = this | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset < buf.length, 'trying to write beyond buffer length') | |
verifuint(value, 0xff) | |
} | |
if (offset >= buf.length) return | |
buf[offset] = value | |
} | |
function _writeUInt16 (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 1 < buf.length, 'trying to write beyond buffer length') | |
verifuint(value, 0xffff) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (browserSupport) { | |
if (offset + 1 === len) { | |
var dv = new DataView(new ArrayBuffer(2)) | |
dv.setUint16(0, value, littleEndian) | |
buf[offset] = dv.getUint8(0) | |
} else { | |
buf._dataview.setUint16(offset, value, littleEndian) | |
} | |
} else { | |
for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) { | |
buf[offset + i] = | |
(value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> | |
(littleEndian ? i : 1 - i) * 8 | |
} | |
} | |
} | |
Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) { | |
_writeUInt16(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) { | |
_writeUInt16(this, value, offset, false, noAssert) | |
} | |
function _writeUInt32 (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'trying to write beyond buffer length') | |
verifuint(value, 0xffffffff) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
var i | |
if (browserSupport) { | |
if (offset + 3 >= len) { | |
var dv = new DataView(new ArrayBuffer(4)) | |
dv.setUint32(0, value, littleEndian) | |
for (i = 0; i + offset < len; i++) { | |
buf[i + offset] = dv.getUint8(i) | |
} | |
} else { | |
buf._dataview.setUint32(offset, value, littleEndian) | |
} | |
} else { | |
for (i = 0, j = Math.min(len - offset, 4); i < j; i++) { | |
buf[offset + i] = | |
(value >>> (littleEndian ? i : 3 - i) * 8) & 0xff | |
} | |
} | |
} | |
Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) { | |
_writeUInt32(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) { | |
_writeUInt32(this, value, offset, false, noAssert) | |
} | |
Buffer.prototype.writeInt8 = function (value, offset, noAssert) { | |
var buf = this | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset < buf.length, 'Trying to write beyond buffer length') | |
verifsint(value, 0x7f, -0x80) | |
} | |
if (offset >= buf.length) | |
return | |
if (browserSupport) { | |
buf._dataview.setInt8(offset, value) | |
} else { | |
if (value >= 0) | |
buf.writeUInt8(value, offset, noAssert) | |
else | |
buf.writeUInt8(0xff + value + 1, offset, noAssert) | |
} | |
} | |
function _writeInt16 (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 1 < buf.length, 'Trying to write beyond buffer length') | |
verifsint(value, 0x7fff, -0x8000) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (browserSupport) { | |
if (offset + 1 === len) { | |
var dv = new DataView(new ArrayBuffer(2)) | |
dv.setInt16(0, value, littleEndian) | |
buf[offset] = dv.getUint8(0) | |
} else { | |
buf._dataview.setInt16(offset, value, littleEndian) | |
} | |
} else { | |
if (value >= 0) | |
_writeUInt16(buf, value, offset, littleEndian, noAssert) | |
else | |
_writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert) | |
} | |
} | |
Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { | |
_writeInt16(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeInt16BE = function (value, offset, noAssert) { | |
_writeInt16(this, value, offset, false, noAssert) | |
} | |
function _writeInt32 (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') | |
verifsint(value, 0x7fffffff, -0x80000000) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (browserSupport) { | |
if (offset + 3 >= len) { | |
var dv = new DataView(new ArrayBuffer(4)) | |
dv.setInt32(0, value, littleEndian) | |
for (var i = 0; i + offset < len; i++) { | |
buf[i + offset] = dv.getUint8(i) | |
} | |
} else { | |
buf._dataview.setInt32(offset, value, littleEndian) | |
} | |
} else { | |
if (value >= 0) | |
_writeUInt32(buf, value, offset, littleEndian, noAssert) | |
else | |
_writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert) | |
} | |
} | |
Buffer.prototype.writeInt32LE = function (value, offset, noAssert) { | |
_writeInt32(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeInt32BE = function (value, offset, noAssert) { | |
_writeInt32(this, value, offset, false, noAssert) | |
} | |
function _writeFloat (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') | |
verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (browserSupport) { | |
if (offset + 3 >= len) { | |
var dv = new DataView(new ArrayBuffer(4)) | |
dv.setFloat32(0, value, littleEndian) | |
for (var i = 0; i + offset < len; i++) { | |
buf[i + offset] = dv.getUint8(i) | |
} | |
} else { | |
buf._dataview.setFloat32(offset, value, littleEndian) | |
} | |
} else { | |
ieee754.write(buf, value, offset, littleEndian, 23, 4) | |
} | |
} | |
Buffer.prototype.writeFloatLE = function (value, offset, noAssert) { | |
_writeFloat(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeFloatBE = function (value, offset, noAssert) { | |
_writeFloat(this, value, offset, false, noAssert) | |
} | |
function _writeDouble (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 7 < buf.length, | |
'Trying to write beyond buffer length') | |
verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (browserSupport) { | |
if (offset + 7 >= len) { | |
var dv = new DataView(new ArrayBuffer(8)) | |
dv.setFloat64(0, value, littleEndian) | |
for (var i = 0; i + offset < len; i++) { | |
buf[i + offset] = dv.getUint8(i) | |
} | |
} else { | |
buf._dataview.setFloat64(offset, value, littleEndian) | |
} | |
} else { | |
ieee754.write(buf, value, offset, littleEndian, 52, 8) | |
} | |
} | |
Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) { | |
_writeDouble(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { | |
_writeDouble(this, value, offset, false, noAssert) | |
} | |
Buffer.prototype.fill = function (value, start, end) { | |
if (!value) value = 0 | |
if (!start) start = 0 | |
if (!end) end = this.length | |
if (typeof value === 'string') { | |
value = value.charCodeAt(0) | |
} | |
if (typeof value !== 'number' || isNaN(value)) { | |
throw new Error('value is not a number') | |
} | |
if (end < start) throw new Error('end < start') | |
if (end === start) return | |
if (this.length === 0) return | |
if (start < 0 || start >= this.length) { | |
throw new Error('start out of bounds') | |
} | |
if (end < 0 || end > this.length) { | |
throw new Error('end out of bounds') | |
} | |
for (var i = start; i < end; i++) { | |
this[i] = value | |
} | |
} | |
Buffer.prototype.inspect = function () { | |
var out = [] | |
var len = this.length | |
for (var i = 0; i < len; i++) { | |
out[i] = toHex(this[i]) | |
if (i === exports.INSPECT_MAX_BYTES) { | |
out[i + 1] = '...' | |
break | |
} | |
} | |
return '<Buffer ' + out.join(' ') + '>' | |
} | |
function BufferToArrayBuffer () { | |
return (new Buffer(this)).buffer | |
} | |
function stringtrim (str) { | |
if (str.trim) return str.trim() | |
return str.replace(/^\s+|\s+$/g, '') | |
} | |
var BP = Buffer.prototype | |
function augment (arr) { | |
arr._isBuffer = true | |
arr.write = BP.write | |
arr.toString = BP.toString | |
arr.toLocaleString = BP.toString | |
arr.toJSON = BP.toJSON | |
arr.copy = BP.copy | |
arr.slice = BP.slice | |
arr.readUInt8 = BP.readUInt8 | |
arr.readUInt16LE = BP.readUInt16LE | |
arr.readUInt16BE = BP.readUInt16BE | |
arr.readUInt32LE = BP.readUInt32LE | |
arr.readUInt32BE = BP.readUInt32BE | |
arr.readInt8 = BP.readInt8 | |
arr.readInt16LE = BP.readInt16LE | |
arr.readInt16BE = BP.readInt16BE | |
arr.readInt32LE = BP.readInt32LE | |
arr.readInt32BE = BP.readInt32BE | |
arr.readFloatLE = BP.readFloatLE | |
arr.readFloatBE = BP.readFloatBE | |
arr.readDoubleLE = BP.readDoubleLE | |
arr.readDoubleBE = BP.readDoubleBE | |
arr.writeUInt8 = BP.writeUInt8 | |
arr.writeUInt16LE = BP.writeUInt16LE | |
arr.writeUInt16BE = BP.writeUInt16BE | |
arr.writeUInt32LE = BP.writeUInt32LE | |
arr.writeUInt32BE = BP.writeUInt32BE | |
arr.writeInt8 = BP.writeInt8 | |
arr.writeInt16LE = BP.writeInt16LE | |
arr.writeInt16BE = BP.writeInt16BE | |
arr.writeInt32LE = BP.writeInt32LE | |
arr.writeInt32BE = BP.writeInt32BE | |
arr.writeFloatLE = BP.writeFloatLE | |
arr.writeFloatBE = BP.writeFloatBE | |
arr.writeDoubleLE = BP.writeDoubleLE | |
arr.writeDoubleBE = BP.writeDoubleBE | |
arr.fill = BP.fill | |
arr.inspect = BP.inspect | |
arr.toArrayBuffer = BufferToArrayBuffer | |
if (arr.byteLength !== 0) | |
arr._dataview = new DataView(arr.buffer, arr.byteOffset, arr.byteLength) | |
return arr | |
} | |
function clamp (index, len, defaultValue) { | |
if (typeof index !== 'number') return defaultValue | |
index = ~~index; // Coerce to integer. | |
if (index >= len) return len | |
if (index >= 0) return index | |
index += len | |
if (index >= 0) return index | |
return 0 | |
} | |
function coerce (length) { | |
length = ~~Math.ceil(+length) | |
return length < 0 ? 0 : length | |
} | |
function isArray (subject) { | |
return (Array.isArray || function (subject) { | |
return Object.prototype.toString.call(subject) === '[object Array]' | |
})(subject) | |
} | |
function isArrayish (subject) { | |
return isArray(subject) || Buffer.isBuffer(subject) || | |
subject && typeof subject === 'object' && | |
typeof subject.length === 'number' | |
} | |
function toHex (n) { | |
if (n < 16) return '0' + n.toString(16) | |
return n.toString(16) | |
} | |
function utf8ToBytes (str) { | |
var byteArray = [] | |
for (var i = 0; i < str.length; i++) | |
if (str.charCodeAt(i) <= 0x7F) | |
byteArray.push(str.charCodeAt(i)) | |
else { | |
var h = encodeURIComponent(str.charAt(i)).substr(1).split('%') | |
for (var j = 0; j < h.length; j++) | |
byteArray.push(parseInt(h[j], 16)) | |
} | |
return byteArray | |
} | |
function asciiToBytes (str) { | |
var byteArray = [] | |
for (var i = 0; i < str.length; i++) { | |
byteArray.push(str.charCodeAt(i) & 0xFF) | |
} | |
return byteArray | |
} | |
function base64ToBytes (str) { | |
return base64.toByteArray(str) | |
} | |
function blitBuffer (src, dst, offset, length) { | |
var pos | |
for (var i = 0; i < length; i++) { | |
if ((i + offset >= dst.length) || (i >= src.length)) | |
break | |
dst[i + offset] = src[i] | |
} | |
return i | |
} | |
function decodeUtf8Char (str) { | |
try { | |
return decodeURIComponent(str) | |
} catch (err) { | |
return String.fromCharCode(0xFFFD) // UTF 8 invalid char | |
} | |
} | |
function verifuint (value, max) { | |
assert(typeof value == 'number', 'cannot write a non-number as a number') | |
assert(value >= 0, | |
'specified a negative value for writing an unsigned value') | |
assert(value <= max, 'value is larger than maximum value for type') | |
assert(Math.floor(value) === value, 'value has a fractional component') | |
} | |
function verifsint(value, max, min) { | |
assert(typeof value == 'number', 'cannot write a non-number as a number') | |
assert(value <= max, 'value larger than maximum allowed value') | |
assert(value >= min, 'value smaller than minimum allowed value') | |
assert(Math.floor(value) === value, 'value has a fractional component') | |
} | |
function verifIEEE754(value, max, min) { | |
assert(typeof value == 'number', 'cannot write a non-number as a number') | |
assert(value <= max, 'value larger than maximum allowed value') | |
assert(value >= min, 'value smaller than minimum allowed value') | |
} | |
function assert (test, message) { | |
if (!test) throw new Error(message || 'Failed assertion') | |
} | |
},{"base64-js":3,"ieee754":4}],"native-buffer-browserify":[function(require,module,exports){ | |
module.exports=require('PcZj9L'); | |
},{}],3:[function(require,module,exports){ | |
(function (exports) { | |
'use strict'; | |
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | |
function b64ToByteArray(b64) { | |
var i, j, l, tmp, placeHolders, arr; | |
if (b64.length % 4 > 0) { | |
throw 'Invalid string. Length must be a multiple of 4'; | |
} | |
placeHolders = indexOf(b64, '='); | |
placeHolders = placeHolders > 0 ? b64.length - placeHolders : 0; | |
arr = [];//new Uint8Array(b64.length * 3 / 4 - placeHolders); | |
l = placeHolders > 0 ? b64.length - 4 : b64.length; | |
for (i = 0, j = 0; i < l; i += 4, j += 3) { | |
tmp = (indexOf(lookup, b64.charAt(i)) << 18) | (indexOf(lookup, b64.charAt(i + 1)) << 12) | (indexOf(lookup, b64.charAt(i + 2)) << 6) | indexOf(lookup, b64.charAt(i + 3)); | |
arr.push((tmp & 0xFF0000) >> 16); | |
arr.push((tmp & 0xFF00) >> 8); | |
arr.push(tmp & 0xFF); | |
} | |
if (placeHolders === 2) { | |
tmp = (indexOf(lookup, b64.charAt(i)) << 2) | (indexOf(lookup, b64.charAt(i + 1)) >> 4); | |
arr.push(tmp & 0xFF); | |
} else if (placeHolders === 1) { | |
tmp = (indexOf(lookup, b64.charAt(i)) << 10) | (indexOf(lookup, b64.charAt(i + 1)) << 4) | (indexOf(lookup, b64.charAt(i + 2)) >> 2); | |
arr.push((tmp >> 8) & 0xFF); | |
arr.push(tmp & 0xFF); | |
} | |
return arr; | |
} | |
function uint8ToBase64(uint8) { | |
var i, | |
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes | |
output = "", | |
temp, length; | |
function tripletToBase64 (num) { | |
return lookup.charAt(num >> 18 & 0x3F) + lookup.charAt(num >> 12 & 0x3F) + lookup.charAt(num >> 6 & 0x3F) + lookup.charAt(num & 0x3F); | |
}; | |
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { | |
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]); | |
output += tripletToBase64(temp); | |
} | |
switch (extraBytes) { | |
case 1: | |
temp = uint8[uint8.length - 1]; | |
output += lookup.charAt(temp >> 2); | |
output += lookup.charAt((temp << 4) & 0x3F); | |
output += '=='; | |
break; | |
case 2: | |
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]); | |
output += lookup.charAt(temp >> 10); | |
output += lookup.charAt((temp >> 4) & 0x3F); | |
output += lookup.charAt((temp << 2) & 0x3F); | |
output += '='; | |
break; | |
} | |
return output; | |
} | |
module.exports.toByteArray = b64ToByteArray; | |
module.exports.fromByteArray = uint8ToBase64; | |
}()); | |
function indexOf (arr, elt /*, from*/) { | |
var len = arr.length; | |
var from = Number(arguments[1]) || 0; | |
from = (from < 0) | |
? Math.ceil(from) | |
: Math.floor(from); | |
if (from < 0) | |
from += len; | |
for (; from < len; from++) { | |
if ((typeof arr === 'string' && arr.charAt(from) === elt) || | |
(typeof arr !== 'string' && arr[from] === elt)) { | |
return from; | |
} | |
} | |
return -1; | |
} | |
},{}],4:[function(require,module,exports){ | |
exports.read = function(buffer, offset, isLE, mLen, nBytes) { | |
var e, m, | |
eLen = nBytes * 8 - mLen - 1, | |
eMax = (1 << eLen) - 1, | |
eBias = eMax >> 1, | |
nBits = -7, | |
i = isLE ? (nBytes - 1) : 0, | |
d = isLE ? -1 : 1, | |
s = buffer[offset + i]; | |
i += d; | |
e = s & ((1 << (-nBits)) - 1); | |
s >>= (-nBits); | |
nBits += eLen; | |
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); | |
m = e & ((1 << (-nBits)) - 1); | |
e >>= (-nBits); | |
nBits += mLen; | |
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); | |
if (e === 0) { | |
e = 1 - eBias; | |
} else if (e === eMax) { | |
return m ? NaN : ((s ? -1 : 1) * Infinity); | |
} else { | |
m = m + Math.pow(2, mLen); | |
e = e - eBias; | |
} | |
return (s ? -1 : 1) * m * Math.pow(2, e - mLen); | |
}; | |
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { | |
var e, m, c, | |
eLen = nBytes * 8 - mLen - 1, | |
eMax = (1 << eLen) - 1, | |
eBias = eMax >> 1, | |
rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), | |
i = isLE ? 0 : (nBytes - 1), | |
d = isLE ? 1 : -1, | |
s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; | |
value = Math.abs(value); | |
if (isNaN(value) || value === Infinity) { | |
m = isNaN(value) ? 1 : 0; | |
e = eMax; | |
} else { | |
e = Math.floor(Math.log(value) / Math.LN2); | |
if (value * (c = Math.pow(2, -e)) < 1) { | |
e--; | |
c *= 2; | |
} | |
if (e + eBias >= 1) { | |
value += rt / c; | |
} else { | |
value += rt * Math.pow(2, 1 - eBias); | |
} | |
if (value * c >= 2) { | |
e++; | |
c /= 2; | |
} | |
if (e + eBias >= eMax) { | |
m = 0; | |
e = eMax; | |
} else if (e + eBias >= 1) { | |
m = (value * c - 1) * Math.pow(2, mLen); | |
e = e + eBias; | |
} else { | |
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); | |
e = 0; | |
} | |
} | |
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); | |
e = (e << mLen) | m; | |
eLen += mLen; | |
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); | |
buffer[offset + i - d] |= s * 128; | |
}; | |
},{}]},{},[]) | |
;;module.exports=require("native-buffer-browserify").Buffer | |
},{}],11:[function(require,module,exports){ | |
var process = module.exports = {}; | |
process.nextTick = (function () { | |
var canSetImmediate = typeof window !== 'undefined' | |
&& window.setImmediate; | |
var canPost = typeof window !== 'undefined' | |
&& window.postMessage && window.addEventListener | |
; | |
if (canSetImmediate) { | |
return function (f) { return window.setImmediate(f) }; | |
} | |
if (canPost) { | |
var queue = []; | |
window.addEventListener('message', function (ev) { | |
var source = ev.source; | |
if ((source === window || source === null) && ev.data === 'process-tick') { | |
ev.stopPropagation(); | |
if (queue.length > 0) { | |
var fn = queue.shift(); | |
fn(); | |
} | |
} | |
}, true); | |
return function nextTick(fn) { | |
queue.push(fn); | |
window.postMessage('process-tick', '*'); | |
}; | |
} | |
return function nextTick(fn) { | |
setTimeout(fn, 0); | |
}; | |
})(); | |
process.title = 'browser'; | |
process.browser = true; | |
process.env = {}; | |
process.argv = []; | |
process.binding = function (name) { | |
throw new Error('process.binding is not supported'); | |
} | |
process.cwd = function () { return '/' }; | |
process.chdir = function (dir) { | |
throw new Error('process.chdir is not supported'); | |
}; | |
},{}],12:[function(require,module,exports){ | |
var base64 = require('base64-js') | |
var ieee754 = require('ieee754') | |
exports.Buffer = Buffer | |
exports.SlowBuffer = Buffer | |
exports.INSPECT_MAX_BYTES = 50 | |
Buffer.poolSize = 8192 | |
Buffer._useTypedArrays = (function () { | |
if (typeof Uint8Array === 'undefined' || typeof ArrayBuffer === 'undefined') | |
return false | |
try { | |
var arr = new Uint8Array(0) | |
arr.foo = function () { return 42 } | |
return 42 === arr.foo() && | |
typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray` | |
} catch (e) { | |
return false | |
} | |
})() | |
function Buffer (subject, encoding, noZero) { | |
if (!(this instanceof Buffer)) | |
return new Buffer(subject, encoding, noZero) | |
var type = typeof subject | |
if (encoding === 'base64' && type === 'string') { | |
subject = stringtrim(subject) | |
while (subject.length % 4 !== 0) { | |
subject = subject + '=' | |
} | |
} | |
var length | |
if (type === 'number') | |
length = coerce(subject) | |
else if (type === 'string') | |
length = Buffer.byteLength(subject, encoding) | |
else if (type === 'object') | |
length = coerce(subject.length) // Assume object is an array | |
else | |
throw new Error('First argument needs to be a number, array or string.') | |
var buf | |
if (Buffer._useTypedArrays) { | |
buf = augment(new Uint8Array(length)) | |
} else { | |
buf = this | |
buf.length = length | |
buf._isBuffer = true | |
} | |
var i | |
if (typeof Uint8Array === 'function' && subject instanceof Uint8Array) { | |
buf.set(subject) | |
} else if (isArrayish(subject)) { | |
for (i = 0; i < length; i++) { | |
if (Buffer.isBuffer(subject)) | |
buf[i] = subject.readUInt8(i) | |
else | |
buf[i] = subject[i] | |
} | |
} else if (type === 'string') { | |
buf.write(subject, 0, encoding) | |
} else if (type === 'number' && !Buffer._useTypedArrays && !noZero) { | |
for (i = 0; i < length; i++) { | |
buf[i] = 0 | |
} | |
} | |
return buf | |
} | |
Buffer.isEncoding = function (encoding) { | |
switch (String(encoding).toLowerCase()) { | |
case 'hex': | |
case 'utf8': | |
case 'utf-8': | |
case 'ascii': | |
case 'binary': | |
case 'base64': | |
case 'raw': | |
return true | |
default: | |
return false | |
} | |
} | |
Buffer.isBuffer = function (b) { | |
return (b != null && b._isBuffer) || false | |
} | |
Buffer.byteLength = function (str, encoding) { | |
switch (encoding || 'utf8') { | |
case 'hex': | |
return str.length / 2 | |
case 'utf8': | |
case 'utf-8': | |
return utf8ToBytes(str).length | |
case 'ascii': | |
case 'binary': | |
return str.length | |
case 'base64': | |
return base64ToBytes(str).length | |
default: | |
throw new Error('Unknown encoding') | |
} | |
} | |
Buffer.concat = function (list, totalLength) { | |
assert(isArray(list), 'Usage: Buffer.concat(list, [totalLength])\n' + | |
'list should be an Array.') | |
if (list.length === 0) { | |
return new Buffer(0) | |
} else if (list.length === 1) { | |
return list[0] | |
} | |
var i | |
if (typeof totalLength !== 'number') { | |
totalLength = 0 | |
for (i = 0; i < list.length; i++) { | |
totalLength += list[i].length | |
} | |
} | |
var buf = new Buffer(totalLength) | |
var pos = 0 | |
for (i = 0; i < list.length; i++) { | |
var item = list[i] | |
item.copy(buf, pos) | |
pos += item.length | |
} | |
return buf | |
} | |
function _hexWrite (buf, string, offset, length) { | |
offset = Number(offset) || 0 | |
var remaining = buf.length - offset | |
if (!length) { | |
length = remaining | |
} else { | |
length = Number(length) | |
if (length > remaining) { | |
length = remaining | |
} | |
} | |
var strLen = string.length | |
assert(strLen % 2 === 0, 'Invalid hex string') | |
if (length > strLen / 2) { | |
length = strLen / 2 | |
} | |
for (var i = 0; i < length; i++) { | |
var byte = parseInt(string.substr(i * 2, 2), 16) | |
assert(!isNaN(byte), 'Invalid hex string') | |
buf[offset + i] = byte | |
} | |
Buffer._charsWritten = i * 2 | |
return i | |
} | |
function _utf8Write (buf, string, offset, length) { | |
var bytes, pos | |
return Buffer._charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length) | |
} | |
function _asciiWrite (buf, string, offset, length) { | |
var bytes, pos | |
return Buffer._charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length) | |
} | |
function _binaryWrite (buf, string, offset, length) { | |
return _asciiWrite(buf, string, offset, length) | |
} | |
function _base64Write (buf, string, offset, length) { | |
var bytes, pos | |
return Buffer._charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length) | |
} | |
Buffer.prototype.write = function (string, offset, length, encoding) { | |
if (isFinite(offset)) { | |
if (!isFinite(length)) { | |
encoding = length | |
length = undefined | |
} | |
} else { // legacy | |
var swap = encoding | |
encoding = offset | |
offset = length | |
length = swap | |
} | |
offset = Number(offset) || 0 | |
var remaining = this.length - offset | |
if (!length) { | |
length = remaining | |
} else { | |
length = Number(length) | |
if (length > remaining) { | |
length = remaining | |
} | |
} | |
encoding = String(encoding || 'utf8').toLowerCase() | |
switch (encoding) { | |
case 'hex': | |
return _hexWrite(this, string, offset, length) | |
case 'utf8': | |
case 'utf-8': | |
return _utf8Write(this, string, offset, length) | |
case 'ascii': | |
return _asciiWrite(this, string, offset, length) | |
case 'binary': | |
return _binaryWrite(this, string, offset, length) | |
case 'base64': | |
return _base64Write(this, string, offset, length) | |
default: | |
throw new Error('Unknown encoding') | |
} | |
} | |
Buffer.prototype.toString = function (encoding, start, end) { | |
var self = this | |
encoding = String(encoding || 'utf8').toLowerCase() | |
start = Number(start) || 0 | |
end = (end !== undefined) | |
? Number(end) | |
: end = self.length | |
if (end === start) | |
return '' | |
switch (encoding) { | |
case 'hex': | |
return _hexSlice(self, start, end) | |
case 'utf8': | |
case 'utf-8': | |
return _utf8Slice(self, start, end) | |
case 'ascii': | |
return _asciiSlice(self, start, end) | |
case 'binary': | |
return _binarySlice(self, start, end) | |
case 'base64': | |
return _base64Slice(self, start, end) | |
default: | |
throw new Error('Unknown encoding') | |
} | |
} | |
Buffer.prototype.toJSON = function () { | |
return { | |
type: 'Buffer', | |
data: Array.prototype.slice.call(this._arr || this, 0) | |
} | |
} | |
Buffer.prototype.copy = function (target, target_start, start, end) { | |
var source = this | |
if (!start) start = 0 | |
if (!end && end !== 0) end = this.length | |
if (!target_start) target_start = 0 | |
if (end === start) return | |
if (target.length === 0 || source.length === 0) return | |
assert(end >= start, 'sourceEnd < sourceStart') | |
assert(target_start >= 0 && target_start < target.length, | |
'targetStart out of bounds') | |
assert(start >= 0 && start < source.length, 'sourceStart out of bounds') | |
assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds') | |
if (end > this.length) | |
end = this.length | |
if (target.length - target_start < end - start) | |
end = target.length - target_start + start | |
for (var i = 0; i < end - start; i++) | |
target[i + target_start] = this[i + start] | |
} | |
function _base64Slice (buf, start, end) { | |
if (start === 0 && end === buf.length) { | |
return base64.fromByteArray(buf) | |
} else { | |
return base64.fromByteArray(buf.slice(start, end)) | |
} | |
} | |
function _utf8Slice (buf, start, end) { | |
var res = '' | |
var tmp = '' | |
end = Math.min(buf.length, end) | |
for (var i = start; i < end; i++) { | |
if (buf[i] <= 0x7F) { | |
res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) | |
tmp = '' | |
} else { | |
tmp += '%' + buf[i].toString(16) | |
} | |
} | |
return res + decodeUtf8Char(tmp) | |
} | |
function _asciiSlice (buf, start, end) { | |
var ret = '' | |
end = Math.min(buf.length, end) | |
for (var i = start; i < end; i++) | |
ret += String.fromCharCode(buf[i]) | |
return ret | |
} | |
function _binarySlice (buf, start, end) { | |
return _asciiSlice(buf, start, end) | |
} | |
function _hexSlice (buf, start, end) { | |
var len = buf.length | |
if (!start || start < 0) start = 0 | |
if (!end || end < 0 || end > len) end = len | |
var out = '' | |
for (var i = start; i < end; i++) { | |
out += toHex(buf[i]) | |
} | |
return out | |
} | |
Buffer.prototype.slice = function (start, end) { | |
var len = this.length | |
start = clamp(start, len, 0) | |
end = clamp(end, len, len) | |
if (Buffer._useTypedArrays) { | |
return augment(this.subarray(start, end)) | |
} else { | |
var sliceLen = end - start | |
var newBuf = new Buffer(sliceLen, undefined, true) | |
for (var i = 0; i < sliceLen; i++) { | |
newBuf[i] = this[i + start] | |
} | |
return newBuf | |
} | |
} | |
Buffer.prototype.readUInt8 = function (offset, noAssert) { | |
var buf = this | |
if (!noAssert) { | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset < buf.length, 'Trying to read beyond buffer length') | |
} | |
if (offset >= buf.length) | |
return | |
return buf[offset] | |
} | |
function _readUInt16 (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
var val | |
if (littleEndian) { | |
val = buf[offset] | |
if (offset + 1 < len) | |
val |= buf[offset + 1] << 8 | |
} else { | |
val = buf[offset] << 8 | |
if (offset + 1 < len) | |
val |= buf[offset + 1] | |
} | |
return val | |
} | |
Buffer.prototype.readUInt16LE = function (offset, noAssert) { | |
return _readUInt16(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readUInt16BE = function (offset, noAssert) { | |
return _readUInt16(this, offset, false, noAssert) | |
} | |
function _readUInt32 (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
var val | |
if (littleEndian) { | |
if (offset + 2 < len) | |
val = buf[offset + 2] << 16 | |
if (offset + 1 < len) | |
val |= buf[offset + 1] << 8 | |
val |= buf[offset] | |
if (offset + 3 < len) | |
val = val + (buf[offset + 3] << 24 >>> 0) | |
} else { | |
if (offset + 1 < len) | |
val = buf[offset + 1] << 16 | |
if (offset + 2 < len) | |
val |= buf[offset + 2] << 8 | |
if (offset + 3 < len) | |
val |= buf[offset + 3] | |
val = val + (buf[offset] << 24 >>> 0) | |
} | |
return val | |
} | |
Buffer.prototype.readUInt32LE = function (offset, noAssert) { | |
return _readUInt32(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readUInt32BE = function (offset, noAssert) { | |
return _readUInt32(this, offset, false, noAssert) | |
} | |
Buffer.prototype.readInt8 = function (offset, noAssert) { | |
var buf = this | |
if (!noAssert) { | |
assert(offset !== undefined && offset !== null, | |
'missing offset') | |
assert(offset < buf.length, 'Trying to read beyond buffer length') | |
} | |
if (offset >= buf.length) | |
return | |
var neg = buf[offset] & 0x80 | |
if (neg) | |
return (0xff - buf[offset] + 1) * -1 | |
else | |
return buf[offset] | |
} | |
function _readInt16 (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
var val = _readUInt16(buf, offset, littleEndian, true) | |
var neg = val & 0x8000 | |
if (neg) | |
return (0xffff - val + 1) * -1 | |
else | |
return val | |
} | |
Buffer.prototype.readInt16LE = function (offset, noAssert) { | |
return _readInt16(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readInt16BE = function (offset, noAssert) { | |
return _readInt16(this, offset, false, noAssert) | |
} | |
function _readInt32 (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
var val = _readUInt32(buf, offset, littleEndian, true) | |
var neg = val & 0x80000000 | |
if (neg) | |
return (0xffffffff - val + 1) * -1 | |
else | |
return val | |
} | |
Buffer.prototype.readInt32LE = function (offset, noAssert) { | |
return _readInt32(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readInt32BE = function (offset, noAssert) { | |
return _readInt32(this, offset, false, noAssert) | |
} | |
function _readFloat (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') | |
} | |
return ieee754.read(buf, offset, littleEndian, 23, 4) | |
} | |
Buffer.prototype.readFloatLE = function (offset, noAssert) { | |
return _readFloat(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readFloatBE = function (offset, noAssert) { | |
return _readFloat(this, offset, false, noAssert) | |
} | |
function _readDouble (buf, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset + 7 < buf.length, 'Trying to read beyond buffer length') | |
} | |
return ieee754.read(buf, offset, littleEndian, 52, 8) | |
} | |
Buffer.prototype.readDoubleLE = function (offset, noAssert) { | |
return _readDouble(this, offset, true, noAssert) | |
} | |
Buffer.prototype.readDoubleBE = function (offset, noAssert) { | |
return _readDouble(this, offset, false, noAssert) | |
} | |
Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { | |
var buf = this | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset < buf.length, 'trying to write beyond buffer length') | |
verifuint(value, 0xff) | |
} | |
if (offset >= buf.length) return | |
buf[offset] = value | |
} | |
function _writeUInt16 (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 1 < buf.length, 'trying to write beyond buffer length') | |
verifuint(value, 0xffff) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) { | |
buf[offset + i] = | |
(value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> | |
(littleEndian ? i : 1 - i) * 8 | |
} | |
} | |
Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) { | |
_writeUInt16(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) { | |
_writeUInt16(this, value, offset, false, noAssert) | |
} | |
function _writeUInt32 (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'trying to write beyond buffer length') | |
verifuint(value, 0xffffffff) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) { | |
buf[offset + i] = | |
(value >>> (littleEndian ? i : 3 - i) * 8) & 0xff | |
} | |
} | |
Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) { | |
_writeUInt32(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) { | |
_writeUInt32(this, value, offset, false, noAssert) | |
} | |
Buffer.prototype.writeInt8 = function (value, offset, noAssert) { | |
var buf = this | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset < buf.length, 'Trying to write beyond buffer length') | |
verifsint(value, 0x7f, -0x80) | |
} | |
if (offset >= buf.length) | |
return | |
if (value >= 0) | |
buf.writeUInt8(value, offset, noAssert) | |
else | |
buf.writeUInt8(0xff + value + 1, offset, noAssert) | |
} | |
function _writeInt16 (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 1 < buf.length, 'Trying to write beyond buffer length') | |
verifsint(value, 0x7fff, -0x8000) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (value >= 0) | |
_writeUInt16(buf, value, offset, littleEndian, noAssert) | |
else | |
_writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert) | |
} | |
Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { | |
_writeInt16(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeInt16BE = function (value, offset, noAssert) { | |
_writeInt16(this, value, offset, false, noAssert) | |
} | |
function _writeInt32 (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') | |
verifsint(value, 0x7fffffff, -0x80000000) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
if (value >= 0) | |
_writeUInt32(buf, value, offset, littleEndian, noAssert) | |
else | |
_writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert) | |
} | |
Buffer.prototype.writeInt32LE = function (value, offset, noAssert) { | |
_writeInt32(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeInt32BE = function (value, offset, noAssert) { | |
_writeInt32(this, value, offset, false, noAssert) | |
} | |
function _writeFloat (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') | |
verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
ieee754.write(buf, value, offset, littleEndian, 23, 4) | |
} | |
Buffer.prototype.writeFloatLE = function (value, offset, noAssert) { | |
_writeFloat(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeFloatBE = function (value, offset, noAssert) { | |
_writeFloat(this, value, offset, false, noAssert) | |
} | |
function _writeDouble (buf, value, offset, littleEndian, noAssert) { | |
if (!noAssert) { | |
assert(value !== undefined && value !== null, 'missing value') | |
assert(typeof littleEndian === 'boolean', 'missing or invalid endian') | |
assert(offset !== undefined && offset !== null, 'missing offset') | |
assert(offset + 7 < buf.length, | |
'Trying to write beyond buffer length') | |
verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308) | |
} | |
var len = buf.length | |
if (offset >= len) | |
return | |
ieee754.write(buf, value, offset, littleEndian, 52, 8) | |
} | |
Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) { | |
_writeDouble(this, value, offset, true, noAssert) | |
} | |
Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { | |
_writeDouble(this, value, offset, false, noAssert) | |
} | |
Buffer.prototype.fill = function (value, start, end) { | |
if (!value) value = 0 | |
if (!start) start = 0 | |
if (!end) end = this.length | |
if (typeof value === 'string') { | |
value = value.charCodeAt(0) | |
} | |
assert(typeof value === 'number' && !isNaN(value), 'value is not a number') | |
assert(end >= start, 'end < start') | |
if (end === start) return | |
if (this.length === 0) return | |
assert(start >= 0 && start < this.length, 'start out of bounds') | |
assert(end >= 0 && end <= this.length, 'end out of bounds') | |
for (var i = start; i < end; i++) { | |
this[i] = value | |
} | |
} | |
Buffer.prototype.inspect = function () { | |
var out = [] | |
var len = this.length | |
for (var i = 0; i < len; i++) { | |
out[i] = toHex(this[i]) | |
if (i === exports.INSPECT_MAX_BYTES) { | |
out[i + 1] = '...' | |
break | |
} | |
} | |
return '<Buffer ' + out.join(' ') + '>' | |
} | |
function BufferToArrayBuffer () { | |
return (new Buffer(this)).buffer | |
} | |
function stringtrim (str) { | |
if (str.trim) return str.trim() | |
return str.replace(/^\s+|\s+$/g, '') | |
} | |
var BP = Buffer.prototype | |
function augment (arr) { | |
arr._isBuffer = true | |
arr.write = BP.write | |
arr.toString = BP.toString | |
arr.toLocaleString = BP.toString | |
arr.toJSON = BP.toJSON | |
arr.copy = BP.copy | |
arr.slice = BP.slice | |
arr.readUInt8 = BP.readUInt8 | |
arr.readUInt16LE = BP.readUInt16LE | |
arr.readUInt16BE = BP.readUInt16BE | |
arr.readUInt32LE = BP.readUInt32LE | |
arr.readUInt32BE = BP.readUInt32BE | |
arr.readInt8 = BP.readInt8 | |
arr.readInt16LE = BP.readInt16LE | |
arr.readInt16BE = BP.readInt16BE | |
arr.readInt32LE = BP.readInt32LE | |
arr.readInt32BE = BP.readInt32BE | |
arr.readFloatLE = BP.readFloatLE | |
arr.readFloatBE = BP.readFloatBE | |
arr.readDoubleLE = BP.readDoubleLE | |
arr.readDoubleBE = BP.readDoubleBE | |
arr.writeUInt8 = BP.writeUInt8 | |
arr.writeUInt16LE = BP.writeUInt16LE | |
arr.writeUInt16BE = BP.writeUInt16BE | |
arr.writeUInt32LE = BP.writeUInt32LE | |
arr.writeUInt32BE = BP.writeUInt32BE | |
arr.writeInt8 = BP.writeInt8 | |
arr.writeInt16LE = BP.writeInt16LE | |
arr.writeInt16BE = BP.writeInt16BE | |
arr.writeInt32LE = BP.writeInt32LE | |
arr.writeInt32BE = BP.writeInt32BE | |
arr.writeFloatLE = BP.writeFloatLE | |
arr.writeFloatBE = BP.writeFloatBE | |
arr.writeDoubleLE = BP.writeDoubleLE | |
arr.writeDoubleBE = BP.writeDoubleBE | |
arr.fill = BP.fill | |
arr.inspect = BP.inspect | |
arr.toArrayBuffer = BufferToArrayBuffer | |
return arr | |
} | |
function clamp (index, len, defaultValue) { | |
if (typeof index !== 'number') return defaultValue | |
index = ~~index; // Coerce to integer. | |
if (index >= len) return len | |
if (index >= 0) return index | |
index += len | |
if (index >= 0) return index | |
return 0 | |
} | |
function coerce (length) { | |
length = ~~Math.ceil(+length) | |
return length < 0 ? 0 : length | |
} | |
function isArray (subject) { | |
return (Array.isArray || function (subject) { | |
return Object.prototype.toString.call(subject) === '[object Array]' | |
})(subject) | |
} | |
function isArrayish (subject) { | |
return isArray(subject) || Buffer.isBuffer(subject) || | |
subject && typeof subject === 'object' && | |
typeof subject.length === 'number' | |
} | |
function toHex (n) { | |
if (n < 16) return '0' + n.toString(16) | |
return n.toString(16) | |
} | |
function utf8ToBytes (str) { | |
var byteArray = [] | |
for (var i = 0; i < str.length; i++) { | |
var b = str.charCodeAt(i) | |
if (b <= 0x7F) | |
byteArray.push(str.charCodeAt(i)) | |
else { | |
var start = i | |
if (b >= 0xD800 && b <= 0xDFFF) i++ | |
var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%') | |
for (var j = 0; j < h.length; j++) | |
byteArray.push(parseInt(h[j], 16)) | |
} | |
} | |
return byteArray | |
} | |
function asciiToBytes (str) { | |
var byteArray = [] | |
for (var i = 0; i < str.length; i++) { | |
byteArray.push(str.charCodeAt(i) & 0xFF) | |
} | |
return byteArray | |
} | |
function base64ToBytes (str) { | |
return base64.toByteArray(str) | |
} | |
function blitBuffer (src, dst, offset, length) { | |
var pos | |
for (var i = 0; i < length; i++) { | |
if ((i + offset >= dst.length) || (i >= src.length)) | |
break | |
dst[i + offset] = src[i] | |
} | |
return i | |
} | |
function decodeUtf8Char (str) { | |
try { | |
return decodeURIComponent(str) | |
} catch (err) { | |
return String.fromCharCode(0xFFFD) // UTF 8 invalid char | |
} | |
} | |
function verifuint (value, max) { | |
assert(typeof value == 'number', 'cannot write a non-number as a number') | |
assert(value >= 0, | |
'specified a negative value for writing an unsigned value') | |
assert(value <= max, 'value is larger than maximum value for type') | |
assert(Math.floor(value) === value, 'value has a fractional component') | |
} | |
function verifsint(value, max, min) { | |
assert(typeof value == 'number', 'cannot write a non-number as a number') | |
assert(value <= max, 'value larger than maximum allowed value') | |
assert(value >= min, 'value smaller than minimum allowed value') | |
assert(Math.floor(value) === value, 'value has a fractional component') | |
} | |
function verifIEEE754(value, max, min) { | |
assert(typeof value == 'number', 'cannot write a non-number as a number') | |
assert(value <= max, 'value larger than maximum allowed value') | |
assert(value >= min, 'value smaller than minimum allowed value') | |
} | |
function assert (test, message) { | |
if (!test) throw new Error(message || 'Failed assertion') | |
} | |
},{"base64-js":13,"ieee754":14}],13:[function(require,module,exports){ | |
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | |
;(function (exports) { | |
'use strict'; | |
var Arr = (typeof Uint8Array !== 'undefined') | |
? Uint8Array | |
: Array | |
var ZERO = '0'.charCodeAt(0) | |
var PLUS = '+'.charCodeAt(0) | |
var SLASH = '/'.charCodeAt(0) | |
var NUMBER = '0'.charCodeAt(0) | |
var LOWER = 'a'.charCodeAt(0) | |
var UPPER = 'A'.charCodeAt(0) | |
function decode (elt) { | |
var code = elt.charCodeAt(0) | |
if (code === PLUS) | |
return 62 // '+' | |
if (code === SLASH) | |
return 63 // '/' | |
if (code < NUMBER) | |
return -1 //no match | |
if (code < NUMBER + 10) | |
return code - NUMBER + 26 + 26 | |
if (code < UPPER + 26) | |
return code - UPPER | |
if (code < LOWER + 26) | |
return code - LOWER + 26 | |
} | |
function b64ToByteArray (b64) { | |
var i, j, l, tmp, placeHolders, arr | |
if (b64.length % 4 > 0) { | |
throw new Error('Invalid string. Length must be a multiple of 4') | |
} | |
var len = b64.length | |
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 | |
arr = new Arr(b64.length * 3 / 4 - placeHolders) | |
l = placeHolders > 0 ? b64.length - 4 : b64.length | |
var L = 0 | |
function push (v) { | |
arr[L++] = v | |
} | |
for (i = 0, j = 0; i < l; i += 4, j += 3) { | |
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) | |
push((tmp & 0xFF0000) >> 16) | |
push((tmp & 0xFF00) >> 8) | |
push(tmp & 0xFF) | |
} | |
if (placeHolders === 2) { | |
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) | |
push(tmp & 0xFF) | |
} else if (placeHolders === 1) { | |
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) | |
push((tmp >> 8) & 0xFF) | |
push(tmp & 0xFF) | |
} | |
return arr | |
} | |
function uint8ToBase64 (uint8) { | |
var i, | |
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes | |
output = "", | |
temp, length | |
function encode (num) { | |
return lookup.charAt(num) | |
} | |
function tripletToBase64 (num) { | |
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) | |
} | |
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { | |
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) | |
output += tripletToBase64(temp) | |
} | |
switch (extraBytes) { | |
case 1: | |
temp = uint8[uint8.length - 1] | |
output += encode(temp >> 2) | |
output += encode((temp << 4) & 0x3F) | |
output += '==' | |
break | |
case 2: | |
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) | |
output += encode(temp >> 10) | |
output += encode((temp >> 4) & 0x3F) | |
output += encode((temp << 2) & 0x3F) | |
output += '=' | |
break | |
} | |
return output | |
} | |
module.exports.toByteArray = b64ToByteArray | |
module.exports.fromByteArray = uint8ToBase64 | |
}()) | |
},{}],14:[function(require,module,exports){ | |
exports.read = function(buffer, offset, isLE, mLen, nBytes) { | |
var e, m, | |
eLen = nBytes * 8 - mLen - 1, | |
eMax = (1 << eLen) - 1, | |
eBias = eMax >> 1, | |
nBits = -7, | |
i = isLE ? (nBytes - 1) : 0, | |
d = isLE ? -1 : 1, | |
s = buffer[offset + i]; | |
i += d; | |
e = s & ((1 << (-nBits)) - 1); | |
s >>= (-nBits); | |
nBits += eLen; | |
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); | |
m = e & ((1 << (-nBits)) - 1); | |
e >>= (-nBits); | |
nBits += mLen; | |
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); | |
if (e === 0) { | |
e = 1 - eBias; | |
} else if (e === eMax) { | |
return m ? NaN : ((s ? -1 : 1) * Infinity); | |
} else { | |
m = m + Math.pow(2, mLen); | |
e = e - eBias; | |
} | |
return (s ? -1 : 1) * m * Math.pow(2, e - mLen); | |
}; | |
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { | |
var e, m, c, | |
eLen = nBytes * 8 - mLen - 1, | |
eMax = (1 << eLen) - 1, | |
eBias = eMax >> 1, | |
rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), | |
i = isLE ? 0 : (nBytes - 1), | |
d = isLE ? 1 : -1, | |
s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; | |
value = Math.abs(value); | |
if (isNaN(value) || value === Infinity) { | |
m = isNaN(value) ? 1 : 0; | |
e = eMax; | |
} else { | |
e = Math.floor(Math.log(value) / Math.LN2); | |
if (value * (c = Math.pow(2, -e)) < 1) { | |
e--; | |
c *= 2; | |
} | |
if (e + eBias >= 1) { | |
value += rt / c; | |
} else { | |
value += rt * Math.pow(2, 1 - eBias); | |
} | |
if (value * c >= 2) { | |
e++; | |
c /= 2; | |
} | |
if (e + eBias >= eMax) { | |
m = 0; | |
e = eMax; | |
} else if (e + eBias >= 1) { | |
m = (value * c - 1) * Math.pow(2, mLen); | |
e = e + eBias; | |
} else { | |
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); | |
e = 0; | |
} | |
} | |
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); | |
e = (e << mLen) | m; | |
eLen += mLen; | |
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); | |
buffer[offset + i - d] |= s * 128; | |
}; | |
},{}],15:[function(require,module,exports){ | |
var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};/*! http://mths.be/punycode v1.2.3 by @mathias */ | |
;(function(root) { | |
var freeExports = typeof exports == 'object' && exports; | |
var freeModule = typeof module == 'object' && module && | |
module.exports == freeExports && module; | |
var freeGlobal = typeof global == 'object' && global; | |
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { | |
root = freeGlobal; | |
} | |
var punycode, | |
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 | |
base = 36, | |
tMin = 1, | |
tMax = 26, | |
skew = 38, | |
damp = 700, | |
initialBias = 72, | |
initialN = 128, // 0x80 | |
delimiter = '-', // '\x2D' | |
regexPunycode = /^xn--/, | |
regexNonASCII = /[^ -~]/, // unprintable ASCII chars + non-ASCII chars | |
regexSeparators = /\x2E|\u3002|\uFF0E|\uFF61/g, // RFC 3490 separators | |
errors = { | |
'overflow': 'Overflow: input needs wider integers to process', | |
'not-basic': 'Illegal input >= 0x80 (not a basic code point)', | |
'invalid-input': 'Invalid input' | |
}, | |
baseMinusTMin = base - tMin, | |
floor = Math.floor, | |
stringFromCharCode = String.fromCharCode, | |
key; | |
function error(type) { | |
throw RangeError(errors[type]); | |
} | |
function map(array, fn) { | |
var length = array.length; | |
while (length--) { | |
array[length] = fn(array[length]); | |
} | |
return array; | |
} | |
function mapDomain(string, fn) { | |
return map(string.split(regexSeparators), fn).join('.'); | |
} | |
function ucs2decode(string) { | |
var output = [], | |
counter = 0, | |
length = string.length, | |
value, | |
extra; | |
while (counter < length) { | |
value = string.charCodeAt(counter++); | |
if (value >= 0xD800 && value <= 0xDBFF && counter < length) { | |
extra = string.charCodeAt(counter++); | |
if ((extra & 0xFC00) == 0xDC00) { // low surrogate | |
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); | |
} else { | |
output.push(value); | |
counter--; | |
} | |
} else { | |
output.push(value); | |
} | |
} | |
return output; | |
} | |
function ucs2encode(array) { | |
return map(array, function(value) { | |
var output = ''; | |
if (value > 0xFFFF) { | |
value -= 0x10000; | |
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); | |
value = 0xDC00 | value & 0x3FF; | |
} | |
output += stringFromCharCode(value); | |
return output; | |
}).join(''); | |
} | |
function basicToDigit(codePoint) { | |
if (codePoint - 48 < 10) { | |
return codePoint - 22; | |
} | |
if (codePoint - 65 < 26) { | |
return codePoint - 65; | |
} | |
if (codePoint - 97 < 26) { | |
return codePoint - 97; | |
} | |
return base; | |
} | |
function digitToBasic(digit, flag) { | |
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); | |
} | |
function adapt(delta, numPoints, firstTime) { | |
var k = 0; | |
delta = firstTime ? floor(delta / damp) : delta >> 1; | |
delta += floor(delta / numPoints); | |
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { | |
delta = floor(delta / baseMinusTMin); | |
} | |
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); | |
} | |
function decode(input) { | |
var output = [], | |
inputLength = input.length, | |
out, | |
i = 0, | |
n = initialN, | |
bias = initialBias, | |
basic, | |
j, | |
index, | |
oldi, | |
w, | |
k, | |
digit, | |
t, | |
length, | |
baseMinusT; | |
basic = input.lastIndexOf(delimiter); | |
if (basic < 0) { | |
basic = 0; | |
} | |
for (j = 0; j < basic; ++j) { | |
if (input.charCodeAt(j) >= 0x80) { | |
error('not-basic'); | |
} | |
output.push(input.charCodeAt(j)); | |
} | |
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { | |
for (oldi = i, w = 1, k = base; /* no condition */; k += base) { | |
if (index >= inputLength) { | |
error('invalid-input'); | |
} | |
digit = basicToDigit(input.charCodeAt(index++)); | |
if (digit >= base || digit > floor((maxInt - i) / w)) { | |
error('overflow'); | |
} | |
i += digit * w; | |
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); | |
if (digit < t) { | |
break; | |
} | |
baseMinusT = base - t; | |
if (w > floor(maxInt / baseMinusT)) { | |
error('overflow'); | |
} | |
w *= baseMinusT; | |
} | |
out = output.length + 1; | |
bias = adapt(i - oldi, out, oldi == 0); | |
if (floor(i / out) > maxInt - n) { | |
error('overflow'); | |
} | |
n += floor(i / out); | |
i %= out; | |
output.splice(i++, 0, n); | |
} | |
return ucs2encode(output); | |
} | |
function encode(input) { | |
var n, | |
delta, | |
handledCPCount, | |
basicLength, | |
bias, | |
j, | |
m, | |
q, | |
k, | |
t, | |
currentValue, | |
output = [], | |
inputLength, | |
handledCPCountPlusOne, | |
baseMinusT, | |
qMinusT; | |
input = ucs2decode(input); | |
inputLength = input.length; | |
n = initialN; | |
delta = 0; | |
bias = initialBias; | |
for (j = 0; j < inputLength; ++j) { | |
currentValue = input[j]; | |
if (currentValue < 0x80) { | |
output.push(stringFromCharCode(currentValue)); | |
} | |
} | |
handledCPCount = basicLength = output.length; | |
if (basicLength) { | |
output.push(delimiter); | |
} | |
while (handledCPCount < inputLength) { | |
for (m = maxInt, j = 0; j < inputLength; ++j) { | |
currentValue = input[j]; | |
if (currentValue >= n && currentValue < m) { | |
m = currentValue; | |
} | |
} | |
handledCPCountPlusOne = handledCPCount + 1; | |
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { | |
error('overflow'); | |
} | |
delta += (m - n) * handledCPCountPlusOne; | |
n = m; | |
for (j = 0; j < inputLength; ++j) { | |
currentValue = input[j]; | |
if (currentValue < n && ++delta > maxInt) { | |
error('overflow'); | |
} | |
if (currentValue == n) { | |
for (q = delta, k = base; /* no condition */; k += base) { | |
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); | |
if (q < t) { | |
break; | |
} | |
qMinusT = q - t; | |
baseMinusT = base - t; | |
output.push( | |
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) | |
); | |
q = floor(qMinusT / baseMinusT); | |
} | |
output.push(stringFromCharCode(digitToBasic(q, 0))); | |
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); | |
delta = 0; | |
++handledCPCount; | |
} | |
} | |
++delta; | |
++n; | |
} | |
return output.join(''); | |
} | |
function toUnicode(domain) { | |
return mapDomain(domain, function(string) { | |
return regexPunycode.test(string) | |
? decode(string.slice(4).toLowerCase()) | |
: string; | |
}); | |
} | |
function toASCII(domain) { | |
return mapDomain(domain, function(string) { | |
return regexNonASCII.test(string) | |
? 'xn--' + encode(string) | |
: string; | |
}); | |
} | |
punycode = { | |
'version': '1.2.3', | |
'ucs2': { | |
'decode': ucs2decode, | |
'encode': ucs2encode | |
}, | |
'decode': decode, | |
'encode': encode, | |
'toASCII': toASCII, | |
'toUnicode': toUnicode | |
}; | |
if ( | |
typeof define == 'function' && | |
typeof define.amd == 'object' && | |
define.amd | |
) { | |
define(function() { | |
return punycode; | |
}); | |
} else if (freeExports && !freeExports.nodeType) { | |
if (freeModule) { // in Node.js or RingoJS v0.8.0+ | |
freeModule.exports = punycode; | |
} else { // in Narwhal or RingoJS v0.7.0- | |
for (key in punycode) { | |
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); | |
} | |
} | |
} else { // in Rhino or a web browser | |
root.punycode = punycode; | |
} | |
}(this)); | |
},{}],16:[function(require,module,exports){ | |
'use strict'; | |
function hasOwnProperty(obj, prop) { | |
return Object.prototype.hasOwnProperty.call(obj, prop); | |
} | |
module.exports = function(qs, sep, eq, options) { | |
sep = sep || '&'; | |
eq = eq || '='; | |
var obj = {}; | |
if (typeof qs !== 'string' || qs.length === 0) { | |
return obj; | |
} | |
var regexp = /\+/g; | |
qs = qs.split(sep); | |
var maxKeys = 1000; | |
if (options && typeof options.maxKeys === 'number') { | |
maxKeys = options.maxKeys; | |
} | |
var len = qs.length; | |
if (maxKeys > 0 && len > maxKeys) { | |
len = maxKeys; | |
} | |
for (var i = 0; i < len; ++i) { | |
var x = qs[i].replace(regexp, '%20'), | |
idx = x.indexOf(eq), | |
kstr, vstr, k, v; | |
if (idx >= 0) { | |
kstr = x.substr(0, idx); | |
vstr = x.substr(idx + 1); | |
} else { | |
kstr = x; | |
vstr = ''; | |
} | |
k = decodeURIComponent(kstr); | |
v = decodeURIComponent(vstr); | |
if (!hasOwnProperty(obj, k)) { | |
obj[k] = v; | |
} else if (isArray(obj[k])) { | |
obj[k].push(v); | |
} else { | |
obj[k] = [obj[k], v]; | |
} | |
} | |
return obj; | |
}; | |
var isArray = Array.isArray || function (xs) { | |
return Object.prototype.toString.call(xs) === '[object Array]'; | |
}; | |
},{}],17:[function(require,module,exports){ | |
'use strict'; | |
var stringifyPrimitive = function(v) { | |
switch (typeof v) { | |
case 'string': | |
return v; | |
case 'boolean': | |
return v ? 'true' : 'false'; | |
case 'number': | |
return isFinite(v) ? v : ''; | |
default: | |
return ''; | |
} | |
}; | |
module.exports = function(obj, sep, eq, name) { | |
sep = sep || '&'; | |
eq = eq || '='; | |
if (obj === null) { | |
obj = undefined; | |
} | |
if (typeof obj === 'object') { | |
return map(objectKeys(obj), function(k) { | |
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; | |
if (isArray(obj[k])) { | |
return obj[k].map(function(v) { | |
return ks + encodeURIComponent(stringifyPrimitive(v)); | |
}).join(sep); | |
} else { | |
return ks + encodeURIComponent(stringifyPrimitive(obj[k])); | |
} | |
}).join(sep); | |
} | |
if (!name) return ''; | |
return encodeURIComponent(stringifyPrimitive(name)) + eq + | |
encodeURIComponent(stringifyPrimitive(obj)); | |
}; | |
var isArray = Array.isArray || function (xs) { | |
return Object.prototype.toString.call(xs) === '[object Array]'; | |
}; | |
function map (xs, f) { | |
if (xs.map) return xs.map(f); | |
var res = []; | |
for (var i = 0; i < xs.length; i++) { | |
res.push(f(xs[i], i)); | |
} | |
return res; | |
} | |
var objectKeys = Object.keys || function (obj) { | |
var res = []; | |
for (var key in obj) { | |
if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); | |
} | |
return res; | |
}; | |
},{}],18:[function(require,module,exports){ | |
'use strict'; | |
exports.decode = exports.parse = require('./decode'); | |
exports.encode = exports.stringify = require('./encode'); | |
},{"./decode":16,"./encode":17}],19:[function(require,module,exports){ | |
module.exports = Duplex; | |
var inherits = require('inherits'); | |
var setImmediate = require('process/browser.js').nextTick; | |
var Readable = require('./readable.js'); | |
var Writable = require('./writable.js'); | |
inherits(Duplex, Readable); | |
Duplex.prototype.write = Writable.prototype.write; | |
Duplex.prototype.end = Writable.prototype.end; | |
Duplex.prototype._write = Writable.prototype._write; | |
function Duplex(options) { | |
if (!(this instanceof Duplex)) | |
return new Duplex(options); | |
Readable.call(this, options); | |
Writable.call(this, options); | |
if (options && options.readable === false) | |
this.readable = false; | |
if (options && options.writable === false) | |
this.writable = false; | |
this.allowHalfOpen = true; | |
if (options && options.allowHalfOpen === false) | |
this.allowHalfOpen = false; | |
this.once('end', onend); | |
} | |
function onend() { | |
if (this.allowHalfOpen || this._writableState.ended) | |
return; | |
var self = this; | |
setImmediate(function () { | |
self.end(); | |
}); | |
} | |
},{"./readable.js":23,"./writable.js":25,"inherits":9,"process/browser.js":21}],20:[function(require,module,exports){ | |
module.exports = Stream; | |
var EE = require('events').EventEmitter; | |
var inherits = require('inherits'); | |
inherits(Stream, EE); | |
Stream.Readable = require('./readable.js'); | |
Stream.Writable = require('./writable.js'); | |
Stream.Duplex = require('./duplex.js'); | |
Stream.Transform = require('./transform.js'); | |
Stream.PassThrough = require('./passthrough.js'); | |
Stream.Stream = Stream; | |
function Stream() { | |
EE.call(this); | |
} | |
Stream.prototype.pipe = function(dest, options) { | |
var source = this; | |
function ondata(chunk) { | |
if (dest.writable) { | |
if (false === dest.write(chunk) && source.pause) { | |
source.pause(); | |
} | |
} | |
} | |
source.on('data', ondata); | |
function ondrain() { | |
if (source.readable && source.resume) { | |
source.resume(); | |
} | |
} | |
dest.on('drain', ondrain); | |
if (!dest._isStdio && (!options || options.end !== false)) { | |
source.on('end', onend); | |
source.on('close', onclose); | |
} | |
var didOnEnd = false; | |
function onend() { | |
if (didOnEnd) return; | |
didOnEnd = true; | |
dest.end(); | |
} | |
function onclose() { | |
if (didOnEnd) return; | |
didOnEnd = true; | |
if (typeof dest.destroy === 'function') dest.destroy(); | |
} | |
function onerror(er) { | |
cleanup(); | |
if (EE.listenerCount(this, 'error') === 0) { | |
throw er; // Unhandled stream error in pipe. | |
} | |
} | |
source.on('error', onerror); | |
dest.on('error', onerror); | |
function cleanup() { | |
source.removeListener('data', ondata); | |
dest.removeListener('drain', ondrain); | |
source.removeListener('end', onend); | |
source.removeListener('close', onclose); | |
source.removeListener('error', onerror); | |
dest.removeListener('error', onerror); | |
source.removeListener('end', cleanup); | |
source.removeListener('close', cleanup); | |
dest.removeListener('close', cleanup); | |
} | |
source.on('end', cleanup); | |
source.on('close', cleanup); | |
dest.on('close', cleanup); | |
dest.emit('pipe', source); | |
return dest; | |
}; | |
},{"./duplex.js":19,"./passthrough.js":22,"./readable.js":23,"./transform.js":24,"./writable.js":25,"events":8,"inherits":9}],21:[function(require,module,exports){ | |
module.exports=require(11) | |
},{}],22:[function(require,module,exports){ | |
module.exports = PassThrough; | |
var Transform = require('./transform.js'); | |
var inherits = require('inherits'); | |
inherits(PassThrough, Transform); | |
function PassThrough(options) { | |
if (!(this instanceof PassThrough)) | |
return new PassThrough(options); | |
Transform.call(this, options); | |
} | |
PassThrough.prototype._transform = function(chunk, encoding, cb) { | |
cb(null, chunk); | |
}; | |
},{"./transform.js":24,"inherits":9}],23:[function(require,module,exports){ | |
var process=require("__browserify_process");// Copyright Joyent, Inc. and other Node contributors. | |
module.exports = Readable; | |
Readable.ReadableState = ReadableState; | |
var EE = require('events').EventEmitter; | |
var Stream = require('./index.js'); | |
var Buffer = require('buffer').Buffer; | |
var setImmediate = require('process/browser.js').nextTick; | |
var StringDecoder; | |
var inherits = require('inherits'); | |
inherits(Readable, Stream); | |
function ReadableState(options, stream) { | |
options = options || {}; | |
var hwm = options.highWaterMark; | |
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; | |
this.highWaterMark = ~~this.highWaterMark; | |
this.buffer = []; | |
this.length = 0; | |
this.pipes = null; | |
this.pipesCount = 0; | |
this.flowing = false; | |
this.ended = false; | |
this.endEmitted = false; | |
this.reading = false; | |
this.calledRead = false; | |
this.sync = true; | |
this.needReadable = false; | |
this.emittedReadable = false; | |
this.readableListening = false; | |
this.objectMode = !!options.objectMode; | |
this.defaultEncoding = options.defaultEncoding || 'utf8'; | |
this.ranOut = false; | |
this.awaitDrain = 0; | |
this.readingMore = false; | |
this.decoder = null; | |
this.encoding = null; | |
if (options.encoding) { | |
if (!StringDecoder) | |
StringDecoder = require('string_decoder').StringDecoder; | |
this.decoder = new StringDecoder(options.encoding); | |
this.encoding = options.encoding; | |
} | |
} | |
function Readable(options) { | |
if (!(this instanceof Readable)) | |
return new Readable(options); | |
this._readableState = new ReadableState(options, this); | |
this.readable = true; | |
Stream.call(this); | |
} | |
Readable.prototype.push = function(chunk, encoding) { | |
var state = this._readableState; | |
if (typeof chunk === 'string' && !state.objectMode) { | |
encoding = encoding || state.defaultEncoding; | |
if (encoding !== state.encoding) { | |
chunk = new Buffer(chunk, encoding); | |
encoding = ''; | |
} | |
} | |
return readableAddChunk(this, state, chunk, encoding, false); | |
}; | |
Readable.prototype.unshift = function(chunk) { | |
var state = this._readableState; | |
return readableAddChunk(this, state, chunk, '', true); | |
}; | |
function readableAddChunk(stream, state, chunk, encoding, addToFront) { | |
var er = chunkInvalid(state, chunk); | |
if (er) { | |
stream.emit('error', er); | |
} else if (chunk === null || chunk === undefined) { | |
state.reading = false; | |
if (!state.ended) | |
onEofChunk(stream, state); | |
} else if (state.objectMode || chunk && chunk.length > 0) { | |
if (state.ended && !addToFront) { | |
var e = new Error('stream.push() after EOF'); | |
stream.emit('error', e); | |
} else if (state.endEmitted && addToFront) { | |
var e = new Error('stream.unshift() after end event'); | |
stream.emit('error', e); | |
} else { | |
if (state.decoder && !addToFront && !encoding) | |
chunk = state.decoder.write(chunk); | |
state.length += state.objectMode ? 1 : chunk.length; | |
if (addToFront) { | |
state.buffer.unshift(chunk); | |
} else { | |
state.reading = false; | |
state.buffer.push(chunk); | |
} | |
if (state.needReadable) | |
emitReadable(stream); | |
maybeReadMore(stream, state); | |
} | |
} else if (!addToFront) { | |
state.reading = false; | |
} | |
return needMoreData(state); | |
} | |
function needMoreData(state) { | |
return !state.ended && | |
(state.needReadable || | |
state.length < state.highWaterMark || | |
state.length === 0); | |
} | |
Readable.prototype.setEncoding = function(enc) { | |
if (!StringDecoder) | |
StringDecoder = require('string_decoder').StringDecoder; | |
this._readableState.decoder = new StringDecoder(enc); | |
this._readableState.encoding = enc; | |
}; | |
var MAX_HWM = 0x800000; | |
function roundUpToNextPowerOf2(n) { | |
if (n >= MAX_HWM) { | |
n = MAX_HWM; | |
} else { | |
n--; | |
for (var p = 1; p < 32; p <<= 1) n |= n >> p; | |
n++; | |
} | |
return n; | |
} | |
function howMuchToRead(n, state) { | |
if (state.length === 0 && state.ended) | |
return 0; | |
if (state.objectMode) | |
return n === 0 ? 0 : 1; | |
if (isNaN(n) || n === null) { | |
if (state.flowing && state.buffer.length) | |
return state.buffer[0].length; | |
else | |
return state.length; | |
} | |
if (n <= 0) | |
return 0; | |
if (n > state.highWaterMark) | |
state.highWaterMark = roundUpToNextPowerOf2(n); | |
if (n > state.length) { | |
if (!state.ended) { | |
state.needReadable = true; | |
return 0; | |
} else | |
return state.length; | |
} | |
return n; | |
} | |
Readable.prototype.read = function(n) { | |
var state = this._readableState; | |
state.calledRead = true; | |
var nOrig = n; | |
if (typeof n !== 'number' || n > 0) | |
state.emittedReadable = false; | |
if (n === 0 && | |
state.needReadable && | |
(state.length >= state.highWaterMark || state.ended)) { | |
emitReadable(this); | |
return null; | |
} | |
n = howMuchToRead(n, state); | |
if (n === 0 && state.ended) { | |
if (state.length === 0) | |
endReadable(this); | |
return null; | |
} | |
var doRead = state.needReadable; | |
if (state.length - n <= state.highWaterMark) | |
doRead = true; | |
if (state.ended || state.reading) | |
doRead = false; | |
if (doRead) { | |
state.reading = true; | |
state.sync = true; | |
if (state.length === 0) | |
state.needReadable = true; | |
this._read(state.highWaterMark); | |
state.sync = false; | |
} | |
if (doRead && !state.reading) | |
n = howMuchToRead(nOrig, state); | |
var ret; | |
if (n > 0) | |
ret = fromList(n, state); | |
else | |
ret = null; | |
if (ret === null) { | |
state.needReadable = true; | |
n = 0; | |
} | |
state.length -= n; | |
if (state.length === 0 && !state.ended) | |
state.needReadable = true; | |
if (state.ended && !state.endEmitted && state.length === 0) | |
endReadable(this); | |
return ret; | |
}; | |
function chunkInvalid(state, chunk) { | |
var er = null; | |
if (!Buffer.isBuffer(chunk) && | |
'string' !== typeof chunk && | |
chunk !== null && | |
chunk !== undefined && | |
!state.objectMode && | |
!er) { | |
er = new TypeError('Invalid non-string/buffer chunk'); | |
} | |
return er; | |
} | |
function onEofChunk(stream, state) { | |
if (state.decoder && !state.ended) { | |
var chunk = state.decoder.end(); | |
if (chunk && chunk.length) { | |
state.buffer.push(chunk); | |
state.length += state.objectMode ? 1 : chunk.length; | |
} | |
} | |
state.ended = true; | |
if (state.length > 0) | |
emitReadable(stream); | |
else | |
endReadable(stream); | |
} | |
function emitReadable(stream) { | |
var state = stream._readableState; | |
state.needReadable = false; | |
if (state.emittedReadable) | |
return; | |
state.emittedReadable = true; | |
if (state.sync) | |
setImmediate(function() { | |
emitReadable_(stream); | |
}); | |
else | |
emitReadable_(stream); | |
} | |
function emitReadable_(stream) { | |
stream.emit('readable'); | |
} | |
function maybeReadMore(stream, state) { | |
if (!state.readingMore) { | |
state.readingMore = true; | |
setImmediate(function() { | |
maybeReadMore_(stream, state); | |
}); | |
} | |
} | |
function maybeReadMore_(stream, state) { | |
var len = state.length; | |
while (!state.reading && !state.flowing && !state.ended && | |
state.length < state.highWaterMark) { | |
stream.read(0); | |
if (len === state.length) | |
break; | |
else | |
len = state.length; | |
} | |
state.readingMore = false; | |
} | |
Readable.prototype._read = function(n) { | |
this.emit('error', new Error('not implemented')); | |
}; | |
Readable.prototype.pipe = function(dest, pipeOpts) { | |
var src = this; | |
var state = this._readableState; | |
switch (state.pipesCount) { | |
case 0: | |
state.pipes = dest; | |
break; | |
case 1: | |
state.pipes = [state.pipes, dest]; | |
break; | |
default: | |
state.pipes.push(dest); | |
break; | |
} | |
state.pipesCount += 1; | |
var doEnd = (!pipeOpts || pipeOpts.end !== false) && | |
dest !== process.stdout && | |
dest !== process.stderr; | |
var endFn = doEnd ? onend : cleanup; | |
if (state.endEmitted) | |
setImmediate(endFn); | |
else | |
src.once('end', endFn); | |
dest.on('unpipe', onunpipe); | |
function onunpipe(readable) { | |
if (readable !== src) return; | |
cleanup(); | |
} | |
function onend() { | |
dest.end(); | |
} | |
var ondrain = pipeOnDrain(src); | |
dest.on('drain', ondrain); | |
function cleanup() { | |
dest.removeListener('close', onclose); | |
dest.removeListener('finish', onfinish); | |
dest.removeListener('drain', ondrain); | |
dest.removeListener('error', onerror); | |
dest.removeListener('unpipe', onunpipe); | |
src.removeListener('end', onend); | |
src.removeListener('end', cleanup); | |
if (!dest._writableState || dest._writableState.needDrain) | |
ondrain(); | |
} | |
var errListeners = EE.listenerCount(dest, 'error'); | |
function onerror(er) { | |
unpipe(); | |
if (errListeners === 0 && EE.listenerCount(dest, 'error') === 0) | |
dest.emit('error', er); | |
} | |
dest.once('error', onerror); | |
function onclose() { | |
dest.removeListener('finish', onfinish); | |
unpipe(); | |
} | |
dest.once('close', onclose); | |
function onfinish() { | |
dest.removeListener('close', onclose); | |
unpipe(); | |
} | |
dest.once('finish', onfinish); | |
function unpipe() { | |
src.unpipe(dest); | |
} | |
dest.emit('pipe', src); | |
if (!state.flowing) { | |
this.on('readable', pipeOnReadable); | |
state.flowing = true; | |
setImmediate(function() { | |
flow(src); | |
}); | |
} | |
return dest; | |
}; | |
function pipeOnDrain(src) { | |
return function() { | |
var dest = this; | |
var state = src._readableState; | |
state.awaitDrain--; | |
if (state.awaitDrain === 0) | |
flow(src); | |
}; | |
} | |
function flow(src) { | |
var state = src._readableState; | |
var chunk; | |
state.awaitDrain = 0; | |
function write(dest, i, list) { | |
var written = dest.write(chunk); | |
if (false === written) { | |
state.awaitDrain++; | |
} | |
} | |
while (state.pipesCount && null !== (chunk = src.read())) { | |
if (state.pipesCount === 1) | |
write(state.pipes, 0, null); | |
else | |
forEach(state.pipes, write); | |
src.emit('data', chunk); | |
if (state.awaitDrain > 0) | |
return; | |
} | |
if (state.pipesCount === 0) { | |
state.flowing = false; | |
if (EE.listenerCount(src, 'data') > 0) | |
emitDataEvents(src); | |
return; | |
} | |
state.ranOut = true; | |
} | |
function pipeOnReadable() { | |
if (this._readableState.ranOut) { | |
this._readableState.ranOut = false; | |
flow(this); | |
} | |
} | |
Readable.prototype.unpipe = function(dest) { | |
var state = this._readableState; | |
if (state.pipesCount === 0) | |
return this; | |
if (state.pipesCount === 1) { | |
if (dest && dest !== state.pipes) | |
return this; | |
if (!dest) | |
dest = state.pipes; | |
state.pipes = null; | |
state.pipesCount = 0; | |
this.removeListener('readable', pipeOnReadable); | |
state.flowing = false; | |
if (dest) | |
dest.emit('unpipe', this); | |
return this; | |
} | |
if (!dest) { | |
var dests = state.pipes; | |
var len = state.pipesCount; | |
state.pipes = null; | |
state.pipesCount = 0; | |
this.removeListener('readable', pipeOnReadable); | |
state.flowing = false; | |
for (var i = 0; i < len; i++) | |
dests[i].emit('unpipe', this); | |
return this; | |
} | |
var i = indexOf(state.pipes, dest); | |
if (i === -1) | |
return this; | |
state.pipes.splice(i, 1); | |
state.pipesCount -= 1; | |
if (state.pipesCount === 1) | |
state.pipes = state.pipes[0]; | |
dest.emit('unpipe', this); | |
return this; | |
}; | |
Readable.prototype.on = function(ev, fn) { | |
var res = Stream.prototype.on.call(this, ev, fn); | |
if (ev === 'data' && !this._readableState.flowing) | |
emitDataEvents(this); | |
if (ev === 'readable' && this.readable) { | |
var state = this._readableState; | |
if (!state.readableListening) { | |
state.readableListening = true; | |
state.emittedReadable = false; | |
state.needReadable = true; | |
if (!state.reading) { | |
this.read(0); | |
} else if (state.length) { | |
emitReadable(this, state); | |
} | |
} | |
} | |
return res; | |
}; | |
Readable.prototype.addListener = Readable.prototype.on; | |
Readable.prototype.resume = function() { | |
emitDataEvents(this); | |
this.read(0); | |
this.emit('resume'); | |
}; | |
Readable.prototype.pause = function() { | |
emitDataEvents(this, true); | |
this.emit('pause'); | |
}; | |
function emitDataEvents(stream, startPaused) { | |
var state = stream._readableState; | |
if (state.flowing) { | |
throw new Error('Cannot switch to old mode now.'); | |
} | |
var paused = startPaused || false; | |
var readable = false; | |
stream.readable = true; | |
stream.pipe = Stream.prototype.pipe; | |
stream.on = stream.addListener = Stream.prototype.on; | |
stream.on('readable', function() { | |
readable = true; | |
var c; | |
while (!paused && (null !== (c = stream.read()))) | |
stream.emit('data', c); | |
if (c === null) { | |
readable = false; | |
stream._readableState.needReadable = true; | |
} | |
}); | |
stream.pause = function() { | |
paused = true; | |
this.emit('pause'); | |
}; | |
stream.resume = function() { | |
paused = false; | |
if (readable) | |
setImmediate(function() { | |
stream.emit('readable'); | |
}); | |
else | |
this.read(0); | |
this.emit('resume'); | |
}; | |
stream.emit('readable'); | |
} | |
Readable.prototype.wrap = function(stream) { | |
var state = this._readableState; | |
var paused = false; | |
var self = this; | |
stream.on('end', function() { | |
if (state.decoder && !state.ended) { | |
var chunk = state.decoder.end(); | |
if (chunk && chunk.length) | |
self.push(chunk); | |
} | |
self.push(null); | |
}); | |
stream.on('data', function(chunk) { | |
if (state.decoder) | |
chunk = state.decoder.write(chunk); | |
if (!chunk || !state.objectMode && !chunk.length) | |
return; | |
var ret = self.push(chunk); | |
if (!ret) { | |
paused = true; | |
stream.pause(); | |
} | |
}); | |
for (var i in stream) { | |
if (typeof stream[i] === 'function' && | |
typeof this[i] === 'undefined') { | |
this[i] = function(method) { return function() { | |
return stream[method].apply(stream, arguments); | |
}}(i); | |
} | |
} | |
var events = ['error', 'close', 'destroy', 'pause', 'resume']; | |
forEach(events, function(ev) { | |
stream.on(ev, function (x) { | |
return self.emit.apply(self, ev, x); | |
}); | |
}); | |
self._read = function(n) { | |
if (paused) { | |
paused = false; | |
stream.resume(); | |
} | |
}; | |
return self; | |
}; | |
Readable._fromList = fromList; | |
function fromList(n, state) { | |
var list = state.buffer; | |
var length = state.length; | |
var stringMode = !!state.decoder; | |
var objectMode = !!state.objectMode; | |
var ret; | |
if (list.length === 0) | |
return null; | |
if (length === 0) | |
ret = null; | |
else if (objectMode) | |
ret = list.shift(); | |
else if (!n || n >= length) { | |
if (stringMode) | |
ret = list.join(''); | |
else | |
ret = Buffer.concat(list, length); | |
list.length = 0; | |
} else { | |
if (n < list[0].length) { | |
var buf = list[0]; | |
ret = buf.slice(0, n); | |
list[0] = buf.slice(n); | |
} else if (n === list[0].length) { | |
ret = list.shift(); | |
} else { | |
if (stringMode) | |
ret = ''; | |
else | |
ret = new Buffer(n); | |
var c = 0; | |
for (var i = 0, l = list.length; i < l && c < n; i++) { | |
var buf = list[0]; | |
var cpy = Math.min(n - c, buf.length); | |
if (stringMode) | |
ret += buf.slice(0, cpy); | |
else | |
buf.copy(ret, c, 0, cpy); | |
if (cpy < buf.length) | |
list[0] = buf.slice(cpy); | |
else | |
list.shift(); | |
c += cpy; | |
} | |
} | |
} | |
return ret; | |
} | |
function endReadable(stream) { | |
var state = stream._readableState; | |
if (state.length > 0) | |
throw new Error('endReadable called on non-empty stream'); | |
if (!state.endEmitted && state.calledRead) { | |
state.ended = true; | |
setImmediate(function() { | |
if (!state.endEmitted && state.length === 0) { | |
state.endEmitted = true; | |
stream.readable = false; | |
stream.emit('end'); | |
} | |
}); | |
} | |
} | |
function forEach (xs, f) { | |
for (var i = 0, l = xs.length; i < l; i++) { | |
f(xs[i], i); | |
} | |
} | |
function indexOf (xs, x) { | |
for (var i = 0, l = xs.length; i < l; i++) { | |
if (xs[i] === x) return i; | |
} | |
return -1; | |
} | |
},{"./index.js":20,"__browserify_process":11,"buffer":12,"events":8,"inherits":9,"process/browser.js":21,"string_decoder":26}],24:[function(require,module,exports){ | |
module.exports = Transform; | |
var Duplex = require('./duplex.js'); | |
var inherits = require('inherits'); | |
inherits(Transform, Duplex); | |
function TransformState(options, stream) { | |
this.afterTransform = function(er, data) { | |
return afterTransform(stream, er, data); | |
}; | |
this.needTransform = false; | |
this.transforming = false; | |
this.writecb = null; | |
this.writechunk = null; | |
} | |
function afterTransform(stream, er, data) { | |
var ts = stream._transformState; | |
ts.transforming = false; | |
var cb = ts.writecb; | |
if (!cb) | |
return stream.emit('error', new Error('no writecb in Transform class')); | |
ts.writechunk = null; | |
ts.writecb = null; | |
if (data !== null && data !== undefined) | |
stream.push(data); | |
if (cb) | |
cb(er); | |
var rs = stream._readableState; | |
rs.reading = false; | |
if (rs.needReadable || rs.length < rs.highWaterMark) { | |
stream._read(rs.highWaterMark); | |
} | |
} | |
function Transform(options) { | |
if (!(this instanceof Transform)) | |
return new Transform(options); | |
Duplex.call(this, options); | |
var ts = this._transformState = new TransformState(options, this); | |
var stream = this; | |
this._readableState.needReadable = true; | |
this._readableState.sync = false; | |
this.once('finish', function() { | |
if ('function' === typeof this._flush) | |
this._flush(function(er) { | |
done(stream, er); | |
}); | |
else | |
done(stream); | |
}); | |
} | |
Transform.prototype.push = function(chunk, encoding) { | |
this._transformState.needTransform = false; | |
return Duplex.prototype.push.call(this, chunk, encoding); | |
}; | |
Transform.prototype._transform = function(chunk, encoding, cb) { | |
throw new Error('not implemented'); | |
}; | |
Transform.prototype._write = function(chunk, encoding, cb) { | |
var ts = this._transformState; | |
ts.writecb = cb; | |
ts.writechunk = chunk; | |
ts.writeencoding = encoding; | |
if (!ts.transforming) { | |
var rs = this._readableState; | |
if (ts.needTransform || | |
rs.needReadable || | |
rs.length < rs.highWaterMark) | |
this._read(rs.highWaterMark); | |
} | |
}; | |
Transform.prototype._read = function(n) { | |
var ts = this._transformState; | |
if (ts.writechunk && ts.writecb && !ts.transforming) { | |
ts.transforming = true; | |
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); | |
} else { | |
ts.needTransform = true; | |
} | |
}; | |
function done(stream, er) { | |
if (er) | |
return stream.emit('error', er); | |
var ws = stream._writableState; | |
var rs = stream._readableState; | |
var ts = stream._transformState; | |
if (ws.length) | |
throw new Error('calling transform done when ws.length != 0'); | |
if (ts.transforming) | |
throw new Error('calling transform done when still transforming'); | |
return stream.push(null); | |
} | |
},{"./duplex.js":19,"inherits":9}],25:[function(require,module,exports){ | |
module.exports = Writable; | |
Writable.WritableState = WritableState; | |
var isUint8Array = typeof Uint8Array !== 'undefined' | |
? function (x) { return x instanceof Uint8Array } | |
: function (x) { | |
return x && x.constructor && x.constructor.name === 'Uint8Array' | |
} | |
; | |
var isArrayBuffer = typeof ArrayBuffer !== 'undefined' | |
? function (x) { return x instanceof ArrayBuffer } | |
: function (x) { | |
return x && x.constructor && x.constructor.name === 'ArrayBuffer' | |
} | |
; | |
var inherits = require('inherits'); | |
var Stream = require('./index.js'); | |
var setImmediate = require('process/browser.js').nextTick; | |
var Buffer = require('buffer').Buffer; | |
inherits(Writable, Stream); | |
function WriteReq(chunk, encoding, cb) { | |
this.chunk = chunk; | |
this.encoding = encoding; | |
this.callback = cb; | |
} | |
function WritableState(options, stream) { | |
options = options || {}; | |
var hwm = options.highWaterMark; | |
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; | |
this.objectMode = !!options.objectMode; | |
this.highWaterMark = ~~this.highWaterMark; | |
this.needDrain = false; | |
this.ending = false; | |
this.ended = false; | |
this.finished = false; | |
var noDecode = options.decodeStrings === false; | |
this.decodeStrings = !noDecode; | |
this.defaultEncoding = options.defaultEncoding || 'utf8'; | |
this.length = 0; | |
this.writing = false; | |
this.sync = true; | |
this.bufferProcessing = false; | |
this.onwrite = function(er) { | |
onwrite(stream, er); | |
}; | |
this.writecb = null; | |
this.writelen = 0; | |
this.buffer = []; | |
} | |
function Writable(options) { | |
if (!(this instanceof Writable) && !(this instanceof Stream.Duplex)) | |
return new Writable(options); | |
this._writableState = new WritableState(options, this); | |
this.writable = true; | |
Stream.call(this); | |
} | |
Writable.prototype.pipe = function() { | |
this.emit('error', new Error('Cannot pipe. Not readable.')); | |
}; | |
function writeAfterEnd(stream, state, cb) { | |
var er = new Error('write after end'); | |
stream.emit('error', er); | |
setImmediate(function() { | |
cb(er); | |
}); | |
} | |
function validChunk(stream, state, chunk, cb) { | |
var valid = true; | |
if (!Buffer.isBuffer(chunk) && | |
'string' !== typeof chunk && | |
chunk !== null && | |
chunk !== undefined && | |
!state.objectMode) { | |
var er = new TypeError('Invalid non-string/buffer chunk'); | |
stream.emit('error', er); | |
setImmediate(function() { | |
cb(er); | |
}); | |
valid = false; | |
} | |
return valid; | |
} | |
Writable.prototype.write = function(chunk, encoding, cb) { | |
var state = this._writableState; | |
var ret = false; | |
if (typeof encoding === 'function') { | |
cb = encoding; | |
encoding = null; | |
} | |
if (isUint8Array(chunk)) | |
chunk = new Buffer(chunk); | |
if (isArrayBuffer(chunk) && typeof Uint8Array !== 'undefined') | |
chunk = new Buffer(new Uint8Array(chunk)); | |
if (Buffer.isBuffer(chunk)) | |
encoding = 'buffer'; | |
else if (!encoding) | |
encoding = state.defaultEncoding; | |
if (typeof cb !== 'function') | |
cb = function() {}; | |
if (state.ended) | |
writeAfterEnd(this, state, cb); | |
else if (validChunk(this, state, chunk, cb)) | |
ret = writeOrBuffer(this, state, chunk, encoding, cb); | |
return ret; | |
}; | |
function decodeChunk(state, chunk, encoding) { | |
if (!state.objectMode && | |
state.decodeStrings !== false && | |
typeof chunk === 'string') { | |
chunk = new Buffer(chunk, encoding); | |
} | |
return chunk; | |
} | |
function writeOrBuffer(stream, state, chunk, encoding, cb) { | |
chunk = decodeChunk(state, chunk, encoding); | |
var len = state.objectMode ? 1 : chunk.length; | |
state.length += len; | |
var ret = state.length < state.highWaterMark; | |
state.needDrain = !ret; | |
if (state.writing) | |
state.buffer.push(new WriteReq(chunk, encoding, cb)); | |
else | |
doWrite(stream, state, len, chunk, encoding, cb); | |
return ret; | |
} | |
function doWrite(stream, state, len, chunk, encoding, cb) { | |
state.writelen = len; | |
state.writecb = cb; | |
state.writing = true; | |
state.sync = true; | |
stream._write(chunk, encoding, state.onwrite); | |
state.sync = false; | |
} | |
function onwriteError(stream, state, sync, er, cb) { | |
if (sync) | |
setImmediate(function() { | |
cb(er); | |
}); | |
else | |
cb(er); | |
stream.emit('error', er); | |
} | |
function onwriteStateUpdate(state) { | |
state.writing = false; | |
state.writecb = null; | |
state.length -= state.writelen; | |
state.writelen = 0; | |
} | |
function onwrite(stream, er) { | |
var state = stream._writableState; | |
var sync = state.sync; | |
var cb = state.writecb; | |
onwriteStateUpdate(state); | |
if (er) | |
onwriteError(stream, state, sync, er, cb); | |
else { | |
var finished = needFinish(stream, state); | |
if (!finished && !state.bufferProcessing && state.buffer.length) | |
clearBuffer(stream, state); | |
if (sync) { | |
setImmediate(function() { | |
afterWrite(stream, state, finished, cb); | |
}); | |
} else { | |
afterWrite(stream, state, finished, cb); | |
} | |
} | |
} | |
function afterWrite(stream, state, finished, cb) { | |
if (!finished) | |
onwriteDrain(stream, state); | |
cb(); | |
if (finished) | |
finishMaybe(stream, state); | |
} | |
function onwriteDrain(stream, state) { | |
if (state.length === 0 && state.needDrain) { | |
state.needDrain = false; | |
stream.emit('drain'); | |
} | |
} | |
function clearBuffer(stream, state) { | |
state.bufferProcessing = true; | |
for (var c = 0; c < state.buffer.length; c++) { | |
var entry = state.buffer[c]; | |
var chunk = entry.chunk; | |
var encoding = entry.encoding; | |
var cb = entry.callback; | |
var len = state.objectMode ? 1 : chunk.length; | |
doWrite(stream, state, len, chunk, encoding, cb); | |
if (state.writing) { | |
c++; | |
break; | |
} | |
} | |
state.bufferProcessing = false; | |
if (c < state.buffer.length) | |
state.buffer = state.buffer.slice(c); | |
else | |
state.buffer.length = 0; | |
} | |
Writable.prototype._write = function(chunk, encoding, cb) { | |
cb(new Error('not implemented')); | |
}; | |
Writable.prototype.end = function(chunk, encoding, cb) { | |
var state = this._writableState; | |
if (typeof chunk === 'function') { | |
cb = chunk; | |
chunk = null; | |
encoding = null; | |
} else if (typeof encoding === 'function') { | |
cb = encoding; | |
encoding = null; | |
} | |
if (typeof chunk !== 'undefined' && chunk !== null) | |
this.write(chunk, encoding); | |
if (!state.ending && !state.finished) | |
endWritable(this, state, cb); | |
}; | |
function needFinish(stream, state) { | |
return (state.ending && | |
state.length === 0 && | |
!state.finished && | |
!state.writing); | |
} | |
function finishMaybe(stream, state) { | |
var need = needFinish(stream, state); | |
if (need) { | |
state.finished = true; | |
stream.emit('finish'); | |
} | |
return need; | |
} | |
function endWritable(stream, state, cb) { | |
state.ending = true; | |
finishMaybe(stream, state); | |
if (cb) { | |
if (state.finished) | |
setImmediate(cb); | |
else | |
stream.once('finish', cb); | |
} | |
state.ended = true; | |
} | |
},{"./index.js":20,"buffer":12,"inherits":9,"process/browser.js":21}],26:[function(require,module,exports){ | |
var Buffer = require('buffer').Buffer; | |
function assertEncoding(encoding) { | |
if (encoding && !Buffer.isEncoding(encoding)) { | |
throw new Error('Unknown encoding: ' + encoding); | |
} | |
} | |
var StringDecoder = exports.StringDecoder = function(encoding) { | |
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); | |
assertEncoding(encoding); | |
switch (this.encoding) { | |
case 'utf8': | |
this.surrogateSize = 3; | |
break; | |
case 'ucs2': | |
case 'utf16le': | |
this.surrogateSize = 2; | |
this.detectIncompleteChar = utf16DetectIncompleteChar; | |
break; | |
case 'base64': | |
this.surrogateSize = 3; | |
this.detectIncompleteChar = base64DetectIncompleteChar; | |
break; | |
default: | |
this.write = passThroughWrite; | |
return; | |
} | |
this.charBuffer = new Buffer(6); | |
this.charReceived = 0; | |
this.charLength = 0; | |
}; | |
StringDecoder.prototype.write = function(buffer) { | |
var charStr = ''; | |
var offset = 0; | |
while (this.charLength) { | |
var i = (buffer.length >= this.charLength - this.charReceived) ? | |
this.charLength - this.charReceived : | |
buffer.length; | |
buffer.copy(this.charBuffer, this.charReceived, offset, i); | |
this.charReceived += (i - offset); | |
offset = i; | |
if (this.charReceived < this.charLength) { | |
return ''; | |
} | |
charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); | |
var charCode = charStr.charCodeAt(charStr.length - 1); | |
if (charCode >= 0xD800 && charCode <= 0xDBFF) { | |
this.charLength += this.surrogateSize; | |
charStr = ''; | |
continue; | |
} | |
this.charReceived = this.charLength = 0; | |
if (i == buffer.length) return charStr; | |
buffer = buffer.slice(i, buffer.length); | |
break; | |
} | |
var lenIncomplete = this.detectIncompleteChar(buffer); | |
var end = buffer.length; | |
if (this.charLength) { | |
buffer.copy(this.charBuffer, 0, buffer.length - lenIncomplete, end); | |
this.charReceived = lenIncomplete; | |
end -= lenIncomplete; | |
} | |
charStr += buffer.toString(this.encoding, 0, end); | |
var end = charStr.length - 1; | |
var charCode = charStr.charCodeAt(end); | |
if (charCode >= 0xD800 && charCode <= 0xDBFF) { | |
var size = this.surrogateSize; | |
this.charLength += size; | |
this.charReceived += size; | |
this.charBuffer.copy(this.charBuffer, size, 0, size); | |
this.charBuffer.write(charStr.charAt(charStr.length - 1), this.encoding); | |
return charStr.substring(0, end); | |
} | |
return charStr; | |
}; | |
StringDecoder.prototype.detectIncompleteChar = function(buffer) { | |
var i = (buffer.length >= 3) ? 3 : buffer.length; | |
for (; i > 0; i--) { | |
var c = buffer[buffer.length - i]; | |
if (i == 1 && c >> 5 == 0x06) { | |
this.charLength = 2; | |
break; | |
} | |
if (i <= 2 && c >> 4 == 0x0E) { | |
this.charLength = 3; | |
break; | |
} | |
if (i <= 3 && c >> 3 == 0x1E) { | |
this.charLength = 4; | |
break; | |
} | |
} | |
return i; | |
}; | |
StringDecoder.prototype.end = function(buffer) { | |
var res = ''; | |
if (buffer && buffer.length) | |
res = this.write(buffer); | |
if (this.charReceived) { | |
var cr = this.charReceived; | |
var buf = this.charBuffer; | |
var enc = this.encoding; | |
res += buf.slice(0, cr).toString(enc); | |
} | |
return res; | |
}; | |
function passThroughWrite(buffer) { | |
return buffer.toString(this.encoding); | |
} | |
function utf16DetectIncompleteChar(buffer) { | |
var incomplete = this.charReceived = buffer.length % 2; | |
this.charLength = incomplete ? 2 : 0; | |
return incomplete; | |
} | |
function base64DetectIncompleteChar(buffer) { | |
var incomplete = this.charReceived = buffer.length % 3; | |
this.charLength = incomplete ? 3 : 0; | |
return incomplete; | |
} | |
},{"buffer":12}],27:[function(require,module,exports){ | |
(function () { | |
"use strict"; | |
var punycode = require('punycode'); | |
exports.parse = urlParse; | |
exports.resolve = urlResolve; | |
exports.resolveObject = urlResolveObject; | |
exports.format = urlFormat; | |
var protocolPattern = /^([a-z0-9.+-]+:)/i, | |
portPattern = /:[0-9]*$/, | |
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], | |
unwise = ['{', '}', '|', '\\', '^', '~', '`'].concat(delims), | |
autoEscape = ['\''].concat(delims), | |
nonHostChars = ['%', '/', '?', ';', '#'] | |
.concat(unwise).concat(autoEscape), | |
nonAuthChars = ['/', '@', '?', '#'].concat(delims), | |
hostnameMaxLen = 255, | |
hostnamePartPattern = /^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/, | |
hostnamePartStart = /^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/, | |
unsafeProtocol = { | |
'javascript': true, | |
'javascript:': true | |
}, | |
hostlessProtocol = { | |
'javascript': true, | |
'javascript:': true | |
}, | |
pathedProtocol = { | |
'http': true, | |
'https': true, | |
'ftp': true, | |
'gopher': true, | |
'file': true, | |
'http:': true, | |
'ftp:': true, | |
'gopher:': true, | |
'file:': true | |
}, | |
slashedProtocol = { | |
'http': true, | |
'https': true, | |
'ftp': true, | |
'gopher': true, | |
'file': true, | |
'http:': true, | |
'https:': true, | |
'ftp:': true, | |
'gopher:': true, | |
'file:': true | |
}, | |
querystring = require('querystring'); | |
function urlParse(url, parseQueryString, slashesDenoteHost) { | |
if (url && typeof(url) === 'object' && url.href) return url; | |
if (typeof url !== 'string') { | |
throw new TypeError("Parameter 'url' must be a string, not " + typeof url); | |
} | |
var out = {}, | |
rest = url; | |
rest = rest.trim(); | |
var proto = protocolPattern.exec(rest); | |
if (proto) { | |
proto = proto[0]; | |
var lowerProto = proto.toLowerCase(); | |
out.protocol = lowerProto; | |
rest = rest.substr(proto.length); | |
} | |
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { | |
var slashes = rest.substr(0, 2) === '//'; | |
if (slashes && !(proto && hostlessProtocol[proto])) { | |
rest = rest.substr(2); | |
out.slashes = true; | |
} | |
} | |
if (!hostlessProtocol[proto] && | |
(slashes || (proto && !slashedProtocol[proto]))) { | |
var atSign = rest.indexOf('@'); | |
if (atSign !== -1) { | |
var auth = rest.slice(0, atSign); | |
var hasAuth = true; | |
for (var i = 0, l = nonAuthChars.length; i < l; i++) { | |
if (auth.indexOf(nonAuthChars[i]) !== -1) { | |
hasAuth = false; | |
break; | |
} | |
} | |
if (hasAuth) { | |
out.auth = decodeURIComponent(auth); | |
rest = rest.substr(atSign + 1); | |
} | |
} | |
var firstNonHost = -1; | |
for (var i = 0, l = nonHostChars.length; i < l; i++) { | |
var index = rest.indexOf(nonHostChars[i]); | |
if (index !== -1 && | |
(firstNonHost < 0 || index < firstNonHost)) firstNonHost = index; | |
} | |
if (firstNonHost !== -1) { | |
out.host = rest.substr(0, firstNonHost); | |
rest = rest.substr(firstNonHost); | |
} else { | |
out.host = rest; | |
rest = ''; | |
} | |
var p = parseHost(out.host); | |
var keys = Object.keys(p); | |
for (var i = 0, l = keys.length; i < l; i++) { | |
var key = keys[i]; | |
out[key] = p[key]; | |
} | |
out.hostname = out.hostname || ''; | |
var ipv6Hostname = out.hostname[0] === '[' && | |
out.hostname[out.hostname.length - 1] === ']'; | |
if (out.hostname.length > hostnameMaxLen) { | |
out.hostname = ''; | |
} else if (!ipv6Hostname) { | |
var hostparts = out.hostname.split(/\./); | |
for (var i = 0, l = hostparts.length; i < l; i++) { | |
var part = hostparts[i]; | |
if (!part) continue; | |
if (!part.match(hostnamePartPattern)) { | |
var newpart = ''; | |
for (var j = 0, k = part.length; j < k; j++) { | |
if (part.charCodeAt(j) > 127) { | |
newpart += 'x'; | |
} else { | |
newpart += part[j]; | |
} | |
} | |
if (!newpart.match(hostnamePartPattern)) { | |
var validParts = hostparts.slice(0, i); | |
var notHost = hostparts.slice(i + 1); | |
var bit = part.match(hostnamePartStart); | |
if (bit) { | |
validParts.push(bit[1]); | |
notHost.unshift(bit[2]); | |
} | |
if (notHost.length) { | |
rest = '/' + notHost.join('.') + rest; | |
} | |
out.hostname = validParts.join('.'); | |
break; | |
} | |
} | |
} | |
} | |
out.hostname = out.hostname.toLowerCase(); | |
if (!ipv6Hostname) { | |
var domainArray = out.hostname.split('.'); | |
var newOut = []; | |
for (var i = 0; i < domainArray.length; ++i) { | |
var s = domainArray[i]; | |
newOut.push(s.match(/[^A-Za-z0-9_-]/) ? | |
'xn--' + punycode.encode(s) : s); | |
} | |
out.hostname = newOut.join('.'); | |
} | |
out.host = (out.hostname || '') + | |
((out.port) ? ':' + out.port : ''); | |
out.href += out.host; | |
if (ipv6Hostname) { | |
out.hostname = out.hostname.substr(1, out.hostname.length - 2); | |
if (rest[0] !== '/') { | |
rest = '/' + rest; | |
} | |
} | |
} | |
if (!unsafeProtocol[lowerProto]) { | |
for (var i = 0, l = autoEscape.length; i < l; i++) { | |
var ae = autoEscape[i]; | |
var esc = encodeURIComponent(ae); | |
if (esc === ae) { | |
esc = escape(ae); | |
} | |
rest = rest.split(ae).join(esc); | |
} | |
} | |
var hash = rest.indexOf('#'); | |
if (hash !== -1) { | |
out.hash = rest.substr(hash); | |
rest = rest.slice(0, hash); | |
} | |
var qm = rest.indexOf('?'); | |
if (qm !== -1) { | |
out.search = rest.substr(qm); | |
out.query = rest.substr(qm + 1); | |
if (parseQueryString) { | |
out.query = querystring.parse(out.query); | |
} | |
rest = rest.slice(0, qm); | |
} else if (parseQueryString) { | |
out.search = ''; | |
out.query = {}; | |
} | |
if (rest) out.pathname = rest; | |
if (slashedProtocol[proto] && | |
out.hostname && !out.pathname) { | |
out.pathname = '/'; | |
} | |
if (out.pathname || out.search) { | |
out.path = (out.pathname ? out.pathname : '') + | |
(out.search ? out.search : ''); | |
} | |
out.href = urlFormat(out); | |
return out; | |
} | |
function urlFormat(obj) { | |
if (typeof(obj) === 'string') obj = urlParse(obj); | |
var auth = obj.auth || ''; | |
if (auth) { | |
auth = encodeURIComponent(auth); | |
auth = auth.replace(/%3A/i, ':'); | |
auth += '@'; | |
} | |
var protocol = obj.protocol || '', | |
pathname = obj.pathname || '', | |
hash = obj.hash || '', | |
host = false, | |
query = ''; | |
if (obj.host !== undefined) { | |
host = auth + obj.host; | |
} else if (obj.hostname !== undefined) { | |
host = auth + (obj.hostname.indexOf(':') === -1 ? | |
obj.hostname : | |
'[' + obj.hostname + ']'); | |
if (obj.port) { | |
host += ':' + obj.port; | |
} | |
} | |
if (obj.query && typeof obj.query === 'object' && | |
Object.keys(obj.query).length) { | |
query = querystring.stringify(obj.query); | |
} | |
var search = obj.search || (query && ('?' + query)) || ''; | |
if (protocol && protocol.substr(-1) !== ':') protocol += ':'; | |
if (obj.slashes || | |
(!protocol || slashedProtocol[protocol]) && host !== false) { | |
host = '//' + (host || ''); | |
if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; | |
} else if (!host) { | |
host = ''; | |
} | |
if (hash && hash.charAt(0) !== '#') hash = '#' + hash; | |
if (search && search.charAt(0) !== '?') search = '?' + search; | |
return protocol + host + pathname + search + hash; | |
} | |
function urlResolve(source, relative) { | |
return urlFormat(urlResolveObject(source, relative)); | |
} | |
function urlResolveObject(source, relative) { | |
if (!source) return relative; | |
source = urlParse(urlFormat(source), false, true); | |
relative = urlParse(urlFormat(relative), false, true); | |
source.hash = relative.hash; | |
if (relative.href === '') { | |
source.href = urlFormat(source); | |
return source; | |
} | |
if (relative.slashes && !relative.protocol) { | |
relative.protocol = source.protocol; | |
if (slashedProtocol[relative.protocol] && | |
relative.hostname && !relative.pathname) { | |
relative.path = relative.pathname = '/'; | |
} | |
relative.href = urlFormat(relative); | |
return relative; | |
} | |
if (relative.protocol && relative.protocol !== source.protocol) { | |
if (!slashedProtocol[relative.protocol]) { | |
relative.href = urlFormat(relative); | |
return relative; | |
} | |
source.protocol = relative.protocol; | |
if (!relative.host && !hostlessProtocol[relative.protocol]) { | |
var relPath = (relative.pathname || '').split('/'); | |
while (relPath.length && !(relative.host = relPath.shift())); | |
if (!relative.host) relative.host = ''; | |
if (!relative.hostname) relative.hostname = ''; | |
if (relPath[0] !== '') relPath.unshift(''); | |
if (relPath.length < 2) relPath.unshift(''); | |
relative.pathname = relPath.join('/'); | |
} | |
source.pathname = relative.pathname; | |
source.search = relative.search; | |
source.query = relative.query; | |
source.host = relative.host || ''; | |
source.auth = relative.auth; | |
source.hostname = relative.hostname || relative.host; | |
source.port = relative.port; | |
if (source.pathname !== undefined || source.search !== undefined) { | |
source.path = (source.pathname ? source.pathname : '') + | |
(source.search ? source.search : ''); | |
} | |
source.slashes = source.slashes || relative.slashes; | |
source.href = urlFormat(source); | |
return source; | |
} | |
var isSourceAbs = (source.pathname && source.pathname.charAt(0) === '/'), | |
isRelAbs = ( | |
relative.host !== undefined || | |
relative.pathname && relative.pathname.charAt(0) === '/' | |
), | |
mustEndAbs = (isRelAbs || isSourceAbs || | |
(source.host && relative.pathname)), | |
removeAllDots = mustEndAbs, | |
srcPath = source.pathname && source.pathname.split('/') || [], | |
relPath = relative.pathname && relative.pathname.split('/') || [], | |
psychotic = source.protocol && | |
!slashedProtocol[source.protocol]; | |
if (psychotic) { | |
delete source.hostname; | |
delete source.port; | |
if (source.host) { | |
if (srcPath[0] === '') srcPath[0] = source.host; | |
else srcPath.unshift(source.host); | |
} | |
delete source.host; | |
if (relative.protocol) { | |
delete relative.hostname; | |
delete relative.port; | |
if (relative.host) { | |
if (relPath[0] === '') relPath[0] = relative.host; | |
else relPath.unshift(relative.host); | |
} | |
delete relative.host; | |
} | |
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); | |
} | |
if (isRelAbs) { | |
source.host = (relative.host || relative.host === '') ? | |
relative.host : source.host; | |
source.hostname = (relative.hostname || relative.hostname === '') ? | |
relative.hostname : source.hostname; | |
source.search = relative.search; | |
source.query = relative.query; | |
srcPath = relPath; | |
} else if (relPath.length) { | |
if (!srcPath) srcPath = []; | |
srcPath.pop(); | |
srcPath = srcPath.concat(relPath); | |
source.search = relative.search; | |
source.query = relative.query; | |
} else if ('search' in relative) { | |
if (psychotic) { | |
source.hostname = source.host = srcPath.shift(); | |
var authInHost = source.host && source.host.indexOf('@') > 0 ? | |
source.host.split('@') : false; | |
if (authInHost) { | |
source.auth = authInHost.shift(); | |
source.host = source.hostname = authInHost.shift(); | |
} | |
} | |
source.search = relative.search; | |
source.query = relative.query; | |
if (source.pathname !== undefined || source.search !== undefined) { | |
source.path = (source.pathname ? source.pathname : '') + | |
(source.search ? source.search : ''); | |
} | |
source.href = urlFormat(source); | |
return source; | |
} | |
if (!srcPath.length) { | |
delete source.pathname; | |
if (!source.search) { | |
source.path = '/' + source.search; | |
} else { | |
delete source.path; | |
} | |
source.href = urlFormat(source); | |
return source; | |
} | |
var last = srcPath.slice(-1)[0]; | |
var hasTrailingSlash = ( | |
(source.host || relative.host) && (last === '.' || last === '..') || | |
last === ''); | |
var up = 0; | |
for (var i = srcPath.length; i >= 0; i--) { | |
last = srcPath[i]; | |
if (last == '.') { | |
srcPath.splice(i, 1); | |
} else if (last === '..') { | |
srcPath.splice(i, 1); | |
up++; | |
} else if (up) { | |
srcPath.splice(i, 1); | |
up--; | |
} | |
} | |
if (!mustEndAbs && !removeAllDots) { | |
for (; up--; up) { | |
srcPath.unshift('..'); | |
} | |
} | |
if (mustEndAbs && srcPath[0] !== '' && | |
(!srcPath[0] || srcPath[0].charAt(0) !== '/')) { | |
srcPath.unshift(''); | |
} | |
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { | |
srcPath.push(''); | |
} | |
var isAbsolute = srcPath[0] === '' || | |
(srcPath[0] && srcPath[0].charAt(0) === '/'); | |
if (psychotic) { | |
source.hostname = source.host = isAbsolute ? '' : | |
srcPath.length ? srcPath.shift() : ''; | |
var authInHost = source.host && source.host.indexOf('@') > 0 ? | |
source.host.split('@') : false; | |
if (authInHost) { | |
source.auth = authInHost.shift(); | |
source.host = source.hostname = authInHost.shift(); | |
} | |
} | |
mustEndAbs = mustEndAbs || (source.host && srcPath.length); | |
if (mustEndAbs && !isAbsolute) { | |
srcPath.unshift(''); | |
} | |
source.pathname = srcPath.join('/'); | |
if (source.pathname !== undefined || source.search !== undefined) { | |
source.path = (source.pathname ? source.pathname : '') + | |
(source.search ? source.search : ''); | |
} | |
source.auth = relative.auth || source.auth; | |
source.slashes = source.slashes || relative.slashes; | |
source.href = urlFormat(source); | |
return source; | |
} | |
function parseHost(host) { | |
var out = {}; | |
var port = portPattern.exec(host); | |
if (port) { | |
port = port[0]; | |
if (port !== ':') { | |
out.port = port.substr(1); | |
} | |
host = host.substr(0, host.length - port.length); | |
} | |
if (host) out.hostname = host; | |
return out; | |
} | |
}()); | |
},{"punycode":15,"querystring":18}],28:[function(require,module,exports){ | |
module.exports = function isBuffer(arg) { | |
return arg && typeof arg === 'object' | |
&& typeof arg.copy === 'function' | |
&& typeof arg.fill === 'function' | |
&& typeof arg.readUInt8 === 'function'; | |
} | |
},{}],29:[function(require,module,exports){ | |
var process=require("__browserify_process"),global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};// Copyright Joyent, Inc. and other Node contributors. | |
var formatRegExp = /%[sdj%]/g; | |
exports.format = function(f) { | |
if (!isString(f)) { | |
var objects = []; | |
for (var i = 0; i < arguments.length; i++) { | |
objects.push(inspect(arguments[i])); | |
} | |
return objects.join(' '); | |
} | |
var i = 1; | |
var args = arguments; | |
var len = args.length; | |
var str = String(f).replace(formatRegExp, function(x) { | |
if (x === '%%') return '%'; | |
if (i >= len) return x; | |
switch (x) { | |
case '%s': return String(args[i++]); | |
case '%d': return Number(args[i++]); | |
case '%j': | |
try { | |
return JSON.stringify(args[i++]); | |
} catch (_) { | |
return '[Circular]'; | |
} | |
default: | |
return x; | |
} | |
}); | |
for (var x = args[i]; i < len; x = args[++i]) { | |
if (isNull(x) || !isObject(x)) { | |
str += ' ' + x; | |
} else { | |
str += ' ' + inspect(x); | |
} | |
} | |
return str; | |
}; | |
exports.deprecate = function(fn, msg) { | |
if (isUndefined(global.process)) { | |
return function() { | |
return exports.deprecate(fn, msg).apply(this, arguments); | |
}; | |
} | |
if (process.noDeprecation === true) { | |
return fn; | |
} | |
var warned = false; | |
function deprecated() { | |
if (!warned) { | |
if (process.throwDeprecation) { | |
throw new Error(msg); | |
} else if (process.traceDeprecation) { | |
console.trace(msg); | |
} else { | |
console.error(msg); | |
} | |
warned = true; | |
} | |
return fn.apply(this, arguments); | |
} | |
return deprecated; | |
}; | |
var debugs = {}; | |
var debugEnviron; | |
exports.debuglog = function(set) { | |
if (isUndefined(debugEnviron)) | |
debugEnviron = process.env.NODE_DEBUG || ''; | |
set = set.toUpperCase(); | |
if (!debugs[set]) { | |
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { | |
var pid = process.pid; | |
debugs[set] = function() { | |
var msg = exports.format.apply(exports, arguments); | |
console.error('%s %d: %s', set, pid, msg); | |
}; | |
} else { | |
debugs[set] = function() {}; | |
} | |
} | |
return debugs[set]; | |
}; | |
function inspect(obj, opts) { | |
var ctx = { | |
seen: [], | |
stylize: stylizeNoColor | |
}; | |
if (arguments.length >= 3) ctx.depth = arguments[2]; | |
if (arguments.length >= 4) ctx.colors = arguments[3]; | |
if (isBoolean(opts)) { | |
ctx.showHidden = opts; | |
} else if (opts) { | |
exports._extend(ctx, opts); | |
} | |
if (isUndefined(ctx.showHidden)) ctx.showHidden = false; | |
if (isUndefined(ctx.depth)) ctx.depth = 2; | |
if (isUndefined(ctx.colors)) ctx.colors = false; | |
if (isUndefined(ctx.customInspect)) ctx.customInspect = true; | |
if (ctx.colors) ctx.stylize = stylizeWithColor; | |
return formatValue(ctx, obj, ctx.depth); | |
} | |
exports.inspect = inspect; | |
inspect.colors = { | |
'bold' : [1, 22], | |
'italic' : [3, 23], | |
'underline' : [4, 24], | |
'inverse' : [7, 27], | |
'white' : [37, 39], | |
'grey' : [90, 39], | |
'black' : [30, 39], | |
'blue' : [34, 39], | |
'cyan' : [36, 39], | |
'green' : [32, 39], | |
'magenta' : [35, 39], | |
'red' : [31, 39], | |
'yellow' : [33, 39] | |
}; | |
inspect.styles = { | |
'special': 'cyan', | |
'number': 'yellow', | |
'boolean': 'yellow', | |
'undefined': 'grey', | |
'null': 'bold', | |
'string': 'green', | |
'date': 'magenta', | |
'regexp': 'red' | |
}; | |
function stylizeWithColor(str, styleType) { | |
var style = inspect.styles[styleType]; | |
if (style) { | |
return '\u001b[' + inspect.colors[style][0] + 'm' + str + | |
'\u001b[' + inspect.colors[style][1] + 'm'; | |
} else { | |
return str; | |
} | |
} | |
function stylizeNoColor(str, styleType) { | |
return str; | |
} | |
function arrayToHash(array) { | |
var hash = {}; | |
array.forEach(function(val, idx) { | |
hash[val] = true; | |
}); | |
return hash; | |
} | |
function formatValue(ctx, value, recurseTimes) { | |
if (ctx.customInspect && | |
value && | |
isFunction(value.inspect) && | |
value.inspect !== exports.inspect && | |
!(value.constructor && value.constructor.prototype === value)) { | |
var ret = value.inspect(recurseTimes, ctx); | |
if (!isString(ret)) { | |
ret = formatValue(ctx, ret, recurseTimes); | |
} | |
return ret; | |
} | |
var primitive = formatPrimitive(ctx, value); | |
if (primitive) { | |
return primitive; | |
} | |
var keys = Object.keys(value); | |
var visibleKeys = arrayToHash(keys); | |
if (ctx.showHidden) { | |
keys = Object.getOwnPropertyNames(value); | |
} | |
if (isError(value) | |
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { | |
return formatError(value); | |
} | |
if (keys.length === 0) { | |
if (isFunction(value)) { | |
var name = value.name ? ': ' + value.name : ''; | |
return ctx.stylize('[Function' + name + ']', 'special'); | |
} | |
if (isRegExp(value)) { | |
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); | |
} | |
if (isDate(value)) { | |
return ctx.stylize(Date.prototype.toString.call(value), 'date'); | |
} | |
if (isError(value)) { | |
return formatError(value); | |
} | |
} | |
var base = '', array = false, braces = ['{', '}']; | |
if (isArray(value)) { | |
array = true; | |
braces = ['[', ']']; | |
} | |
if (isFunction(value)) { | |
var n = value.name ? ': ' + value.name : ''; | |
base = ' [Function' + n + ']'; | |
} | |
if (isRegExp(value)) { | |
base = ' ' + RegExp.prototype.toString.call(value); | |
} | |
if (isDate(value)) { | |
base = ' ' + Date.prototype.toUTCString.call(value); | |
} | |
if (isError(value)) { | |
base = ' ' + formatError(value); | |
} | |
if (keys.length === 0 && (!array || value.length == 0)) { | |
return braces[0] + base + braces[1]; | |
} | |
if (recurseTimes < 0) { | |
if (isRegExp(value)) { | |
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); | |
} else { | |
return ctx.stylize('[Object]', 'special'); | |
} | |
} | |
ctx.seen.push(value); | |
var output; | |
if (array) { | |
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); | |
} else { | |
output = keys.map(function(key) { | |
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); | |
}); | |
} | |
ctx.seen.pop(); | |
return reduceToSingleString(output, base, braces); | |
} | |
function formatPrimitive(ctx, value) { | |
if (isUndefined(value)) | |
return ctx.stylize('undefined', 'undefined'); | |
if (isString(value)) { | |
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') | |
.replace(/'/g, "\\'") | |
.replace(/\\"/g, '"') + '\''; | |
return ctx.stylize(simple, 'string'); | |
} | |
if (isNumber(value)) | |
return ctx.stylize('' + value, 'number'); | |
if (isBoolean(value)) | |
return ctx.stylize('' + value, 'boolean'); | |
if (isNull(value)) | |
return ctx.stylize('null', 'null'); | |
} | |
function formatError(value) { | |
return '[' + Error.prototype.toString.call(value) + ']'; | |
} | |
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { | |
var output = []; | |
for (var i = 0, l = value.length; i < l; ++i) { | |
if (hasOwnProperty(value, String(i))) { | |
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, | |
String(i), true)); | |
} else { | |
output.push(''); | |
} | |
} | |
keys.forEach(function(key) { | |
if (!key.match(/^\d+$/)) { | |
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, | |
key, true)); | |
} | |
}); | |
return output; | |
} | |
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { | |
var name, str, desc; | |
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; | |
if (desc.get) { | |
if (desc.set) { | |
str = ctx.stylize('[Getter/Setter]', 'special'); | |
} else { | |
str = ctx.stylize('[Getter]', 'special'); | |
} | |
} else { | |
if (desc.set) { | |
str = ctx.stylize('[Setter]', 'special'); | |
} | |
} | |
if (!hasOwnProperty(visibleKeys, key)) { | |
name = '[' + key + ']'; | |
} | |
if (!str) { | |
if (ctx.seen.indexOf(desc.value) < 0) { | |
if (isNull(recurseTimes)) { | |
str = formatValue(ctx, desc.value, null); | |
} else { | |
str = formatValue(ctx, desc.value, recurseTimes - 1); | |
} | |
if (str.indexOf('\n') > -1) { | |
if (array) { | |
str = str.split('\n').map(function(line) { | |
return ' ' + line; | |
}).join('\n').substr(2); | |
} else { | |
str = '\n' + str.split('\n').map(function(line) { | |
return ' ' + line; | |
}).join('\n'); | |
} | |
} | |
} else { | |
str = ctx.stylize('[Circular]', 'special'); | |
} | |
} | |
if (isUndefined(name)) { | |
if (array && key.match(/^\d+$/)) { | |
return str; | |
} | |
name = JSON.stringify('' + key); | |
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { | |
name = name.substr(1, name.length - 2); | |
name = ctx.stylize(name, 'name'); | |
} else { | |
name = name.replace(/'/g, "\\'") | |
.replace(/\\"/g, '"') | |
.replace(/(^"|"$)/g, "'"); | |
name = ctx.stylize(name, 'string'); | |
} | |
} | |
return name + ': ' + str; | |
} | |
function reduceToSingleString(output, base, braces) { | |
var numLinesEst = 0; | |
var length = output.reduce(function(prev, cur) { | |
numLinesEst++; | |
if (cur.indexOf('\n') >= 0) numLinesEst++; | |
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; | |
}, 0); | |
if (length > 60) { | |
return braces[0] + | |
(base === '' ? '' : base + '\n ') + | |
' ' + | |
output.join(',\n ') + | |
' ' + | |
braces[1]; | |
} | |
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; | |
} | |
function isArray(ar) { | |
return Array.isArray(ar); | |
} | |
exports.isArray = isArray; | |
function isBoolean(arg) { | |
return typeof arg === 'boolean'; | |
} | |
exports.isBoolean = isBoolean; | |
function isNull(arg) { | |
return arg === null; | |
} | |
exports.isNull = isNull; | |
function isNullOrUndefined(arg) { | |
return arg == null; | |
} | |
exports.isNullOrUndefined = isNullOrUndefined; | |
function isNumber(arg) { | |
return typeof arg === 'number'; | |
} | |
exports.isNumber = isNumber; | |
function isString(arg) { | |
return typeof arg === 'string'; | |
} | |
exports.isString = isString; | |
function isSymbol(arg) { | |
return typeof arg === 'symbol'; | |
} | |
exports.isSymbol = isSymbol; | |
function isUndefined(arg) { | |
return arg === void 0; | |
} | |
exports.isUndefined = isUndefined; | |
function isRegExp(re) { | |
return isObject(re) && objectToString(re) === '[object RegExp]'; | |
} | |
exports.isRegExp = isRegExp; | |
function isObject(arg) { | |
return typeof arg === 'object' && arg !== null; | |
} | |
exports.isObject = isObject; | |
function isDate(d) { | |
return isObject(d) && objectToString(d) === '[object Date]'; | |
} | |
exports.isDate = isDate; | |
function isError(e) { | |
return isObject(e) && | |
(objectToString(e) === '[object Error]' || e instanceof Error); | |
} | |
exports.isError = isError; | |
function isFunction(arg) { | |
return typeof arg === 'function'; | |
} | |
exports.isFunction = isFunction; | |
function isPrimitive(arg) { | |
return arg === null || | |
typeof arg === 'boolean' || | |
typeof arg === 'number' || | |
typeof arg === 'string' || | |
typeof arg === 'symbol' || // ES6 symbol | |
typeof arg === 'undefined'; | |
} | |
exports.isPrimitive = isPrimitive; | |
exports.isBuffer = require('./support/isBuffer'); | |
function objectToString(o) { | |
return Object.prototype.toString.call(o); | |
} | |
function pad(n) { | |
return n < 10 ? '0' + n.toString(10) : n.toString(10); | |
} | |
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', | |
'Oct', 'Nov', 'Dec']; | |
function timestamp() { | |
var d = new Date(); | |
var time = [pad(d.getHours()), | |
pad(d.getMinutes()), | |
pad(d.getSeconds())].join(':'); | |
return [d.getDate(), months[d.getMonth()], time].join(' '); | |
} | |
exports.log = function() { | |
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); | |
}; | |
exports.inherits = require('inherits'); | |
exports._extend = function(origin, add) { | |
if (!add || !isObject(add)) return origin; | |
var keys = Object.keys(add); | |
var i = keys.length; | |
while (i--) { | |
origin[keys[i]] = add[keys[i]]; | |
} | |
return origin; | |
}; | |
function hasOwnProperty(obj, prop) { | |
return Object.prototype.hasOwnProperty.call(obj, prop); | |
} | |
},{"./support/isBuffer":28,"__browserify_process":11,"inherits":9}],30:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var Buffer = require('buffer').Buffer; | |
function Shape(rules, options) { | |
if (!rules) { | |
this.rules = { type: 'structure', members: {} }; | |
return; | |
} | |
this.options = options; | |
this.rules = {}; | |
this.set_type(rules.type); | |
AWS.util.each.call(this, rules, function (key, value) { | |
if (key !== 'type') this['set_' + key](value); | |
}); | |
if (this.rules.type === 'blob') { | |
if (this.rules.payload || this.rules.streaming) { | |
this.rules.type = 'binary'; | |
} else { | |
this.rules.type = 'base64'; | |
} | |
} | |
} | |
function InputShape(rules, options) { | |
Shape.call(this, rules, options); | |
} | |
function OutputShape(rules, options) { | |
Shape.call(this, rules, options); | |
} | |
Shape.prototype = { | |
shapeClass: function() { | |
if (this instanceof InputShape) return InputShape; | |
if (this instanceof OutputShape) return OutputShape; | |
}, | |
xmlname: function() { | |
if (this.rules.flattened) { | |
return this._xmlname || (this.rules.members || {}).name; | |
} else { | |
return this._xmlname; | |
} | |
}, | |
set_type: function(name) { | |
var types = { | |
structure: 'structure', | |
list: 'list', | |
map: 'map', | |
boolean: 'boolean', | |
timestamp: 'timestamp', | |
character: 'string', | |
double: 'float', | |
float: 'float', | |
integer: 'integer', | |
long: 'integer', | |
short: 'integer', | |
string: 'string', | |
blob: 'blob', | |
biginteger: 'integer', | |
bigdecimal: 'float' | |
}; | |
if (name === 'string') { // omit string to reduce size | |
} else if (types[name]) { | |
this.rules.type = types[name]; | |
} else { | |
throw new Error('unhandled shape type ' + name); | |
} | |
}, | |
set_members: function(members) { | |
var type = this.rules.type; | |
var ShapeClass = this.shapeClass(); | |
if (type === 'structure') { | |
this.rules.members = {}; | |
AWS.util.each.call(this, members, function(memberName, memberRules) { | |
var shape = new ShapeClass(memberRules, this.options); | |
if (this.swapNames(shape)) { | |
shape.rules.name = memberName; | |
memberName = shape.xmlname(); | |
} | |
this.rules.members[memberName] = shape.rules; | |
}); | |
} else if (type === 'list') { | |
this.rules.members = new ShapeClass(members, this.options).rules; | |
} else if (type === 'map') { | |
this.rules.members = new ShapeClass(members, this.options).rules; | |
} else if (type === 'blob') { | |
this.rules.members = {}; | |
} else { | |
throw new Error('unhandled complex shape `' + type + '\''); | |
} | |
}, | |
set_keys: function(rules) { | |
var ShapeClass = this.shapeClass(); | |
this.rules.keys = new ShapeClass(rules, this.options).rules; | |
}, | |
set_timestamp_format: function(format) { | |
this.rules.format = format; | |
}, | |
set_xmlname: function(name) { | |
this._xmlname = name; | |
this.rules.name = name; | |
}, | |
set_location: function (location) { | |
this.rules.location = (location === 'http_status' ? 'status' : location); | |
}, | |
set_location_name: function(header_name) { | |
this.rules.name = header_name; | |
}, | |
set_payload: function(state) { | |
if (state) this.rules.payload = true; | |
}, | |
set_flattened: function(state) { | |
if (state) this.rules.flattened = true; | |
}, | |
set_streaming: function(state) { | |
if (state) this.rules.streaming = true; | |
}, | |
set_wrapper: function(state) { | |
if (state) this.rules.wrapper = true; | |
}, | |
set_xmlattribute: function(state) { | |
if (state) this.rules.attribute = true; | |
}, | |
set_xmlnamespace: function(ns) { | |
this.rules.xmlns = ns; | |
}, | |
set_documentation: function(docs) { | |
if (this.options.documentation) this.rules.documentation = docs; | |
}, | |
set_enum: function(values) { | |
if (this.options.documentation) this.rules.enum = values; | |
}, | |
set_shape_name: function() {}, | |
set_box: function() {}, | |
set_sensitive: function() {} | |
}; | |
InputShape.prototype = AWS.util.merge(Shape.prototype, { | |
swapNames: function() { return false; }, | |
set_required: function() { this.rules.required = true; }, | |
set_member_order: function(order) { this.rules.order = order; }, | |
set_min_length: function(min) { | |
if (this.options.documentation) this.rules.min_length = min; | |
}, | |
set_max_length: function(max) { | |
if (this.options.documentation) this.rules.max_length = max; | |
}, | |
set_pattern: function(pattern) { | |
if (this.options.documentation) this.rules.pattern = pattern; | |
} | |
}); | |
OutputShape.prototype = AWS.util.merge(Shape.prototype, { | |
swapNames: function(shape) { | |
if (this.options.documentation) return false; | |
return shape.xmlname() && ['query', 'rest-xml'].indexOf(this.options.type) >= 0; | |
}, | |
set_required: function() {}, | |
set_member_order: function() {}, | |
set_min_length: function() {}, | |
set_max_length: function() {}, | |
set_pattern: function() {} | |
}); | |
function Operation(rules, options) { | |
var origRules = rules; | |
function normalizeInputs() { | |
if (options.type.indexOf('rest') < 0) return; | |
var xml = options.type.indexOf('xml') >= 0; | |
var payload = false; | |
var wrapper = false; | |
var hasPayload = false; | |
AWS.util.each(rules.input.members, function (name, rule) { | |
if (rule.payload) { | |
hasPayload = true; | |
payload = name; | |
delete rule.payload; | |
return AWS.util.abort; | |
} | |
}); | |
if (!hasPayload) { | |
var list = []; | |
AWS.util.each(rules.input.members, function (name, rule) { | |
if (!rule.location) { list.push(name); } | |
}); | |
if (list.length > 0) { | |
payload = list; | |
if (xml) wrapper = origRules.input.shape_name; | |
} | |
} | |
if (wrapper) rules.input = AWS.util.merge({wrapper: wrapper}, rules.input); | |
if (payload) rules.input = AWS.util.merge({payload: payload}, rules.input); | |
} | |
function normalizeOutputs() { | |
var moveUp = null; | |
AWS.util.each(rules.output.members, function(memberName, rule) { | |
if (rule.payload && rule.type === 'structure') { | |
delete rule.payload; | |
moveUp = memberName; | |
} | |
else if (rule.payload || rule.streaming) { | |
delete rule.payload; | |
rules.output.payload = memberName; | |
} | |
}); | |
if (moveUp) { | |
var rule = rules.output.members[moveUp]; | |
delete rules.output.members[moveUp]; | |
AWS.util.update(rules.output.members, rule.members); | |
} | |
} | |
rules = AWS.util.copy(rules); | |
rules.input = new InputShape(rules.input, options).rules; | |
rules.output = new OutputShape(rules.output, options).rules; | |
rules.input.members = rules.input.members || {}; | |
rules.output.members = rules.output.members || {}; | |
normalizeInputs(); | |
normalizeOutputs(); | |
if (rules.http) delete rules.http.response_code; | |
if (options.documentation) { | |
rules.errors = rules.errors.map(function(e) { return e.shape_name; }); | |
} else { | |
delete rules.errors; | |
delete rules.documentation; | |
delete rules.documentation_url; | |
delete rules.response_code; | |
} | |
return rules; | |
} | |
function Translator(api, options) { | |
function inflect(key) { | |
return key.replace(/_(\w)/g, function (_, m) { return m.toUpperCase(); }); | |
} | |
function setTranslatedKeys() { | |
var list = Object.keys(api); | |
list.push('timestamp_format'); | |
list.sort().forEach(function (key) { translate[inflect(key)] = api[key]; }); | |
translate.timestampFormat = translate.timestampFormat || 'iso8601'; | |
if (translate.jsonVersion) translate.jsonVersion = translate.jsonVersion.toString(); | |
if (translate.jsonVersion === '1') translate.jsonVersion = '1.0'; | |
if (!options.documentation) delete translate.documentation; | |
if (!translate.resultWrapped) delete translate.resultWrapped; | |
if (!api.type.match(/xml/)) delete translate.xmlnamespace; | |
delete translate.operations; | |
delete translate.pagination; | |
delete translate.waiters; | |
delete translate.type; | |
} | |
function setOperations() { | |
translate.operations = {}; | |
AWS.util.each(api.operations, function (key, value) { | |
var methodName = key[0].toLowerCase() + key.substr(1); | |
methodName = methodName.replace(/\d{4}_\d{2}_\d{2}$/, ''); | |
var operation = new Operation(value, options); | |
translate.operations[methodName] = operation; | |
}); | |
} | |
function setPagination() { | |
if (api.pagination) { | |
translate.pagination = {}; | |
AWS.util.each(api.pagination, function (key, value) { | |
var object = {}; | |
AWS.util.each(value, function (k2, v2) { object[inflect(k2)] = v2; }); | |
translate.pagination[key[0].toLowerCase() + key.substr(1)] = object; | |
}); | |
} | |
} | |
if (typeof api === 'string' || Buffer.isBuffer(api)) { | |
api = JSON.parse(api); | |
} | |
options = options || {}; | |
options.type = api.type; | |
var translate = {}; | |
translate.format = api.type; | |
setTranslatedKeys(); | |
setOperations(); | |
setPagination(); | |
return translate; | |
} | |
AWS.API = { Translator: Translator }; | |
module.exports = Translator; | |
},{"../core":33,"buffer":12}],31:[function(require,module,exports){ | |
window.AWS = module.exports = require('./core'); | |
require('./http/xhr'); | |
require('./services'); | |
},{"./core":33,"./http/xhr":41,"./services":52}],32:[function(require,module,exports){ | |
var AWS = require('./core'); | |
require('./credentials'); | |
require('./credentials/credential_provider_chain'); | |
AWS.Config = AWS.util.inherit({ | |
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); | |
}); | |
}, | |
update: function update(options, allowUnknownKeys) { | |
allowUnknownKeys = allowUnknownKeys || false; | |
options = this.extractCredentials(options); | |
AWS.util.each.call(this, options, function (key, value) { | |
if (allowUnknownKeys || this.keys.hasOwnProperty(key)) this[key] = value; | |
}); | |
}, | |
getCredentials: 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 | |
}); | |
} | |
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')); | |
} | |
}, | |
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); | |
return this; | |
}, | |
clear: function clear() { | |
AWS.util.each.call(this, this.keys, function (key) { | |
delete this[key]; | |
}); | |
this.set('credentials', undefined); | |
this.set('credentialProvider', undefined); | |
}, | |
set: 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 { | |
this[property] = value; | |
} | |
}, | |
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, | |
dynamoDbCrc32: true | |
}, | |
extractCredentials: function extractCredentials(options) { | |
if (options.accessKeyId && options.secretAccessKey) { | |
options = AWS.util.copy(options); | |
options.credentials = new AWS.Credentials(options); | |
} | |
return options; | |
} | |
}); | |
AWS.config = new AWS.Config(); | |
},{"./core":33,"./credentials":34,"./credentials/credential_provider_chain":35}],33:[function(require,module,exports){ | |
var AWS = {}; | |
module.exports = AWS; | |
require('./util'); | |
AWS.util.update(AWS, { | |
VERSION: '2.0.0-rc8', | |
ServiceInterface: {}, | |
Signers: {}, | |
XML: {} | |
}); | |
require('./service'); | |
require('./credentials'); | |
require('./credentials/credential_provider_chain'); | |
require('./credentials/temporary_credentials'); | |
require('./credentials/web_identity_credentials'); | |
require('./credentials/saml_credentials'); | |
require('./config'); | |
require('./http'); | |
require('./sequential_executor'); | |
require('./event_listeners'); | |
require('./request'); | |
require('./signers/request_signer'); | |
require('./param_validator'); | |
AWS.events = new AWS.SequentialExecutor(); | |
if (typeof window !== 'undefined') window.AWS = AWS; | |
},{"./config":32,"./credentials":34,"./credentials/credential_provider_chain":35,"./credentials/saml_credentials":36,"./credentials/temporary_credentials":37,"./credentials/web_identity_credentials":38,"./event_listeners":39,"./http":40,"./param_validator":43,"./request":44,"./sequential_executor":45,"./service":46,"./signers/request_signer":59,"./util":65}],34:[function(require,module,exports){ | |
var AWS = require('./core'); | |
AWS.Credentials = AWS.util.inherit({ | |
constructor: function Credentials() { | |
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]; | |
} | |
}, | |
expiryWindow: 15, | |
needsRefresh: 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; | |
} | |
}, | |
get: 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(); | |
} | |
}, | |
refresh: function refresh(callback) { | |
this.expired = false; | |
callback(); | |
} | |
}); | |
},{"./core":33}],35:[function(require,module,exports){ | |
var AWS = require('../core'); | |
require('../credentials'); | |
AWS.CredentialProviderChain = AWS.util.inherit(AWS.Credentials, { | |
constructor: function CredentialProviderChain(providers) { | |
if (providers) { | |
this.providers = providers; | |
} else { | |
this.providers = AWS.CredentialProviderChain.defaultProviders.slice(0); | |
} | |
}, | |
resolve: function resolve(callback) { | |
if (this.providers.length === 0) { | |
callback(new Error('No providers')); | |
return; | |
} | |
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(err) { | |
resolveNext(err, err ? null : creds); | |
}); | |
} else { | |
resolveNext(null, creds); | |
} | |
} | |
resolveNext(); | |
return this; | |
} | |
}); | |
AWS.CredentialProviderChain.defaultProviders = []; | |
},{"../core":33,"../credentials":34}],36:[function(require,module,exports){ | |
var AWS = require('../core'); | |
require('../credentials'); | |
require('../services/sts'); | |
AWS.SAMLCredentials = AWS.util.inherit(AWS.Credentials, { | |
constructor: function SAMLCredentials(params) { | |
AWS.Credentials.call(this); | |
this.expired = true; | |
this.service = new AWS.STS(); | |
this.params = params; | |
}, | |
refresh: function refresh(callback) { | |
var self = this; | |
if (!callback) callback = function(err) { if (err) throw err; }; | |
self.service.assumeRoleWithSAML(self.params, function (err, data) { | |
if (!err) { | |
self.service.credentialsFrom(data, self); | |
} | |
callback(err); | |
}); | |
} | |
}); | |
},{"../core":33,"../credentials":34,"../services/sts":57}],37:[function(require,module,exports){ | |
var AWS = require('../core'); | |
require('../credentials'); | |
require('../services/sts'); | |
AWS.TemporaryCredentials = AWS.util.inherit(AWS.Credentials, { | |
constructor: function TemporaryCredentials(params) { | |
AWS.Credentials.call(this); | |
this.loadMasterCredentials(); | |
this.service = new AWS.STS(); | |
this.expired = true; | |
this.params = params || {}; | |
if (this.params.RoleArn) { | |
this.params.RoleSessionName = | |
this.params.RoleSessionName || 'temporary-credentials'; | |
} | |
}, | |
refresh: function refresh(callback) { | |
var self = this; | |
if (!callback) callback = function(err) { if (err) throw err; }; | |
self.service.config.credentials = self.masterCredentials; | |
var operation = self.params.RoleArn ? | |
self.service.assumeRole : self.service.getSessionToken; | |
operation.call(self.service, self.params, function (err, data) { | |
if (!err) { | |
self.service.credentialsFrom(data, self); | |
} | |
callback(err); | |
}); | |
}, | |
loadMasterCredentials: function loadMasterCredentials() { | |
this.masterCredentials = AWS.config.credentials; | |
while (this.masterCredentials.masterCredentials) { | |
this.masterCredentials = this.masterCredentials.masterCredentials; | |
} | |
} | |
}); | |
},{"../core":33,"../credentials":34,"../services/sts":57}],38:[function(require,module,exports){ | |
var AWS = require('../core'); | |
require('../credentials'); | |
require('../services/sts'); | |
AWS.WebIdentityCredentials = AWS.util.inherit(AWS.Credentials, { | |
constructor: function WebIdentityCredentials(params) { | |
AWS.Credentials.call(this); | |
this.expired = true; | |
this.service = new AWS.STS(); | |
this.params = params; | |
this.params.RoleSessionName = this.params.RoleSessionName || 'web-identity'; | |
}, | |
refresh: function refresh(callback) { | |
var self = this; | |
if (!callback) callback = function(err) { if (err) throw err; }; | |
self.service.assumeRoleWithWebIdentity(self.params, function (err, data) { | |
if (!err) { | |
self.service.credentialsFrom(data, self); | |
} | |
callback(err); | |
}); | |
} | |
}); | |
},{"../core":33,"../credentials":34,"../services/sts":57}],39:[function(require,module,exports){ | |
var AWS = require('./core'); | |
require('./sequential_executor'); | |
require('./service_interface/json'); | |
require('./service_interface/query'); | |
require('./service_interface/rest'); | |
require('./service_interface/rest_json'); | |
require('./service_interface/rest_xml'); | |
var Buffer = require('buffer').Buffer; | |
AWS.EventListeners = { | |
Core: {} /* doc hack */ | |
}; | |
AWS.EventListeners = { | |
Core: new AWS.SequentialExecutor().addNamedListeners(function(add, addAsync) { | |
addAsync('VALIDATE_CREDENTIALS', 'validate', | |
function VALIDATE_CREDENTIALS(req, doneCallback) { | |
req.service.config.getCredentials(function(err) { | |
if (err) { | |
err = AWS.util.error(err, | |
{code: 'SigningError', message: 'Missing credentials in config'}); | |
} | |
doneCallback(err); | |
}); | |
}); | |
add('VALIDATE_REGION', 'validate', function VALIDATE_REGION(req) { | |
if (!req.service.config.region && !req.service.hasGlobalEndpoint()) { | |
throw AWS.util.error(new Error(), | |
{code: 'SigningError', message: 'Missing region in config'}); | |
} | |
}); | |
add('VALIDATE_PARAMETERS', 'validate', function VALIDATE_PARAMETERS(req) { | |
var rules = req.service.api.operations[req.operation].input; | |
new AWS.ParamValidator().validate(rules, req.params); | |
}); | |
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; | |
}); | |
addAsync('SIGN', 'sign', function SIGN(req, doneCallback) { | |
if (!req.service.api.signatureVersion) return doneCallback(); // none | |
req.service.config.getCredentials(function (err, credentials) { | |
try { | |
if (err) return doneCallback(err); | |
var date = AWS.util.date.getDate(); | |
var SignerClass = req.service.getSignerClass(req); | |
var signer = new SignerClass(req.httpRequest, | |
req.service.api.signingName || req.service.api.endpointPrefix); | |
delete req.httpRequest.headers['Authorization']; | |
delete req.httpRequest.headers['Date']; | |
delete req.httpRequest.headers['X-Amz-Date']; | |
signer.addAuthorization(credentials, date); | |
doneCallback(); | |
} catch (e) { | |
doneCallback(e); | |
} | |
}); | |
}); | |
add('SETUP_ERROR', 'extractError', function SETUP_ERROR(resp) { | |
if (this.service.successfulResponse(resp, this)) { | |
throw null; | |
} | |
resp.error = AWS.util.error(new Error(), | |
{code: 'UnknownError', message: 'An unknown error occurred.'}); | |
resp.data = null; | |
}); | |
add('SETUP_DATA', 'extractData', function SETUP_DATA(resp) { | |
resp.data = {}; | |
resp.error = null; | |
}); | |
add('SEND', 'send', function SEND(resp) { | |
function callback(httpResp) { | |
resp.httpResponse.stream = httpResp; | |
httpResp.on('headers', function onHeaders(statusCode, headers) { | |
resp.request.emitEvent('httpHeaders', [statusCode, headers, resp]); | |
if (!resp.request.httpRequest._streaming) { | |
if (AWS.HttpClient.streamsApiVersion === 2) { // streams2 API check | |
httpResp.on('readable', function onReadable() { | |
var data = httpResp.read(); | |
if (data !== null) { | |
resp.request.emitEvent('httpData', [data, resp]); | |
} | |
}); | |
} else { // legacy streams API | |
httpResp.on('data', function onData(data) { | |
resp.request.emitEvent('httpData', [data, resp]); | |
}); | |
} | |
} | |
}); | |
httpResp.on('end', function onEnd() { | |
resp.request.emitEvent('httpDone', [resp]); | |
}); | |
} | |
function progress(httpResp) { | |
httpResp.on('sendProgress', function onSendProgress(progress) { | |
resp.request.emitEvent('httpUploadProgress', [progress, resp]); | |
}); | |
httpResp.on('receiveProgress', function onReceiveProgress(progress) { | |
resp.request.emitEvent('httpDownloadProgress', [progress, resp]); | |
}); | |
} | |
function error(err) { | |
err = AWS.util.error(err, { | |
code: 'NetworkingError', | |
region: resp.request.httpRequest.region, | |
hostname: resp.request.httpRequest.endpoint.hostname, | |
retryable: true | |
}); | |
resp.request.emitEvent('httpError', [err, resp]); | |
} | |
var http = AWS.HttpClient.getInstance(); | |
var httpOptions = resp.request.service.config.httpOptions || {}; | |
var s = http.handleRequest(this.httpRequest, httpOptions, callback, error); | |
progress(s); | |
}); | |
add('HTTP_HEADERS', 'httpHeaders', | |
function HTTP_HEADERS(statusCode, headers, resp) { | |
resp.httpResponse.statusCode = statusCode; | |
resp.httpResponse.headers = headers; | |
resp.httpResponse.body = new Buffer(''); | |
resp.httpResponse.buffers = []; | |
resp.httpResponse.numBytes = 0; | |
}); | |
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.emitEvent('httpDownloadProgress', [progress, resp]); | |
} | |
resp.httpResponse.buffers.push(new Buffer(chunk)); | |
} | |
}); | |
add('HTTP_DONE', 'httpDone', function HTTP_DONE(resp) { | |
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; | |
this.completeRequest(resp); | |
}); | |
add('HTTP_ERROR', 'httpError', function HTTP_ERROR(error, resp) { | |
resp.error = error; | |
this.completeRequest(resp); | |
}); | |
add('FINALIZE_ERROR', 'retry', function FINALIZE_ERROR(resp) { | |
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) { | |
switch (resp.error.code) { | |
case 'RequestExpired': // EC2 only | |
case 'ExpiredTokenException': | |
case 'ExpiredToken': | |
resp.error.retryable = true; | |
resp.request.service.config.credentials.expired = true; | |
} | |
}); | |
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']); | |
resp.error.redirect = true; | |
resp.error.retryable = true; | |
} | |
}); | |
add('RETRY_CHECK', 'retry', function RETRY_CHECK(resp) { | |
if (resp.error) { | |
if (resp.error.redirect && resp.redirectCount < this.service.config.maxRedirects) { | |
resp.redirectCount++; | |
} else if (resp.error.retryable && resp.retryCount < this.service.numRetries()) { | |
resp.retryCount++; | |
} else { | |
throw resp.error; | |
} | |
} | |
}); | |
addAsync('RETRY_SIGN', 'retry', function RETRY_SIGN(resp, doneCallback) { | |
this.emitEvent('sign', resp, doneCallback); | |
}); | |
addAsync('RETRY_DELAY_SEND', 'retry', function RETRY_DELAY_SEND(resp, doneCallback) { | |
var delay = 0; | |
if (!resp.error.redirect) { | |
delay = this.service.retryDelays()[resp.retryCount-1] || 0; | |
} | |
resp.error = null; | |
resp.data = null; | |
setTimeout(function() { | |
resp.request.emitEvent('send', resp, doneCallback); | |
}, delay); | |
}); | |
}), | |
Logger: new AWS.SequentialExecutor().addNamedListeners(function(add) { | |
add('LOG_REQUEST', 'complete', function LOG_REQUEST(resp) { | |
var req = resp.request; | |
var logger = req.service.config.logger; | |
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, true); | |
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 += ' ' + req.operation + '(' + params + ')'; | |
if (ansi) message += '\x1B[0m'; | |
return message; | |
} | |
var message = buildMessage(); | |
if (typeof logger.log === 'function') { | |
logger.log(message); | |
} else if (typeof logger.write === 'function') { | |
logger.write(message + '\n'); | |
} | |
}); | |
}), | |
Json: new AWS.SequentialExecutor().addNamedListeners(function(add) { | |
var svc = AWS.ServiceInterface.Json; | |
add('BUILD', 'build', svc.buildRequest); | |
add('EXTRACT_DATA', 'extractData', svc.extractData); | |
add('EXTRACT_ERROR', 'extractError', svc.extractError); | |
}), | |
Rest: new AWS.SequentialExecutor().addNamedListeners(function(add) { | |
var svc = AWS.ServiceInterface.Rest; | |
add('BUILD', 'build', svc.buildRequest); | |
add('EXTRACT_DATA', 'extractData', svc.extractData); | |
add('EXTRACT_ERROR', 'extractError', svc.extractError); | |
}), | |
RestJson: new AWS.SequentialExecutor().addNamedListeners(function(add) { | |
var svc = AWS.ServiceInterface.RestJson; | |
add('BUILD', 'build', svc.buildRequest); | |
add('EXTRACT_DATA', 'extractData', svc.extractData); | |
add('EXTRACT_ERROR', 'extractError', svc.extractError); | |
}), | |
RestXml: new AWS.SequentialExecutor().addNamedListeners(function(add) { | |
var svc = AWS.ServiceInterface.RestXml; | |
add('BUILD', 'build', svc.buildRequest); | |
add('EXTRACT_DATA', 'extractData', svc.extractData); | |
add('EXTRACT_ERROR', 'extractError', svc.extractError); | |
}), | |
Query: new AWS.SequentialExecutor().addNamedListeners(function(add) { | |
var svc = AWS.ServiceInterface.Query; | |
add('BUILD', 'build', svc.buildRequest); | |
add('EXTRACT_DATA', 'extractData', svc.extractData); | |
add('EXTRACT_ERROR', 'extractError', svc.extractError); | |
}) | |
}; | |
},{"./core":33,"./sequential_executor":45,"./service_interface/json":47,"./service_interface/query":48,"./service_interface/rest":49,"./service_interface/rest_json":50,"./service_interface/rest_xml":51,"buffer":12,"util":29}],40:[function(require,module,exports){ | |
var AWS = require('./core'); | |
var inherit = AWS.util.inherit; | |
AWS.Endpoint = inherit({ | |
constructor: 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)); | |
if (this.port) { | |
this.port = parseInt(this.port, 10); | |
} else { | |
this.port = this.protocol === 'https:' ? 443 : 80; | |
} | |
} | |
}); | |
AWS.HttpRequest = inherit({ | |
constructor: 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.setUserAgent(); | |
}, | |
setUserAgent: function setUserAgent() { | |
var prefix = AWS.util.isBrowser() ? 'X-Amz-' : ''; | |
this.headers[prefix + 'User-Agent'] = AWS.util.userAgent(); | |
}, | |
pathname: function pathname() { | |
return this.path.split('?', 1)[0]; | |
}, | |
search: function search() { | |
return this.path.split('?', 2)[1] || ''; | |
} | |
}); | |
AWS.HttpResponse = inherit({ | |
constructor: function HttpResponse() { | |
this.statusCode = undefined; | |
this.headers = {}; | |
this.body = undefined; | |
} | |
}); | |
AWS.HttpClient = inherit({}); | |
AWS.HttpClient.getInstance = function getInstance() { | |
if (this.singleton === undefined) { | |
this.singleton = new this(); | |
} | |
return this.singleton; | |
}; | |
},{"./core":33}],41:[function(require,module,exports){ | |
var Buffer=require("__browserify_Buffer");var AWS = require('../core'); | |
var EventEmitter = require('events').EventEmitter; | |
require('../http'); | |
AWS.XHRClient = AWS.util.inherit({ | |
handleRequest: function handleRequest(httpRequest, httpOptions, callback, errCallback) { | |
var self = this; | |
var endpoint = httpRequest.endpoint; | |
var emitter = new EventEmitter(); | |
var href = endpoint.protocol + '//' + endpoint.hostname; | |
if (endpoint.port != 80 && endpoint.port != 443) { | |
href += ':' + endpoint.port; | |
} | |
href += httpRequest.path; | |
var xhr = new XMLHttpRequest(); | |
httpRequest.stream = xhr; | |
if (httpOptions.timeout) { | |
xhr.timeout = httpOptions.timeout; | |
} | |
var failed = false; // toggle failed if invalid state is set | |
xhr.addEventListener('readystatechange', function() { | |
if (failed) return; // fail fast if in invalid state | |
if (this.readyState === this.HEADERS_RECEIVED) { | |
try { xhr.responseType = 'arraybuffer'; } catch (e) {} | |
if (xhr.status === 0) { failed = true; return; } // 0 code is invalid | |
emitter.statusCode = xhr.status; | |
emitter.headers = self.parseHeaders(xhr.getAllResponseHeaders()); | |
emitter.emit('headers', emitter.statusCode, emitter.headers); | |
} else if (this.readyState === this.DONE) { | |
self.finishRequest(xhr, emitter); | |
} | |
}, false); | |
xhr.upload.addEventListener('progress', function (evt) { | |
emitter.emit('sendProgress', evt); | |
}); | |
xhr.addEventListener('progress', function (evt) { | |
emitter.emit('receiveProgress', evt); | |
}, false); | |
xhr.addEventListener('timeout', function () { | |
errCallback(AWS.util.error(new Error('Timeout'), {code: 'TimeoutError'})); | |
}, false); | |
xhr.addEventListener('error', function () { | |
errCallback(AWS.util.error(new Error('Network Failure'), { | |
code: 'NetworkingError' | |
})); | |
}, false); | |
callback(emitter); | |
xhr.open(httpRequest.method, href, true); | |
AWS.util.each(httpRequest.headers, function (key, value) { | |
if (key !== 'Content-Length' && key !== 'User-Agent' && key !== 'Host') { | |
xhr.setRequestHeader(key, value); | |
} | |
}); | |
if (httpRequest.body && typeof httpRequest.body.buffer === 'object') { | |
xhr.send(httpRequest.body.buffer); // typed arrays sent as ArrayBuffer | |
} else { | |
xhr.send(httpRequest.body); | |
} | |
return emitter; | |
}, | |
parseHeaders: function parseHeaders(rawHeaders) { | |
var headers = {}; | |
AWS.util.arrayEach(rawHeaders.split(/\r?\n/), function (line) { | |
var key = line.split(':', 1)[0]; | |
var value = line.substring(key.length + 2); | |
if (key.length > 0) headers[key] = value; | |
}); | |
return headers; | |
}, | |
finishRequest: function finishRequest(xhr, emitter) { | |
var buffer; | |
if (xhr.responseType === 'arraybuffer' && xhr.response) { | |
var ab = xhr.response; | |
buffer = new Buffer(ab.byteLength); | |
var view = new Uint8Array(ab); | |
for (var i = 0; i < buffer.length; ++i) { | |
buffer[i] = view[i]; | |
} | |
} | |
try { | |
if (!buffer && typeof xhr.responseText === 'string') { | |
buffer = new Buffer(xhr.responseText); | |
} | |
} catch (e) {} | |
if (buffer) emitter.emit('data', buffer); | |
emitter.emit('end'); | |
} | |
}); | |
AWS.HttpClient.prototype = AWS.XHRClient.prototype; | |
AWS.HttpClient.streamsApiVersion = 1; | |
},{"../core":33,"../http":40,"__browserify_Buffer":10,"events":8}],42:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var inherit = AWS.util.inherit; | |
AWS.JSON = {}; | |
AWS.JSON.Builder = inherit({ | |
constructor: function JSONBuilder(rules, options) { | |
this.rules = rules; | |
this.timestampFormat = options.timestampFormat; | |
}, | |
build: function build(params) { | |
return JSON.stringify(this.translate(this.rules, params)); | |
}, | |
translate: function translate(rules, value) { | |
if (rules.type == 'structure') { | |
var struct = {}; | |
AWS.util.each.call(this, value, function (memberName, memberValue) { | |
var memberRules = rules.members[memberName] || {}; | |
struct[memberName] = this.translate(memberRules, memberValue); | |
}); | |
return struct; | |
} else if (rules.type == 'list') { | |
var list = []; | |
AWS.util.arrayEach.call(this, value, function (memberValue) { | |
var memberRules = rules.members || {}; | |
list.push(this.translate(memberRules, memberValue)); | |
}); | |
return list; | |
} else if (rules.type == 'map') { | |
var map = {}; | |
AWS.util.each.call(this, value, function (memberName, memberValue) { | |
var memberRules = rules.members || {}; | |
map[memberName] = this.translate(memberRules, memberValue); | |
}); | |
return map; | |
} else if (rules.type == 'timestamp') { | |
var timestampFormat = rules.format || this.timestampFormat; | |
return AWS.util.date.format(value, timestampFormat); | |
} else if (rules.type == 'integer') { | |
return parseInt(value, 10); | |
} else if (rules.type == 'float') { | |
return parseFloat(value); | |
} else { | |
return value; | |
} | |
} | |
}); | |
},{"../core":33}],43:[function(require,module,exports){ | |
var Buffer=require("__browserify_Buffer");var AWS = require('./core'); | |
AWS.ParamValidator = AWS.util.inherit({ | |
validate: function validate(rules, params, context) { | |
var cRules = (rules || {}).members || {}; | |
var payload = rules ? rules.xml : null; | |
if (payload) { | |
cRules = AWS.util.merge(cRules, (cRules[payload] || {}).members || {}); | |
delete cRules[payload]; | |
} | |
return this.validateStructure(cRules, params || {}, context || 'params'); | |
}, | |
validateStructure: function validateStructure(rules, params, context) { | |
this.validateType(context, params, ['object'], 'structure'); | |
for (var paramName in rules) { | |
if (!rules.hasOwnProperty(paramName)) continue; | |
if (rules[paramName].required && params[paramName] === undefined) { | |
this.fail('MissingRequiredParameter', | |
'Missing required key \'' + paramName + '\' in ' + context); | |
} | |
} | |
for (paramName in params) { | |
if (!params.hasOwnProperty(paramName)) continue; | |
var paramValue = params[paramName], | |
paramRules = rules[paramName]; | |
if (paramRules !== undefined) { | |
var memberContext = [context, paramName].join('.'); | |
this.validateMember(paramRules, paramValue, memberContext); | |
} else { | |
this.fail('UnexpectedParameter', | |
'Unexpected key \'' + paramName + '\' found in ' + context); | |
} | |
} | |
return true; | |
}, | |
validateMember: function validateMember(rules, param, context) { | |
var memberRules = rules.members || {}; | |
switch(rules.type) { | |
case 'structure': | |
return this.validateStructure(memberRules, param, context); | |
case 'list': | |
return this.validateList(memberRules, param, context); | |
case 'map': | |
return this.validateMap(memberRules, param, context); | |
default: | |
return this.validateScalar(rules, param, context); | |
} | |
}, | |
validateList: function validateList(rules, params, context) { | |
this.validateType(context, params, [Array]); | |
for (var i = 0; i < params.length; i++) { | |
this.validateMember(rules, params[i], context + '[' + i + ']'); | |
} | |
}, | |
validateMap: function validateMap(rules, params, context) { | |
this.validateType(context, params, ['object'], 'map'); | |
for (var param in params) { | |
if (!params.hasOwnProperty(param)) continue; | |
this.validateMember(rules, params[param], | |
context + '[\'' + param + '\']'); | |
} | |
}, | |
validateScalar: function validateScalar(rules, value, context) { | |
switch (rules.type) { | |
case null: | |
case undefined: | |
case 'string': | |
return this.validateType(context, value, ['string']); | |
case 'base64': | |
case 'binary': | |
return this.validatePayload(context, value); | |
case 'integer': | |
case 'float': | |
return this.validateNumber(context, value); | |
case 'boolean': | |
return this.validateType(context, value, ['boolean']); | |
case 'timestamp': | |
return this.validateType(context, value, [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 ' + | |
rules.type + ' for ' + context); | |
} | |
}, | |
fail: function fail(code, message) { | |
throw AWS.util.error(new Error(message), {code: code}); | |
}, | |
validateType: function validateType(context, value, acceptedTypes, type) { | |
var foundInvalidType = false; | |
for (var i = 0; i < acceptedTypes.length; i++) { | |
if (typeof acceptedTypes[i] === 'string') { | |
if (typeof value === acceptedTypes[i]) return; | |
} else if (acceptedTypes[i] instanceof RegExp) { | |
if ((value || '').toString().match(acceptedTypes[i])) return; | |
} else { | |
if (value instanceof acceptedTypes[i]) return; | |
if (AWS.util.isType(value, acceptedTypes[i])) return; | |
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); | |
}, | |
validateNumber: function validateNumber(context, value) { | |
if (typeof value === 'string') { | |
var castedValue = parseFloat(value); | |
if (castedValue.toString() === value) value = castedValue; | |
} | |
return this.validateType(context, value, ['number']); | |
}, | |
validatePayload: function validatePayload(context, value) { | |
if (typeof value === 'string') return; | |
if (value && typeof value.byteLength === 'number') return; // typed arrays | |
if (AWS.util.isNode()) { // special check for buffer/stream in Node.js | |
var Stream = require('stream').Stream; | |
if (value instanceof Buffer || value instanceof Stream) return; | |
} | |
var types = ['Buffer', 'Stream', 'File', 'Blob', 'ArrayBuffer', 'DataView']; | |
if (value) { | |
for (var i = 0; i < types.length; i++) { | |
if (AWS.util.isType(value, types[i])) return; | |
if (AWS.util.typeName(value.constructor) === types[i]) return; | |
} | |
} | |
this.fail('InvalidParameterType', 'Expected ' + context + ' to be a ' + | |
'string, Buffer, Stream, Blob, or typed array object'); | |
} | |
}); | |
},{"./core":33,"__browserify_Buffer":10,"stream":20}],44:[function(require,module,exports){ | |
var process=require("__browserify_process");var AWS = require('./core'); | |
var inherit = AWS.util.inherit; | |
AWS.Request = inherit({ | |
constructor: function Request(service, operation, params) { | |
var endpoint = service.endpoint; | |
var region = service.config.region; | |
if (service.hasGlobalEndpoint()) region = 'us-east-1'; | |
this.service = service; | |
this.operation = operation; | |
this.params = params || {}; | |
this.httpRequest = new AWS.HttpRequest(endpoint, region); | |
this.startTime = AWS.util.date.getDate(); | |
AWS.SequentialExecutor.call(this); | |
}, | |
send: function send(callback, response) { | |
if (callback) { | |
this.on('complete', function (resp) { | |
callback.call(resp, resp.error, resp.data); | |
}); | |
} | |
if (!response) response = new AWS.Response(this); | |
var eventNames = ['validate', 'build', 'afterBuild', 'sign', 'send']; | |
this.emitEvents(eventNames, response, function(err) { | |
if (err) { | |
this.failRequest(response); | |
} | |
}); | |
return response; | |
}, | |
abort: function abort() { | |
this._events = { // reset events | |
error: this._events.error, | |
complete: this._events.complete | |
}; | |
if (this.httpRequest.stream) { // abort HTTP stream | |
this.httpRequest.stream.abort(); | |
} | |
var response = new AWS.Response(this); | |
response.error = AWS.util.error(new Error('Request aborted by user'), { | |
code: 'RequestAbortedError', retryable: false | |
}); | |
this.failRequest(response); | |
return this; | |
}, | |
eachPage: function eachPage(callback) { | |
function wrappedCallback(response) { | |
var result = callback.call(response, response.error, response.data); | |
if (result === false) return; | |
if (response.hasNextPage()) { | |
response.nextPage().on('complete', wrappedCallback).send(); | |
} else { | |
callback.call(response, null, null); | |
} | |
} | |
this.on('complete', wrappedCallback).send(); | |
}, | |
eachItem: function eachItem(callback) { | |
function wrappedCallback(err, data) { | |
if (err) return callback(err, null); | |
if (data === null) return callback(null, null); | |
var config = this.request.service.paginationConfig(this.request.operation); | |
var resultKey = config.resultKey; | |
if (Array.isArray(resultKey)) resultKey = resultKey[0]; | |
var results = AWS.util.jamespath.query(resultKey, data); | |
AWS.util.arrayEach(results, function(result) { | |
AWS.util.arrayEach(result, function(item) { callback(null, item); }); | |
}); | |
} | |
this.eachPage(wrappedCallback); | |
}, | |
isPageable: function isPageable() { | |
return this.service.paginationConfig(this.operation) ? true : false; | |
}, | |
createReadStream: function createReadStream() { | |
var streams = require('stream'); | |
var req = this; | |
var stream = null; | |
var legacyStreams = false; | |
if (AWS.HttpClient.streamsApiVersion === 2) { | |
stream = new streams.Readable(); | |
stream._read = function() { stream.push(''); }; | |
} else { | |
stream = new streams.Stream(); | |
stream.readable = true; | |
} | |
stream.sent = false; | |
stream.on('newListener', function(event) { | |
if (!stream.sent && (event === 'data' || event === 'readable')) { | |
if (event === 'data') legacyStreams = true; | |
stream.sent = true; | |
process.nextTick(function() { req.send(); }); | |
} | |
}); | |
this.on('httpHeaders', function streamHeaders(statusCode, headers, resp) { | |
if (statusCode < 300) { | |
this.httpRequest._streaming = true; | |
req.removeListener('httpData', AWS.EventListeners.Core.HTTP_DATA); | |
req.removeListener('httpError', AWS.EventListeners.Core.HTTP_ERROR); | |
req.on('httpError', function streamHttpError(error, resp) { | |
resp.error = error; | |
resp.error.retryable = false; | |
this.completeRequest(resp); | |
}); | |
var httpStream = resp.httpResponse.stream; | |
stream.response = resp; | |
stream._read = function() { | |
var data; | |
while (data = httpStream.read()) { | |
stream.push(data); | |
} | |
stream.push(''); | |
}; | |
var events = ['end', 'error', (legacyStreams ? 'data' : 'readable')]; | |
AWS.util.arrayEach(events, function(event) { | |
httpStream.on(event, function(arg) { | |
stream.emit(event, arg); | |
}); | |
}); | |
} | |
}); | |
this.on('error', function(err) { | |
stream.emit('error', err); | |
}); | |
return stream; | |
}, | |
completeRequest: function completeRequest(response) { | |
this.emitEvents(['extractError', 'extractData'], response, function(err) { | |
if (err) { | |
this.emitEvent('retry', response, function(retryError) { | |
if (retryError) this.failRequest(response); | |
}); | |
} else { | |
this.emitEvent('success', [response], this.unhandledErrorCallback); | |
this.emitEvent('complete', [response], this.unhandledErrorCallback); | |
} | |
}); | |
}, | |
failRequest: function failRequest(response) { | |
this.emitEvent('error', [response.error, response], this.unhandledErrorCallback); | |
this.emitEvent('complete', [response], this.unhandledErrorCallback); | |
}, | |
emitEvents: function emitEvents(eventNames, response, doneCallback) { | |
if (!doneCallback) doneCallback = this.unhandledErrorCallback; | |
if (response.error) { | |
doneCallback.call(this, response.error); | |
} else if (eventNames.length === 0) { | |
doneCallback.call(this); | |
} else { | |
this.emitEvent(eventNames[0], response, function(err) { | |
if (err) { | |
doneCallback.call(this, err); | |
} else { | |
this.emitEvents(eventNames.slice(1), response, doneCallback); | |
} | |
}); | |
} | |
}, | |
emitEvent: function emitEvent(eventName, args, doneCallback) { | |
if (!doneCallback) doneCallback = this.unhandledErrorCallback; | |
var response = null; | |
if (Array.isArray(args)) { | |
response = args[args.length - 1]; | |
} else { | |
response = args; | |
args = this.eventParameters(eventName, response); | |
} | |
this.emit(eventName, args, function (err) { | |
if (err) { | |
response.error = err; | |
} | |
doneCallback.call(this, err); | |
}); | |
}, | |
eventParameters: function eventParameters(eventName, response) { | |
switch (eventName) { | |
case 'validate': | |
case 'sign': | |
case 'build': | |
case 'afterBuild': | |
return [this]; | |
default: | |
return [response]; | |
} | |
} | |
}); | |
AWS.util.mixin(AWS.Request, AWS.SequentialExecutor); | |
AWS.Response = inherit({ | |
constructor: function Response(request) { | |
this.request = request; | |
this.data = null; | |
this.error = null; | |
this.retryCount = 0; | |
this.redirectCount = 0; | |
this.httpResponse = new AWS.HttpResponse(); | |
}, | |
nextPage: 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); | |
} | |
}, | |
hasNextPage: function hasNextPage() { | |
this.cacheNextPageTokens(); | |
if (this.nextPageTokens) return true; | |
if (this.nextPageTokens === undefined) return undefined; | |
else return false; | |
}, | |
cacheNextPageTokens: function cacheNextPageTokens() { | |
if (this.hasOwnProperty('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 (!AWS.util.jamespath.find(config.moreResults, this.data)) { | |
return this.nextPageTokens; | |
} | |
} | |
var exprs = config.outputToken; | |
if (typeof exprs === 'string') exprs = [exprs]; | |
AWS.util.arrayEach.call(this, exprs, function (expr) { | |
var output = AWS.util.jamespath.find(expr, this.data); | |
if (output) { | |
this.nextPageTokens = this.nextPageTokens || []; | |
this.nextPageTokens.push(output); | |
} | |
}); | |
return this.nextPageTokens; | |
} | |
}); | |
},{"./core":33,"__browserify_process":11,"stream":20}],45:[function(require,module,exports){ | |
var process=require("__browserify_process");var AWS = require('./core'); | |
var domain; | |
AWS.SequentialExecutor = AWS.util.inherit({ | |
constructor: function SequentialExecutor() { | |
this.domain = null; | |
if (require('events').usingDomains) { | |
domain = require('domain'); | |
if (domain.active) this.domain = domain.active; | |
} | |
this._events = {}; | |
}, | |
listeners: function listeners(eventName) { | |
return this._events[eventName] ? this._events[eventName].slice(0) : []; | |
}, | |
on: function on(eventName, listener) { | |
if (this._events[eventName]) { | |
this._events[eventName].push(listener); | |
} else { | |
this._events[eventName] = [listener]; | |
} | |
return this; | |
}, | |
onAsync: function onAsync(eventName, listener) { | |
listener._isAsync = true; | |
return this.on(eventName, listener); | |
}, | |
removeListener: 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; | |
}, | |
removeAllListeners: function removeAllListeners(eventName) { | |
if (eventName) { | |
delete this._events[eventName]; | |
} else { | |
this._events = {}; | |
} | |
return this; | |
}, | |
emit: function emit(eventName, eventArgs, doneCallback) { | |
if (!doneCallback) doneCallback = this.unhandledErrorCallback; | |
if (domain && this.domain instanceof domain.Domain) | |
this.domain.enter(); | |
var listeners = this.listeners(eventName); | |
var count = listeners.length; | |
this.callListeners(listeners, eventArgs, doneCallback); | |
return count > 0; | |
}, | |
callListeners: function callListeners(listeners, args, doneCallback) { | |
if (listeners.length === 0) { | |
doneCallback.call(this); | |
if (domain && this.domain instanceof domain.Domain) | |
this.domain.exit(); | |
} else { | |
var listener = listeners.shift(); | |
if (listener._isAsync) { | |
var callNextListener = function(err) { | |
if (err) { | |
doneCallback.call(this, err); | |
if (domain && this.domain instanceof domain.Domain) | |
this.domain.exit(); | |
} else { | |
this.callListeners(listeners, args, doneCallback); | |
} | |
}.bind(this); | |
listener.apply(this, args.concat([callNextListener])); | |
} else { | |
try { | |
listener.apply(this, args); | |
this.callListeners(listeners, args, doneCallback); | |
} catch (err) { | |
doneCallback.call(this, err); | |
if (domain && this.domain instanceof domain.Domain) | |
this.domain.exit(); | |
} | |
} | |
} | |
}, | |
addListeners: function addListeners(listeners) { | |
var self = this; | |
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; | |
}, | |
addNamedListener: function addNamedListener(name, eventName, callback) { | |
this[name] = callback; | |
this.addListener(eventName, callback); | |
return this; | |
}, | |
addNamedAsyncListener: function addNamedAsyncListener(name, eventName, callback) { | |
callback._isAsync = true; | |
return this.addNamedListener(name, eventName, callback); | |
}, | |
addNamedListeners: function addNamedListeners(callback) { | |
var self = this; | |
callback( | |
function() { | |
self.addNamedListener.apply(self, arguments); | |
}, | |
function() { | |
self.addNamedAsyncListener.apply(self, arguments); | |
} | |
); | |
return this; | |
}, | |
unhandledErrorCallback: function unhandledErrorCallback(err) { | |
if (err) { | |
if (domain && this.domain instanceof domain.Domain) { | |
err.domainEmitter = this; | |
err.domain = this.domain; | |
err.domainThrown = false; | |
this.domain.emit('error', err); | |
} else if (process.exit) { | |
console.error(err.stack ? err.stack : err); | |
process.exit(1); | |
} else { | |
throw err; | |
} | |
} | |
} | |
}); | |
AWS.SequentialExecutor.prototype.addListener = AWS.SequentialExecutor.prototype.on; | |
},{"./core":33,"__browserify_process":11,"domain":1,"events":8}],46:[function(require,module,exports){ | |
var __dirname="/";var AWS = require('./core'); | |
var Translator = require('./api/translator'); | |
var inherit = AWS.util.inherit; | |
AWS.Service = inherit({ | |
constructor: 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) return new ServiceClass(config); | |
this.initialize(config); | |
}, | |
initialize: function initialize(config) { | |
AWS.util.hideProperties(this, ['client']); | |
this.client = this; // backward compatibility with client property | |
this.config = new AWS.Config(AWS.config); | |
if (config) this.config.update(config, true); | |
this.setEndpoint(this.config.endpoint); | |
}, | |
loadServiceClass: function loadServiceClass(serviceConfig) { | |
var config = serviceConfig; | |
if (!AWS.util.isEmpty(this.api)) { | |
return; | |
} else if (config.apiConfig) { | |
return AWS.Service.defineServiceApi(this.constructor, config.apiConfig); | |
} else if (!this.constructor.services) { | |
return; | |
} 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); | |
} | |
}, | |
getLatestServiceClass: function getLatestServiceClass(version) { | |
version = this.getLatestServiceVersion(version); | |
if (this.constructor.services[version] === null) { | |
AWS.Service.defineServiceApi(this.constructor, version); | |
} | |
return this.constructor.services[version]; | |
}, | |
getLatestServiceVersion: 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--) { | |
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 + '\''); | |
}, | |
api: {}, | |
defaultRetryCount: 3, | |
makeRequest: 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; | |
}, | |
makeUnauthenticatedRequest: function makeUnauthenticatedRequest(operation, params, callback) { | |
if (typeof params === 'function') { | |
callback = params; | |
params = {}; | |
} | |
var request = this.makeRequest(operation, params); | |
request.removeListener('validate', AWS.EventListeners.Core.VALIDATE_CREDENTIALS); | |
request.removeListener('sign', AWS.EventListeners.Core.SIGN); | |
request.addListener('build', function convertToGET(request) { | |
request.httpRequest.method = 'GET'; | |
request.httpRequest.path = '/?' + request.httpRequest.body; | |
request.httpRequest.body = ''; | |
delete request.httpRequest.headers['Content-Length']; | |
delete request.httpRequest.headers['Content-Type']; | |
}); | |
return callback ? request.send(callback) : request; | |
}, | |
addAllRequestListeners: function addAllRequestListeners(request) { | |
var list = [AWS.events, AWS.EventListeners.Core, | |
this.serviceInterface()]; | |
for (var i = 0; i < list.length; i++) { | |
if (list[i]) request.addListeners(list[i]); | |
} | |
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); | |
}, | |
setupRequestListeners: function setupRequestListeners() { | |
}, | |
getSignerClass: function getSignerClass() { | |
var version = this.api.signatureVersion; | |
if (this.config.signatureVersion) version = this.config.signatureVersion; | |
else if (this.isRegionV4()) version = 'v4'; | |
return AWS.Signers.RequestSigner.getVersion(version); | |
}, | |
serviceInterface: function serviceInterface() { | |
switch (this.api.format) { | |
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.format) { | |
throw new Error('Invalid service `format\' ' + | |
this.api.format + ' in API config'); | |
} | |
}, | |
successfulResponse: function successfulResponse(resp) { | |
return resp.httpResponse.statusCode < 300; | |
}, | |
numRetries: function numRetries() { | |
if (this.config.maxRetries !== undefined) { | |
return this.config.maxRetries; | |
} else { | |
return this.defaultRetryCount; | |
} | |
}, | |
retryDelays: function retryDelays() { | |
var retryCount = this.numRetries(); | |
var delays = []; | |
for (var i = 0; i < retryCount; ++i) { | |
delays[i] = Math.pow(2, i) * 30; | |
} | |
return delays; | |
}, | |
retryableError: 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; | |
}, | |
networkingError: function networkingError(error) { | |
return error.code == 'NetworkingError'; | |
}, | |
expiredCredentialsError: function expiredCredentialsError(error) { | |
return (error.code === 'ExpiredTokenException'); | |
}, | |
throttledError: function throttledError(error) { | |
return (error.code == 'ProvisionedThroughputExceededException'); | |
}, | |
setEndpoint: function setEndpoint(endpoint) { | |
if (endpoint) { | |
this.endpoint = new AWS.Endpoint(endpoint, this.config); | |
} else if (this.hasGlobalEndpoint()) { | |
this.endpoint = new AWS.Endpoint(this.api.globalEndpoint, this.config); | |
} else { | |
var host = this.api.endpointPrefix + '.' + this.config.region + | |
this.endpointSuffix(); | |
this.endpoint = new AWS.Endpoint(host, this.config); | |
} | |
}, | |
hasGlobalEndpoint: function hasGlobalEndpoint() { | |
if (this.isRegionV4()) return false; | |
return this.api.globalEndpoint; | |
}, | |
endpointSuffix: function endpointSuffix() { | |
var suffix = '.amazonaws.com'; | |
if (this.isRegionCN()) return suffix + '.cn'; | |
else return suffix; | |
}, | |
isRegionCN: function isRegionCN() { | |
if (!this.config.region) return false; | |
return this.config.region.match(/^cn-/) ? true : false; | |
}, | |
isRegionV4: function isRegionV4() { | |
return this.isRegionCN(); | |
}, | |
paginationConfig: function paginationConfig(operation, throwException) { | |
function fail(name) { | |
if (throwException) { | |
var e = new Error(); | |
throw AWS.util.error(e, 'No pagination configuration for ' + name); | |
} | |
return null; | |
} | |
if (!this.api.pagination) return fail('service'); | |
if (!this.api.pagination[operation]) return fail(operation); | |
return this.api.pagination[operation]; | |
} | |
}); | |
AWS.util.update(AWS.Service, { | |
defineMethods: function defineMethods(svc) { | |
AWS.util.each(svc.prototype.api.operations, function iterator(method) { | |
if (svc.prototype[method]) return; | |
svc.prototype[method] = function (params, callback) { | |
return this.makeRequest(method, params, callback); | |
}; | |
}); | |
}, | |
defineService: function defineService(serviceIdentifier, versions, features) { | |
if (!Array.isArray(versions)) { | |
features = versions; | |
versions = []; | |
} | |
var svc = inherit(AWS.Service, features || {}); | |
svc.Client = svc; // backward compatibility for Client class | |
if (typeof serviceIdentifier === 'string') { | |
var services = {}; | |
for (var i = 0; i < versions.length; i++) { | |
services[versions[i]] = null; | |
} | |
svc.services = svc.services || services; | |
svc.apiVersions = Object.keys(svc.services).sort(); | |
svc.serviceIdentifier = svc.serviceIdentifier || serviceIdentifier; | |
} else { // defineService called with an API | |
svc.prototype.api = serviceIdentifier; | |
AWS.Service.defineMethods(svc); | |
} | |
return svc; | |
}, | |
defineServiceApi: function defineServiceApi(superclass, version, apiConfig) { | |
var svc = inherit(superclass, { | |
serviceIdentifier: superclass.serviceIdentifier | |
}); | |
function setApi(api) { | |
if (api.type && api.api_version) { | |
svc.prototype.api = new Translator(api, {documentation: false}); | |
} else { | |
svc.prototype.api = api; | |
} | |
} | |
if (typeof version === 'string') { | |
if (apiConfig) { | |
setApi(apiConfig); | |
} else { | |
var file = superclass.serviceIdentifier + '-' + version; | |
var path = __dirname + '/../apis/' + file + '.json'; | |
try { | |
var fs = require('fs'); | |
setApi(JSON.parse(fs.readFileSync(path))); | |
} catch (err) { | |
throw AWS.util.error(err, { | |
message: 'Could not find API configuration ' + file | |
}); | |
} | |
} | |
if (!superclass.services.hasOwnProperty(version)) { | |
superclass.apiVersions.push(version); | |
} | |
superclass.services[version] = svc; | |
} else { | |
setApi(version); | |
} | |
AWS.Service.defineMethods(svc); | |
return svc; | |
} | |
}); | |
},{"./api/translator":30,"./core":33,"fs":1}],47:[function(require,module,exports){ | |
var AWS = require('../core'); | |
require('../json/builder'); | |
AWS.ServiceInterface.Json = { | |
buildRequest: function buildRequest(req) { | |
var httpRequest = req.httpRequest; | |
var api = req.service.api; | |
var target = api.targetPrefix + '.' + api.operations[req.operation].name; | |
var version = api.jsonVersion || '1.0'; | |
var rules = api.operations[req.operation].input; | |
var builder = new AWS.JSON.Builder(rules, api); | |
httpRequest.path = '/'; | |
httpRequest.body = builder.build(req.params || {}); | |
httpRequest.headers['Content-Type'] = 'application/x-amz-json-' + version; | |
httpRequest.headers['X-Amz-Target'] = target; | |
}, | |
extractError: function extractError(resp) { | |
var error = {}; | |
var httpResponse = resp.httpResponse; | |
if (httpResponse.body.length > 0) { | |
var e = JSON.parse(httpResponse.body.toString()); | |
if (e.__type || e.code) { | |
error.code = (e.__type || e.code).split('#').pop(); | |
} else { | |
error.code = 'UnknownError'; | |
} | |
if (error.code === 'RequestEntityTooLarge') { | |
error.message = 'Request body must be less than 1 MB'; | |
} else { | |
error.message = (e.message || e.Message || null); | |
} | |
} else { | |
error.code = httpResponse.statusCode; | |
error.message = null; | |
} | |
resp.error = AWS.util.error(new Error(), error); | |
}, | |
extractData: function extractData(resp) { | |
resp.data = JSON.parse(resp.httpResponse.body.toString() || '{}'); | |
} | |
}; | |
},{"../core":33,"../json/builder":42}],48:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var inherit = AWS.util.inherit; | |
require('../xml/parser'); | |
AWS.ServiceInterface.Query = { | |
buildRequest: function buildRequest(req) { | |
var operation = req.service.api.operations[req.operation]; | |
var httpRequest = req.httpRequest; | |
httpRequest.path = '/'; | |
httpRequest.headers['Content-Type'] = | |
'application/x-www-form-urlencoded; charset=utf-8'; | |
httpRequest.params = { | |
Version: req.service.api.apiVersion, | |
Action: operation.name | |
}; | |
var rules = operation.input; | |
if (rules) rules = rules.members; | |
var builder = new AWS.QueryParamSerializer(rules, req.service.api); | |
builder.serialize(req.params, function(name, value) { | |
httpRequest.params[name] = value; | |
}); | |
httpRequest.body = AWS.util.queryParamsToString(httpRequest.params); | |
}, | |
extractError: function extractError(resp) { | |
var data, body = resp.httpResponse.body.toString(); | |
if (body.match('<UnknownOperationException')) { | |
data = { | |
Code: 'UnknownOperation', | |
Message: 'Unknown operation ' + resp.request.operation | |
}; | |
} else { | |
data = new AWS.XML.Parser({}).parse(body); | |
} | |
if (data.Errors) data = data.Errors; | |
if (data.Error) data = data.Error; | |
if (data.Code) { | |
resp.error = AWS.util.error(new Error(), { | |
code: data.Code, | |
message: data.Message | |
}); | |
} else { | |
resp.error = AWS.util.error(new Error(), { | |
code: resp.httpResponse.statusCode, | |
message: null | |
}); | |
} | |
}, | |
extractData: function extractData(resp) { | |
var req = resp.request; | |
var operation = req.service.api.operations[req.operation]; | |
var wrapperKey = operation.name + 'Result'; | |
var rules = operation.output || {}; | |
if (req.service.api.resultWrapped) { | |
var tmp = { | |
type: 'structure', | |
members: {} | |
}; | |
tmp.members[wrapperKey] = rules; | |
rules = tmp; | |
} | |
var parser = new AWS.XML.Parser(rules); | |
var data = parser.parse(resp.httpResponse.body.toString()); | |
if (req.service.api.resultWrapped) { | |
if (data[wrapperKey]) { | |
AWS.util.update(data, data[wrapperKey]); | |
delete data[wrapperKey]; | |
} | |
} | |
AWS.util.each((operation.output || {}).members || {}, function (memberName, memberRules) { | |
if (memberRules.wrapper && data[memberName]) { | |
AWS.util.update(data, data[memberName]); | |
delete data[memberName]; | |
} | |
}); | |
resp.data = data; | |
} | |
}; | |
AWS.QueryParamSerializer = inherit({ | |
constructor: function QueryParamSerializer(rules, options) { | |
this.rules = rules; | |
this.timestampFormat = options ? options.timestampFormat : 'iso8601'; | |
}, | |
serialize: function serialize(params, fn) { | |
this.serializeStructure('', params, this.rules, fn); | |
}, | |
serializeStructure: function serializeStructure(prefix, struct, rules, fn) { | |
var that = this; | |
AWS.util.each(struct, function (name, member) { | |
var n = rules[name].name || name; | |
var memberName = prefix ? prefix + '.' + n : n; | |
that.serializeMember(memberName, member, rules[name], fn); | |
}); | |
}, | |
serializeMap: function serialzeMap(name, map, rules, fn) { | |
var i = 1; | |
var that = this; | |
AWS.util.each(map, function (key, value) { | |
var prefix = rules.flattened ? '.' : '.entry.'; | |
var position = prefix + (i++) + '.'; | |
var keyName = position + (rules.keys.name || 'key'); | |
var valueName = position + (rules.members.name || 'value'); | |
that.serializeMember(name + keyName, key, rules.keys, fn); | |
that.serializeMember(name + valueName, value, rules.members, fn); | |
}); | |
}, | |
serializeList: function serializeList(name, list, rules, fn) { | |
var that = this; | |
var memberRules = rules.members || {}; | |
AWS.util.arrayEach(list, function (v, n) { | |
var suffix = '.' + (n + 1); | |
if (rules.flattened) { | |
if (memberRules.name) { | |
var parts = name.split('.'); | |
parts.pop(); | |
parts.push(memberRules.name); | |
name = parts.join('.'); | |
} | |
} else { | |
suffix = '.member' + suffix; | |
} | |
that.serializeMember(name + suffix, v, memberRules, fn); | |
}); | |
}, | |
serializeMember: function serializeMember(name, value, rules, fn) { | |
if (rules.type === 'structure') { | |
this.serializeStructure(name, value, rules.members, fn); | |
} else if (rules.type === 'list') { | |
this.serializeList(name, value, rules, fn); | |
} else if (rules.type === 'map') { | |
this.serializeMap(name, value, rules, fn); | |
} else if (rules.type === 'timestamp') { | |
var timestampFormat = rules.format || this.timestampFormat; | |
fn.call(this, name, AWS.util.date.format(value, timestampFormat)); | |
} else { | |
fn.call(this, name, String(value)); | |
} | |
} | |
}); | |
},{"../core":33,"../xml/parser":67}],49:[function(require,module,exports){ | |
var AWS = require('../core'); | |
AWS.ServiceInterface.Rest = { | |
buildRequest: function buildRequest(req) { | |
AWS.ServiceInterface.Rest.populateMethod(req); | |
AWS.ServiceInterface.Rest.populateURI(req); | |
AWS.ServiceInterface.Rest.populateHeaders(req); | |
}, | |
extractError: function extractError() { | |
}, | |
extractData: function extractData(resp) { | |
var req = resp.request; | |
var data = {}; | |
var r = resp.httpResponse; | |
var operation = req.service.api.operations[req.operation]; | |
var rules = (operation.output || {}).members || {}; | |
var headers = {}; | |
AWS.util.each(r.headers, function (k, v) { | |
headers[k.toLowerCase()] = v; | |
}); | |
AWS.util.each(rules, function (name, rule) { | |
if (rule.location === 'header') { | |
var header = (rule.name || name).toLowerCase(); | |
if (rule.type == 'map') { | |
data[name] = {}; | |
AWS.util.each(r.headers, function (k, v) { | |
var result = k.match(new RegExp('^' + rule.name + '(.+)', 'i')); | |
if (result !== null) { | |
data[name][result[1]] = v; | |
} | |
}); | |
} | |
if (headers[header] !== undefined) { | |
data[name] = headers[header]; | |
} | |
} | |
if (rule.location === 'status') { | |
data[name] = parseInt(r.statusCode, 10); | |
} | |
}); | |
resp.data = data; | |
}, | |
populateMethod: function populateMethod(req) { | |
req.httpRequest.method = req.service.api.operations[req.operation].http.method; | |
}, | |
populateURI: function populateURI(req) { | |
var operation = req.service.api.operations[req.operation]; | |
var uri = operation.http.uri; | |
var pathPattern = uri.split(/\?/)[0]; | |
var rules = (operation.input || {}).members || {}; | |
var escapePathParam = req.service.escapePathParam || | |
AWS.ServiceInterface.Rest.escapePathParam; | |
var escapeQuerystringParam = req.service.escapeQuerystringParam || | |
AWS.ServiceInterface.Rest.escapeQuerystringParam; | |
AWS.util.each.call(this, rules, function (name, rule) { | |
if (rule.location == 'uri' && req.params[name]) { | |
var value = pathPattern.match('{' + name + '}') ? | |
escapePathParam(req.params[name]) : | |
escapeQuerystringParam(req.params[name]); | |
uri = uri.replace('{' + name + '}', value); | |
} | |
}); | |
var path = uri.split('?')[0]; | |
var querystring = uri.split('?')[1]; | |
if (querystring) { | |
var parts = []; | |
AWS.util.arrayEach(querystring.split('&'), function (part) { | |
if (!part.match('{\\w+}')) parts.push(part); | |
}); | |
uri = (parts.length > 0 ? path + '?' + parts.join('&') : path); | |
} else { | |
uri = path; | |
} | |
req.httpRequest.path = uri; | |
}, | |
escapePathParam: function escapePathParam(value) { | |
return AWS.util.uriEscape(String(value)); | |
}, | |
escapeQuerystringParam: function escapeQuerystringParam(value) { | |
return AWS.util.uriEscape(String(value)); | |
}, | |
populateHeaders: function populateHeaders(req) { | |
var operation = req.service.api.operations[req.operation]; | |
var rules = (operation.input || {}).members || {}; | |
AWS.util.each.call(this, rules, function (name, rule) { | |
if (rule.location === 'header' && req.params[name]) { | |
if (rule.type === 'map') { | |
AWS.util.each(req.params[name], function (key, value) { | |
req.httpRequest.headers[rule.name + key] = value; | |
}); | |
} else { | |
var value = req.params[name]; | |
if (rule.type === 'timestamp') { | |
var timestampFormat = rule.format || req.service.api.timestampFormat; | |
value = AWS.util.date.format(value, timestampFormat); | |
} | |
req.httpRequest.headers[rule.name || name] = value; | |
} | |
} | |
}); | |
} | |
}; | |
},{"../core":33}],50:[function(require,module,exports){ | |
var AWS = require('../core'); | |
require('./rest'); | |
require('./json'); | |
AWS.ServiceInterface.RestJson = { | |
buildRequest: function buildRequest(req) { | |
AWS.ServiceInterface.Rest.buildRequest(req); | |
AWS.ServiceInterface.RestJson.populateBody(req); | |
}, | |
extractError: function extractError(resp) { | |
AWS.ServiceInterface.Json.extractError(resp); | |
}, | |
extractData: function extractData(resp) { | |
AWS.ServiceInterface.Rest.extractData(resp); | |
var req = resp.request; | |
var rules = req.service.api.operations[req.operation].output || {}; | |
if (rules.payload && rules.members[rules.payload]) { | |
if (rules.members[rules.payload].streaming) { | |
resp.data[rules.payload] = resp.httpResponse.body; | |
} else { | |
resp.data[rules.payload] = resp.httpResponse.body.toString(); | |
} | |
} else { | |
var data = resp.data; | |
AWS.ServiceInterface.Json.extractData(resp); | |
resp.data = AWS.util.merge(data, resp.data); | |
} | |
resp.data.RequestId = resp.httpResponse.headers['x-amz-request-id'] || | |
resp.httpResponse.headers['x-amzn-requestid']; | |
}, | |
populateBody: function populateBody(req) { | |
var input = req.service.api.operations[req.operation].input; | |
var payload = input.payload; | |
var params = {}; | |
if (typeof payload === 'string') { | |
var rules = input.members[payload]; | |
params = req.params[payload]; | |
if (params === undefined) return; | |
if (rules.type === 'structure') { | |
req.httpRequest.body = this.buildJSON(params, input, req.service.api); | |
} else { | |
req.httpRequest.body = params; | |
} | |
} else if (payload) { | |
AWS.util.arrayEach(payload, function (param) { | |
if (req.params[param] !== undefined) { | |
params[param] = req.params[param]; | |
} | |
}); | |
req.httpRequest.body = this.buildJSON(params, input, req.service.api); | |
} | |
}, | |
buildJSON: function buildJSON(params, rules, api) { | |
var builder = new AWS.JSON.Builder(rules, api); | |
return builder.build(params); | |
} | |
}; | |
},{"../core":33,"./json":47,"./rest":49}],51:[function(require,module,exports){ | |
var AWS = require('../core'); | |
require('../xml/builder'); | |
require('./rest'); | |
AWS.ServiceInterface.RestXml = { | |
buildRequest: function buildRequest(req) { | |
AWS.ServiceInterface.Rest.buildRequest(req); | |
AWS.ServiceInterface.RestXml.populateBody(req); | |
}, | |
extractError: function extractError(resp) { | |
AWS.ServiceInterface.Rest.extractError(resp); | |
var data = new AWS.XML.Parser({}).parse(resp.httpResponse.body.toString()); | |
if (data.Errors) data = data.Errors; | |
if (data.Error) data = data.Error; | |
if (data.Code) { | |
resp.error = AWS.util.error(new Error(), { | |
code: data.Code, | |
message: data.Message | |
}); | |
} else { | |
resp.error = AWS.util.error(new Error(), { | |
code: resp.httpResponse.statusCode, | |
message: null | |
}); | |
} | |
}, | |
extractData: function extractData(resp) { | |
AWS.ServiceInterface.Rest.extractData(resp); | |
var req = resp.request; | |
var httpResponse = resp.httpResponse; | |
var operation = req.service.api.operations[req.operation]; | |
var rules = operation.output.members; | |
var output = operation.output; | |
var payload = output.payload; | |
if (payload) { | |
if (rules[payload].streaming) { | |
resp.data[payload] = httpResponse.body; | |
} else { | |
resp.data[payload] = httpResponse.body.toString(); | |
} | |
} else if (httpResponse.body.length > 0) { | |
var parser = new AWS.XML.Parser(operation.output || {}); | |
AWS.util.update(resp.data, parser.parse(httpResponse.body.toString())); | |
} | |
resp.data.RequestId = httpResponse.headers['x-amz-request-id'] || | |
httpResponse.headers['x-amzn-requestid']; | |
}, | |
populateBody: function populateBody(req) { | |
var input = req.service.api.operations[req.operation].input; | |
var payload = input.payload; | |
var rules = {}; | |
var builder = null; | |
var params = req.params; | |
if (typeof payload === 'string') { | |
rules = input.members[payload]; | |
params = params[payload]; | |
if (params === undefined) return; | |
if (rules.type === 'structure') { | |
builder = new AWS.XML.Builder(payload, rules.members, req.service.api); | |
req.httpRequest.body = builder.toXML(params); | |
} else { | |
req.httpRequest.body = params; | |
} | |
} else if (payload) { | |
AWS.util.arrayEach(payload, function (member) { | |
rules[member] = input.members[member]; | |
}); | |
builder = new AWS.XML.Builder(input.wrapper, rules, req.service.api); | |
req.httpRequest.body = builder.toXML(params); | |
} | |
} | |
}; | |
},{"../core":33,"../xml/builder":66,"./rest":49}],52:[function(require,module,exports){ | |
var AWS = require("./core"); module.exports = AWS; | |
AWS.Service.defineServiceApi(require("./services/dynamodb"), "2012-08-10", {"format":"json","apiVersion":"2012-08-10","endpointPrefix":"dynamodb","jsonVersion":"1.0","serviceAbbreviation":"DynamoDB","serviceFullName":"Amazon DynamoDB","signatureVersion":"v4","targetPrefix":"DynamoDB_20120810","timestampFormat":"iso8601","operations":{"batchGetItem":{"name":"BatchGetItem","input":{"type":"structure","members":{"RequestItems":{"type":"map","keys":{},"members":{"type":"structure","members":{"Keys":{"type":"list","members":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"required":true},"AttributesToGet":{"type":"list","members":{}},"ConsistentRead":{"type":"boolean"}}},"required":true},"ReturnConsumedCapacity":{}}},"output":{"type":"structure","members":{"Responses":{"type":"map","keys":{},"members":{"type":"list","members":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}}}},"UnprocessedKeys":{"type":"map","keys":{},"members":{"type":"structure","members":{"Keys":{"type":"list","members":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}}},"AttributesToGet":{"type":"list","members":{}},"ConsistentRead":{"type":"boolean"}}}},"ConsumedCapacity":{"type":"list","members":{"type":"structure","members":{"TableName":{},"CapacityUnits":{"type":"float"},"Table":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}},"LocalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}},"GlobalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}}}}}}}},"batchWriteItem":{"name":"BatchWriteItem","input":{"type":"structure","members":{"RequestItems":{"type":"map","keys":{},"members":{"type":"list","members":{"type":"structure","members":{"PutRequest":{"type":"structure","members":{"Item":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"required":true}}},"DeleteRequest":{"type":"structure","members":{"Key":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"required":true}}}}}},"required":true},"ReturnConsumedCapacity":{},"ReturnItemCollectionMetrics":{}}},"output":{"type":"structure","members":{"UnprocessedItems":{"type":"map","keys":{},"members":{"type":"list","members":{"type":"structure","members":{"PutRequest":{"type":"structure","members":{"Item":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}}}},"DeleteRequest":{"type":"structure","members":{"Key":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}}}}}}}},"ItemCollectionMetrics":{"type":"map","keys":{},"members":{"type":"list","members":{"type":"structure","members":{"ItemCollectionKey":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"SizeEstimateRangeGB":{"type":"list","members":{"type":"float"}}}}}},"ConsumedCapacity":{"type":"list","members":{"type":"structure","members":{"TableName":{},"CapacityUnits":{"type":"float"},"Table":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}},"LocalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}},"GlobalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}}}}}}}},"createTable":{"name":"CreateTable","input":{"type":"structure","members":{"AttributeDefinitions":{"type":"list","members":{"type":"structure","members":{"AttributeName":{"required":true},"AttributeType":{"required":true}}},"required":true},"TableName":{"required":true},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{"required":true},"KeyType":{"required":true}}},"required":true},"LocalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{"required":true},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{"required":true},"KeyType":{"required":true}}},"required":true},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}},"required":true}}}},"GlobalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{"required":true},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{"required":true},"KeyType":{"required":true}}},"required":true},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}},"required":true},"ProvisionedThroughput":{"type":"structure","members":{"ReadCapacityUnits":{"type":"integer","required":true},"WriteCapacityUnits":{"type":"integer","required":true}},"required":true}}}},"ProvisionedThroughput":{"type":"structure","members":{"ReadCapacityUnits":{"type":"integer","required":true},"WriteCapacityUnits":{"type":"integer","required":true}},"required":true}}},"output":{"type":"structure","members":{"TableDescription":{"type":"structure","members":{"AttributeDefinitions":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"AttributeType":{}}}},"TableName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"TableStatus":{},"CreationDateTime":{"type":"timestamp"},"ProvisionedThroughput":{"type":"structure","members":{"LastIncreaseDateTime":{"type":"timestamp"},"LastDecreaseDateTime":{"type":"timestamp"},"NumberOfDecreasesToday":{"type":"integer"},"ReadCapacityUnits":{"type":"integer"},"WriteCapacityUnits":{"type":"integer"}}},"TableSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"},"LocalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}}},"IndexSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"}}}},"GlobalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}}},"IndexStatus":{},"ProvisionedThroughput":{"type":"structure","members":{"LastIncreaseDateTime":{"type":"timestamp"},"LastDecreaseDateTime":{"type":"timestamp"},"NumberOfDecreasesToday":{"type":"integer"},"ReadCapacityUnits":{"type":"integer"},"WriteCapacityUnits":{"type":"integer"}}},"IndexSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"}}}}}}}}},"deleteItem":{"name":"DeleteItem","input":{"type":"structure","members":{"TableName":{"required":true},"Key":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"required":true},"Expected":{"type":"map","keys":{},"members":{"type":"structure","members":{"Value":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"Exists":{"type":"boolean"}}}},"ReturnValues":{},"ReturnConsumedCapacity":{},"ReturnItemCollectionMetrics":{}}},"output":{"type":"structure","members":{"Attributes":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ConsumedCapacity":{"type":"structure","members":{"TableName":{},"CapacityUnits":{"type":"float"},"Table":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}},"LocalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}},"GlobalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}}}},"ItemCollectionMetrics":{"type":"structure","members":{"ItemCollectionKey":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"SizeEstimateRangeGB":{"type":"list","members":{"type":"float"}}}}}}},"deleteTable":{"name":"DeleteTable","input":{"type":"structure","members":{"TableName":{"required":true}}},"output":{"type":"structure","members":{"TableDescription":{"type":"structure","members":{"AttributeDefinitions":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"AttributeType":{}}}},"TableName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"TableStatus":{},"CreationDateTime":{"type":"timestamp"},"ProvisionedThroughput":{"type":"structure","members":{"LastIncreaseDateTime":{"type":"timestamp"},"LastDecreaseDateTime":{"type":"timestamp"},"NumberOfDecreasesToday":{"type":"integer"},"ReadCapacityUnits":{"type":"integer"},"WriteCapacityUnits":{"type":"integer"}}},"TableSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"},"LocalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}}},"IndexSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"}}}},"GlobalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}}},"IndexStatus":{},"ProvisionedThroughput":{"type":"structure","members":{"LastIncreaseDateTime":{"type":"timestamp"},"LastDecreaseDateTime":{"type":"timestamp"},"NumberOfDecreasesToday":{"type":"integer"},"ReadCapacityUnits":{"type":"integer"},"WriteCapacityUnits":{"type":"integer"}}},"IndexSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"}}}}}}}}},"describeTable":{"name":"DescribeTable","input":{"type":"structure","members":{"TableName":{"required":true}}},"output":{"type":"structure","members":{"Table":{"type":"structure","members":{"AttributeDefinitions":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"AttributeType":{}}}},"TableName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"TableStatus":{},"CreationDateTime":{"type":"timestamp"},"ProvisionedThroughput":{"type":"structure","members":{"LastIncreaseDateTime":{"type":"timestamp"},"LastDecreaseDateTime":{"type":"timestamp"},"NumberOfDecreasesToday":{"type":"integer"},"ReadCapacityUnits":{"type":"integer"},"WriteCapacityUnits":{"type":"integer"}}},"TableSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"},"LocalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}}},"IndexSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"}}}},"GlobalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}}},"IndexStatus":{},"ProvisionedThroughput":{"type":"structure","members":{"LastIncreaseDateTime":{"type":"timestamp"},"LastDecreaseDateTime":{"type":"timestamp"},"NumberOfDecreasesToday":{"type":"integer"},"ReadCapacityUnits":{"type":"integer"},"WriteCapacityUnits":{"type":"integer"}}},"IndexSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"}}}}}}}}},"getItem":{"name":"GetItem","input":{"type":"structure","members":{"TableName":{"required":true},"Key":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"required":true},"AttributesToGet":{"type":"list","members":{}},"ConsistentRead":{"type":"boolean"},"ReturnConsumedCapacity":{}}},"output":{"type":"structure","members":{"Item":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ConsumedCapacity":{"type":"structure","members":{"TableName":{},"CapacityUnits":{"type":"float"},"Table":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}},"LocalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}},"GlobalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}}}}}}},"listTables":{"name":"ListTables","input":{"type":"structure","members":{"ExclusiveStartTableName":{},"Limit":{"type":"integer"}}},"output":{"type":"structure","members":{"TableNames":{"type":"list","members":{}},"LastEvaluatedTableName":{}}}},"putItem":{"name":"PutItem","input":{"type":"structure","members":{"TableName":{"required":true},"Item":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"required":true},"Expected":{"type":"map","keys":{},"members":{"type":"structure","members":{"Value":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"Exists":{"type":"boolean"}}}},"ReturnValues":{},"ReturnConsumedCapacity":{},"ReturnItemCollectionMetrics":{}}},"output":{"type":"structure","members":{"Attributes":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ConsumedCapacity":{"type":"structure","members":{"TableName":{},"CapacityUnits":{"type":"float"},"Table":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}},"LocalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}},"GlobalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}}}},"ItemCollectionMetrics":{"type":"structure","members":{"ItemCollectionKey":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"SizeEstimateRangeGB":{"type":"list","members":{"type":"float"}}}}}}},"query":{"name":"Query","input":{"type":"structure","members":{"TableName":{"required":true},"IndexName":{},"Select":{},"AttributesToGet":{"type":"list","members":{}},"Limit":{"type":"integer"},"ConsistentRead":{"type":"boolean"},"KeyConditions":{"type":"map","keys":{},"members":{"type":"structure","members":{"AttributeValueList":{"type":"list","members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ComparisonOperator":{"required":true}}}},"ScanIndexForward":{"type":"boolean"},"ExclusiveStartKey":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ReturnConsumedCapacity":{}}},"output":{"type":"structure","members":{"Items":{"type":"list","members":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}}},"Count":{"type":"integer"},"LastEvaluatedKey":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ConsumedCapacity":{"type":"structure","members":{"TableName":{},"CapacityUnits":{"type":"float"},"Table":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}},"LocalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}},"GlobalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}}}}}}},"scan":{"name":"Scan","input":{"type":"structure","members":{"TableName":{"required":true},"AttributesToGet":{"type":"list","members":{}},"Limit":{"type":"integer"},"Select":{},"ScanFilter":{"type":"map","keys":{},"members":{"type":"structure","members":{"AttributeValueList":{"type":"list","members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ComparisonOperator":{"required":true}}}},"ExclusiveStartKey":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ReturnConsumedCapacity":{},"TotalSegments":{"type":"integer"},"Segment":{"type":"integer"}}},"output":{"type":"structure","members":{"Items":{"type":"list","members":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}}},"Count":{"type":"integer"},"ScannedCount":{"type":"integer"},"LastEvaluatedKey":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ConsumedCapacity":{"type":"structure","members":{"TableName":{},"CapacityUnits":{"type":"float"},"Table":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}},"LocalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}},"GlobalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}}}}}}},"updateItem":{"name":"UpdateItem","input":{"type":"structure","members":{"TableName":{"required":true},"Key":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"required":true},"AttributeUpdates":{"type":"map","keys":{},"members":{"type":"structure","members":{"Value":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"Action":{}}}},"Expected":{"type":"map","keys":{},"members":{"type":"structure","members":{"Value":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}},"Exists":{"type":"boolean"}}}},"ReturnValues":{},"ReturnConsumedCapacity":{},"ReturnItemCollectionMetrics":{}}},"output":{"type":"structure","members":{"Attributes":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"ConsumedCapacity":{"type":"structure","members":{"TableName":{},"CapacityUnits":{"type":"float"},"Table":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}},"LocalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}},"GlobalSecondaryIndexes":{"type":"map","keys":{},"members":{"type":"structure","members":{"CapacityUnits":{"type":"float"}}}}}},"ItemCollectionMetrics":{"type":"structure","members":{"ItemCollectionKey":{"type":"map","keys":{},"members":{"type":"structure","members":{"S":{},"N":{},"B":{"type":"base64"},"SS":{"type":"list","members":{}},"NS":{"type":"list","members":{}},"BS":{"type":"list","members":{"type":"base64"}}}}},"SizeEstimateRangeGB":{"type":"list","members":{"type":"float"}}}}}}},"updateTable":{"name":"UpdateTable","input":{"type":"structure","members":{"TableName":{"required":true},"ProvisionedThroughput":{"type":"structure","members":{"ReadCapacityUnits":{"type":"integer","required":true},"WriteCapacityUnits":{"type":"integer","required":true}}},"GlobalSecondaryIndexUpdates":{"type":"list","members":{"type":"structure","members":{"Update":{"type":"structure","members":{"IndexName":{"required":true},"ProvisionedThroughput":{"type":"structure","members":{"ReadCapacityUnits":{"type":"integer","required":true},"WriteCapacityUnits":{"type":"integer","required":true}},"required":true}}}}}}}},"output":{"type":"structure","members":{"TableDescription":{"type":"structure","members":{"AttributeDefinitions":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"AttributeType":{}}}},"TableName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"TableStatus":{},"CreationDateTime":{"type":"timestamp"},"ProvisionedThroughput":{"type":"structure","members":{"LastIncreaseDateTime":{"type":"timestamp"},"LastDecreaseDateTime":{"type":"timestamp"},"NumberOfDecreasesToday":{"type":"integer"},"ReadCapacityUnits":{"type":"integer"},"WriteCapacityUnits":{"type":"integer"}}},"TableSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"},"LocalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}}},"IndexSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"}}}},"GlobalSecondaryIndexes":{"type":"list","members":{"type":"structure","members":{"IndexName":{},"KeySchema":{"type":"list","members":{"type":"structure","members":{"AttributeName":{},"KeyType":{}}}},"Projection":{"type":"structure","members":{"ProjectionType":{},"NonKeyAttributes":{"type":"list","members":{}}}},"IndexStatus":{},"ProvisionedThroughput":{"type":"structure","members":{"LastIncreaseDateTime":{"type":"timestamp"},"LastDecreaseDateTime":{"type":"timestamp"},"NumberOfDecreasesToday":{"type":"integer"},"ReadCapacityUnits":{"type":"integer"},"WriteCapacityUnits":{"type":"integer"}}},"IndexSizeBytes":{"type":"integer"},"ItemCount":{"type":"integer"}}}}}}}}}},"pagination":{"batchGetItem":{"inputToken":"RequestItems","outputToken":"UnprocessedKeys","resultKey":"Items"},"listTables":{"inputToken":"ExclusiveStartTableName","outputToken":"LastEvaluatedTableName","resultKey":"TableNames"},"query":{"inputToken":"ExclusiveStartKey","outputToken":"LastEvaluatedKey","resultKey":"Items"},"scan":{"inputToken":"ExclusiveStartKey","outputToken":"LastEvaluatedKey","resultKey":"Items"}}}); | |
AWS.Service.defineServiceApi(require("./services/s3"), "2006-03-01", {"format":"rest-xml","apiVersion":"2006-03-01","checksumFormat":"md5","endpointPrefix":"s3","globalEndpoint":"s3.amazonaws.com","serviceAbbreviation":"Amazon S3","serviceFullName":"Amazon Simple Storage Service","signatureVersion":"s3","timestampFormat":"rfc822","xmlnamespace":"http://s3.amazonaws.com/doc/2006-03-01/","operations":{"abortMultipartUpload":{"name":"AbortMultipartUpload","http":{"method":"DELETE","uri":"/{Bucket}/{Key}?uploadId={UploadId}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Key":{"required":true,"location":"uri"},"UploadId":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{}}},"completeMultipartUpload":{"name":"CompleteMultipartUpload","http":{"method":"POST","uri":"/{Bucket}/{Key}?uploadId={UploadId}"},"input":{"payload":"MultipartUpload","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Key":{"required":true,"location":"uri"},"MultipartUpload":{"type":"structure","name":"CompleteMultipartUpload","members":{"Parts":{"type":"list","name":"Part","members":{"type":"structure","members":{"ETag":{},"PartNumber":{"type":"integer"}}},"flattened":true}}},"UploadId":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"Bucket":{},"ETag":{},"Expiration":{"type":"timestamp","location":"header","name":"x-amz-expiration"},"Key":{},"Location":{},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"VersionId":{"location":"header","name":"x-amz-version-id"}}}},"copyObject":{"name":"CopyObject","alias":"PutObjectCopy","http":{"method":"PUT","uri":"/{Bucket}/{Key}"},"input":{"type":"structure","members":{"ACL":{"location":"header","name":"x-amz-acl"},"Bucket":{"required":true,"location":"uri"},"CacheControl":{"location":"header","name":"Cache-Control"},"ContentDisposition":{"location":"header","name":"Content-Disposition"},"ContentEncoding":{"location":"header","name":"Content-Encoding"},"ContentLanguage":{"location":"header","name":"Content-Language"},"ContentType":{"location":"header","name":"Content-Type"},"CopySource":{"required":true,"location":"header","name":"x-amz-copy-source"},"CopySourceIfMatch":{"type":"timestamp","location":"header","name":"x-amz-copy-source-if-match"},"CopySourceIfModifiedSince":{"type":"timestamp","location":"header","name":"x-amz-copy-source-if-modified-since"},"CopySourceIfNoneMatch":{"type":"timestamp","location":"header","name":"x-amz-copy-source-if-none-match"},"CopySourceIfUnmodifiedSince":{"type":"timestamp","location":"header","name":"x-amz-copy-source-if-unmodified-since"},"Expires":{"type":"timestamp","location":"header","name":"Expires"},"GrantFullControl":{"location":"header","name":"x-amz-grant-full-control"},"GrantRead":{"location":"header","name":"x-amz-grant-read"},"GrantReadACP":{"location":"header","name":"x-amz-grant-read-acp"},"GrantWriteACP":{"location":"header","name":"x-amz-grant-write-acp"},"Key":{"required":true,"location":"uri"},"Metadata":{"type":"map","location":"header","name":"x-amz-meta-","members":{},"keys":{}},"MetadataDirective":{"location":"header","name":"x-amz-metadata-directive"},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"StorageClass":{"location":"header","name":"x-amz-storage-class"},"WebsiteRedirectLocation":{"location":"header","name":"x-amz-website-redirect-location"}}},"output":{"type":"structure","members":{"CopySourceVersionId":{"location":"header","name":"x-amz-copy-source-version-id"},"Expiration":{"location":"header","name":"x-amz-expiration"},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"ETag":{},"LastModified":{}}}},"createBucket":{"name":"CreateBucket","alias":"PutBucket","http":{"method":"PUT","uri":"/{Bucket}"},"input":{"payload":"CreateBucketConfiguration","type":"structure","members":{"ACL":{"location":"header","name":"x-amz-acl"},"Bucket":{"required":true,"location":"uri"},"CreateBucketConfiguration":{"type":"structure","members":{"LocationConstraint":{}}},"GrantFullControl":{"location":"header","name":"x-amz-grant-full-control"},"GrantRead":{"location":"header","name":"x-amz-grant-read"},"GrantReadACP":{"location":"header","name":"x-amz-grant-read-acp"},"GrantWrite":{"location":"header","name":"x-amz-grant-write"},"GrantWriteACP":{"location":"header","name":"x-amz-grant-write-acp"}}},"output":{"type":"structure","members":{"Location":{"location":"header","name":"Location"}}}},"createMultipartUpload":{"name":"CreateMultipartUpload","alias":"InitiateMultipartUpload","http":{"method":"POST","uri":"/{Bucket}/{Key}?uploads"},"input":{"type":"structure","members":{"ACL":{"location":"header","name":"x-amz-acl"},"Bucket":{"required":true,"location":"uri"},"CacheControl":{"location":"header","name":"Cache-Control"},"ContentDisposition":{"location":"header","name":"Content-Disposition"},"ContentEncoding":{"location":"header","name":"Content-Encoding"},"ContentLanguage":{"location":"header","name":"Content-Language"},"ContentType":{"location":"header","name":"Content-Type"},"Expires":{"type":"timestamp","location":"header","name":"Expires"},"GrantFullControl":{"location":"header","name":"x-amz-grant-full-control"},"GrantRead":{"location":"header","name":"x-amz-grant-read"},"GrantReadACP":{"location":"header","name":"x-amz-grant-read-acp"},"GrantWriteACP":{"location":"header","name":"x-amz-grant-write-acp"},"Key":{"required":true,"location":"uri"},"Metadata":{"type":"map","location":"header","name":"x-amz-meta-","members":{},"keys":{}},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"StorageClass":{"location":"header","name":"x-amz-storage-class"},"WebsiteRedirectLocation":{"location":"header","name":"x-amz-website-redirect-location"}}},"output":{"type":"structure","members":{"Bucket":{"name":"Bucket"},"Key":{},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"UploadId":{}}}},"deleteBucket":{"name":"DeleteBucket","http":{"method":"DELETE","uri":"/{Bucket}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{}}},"deleteBucketCors":{"name":"DeleteBucketCors","http":{"method":"DELETE","uri":"/{Bucket}?cors"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{}}},"deleteBucketLifecycle":{"name":"DeleteBucketLifecycle","http":{"method":"DELETE","uri":"/{Bucket}?lifecycle"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{}}},"deleteBucketPolicy":{"name":"DeleteBucketPolicy","http":{"method":"DELETE","uri":"/{Bucket}?policy"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{}}},"deleteBucketTagging":{"name":"DeleteBucketTagging","http":{"method":"DELETE","uri":"/{Bucket}?tagging"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{}}},"deleteBucketWebsite":{"name":"DeleteBucketWebsite","http":{"method":"DELETE","uri":"/{Bucket}?website"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{}}},"deleteObject":{"name":"DeleteObject","http":{"method":"DELETE","uri":"/{Bucket}/{Key}?versionId={VersionId}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Key":{"required":true,"location":"uri"},"MFA":{"location":"header","name":"x-amz-mfa"},"VersionId":{"location":"uri"}}},"output":{"type":"structure","members":{"DeleteMarker":{"type":"boolean","location":"header","name":"x-amz-delete-marker"},"VersionId":{"location":"header","name":"x-amz-version-id"}}}},"deleteObjects":{"name":"DeleteObjects","alias":"DeleteMultipleObjects","http":{"method":"POST","uri":"/{Bucket}?delete"},"input":{"payload":"Delete","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Delete":{"type":"structure","required":true,"members":{"Objects":{"type":"list","required":true,"name":"Object","members":{"type":"structure","members":{"Key":{"required":true},"VersionId":{}}},"flattened":true},"Quiet":{"type":"boolean"}}},"MFA":{"location":"header","name":"x-amz-mfa"}}},"output":{"type":"structure","members":{"Deleted":{"type":"list","members":{"type":"structure","members":{"DeleteMarker":{"type":"boolean"},"DeleteMarkerVersionId":{},"Key":{},"VersionId":{}}},"flattened":true},"Error":{"type":"list","name":"Errors","members":{"type":"structure","members":{"Code":{},"Key":{},"Message":{},"VersionId":{}}},"flattened":true}}}},"getBucketAcl":{"name":"GetBucketAcl","http":{"method":"GET","uri":"/{Bucket}?acl"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"AccessControlList":{"type":"list","name":"Grants","members":{"type":"structure","name":"Grant","members":{"Grantee":{"type":"structure","xmlns":{"uri":"http://www.w3.org/2001/XMLSchema-instance","prefix":"xsi"},"members":{"DisplayName":{},"EmailAddress":{},"ID":{},"xsi:type":{"name":"Type","attribute":true},"URI":{}}},"Permission":{}}}},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}}}}},"getBucketCors":{"name":"GetBucketCors","http":{"method":"GET","uri":"/{Bucket}?cors"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"CORSRule":{"type":"list","name":"CORSRules","members":{"type":"structure","members":{"AllowedHeader":{"type":"list","name":"AllowedHeaders","members":{},"flattened":true},"AllowedMethod":{"type":"list","name":"AllowedMethods","members":{},"flattened":true},"AllowedOrigin":{"type":"list","name":"AllowedOrigins","members":{},"flattened":true},"ExposeHeader":{"type":"list","name":"ExposeHeaders","members":{},"flattened":true},"MaxAgeSeconds":{"type":"integer"}}},"flattened":true}}}},"getBucketLifecycle":{"name":"GetBucketLifecycle","http":{"method":"GET","uri":"/{Bucket}?lifecycle"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"Rule":{"type":"list","name":"Rules","members":{"type":"structure","members":{"Expiration":{"type":"structure","members":{"Date":{"type":"timestamp","format":"iso8601"},"Days":{"type":"integer"}}},"ID":{},"Prefix":{},"Status":{},"Transition":{"type":"structure","members":{"Date":{"type":"timestamp","format":"iso8601"},"Days":{"type":"integer"},"StorageClass":{}}}}},"flattened":true}}}},"getBucketLocation":{"name":"GetBucketLocation","http":{"method":"GET","uri":"/{Bucket}?location"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"LocationConstraint":{}}}},"getBucketLogging":{"name":"GetBucketLogging","http":{"method":"GET","uri":"/{Bucket}?logging"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"LoggingEnabled":{"type":"structure","members":{"TargetBucket":{},"TargetGrants":{"type":"list","members":{"type":"structure","name":"Grant","members":{"Grantee":{"type":"structure","xmlns":{"uri":"http://www.w3.org/2001/XMLSchema-instance","prefix":"xsi"},"members":{"DisplayName":{},"EmailAddress":{},"ID":{},"xsi:type":{"name":"Type","attribute":true},"URI":{}}},"Permission":{}}}},"TargetPrefix":{}}}}}},"getBucketNotification":{"name":"GetBucketNotification","http":{"method":"GET","uri":"/{Bucket}?notification"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"TopicConfiguration":{"type":"structure","members":{"Event":{},"Topic":{}}}}}},"getBucketPolicy":{"name":"GetBucketPolicy","http":{"method":"GET","uri":"/{Bucket}?policy"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"Policy":{}},"payload":"Policy"}},"getBucketRequestPayment":{"name":"GetBucketRequestPayment","http":{"method":"GET","uri":"/{Bucket}?requestPayment"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"Payer":{}}}},"getBucketTagging":{"name":"GetBucketTagging","http":{"method":"GET","uri":"/{Bucket}?tagging"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"TagSet":{"type":"list","members":{"type":"structure","name":"Tag","members":{"Key":{},"Value":{}}}}}}},"getBucketVersioning":{"name":"GetBucketVersioning","http":{"method":"GET","uri":"/{Bucket}?versioning"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"MFADelete":{},"Status":{}}}},"getBucketWebsite":{"name":"GetBucketWebsite","http":{"method":"GET","uri":"/{Bucket}?website"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"ErrorDocument":{"type":"structure","members":{"Key":{}}},"IndexDocument":{"type":"structure","members":{"Suffix":{}}},"RedirectAllRequestsTo":{"type":"structure","members":{"HostName":{},"Protocol":{}}},"RoutingRules":{"type":"list","members":{"type":"structure","name":"RoutingRule","members":{"Condition":{"type":"structure","members":{"HttpErrorCodeReturnedEquals":{},"KeyPrefixEquals":{}}},"Redirect":{"type":"structure","members":{"HostName":{},"HttpRedirectCode":{},"Protocol":{},"ReplaceKeyPrefixWith":{},"ReplaceKeyWith":{}}}}}}}}},"getObject":{"name":"GetObject","http":{"method":"GET","uri":"/{Bucket}/{Key}?versionId={VersionId}&response-content-type={ResponseContentType}&response-content-language={ResponseContentLanguage}&response-expires={ResponseExpires}&response-cache-control={ResponseCacheControl}&response-content-disposition={ResponseContentDisposition}&response-content-encoding={ResponseContentEncoding}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"IfMatch":{"location":"header","name":"If-Match"},"IfModifiedSince":{"type":"timestamp","location":"header","name":"If-Modified-Since"},"IfNoneMatch":{"location":"header","name":"If-None-Match"},"IfUnmodifiedSince":{"type":"timestamp","location":"header","name":"If-Unmodified-Since"},"Key":{"required":true,"location":"uri"},"Range":{"location":"header","name":"Range"},"ResponseCacheControl":{"location":"uri"},"ResponseContentDisposition":{"location":"uri"},"ResponseContentEncoding":{"location":"uri"},"ResponseContentLanguage":{"location":"uri"},"ResponseContentType":{"location":"uri"},"ResponseExpires":{"type":"timestamp","location":"uri"},"VersionId":{"location":"uri"}}},"output":{"type":"structure","members":{"AcceptRanges":{"location":"header","name":"accept-ranges"},"Body":{"type":"binary","streaming":true},"CacheControl":{"location":"header","name":"Cache-Control"},"ContentDisposition":{"location":"header","name":"Content-Disposition"},"ContentEncoding":{"location":"header","name":"Content-Encoding"},"ContentLanguage":{"location":"header","name":"Content-Language"},"ContentLength":{"type":"integer","location":"header","name":"Content-Length"},"ContentType":{"location":"header","name":"Content-Type"},"DeleteMarker":{"type":"boolean","location":"header","name":"x-amz-delete-marker"},"ETag":{"location":"header","name":"ETag"},"Expiration":{"location":"header","name":"x-amz-expiration"},"Expires":{"type":"timestamp","location":"header","name":"Expires"},"LastModified":{"type":"timestamp","location":"header","name":"Last-Modified"},"Metadata":{"type":"map","location":"header","name":"x-amz-meta-","members":{},"keys":{}},"MissingMeta":{"type":"integer","location":"header","name":"x-amz-missing-meta"},"Restore":{"location":"header","name":"x-amz-restore"},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"VersionId":{"location":"header","name":"x-amz-version-id"},"WebsiteRedirectLocation":{"location":"header","name":"x-amz-website-redirect-location"}},"payload":"Body"}},"getObjectAcl":{"name":"GetObjectAcl","http":{"method":"GET","uri":"/{Bucket}/{Key}?acl&versionId={VersionId}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Key":{"required":true,"location":"uri"},"VersionId":{"location":"uri"}}},"output":{"type":"structure","members":{"AccessControlList":{"type":"list","name":"Grants","members":{"type":"structure","name":"Grant","members":{"Grantee":{"type":"structure","xmlns":{"uri":"http://www.w3.org/2001/XMLSchema-instance","prefix":"xsi"},"members":{"DisplayName":{},"EmailAddress":{},"ID":{},"xsi:type":{"name":"Type","attribute":true},"URI":{}}},"Permission":{}}}},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}}}}},"getObjectTorrent":{"name":"GetObjectTorrent","http":{"method":"GET","uri":"/{Bucket}/{Key}?torrent"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Key":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"Body":{"type":"binary","streaming":true}},"payload":"Body"}},"headBucket":{"name":"HeadBucket","http":{"method":"HEAD","uri":"/{Bucket}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{}}},"headObject":{"name":"HeadObject","http":{"method":"HEAD","uri":"/{Bucket}/{Key}?versionId={VersionId}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"IfMatch":{"location":"header","name":"If-Match"},"IfModifiedSince":{"type":"timestamp","location":"header","name":"If-Modified-Since"},"IfNoneMatch":{"location":"header","name":"If-None-Match"},"IfUnmodifiedSince":{"type":"timestamp","location":"header","name":"If-Unmodified-Since"},"Key":{"required":true,"location":"uri"},"Range":{"location":"header","name":"Range"},"VersionId":{"location":"uri"}}},"output":{"type":"structure","members":{"AcceptRanges":{"location":"header","name":"accept-ranges"},"CacheControl":{"location":"header","name":"Cache-Control"},"ContentDisposition":{"location":"header","name":"Content-Disposition"},"ContentEncoding":{"location":"header","name":"Content-Encoding"},"ContentLanguage":{"location":"header","name":"Content-Language"},"ContentLength":{"type":"integer","location":"header","name":"Content-Length"},"ContentType":{"location":"header","name":"Content-Type"},"DeleteMarker":{"type":"boolean","location":"header","name":"x-amz-delete-marker"},"ETag":{"location":"header","name":"ETag"},"Expiration":{"location":"header","name":"x-amz-expiration"},"Expires":{"type":"timestamp","location":"header","name":"Expires"},"LastModified":{"type":"timestamp","location":"header","name":"Last-Modified"},"Metadata":{"type":"map","location":"header","name":"x-amz-meta-","members":{},"keys":{}},"MissingMeta":{"type":"integer","location":"header","name":"x-amz-missing-meta"},"Restore":{"location":"header","name":"x-amz-restore"},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"VersionId":{"location":"header","name":"x-amz-version-id"},"WebsiteRedirectLocation":{"location":"header","name":"x-amz-website-redirect-location"}}}},"listBuckets":{"name":"ListBuckets","alias":"GetService","http":{"method":"GET","uri":"/"},"input":{"type":"structure","members":{}},"output":{"type":"structure","members":{"Buckets":{"type":"list","members":{"type":"structure","name":"Bucket","members":{"CreationDate":{"type":"timestamp"},"Name":{}}}},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}}}}},"listMultipartUploads":{"name":"ListMultipartUploads","http":{"method":"GET","uri":"/{Bucket}?uploads&prefix={Prefix}&delimiter={Delimiter}&max-uploads={MaxUploads}&key-marker={KeyMarker}&upload-id-marker={UploadIdMarker}&encoding-type={EncodingType}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Delimiter":{"location":"uri"},"EncodingType":{"location":"uri"},"KeyMarker":{"location":"uri"},"MaxUploads":{"type":"integer","location":"uri"},"Prefix":{"location":"uri"},"UploadIdMarker":{"location":"uri"}}},"output":{"type":"structure","members":{"Bucket":{},"CommonPrefixes":{"type":"list","members":{"type":"structure","members":{"Prefix":{}}},"flattened":true},"EncodingType":{"location":"header","name":"Encoding-Type"},"IsTruncated":{"type":"boolean"},"KeyMarker":{},"MaxUploads":{"type":"integer"},"NextKeyMarker":{},"NextUploadIdMarker":{},"Prefix":{},"UploadIdMarker":{},"Upload":{"type":"list","name":"Uploads","members":{"type":"structure","members":{"Initiated":{"type":"timestamp"},"Initiator":{"type":"structure","members":{"DisplayName":{},"ID":{}}},"Key":{},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}},"StorageClass":{},"UploadId":{}}},"flattened":true}}}},"listObjectVersions":{"name":"ListObjectVersions","alias":"GetBucketObjectVersions","http":{"method":"GET","uri":"/{Bucket}?versions&delimiter={Delimiter}&key-marker={KeyMarker}&max-keys={MaxKeys}&prefix={Prefix}&version-id-marker={VersionIdMarker}&encoding-type={EncodingType}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Delimiter":{"location":"uri"},"EncodingType":{"location":"uri"},"KeyMarker":{"location":"uri"},"MaxKeys":{"type":"integer","location":"uri"},"Prefix":{"location":"uri"},"VersionIdMarker":{"location":"uri"}}},"output":{"type":"structure","members":{"CommonPrefixes":{"type":"list","members":{"type":"structure","members":{"Prefix":{}}},"flattened":true},"DeleteMarker":{"type":"list","name":"DeleteMarkers","members":{"type":"structure","members":{"IsLatest":{"type":"boolean"},"Key":{},"LastModified":{"type":"timestamp"},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}},"VersionId":{}}},"flattened":true},"EncodingType":{"location":"header","name":"Encoding-Type"},"IsTruncated":{"type":"boolean"},"KeyMarker":{},"MaxKeys":{"type":"integer"},"Name":{},"NextKeyMarker":{},"NextVersionIdMarker":{},"Prefix":{},"VersionIdMarker":{},"Version":{"type":"list","name":"Versions","members":{"type":"structure","members":{"ETag":{},"IsLatest":{"type":"boolean"},"Key":{},"LastModified":{"type":"timestamp"},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}},"Size":{},"StorageClass":{},"VersionId":{}}},"flattened":true}}}},"listObjects":{"name":"ListObjects","alias":"GetBucket","http":{"method":"GET","uri":"/{Bucket}?delimiter={Delimiter}&marker={Marker}&max-keys={MaxKeys}&prefix={Prefix}&encoding-type={EncodingType}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Delimiter":{"location":"uri"},"EncodingType":{"location":"uri"},"Marker":{"location":"uri"},"MaxKeys":{"type":"integer","location":"uri"},"Prefix":{"location":"uri"}}},"output":{"type":"structure","members":{"CommonPrefixes":{"type":"list","members":{"type":"structure","members":{"Prefix":{}}},"flattened":true},"Contents":{"type":"list","members":{"type":"structure","members":{"ETag":{},"Key":{},"LastModified":{"type":"timestamp"},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}},"Size":{"type":"integer"},"StorageClass":{}}},"flattened":true},"EncodingType":{"location":"header","name":"Encoding-Type"},"IsTruncated":{"type":"boolean"},"Marker":{},"MaxKeys":{"type":"integer"},"Name":{},"NextMarker":{},"Prefix":{}}}},"listParts":{"name":"ListParts","http":{"method":"GET","uri":"/{Bucket}/{Key}?uploadId={UploadId}&max-parts={MaxParts}&part-number-marker={PartNumberMarker}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Key":{"required":true,"location":"uri"},"MaxParts":{"type":"integer","location":"uri"},"PartNumberMarker":{"type":"integer","location":"uri"},"UploadId":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"Bucket":{},"Initiator":{"type":"structure","members":{"DisplayName":{},"ID":{}}},"IsTruncated":{"type":"boolean"},"Key":{},"MaxParts":{"type":"integer"},"NextPartNumberMarker":{"type":"integer"},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}},"PartNumberMarker":{"type":"integer"},"Part":{"type":"list","name":"Parts","members":{"type":"structure","members":{"ETag":{},"LastModified":{"type":"timestamp"},"PartNumber":{"type":"integer"},"Size":{"type":"integer"}}},"flattened":true},"StorageClass":{},"UploadId":{}}}},"putBucketAcl":{"name":"PutBucketAcl","http":{"method":"PUT","uri":"/{Bucket}?acl"},"input":{"payload":"AccessControlPolicy","type":"structure","members":{"ACL":{"location":"header","name":"x-amz-acl"},"AccessControlPolicy":{"type":"structure","members":{"Grants":{"type":"list","name":"AccessControlList","members":{"type":"structure","name":"Grant","members":{"Grantee":{"type":"structure","xmlns":{"uri":"http://www.w3.org/2001/XMLSchema-instance","prefix":"xsi"},"members":{"DisplayName":{},"EmailAddress":{},"ID":{},"Type":{"required":true,"name":"xsi:type","attribute":true},"URI":{}}},"Permission":{}}}},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}}}},"Bucket":{"required":true,"location":"uri"},"ContentMD5":{"location":"header","name":"Content-MD5"},"GrantFullControl":{"location":"header","name":"x-amz-grant-full-control"},"GrantRead":{"location":"header","name":"x-amz-grant-read"},"GrantReadACP":{"location":"header","name":"x-amz-grant-read-acp"},"GrantWrite":{"location":"header","name":"x-amz-grant-write"},"GrantWriteACP":{"location":"header","name":"x-amz-grant-write-acp"}}},"output":{"type":"structure","members":{}}},"putBucketCors":{"name":"PutBucketCors","http":{"method":"PUT","uri":"/{Bucket}?cors"},"input":{"payload":"CORSConfiguration","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"CORSConfiguration":{"type":"structure","members":{"CORSRules":{"type":"list","name":"CORSRule","members":{"type":"structure","members":{"AllowedHeaders":{"type":"list","name":"AllowedHeader","members":{},"flattened":true},"AllowedMethods":{"type":"list","name":"AllowedMethod","members":{},"flattened":true},"AllowedOrigins":{"type":"list","name":"AllowedOrigin","members":{},"flattened":true},"ExposeHeaders":{"type":"list","name":"ExposeHeader","members":{},"flattened":true},"MaxAgeSeconds":{"type":"integer"}}},"flattened":true}}},"ContentMD5":{"location":"header","name":"Content-MD5"}}},"output":{"type":"structure","members":{}}},"putBucketLifecycle":{"name":"PutBucketLifecycle","http":{"method":"PUT","uri":"/{Bucket}?lifecycle"},"input":{"payload":"LifecycleConfiguration","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"ContentMD5":{"location":"header","name":"Content-MD5"},"LifecycleConfiguration":{"type":"structure","members":{"Rules":{"type":"list","required":true,"name":"Rule","members":{"type":"structure","members":{"Expiration":{"type":"structure","members":{"Date":{"type":"timestamp","format":"iso8601"},"Days":{"type":"integer"}}},"ID":{},"Prefix":{"required":true},"Status":{"required":true},"Transition":{"type":"structure","members":{"Date":{"type":"timestamp","format":"iso8601"},"Days":{"type":"integer"},"StorageClass":{}}}}},"flattened":true}}}}},"output":{"type":"structure","members":{}}},"putBucketLogging":{"name":"PutBucketLogging","http":{"method":"PUT","uri":"/{Bucket}?logging"},"input":{"payload":"BucketLoggingStatus","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"BucketLoggingStatus":{"type":"structure","required":true,"members":{"LoggingEnabled":{"type":"structure","members":{"TargetBucket":{},"TargetGrants":{"type":"list","members":{"type":"structure","name":"Grant","members":{"Grantee":{"type":"structure","xmlns":{"uri":"http://www.w3.org/2001/XMLSchema-instance","prefix":"xsi"},"members":{"DisplayName":{},"EmailAddress":{},"ID":{},"Type":{"required":true,"name":"xsi:type","attribute":true},"URI":{}}},"Permission":{}}}},"TargetPrefix":{}}}}},"ContentMD5":{"location":"header","name":"Content-MD5"}}},"output":{"type":"structure","members":{}}},"putBucketNotification":{"name":"PutBucketNotification","http":{"method":"PUT","uri":"/{Bucket}?notification"},"input":{"payload":"NotificationConfiguration","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"ContentMD5":{"location":"header","name":"Content-MD5"},"NotificationConfiguration":{"type":"structure","required":true,"members":{"TopicConfiguration":{"type":"structure","required":true,"members":{"Event":{},"Topic":{}}}}}}},"output":{"type":"structure","members":{}}},"putBucketPolicy":{"name":"PutBucketPolicy","http":{"method":"PUT","uri":"/{Bucket}?policy"},"input":{"payload":"Policy","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"ContentMD5":{"location":"header","name":"Content-MD5"},"Policy":{"required":true}}},"output":{"type":"structure","members":{}}},"putBucketRequestPayment":{"name":"PutBucketRequestPayment","http":{"method":"PUT","uri":"/{Bucket}?requestPayment"},"input":{"payload":"RequestPaymentConfiguration","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"ContentMD5":{"location":"header","name":"Content-MD5"},"RequestPaymentConfiguration":{"type":"structure","required":true,"members":{"Payer":{"required":true}}}}},"output":{"type":"structure","members":{}}},"putBucketTagging":{"name":"PutBucketTagging","http":{"method":"PUT","uri":"/{Bucket}?tagging"},"input":{"payload":"Tagging","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"ContentMD5":{"location":"header","name":"Content-MD5"},"Tagging":{"type":"structure","required":true,"members":{"TagSet":{"type":"list","required":true,"members":{"type":"structure","required":true,"name":"Tag","members":{"Key":{"required":true},"Value":{"required":true}}}}}}}},"output":{"type":"structure","members":{}}},"putBucketVersioning":{"name":"PutBucketVersioning","http":{"method":"PUT","uri":"/{Bucket}?versioning"},"input":{"payload":"VersioningConfiguration","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"ContentMD5":{"location":"header","name":"Content-MD5"},"MFA":{"location":"header","name":"x-amz-mfa"},"VersioningConfiguration":{"type":"structure","required":true,"members":{"MFADelete":{},"Status":{}}}}},"output":{"type":"structure","members":{}}},"putBucketWebsite":{"name":"PutBucketWebsite","http":{"method":"PUT","uri":"/{Bucket}?website"},"input":{"payload":"WebsiteConfiguration","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"ContentMD5":{"location":"header","name":"Content-MD5"},"WebsiteConfiguration":{"type":"structure","required":true,"members":{"ErrorDocument":{"type":"structure","members":{"Key":{"required":true}}},"IndexDocument":{"type":"structure","members":{"Suffix":{"required":true}}},"RedirectAllRequestsTo":{"type":"structure","members":{"HostName":{"required":true},"Protocol":{}}},"RoutingRules":{"type":"list","members":{"type":"structure","name":"RoutingRule","members":{"Condition":{"type":"structure","members":{"HttpErrorCodeReturnedEquals":{},"KeyPrefixEquals":{}}},"Redirect":{"type":"structure","required":true,"members":{"HostName":{},"HttpRedirectCode":{},"Protocol":{},"ReplaceKeyPrefixWith":{},"ReplaceKeyWith":{}}}}}}}}}},"output":{"type":"structure","members":{}}},"putObject":{"name":"PutObject","http":{"method":"PUT","uri":"/{Bucket}/{Key}"},"input":{"payload":"Body","type":"structure","members":{"ACL":{"location":"header","name":"x-amz-acl"},"Body":{"type":"binary","streaming":true},"Bucket":{"required":true,"location":"uri"},"CacheControl":{"location":"header","name":"Cache-Control"},"ContentDisposition":{"location":"header","name":"Content-Disposition"},"ContentEncoding":{"location":"header","name":"Content-Encoding"},"ContentLanguage":{"location":"header","name":"Content-Language"},"ContentLength":{"type":"integer","location":"header","name":"Content-Length"},"ContentMD5":{"location":"header","name":"Content-MD5"},"ContentType":{"location":"header","name":"Content-Type"},"Expires":{"type":"timestamp","location":"header","name":"Expires"},"GrantFullControl":{"location":"header","name":"x-amz-grant-full-control"},"GrantRead":{"location":"header","name":"x-amz-grant-read"},"GrantReadACP":{"location":"header","name":"x-amz-grant-read-acp"},"GrantWriteACP":{"location":"header","name":"x-amz-grant-write-acp"},"Key":{"required":true,"location":"uri"},"Metadata":{"type":"map","location":"header","name":"x-amz-meta-","members":{},"keys":{}},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"StorageClass":{"location":"header","name":"x-amz-storage-class"},"WebsiteRedirectLocation":{"location":"header","name":"x-amz-website-redirect-location"}}},"output":{"type":"structure","members":{"ETag":{"location":"header","name":"ETag"},"Expiration":{"type":"timestamp","location":"header","name":"x-amz-expiration"},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"VersionId":{"location":"header","name":"x-amz-version-id"}}}},"putObjectAcl":{"name":"PutObjectAcl","http":{"method":"PUT","uri":"/{Bucket}/{Key}?acl"},"input":{"payload":"AccessControlPolicy","type":"structure","members":{"ACL":{"location":"header","name":"x-amz-acl"},"AccessControlPolicy":{"type":"structure","members":{"Grants":{"type":"list","name":"AccessControlList","members":{"type":"structure","name":"Grant","members":{"Grantee":{"type":"structure","xmlns":{"uri":"http://www.w3.org/2001/XMLSchema-instance","prefix":"xsi"},"members":{"DisplayName":{},"EmailAddress":{},"ID":{},"Type":{"required":true,"name":"xsi:type","attribute":true},"URI":{}}},"Permission":{}}}},"Owner":{"type":"structure","members":{"DisplayName":{},"ID":{}}}}},"Bucket":{"required":true,"location":"uri"},"ContentMD5":{"location":"header","name":"Content-MD5"},"GrantFullControl":{"location":"header","name":"x-amz-grant-full-control"},"GrantRead":{"location":"header","name":"x-amz-grant-read"},"GrantReadACP":{"location":"header","name":"x-amz-grant-read-acp"},"GrantWrite":{"location":"header","name":"x-amz-grant-write"},"GrantWriteACP":{"location":"header","name":"x-amz-grant-write-acp"},"Key":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{}}},"restoreObject":{"name":"RestoreObject","alias":"PostObjectRestore","http":{"method":"POST","uri":"/{Bucket}/{Key}?restore"},"input":{"payload":"RestoreRequest","type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"Key":{"required":true,"location":"uri"},"RestoreRequest":{"type":"structure","members":{"Days":{"type":"integer","required":true}}}}},"output":{"type":"structure","members":{}}},"uploadPart":{"name":"UploadPart","http":{"method":"PUT","uri":"/{Bucket}/{Key}?partNumber={PartNumber}&uploadId={UploadId}"},"input":{"payload":"Body","type":"structure","members":{"Body":{"type":"binary","streaming":true},"Bucket":{"required":true,"location":"uri"},"ContentLength":{"type":"integer","location":"header","name":"Content-Length"},"ContentMD5":{"location":"header","name":"Content-MD5"},"Key":{"required":true,"location":"uri"},"PartNumber":{"type":"integer","required":true,"location":"uri"},"UploadId":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"ETag":{"location":"header","name":"ETag"},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"}}}},"uploadPartCopy":{"name":"UploadPartCopy","http":{"method":"PUT","uri":"/{Bucket}/{Key}?partNumber={PartNumber}&uploadId={UploadId}"},"input":{"type":"structure","members":{"Bucket":{"required":true,"location":"uri"},"CopySource":{"required":true,"location":"header","name":"x-amz-copy-source"},"CopySourceIfMatch":{"type":"timestamp","location":"header","name":"x-amz-copy-source-if-match"},"CopySourceIfModifiedSince":{"type":"timestamp","location":"header","name":"x-amz-copy-source-if-modified-since"},"CopySourceIfNoneMatch":{"type":"timestamp","location":"header","name":"x-amz-copy-source-if-none-match"},"CopySourceIfUnmodifiedSince":{"type":"timestamp","location":"header","name":"x-amz-copy-source-if-unmodified-since"},"CopySourceRange":{"location":"header","name":"x-amz-copy-source-range"},"Key":{"required":true,"location":"uri"},"PartNumber":{"type":"integer","required":true,"location":"uri"},"UploadId":{"required":true,"location":"uri"}}},"output":{"type":"structure","members":{"CopySourceVersionId":{"location":"header","name":"x-amz-copy-source-version-id"},"ServerSideEncryption":{"location":"header","name":"x-amz-server-side-encryption"},"ETag":{},"LastModified":{"type":"timestamp"}}}}},"pagination":{"listMultipartUploads":{"limitKey":"MaxUploads","moreResults":"IsTruncated","outputToken":["NextKeyMarker","NextUploadIdMarker"],"inputToken":["KeyMarker","UploadIdMarker"],"resultKey":"Uploads"},"listObjectVersions":{"moreResults":"IsTruncated","limitKey":"MaxKeys","outputToken":["NextKeyMarker","NextVersionIdMarker"],"inputToken":["KeyMarker","VersionIdMarker"],"resultKey":"Versions"},"listObjects":{"moreResults":"IsTruncated","limitKey":"MaxKeys","outputToken":"NextMarker or Contents[-1].Key","inputToken":"Marker","resultKey":["Contents","CommonPrefixes"]},"listParts":{"limitKey":"IsTruncated","outputToken":"NextPartNumberMarker","inputToken":"PartNumberMarker","resultKey":"Parts"}}}); | |
AWS.Service.defineServiceApi(require("./services/sqs"), "2012-11-05", {"format":"query","apiVersion":"2012-11-05","endpointPrefix":"sqs","resultWrapped":true,"serviceAbbreviation":"Amazon SQS","serviceFullName":"Amazon Simple Queue Service","signatureVersion":"v4","timestampFormat":"iso8601","operations":{"addPermission":{"name":"AddPermission","input":{"type":"structure","members":{"QueueUrl":{"required":true},"Label":{"required":true},"AWSAccountIds":{"type":"list","members":{"name":"AWSAccountId"},"flattened":true,"required":true},"Actions":{"type":"list","members":{"name":"ActionName"},"flattened":true,"required":true}}},"output":{"type":"structure","members":{}}},"changeMessageVisibility":{"name":"ChangeMessageVisibility","input":{"type":"structure","members":{"QueueUrl":{"required":true},"ReceiptHandle":{"required":true},"VisibilityTimeout":{"type":"integer","required":true}}},"output":{"type":"structure","members":{}}},"changeMessageVisibilityBatch":{"name":"ChangeMessageVisibilityBatch","input":{"type":"structure","members":{"QueueUrl":{"required":true},"Entries":{"type":"list","members":{"type":"structure","members":{"Id":{"required":true},"ReceiptHandle":{"required":true},"VisibilityTimeout":{"type":"integer"}},"name":"ChangeMessageVisibilityBatchRequestEntry"},"flattened":true,"required":true}}},"output":{"type":"structure","members":{"ChangeMessageVisibilityBatchResultEntry":{"type":"list","members":{"type":"structure","members":{"Id":{}},"name":"ChangeMessageVisibilityBatchResultEntry"},"flattened":true,"name":"Successful"},"BatchResultErrorEntry":{"type":"list","members":{"type":"structure","members":{"Id":{},"SenderFault":{"type":"boolean"},"Code":{},"Message":{}},"name":"BatchResultErrorEntry"},"flattened":true,"name":"Failed"}}}},"createQueue":{"name":"CreateQueue","input":{"type":"structure","members":{"QueueName":{"required":true},"Attributes":{"type":"map","keys":{"name":"Name"},"members":{"name":"Value"},"flattened":true,"name":"Attribute"}}},"output":{"type":"structure","members":{"QueueUrl":{}}}},"deleteMessage":{"name":"DeleteMessage","input":{"type":"structure","members":{"QueueUrl":{"required":true},"ReceiptHandle":{"required":true}}},"output":{"type":"structure","members":{}}},"deleteMessageBatch":{"name":"DeleteMessageBatch","input":{"type":"structure","members":{"QueueUrl":{"required":true},"Entries":{"type":"list","members":{"type":"structure","members":{"Id":{"required":true},"ReceiptHandle":{"required":true}},"name":"DeleteMessageBatchRequestEntry"},"flattened":true,"required":true}}},"output":{"type":"structure","members":{"DeleteMessageBatchResultEntry":{"type":"list","members":{"type":"structure","members":{"Id":{}},"name":"DeleteMessageBatchResultEntry"},"flattened":true,"name":"Successful"},"BatchResultErrorEntry":{"type":"list","members":{"type":"structure","members":{"Id":{},"SenderFault":{"type":"boolean"},"Code":{},"Message":{}},"name":"BatchResultErrorEntry"},"flattened":true,"name":"Failed"}}}},"deleteQueue":{"name":"DeleteQueue","input":{"type":"structure","members":{"QueueUrl":{"required":true}}},"output":{"type":"structure","members":{}}},"getQueueAttributes":{"name":"GetQueueAttributes","input":{"type":"structure","members":{"QueueUrl":{"required":true},"AttributeNames":{"type":"list","members":{"name":"AttributeName"},"flattened":true}}},"output":{"type":"structure","members":{"Attribute":{"type":"map","keys":{"name":"Name"},"members":{"name":"Value"},"flattened":true,"name":"Attributes"}}}},"getQueueUrl":{"name":"GetQueueUrl","input":{"type":"structure","members":{"QueueName":{"required":true},"QueueOwnerAWSAccountId":{}}},"output":{"type":"structure","members":{"QueueUrl":{}}}},"listQueues":{"name":"ListQueues","input":{"type":"structure","members":{"QueueNamePrefix":{}}},"output":{"type":"structure","members":{"QueueUrl":{"type":"list","members":{"name":"QueueUrl"},"flattened":true,"name":"QueueUrls"}}}},"receiveMessage":{"name":"ReceiveMessage","input":{"type":"structure","members":{"QueueUrl":{"required":true},"AttributeNames":{"type":"list","members":{"name":"AttributeName"},"flattened":true},"MaxNumberOfMessages":{"type":"integer"},"VisibilityTimeout":{"type":"integer"},"WaitTimeSeconds":{"type":"integer"}}},"output":{"type":"structure","members":{"Message":{"type":"list","members":{"type":"structure","members":{"MessageId":{},"ReceiptHandle":{},"MD5OfBody":{},"Body":{},"Attribute":{"type":"map","keys":{"name":"Name"},"members":{"name":"Value"},"flattened":true,"name":"Attributes"}},"name":"Message"},"flattened":true,"name":"Messages"}}}},"removePermission":{"name":"RemovePermission","input":{"type":"structure","members":{"QueueUrl":{"required":true},"Label":{"required":true}}},"output":{"type":"structure","members":{}}},"sendMessage":{"name":"SendMessage","input":{"type":"structure","members":{"QueueUrl":{"required":true},"MessageBody":{"required":true},"DelaySeconds":{"type":"integer"}}},"output":{"type":"structure","members":{"MD5OfMessageBody":{},"MessageId":{}}}},"sendMessageBatch":{"name":"SendMessageBatch","input":{"type":"structure","members":{"QueueUrl":{"required":true},"Entries":{"type":"list","members":{"type":"structure","members":{"Id":{"required":true},"MessageBody":{"required":true},"DelaySeconds":{"type":"integer"}},"name":"SendMessageBatchRequestEntry"},"flattened":true,"required":true}}},"output":{"type":"structure","members":{"SendMessageBatchResultEntry":{"type":"list","members":{"type":"structure","members":{"Id":{},"MessageId":{},"MD5OfMessageBody":{}},"name":"SendMessageBatchResultEntry"},"flattened":true,"name":"Successful"},"BatchResultErrorEntry":{"type":"list","members":{"type":"structure","members":{"Id":{},"SenderFault":{"type":"boolean"},"Code":{},"Message":{}},"name":"BatchResultErrorEntry"},"flattened":true,"name":"Failed"}}}},"setQueueAttributes":{"name":"SetQueueAttributes","input":{"type":"structure","members":{"QueueUrl":{"required":true},"Attributes":{"type":"map","keys":{"name":"Name"},"members":{"name":"Value"},"flattened":true,"name":"Attribute","required":true}}},"output":{"type":"structure","members":{}}}},"pagination":{"listQueues":{"resultKey":"QueueUrls"}}}); | |
AWS.Service.defineServiceApi(require("./services/sns"), "2010-03-31", {"format":"query","apiVersion":"2010-03-31","endpointPrefix":"sns","resultWrapped":true,"serviceAbbreviation":"Amazon SNS","serviceFullName":"Amazon Simple Notification Service","signatureVersion":"v4","timestampFormat":"iso8601","operations":{"addPermission":{"name":"AddPermission","input":{"type":"structure","members":{"TopicArn":{"required":true},"Label":{"required":true},"AWSAccountId":{"type":"list","members":{},"required":true},"ActionName":{"type":"list","members":{},"required":true}}},"output":{"type":"structure","members":{}}},"confirmSubscription":{"name":"ConfirmSubscription","input":{"type":"structure","members":{"TopicArn":{"required":true},"Token":{"required":true},"AuthenticateOnUnsubscribe":{}}},"output":{"type":"structure","members":{"SubscriptionArn":{}}}},"createPlatformApplication":{"name":"CreatePlatformApplication","input":{"type":"structure","members":{"Name":{"required":true},"Platform":{"required":true},"Attributes":{"type":"map","keys":{},"members":{},"required":true}}},"output":{"type":"structure","members":{"PlatformApplicationArn":{}}}},"createPlatformEndpoint":{"name":"CreatePlatformEndpoint","input":{"type":"structure","members":{"PlatformApplicationArn":{"required":true},"Token":{"required":true},"CustomUserData":{},"Attributes":{"type":"map","keys":{},"members":{}}}},"output":{"type":"structure","members":{"EndpointArn":{}}}},"createTopic":{"name":"CreateTopic","input":{"type":"structure","members":{"Name":{"required":true}}},"output":{"type":"structure","members":{"TopicArn":{}}}},"deleteEndpoint":{"name":"DeleteEndpoint","input":{"type":"structure","members":{"EndpointArn":{"required":true}}},"output":{"type":"structure","members":{}}},"deletePlatformApplication":{"name":"DeletePlatformApplication","input":{"type":"structure","members":{"PlatformApplicationArn":{"required":true}}},"output":{"type":"structure","members":{}}},"deleteTopic":{"name":"DeleteTopic","input":{"type":"structure","members":{"TopicArn":{"required":true}}},"output":{"type":"structure","members":{}}},"getEndpointAttributes":{"name":"GetEndpointAttributes","input":{"type":"structure","members":{"EndpointArn":{"required":true}}},"output":{"type":"structure","members":{"Attributes":{"type":"map","keys":{},"members":{}}}}},"getPlatformApplicationAttributes":{"name":"GetPlatformApplicationAttributes","input":{"type":"structure","members":{"PlatformApplicationArn":{"required":true}}},"output":{"type":"structure","members":{"Attributes":{"type":"map","keys":{},"members":{}}}}},"getSubscriptionAttributes":{"name":"GetSubscriptionAttributes","input":{"type":"structure","members":{"SubscriptionArn":{"required":true}}},"output":{"type":"structure","members":{"Attributes":{"type":"map","keys":{},"members":{}}}}},"getTopicAttributes":{"name":"GetTopicAttributes","input":{"type":"structure","members":{"TopicArn":{"required":true}}},"output":{"type":"structure","members":{"Attributes":{"type":"map","keys":{},"members":{}}}}},"listEndpointsByPlatformApplication":{"name":"ListEndpointsByPlatformApplication","input":{"type":"structure","members":{"PlatformApplicationArn":{"required":true},"NextToken":{}}},"output":{"type":"structure","members":{"Endpoints":{"type":"list","members":{"type":"structure","members":{"EndpointArn":{},"Attributes":{"type":"map","keys":{},"members":{}}}}},"NextToken":{}}}},"listPlatformApplications":{"name":"ListPlatformApplications","input":{"type":"structure","members":{"NextToken":{}}},"output":{"type":"structure","members":{"PlatformApplications":{"type":"list","members":{"type":"structure","members":{"PlatformApplicationArn":{},"Attributes":{"type":"map","keys":{},"members":{}}}}},"NextToken":{}}}},"listSubscriptions":{"name":"ListSubscriptions","input":{"type":"structure","members":{"NextToken":{}}},"output":{"type":"structure","members":{"Subscriptions":{"type":"list","members":{"type":"structure","members":{"SubscriptionArn":{},"Owner":{},"Protocol":{},"Endpoint":{},"TopicArn":{}}}},"NextToken":{}}}},"listSubscriptionsByTopic":{"name":"ListSubscriptionsByTopic","input":{"type":"structure","members":{"TopicArn":{"required":true},"NextToken":{}}},"output":{"type":"structure","members":{"Subscriptions":{"type":"list","members":{"type":"structure","members":{"SubscriptionArn":{},"Owner":{},"Protocol":{},"Endpoint":{},"TopicArn":{}}}},"NextToken":{}}}},"listTopics":{"name":"ListTopics","input":{"type":"structure","members":{"NextToken":{}}},"output":{"type":"structure","members":{"Topics":{"type":"list","members":{"type":"structure","members":{"TopicArn":{}}}},"NextToken":{}}}},"publish":{"name":"Publish","input":{"type":"structure","members":{"TopicArn":{},"TargetArn":{},"Message":{"required":true},"Subject":{},"MessageStructure":{}}},"output":{"type":"structure","members":{"MessageId":{}}}},"removePermission":{"name":"RemovePermission","input":{"type":"structure","members":{"TopicArn":{"required":true},"Label":{"required":true}}},"output":{"type":"structure","members":{}}},"setEndpointAttributes":{"name":"SetEndpointAttributes","input":{"type":"structure","members":{"EndpointArn":{"required":true},"Attributes":{"type":"map","keys":{},"members":{},"required":true}}},"output":{"type":"structure","members":{}}},"setPlatformApplicationAttributes":{"name":"SetPlatformApplicationAttributes","input":{"type":"structure","members":{"PlatformApplicationArn":{"required":true},"Attributes":{"type":"map","keys":{},"members":{},"required":true}}},"output":{"type":"structure","members":{}}},"setSubscriptionAttributes":{"name":"SetSubscriptionAttributes","input":{"type":"structure","members":{"SubscriptionArn":{"required":true},"AttributeName":{"required":true},"AttributeValue":{}}},"output":{"type":"structure","members":{}}},"setTopicAttributes":{"name":"SetTopicAttributes","input":{"type":"structure","members":{"TopicArn":{"required":true},"AttributeName":{"required":true},"AttributeValue":{}}},"output":{"type":"structure","members":{}}},"subscribe":{"name":"Subscribe","input":{"type":"structure","members":{"TopicArn":{"required":true},"Protocol":{"required":true},"Endpoint":{}}},"output":{"type":"structure","members":{"SubscriptionArn":{}}}},"unsubscribe":{"name":"Unsubscribe","input":{"type":"structure","members":{"SubscriptionArn":{"required":true}}},"output":{"type":"structure","members":{}}}},"pagination":{"listSubscriptions":{"inputToken":"NextToken","outputToken":"NextToken","resultKey":"Subscriptions"},"listSubscriptionsByTopic":{"inputToken":"NextToken","outputToken":"NextToken","resultKey":"Subscriptions"},"listTopics":{"inputToken":"NextToken","outputToken":"NextToken","resultKey":"Topics"}}}); | |
AWS.Service.defineServiceApi(require("./services/sts"), "2011-06-15", {"format":"query","apiVersion":"2011-06-15","endpointPrefix":"sts","globalEndpoint":"sts.amazonaws.com","resultWrapped":true,"serviceAbbreviation":"AWS STS","serviceFullName":"AWS Security Token Service","signatureVersion":"v4","timestampFormat":"iso8601","operations":{"assumeRole":{"name":"AssumeRole","input":{"type":"structure","members":{"RoleArn":{"required":true},"RoleSessionName":{"required":true},"Policy":{},"DurationSeconds":{"type":"integer"},"ExternalId":{}}},"output":{"type":"structure","members":{"Credentials":{"type":"structure","members":{"AccessKeyId":{},"SecretAccessKey":{},"SessionToken":{},"Expiration":{"type":"timestamp"}}},"AssumedRoleUser":{"type":"structure","members":{"AssumedRoleId":{},"Arn":{}}},"PackedPolicySize":{"type":"integer"}}}},"assumeRoleWithSAML":{"name":"AssumeRoleWithSAML","input":{"type":"structure","members":{"RoleArn":{"required":true},"PrincipalArn":{"required":true},"SAMLAssertion":{"required":true},"Policy":{},"DurationSeconds":{"type":"integer"}}},"output":{"type":"structure","members":{"Credentials":{"type":"structure","members":{"AccessKeyId":{},"SecretAccessKey":{},"SessionToken":{},"Expiration":{"type":"timestamp"}}},"AssumedRoleUser":{"type":"structure","members":{"AssumedRoleId":{},"Arn":{}}},"PackedPolicySize":{"type":"integer"}}}},"assumeRoleWithWebIdentity":{"name":"AssumeRoleWithWebIdentity","input":{"type":"structure","members":{"RoleArn":{"required":true},"RoleSessionName":{"required":true},"WebIdentityToken":{"required":true},"ProviderId":{},"Policy":{},"DurationSeconds":{"type":"integer"}}},"output":{"type":"structure","members":{"Credentials":{"type":"structure","members":{"AccessKeyId":{},"SecretAccessKey":{},"SessionToken":{},"Expiration":{"type":"timestamp"}}},"SubjectFromWebIdentityToken":{},"AssumedRoleUser":{"type":"structure","members":{"AssumedRoleId":{},"Arn":{}}},"PackedPolicySize":{"type":"integer"}}}},"decodeAuthorizationMessage":{"name":"DecodeAuthorizationMessage","input":{"type":"structure","members":{"EncodedMessage":{"required":true}}},"output":{"type":"structure","members":{"DecodedMessage":{}}}},"getFederationToken":{"name":"GetFederationToken","input":{"type":"structure","members":{"Name":{"required":true},"Policy":{},"DurationSeconds":{"type":"integer"}}},"output":{"type":"structure","members":{"Credentials":{"type":"structure","members":{"AccessKeyId":{},"SecretAccessKey":{},"SessionToken":{},"Expiration":{"type":"timestamp"}}},"FederatedUser":{"type":"structure","members":{"FederatedUserId":{},"Arn":{}}},"PackedPolicySize":{"type":"integer"}}}},"getSessionToken":{"name":"GetSessionToken","input":{"type":"structure","members":{"DurationSeconds":{"type":"integer"},"SerialNumber":{},"TokenCode":{}}},"output":{"type":"structure","members":{"Credentials":{"type":"structure","members":{"AccessKeyId":{},"SecretAccessKey":{},"SessionToken":{},"Expiration":{"type":"timestamp"}}}}}}}}); | |
},{"./core":33,"./services/dynamodb":53,"./services/s3":54,"./services/sns":55,"./services/sqs":56,"./services/sts":57}],53:[function(require,module,exports){ | |
var AWS = require('../core'); | |
AWS.DynamoDB = AWS.Service.defineService('dynamodb', ['2012-08-10', '2011-12-05'], { | |
setupRequestListeners: function setupRequestListeners(request) { | |
if (request.service.config.dynamoDbCrc32) { | |
request.addListener('extractData', this.checkCrc32); | |
} | |
}, | |
checkCrc32: function checkCrc32(resp) { | |
if (!resp.request.service.crc32IsValid(resp)) { | |
resp.error = AWS.util.error(new Error(), { | |
code: 'CRC32CheckFailed', | |
message: 'CRC32 integrity check failed', | |
retryable: true | |
}); | |
} | |
}, | |
crc32IsValid: 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); | |
}, | |
defaultRetryCount: 10, | |
retryDelays: function retryDelays() { | |
var retryCount = this.numRetries(); | |
var delays = []; | |
for (var i = 0; i < retryCount; ++i) { | |
if (i === 0) { | |
delays.push(0); | |
} else { | |
delays.push(50 * Math.pow(2, i - 1)); | |
} | |
} | |
return delays; | |
} | |
}); | |
module.exports = AWS.DynamoDB; | |
},{"../core":33}],54:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var Buffer = require('buffer').Buffer; | |
AWS.S3 = AWS.Service.defineService('s3', ['2006-03-01'], { | |
initialize: function initialize(options) { | |
AWS.Service.prototype.initialize.call(this, options); | |
this.setEndpoint((options || {}).endpoint, options); | |
}, | |
setupRequestListeners: function setupRequestListeners(request) { | |
request.addListener('build', this.addContentType); | |
request.addListener('build', this.populateURI); | |
request.addListener('build', this.computeContentMd5); | |
request.addListener('build', this.computeSha256); | |
request.removeListener('validate', | |
AWS.EventListeners.Core.VALIDATE_REGION); | |
request.addListener('extractError', this.extractError); | |
request.addListener('extractData', this.extractData); | |
}, | |
populateURI: function populateURI(req) { | |
var httpRequest = req.httpRequest; | |
var b = req.params.Bucket; | |
if (b) { | |
if (!req.service.pathStyleBucketName(b)) { | |
httpRequest.endpoint.host = httpRequest.endpoint.hostname = b + '.' + | |
httpRequest.endpoint.hostname; | |
httpRequest.virtualHostedBucket = b; // needed for signing the request | |
httpRequest.path = httpRequest.path.replace(new RegExp('^/' + b), ''); | |
if (httpRequest.path[0] !== '/') { | |
httpRequest.path = '/' + httpRequest.path; | |
} | |
} | |
} | |
}, | |
addContentType: function addContentType(req) { | |
var httpRequest = req.httpRequest; | |
if (!httpRequest.headers['Content-Type']) { // always have a Content-Type | |
httpRequest.headers['Content-Type'] = 'application/octet-stream'; | |
} | |
if (AWS.util.isBrowser() && navigator.userAgent.match(/Firefox/)) { | |
if (!httpRequest.headers['Content-Type'].match(/;/)) { | |
var charset = '; charset=UTF-8'; | |
httpRequest.headers['Content-Type'] += charset; | |
} | |
} | |
}, | |
computableChecksumOperations: { | |
putBucketCors: true, | |
putBucketLifecycle: true, | |
putBucketTagging: true, | |
deleteObjects: true | |
}, | |
willComputeChecksums: function willComputeChecksums(req) { | |
if (this.computableChecksumOperations[req.operation]) return true; | |
if (!this.config.computeChecksums) return false; | |
if (!Buffer.isBuffer(req.httpRequest.body) && | |
typeof req.httpRequest.body !== 'string') { | |
return false; | |
} | |
var rules = req.service.api.operations[req.operation].input.members; | |
if (req.service.getSignerClass(req) === AWS.Signers.V4) { | |
if (rules.ContentMD5 && !rules.ContentMD5.required) return false; | |
} | |
if (rules.ContentMD5 && !req.params.ContentMD5) return true; | |
}, | |
computeContentMd5: function computeContentMd5(req) { | |
if (req.service.willComputeChecksums(req)) { | |
var md5 = AWS.util.crypto.md5(req.httpRequest.body, 'base64'); | |
req.httpRequest.headers['Content-MD5'] = md5; | |
} | |
}, | |
computeSha256: function computeSha256(req) { | |
if (req.service.getSignerClass(req) === AWS.Signers.V4) { | |
req.httpRequest.headers['X-Amz-Content-Sha256'] = | |
AWS.util.crypto.sha256(req.httpRequest.body || '', 'hex'); | |
} | |
}, | |
pathStyleBucketName: function pathStyleBucketName(bucketName) { | |
if (this.config.s3ForcePathStyle) return true; | |
if (this.dnsCompatibleBucketName(bucketName)) { | |
return (this.config.sslEnabled && bucketName.match(/\./)) ? true : false; | |
} else { | |
return true; // not dns compatible names must always use path style | |
} | |
}, | |
dnsCompatibleBucketName: 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; | |
}, | |
escapePathParam: function escapePathParam(value) { | |
return AWS.util.uriEscapePath(String(value)); | |
}, | |
successfulResponse: function successfulResponse(resp) { | |
var req = resp.request; | |
var httpResponse = resp.httpResponse; | |
if (req.operation === 'completeMultipartUpload' && | |
httpResponse.body.toString().match('<Error>')) | |
return false; | |
else | |
return httpResponse.statusCode < 300; | |
}, | |
retryableError: function retryableError(error, request) { | |
if (request.operation == 'completeMultipartUpload' && | |
error.statusCode === 200) { | |
return true; | |
} else { | |
var _super = AWS.Service.prototype.retryableError; | |
return _super.call(this, error, request); | |
} | |
}, | |
extractData: function extractData(resp) { | |
var req = resp.request; | |
if (req.operation === 'getBucketLocation') { | |
var match = resp.httpResponse.body.toString().match(/>(.+)<\/Location/); | |
if (match) { | |
delete resp.data['_']; | |
resp.data.LocationConstraint = match[1]; | |
} | |
} | |
}, | |
extractError: function extractError(resp) { | |
var codes = { | |
304: 'NotModified', | |
403: 'Forbidden', | |
400: 'BadRequest', | |
404: 'NotFound' | |
}; | |
var code = resp.httpResponse.statusCode; | |
var body = resp.httpResponse.body; | |
if (codes[code] && body.length === 0) { | |
resp.error = AWS.util.error(new Error(), { | |
code: codes[resp.httpResponse.statusCode], | |
message: null | |
}); | |
} else { | |
var data = new AWS.XML.Parser({}).parse(body.toString()); | |
resp.error = AWS.util.error(new Error(), { | |
code: data.Code || code, | |
message: data.Message || null | |
}); | |
} | |
}, | |
setEndpoint: function setEndpoint(endpoint) { | |
if (endpoint) { | |
this.endpoint = new AWS.Endpoint(endpoint, this.config); | |
} else if (this.config.region && this.config.region !== 'us-east-1') { | |
var sep = '-'; | |
if (this.isRegionV4()) sep = '.'; | |
var hostname = 's3' + sep + this.config.region + this.endpointSuffix(); | |
this.endpoint = new AWS.Endpoint(hostname); | |
} else { | |
this.endpoint = new AWS.Endpoint(this.api.globalEndpoint, this.config); | |
} | |
}, | |
getSignedUrl: function getSignedUrl(operation, params, callback) { | |
var expires = params.Expires || 900; | |
delete params.Expires; // we can't validate this | |
var url = require('url'); | |
var events = ['validate', 'build', 'sign']; | |
var request = this.makeRequest(operation, params); | |
var expiresHeader = 'presigned-expires'; | |
function signedUrlBuilder() { | |
delete request.httpRequest.headers['User-Agent']; | |
delete request.httpRequest.headers['X-Amz-User-Agent']; | |
request.httpRequest.headers[expiresHeader] = parseInt( | |
AWS.util.date.unixTimestamp() + expires, 10).toString(); | |
} | |
function signedUrlSigner() { | |
var queryParams = {}; | |
AWS.util.each(request.httpRequest.headers, function (key, value) { | |
if (key === expiresHeader) key = 'Expires'; | |
queryParams[key] = value; | |
}); | |
delete request.httpRequest.headers[expiresHeader]; | |
var auth = queryParams['Authorization'].split(':'); | |
delete queryParams['Authorization']; | |
delete queryParams['Host']; | |
queryParams['AWSAccessKeyId'] = auth[0].split(' ')[1]; | |
queryParams['Signature'] = auth[1]; | |
var endpoint = request.httpRequest.endpoint; | |
var parsedUrl = url.parse(request.httpRequest.path); | |
var querystring = AWS.util.queryParamsToString(queryParams); | |
endpoint.pathname = parsedUrl.pathname; | |
endpoint.search = !parsedUrl.search ? querystring : | |
parsedUrl.search + '&' + querystring; | |
} | |
request.on('build', signedUrlBuilder); | |
request.on('sign', signedUrlSigner); | |
request.removeListener('build', this.addContentType); | |
if (!params.Body) { // no Content-MD5 signing if body is not provided | |
request.removeListener('build', this.computeContentMd5); | |
} | |
if (callback) { | |
request.emitEvents(events, new AWS.Response(request), function (err) { | |
if (err) callback(err, null); | |
else callback(null, url.format(request.httpRequest.endpoint)); | |
}); | |
} else { | |
AWS.util.arrayEach(events, function (item) { | |
request.emitEvent(item, [request]); | |
}); | |
return url.format(request.httpRequest.endpoint); | |
} | |
} | |
}); | |
AWS.S3.prototype.createBucket = function createBucket(params, callback) { | |
if (!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); | |
}; | |
module.exports = AWS.S3; | |
},{"../core":33,"buffer":12,"url":27}],55:[function(require,module,exports){ | |
var AWS = require('../core'); | |
AWS.SNS = AWS.Service.defineService('sns', ['2010-03-31']); | |
module.exports = AWS.SNS; | |
},{"../core":33}],56:[function(require,module,exports){ | |
var AWS = require('../core'); | |
AWS.SQS = AWS.Service.defineService('sqs', ['2012-11-05'], { | |
setupRequestListeners: 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); | |
} | |
} | |
}, | |
verifySendMessageChecksum: 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); | |
} | |
}, | |
verifySendMessageBatchChecksum: 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(', ')); | |
} | |
}, | |
verifyReceiveMessageChecksum: 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(', ')); | |
} | |
}, | |
throwInvalidChecksumError: 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 | |
}); | |
}, | |
isChecksumValid: function isChecksumValid(checksum, data) { | |
return this.calculateChecksum(data) === checksum; | |
}, | |
calculateChecksum: function calculateChecksum(data) { | |
return AWS.util.crypto.md5(data, 'hex'); | |
}, | |
buildEndpoint: function buildEndpoint(request) { | |
var url = request.httpRequest.params.QueueUrl; | |
if (url) { | |
request.httpRequest.endpoint = new AWS.Endpoint(url); | |
var matches = request.httpRequest.endpoint.host.match(/^sqs\.(.+?)\./); | |
if (matches) request.httpRequest.region = matches[1]; | |
} | |
} | |
}); | |
module.exports = AWS.SQS; | |
},{"../core":33}],57:[function(require,module,exports){ | |
var AWS = require('../core'); | |
AWS.STS = AWS.Service.defineService('sts', ['2011-06-15'], { | |
credentialsFrom: 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; | |
} | |
}); | |
AWS.STS.prototype.assumeRoleWithWebIdentity = function assumeRoleWithWebIdentity(params, callback) { | |
return this.makeUnauthenticatedRequest('assumeRoleWithWebIdentity', params, callback); | |
}; | |
AWS.STS.prototype.assumeRoleWithSAML = function assumeRoleWithSAML(params, callback) { | |
return this.makeUnauthenticatedRequest('assumeRoleWithSAML', params, callback); | |
}; | |
module.exports = AWS.STS; | |
},{"../core":33}],58:[function(require,module,exports){ | |
var AWS = require('../core'); | |
require('./v3'); | |
var inherit = AWS.util.inherit; | |
AWS.Signers.CloudFront = inherit(AWS.Signers.S3, { | |
stringToSign: function stringToSign() { | |
return this.request.headers['X-Amz-Date']; | |
} | |
}); | |
module.exports = AWS.Signers.CloudFront; | |
},{"../core":33,"./v3":62}],59:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var inherit = AWS.util.inherit; | |
AWS.Signers.RequestSigner = inherit({ | |
constructor: function RequestSigner(request) { | |
this.request = request; | |
} | |
}); | |
AWS.Signers.RequestSigner.getVersion = 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; | |
case 'cloudfront': return AWS.Signers.CloudFront; | |
} | |
throw new Error('Unknown signing version ' + version); | |
}; | |
require('./v2'); | |
require('./v3'); | |
require('./v3https'); | |
require('./v4'); | |
require('./s3'); | |
require('./cloudfront'); | |
},{"../core":33,"./cloudfront":58,"./s3":60,"./v2":61,"./v3":62,"./v3https":63,"./v4":64}],60:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var inherit = AWS.util.inherit; | |
AWS.Signers.S3 = inherit(AWS.Signers.RequestSigner, { | |
subResources: { | |
'acl': 1, | |
'cors': 1, | |
'lifecycle': 1, | |
'delete': 1, | |
'location': 1, | |
'logging': 1, | |
'notification': 1, | |
'partNumber': 1, | |
'policy': 1, | |
'requestPayment': 1, | |
'restore': 1, | |
'tagging': 1, | |
'torrent': 1, | |
'uploadId': 1, | |
'uploads': 1, | |
'versionId': 1, | |
'versioning': 1, | |
'versions': 1, | |
'website': 1 | |
}, | |
responseHeaders: { | |
'response-content-type': 1, | |
'response-content-language': 1, | |
'response-expires': 1, | |
'response-cache-control': 1, | |
'response-content-disposition': 1, | |
'response-content-encoding': 1 | |
}, | |
addAuthorization: function addAuthorization(credentials, date) { | |
if (!this.request.headers['presigned-expires']) { | |
this.request.headers['X-Amz-Date'] = AWS.util.date.rfc822(date); | |
} | |
if (credentials.sessionToken) { | |
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; | |
}, | |
stringToSign: function stringToSign() { | |
var r = this.request; | |
var parts = []; | |
parts.push(r.method); | |
parts.push(r.headers['Content-MD5'] || ''); | |
parts.push(r.headers['Content-Type'] || ''); | |
parts.push(r.headers['presigned-expires'] || ''); | |
var headers = this.canonicalizedAmzHeaders(); | |
if (headers) parts.push(headers); | |
parts.push(this.canonicalizedResource()); | |
return parts.join('\n'); | |
}, | |
canonicalizedAmzHeaders: 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'); | |
}, | |
canonicalizedResource: 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) { | |
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 resource = { name: name }; | |
if (value !== undefined) { | |
if (this.subResources[name]) { | |
resource.value = value; | |
} else { | |
resource.value = decodeURIComponent(value); | |
} | |
} | |
resources.push(resource); | |
} | |
}); | |
resources.sort(function (a, b) { return a.name < b.name ? -1 : 1; }); | |
if (resources.length) { | |
querystring = []; | |
AWS.util.arrayEach(resources, function (resource) { | |
if (resource.value === undefined) | |
querystring.push(resource.name); | |
else | |
querystring.push(resource.name + '=' + resource.value); | |
}); | |
resource += '?' + querystring.join('&'); | |
} | |
} | |
return resource; | |
}, | |
sign: function sign(secret, string) { | |
return AWS.util.crypto.hmac(secret, string, 'base64', 'sha1'); | |
} | |
}); | |
module.exports = AWS.Signers.S3; | |
},{"../core":33}],61:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var inherit = AWS.util.inherit; | |
AWS.Signers.V2 = inherit(AWS.Signers.RequestSigner, { | |
addAuthorization: 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; | |
}, | |
signature: function signature(credentials) { | |
return AWS.util.crypto.hmac(credentials.secretAccessKey, this.stringToSign(), 'base64'); | |
}, | |
stringToSign: 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'); | |
} | |
}); | |
module.exports = AWS.Signers.V2; | |
},{"../core":33}],62:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var inherit = AWS.util.inherit; | |
AWS.Signers.V3 = inherit(AWS.Signers.RequestSigner, { | |
addAuthorization: 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); | |
}, | |
authorization: function authorization(credentials) { | |
return 'AWS3 ' + | |
'AWSAccessKeyId=' + credentials.accessKeyId + ',' + | |
'Algorithm=HmacSHA256,' + | |
'SignedHeaders=' + this.signedHeaders() + ',' + | |
'Signature=' + this.signature(credentials); | |
}, | |
signedHeaders: function signedHeaders() { | |
var headers = []; | |
AWS.util.arrayEach(this.headersToSign(), function iterator(h) { | |
headers.push(h.toLowerCase()); | |
}); | |
return headers.sort().join(';'); | |
}, | |
canonicalHeaders: 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'; | |
}, | |
headersToSign: 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; | |
}, | |
signature: function signature(credentials) { | |
return AWS.util.crypto.hmac(credentials.secretAccessKey, this.stringToSign(), 'base64'); | |
}, | |
stringToSign: 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')); | |
} | |
}); | |
module.exports = AWS.Signers.V3; | |
},{"../core":33}],63:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var inherit = AWS.util.inherit; | |
require('./v3'); | |
AWS.Signers.V3Https = inherit(AWS.Signers.V3, { | |
authorization: function authorization(credentials) { | |
return 'AWS3-HTTPS ' + | |
'AWSAccessKeyId=' + credentials.accessKeyId + ',' + | |
'Algorithm=HmacSHA256,' + | |
'Signature=' + this.signature(credentials); | |
}, | |
stringToSign: function stringToSign() { | |
return this.request.headers['X-Amz-Date']; | |
} | |
}); | |
module.exports = AWS.Signers.V3Https; | |
},{"../core":33,"./v3":62}],64:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var inherit = AWS.util.inherit; | |
var cachedSecret = {}; | |
AWS.Signers.V4 = inherit(AWS.Signers.RequestSigner, { | |
constructor: function V4(request, serviceName) { | |
AWS.Signers.RequestSigner.call(this, request); | |
this.serviceName = serviceName; | |
}, | |
addAuthorization: function addAuthorization(credentials, date) { | |
var datetime = AWS.util.date.iso8601(date).replace(/[:\-]|\.\d{3}/g, ''); | |
this.addHeaders(credentials, datetime); | |
this.updateBody(credentials); | |
this.request.headers['Authorization'] = | |
this.authorization(credentials, datetime); | |
}, | |
addHeaders: function addHeaders(credentials, datetime) { | |
this.request.headers['X-Amz-Date'] = datetime; | |
if (credentials.sessionToken) { | |
this.request.headers['x-amz-security-token'] = credentials.sessionToken; | |
} | |
}, | |
updateBody: function updateBody(credentials) { | |
if (this.request.params) { | |
this.request.params.AWSAccessKeyId = credentials.accessKeyId; | |
if (credentials.sessionToken) { | |
this.request.params.SecurityToken = credentials.sessionToken; | |
} | |
this.request.body = AWS.util.queryParamsToString(this.request.params); | |
this.request.headers['Content-Length'] = this.request.body.length; | |
} | |
}, | |
authorization: function authorization(credentials, datetime) { | |
var parts = []; | |
var credString = this.credentialString(datetime); | |
parts.push('AWS4-HMAC-SHA256 Credential=' + | |
credentials.accessKeyId + '/' + credString); | |
parts.push('SignedHeaders=' + this.signedHeaders()); | |
parts.push('Signature=' + this.signature(credentials, datetime)); | |
return parts.join(', '); | |
}, | |
signature: function signature(credentials, datetime) { | |
var cache = cachedSecret[this.serviceName]; | |
var date = datetime.substr(0, 8); | |
if (!cache || | |
cache.akid !== credentials.accessKeyId || | |
cache.region !== this.request.region || | |
cache.date !== date) { | |
var kSecret = credentials.secretAccessKey; | |
var kDate = AWS.util.crypto.hmac('AWS4' + kSecret, date, 'buffer'); | |
var kRegion = AWS.util.crypto.hmac(kDate, this.request.region, 'buffer'); | |
var kService = AWS.util.crypto.hmac(kRegion, this.serviceName, 'buffer'); | |
var kCredentials = AWS.util.crypto.hmac(kService, 'aws4_request', 'buffer'); | |
cachedSecret[this.serviceName] = { | |
region: this.request.region, date: date, | |
key: kCredentials, akid: credentials.accessKeyId | |
}; | |
} | |
var key = cachedSecret[this.serviceName].key; | |
return AWS.util.crypto.hmac(key, this.stringToSign(datetime), 'hex'); | |
}, | |
stringToSign: 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'); | |
}, | |
canonicalString: function canonicalString() { | |
var parts = []; | |
parts.push(this.request.method); | |
parts.push(this.request.pathname()); | |
parts.push(this.request.search()); | |
parts.push(this.canonicalHeaders() + '\n'); | |
parts.push(this.signedHeaders()); | |
parts.push(this.hexEncodedBodyHash()); | |
return parts.join('\n'); | |
}, | |
canonicalHeaders: 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'); | |
}, | |
canonicalHeaderValues: function canonicalHeaderValues(values) { | |
return values.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, ''); | |
}, | |
signedHeaders: 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(';'); | |
}, | |
credentialString: function credentialString(datetime) { | |
var parts = []; | |
parts.push(datetime.substr(0, 8)); | |
parts.push(this.request.region); | |
parts.push(this.serviceName); | |
parts.push('aws4_request'); | |
return parts.join('/'); | |
}, | |
hexEncodedHash: function hash(string) { | |
return AWS.util.crypto.sha256(string, 'hex'); | |
}, | |
hexEncodedBodyHash: function hexEncodedBodyHash() { | |
if (this.request.headers['X-Amz-Content-Sha256']) { | |
return this.request.headers['X-Amz-Content-Sha256']; | |
} else { | |
return this.hexEncodedHash(this.request.body || ''); | |
} | |
}, | |
unsignableHeaders: ['authorization', 'content-type', 'user-agent', | |
'x-amz-user-agent', 'x-amz-content-sha256'], | |
isSignableHeader: function isSignableHeader(key) { | |
return this.unsignableHeaders.indexOf(key) < 0; | |
} | |
}); | |
module.exports = AWS.Signers.V4; | |
},{"../core":33}],65:[function(require,module,exports){ | |
var process=require("__browserify_process");/*global escape:true */ | |
var AWS = require('./core'); | |
var cryptoLib = require('crypto'); | |
var Buffer = require('buffer').Buffer; | |
AWS.util = { | |
engine: function engine() { | |
if (AWS.util.isBrowser() && typeof navigator !== 'undefined') { | |
return navigator.userAgent; | |
} else { | |
return process.platform + '/' + process.version; | |
} | |
}, | |
userAgent: function userAgent() { | |
var name = AWS.util.isBrowser() ? 'js' : 'nodejs'; | |
var agent = 'aws-sdk-' + name + '/' + AWS.VERSION; | |
if (name === 'nodejs') agent += ' ' + AWS.util.engine(); | |
return agent; | |
}, | |
isBrowser: function isBrowser() { return typeof window !== 'undefined'; }, | |
isNode: function isNode() { return !AWS.util.isBrowser(); }, | |
uriEscape: function uriEscape(string) { | |
var output = encodeURIComponent(string); | |
output = output.replace(/[^A-Za-z0-9_.~\-%]+/g, escape); | |
output = output.replace(/[*]/g, function(ch) { | |
return '%' + ch.charCodeAt(0).toString(16).toUpperCase(); | |
}); | |
return output; | |
}, | |
uriEscapePath: function uriEscapePath(string) { | |
var parts = []; | |
AWS.util.arrayEach(string.split('/'), function (part) { | |
parts.push(AWS.util.uriEscape(part)); | |
}); | |
return parts.join('/'); | |
}, | |
urlParse: function urlParse(url) { | |
return require('url').parse(url); | |
}, | |
queryParamsToString: function queryParamsToString(params) { | |
var items = []; | |
var escape = AWS.util.uriEscape; | |
var sortedKeys = Object.keys(params).sort(); | |
AWS.util.arrayEach(sortedKeys, function(name) { | |
var value = params[name]; | |
var ename = escape(name); | |
var result = ename; | |
if (Array.isArray(value)) { | |
var vals = []; | |
AWS.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('&'); | |
}, | |
readFileSync: function readFileSync(path) { | |
if (typeof window !== 'undefined') return null; | |
return require('fs').readFileSync(path, 'utf-8'); | |
}, | |
base64: { | |
encode: function encode64(string) { | |
return new Buffer(string).toString('base64'); | |
}, | |
decode: function decode64(string) { | |
return new Buffer(string, 'base64').toString(); | |
} | |
}, | |
buffer: { | |
Buffer: Buffer, | |
concat: function(buffers) { | |
var length = 0, | |
offset = 0, | |
buffer = null, i; | |
for (i = 0; i < buffers.length; i++) { | |
length += buffers[i].length; | |
} | |
buffer = new Buffer(length); | |
for (i = 0; i < buffers.length; i++) { | |
buffers[i].copy(buffer, offset); | |
offset += buffers[i].length; | |
} | |
return buffer; | |
} | |
}, | |
string: { | |
byteLength: function byteLength(string) { | |
if (string === null || string === undefined) return 0; | |
if (typeof string === 'string') string = new 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 AWS.util.error(new Error('Cannot determine length of ' + string), | |
{ object: string }); | |
} | |
} | |
}, | |
jamespath: { | |
query: function query(expression, data) { | |
if (!data) return []; | |
var results = []; | |
var expressions = expression.split(/\s+or\s+/); | |
AWS.util.arrayEach.call(this, expressions, function (expr) { | |
var objects = [data]; | |
var tokens = expr.split('.'); | |
AWS.util.arrayEach.call(this, tokens, function (token) { | |
var match = token.match('^(.+?)(?:\\[(-?\\d+|\\*)\\])?$'); | |
var newObjects = []; | |
AWS.util.arrayEach.call(this, objects, function (obj) { | |
if (match[1] === '*') { | |
AWS.util.arrayEach.call(this, obj, function (value) { | |
newObjects.push(value); | |
}); | |
} else if (obj.hasOwnProperty(match[1])) { | |
newObjects.push(obj[match[1]]); | |
} | |
}); | |
objects = newObjects; | |
if (match[2]) { | |
newObjects = []; | |
AWS.util.arrayEach.call(this, objects, function (obj) { | |
if (Array.isArray(obj)) { | |
if (match[2] === '*') { | |
newObjects = newObjects.concat(obj); | |
} else { | |
var idx = parseInt(match[2], 10); | |
if (idx < 0) idx = obj.length + idx; // negative indexing | |
newObjects.push(obj[idx]); | |
} | |
} | |
}); | |
objects = newObjects; | |
} | |
if (objects.length === 0) return AWS.util.abort; | |
}); | |
if (objects.length > 0) { | |
results = objects; | |
return AWS.util.abort; | |
} | |
}); | |
return results; | |
}, | |
find: function find(expression, data) { | |
return AWS.util.jamespath.query(expression, data)[0]; | |
} | |
}, | |
date: { | |
getDate: function getDate() { return new Date(); }, | |
iso8601: function iso8601(date) { | |
if (date === undefined) { date = AWS.util.date.getDate(); } | |
return date.toISOString(); | |
}, | |
rfc822: function rfc822(date) { | |
if (date === undefined) { date = AWS.util.date.getDate(); } | |
return date.toUTCString(); | |
}, | |
unixTimestamp: function unixTimestamp(date) { | |
if (date === undefined) { date = AWS.util.date.getDate(); } | |
return date.getTime() / 1000; | |
}, | |
from: function format(date) { | |
if (typeof date === 'number') { | |
return new Date(date * 1000); // unix timestamp | |
} else { | |
return new Date(date); | |
} | |
}, | |
format: function format(date, formatter) { | |
if (!formatter) formatter = 'iso8601'; | |
return AWS.util.date[formatter](AWS.util.date.from(date)); | |
} | |
}, | |
crypto: { | |
crc32Table: [ | |
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, | |
0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, | |
0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, | |
0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, | |
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, | |
0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, | |
0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, | |
0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, | |
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, | |
0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, | |
0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, | |
0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, | |
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, | |
0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, | |
0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, | |
0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, | |
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, | |
0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, | |
0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, | |
0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, | |
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, | |
0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, | |
0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, | |
0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, | |
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, | |
0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, | |
0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, | |
0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, | |
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, | |
0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, | |
0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, | |
0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, | |
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, | |
0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, | |
0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, | |
0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, | |
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, | |
0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, | |
0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, | |
0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, | |
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, | |
0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, | |
0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, | |
0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, | |
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, | |
0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, | |
0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, | |
0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, | |
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, | |
0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, | |
0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, | |
0x2D02EF8D], | |
crc32: function crc32(data) { | |
var tbl = AWS.util.crypto.crc32Table; | |
var crc = 0 ^ -1; | |
if (typeof data === 'string') { | |
data = new 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; | |
}, | |
hmac: 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 Buffer(string); | |
return cryptoLib.createHmac(fn, key).update(string).digest(digest); | |
}, | |
md5: function md5(data, digest) { | |
if (!digest) { digest = 'binary'; } | |
if (digest === 'buffer') { digest = undefined; } | |
if (typeof data === 'string') data = new Buffer(data); | |
return AWS.util.crypto.createHash('md5').update(data).digest(digest); | |
}, | |
sha256: function sha256(string, digest) { | |
if (!digest) { digest = 'binary'; } | |
if (digest === 'buffer') { digest = undefined; } | |
if (typeof string === 'string') string = new Buffer(string); | |
return AWS.util.crypto.createHash('sha256').update(string).digest(digest); | |
}, | |
toHex: 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(''); | |
}, | |
createHash: function createHash(algorithm) { | |
return cryptoLib.createHash(algorithm); | |
} | |
}, | |
abort: {}, | |
each: function each(object, iterFunction) { | |
for (var key in object) { | |
if (object.hasOwnProperty(key)) { | |
var ret = iterFunction.call(this, key, object[key]); | |
if (ret === AWS.util.abort) break; | |
} | |
} | |
}, | |
arrayEach: function arrayEach(array, iterFunction) { | |
for (var idx in array) { | |
if (array.hasOwnProperty(idx)) { | |
var ret = iterFunction.call(this, array[idx], parseInt(idx, 10)); | |
if (ret === AWS.util.abort) break; | |
} | |
} | |
}, | |
update: function update(obj1, obj2) { | |
AWS.util.each(obj2, function iterator(key, item) { | |
obj1[key] = item; | |
}); | |
return obj1; | |
}, | |
merge: function merge(obj1, obj2) { | |
return AWS.util.update(AWS.util.copy(obj1), obj2); | |
}, | |
copy: function copy(object) { | |
if (object === null || object === undefined) return object; | |
var dupe = {}; | |
for (var key in object) { | |
dupe[key] = object[key]; | |
} | |
return dupe; | |
}, | |
isEmpty: function isEmpty(obj) { | |
for (var prop in obj) { | |
if (obj.hasOwnProperty(prop)) { | |
return false; | |
} | |
} | |
return true; | |
}, | |
isType: function isType(obj, type) { | |
if (typeof type === 'function') type = AWS.util.typeName(type); | |
return Object.prototype.toString.call(obj) === '[object ' + type + ']'; | |
}, | |
typeName: function typeName(type) { | |
if (type.hasOwnProperty('name')) return type.name; | |
var str = type.toString(); | |
var match = str.match(/^\s*function (.+)\(/); | |
return match ? match[1] : str; | |
}, | |
error: function error(err, options) { | |
var originalError = null; | |
if (typeof err.message === 'string' && err.message !== '') { | |
if (typeof options === 'string' || (options && options.message)) { | |
originalError = AWS.util.copy(err); | |
originalError.message = err.message; | |
} | |
} | |
err.message = err.message || null; | |
if (typeof options === 'string') { | |
err.message = options; | |
} else { | |
AWS.util.update(err, options); | |
} | |
if (typeof Object.defineProperty === 'function') { | |
Object.defineProperty(err, 'name', {writable: true, enumerable: false}); | |
Object.defineProperty(err, 'message', {enumerable: true}); | |
} | |
err.name = err.name || err.code || 'Error'; | |
err.time = new Date(); | |
if (originalError) err.originalError = originalError; | |
return err; | |
}, | |
inherit: function inherit(klass, features) { | |
var newObject = null; | |
if (features === undefined) { | |
features = klass; | |
klass = Object; | |
newObject = {}; | |
} else { | |
var ctor = function __ctor_wrapper__() {}; | |
ctor.prototype = klass.prototype; | |
newObject = new ctor(); | |
} | |
if (features.constructor === Object) { | |
features.constructor = function() { | |
if (klass !== Object) { | |
return klass.apply(this, arguments); | |
} | |
}; | |
} | |
features.constructor.prototype = newObject; | |
AWS.util.update(features.constructor.prototype, features); | |
features.constructor.__super__ = klass; | |
return features.constructor; | |
}, | |
mixin: function mixin() { | |
var klass = arguments[0]; | |
for (var i = 1; i < arguments.length; i++) { | |
for (var prop in arguments[i].prototype) { | |
var fn = arguments[i].prototype[prop]; | |
if (prop != 'constructor') { | |
klass.prototype[prop] = fn; | |
} | |
} | |
} | |
return klass; | |
}, | |
hideProperties: function hideProperties(obj, props) { | |
if (typeof Object.defineProperty !== 'function') return; | |
AWS.util.arrayEach(props, function (key) { | |
Object.defineProperty(obj, key, { | |
enumerable: false, writable: true, configurable: true }); | |
}); | |
} | |
}; | |
module.exports = AWS.util; | |
},{"./core":33,"__browserify_process":11,"buffer":12,"crypto":3,"fs":1,"url":27}],66:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var builder = require('xmlbuilder'); | |
var inherit = AWS.util.inherit; | |
AWS.XML.Builder = inherit({ | |
constructor: function XMLBuilder(root, rules, options) { | |
this.root = root; | |
this.rules = rules; | |
this.xmlns = options.xmlnamespace; | |
this.timestampFormat = options.timestampFormat; | |
}, | |
toXML: function toXML(params) { | |
var xml = builder.create(this.root); | |
if (this.xmlns) xml.att('xmlns', this.xmlns); | |
this.serializeStructure(this.rules, params, xml); | |
return xml.root().toString(); | |
}, | |
serializeStructure: function serializeStructure(rules, params, xml) { | |
AWS.util.each.call(this, rules || {}, function (memberName, memberRules) { | |
var value = params[memberName]; | |
if (value !== undefined) { | |
if (memberRules.attribute) { | |
xml.att(memberRules.name, value); | |
} else { | |
this.serializeMember(memberName, memberRules, value, xml); | |
} | |
} | |
}); | |
}, | |
serializeList: function serializeList(name, rules, list, xml) { | |
if (rules.flattened) { | |
AWS.util.arrayEach.call(this, list, function (value) { | |
this.serializeMember(rules.name || name, rules.members, value, xml); | |
}); | |
} else { | |
xml = xml.ele(rules.name || name); | |
AWS.util.arrayEach.call(this, list, function (value) { | |
var memberName = rules.members.name || 'member'; | |
this.serializeMember(memberName, rules.members, value, xml); | |
}); | |
} | |
}, | |
serializeMember: function serializeMember(memberName, rules, params, xml) { | |
var name = memberName; | |
if (rules.type === 'structure') { | |
xml = xml.ele(name); | |
this.serializeStructure(rules.members, params, xml); | |
} else if (rules.type === 'list') { | |
this.serializeList(name, rules, params, xml); | |
} else if (rules.type === 'timestamp') { | |
var timestampFormat = rules.format || this.timestampFormat; | |
var date = AWS.util.date.format(params, timestampFormat); | |
xml = xml.ele(name, String(date)); | |
} else { | |
xml = xml.ele(name, String(params)); | |
} | |
this.applyNamespaces(xml, rules); | |
}, | |
applyNamespaces: function applyNamespaces(xml, rules) { | |
if (rules.xmlns) { | |
var attr = 'xmlns'; | |
if (rules.xmlns.prefix) attr += ':' + rules.xmlns.prefix; | |
xml.att(attr, rules.xmlns.uri); | |
} | |
} | |
}); | |
},{"../core":33,"xmlbuilder":72}],67:[function(require,module,exports){ | |
var AWS = require('../core'); | |
var inherit = AWS.util.inherit; | |
var xml2js = require('xml2js'); | |
AWS.XML.Parser = inherit({ | |
constructor: function XMLParser(rules) { | |
this.rules = (rules || {}).members || {}; | |
}, | |
options: { | |
explicitCharkey: false, // undocumented | |
trim: false, // trim the leading/trailing whitespace from text nodes | |
normalize: false, // trim interior whitespace inside text nodes | |
explicitRoot: false, // return the root node in the resulting object? | |
emptyTag: null, // the default value for empty nodes | |
explicitArray: true, // always put child nodes in an array | |
ignoreAttrs: false, // ignore attributes, only create text nodes | |
mergeAttrs: false, // merge attributes and child elements | |
validator: null // a callable validator | |
}, | |
parse: function parse(xml) { | |
var result = null; | |
var error = null; | |
var parser = new xml2js.Parser(this.options); | |
parser.parseString(xml, function (e, r) { | |
error = e; | |
result = r; | |
}); | |
if (result) { | |
delete result.xmlns; | |
return this.parseStructure(result, this.rules); | |
} else if (error) { | |
throw AWS.util.error(error, {code: 'XMLParserError'}); | |
} else { // empty xml document | |
return this.parseStructure({}, this.rules); | |
} | |
}, | |
parseStructure: function parseStructure(structure, rules) { | |
var data = {}; | |
AWS.util.each.call(this, rules, function(memberName, memberRules) { | |
if (memberRules.type == 'list') { | |
data[memberRules.name || memberName] = []; | |
} | |
}); | |
AWS.util.each.call(this, structure, function (xmlName, value) { | |
if (xmlName == '$') { | |
AWS.util.each.call(this, value, function (attrName, attrValue) { | |
if (rules[attrName]) { | |
var rule = rules[attrName]; | |
data[rule.name || xmlName] = this.parseMember([attrValue], rule); | |
} | |
}); | |
} else { | |
var rule = rules[xmlName] || {}; | |
data[rule.name || xmlName] = this.parseMember(value, rule); | |
} | |
}); | |
return data; | |
}, | |
parseMap: function parseMap(map, rules) { | |
var data = {}; | |
var keyRules = rules.keys || {}; | |
var valueRules = rules.members || {}; | |
var keyName = keyRules.name || 'key'; | |
var valueName = valueRules.name || 'value'; | |
if (!rules.flattened) { | |
map = map[0].entry; | |
} | |
AWS.util.arrayEach.call(this, map, function (entry) { | |
var value = this.parseMember(entry[valueName], valueRules); | |
data[entry[keyName][0]] = value; | |
}); | |
return data; | |
}, | |
parseList: function parseList(list, rules) { | |
var data = []; | |
var memberRules = rules.members || {}; | |
var memberName = memberRules.name || 'member'; | |
if (rules.flattened) { | |
AWS.util.arrayEach.call(this, list, function (value) { | |
data.push(this.parseMember([value], memberRules)); | |
}); | |
} else { | |
AWS.util.arrayEach.call(this, list, function (member) { | |
AWS.util.arrayEach.call(this, member[memberName], function (value) { | |
data.push(this.parseMember([value], memberRules)); | |
}); | |
}); | |
} | |
return data; | |
}, | |
parseMember: function parseMember(values, rules) { | |
if (values[0] === null) { | |
if (rules.type === 'structure') return {}; | |
if (rules.type === 'list') return []; | |
if (rules.type === 'map') return {}; | |
return null; | |
} | |
if (values[0]['$'] && values[0]['$'].encoding == 'base64') { | |
return AWS.util.base64.decode(values[0]['_']); | |
} | |
if (!rules.type) { | |
if (typeof values[0] === 'string') { | |
rules.type = 'string'; | |
} else if (values[0]['_']) { | |
rules.type = 'string'; | |
values = [values[0]['_']]; | |
} else { | |
rules.type = 'structure'; | |
} | |
} | |
if (rules.type === 'string') { | |
return values[0]; | |
} else if (rules.type === 'structure') { | |
return this.parseStructure(values[0], rules.members || {}); | |
} else if (rules.type === 'list') { | |
return this.parseList(values, rules); | |
} else if (rules.type === 'map') { | |
return this.parseMap(values, rules); | |
} else if (rules.type === 'integer') { | |
return parseInt(values[0], 10); | |
} else if (rules.type === 'float') { | |
return parseFloat(values[0]); | |
} else if (rules.type === 'timestamp') { | |
return this.parseTimestamp(values[0]); | |
} else if (rules.type === 'boolean') { | |
return values[0] === 'true'; | |
} else { | |
var msg = 'unhandled type: ' + rules.type; | |
throw AWS.util.error(new Error(msg), {code: 'XMLParserError'}); | |
} | |
}, | |
parseTimestamp: function parseTimestamp(value) { | |
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 AWS.util.error( | |
new Error('unhandled timestamp format: ' + value), | |
{code: 'TimestampParserError'}); | |
} | |
} | |
}); | |
},{"../core":33,"xml2js":68}],68:[function(require,module,exports){ | |
(function() { | |
var events, isEmpty, sax, | |
__hasProp = {}.hasOwnProperty, | |
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | |
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | |
sax = require('sax'); | |
events = require('events'); | |
isEmpty = function(thing) { | |
return typeof thing === "object" && (thing != null) && Object.keys(thing).length === 0; | |
}; | |
exports.defaults = { | |
"0.1": { | |
explicitCharkey: false, | |
trim: true, | |
normalize: true, | |
normalizeTags: false, | |
attrkey: "@", | |
charkey: "#", | |
explicitArray: false, | |
ignoreAttrs: false, | |
mergeAttrs: false, | |
explicitRoot: false, | |
validator: null, | |
xmlns: false | |
}, | |
"0.2": { | |
explicitCharkey: false, | |
trim: false, | |
normalize: false, | |
normalizeTags: false, | |
attrkey: "$", | |
charkey: "_", | |
explicitArray: true, | |
ignoreAttrs: false, | |
mergeAttrs: false, | |
explicitRoot: true, | |
validator: null, | |
xmlns: false | |
} | |
}; | |
exports.ValidationError = (function(_super) { | |
__extends(ValidationError, _super); | |
function ValidationError(message) { | |
this.message = message; | |
} | |
return ValidationError; | |
})(Error); | |
exports.Parser = (function(_super) { | |
__extends(Parser, _super); | |
function Parser(opts) { | |
this.parseString = __bind(this.parseString, this); | |
this.reset = __bind(this.reset, this); | |
var key, value, _ref; | |
this.options = {}; | |
_ref = exports.defaults["0.2"]; | |
for (key in _ref) { | |
if (!__hasProp.call(_ref, key)) continue; | |
value = _ref[key]; | |
this.options[key] = value; | |
} | |
for (key in opts) { | |
if (!__hasProp.call(opts, key)) continue; | |
value = opts[key]; | |
this.options[key] = value; | |
} | |
if (this.options.xmlns) { | |
this.options.xmlnskey = this.options.attrkey + "ns"; | |
} | |
this.reset(); | |
} | |
Parser.prototype.reset = function() { | |
var attrkey, charkey, err, stack, | |
_this = this; | |
this.removeAllListeners(); | |
this.saxParser = sax.parser(true, { | |
trim: false, | |
normalize: false, | |
xmlns: this.options.xmlns | |
}); | |
err = false; | |
this.saxParser.onerror = function(error) { | |
if (!err) { | |
err = true; | |
return _this.emit("error", error); | |
} | |
}; | |
this.EXPLICIT_CHARKEY = this.options.explicitCharkey; | |
this.resultObject = null; | |
stack = []; | |
attrkey = this.options.attrkey; | |
charkey = this.options.charkey; | |
this.saxParser.onopentag = function(node) { | |
var key, obj, _ref; | |
obj = {}; | |
obj[charkey] = ""; | |
if (!_this.options.ignoreAttrs) { | |
_ref = node.attributes; | |
for (key in _ref) { | |
if (!__hasProp.call(_ref, key)) continue; | |
if (!(attrkey in obj) && !_this.options.mergeAttrs) { | |
obj[attrkey] = {}; | |
} | |
if (_this.options.mergeAttrs) { | |
obj[key] = node.attributes[key]; | |
} else { | |
obj[attrkey][key] = node.attributes[key]; | |
} | |
} | |
} | |
obj["#name"] = _this.options.normalizeTags ? node.name.toLowerCase() : node.name; | |
if (_this.options.xmlns) { | |
obj[_this.options.xmlnskey] = { | |
uri: node.uri, | |
local: node.local | |
}; | |
} | |
return stack.push(obj); | |
}; | |
this.saxParser.onclosetag = function() { | |
var node, nodeName, obj, old, s, xpath; | |
obj = stack.pop(); | |
nodeName = obj["#name"]; | |
delete obj["#name"]; | |
s = stack[stack.length - 1]; | |
if (obj[charkey].match(/^\s*$/)) { | |
delete obj[charkey]; | |
} else { | |
if (_this.options.trim) { | |
obj[charkey] = obj[charkey].trim(); | |
} | |
if (_this.options.normalize) { | |
obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim(); | |
} | |
if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) { | |
obj = obj[charkey]; | |
} | |
} | |
if (_this.options.emptyTag !== void 0 && isEmpty(obj)) { | |
obj = _this.options.emptyTag; | |
} | |
if (_this.options.validator != null) { | |
xpath = "/" + ((function() { | |
var _i, _len, _results; | |
_results = []; | |
for (_i = 0, _len = stack.length; _i < _len; _i++) { | |
node = stack[_i]; | |
_results.push(node["#name"]); | |
} | |
return _results; | |
})()).concat(nodeName).join("/"); | |
obj = _this.options.validator(xpath, s && s[nodeName], obj); | |
} | |
if (stack.length > 0) { | |
if (!_this.options.explicitArray) { | |
if (!(nodeName in s)) { | |
return s[nodeName] = obj; | |
} else if (s[nodeName] instanceof Array) { | |
return s[nodeName].push(obj); | |
} else { | |
old = s[nodeName]; | |
s[nodeName] = [old]; | |
return s[nodeName].push(obj); | |
} | |
} else { | |
if (!(s[nodeName] instanceof Array)) { | |
s[nodeName] = []; | |
} | |
return s[nodeName].push(obj); | |
} | |
} else { | |
if (_this.options.explicitRoot) { | |
old = obj; | |
obj = {}; | |
obj[nodeName] = old; | |
} | |
_this.resultObject = obj; | |
return _this.emit("end", _this.resultObject); | |
} | |
}; | |
return this.saxParser.ontext = this.saxParser.oncdata = function(text) { | |
var s; | |
s = stack[stack.length - 1]; | |
if (s) { | |
return s[charkey] += text; | |
} | |
}; | |
}; | |
Parser.prototype.parseString = function(str, cb) { | |
if ((cb != null) && typeof cb === "function") { | |
this.on("end", function(result) { | |
this.reset(); | |
return cb(null, result); | |
}); | |
this.on("error", function(err) { | |
this.reset(); | |
return cb(err); | |
}); | |
} | |
if (str.toString().trim() === '') { | |
this.emit("end", null); | |
return true; | |
} | |
try { | |
return this.saxParser.write(str.toString()); | |
} catch (ex) { | |
return this.emit("error", ex.message); | |
} | |
}; | |
return Parser; | |
})(events.EventEmitter); | |
exports.parseString = function(str, a, b) { | |
var cb, options, parser; | |
if (b != null) { | |
if (typeof b === 'function') { | |
cb = b; | |
} | |
if (typeof a === 'object') { | |
options = a; | |
} | |
} else { | |
if (typeof a === 'function') { | |
cb = a; | |
} | |
options = {}; | |
} | |
parser = new exports.Parser(options); | |
return parser.parseString(str, cb); | |
}; | |
}).call(this); | |
},{"events":8,"sax":69}],69:[function(require,module,exports){ | |
;(function (sax) { | |
sax.parser = function (strict, opt) { return new SAXParser(strict, opt) } | |
sax.SAXParser = SAXParser | |
sax.SAXStream = SAXStream | |
sax.createStream = createStream | |
sax.MAX_BUFFER_LENGTH = 64 * 1024 | |
var buffers = [ | |
"comment", "sgmlDecl", "textNode", "tagName", "doctype", | |
"procInstName", "procInstBody", "entity", "attribName", | |
"attribValue", "cdata", "script" | |
] | |
sax.EVENTS = // for discoverability. | |
[ "text" | |
, "processinginstruction" | |
, "sgmldeclaration" | |
, "doctype" | |
, "comment" | |
, "attribute" | |
, "opentag" | |
, "closetag" | |
, "opencdata" | |
, "cdata" | |
, "closecdata" | |
, "error" | |
, "end" | |
, "ready" | |
, "script" | |
, "opennamespace" | |
, "closenamespace" | |
] | |
function SAXParser (strict, opt) { | |
if (!(this instanceof SAXParser)) return new SAXParser(strict, opt) | |
var parser = this | |
clearBuffers(parser) | |
parser.q = parser.c = "" | |
parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH | |
parser.opt = opt || {} | |
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags | |
parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase" | |
parser.tags = [] | |
parser.closed = parser.closedRoot = parser.sawRoot = false | |
parser.tag = parser.error = null | |
parser.strict = !!strict | |
parser.noscript = !!(strict || parser.opt.noscript) | |
parser.state = S.BEGIN | |
parser.ENTITIES = Object.create(sax.ENTITIES) | |
parser.attribList = [] | |
if (parser.opt.xmlns) parser.ns = Object.create(rootNS) | |
parser.trackPosition = parser.opt.position !== false | |
if (parser.trackPosition) { | |
parser.position = parser.line = parser.column = 0 | |
} | |
emit(parser, "onready") | |
} | |
if (!Object.create) Object.create = function (o) { | |
function f () { this.__proto__ = o } | |
f.prototype = o | |
return new f | |
} | |
if (!Object.getPrototypeOf) Object.getPrototypeOf = function (o) { | |
return o.__proto__ | |
} | |
if (!Object.keys) Object.keys = function (o) { | |
var a = [] | |
for (var i in o) if (o.hasOwnProperty(i)) a.push(i) | |
return a | |
} | |
function checkBufferLength (parser) { | |
var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10) | |
, maxActual = 0 | |
for (var i = 0, l = buffers.length; i < l; i ++) { | |
var len = parser[buffers[i]].length | |
if (len > maxAllowed) { | |
switch (buffers[i]) { | |
case "textNode": | |
closeText(parser) | |
break | |
case "cdata": | |
emitNode(parser, "oncdata", parser.cdata) | |
parser.cdata = "" | |
break | |
case "script": | |
emitNode(parser, "onscript", parser.script) | |
parser.script = "" | |
break | |
default: | |
error(parser, "Max buffer length exceeded: "+buffers[i]) | |
} | |
} | |
maxActual = Math.max(maxActual, len) | |
} | |
parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual) | |
+ parser.position | |
} | |
function clearBuffers (parser) { | |
for (var i = 0, l = buffers.length; i < l; i ++) { | |
parser[buffers[i]] = "" | |
} | |
} | |
SAXParser.prototype = | |
{ end: function () { end(this) } | |
, write: write | |
, resume: function () { this.error = null; return this } | |
, close: function () { return this.write(null) } | |
} | |
try { | |
var Stream = require("stream").Stream | |
} catch (ex) { | |
var Stream = function () {} | |
} | |
var streamWraps = sax.EVENTS.filter(function (ev) { | |
return ev !== "error" && ev !== "end" | |
}) | |
function createStream (strict, opt) { | |
return new SAXStream(strict, opt) | |
} | |
function SAXStream (strict, opt) { | |
if (!(this instanceof SAXStream)) return new SAXStream(strict, opt) | |
Stream.apply(this) | |
this._parser = new SAXParser(strict, opt) | |
this.writable = true | |
this.readable = true | |
var me = this | |
this._parser.onend = function () { | |
me.emit("end") | |
} | |
this._parser.onerror = function (er) { | |
me.emit("error", er) | |
me._parser.error = null | |
} | |
streamWraps.forEach(function (ev) { | |
Object.defineProperty(me, "on" + ev, { | |
get: function () { return me._parser["on" + ev] }, | |
set: function (h) { | |
if (!h) { | |
me.removeAllListeners(ev) | |
return me._parser["on"+ev] = h | |
} | |
me.on(ev, h) | |
}, | |
enumerable: true, | |
configurable: false | |
}) | |
}) | |
} | |
SAXStream.prototype = Object.create(Stream.prototype, | |
{ constructor: { value: SAXStream } }) | |
SAXStream.prototype.write = function (data) { | |
this._parser.write(data.toString()) | |
this.emit("data", data) | |
return true | |
} | |
SAXStream.prototype.end = function (chunk) { | |
if (chunk && chunk.length) this._parser.write(chunk.toString()) | |
this._parser.end() | |
return true | |
} | |
SAXStream.prototype.on = function (ev, handler) { | |
var me = this | |
if (!me._parser["on"+ev] && streamWraps.indexOf(ev) !== -1) { | |
me._parser["on"+ev] = function () { | |
var args = arguments.length === 1 ? [arguments[0]] | |
: Array.apply(null, arguments) | |
args.splice(0, 0, ev) | |
me.emit.apply(me, args) | |
} | |
} | |
return Stream.prototype.on.call(me, ev, handler) | |
} | |
var whitespace = "\r\n\t " | |
, number = "0124356789" | |
, letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
, quote = "'\"" | |
, entity = number+letter+"#" | |
, attribEnd = whitespace + ">" | |
, CDATA = "[CDATA[" | |
, DOCTYPE = "DOCTYPE" | |
, XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" | |
, XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/" | |
, rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE } | |
whitespace = charClass(whitespace) | |
number = charClass(number) | |
letter = charClass(letter) | |
var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ | |
var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/ | |
quote = charClass(quote) | |
entity = charClass(entity) | |
attribEnd = charClass(attribEnd) | |
function charClass (str) { | |
return str.split("").reduce(function (s, c) { | |
s[c] = true | |
return s | |
}, {}) | |
} | |
function isRegExp (c) { | |
return Object.prototype.toString.call(c) === '[object RegExp]' | |
} | |
function is (charclass, c) { | |
return isRegExp(charclass) ? !!c.match(charclass) : charclass[c] | |
} | |
function not (charclass, c) { | |
return !is(charclass, c) | |
} | |
var S = 0 | |
sax.STATE = | |
{ BEGIN : S++ | |
, TEXT : S++ // general stuff | |
, TEXT_ENTITY : S++ // & and such. | |
, OPEN_WAKA : S++ // < | |
, SGML_DECL : S++ // <!BLARG | |
, SGML_DECL_QUOTED : S++ // <!BLARG foo "bar | |
, DOCTYPE : S++ // <!DOCTYPE | |
, DOCTYPE_QUOTED : S++ // <!DOCTYPE "//blah | |
, DOCTYPE_DTD : S++ // <!DOCTYPE "//blah" [ ... | |
, DOCTYPE_DTD_QUOTED : S++ // <!DOCTYPE "//blah" [ "foo | |
, COMMENT_STARTING : S++ // <!- | |
, COMMENT : S++ // <!-- | |
, COMMENT_ENDING : S++ // <!-- blah - | |
, COMMENT_ENDED : S++ // <!-- blah -- | |
, CDATA : S++ // <![CDATA[ something | |
, CDATA_ENDING : S++ // ] | |
, CDATA_ENDING_2 : S++ // ]] | |
, PROC_INST : S++ // <?hi | |
, PROC_INST_BODY : S++ // <?hi there | |
, PROC_INST_ENDING : S++ // <?hi "there" ? | |
, OPEN_TAG : S++ // <strong | |
, OPEN_TAG_SLASH : S++ // <strong / | |
, ATTRIB : S++ // <a | |
, ATTRIB_NAME : S++ // <a foo | |
, ATTRIB_NAME_SAW_WHITE : S++ // <a foo _ | |
, ATTRIB_VALUE : S++ // <a foo= | |
, ATTRIB_VALUE_QUOTED : S++ // <a foo="bar | |
, ATTRIB_VALUE_UNQUOTED : S++ // <a foo=bar | |
, ATTRIB_VALUE_ENTITY_Q : S++ // <foo bar=""" | |
, ATTRIB_VALUE_ENTITY_U : S++ // <foo bar=" | |
, CLOSE_TAG : S++ // </a | |
, CLOSE_TAG_SAW_WHITE : S++ // </a > | |
, SCRIPT : S++ // <script> ... | |
, SCRIPT_ENDING : S++ // <script> ... < | |
} | |
sax.ENTITIES = | |
{ "amp" : "&" | |
, "gt" : ">" | |
, "lt" : "<" | |
, "quot" : "\"" | |
, "apos" : "'" | |
, "AElig" : 198 | |
, "Aacute" : 193 | |
, "Acirc" : 194 | |
, "Agrave" : 192 | |
, "Aring" : 197 | |
, "Atilde" : 195 | |
, "Auml" : 196 | |
, "Ccedil" : 199 | |
, "ETH" : 208 | |
, "Eacute" : 201 | |
, "Ecirc" : 202 | |
, "Egrave" : 200 | |
, "Euml" : 203 | |
, "Iacute" : 205 | |
, "Icirc" : 206 | |
, "Igrave" : 204 | |
, "Iuml" : 207 | |
, "Ntilde" : 209 | |
, "Oacute" : 211 | |
, "Ocirc" : 212 | |
, "Ograve" : 210 | |
, "Oslash" : 216 | |
, "Otilde" : 213 | |
, "Ouml" : 214 | |
, "THORN" : 222 | |
, "Uacute" : 218 | |
, "Ucirc" : 219 | |
, "Ugrave" : 217 | |
, "Uuml" : 220 | |
, "Yacute" : 221 | |
, "aacute" : 225 | |
, "acirc" : 226 | |
, "aelig" : 230 | |
, "agrave" : 224 | |
, "aring" : 229 | |
, "atilde" : 227 | |
, "auml" : 228 | |
, "ccedil" : 231 | |
, "eacute" : 233 | |
, "ecirc" : 234 | |
, "egrave" : 232 | |
, "eth" : 240 | |
, "euml" : 235 | |
, "iacute" : 237 | |
, "icirc" : 238 | |
, "igrave" : 236 | |
, "iuml" : 239 | |
, "ntilde" : 241 | |
, "oacute" : 243 | |
, "ocirc" : 244 | |
, "ograve" : 242 | |
, "oslash" : 248 | |
, "otilde" : 245 | |
, "ouml" : 246 | |
, "szlig" : 223 | |
, "thorn" : 254 | |
, "uacute" : 250 | |
, "ucirc" : 251 | |
, "ugrave" : 249 | |
, "uuml" : 252 | |
, "yacute" : 253 | |
, "yuml" : 255 | |
, "copy" : 169 | |
, "reg" : 174 | |
, "nbsp" : 160 | |
, "iexcl" : 161 | |
, "cent" : 162 | |
, "pound" : 163 | |
, "curren" : 164 | |
, "yen" : 165 | |
, "brvbar" : 166 | |
, "sect" : 167 | |
, "uml" : 168 | |
, "ordf" : 170 | |
, "laquo" : 171 | |
, "not" : 172 | |
, "shy" : 173 | |
, "macr" : 175 | |
, "deg" : 176 | |
, "plusmn" : 177 | |
, "sup1" : 185 | |
, "sup2" : 178 | |
, "sup3" : 179 | |
, "acute" : 180 | |
, "micro" : 181 | |
, "para" : 182 | |
, "middot" : 183 | |
, "cedil" : 184 | |
, "ordm" : 186 | |
, "raquo" : 187 | |
, "frac14" : 188 | |
, "frac12" : 189 | |
, "frac34" : 190 | |
, "iquest" : 191 | |
, "times" : 215 | |
, "divide" : 247 | |
, "OElig" : 338 | |
, "oelig" : 339 | |
, "Scaron" : 352 | |
, "scaron" : 353 | |
, "Yuml" : 376 | |
, "fnof" : 402 | |
, "circ" : 710 | |
, "tilde" : 732 | |
, "Alpha" : 913 | |
, "Beta" : 914 | |
, "Gamma" : 915 | |
, "Delta" : 916 | |
, "Epsilon" : 917 | |
, "Zeta" : 918 | |
, "Eta" : 919 | |
, "Theta" : 920 | |
, "Iota" : 921 | |
, "Kappa" : 922 | |
, "Lambda" : 923 | |
, "Mu" : 924 | |
, "Nu" : 925 | |
, "Xi" : 926 | |
, "Omicron" : 927 | |
, "Pi" : 928 | |
, "Rho" : 929 | |
, "Sigma" : 931 | |
, "Tau" : 932 | |
, "Upsilon" : 933 | |
, "Phi" : 934 | |
, "Chi" : 935 | |
, "Psi" : 936 | |
, "Omega" : 937 | |
, "alpha" : 945 | |
, "beta" : 946 | |
, "gamma" : 947 | |
, "delta" : 948 | |
, "epsilon" : 949 | |
, "zeta" : 950 | |
, "eta" : 951 | |
, "theta" : 952 | |
, "iota" : 953 | |
, "kappa" : 954 | |
, "lambda" : 955 | |
, "mu" : 956 | |
, "nu" : 957 | |
, "xi" : 958 | |
, "omicron" : 959 | |
, "pi" : 960 | |
, "rho" : 961 | |
, "sigmaf" : 962 | |
, "sigma" : 963 | |
, "tau" : 964 | |
, "upsilon" : 965 | |
, "phi" : 966 | |
, "chi" : 967 | |
, "psi" : 968 | |
, "omega" : 969 | |
, "thetasym" : 977 | |
, "upsih" : 978 | |
, "piv" : 982 | |
, "ensp" : 8194 | |
, "emsp" : 8195 | |
, "thinsp" : 8201 | |
, "zwnj" : 8204 | |
, "zwj" : 8205 | |
, "lrm" : 8206 | |
, "rlm" : 8207 | |
, "ndash" : 8211 | |
, "mdash" : 8212 | |
, "lsquo" : 8216 | |
, "rsquo" : 8217 | |
, "sbquo" : 8218 | |
, "ldquo" : 8220 | |
, "rdquo" : 8221 | |
, "bdquo" : 8222 | |
, "dagger" : 8224 | |
, "Dagger" : 8225 | |
, "bull" : 8226 | |
, "hellip" : 8230 | |
, "permil" : 8240 | |
, "prime" : 8242 | |
, "Prime" : 8243 | |
, "lsaquo" : 8249 | |
, "rsaquo" : 8250 | |
, "oline" : 8254 | |
, "frasl" : 8260 | |
, "euro" : 8364 | |
, "image" : 8465 | |
, "weierp" : 8472 | |
, "real" : 8476 | |
, "trade" : 8482 | |
, "alefsym" : 8501 | |
, "larr" : 8592 | |
, "uarr" : 8593 | |
, "rarr" : 8594 | |
, "darr" : 8595 | |
, "harr" : 8596 | |
, "crarr" : 8629 | |
, "lArr" : 8656 | |
, "uArr" : 8657 | |
, "rArr" : 8658 | |
, "dArr" : 8659 | |
, "hArr" : 8660 | |
, "forall" : 8704 | |
, "part" : 8706 | |
, "exist" : 8707 | |
, "empty" : 8709 | |
, "nabla" : 8711 | |
, "isin" : 8712 | |
, "notin" : 8713 | |
, "ni" : 8715 | |
, "prod" : 8719 | |
, "sum" : 8721 | |
, "minus" : 8722 | |
, "lowast" : 8727 | |
, "radic" : 8730 | |
, "prop" : 8733 | |
, "infin" : 8734 | |
, "ang" : 8736 | |
, "and" : 8743 | |
, "or" : 8744 | |
, "cap" : 8745 | |
, "cup" : 8746 | |
, "int" : 8747 | |
, "there4" : 8756 | |
, "sim" : 8764 | |
, "cong" : 8773 | |
, "asymp" : 8776 | |
, "ne" : 8800 | |
, "equiv" : 8801 | |
, "le" : 8804 | |
, "ge" : 8805 | |
, "sub" : 8834 | |
, "sup" : 8835 | |
, "nsub" : 8836 | |
, "sube" : 8838 | |
, "supe" : 8839 | |
, "oplus" : 8853 | |
, "otimes" : 8855 | |
, "perp" : 8869 | |
, "sdot" : 8901 | |
, "lceil" : 8968 | |
, "rceil" : 8969 | |
, "lfloor" : 8970 | |
, "rfloor" : 8971 | |
, "lang" : 9001 | |
, "rang" : 9002 | |
, "loz" : 9674 | |
, "spades" : 9824 | |
, "clubs" : 9827 | |
, "hearts" : 9829 | |
, "diams" : 9830 | |
} | |
Object.keys(sax.ENTITIES).forEach(function (key) { | |
var e = sax.ENTITIES[key] | |
var s = typeof e === 'number' ? String.fromCharCode(e) : e | |
sax.ENTITIES[key] = s | |
}) | |
for (var S in sax.STATE) sax.STATE[sax.STATE[S]] = S | |
S = sax.STATE | |
function emit (parser, event, data) { | |
parser[event] && parser[event](data) | |
} | |
function emitNode (parser, nodeType, data) { | |
if (parser.textNode) closeText(parser) | |
emit(parser, nodeType, data) | |
} | |
function closeText (parser) { | |
parser.textNode = textopts(parser.opt, parser.textNode) | |
if (parser.textNode) emit(parser, "ontext", parser.textNode) | |
parser.textNode = "" | |
} | |
function textopts (opt, text) { | |
if (opt.trim) text = text.trim() | |
if (opt.normalize) text = text.replace(/\s+/g, " ") | |
return text | |
} | |
function error (parser, er) { | |
closeText(parser) | |
if (parser.trackPosition) { | |
er += "\nLine: "+parser.line+ | |
"\nColumn: "+parser.column+ | |
"\nChar: "+parser.c | |
} | |
er = new Error(er) | |
parser.error = er | |
emit(parser, "onerror", er) | |
return parser | |
} | |
function end (parser) { | |
if (!parser.closedRoot) strictFail(parser, "Unclosed root tag") | |
if (parser.state !== S.TEXT) error(parser, "Unexpected end") | |
closeText(parser) | |
parser.c = "" | |
parser.closed = true | |
emit(parser, "onend") | |
SAXParser.call(parser, parser.strict, parser.opt) | |
return parser | |
} | |
function strictFail (parser, message) { | |
if (typeof parser !== 'object' || !(parser instanceof SAXParser)) | |
throw new Error('bad call to strictFail'); | |
if (parser.strict) error(parser, message) | |
} | |
function newTag (parser) { | |
if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]() | |
var parent = parser.tags[parser.tags.length - 1] || parser | |
, tag = parser.tag = { name : parser.tagName, attributes : {} } | |
if (parser.opt.xmlns) tag.ns = parent.ns | |
parser.attribList.length = 0 | |
} | |
function qname (name) { | |
var i = name.indexOf(":") | |
, qualName = i < 0 ? [ "", name ] : name.split(":") | |
, prefix = qualName[0] | |
, local = qualName[1] | |
if (name === "xmlns") { | |
prefix = "xmlns" | |
local = "" | |
} | |
return { prefix: prefix, local: local } | |
} | |
function attrib (parser) { | |
if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]() | |
if (parser.attribList.indexOf(parser.attribName) !== -1 || | |
parser.tag.attributes.hasOwnProperty(parser.attribName)) { | |
return parser.attribName = parser.attribValue = "" | |
} | |
if (parser.opt.xmlns) { | |
var qn = qname(parser.attribName) | |
, prefix = qn.prefix | |
, local = qn.local | |
if (prefix === "xmlns") { | |
if (local === "xml" && parser.attribValue !== XML_NAMESPACE) { | |
strictFail( parser | |
, "xml: prefix must be bound to " + XML_NAMESPACE + "\n" | |
+ "Actual: " + parser.attribValue ) | |
} else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) { | |
strictFail( parser | |
, "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\n" | |
+ "Actual: " + parser.attribValue ) | |
} else { | |
var tag = parser.tag | |
, parent = parser.tags[parser.tags.length - 1] || parser | |
if (tag.ns === parent.ns) { | |
tag.ns = Object.create(parent.ns) | |
} | |
tag.ns[local] = parser.attribValue | |
} | |
} | |
parser.attribList.push([parser.attribName, parser.attribValue]) | |
} else { | |
parser.tag.attributes[parser.attribName] = parser.attribValue | |
emitNode( parser | |
, "onattribute" | |
, { name: parser.attribName | |
, value: parser.attribValue } ) | |
} | |
parser.attribName = parser.attribValue = "" | |
} | |
function openTag (parser, selfClosing) { | |
if (parser.opt.xmlns) { | |
var tag = parser.tag | |
var qn = qname(parser.tagName) | |
tag.prefix = qn.prefix | |
tag.local = qn.local | |
tag.uri = tag.ns[qn.prefix] || "" | |
if (tag.prefix && !tag.uri) { | |
strictFail(parser, "Unbound namespace prefix: " | |
+ JSON.stringify(parser.tagName)) | |
tag.uri = qn.prefix | |
} | |
var parent = parser.tags[parser.tags.length - 1] || parser | |
if (tag.ns && parent.ns !== tag.ns) { | |
Object.keys(tag.ns).forEach(function (p) { | |
emitNode( parser | |
, "onopennamespace" | |
, { prefix: p , uri: tag.ns[p] } ) | |
}) | |
} | |
for (var i = 0, l = parser.attribList.length; i < l; i ++) { | |
var nv = parser.attribList[i] | |
var name = nv[0] | |
, value = nv[1] | |
, qualName = qname(name) | |
, prefix = qualName.prefix | |
, local = qualName.local | |
, uri = prefix == "" ? "" : (tag.ns[prefix] || "") | |
, a = { name: name | |
, value: value | |
, prefix: prefix | |
, local: local | |
, uri: uri | |
} | |
if (prefix && prefix != "xmlns" && !uri) { | |
strictFail(parser, "Unbound namespace prefix: " | |
+ JSON.stringify(prefix)) | |
a.uri = prefix | |
} | |
parser.tag.attributes[name] = a | |
emitNode(parser, "onattribute", a) | |
} | |
parser.attribList.length = 0 | |
} | |
parser.tag.isSelfClosing = !!selfClosing | |
parser.sawRoot = true | |
parser.tags.push(parser.tag) | |
emitNode(parser, "onopentag", parser.tag) | |
if (!selfClosing) { | |
if (!parser.noscript && parser.tagName.toLowerCase() === "script") { | |
parser.state = S.SCRIPT | |
} else { | |
parser.state = S.TEXT | |
} | |
parser.tag = null | |
parser.tagName = "" | |
} | |
parser.attribName = parser.attribValue = "" | |
parser.attribList.length = 0 | |
} | |
function closeTag (parser) { | |
if (!parser.tagName) { | |
strictFail(parser, "Weird empty close tag.") | |
parser.textNode += "</>" | |
parser.state = S.TEXT | |
return | |
} | |
if (parser.script) { | |
if (parser.tagName !== "script") { | |
parser.script += "</" + parser.tagName + ">" | |
parser.tagName = "" | |
parser.state = S.SCRIPT | |
return | |
} | |
emitNode(parser, "onscript", parser.script) | |
parser.script = "" | |
} | |
var t = parser.tags.length | |
var tagName = parser.tagName | |
if (!parser.strict) tagName = tagName[parser.looseCase]() | |
var closeTo = tagName | |
while (t --) { | |
var close = parser.tags[t] | |
if (close.name !== closeTo) { | |
strictFail(parser, "Unexpected close tag") | |
} else break | |
} | |
if (t < 0) { | |
strictFail(parser, "Unmatched closing tag: "+parser.tagName) | |
parser.textNode += "</" + parser.tagName + ">" | |
parser.state = S.TEXT | |
return | |
} | |
parser.tagName = tagName | |
var s = parser.tags.length | |
while (s --> t) { | |
var tag = parser.tag = parser.tags.pop() | |
parser.tagName = parser.tag.name | |
emitNode(parser, "onclosetag", parser.tagName) | |
var x = {} | |
for (var i in tag.ns) x[i] = tag.ns[i] | |
var parent = parser.tags[parser.tags.length - 1] || parser | |
if (parser.opt.xmlns && tag.ns !== parent.ns) { | |
Object.keys(tag.ns).forEach(function (p) { | |
var n = tag.ns[p] | |
emitNode(parser, "onclosenamespace", { prefix: p, uri: n }) | |
}) | |
} | |
} | |
if (t === 0) parser.closedRoot = true | |
parser.tagName = parser.attribValue = parser.attribName = "" | |
parser.attribList.length = 0 | |
parser.state = S.TEXT | |
} | |
function parseEntity (parser) { | |
var entity = parser.entity | |
, entityLC = entity.toLowerCase() | |
, num | |
, numStr = "" | |
if (parser.ENTITIES[entity]) | |
return parser.ENTITIES[entity] | |
if (parser.ENTITIES[entityLC]) | |
return parser.ENTITIES[entityLC] | |
entity = entityLC | |
if (entity.charAt(0) === "#") { | |
if (entity.charAt(1) === "x") { | |
entity = entity.slice(2) | |
num = parseInt(entity, 16) | |
numStr = num.toString(16) | |
} else { | |
entity = entity.slice(1) | |
num = parseInt(entity, 10) | |
numStr = num.toString(10) | |
} | |
} | |
entity = entity.replace(/^0+/, "") | |
if (numStr.toLowerCase() !== entity) { | |
strictFail(parser, "Invalid character entity") | |
return "&"+parser.entity + ";" | |
} | |
return String.fromCharCode(num) | |
} | |
function write (chunk) { | |
var parser = this | |
if (this.error) throw this.error | |
if (parser.closed) return error(parser, | |
"Cannot write after close. Assign an onready handler.") | |
if (chunk === null) return end(parser) | |
var i = 0, c = "" | |
while (parser.c = c = chunk.charAt(i++)) { | |
if (parser.trackPosition) { | |
parser.position ++ | |
if (c === "\n") { | |
parser.line ++ | |
parser.column = 0 | |
} else parser.column ++ | |
} | |
switch (parser.state) { | |
case S.BEGIN: | |
if (c === "<") { | |
parser.state = S.OPEN_WAKA | |
parser.startTagPosition = parser.position | |
} else if (not(whitespace,c)) { | |
strictFail(parser, "Non-whitespace before first tag.") | |
parser.textNode = c | |
parser.state = S.TEXT | |
} | |
continue | |
case S.TEXT: | |
if (parser.sawRoot && !parser.closedRoot) { | |
var starti = i-1 | |
while (c && c!=="<" && c!=="&") { | |
c = chunk.charAt(i++) | |
if (c && parser.trackPosition) { | |
parser.position ++ | |
if (c === "\n") { | |
parser.line ++ | |
parser.column = 0 | |
} else parser.column ++ | |
} | |
} | |
parser.textNode += chunk.substring(starti, i-1) | |
} | |
if (c === "<") { | |
parser.state = S.OPEN_WAKA | |
parser.startTagPosition = parser.position | |
} else { | |
if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot)) | |
strictFail(parser, "Text data outside of root node.") | |
if (c === "&") parser.state = S.TEXT_ENTITY | |
else parser.textNode += c | |
} | |
continue | |
case S.SCRIPT: | |
if (c === "<") { | |
parser.state = S.SCRIPT_ENDING | |
} else parser.script += c | |
continue | |
case S.SCRIPT_ENDING: | |
if (c === "/") { | |
parser.state = S.CLOSE_TAG | |
} else { | |
parser.script += "<" + c | |
parser.state = S.SCRIPT | |
} | |
continue | |
case S.OPEN_WAKA: | |
if (c === "!") { | |
parser.state = S.SGML_DECL | |
parser.sgmlDecl = "" | |
} else if (is(whitespace, c)) { | |
} else if (is(nameStart,c)) { | |
parser.state = S.OPEN_TAG | |
parser.tagName = c | |
} else if (c === "/") { | |
parser.state = S.CLOSE_TAG | |
parser.tagName = "" | |
} else if (c === "?") { | |
parser.state = S.PROC_INST | |
parser.procInstName = parser.procInstBody = "" | |
} else { | |
strictFail(parser, "Unencoded <") | |
if (parser.startTagPosition + 1 < parser.position) { | |
var pad = parser.position - parser.startTagPosition | |
c = new Array(pad).join(" ") + c | |
} | |
parser.textNode += "<" + c | |
parser.state = S.TEXT | |
} | |
continue | |
case S.SGML_DECL: | |
if ((parser.sgmlDecl+c).toUpperCase() === CDATA) { | |
emitNode(parser, "onopencdata") | |
parser.state = S.CDATA | |
parser.sgmlDecl = "" | |
parser.cdata = "" | |
} else if (parser.sgmlDecl+c === "--") { | |
parser.state = S.COMMENT | |
parser.comment = "" | |
parser.sgmlDecl = "" | |
} else if ((parser.sgmlDecl+c).toUpperCase() === DOCTYPE) { | |
parser.state = S.DOCTYPE | |
if (parser.doctype || parser.sawRoot) strictFail(parser, | |
"Inappropriately located doctype declaration") | |
parser.doctype = "" | |
parser.sgmlDecl = "" | |
} else if (c === ">") { | |
emitNode(parser, "onsgmldeclaration", parser.sgmlDecl) | |
parser.sgmlDecl = "" | |
parser.state = S.TEXT | |
} else if (is(quote, c)) { | |
parser.state = S.SGML_DECL_QUOTED | |
parser.sgmlDecl += c | |
} else parser.sgmlDecl += c | |
continue | |
case S.SGML_DECL_QUOTED: | |
if (c === parser.q) { | |
parser.state = S.SGML_DECL | |
parser.q = "" | |
} | |
parser.sgmlDecl += c | |
continue | |
case S.DOCTYPE: | |
if (c === ">") { | |
parser.state = S.TEXT | |
emitNode(parser, "ondoctype", parser.doctype) | |
parser.doctype = true // just remember that we saw it. | |
} else { | |
parser.doctype += c | |
if (c === "[") parser.state = S.DOCTYPE_DTD | |
else if (is(quote, c)) { | |
parser.state = S.DOCTYPE_QUOTED | |
parser.q = c | |
} | |
} | |
continue | |
case S.DOCTYPE_QUOTED: | |
parser.doctype += c | |
if (c === parser.q) { | |
parser.q = "" | |
parser.state = S.DOCTYPE | |
} | |
continue | |
case S.DOCTYPE_DTD: | |
parser.doctype += c | |
if (c === "]") parser.state = S.DOCTYPE | |
else if (is(quote,c)) { | |
parser.state = S.DOCTYPE_DTD_QUOTED | |
parser.q = c | |
} | |
continue | |
case S.DOCTYPE_DTD_QUOTED: | |
parser.doctype += c | |
if (c === parser.q) { | |
parser.state = S.DOCTYPE_DTD | |
parser.q = "" | |
} | |
continue | |
case S.COMMENT: | |
if (c === "-") parser.state = S.COMMENT_ENDING | |
else parser.comment += c | |
continue | |
case S.COMMENT_ENDING: | |
if (c === "-") { | |
parser.state = S.COMMENT_ENDED | |
parser.comment = textopts(parser.opt, parser.comment) | |
if (parser.comment) emitNode(parser, "oncomment", parser.comment) | |
parser.comment = "" | |
} else { | |
parser.comment += "-" + c | |
parser.state = S.COMMENT | |
} | |
continue | |
case S.COMMENT_ENDED: | |
if (c !== ">") { | |
strictFail(parser, "Malformed comment") | |
parser.comment += "--" + c | |
parser.state = S.COMMENT | |
} else parser.state = S.TEXT | |
continue | |
case S.CDATA: | |
if (c === "]") parser.state = S.CDATA_ENDING | |
else parser.cdata += c | |
continue | |
case S.CDATA_ENDING: | |
if (c === "]") parser.state = S.CDATA_ENDING_2 | |
else { | |
parser.cdata += "]" + c | |
parser.state = S.CDATA | |
} | |
continue | |
case S.CDATA_ENDING_2: | |
if (c === ">") { | |
if (parser.cdata) emitNode(parser, "oncdata", parser.cdata) | |
emitNode(parser, "onclosecdata") | |
parser.cdata = "" | |
parser.state = S.TEXT | |
} else if (c === "]") { | |
parser.cdata += "]" | |
} else { | |
parser.cdata += "]]" + c | |
parser.state = S.CDATA | |
} | |
continue | |
case S.PROC_INST: | |
if (c === "?") parser.state = S.PROC_INST_ENDING | |
else if (is(whitespace, c)) parser.state = S.PROC_INST_BODY | |
else parser.procInstName += c | |
continue | |
case S.PROC_INST_BODY: | |
if (!parser.procInstBody && is(whitespace, c)) continue | |
else if (c === "?") parser.state = S.PROC_INST_ENDING | |
else parser.procInstBody += c | |
continue | |
case S.PROC_INST_ENDING: | |
if (c === ">") { | |
emitNode(parser, "onprocessinginstruction", { | |
name : parser.procInstName, | |
body : parser.procInstBody | |
}) | |
parser.procInstName = parser.procInstBody = "" | |
parser.state = S.TEXT | |
} else { | |
parser.procInstBody += "?" + c | |
parser.state = S.PROC_INST_BODY | |
} | |
continue | |
case S.OPEN_TAG: | |
if (is(nameBody, c)) parser.tagName += c | |
else { | |
newTag(parser) | |
if (c === ">") openTag(parser) | |
else if (c === "/") parser.state = S.OPEN_TAG_SLASH | |
else { | |
if (not(whitespace, c)) strictFail( | |
parser, "Invalid character in tag name") | |
parser.state = S.ATTRIB | |
} | |
} | |
continue | |
case S.OPEN_TAG_SLASH: | |
if (c === ">") { | |
openTag(parser, true) | |
closeTag(parser) | |
} else { | |
strictFail(parser, "Forward-slash in opening tag not followed by >") | |
parser.state = S.ATTRIB | |
} | |
continue | |
case S.ATTRIB: | |
if (is(whitespace, c)) continue | |
else if (c === ">") openTag(parser) | |
else if (c === "/") parser.state = S.OPEN_TAG_SLASH | |
else if (is(nameStart, c)) { | |
parser.attribName = c | |
parser.attribValue = "" | |
parser.state = S.ATTRIB_NAME | |
} else strictFail(parser, "Invalid attribute name") | |
continue | |
case S.ATTRIB_NAME: | |
if (c === "=") parser.state = S.ATTRIB_VALUE | |
else if (c === ">") { | |
strictFail(parser, "Attribute without value") | |
parser.attribValue = parser.attribName | |
attrib(parser) | |
openTag(parser) | |
} | |
else if (is(whitespace, c)) parser.state = S.ATTRIB_NAME_SAW_WHITE | |
else if (is(nameBody, c)) parser.attribName += c | |
else strictFail(parser, "Invalid attribute name") | |
continue | |
case S.ATTRIB_NAME_SAW_WHITE: | |
if (c === "=") parser.state = S.ATTRIB_VALUE | |
else if (is(whitespace, c)) continue | |
else { | |
strictFail(parser, "Attribute without value") | |
parser.tag.attributes[parser.attribName] = "" | |
parser.attribValue = "" | |
emitNode(parser, "onattribute", | |
{ name : parser.attribName, value : "" }) | |
parser.attribName = "" | |
if (c === ">") openTag(parser) | |
else if (is(nameStart, c)) { | |
parser.attribName = c | |
parser.state = S.ATTRIB_NAME | |
} else { | |
strictFail(parser, "Invalid attribute name") | |
parser.state = S.ATTRIB | |
} | |
} | |
continue | |
case S.ATTRIB_VALUE: | |
if (is(whitespace, c)) continue | |
else if (is(quote, c)) { | |
parser.q = c | |
parser.state = S.ATTRIB_VALUE_QUOTED | |
} else { | |
strictFail(parser, "Unquoted attribute value") | |
parser.state = S.ATTRIB_VALUE_UNQUOTED | |
parser.attribValue = c | |
} | |
continue | |
case S.ATTRIB_VALUE_QUOTED: | |
if (c !== parser.q) { | |
if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_Q | |
else parser.attribValue += c | |
continue | |
} | |
attrib(parser) | |
parser.q = "" | |
parser.state = S.ATTRIB | |
continue | |
case S.ATTRIB_VALUE_UNQUOTED: | |
if (not(attribEnd,c)) { | |
if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_U | |
else parser.attribValue += c | |
continue | |
} | |
attrib(parser) | |
if (c === ">") openTag(parser) | |
else parser.state = S.ATTRIB | |
continue | |
case S.CLOSE_TAG: | |
if (!parser.tagName) { | |
if (is(whitespace, c)) continue | |
else if (not(nameStart, c)) { | |
if (parser.script) { | |
parser.script += "</" + c | |
parser.state = S.SCRIPT | |
} else { | |
strictFail(parser, "Invalid tagname in closing tag.") | |
} | |
} else parser.tagName = c | |
} | |
else if (c === ">") closeTag(parser) | |
else if (is(nameBody, c)) parser.tagName += c | |
else if (parser.script) { | |
parser.script += "</" + parser.tagName | |
parser.tagName = "" | |
parser.state = S.SCRIPT | |
} else { | |
if (not(whitespace, c)) strictFail(parser, | |
"Invalid tagname in closing tag") | |
parser.state = S.CLOSE_TAG_SAW_WHITE | |
} | |
continue | |
case S.CLOSE_TAG_SAW_WHITE: | |
if (is(whitespace, c)) continue | |
if (c === ">") closeTag(parser) | |
else strictFail(parser, "Invalid characters in closing tag") | |
continue | |
case S.TEXT_ENTITY: | |
case S.ATTRIB_VALUE_ENTITY_Q: | |
case S.ATTRIB_VALUE_ENTITY_U: | |
switch(parser.state) { | |
case S.TEXT_ENTITY: | |
var returnState = S.TEXT, buffer = "textNode" | |
break | |
case S.ATTRIB_VALUE_ENTITY_Q: | |
var returnState = S.ATTRIB_VALUE_QUOTED, buffer = "attribValue" | |
break | |
case S.ATTRIB_VALUE_ENTITY_U: | |
var returnState = S.ATTRIB_VALUE_UNQUOTED, buffer = "attribValue" | |
break | |
} | |
if (c === ";") { | |
parser[buffer] += parseEntity(parser) | |
parser.entity = "" | |
parser.state = returnState | |
} | |
else if (is(entity, c)) parser.entity += c | |
else { | |
strictFail(parser, "Invalid character entity") | |
parser[buffer] += "&" + parser.entity + c | |
parser.entity = "" | |
parser.state = returnState | |
} | |
continue | |
default: | |
throw new Error(parser, "Unknown state: " + parser.state) | |
} | |
} // while | |
if (parser.position >= parser.bufferCheckPosition) checkBufferLength(parser) | |
return parser | |
} | |
})(typeof exports === "undefined" ? sax = {} : exports) | |
},{"stream":20}],70:[function(require,module,exports){ | |
(function() { | |
var XMLBuilder, XMLFragment; | |
XMLFragment = require('./XMLFragment'); | |
XMLBuilder = (function() { | |
function XMLBuilder(name, xmldec, doctype) { | |
var att, child, _ref; | |
this.children = []; | |
this.rootObject = null; | |
if (this.is(name, 'Object')) { | |
_ref = [name, xmldec], xmldec = _ref[0], doctype = _ref[1]; | |
name = null; | |
} | |
if (name != null) { | |
name = '' + name || ''; | |
if (xmldec == null) { | |
xmldec = { | |
'version': '1.0' | |
}; | |
} | |
} | |
if ((xmldec != null) && !(xmldec.version != null)) { | |
throw new Error("Version number is required"); | |
} | |
if (xmldec != null) { | |
xmldec.version = '' + xmldec.version || ''; | |
if (!xmldec.version.match(/1\.[0-9]+/)) { | |
throw new Error("Invalid version number: " + xmldec.version); | |
} | |
att = { | |
version: xmldec.version | |
}; | |
if (xmldec.encoding != null) { | |
xmldec.encoding = '' + xmldec.encoding || ''; | |
if (!xmldec.encoding.match(/[A-Za-z](?:[A-Za-z0-9._-]|-)*/)) { | |
throw new Error("Invalid encoding: " + xmldec.encoding); | |
} | |
att.encoding = xmldec.encoding; | |
} | |
if (xmldec.standalone != null) { | |
att.standalone = xmldec.standalone ? "yes" : "no"; | |
} | |
child = new XMLFragment(this, '?xml', att); | |
this.children.push(child); | |
} | |
if (doctype != null) { | |
att = {}; | |
if (name != null) { | |
att.name = name; | |
} | |
if (doctype.ext != null) { | |
doctype.ext = '' + doctype.ext || ''; | |
att.ext = doctype.ext; | |
} | |
child = new XMLFragment(this, '!DOCTYPE', att); | |
this.children.push(child); | |
} | |
if (name != null) { | |
this.begin(name); | |
} | |
} | |
XMLBuilder.prototype.begin = function(name, xmldec, doctype) { | |
var doc, root; | |
if (!(name != null)) { | |
throw new Error("Root element needs a name"); | |
} | |
if (this.rootObject) { | |
this.children = []; | |
this.rootObject = null; | |
} | |
if (xmldec != null) { | |
doc = new XMLBuilder(name, xmldec, doctype); | |
return doc.root(); | |
} | |
name = '' + name || ''; | |
root = new XMLFragment(this, name, {}); | |
root.isRoot = true; | |
root.documentObject = this; | |
this.children.push(root); | |
this.rootObject = root; | |
return root; | |
}; | |
XMLBuilder.prototype.root = function() { | |
return this.rootObject; | |
}; | |
XMLBuilder.prototype.end = function(options) { | |
return toString(options); | |
}; | |
XMLBuilder.prototype.toString = function(options) { | |
var child, r, _i, _len, _ref; | |
r = ''; | |
_ref = this.children; | |
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
child = _ref[_i]; | |
r += child.toString(options); | |
} | |
return r; | |
}; | |
XMLBuilder.prototype.is = function(obj, type) { | |
var clas; | |
clas = Object.prototype.toString.call(obj).slice(8, -1); | |
return (obj != null) && clas === type; | |
}; | |
return XMLBuilder; | |
})(); | |
module.exports = XMLBuilder; | |
}).call(this); | |
},{"./XMLFragment":71}],71:[function(require,module,exports){ | |
(function() { | |
var XMLFragment, | |
__hasProp = {}.hasOwnProperty; | |
XMLFragment = (function() { | |
function XMLFragment(parent, name, attributes, text) { | |
this.isRoot = false; | |
this.documentObject = null; | |
this.parent = parent; | |
this.name = name; | |
this.attributes = attributes; | |
this.value = text; | |
this.children = []; | |
} | |
XMLFragment.prototype.element = function(name, attributes, text) { | |
var child, key, val, _ref, _ref1; | |
if (!(name != null)) { | |
throw new Error("Missing element name"); | |
} | |
name = '' + name || ''; | |
this.assertLegalChar(name); | |
if (attributes == null) { | |
attributes = {}; | |
} | |
if (this.is(attributes, 'String') && this.is(text, 'Object')) { | |
_ref = [text, attributes], attributes = _ref[0], text = _ref[1]; | |
} else if (this.is(attributes, 'String')) { | |
_ref1 = [{}, attributes], attributes = _ref1[0], text = _ref1[1]; | |
} | |
for (key in attributes) { | |
if (!__hasProp.call(attributes, key)) continue; | |
val = attributes[key]; | |
val = '' + val || ''; | |
attributes[key] = this.escape(val); | |
} | |
child = new XMLFragment(this, name, attributes); | |
if (text != null) { | |
text = '' + text || ''; | |
text = this.escape(text); | |
this.assertLegalChar(text); | |
child.raw(text); | |
} | |
this.children.push(child); | |
return child; | |
}; | |
XMLFragment.prototype.insertBefore = function(name, attributes, text) { | |
var child, i, key, val, _ref, _ref1; | |
if (this.isRoot) { | |
throw new Error("Cannot insert elements at root level"); | |
} | |
if (!(name != null)) { | |
throw new Error("Missing element name"); | |
} | |
name = '' + name || ''; | |
this.assertLegalChar(name); | |
if (attributes == null) { | |
attributes = {}; | |
} | |
if (this.is(attributes, 'String') && this.is(text, 'Object')) { | |
_ref = [text, attributes], attributes = _ref[0], text = _ref[1]; | |
} else if (this.is(attributes, 'String')) { | |
_ref1 = [{}, attributes], attributes = _ref1[0], text = _ref1[1]; | |
} | |
for (key in attributes) { | |
if (!__hasProp.call(attributes, key)) continue; | |
val = attributes[key]; | |
val = '' + val || ''; | |
attributes[key] = this.escape(val); | |
} | |
child = new XMLFragment(this.parent, name, attributes); | |
if (text != null) { | |
text = '' + text || ''; | |
text = this.escape(text); | |
this.assertLegalChar(text); | |
child.raw(text); | |
} | |
i = this.parent.children.indexOf(this); | |
this.parent.children.splice(i, 0, child); | |
return child; | |
}; | |
XMLFragment.prototype.insertAfter = function(name, attributes, text) { | |
var child, i, key, val, _ref, _ref1; | |
if (this.isRoot) { | |
throw new Error("Cannot insert elements at root level"); | |
} | |
if (!(name != null)) { | |
throw new Error("Missing element name"); | |
} | |
name = '' + name || ''; | |
this.assertLegalChar(name); | |
if (attributes == null) { | |
attributes = {}; | |
} | |
if (this.is(attributes, 'String') && this.is(text, 'Object')) { | |
_ref = [text, attributes], attributes = _ref[0], text = _ref[1]; | |
} else if (this.is(attributes, 'String')) { | |
_ref1 = [{}, attributes], attributes = _ref1[0], text = _ref1[1]; | |
} | |
for (key in attributes) { | |
if (!__hasProp.call(attributes, key)) continue; | |
val = attributes[key]; | |
val = '' + val || ''; | |
attributes[key] = this.escape(val); | |
} | |
child = new XMLFragment(this.parent, name, attributes); | |
if (text != null) { | |
text = '' + text || ''; | |
text = this.escape(text); | |
this.assertLegalChar(text); | |
child.raw(text); | |
} | |
i = this.parent.children.indexOf(this); | |
this.parent.children.splice(i + 1, 0, child); | |
return child; | |
}; | |
XMLFragment.prototype.remove = function() { | |
var i, _ref; | |
if (this.isRoot) { | |
throw new Error("Cannot remove the root element"); | |
} | |
i = this.parent.children.indexOf(this); | |
[].splice.apply(this.parent.children, [i, i - i + 1].concat(_ref = [])), _ref; | |
return this.parent; | |
}; | |
XMLFragment.prototype.text = function(value) { | |
var child; | |
if (!(value != null)) { | |
throw new Error("Missing element text"); | |
} | |
value = '' + value || ''; | |
value = this.escape(value); | |
this.assertLegalChar(value); | |
child = new XMLFragment(this, '', {}, value); | |
this.children.push(child); | |
return this; | |
}; | |
XMLFragment.prototype.cdata = function(value) { | |
var child; | |
if (!(value != null)) { | |
throw new Error("Missing CDATA text"); | |
} | |
value = '' + value || ''; | |
this.assertLegalChar(value); | |
if (value.match(/]]>/)) { | |
throw new Error("Invalid CDATA text: " + value); | |
} | |
child = new XMLFragment(this, '', {}, '<![CDATA[' + value + ']]>'); | |
this.children.push(child); | |
return this; | |
}; | |
XMLFragment.prototype.comment = function(value) { | |
var child; | |
if (!(value != null)) { | |
throw new Error("Missing comment text"); | |
} | |
value = '' + value || ''; | |
value = this.escape(value); | |
this.assertLegalChar(value); | |
if (value.match(/--/)) { | |
throw new Error("Comment text cannot contain double-hypen: " + value); | |
} | |
child = new XMLFragment(this, '', {}, '<!-- ' + value + ' -->'); | |
this.children.push(child); | |
return this; | |
}; | |
XMLFragment.prototype.raw = function(value) { | |
var child; | |
if (!(value != null)) { | |
throw new Error("Missing raw text"); | |
} | |
value = '' + value || ''; | |
child = new XMLFragment(this, '', {}, value); | |
this.children.push(child); | |
return this; | |
}; | |
XMLFragment.prototype.up = function() { | |
if (this.isRoot) { | |
throw new Error("This node has no parent. Use doc() if you need to get the document object."); | |
} | |
return this.parent; | |
}; | |
XMLFragment.prototype.root = function() { | |
var child; | |
if (this.isRoot) { | |
return this; | |
} | |
child = this.parent; | |
while (!child.isRoot) { | |
child = child.parent; | |
} | |
return child; | |
}; | |
XMLFragment.prototype.document = function() { | |
return this.root().documentObject; | |
}; | |
XMLFragment.prototype.end = function(options) { | |
return this.document().toString(options); | |
}; | |
XMLFragment.prototype.prev = function() { | |
var i; | |
if (this.isRoot) { | |
throw new Error("Root node has no siblings"); | |
} | |
i = this.parent.children.indexOf(this); | |
if (i < 1) { | |
throw new Error("Already at the first node"); | |
} | |
return this.parent.children[i - 1]; | |
}; | |
XMLFragment.prototype.next = function() { | |
var i; | |
if (this.isRoot) { | |
throw new Error("Root node has no siblings"); | |
} | |
i = this.parent.children.indexOf(this); | |
if (i === -1 || i === this.parent.children.length - 1) { | |
throw new Error("Already at the last node"); | |
} | |
return this.parent.children[i + 1]; | |
}; | |
XMLFragment.prototype.clone = function(deep) { | |
var clonedSelf; | |
clonedSelf = new XMLFragment(this.parent, this.name, this.attributes, this.value); | |
if (deep) { | |
this.children.forEach(function(child) { | |
var clonedChild; | |
clonedChild = child.clone(deep); | |
clonedChild.parent = clonedSelf; | |
return clonedSelf.children.push(clonedChild); | |
}); | |
} | |
return clonedSelf; | |
}; | |
XMLFragment.prototype.importXMLBuilder = function(xmlbuilder) { | |
var clonedRoot; | |
clonedRoot = xmlbuilder.root().clone(true); | |
clonedRoot.parent = this; | |
this.children.push(clonedRoot); | |
clonedRoot.isRoot = false; | |
return this; | |
}; | |
XMLFragment.prototype.attribute = function(name, value) { | |
var _ref; | |
if (!(name != null)) { | |
throw new Error("Missing attribute name"); | |
} | |
if (!(value != null)) { | |
throw new Error("Missing attribute value"); | |
} | |
name = '' + name || ''; | |
value = '' + value || ''; | |
if ((_ref = this.attributes) == null) { | |
this.attributes = {}; | |
} | |
this.attributes[name] = this.escape(value); | |
return this; | |
}; | |
XMLFragment.prototype.removeAttribute = function(name) { | |
if (!(name != null)) { | |
throw new Error("Missing attribute name"); | |
} | |
name = '' + name || ''; | |
delete this.attributes[name]; | |
return this; | |
}; | |
XMLFragment.prototype.toString = function(options, level) { | |
var attName, attValue, child, indent, newline, pretty, r, space, _i, _len, _ref, _ref1; | |
pretty = (options != null) && options.pretty || false; | |
indent = (options != null) && options.indent || ' '; | |
newline = (options != null) && options.newline || '\n'; | |
level || (level = 0); | |
space = new Array(level + 1).join(indent); | |
r = ''; | |
if (pretty) { | |
r += space; | |
} | |
if (!(this.value != null)) { | |
r += '<' + this.name; | |
} else { | |
r += '' + this.value; | |
} | |
_ref = this.attributes; | |
for (attName in _ref) { | |
attValue = _ref[attName]; | |
if (this.name === '!DOCTYPE') { | |
r += ' ' + attValue; | |
} else { | |
r += ' ' + attName + '="' + attValue + '"'; | |
} | |
} | |
if (this.children.length === 0) { | |
if (!(this.value != null)) { | |
r += this.name === '?xml' ? '?>' : this.name === '!DOCTYPE' ? '>' : '/>'; | |
} | |
if (pretty) { | |
r += newline; | |
} | |
} else if (pretty && this.children.length === 1 && this.children[0].value) { | |
r += '>'; | |
r += this.children[0].value; | |
r += '</' + this.name + '>'; | |
r += newline; | |
} else { | |
r += '>'; | |
if (pretty) { | |
r += newline; | |
} | |
_ref1 = this.children; | |
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | |
child = _ref1[_i]; | |
r += child.toString(options, level + 1); | |
} | |
if (pretty) { | |
r += space; | |
} | |
r += '</' + this.name + '>'; | |
if (pretty) { | |
r += newline; | |
} | |
} | |
return r; | |
}; | |
XMLFragment.prototype.escape = function(str) { | |
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/'/g, ''').replace(/"/g, '"'); | |
}; | |
XMLFragment.prototype.assertLegalChar = function(str) { | |
var chars, chr; | |
chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/; | |
chr = str.match(chars); | |
if (chr) { | |
throw new Error("Invalid character (" + chr + ") in string: " + str); | |
} | |
}; | |
XMLFragment.prototype.is = function(obj, type) { | |
var clas; | |
clas = Object.prototype.toString.call(obj).slice(8, -1); | |
return (obj != null) && clas === type; | |
}; | |
XMLFragment.prototype.ele = function(name, attributes, text) { | |
return this.element(name, attributes, text); | |
}; | |
XMLFragment.prototype.txt = function(value) { | |
return this.text(value); | |
}; | |
XMLFragment.prototype.dat = function(value) { | |
return this.cdata(value); | |
}; | |
XMLFragment.prototype.att = function(name, value) { | |
return this.attribute(name, value); | |
}; | |
XMLFragment.prototype.com = function(value) { | |
return this.comment(value); | |
}; | |
XMLFragment.prototype.doc = function() { | |
return this.document(); | |
}; | |
XMLFragment.prototype.e = function(name, attributes, text) { | |
return this.element(name, attributes, text); | |
}; | |
XMLFragment.prototype.t = function(value) { | |
return this.text(value); | |
}; | |
XMLFragment.prototype.d = function(value) { | |
return this.cdata(value); | |
}; | |
XMLFragment.prototype.a = function(name, value) { | |
return this.attribute(name, value); | |
}; | |
XMLFragment.prototype.c = function(value) { | |
return this.comment(value); | |
}; | |
XMLFragment.prototype.r = function(value) { | |
return this.raw(value); | |
}; | |
XMLFragment.prototype.u = function() { | |
return this.up(); | |
}; | |
return XMLFragment; | |
})(); | |
module.exports = XMLFragment; | |
}).call(this); | |
},{}],72:[function(require,module,exports){ | |
(function() { | |
var XMLBuilder; | |
XMLBuilder = require('./XMLBuilder'); | |
module.exports.create = function(name, xmldec, doctype) { | |
if (name != null) { | |
return new XMLBuilder(name, xmldec, doctype).root(); | |
} else { | |
return new XMLBuilder(); | |
} | |
}; | |
}).call(this); | |
},{"./XMLBuilder":70}]},{},[31]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AWS SDK for JavaScript v2.0.0-rc8.fix-gh-207 | |
// Copyright 2012-2014 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){},{}],2:[function(e,t,r){var n=e("buffer").Buffer;var i=4;var s=new n(i);s.fill(0);var a=8;function o(e,t){if(e.length%i!==0){var r=e.length+(i-e.length%i);e=n.concat([e,s],r)}var a=[];var o=t?e.readInt32BE:e.readInt32LE;for(var u=0;u<e.length;u+=i){a.push(o.call(e,u))}return a}function u(e,t,r){var i=new n(t);var s=r?i.writeInt32BE:i.writeInt32LE;for(var a=0;a<e.length;a++){s.call(i,e[a],a*4,true)}return i}function c(e,t,r,i){if(!n.isBuffer(e))e=new n(e);var s=t(o(e,i),e.length*a);return u(s,r,i)}t.exports={hash:c}},{buffer:12}],3:[function(e,t,r){var n=e("buffer").Buffer;var i=e("./sha");var s=e("./sha256");var a=e("./rng");var o=e("./md5");var u={sha1:i,sha256:s,md5:o};var c=64;var l=new n(c);l.fill(0);function p(e,t,r){if(!n.isBuffer(t))t=new n(t);if(!n.isBuffer(r))r=new n(r);if(t.length>c){t=e(t)}else if(t.length<c){t=n.concat([t,l],c)}var i=new n(c),s=new n(c);for(var a=0;a<c;a++){i[a]=t[a]^54;s[a]=t[a]^92}var o=e(n.concat([i,r]));return e(n.concat([s,o]))}function f(e,t){e=e||"sha1";var r=u[e];var i=[];var s=0;if(!r)m("algorithm:",e,"is not yet supported");return{update:function(e){if(!n.isBuffer(e))e=new n(e);i.push(e);s+=e.length;return this},digest:function(e){var s=n.concat(i);var a=t?p(r,t,s):r(s);i=null;return e?a.toString(e):a}}}function m(){var e=[].slice.call(arguments).join(" ");throw new Error([e,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}r.createHash=function(e){return f(e)};r.createHmac=function(e,t){return f(e,t)};r.randomBytes=function(e,t){if(t&&t.call){try{t.call(this,undefined,new n(a(e)))}catch(r){t(r)}}else{return new n(a(e))}};function d(e,t){for(var r in e)t(e[r],r)}d(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],function(e){r[e]=function(){m("sorry,",e,"is not implemented yet")}})},{"./md5":4,"./rng":5,"./sha":6,"./sha256":7,buffer:12}],4:[function(e,t,r){var n=e("./helpers");function i(){return hex_md5("abc")=="900150983cd24fb0d6963f7d28e17f72"}function s(e,t){e[t>>5]|=128<<t%32;e[(t+64>>>9<<4)+14]=t;var r=1732584193;var n=-271733879;var i=-1732584194;var s=271733878;for(var a=0;a<e.length;a+=16){var f=r;var m=n;var d=i;var h=s;r=o(r,n,i,s,e[a+0],7,-680876936);s=o(s,r,n,i,e[a+1],12,-389564586);i=o(i,s,r,n,e[a+2],17,606105819);n=o(n,i,s,r,e[a+3],22,-1044525330);r=o(r,n,i,s,e[a+4],7,-176418897);s=o(s,r,n,i,e[a+5],12,1200080426);i=o(i,s,r,n,e[a+6],17,-1473231341);n=o(n,i,s,r,e[a+7],22,-45705983);r=o(r,n,i,s,e[a+8],7,1770035416);s=o(s,r,n,i,e[a+9],12,-1958414417);i=o(i,s,r,n,e[a+10],17,-42063);n=o(n,i,s,r,e[a+11],22,-1990404162);r=o(r,n,i,s,e[a+12],7,1804603682);s=o(s,r,n,i,e[a+13],12,-40341101);i=o(i,s,r,n,e[a+14],17,-1502002290);n=o(n,i,s,r,e[a+15],22,1236535329);r=u(r,n,i,s,e[a+1],5,-165796510);s=u(s,r,n,i,e[a+6],9,-1069501632);i=u(i,s,r,n,e[a+11],14,643717713);n=u(n,i,s,r,e[a+0],20,-373897302);r=u(r,n,i,s,e[a+5],5,-701558691);s=u(s,r,n,i,e[a+10],9,38016083);i=u(i,s,r,n,e[a+15],14,-660478335);n=u(n,i,s,r,e[a+4],20,-405537848);r=u(r,n,i,s,e[a+9],5,568446438);s=u(s,r,n,i,e[a+14],9,-1019803690);i=u(i,s,r,n,e[a+3],14,-187363961);n=u(n,i,s,r,e[a+8],20,1163531501);r=u(r,n,i,s,e[a+13],5,-1444681467);s=u(s,r,n,i,e[a+2],9,-51403784);i=u(i,s,r,n,e[a+7],14,1735328473);n=u(n,i,s,r,e[a+12],20,-1926607734);r=c(r,n,i,s,e[a+5],4,-378558);s=c(s,r,n,i,e[a+8],11,-2022574463);i=c(i,s,r,n,e[a+11],16,1839030562);n=c(n,i,s,r,e[a+14],23,-35309556);r=c(r,n,i,s,e[a+1],4,-1530992060);s=c(s,r,n,i,e[a+4],11,1272893353);i=c(i,s,r,n,e[a+7],16,-155497632);n=c(n,i,s,r,e[a+10],23,-1094730640);r=c(r,n,i,s,e[a+13],4,681279174);s=c(s,r,n,i,e[a+0],11,-358537222);i=c(i,s,r,n,e[a+3],16,-722521979);n=c(n,i,s,r,e[a+6],23,76029189);r=c(r,n,i,s,e[a+9],4,-640364487);s=c(s,r,n,i,e[a+12],11,-421815835);i=c(i,s,r,n,e[a+15],16,530742520);n=c(n,i,s,r,e[a+2],23,-995338651);r=l(r,n,i,s,e[a+0],6,-198630844);s=l(s,r,n,i,e[a+7],10,1126891415);i=l(i,s,r,n,e[a+14],15,-1416354905);n=l(n,i,s,r,e[a+5],21,-57434055);r=l(r,n,i,s,e[a+12],6,1700485571);s=l(s,r,n,i,e[a+3],10,-1894986606);i=l(i,s,r,n,e[a+10],15,-1051523);n=l(n,i,s,r,e[a+1],21,-2054922799);r=l(r,n,i,s,e[a+8],6,1873313359);s=l(s,r,n,i,e[a+15],10,-30611744);i=l(i,s,r,n,e[a+6],15,-1560198380);n=l(n,i,s,r,e[a+13],21,1309151649);r=l(r,n,i,s,e[a+4],6,-145523070);s=l(s,r,n,i,e[a+11],10,-1120210379);i=l(i,s,r,n,e[a+2],15,718787259);n=l(n,i,s,r,e[a+9],21,-343485551);r=p(r,f);n=p(n,m);i=p(i,d);s=p(s,h)}return Array(r,n,i,s)}function a(e,t,r,n,i,s){return p(f(p(p(t,e),p(n,s)),i),r)}function o(e,t,r,n,i,s,o){return a(t&r|~t&n,e,t,i,s,o)}function u(e,t,r,n,i,s,o){return a(t&n|r&~n,e,t,i,s,o)}function c(e,t,r,n,i,s,o){return a(t^r^n,e,t,i,s,o)}function l(e,t,r,n,i,s,o){return a(r^(t|~n),e,t,i,s,o)}function p(e,t){var r=(e&65535)+(t&65535);var n=(e>>16)+(t>>16)+(r>>16);return n<<16|r&65535}function f(e,t){return e<<t|e>>>32-t}t.exports=function m(e){return n.hash(e,s,16)}},{"./helpers":2}],5:[function(e,t,r){(function(){var e=this;var r,n;r=function(e){var t=new Array(e);var r;for(var n=0,r;n<e;n++){if((n&3)==0)r=Math.random()*4294967296;t[n]=r>>>((n&3)<<3)&255}return t};if(e.crypto&&crypto.getRandomValues){n=function(e){var t=new Uint8Array(e);crypto.getRandomValues(t);return t}}t.exports=n||r})()},{}],6:[function(e,t,r){var n=e("./helpers");function i(e,t){e[t>>5]|=128<<24-t%32;e[(t+64>>9<<4)+15]=t;var r=Array(80);var n=1732584193;var i=-271733879;var c=-1732584194;var l=271733878;var p=-1009589776;for(var f=0;f<e.length;f+=16){var m=n;var d=i;var h=c;var y=l;var b=p;for(var g=0;g<80;g++){if(g<16)r[g]=e[f+g];else r[g]=u(r[g-3]^r[g-8]^r[g-14]^r[g-16],1);var v=o(o(u(n,5),s(g,i,c,l)),o(o(p,r[g]),a(g)));p=l;l=c;c=u(i,30);i=n;n=v}n=o(n,m);i=o(i,d);c=o(c,h);l=o(l,y);p=o(p,b)}return Array(n,i,c,l,p)}function s(e,t,r,n){if(e<20)return t&r|~t&n;if(e<40)return t^r^n;if(e<60)return t&r|t&n|r&n;return t^r^n}function a(e){return e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514}function o(e,t){var r=(e&65535)+(t&65535);var n=(e>>16)+(t>>16)+(r>>16);return n<<16|r&65535}function u(e,t){return e<<t|e>>>32-t}t.exports=function c(e){return n.hash(e,i,20,true)}},{"./helpers":2}],7:[function(e,t,r){var n=e("./helpers");var i=function(e,t){var r=(e&65535)+(t&65535);var n=(e>>16)+(t>>16)+(r>>16);return n<<16|r&65535};var s=function(e,t){return e>>>t|e<<32-t};var a=function(e,t){return e>>>t};var o=function(e,t,r){return e&t^~e&r};var u=function(e,t,r){return e&t^e&r^t&r};var c=function(e){return s(e,2)^s(e,13)^s(e,22)};var l=function(e){return s(e,6)^s(e,11)^s(e,25)};var p=function(e){return s(e,7)^s(e,18)^a(e,3)};var f=function(e){return s(e,17)^s(e,19)^a(e,10)};var m=function(e,t){var r=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298);var n=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225);var s=new Array(64);var a,m,d,h,y,b,g,v,E,w;var S,T;e[t>>5]|=128<<24-t%32;e[(t+64>>9<<4)+15]=t;for(var E=0;E<e.length;E+=16){a=n[0];m=n[1];d=n[2];h=n[3];y=n[4];b=n[5];g=n[6];v=n[7];for(var w=0;w<64;w++){if(w<16){s[w]=e[w+E]}else{s[w]=i(i(i(f(s[w-2]),s[w-7]),p(s[w-15])),s[w-16])}S=i(i(i(i(v,l(y)),o(y,b,g)),r[w]),s[w]);T=i(c(a),u(a,m,d));v=g;g=b;b=y;y=i(h,S);h=d;d=m;m=a;a=i(S,T)}n[0]=i(a,n[0]);n[1]=i(m,n[1]);n[2]=i(d,n[2]);n[3]=i(h,n[3]);n[4]=i(y,n[4]);n[5]=i(b,n[5]);n[6]=i(g,n[6]);n[7]=i(v,n[7])}return n};t.exports=function d(e){return n.hash(e,m,32,true)}},{"./helpers":2}],8:[function(e,t,r){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=n;n.EventEmitter=n;n.prototype._events=undefined;n.prototype._maxListeners=undefined;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(e){if(!s(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};n.prototype.emit=function(e){var t,r,n,s,u,c;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||a(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}else{throw TypeError('Uncaught, unspecified "error" event.')}return false}}r=this._events[e];if(o(r))return false;if(i(r)){switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=arguments.length;s=new Array(n-1);for(u=1;u<n;u++)s[u-1]=arguments[u];r.apply(this,s)}}else if(a(r)){n=arguments.length;s=new Array(n-1);for(u=1;u<n;u++)s[u-1]=arguments[u];c=r.slice();n=c.length;for(u=0;u<n;u++)c[u].apply(this,s)}return true};n.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,i(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(a(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(a(this._events[e])&&!this._events[e].warned){var r;if(!o(this._maxListeners)){r=this._maxListeners}else{r=n.defaultMaxListeners}if(r&&r>0&&this._events[e].length>r){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);console.trace()}}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=false;function n(){this.removeListener(e,n);if(!r){r=true;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var r,n,s,o;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];s=r.length;n=-1;if(r===t||i(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(a(r)){for(o=s;o-->0;){if(r[o]===t||r[o].listener&&r[o].listener===t){n=o;break}}if(n<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(n,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}r=this._events[e];if(i(r)){this.removeListener(e,r)}else{while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};n.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(i(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};n.listenerCount=function(e,t){var r;if(!e._events||!e._events[t])r=0;else if(i(e._events[t]))r=1;else r=e._events[t].length;return r};function i(e){return typeof e==="function"}function s(e){return typeof e==="number"}function a(e){return typeof e==="object"&&e!==null}function o(e){return e===void 0}},{}],9:[function(e,t,r){if(typeof Object.create==="function"){t.exports=function n(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{t.exports=function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},{}],10:[function(e,t,r){e=function n(t,r,i){function s(o,u){if(!r[o]){if(!t[o]){var c=typeof e=="function"&&e;if(!u&&c)return c(o,!0);if(a)return a(o,!0);throw new Error("Cannot find module '"+o+"'")}var l=r[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return s(r?r:e)},l,l.exports,n,t,r,i)}return r[o].exports}var a=typeof e=="function"&&e;for(var o=0;o<i.length;o++)s(i[o]);return s}({PcZj9L:[function(e,t,r){var n=e("base64-js");var i=e("ieee754");r.Buffer=a;r.SlowBuffer=a;r.INSPECT_MAX_BYTES=50;a.poolSize=8192;var s=function(){if(typeof Uint8Array==="undefined"||typeof ArrayBuffer==="undefined"||typeof DataView==="undefined")return false;try{var e=new Uint8Array(0);e.foo=function(){return 42};return 42===e.foo()}catch(t){return false}}();function a(e,t,r){if(!(this instanceof a))return new a(e,t,r);var n=typeof e;if(t==="base64"&&n==="string"){e=N(e);while(e.length%4!==0){e=e+"="}}var i;if(n==="number")i=L(e);else if(n==="string")i=a.byteLength(e,t);else if(n==="object")i=L(e.length);else throw new Error("First argument needs to be a number, array or string.");var o;if(s){o=_(new Uint8Array(i))}else{o=this;o.length=i}var u;if(a.isBuffer(e)){o.set(e)}else if(M(e)){for(u=0;u<i;u++){if(a.isBuffer(e))o[u]=e.readUInt8(u);else o[u]=e[u]}}else if(n==="string"){o.write(e,0,t)}else if(n==="number"&&!s&&!r){for(u=0;u<i;u++){o[u]=0}}return o}a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":return true;default:return false}};a.isBuffer=function(e){return e&&e._isBuffer};a.byteLength=function(e,t){switch(t||"utf8"){case"hex":return e.length/2;case"utf8":case"utf-8":return U(e).length;case"ascii":case"binary":return e.length;case"base64":return z(e).length;default:throw new Error("Unknown encoding")}};a.concat=function(e,t){if(!D(e)){throw new Error("Usage: Buffer.concat(list, [totalLength])\n"+"list should be an Array.")}if(e.length===0){return new a(0)}else if(e.length===1){return e[0]}var r;if(typeof t!=="number"){t=0;for(r=0;r<e.length;r++){t+=e[r].length}}var n=new a(t);var i=0;for(r=0;r<e.length;r++){var s=e[r];s.copy(n,i);i+=s.length}return n};function o(e,t,r,n){r=Number(r)||0;var i=e.length-r;if(!n){n=i}else{n=Number(n);if(n>i){n=i}}var s=t.length;if(s%2!==0){throw new Error("Invalid hex string")}if(n>s/2){n=s/2}for(var o=0;o<n;o++){var u=parseInt(t.substr(o*2,2),16);if(isNaN(u))throw new Error("Invalid hex string");e[r+o]=u}a._charsWritten=o*2;return o}function u(e,t,r,n){var i,s;return a._charsWritten=V(U(t),e,r,n)}function c(e,t,r,n){var i,s;return a._charsWritten=V(O(t),e,r,n)}function l(e,t,r,n){return c(e,t,r,n)}function p(e,t,r,n){var i,s;return a._charsWritten=V(z(t),e,r,n)}a.prototype.write=function(e,t,r,n){if(isFinite(t)){if(!isFinite(r)){n=r;r=undefined}}else{var i=n;n=t;t=r;r=i}t=Number(t)||0;var s=this.length-t;if(!r){r=s}else{r=Number(r);if(r>s){r=s}}n=String(n||"utf8").toLowerCase();switch(n){case"hex":return o(this,e,t,r);case"utf8":case"utf-8":return u(this,e,t,r);case"ascii":return c(this,e,t,r);case"binary":return l(this,e,t,r);case"base64":return p(this,e,t,r);default:throw new Error("Unknown encoding")}};a.prototype.toString=function(e,t,r){var n=this;e=String(e||"utf8").toLowerCase();t=Number(t)||0;r=r!==undefined?Number(r):r=n.length;if(r===t)return"";switch(e){case"hex":return y(n,t,r);case"utf8":case"utf-8":return m(n,t,r);case"ascii":return d(n,t,r);case"binary":return h(n,t,r);case"base64":return f(n,t,r);default:throw new Error("Unknown encoding")}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};a.prototype.copy=function(e,t,r,n){var i=this;if(!r)r=0;if(!n&&n!==0)n=this.length;if(!t)t=0;if(n===r)return;if(e.length===0||i.length===0)return;if(n<r)throw new Error("sourceEnd < sourceStart");if(t<0||t>=e.length)throw new Error("targetStart out of bounds");if(r<0||r>=i.length)throw new Error("sourceStart out of bounds");if(n<0||n>i.length)throw new Error("sourceEnd out of bounds");if(n>this.length)n=this.length;if(e.length-t<n-r)n=e.length-t+r;for(var s=0;s<n-r;s++)e[s+t]=this[s+r]};function f(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function m(e,t,r){var n="";var i="";r=Math.min(e.length,r);for(var s=t;s<r;s++){if(e[s]<=127){n+=K(i)+String.fromCharCode(e[s]);i=""}else{i+="%"+e[s].toString(16)}}return n+K(i)}function d(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++)n+=String.fromCharCode(e[i]);return n}function h(e,t,r){return d(e,t,r)}function y(e,t,r){var n=e.length;if(!t||t<0)t=0;if(!r||r<0||r>n)r=n;var i="";for(var s=t;s<r;s++){i+=P(e[s])}return i}a.prototype.slice=function(e,t){var r=this.length;e=q(e,r,0);t=q(t,r,r);if(s){return _(this.subarray(e,t))}else{var n=t-e;var i=new a(n,undefined,true);for(var o=0;o<n;o++){i[o]=this[o+e]}return i}};a.prototype.readUInt8=function(e,t){var r=this;if(!t){F(e!==undefined&&e!==null,"missing offset");F(e<r.length,"Trying to read beyond buffer length")}if(e>=r.length)return;return r[e]};function b(e,t,r,n){if(!n){F(typeof r==="boolean","missing or invalid endian");F(t!==undefined&&t!==null,"missing offset");F(t+1<e.length,"Trying to read beyond buffer length")}var i=e.length;if(t>=i)return;if(s){if(t+1<i){return e._dataview.getUint16(t,r)}else{var a=new DataView(new ArrayBuffer(2));a.setUint8(0,e[i-1]);return a.getUint16(0,r)}}else{var o;if(r){o=e[t];if(t+1<i)o|=e[t+1]<<8}else{o=e[t]<<8;if(t+1<i)o|=e[t+1]}return o}}a.prototype.readUInt16LE=function(e,t){return b(this,e,true,t)};a.prototype.readUInt16BE=function(e,t){return b(this,e,false,t)};function g(e,t,r,n){if(!n){F(typeof r==="boolean","missing or invalid endian");F(t!==undefined&&t!==null,"missing offset");F(t+3<e.length,"Trying to read beyond buffer length")}var i=e.length;if(t>=i)return;if(s){if(t+3<i){return e._dataview.getUint32(t,r)}else{var a=new DataView(new ArrayBuffer(4));for(var o=0;o+t<i;o++){a.setUint8(o,e[o+t])}return a.getUint32(0,r)}}else{var u;if(r){if(t+2<i)u=e[t+2]<<16;if(t+1<i)u|=e[t+1]<<8;u|=e[t];if(t+3<i)u=u+(e[t+3]<<24>>>0)}else{if(t+1<i)u=e[t+1]<<16;if(t+2<i)u|=e[t+2]<<8;if(t+3<i)u|=e[t+3];u=u+(e[t]<<24>>>0)}return u}}a.prototype.readUInt32LE=function(e,t){return g(this,e,true,t)};a.prototype.readUInt32BE=function(e,t){return g(this,e,false,t)};a.prototype.readInt8=function(e,t){var r=this;if(!t){F(e!==undefined&&e!==null,"missing offset");F(e<r.length,"Trying to read beyond buffer length")}if(e>=r.length)return;if(s){return r._dataview.getInt8(e)}else{var n=r[e]&128;if(n)return(255-r[e]+1)*-1;else return r[e]}};function v(e,t,r,n){if(!n){F(typeof r==="boolean","missing or invalid endian");F(t!==undefined&&t!==null,"missing offset");F(t+1<e.length,"Trying to read beyond buffer length")}var i=e.length;if(t>=i)return;if(s){if(t+1===i){var a=new DataView(new ArrayBuffer(2));a.setUint8(0,e[i-1]);return a.getInt16(0,r)}else{return e._dataview.getInt16(t,r)}}else{var o=b(e,t,r,true);var u=o&32768;if(u)return(65535-o+1)*-1;else return o}}a.prototype.readInt16LE=function(e,t){return v(this,e,true,t)};a.prototype.readInt16BE=function(e,t){return v(this,e,false,t)};function E(e,t,r,n){if(!n){F(typeof r==="boolean","missing or invalid endian");F(t!==undefined&&t!==null,"missing offset");F(t+3<e.length,"Trying to read beyond buffer length")}var i=e.length;if(t>=i)return;if(s){if(t+3>=i){var a=new DataView(new ArrayBuffer(4));for(var o=0;o+t<i;o++){a.setUint8(o,e[o+t])}return a.getInt32(0,r)}else{return e._dataview.getInt32(t,r)}}else{var u=g(e,t,r,true);var c=u&2147483648;if(c)return(4294967295-u+1)*-1;else return u}}a.prototype.readInt32LE=function(e,t){return E(this,e,true,t)};a.prototype.readInt32BE=function(e,t){return E(this,e,false,t)};function w(e,t,r,n){if(!n){F(typeof r==="boolean","missing or invalid endian");F(t+3<e.length,"Trying to read beyond buffer length")}if(s){return e._dataview.getFloat32(t,r)}else{return i.read(e,t,r,23,4)}}a.prototype.readFloatLE=function(e,t){return w(this,e,true,t)};a.prototype.readFloatBE=function(e,t){return w(this,e,false,t)};function S(e,t,r,n){if(!n){F(typeof r==="boolean","missing or invalid endian");F(t+7<e.length,"Trying to read beyond buffer length")}if(s){return e._dataview.getFloat64(t,r)}else{return i.read(e,t,r,52,8)}}a.prototype.readDoubleLE=function(e,t){return S(this,e,true,t)};a.prototype.readDoubleBE=function(e,t){return S(this,e,false,t)};a.prototype.writeUInt8=function(e,t,r){var n=this;if(!r){F(e!==undefined&&e!==null,"missing value");F(t!==undefined&&t!==null,"missing offset");F(t<n.length,"trying to write beyond buffer length");G(e,255)}if(t>=n.length)return;n[t]=e};function T(e,t,r,n,i){if(!i){F(t!==undefined&&t!==null,"missing value");F(typeof n==="boolean","missing or invalid endian");F(r!==undefined&&r!==null,"missing offset");F(r+1<e.length,"trying to write beyond buffer length");G(t,65535)}var a=e.length;if(r>=a)return;if(s){if(r+1===a){var o=new DataView(new ArrayBuffer(2));o.setUint16(0,t,n);e[r]=o.getUint8(0)}else{e._dataview.setUint16(r,t,n)}}else{for(var u=0,c=Math.min(a-r,2);u<c;u++){e[r+u]=(t&255<<8*(n?u:1-u))>>>(n?u:1-u)*8}}}a.prototype.writeUInt16LE=function(e,t,r){T(this,e,t,true,r)};a.prototype.writeUInt16BE=function(e,t,r){T(this,e,t,false,r)};function C(e,t,r,n,i){if(!i){F(t!==undefined&&t!==null,"missing value");F(typeof n==="boolean","missing or invalid endian");F(r!==undefined&&r!==null,"missing offset");F(r+3<e.length,"trying to write beyond buffer length");G(t,4294967295)}var a=e.length;if(r>=a)return;var o;if(s){if(r+3>=a){var u=new DataView(new ArrayBuffer(4));u.setUint32(0,t,n);for(o=0;o+r<a;o++){e[o+r]=u.getUint8(o)}}else{e._dataview.setUint32(r,t,n)}}else{for(o=0,j=Math.min(a-r,4);o<j;o++){e[r+o]=t>>>(n?o:3-o)*8&255}}}a.prototype.writeUInt32LE=function(e,t,r){C(this,e,t,true,r)};a.prototype.writeUInt32BE=function(e,t,r){C(this,e,t,false,r)};a.prototype.writeInt8=function(e,t,r){var n=this;if(!r){F(e!==undefined&&e!==null,"missing value");F(t!==undefined&&t!==null,"missing offset");F(t<n.length,"Trying to write beyond buffer length");H(e,127,-128)}if(t>=n.length)return;if(s){n._dataview.setInt8(t,e)}else{if(e>=0)n.writeUInt8(e,t,r);else n.writeUInt8(255+e+1,t,r)}};function A(e,t,r,n,i){if(!i){F(t!==undefined&&t!==null,"missing value");F(typeof n==="boolean","missing or invalid endian");F(r!==undefined&&r!==null,"missing offset");F(r+1<e.length,"Trying to write beyond buffer length");H(t,32767,-32768)}var a=e.length;if(r>=a)return;if(s){if(r+1===a){var o=new DataView(new ArrayBuffer(2));o.setInt16(0,t,n);e[r]=o.getUint8(0)}else{e._dataview.setInt16(r,t,n)}}else{if(t>=0)T(e,t,r,n,i);else T(e,65535+t+1,r,n,i)}}a.prototype.writeInt16LE=function(e,t,r){A(this,e,t,true,r)};a.prototype.writeInt16BE=function(e,t,r){A(this,e,t,false,r)};function x(e,t,r,n,i){if(!i){F(t!==undefined&&t!==null,"missing value");F(typeof n==="boolean","missing or invalid endian");F(r!==undefined&&r!==null,"missing offset");F(r+3<e.length,"Trying to write beyond buffer length");H(t,2147483647,-2147483648)}var a=e.length;if(r>=a)return;if(s){if(r+3>=a){var o=new DataView(new ArrayBuffer(4));o.setInt32(0,t,n);for(var u=0;u+r<a;u++){e[u+r]=o.getUint8(u)}}else{e._dataview.setInt32(r,t,n)}}else{if(t>=0)C(e,t,r,n,i);else C(e,4294967295+t+1,r,n,i)}}a.prototype.writeInt32LE=function(e,t,r){x(this,e,t,true,r)};a.prototype.writeInt32BE=function(e,t,r){x(this,e,t,false,r)};function I(e,t,r,n,a){if(!a){F(t!==undefined&&t!==null,"missing value");F(typeof n==="boolean","missing or invalid endian");F(r!==undefined&&r!==null,"missing offset");F(r+3<e.length,"Trying to write beyond buffer length");W(t,3.4028234663852886e38,-3.4028234663852886e38)}var o=e.length;if(r>=o)return;if(s){if(r+3>=o){var u=new DataView(new ArrayBuffer(4));u.setFloat32(0,t,n);for(var c=0;c+r<o;c++){e[c+r]=u.getUint8(c)}}else{e._dataview.setFloat32(r,t,n)}}else{i.write(e,t,r,n,23,4)}}a.prototype.writeFloatLE=function(e,t,r){I(this,e,t,true,r)};a.prototype.writeFloatBE=function(e,t,r){I(this,e,t,false,r)};function R(e,t,r,n,a){if(!a){F(t!==undefined&&t!==null,"missing value");F(typeof n==="boolean","missing or invalid endian");F(r!==undefined&&r!==null,"missing offset");F(r+7<e.length,"Trying to write beyond buffer length");W(t,1.7976931348623157e308,-1.7976931348623157e308)}var o=e.length;if(r>=o)return;if(s){if(r+7>=o){var u=new DataView(new ArrayBuffer(8));u.setFloat64(0,t,n);for(var c=0;c+r<o;c++){e[c+r]=u.getUint8(c)}}else{e._dataview.setFloat64(r,t,n)}}else{i.write(e,t,r,n,52,8)}}a.prototype.writeDoubleLE=function(e,t,r){R(this,e,t,true,r)};a.prototype.writeDoubleBE=function(e,t,r){R(this,e,t,false,r)};a.prototype.fill=function(e,t,r){if(!e)e=0;if(!t)t=0;if(!r)r=this.length;if(typeof e==="string"){e=e.charCodeAt(0)}if(typeof e!=="number"||isNaN(e)){throw new Error("value is not a number")}if(r<t)throw new Error("end < start");if(r===t)return;if(this.length===0)return;if(t<0||t>=this.length){throw new Error("start out of bounds")}if(r<0||r>this.length){throw new Error("end out of bounds")}for(var n=t;n<r;n++){this[n]=e}};a.prototype.inspect=function(){var e=[];var t=this.length;for(var n=0;n<t;n++){e[n]=P(this[n]);if(n===r.INSPECT_MAX_BYTES){e[n+1]="...";break}}return"<Buffer "+e.join(" ")+">"};function k(){return new a(this).buffer}function N(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}var B=a.prototype;function _(e){e._isBuffer=true;e.write=B.write;e.toString=B.toString;e.toLocaleString=B.toString;e.toJSON=B.toJSON;e.copy=B.copy;e.slice=B.slice;e.readUInt8=B.readUInt8;e.readUInt16LE=B.readUInt16LE;e.readUInt16BE=B.readUInt16BE;e.readUInt32LE=B.readUInt32LE;e.readUInt32BE=B.readUInt32BE;e.readInt8=B.readInt8;e.readInt16LE=B.readInt16LE;e.readInt16BE=B.readInt16BE;e.readInt32LE=B.readInt32LE;e.readInt32BE=B.readInt32BE;e.readFloatLE=B.readFloatLE;e.readFloatBE=B.readFloatBE;e.readDoubleLE=B.readDoubleLE;e.readDoubleBE=B.readDoubleBE;e.writeUInt8=B.writeUInt8;e.writeUInt16LE=B.writeUInt16LE;e.writeUInt16BE=B.writeUInt16BE;e.writeUInt32LE=B.writeUInt32LE;e.writeUInt32BE=B.writeUInt32BE;e.writeInt8=B.writeInt8;e.writeInt16LE=B.writeInt16LE;e.writeInt16BE=B.writeInt16BE;e.writeInt32LE=B.writeInt32LE;e.writeInt32BE=B.writeInt32BE;e.writeFloatLE=B.writeFloatLE;e.writeFloatBE=B.writeFloatBE;e.writeDoubleLE=B.writeDoubleLE;e.writeDoubleBE=B.writeDoubleBE;e.fill=B.fill;e.inspect=B.inspect;e.toArrayBuffer=k;if(e.byteLength!==0)e._dataview=new DataView(e.buffer,e.byteOffset,e.byteLength);return e}function q(e,t,r){if(typeof e!=="number")return r;e=~~e;if(e>=t)return t;if(e>=0)return e;e+=t;if(e>=0)return e;return 0}function L(e){e=~~Math.ceil(+e);return e<0?0:e}function D(e){return(Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"})(e)}function M(e){return D(e)||a.isBuffer(e)||e&&typeof e==="object"&&typeof e.length==="number"}function P(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function U(e){var t=[];for(var r=0;r<e.length;r++)if(e.charCodeAt(r)<=127)t.push(e.charCodeAt(r));else{var n=encodeURIComponent(e.charAt(r)).substr(1).split("%");for(var i=0;i<n.length;i++)t.push(parseInt(n[i],16))}return t}function O(e){var t=[];for(var r=0;r<e.length;r++){t.push(e.charCodeAt(r)&255)}return t}function z(e){return n.toByteArray(e)}function V(e,t,r,n){var i;for(var s=0;s<n;s++){if(s+r>=t.length||s>=e.length)break;t[s+r]=e[s]}return s}function K(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}function G(e,t){F(typeof e=="number","cannot write a non-number as a number");F(e>=0,"specified a negative value for writing an unsigned value");F(e<=t,"value is larger than maximum value for type");F(Math.floor(e)===e,"value has a fractional component")}function H(e,t,r){F(typeof e=="number","cannot write a non-number as a number");F(e<=t,"value larger than maximum allowed value");F(e>=r,"value smaller than minimum allowed value");F(Math.floor(e)===e,"value has a fractional component")}function W(e,t,r){F(typeof e=="number","cannot write a non-number as a number");F(e<=t,"value larger than maximum allowed value");F(e>=r,"value smaller than minimum allowed value")}function F(e,t){if(!e)throw new Error(t||"Failed assertion")}},{"base64-js":3,ieee754:4}],"native-buffer-browserify":[function(e,t,r){t.exports=e("PcZj9L")},{}],3:[function(e,t,r){(function(e){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function i(e){var t,i,s,a,o,u;if(e.length%4>0){throw"Invalid string. Length must be a multiple of 4"}o=n(e,"=");o=o>0?e.length-o:0;u=[];s=o>0?e.length-4:e.length;for(t=0,i=0;t<s;t+=4,i+=3){a=n(r,e.charAt(t))<<18|n(r,e.charAt(t+1))<<12|n(r,e.charAt(t+2))<<6|n(r,e.charAt(t+3));u.push((a&16711680)>>16);u.push((a&65280)>>8);u.push(a&255)}if(o===2){a=n(r,e.charAt(t))<<2|n(r,e.charAt(t+1))>>4;u.push(a&255)}else if(o===1){a=n(r,e.charAt(t))<<10|n(r,e.charAt(t+1))<<4|n(r,e.charAt(t+2))>>2;u.push(a>>8&255);u.push(a&255)}return u}function s(e){var t,n=e.length%3,i="",s,a;function o(e){return r.charAt(e>>18&63)+r.charAt(e>>12&63)+r.charAt(e>>6&63)+r.charAt(e&63)}for(t=0,a=e.length-n;t<a;t+=3){s=(e[t]<<16)+(e[t+1]<<8)+e[t+2];i+=o(s)}switch(n){case 1:s=e[e.length-1];i+=r.charAt(s>>2);i+=r.charAt(s<<4&63);i+="==";break;case 2:s=(e[e.length-2]<<8)+e[e.length-1];i+=r.charAt(s>>10);i+=r.charAt(s>>4&63);i+=r.charAt(s<<2&63);i+="=";break}return i}t.exports.toByteArray=i;t.exports.fromByteArray=s})();function n(e,t){var r=e.length;var n=Number(arguments[1])||0;n=n<0?Math.ceil(n):Math.floor(n);if(n<0)n+=r;for(;n<r;n++){if(typeof e==="string"&&e.charAt(n)===t||typeof e!=="string"&&e[n]===t){return n}}return-1}},{}],4:[function(e,t,r){r.read=function(e,t,r,n,i){var s,a,o=i*8-n-1,u=(1<<o)-1,c=u>>1,l=-7,p=r?i-1:0,f=r?-1:1,m=e[t+p];p+=f;s=m&(1<<-l)-1;m>>=-l;l+=o;for(;l>0;s=s*256+e[t+p],p+=f,l-=8);a=s&(1<<-l)-1;s>>=-l;l+=n;for(;l>0;a=a*256+e[t+p],p+=f,l-=8);if(s===0){s=1-c}else if(s===u){return a?NaN:(m?-1:1)*Infinity}else{a=a+Math.pow(2,n);s=s-c}return(m?-1:1)*a*Math.pow(2,s-n)};r.write=function(e,t,r,n,i,s){var a,o,u,c=s*8-i-1,l=(1<<c)-1,p=l>>1,f=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=n?0:s-1,d=n?1:-1,h=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){o=isNaN(t)?1:0;a=l}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(u=Math.pow(2,-a))<1){a--;u*=2}if(a+p>=1){t+=f/u}else{t+=f*Math.pow(2,1-p)}if(t*u>=2){a++;u/=2}if(a+p>=l){o=0;a=l}else if(a+p>=1){o=(t*u-1)*Math.pow(2,i);a=a+p}else{o=t*Math.pow(2,p-1)*Math.pow(2,i);a=0}}for(;i>=8;e[r+m]=o&255,m+=d,o/=256,i-=8);a=a<<i|o;c+=i;for(;c>0;e[r+m]=a&255,m+=d,a/=256,c-=8);e[r+m-d]|=h*128}},{}]},{},[]);t.exports=e("native-buffer-browserify").Buffer},{}],11:[function(e,t,r){var n=t.exports={};n.nextTick=function(){var e=typeof window!=="undefined"&&window.setImmediate;var t=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(e){return function(e){return window.setImmediate(e)}}if(t){var r=[];window.addEventListener("message",function(e){var t=e.source;if((t===window||t===null)&&e.data==="process-tick"){e.stopPropagation();if(r.length>0){var n=r.shift();n()}}},true);return function n(e){r.push(e);window.postMessage("process-tick","*")}}return function i(e){setTimeout(e,0)}}();n.title="browser";n.browser=true;n.env={};n.argv=[];n.binding=function(e){throw new Error("process.binding is not supported")};n.cwd=function(){return"/"};n.chdir=function(e){throw new Error("process.chdir is not supported")}},{}],12:[function(e,t,r){var n=e("base64-js");var i=e("ieee754");r.Buffer=s;r.SlowBuffer=s; | |
r.INSPECT_MAX_BYTES=50;s.poolSize=8192;s._useTypedArrays=function(){if(typeof Uint8Array==="undefined"||typeof ArrayBuffer==="undefined")return false;try{var e=new Uint8Array(0);e.foo=function(){return 42};return 42===e.foo()&&typeof e.subarray==="function"}catch(t){return false}}();function s(e,t,r){if(!(this instanceof s))return new s(e,t,r);var n=typeof e;if(t==="base64"&&n==="string"){e=k(e);while(e.length%4!==0){e=e+"="}}var i;if(n==="number")i=q(e);else if(n==="string")i=s.byteLength(e,t);else if(n==="object")i=q(e.length);else throw new Error("First argument needs to be a number, array or string.");var a;if(s._useTypedArrays){a=B(new Uint8Array(i))}else{a=this;a.length=i;a._isBuffer=true}var o;if(typeof Uint8Array==="function"&&e instanceof Uint8Array){a.set(e)}else if(D(e)){for(o=0;o<i;o++){if(s.isBuffer(e))a[o]=e.readUInt8(o);else a[o]=e[o]}}else if(n==="string"){a.write(e,0,t)}else if(n==="number"&&!s._useTypedArrays&&!r){for(o=0;o<i;o++){a[o]=0}}return a}s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":return true;default:return false}};s.isBuffer=function(e){return e!=null&&e._isBuffer||false};s.byteLength=function(e,t){switch(t||"utf8"){case"hex":return e.length/2;case"utf8":case"utf-8":return P(e).length;case"ascii":case"binary":return e.length;case"base64":return O(e).length;default:throw new Error("Unknown encoding")}};s.concat=function(e,t){H(L(e),"Usage: Buffer.concat(list, [totalLength])\n"+"list should be an Array.");if(e.length===0){return new s(0)}else if(e.length===1){return e[0]}var r;if(typeof t!=="number"){t=0;for(r=0;r<e.length;r++){t+=e[r].length}}var n=new s(t);var i=0;for(r=0;r<e.length;r++){var a=e[r];a.copy(n,i);i+=a.length}return n};function a(e,t,r,n){r=Number(r)||0;var i=e.length-r;if(!n){n=i}else{n=Number(n);if(n>i){n=i}}var a=t.length;H(a%2===0,"Invalid hex string");if(n>a/2){n=a/2}for(var o=0;o<n;o++){var u=parseInt(t.substr(o*2,2),16);H(!isNaN(u),"Invalid hex string");e[r+o]=u}s._charsWritten=o*2;return o}function o(e,t,r,n){var i,a;return s._charsWritten=j(P(t),e,r,n)}function u(e,t,r,n){var i,a;return s._charsWritten=j(U(t),e,r,n)}function c(e,t,r,n){return u(e,t,r,n)}function l(e,t,r,n){var i,a;return s._charsWritten=j(O(t),e,r,n)}s.prototype.write=function(e,t,r,n){if(isFinite(t)){if(!isFinite(r)){n=r;r=undefined}}else{var i=n;n=t;t=r;r=i}t=Number(t)||0;var s=this.length-t;if(!r){r=s}else{r=Number(r);if(r>s){r=s}}n=String(n||"utf8").toLowerCase();switch(n){case"hex":return a(this,e,t,r);case"utf8":case"utf-8":return o(this,e,t,r);case"ascii":return u(this,e,t,r);case"binary":return c(this,e,t,r);case"base64":return l(this,e,t,r);default:throw new Error("Unknown encoding")}};s.prototype.toString=function(e,t,r){var n=this;e=String(e||"utf8").toLowerCase();t=Number(t)||0;r=r!==undefined?Number(r):r=n.length;if(r===t)return"";switch(e){case"hex":return h(n,t,r);case"utf8":case"utf-8":return f(n,t,r);case"ascii":return m(n,t,r);case"binary":return d(n,t,r);case"base64":return p(n,t,r);default:throw new Error("Unknown encoding")}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};s.prototype.copy=function(e,t,r,n){var i=this;if(!r)r=0;if(!n&&n!==0)n=this.length;if(!t)t=0;if(n===r)return;if(e.length===0||i.length===0)return;H(n>=r,"sourceEnd < sourceStart");H(t>=0&&t<e.length,"targetStart out of bounds");H(r>=0&&r<i.length,"sourceStart out of bounds");H(n>=0&&n<=i.length,"sourceEnd out of bounds");if(n>this.length)n=this.length;if(e.length-t<n-r)n=e.length-t+r;for(var s=0;s<n-r;s++)e[s+t]=this[s+r]};function p(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function f(e,t,r){var n="";var i="";r=Math.min(e.length,r);for(var s=t;s<r;s++){if(e[s]<=127){n+=z(i)+String.fromCharCode(e[s]);i=""}else{i+="%"+e[s].toString(16)}}return n+z(i)}function m(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++)n+=String.fromCharCode(e[i]);return n}function d(e,t,r){return m(e,t,r)}function h(e,t,r){var n=e.length;if(!t||t<0)t=0;if(!r||r<0||r>n)r=n;var i="";for(var s=t;s<r;s++){i+=M(e[s])}return i}s.prototype.slice=function(e,t){var r=this.length;e=_(e,r,0);t=_(t,r,r);if(s._useTypedArrays){return B(this.subarray(e,t))}else{var n=t-e;var i=new s(n,undefined,true);for(var a=0;a<n;a++){i[a]=this[a+e]}return i}};s.prototype.readUInt8=function(e,t){var r=this;if(!t){H(e!==undefined&&e!==null,"missing offset");H(e<r.length,"Trying to read beyond buffer length")}if(e>=r.length)return;return r[e]};function y(e,t,r,n){if(!n){H(typeof r==="boolean","missing or invalid endian");H(t!==undefined&&t!==null,"missing offset");H(t+1<e.length,"Trying to read beyond buffer length")}var i=e.length;if(t>=i)return;var s;if(r){s=e[t];if(t+1<i)s|=e[t+1]<<8}else{s=e[t]<<8;if(t+1<i)s|=e[t+1]}return s}s.prototype.readUInt16LE=function(e,t){return y(this,e,true,t)};s.prototype.readUInt16BE=function(e,t){return y(this,e,false,t)};function b(e,t,r,n){if(!n){H(typeof r==="boolean","missing or invalid endian");H(t!==undefined&&t!==null,"missing offset");H(t+3<e.length,"Trying to read beyond buffer length")}var i=e.length;if(t>=i)return;var s;if(r){if(t+2<i)s=e[t+2]<<16;if(t+1<i)s|=e[t+1]<<8;s|=e[t];if(t+3<i)s=s+(e[t+3]<<24>>>0)}else{if(t+1<i)s=e[t+1]<<16;if(t+2<i)s|=e[t+2]<<8;if(t+3<i)s|=e[t+3];s=s+(e[t]<<24>>>0)}return s}s.prototype.readUInt32LE=function(e,t){return b(this,e,true,t)};s.prototype.readUInt32BE=function(e,t){return b(this,e,false,t)};s.prototype.readInt8=function(e,t){var r=this;if(!t){H(e!==undefined&&e!==null,"missing offset");H(e<r.length,"Trying to read beyond buffer length")}if(e>=r.length)return;var n=r[e]&128;if(n)return(255-r[e]+1)*-1;else return r[e]};function g(e,t,r,n){if(!n){H(typeof r==="boolean","missing or invalid endian");H(t!==undefined&&t!==null,"missing offset");H(t+1<e.length,"Trying to read beyond buffer length")}var i=e.length;if(t>=i)return;var s=y(e,t,r,true);var a=s&32768;if(a)return(65535-s+1)*-1;else return s}s.prototype.readInt16LE=function(e,t){return g(this,e,true,t)};s.prototype.readInt16BE=function(e,t){return g(this,e,false,t)};function v(e,t,r,n){if(!n){H(typeof r==="boolean","missing or invalid endian");H(t!==undefined&&t!==null,"missing offset");H(t+3<e.length,"Trying to read beyond buffer length")}var i=e.length;if(t>=i)return;var s=b(e,t,r,true);var a=s&2147483648;if(a)return(4294967295-s+1)*-1;else return s}s.prototype.readInt32LE=function(e,t){return v(this,e,true,t)};s.prototype.readInt32BE=function(e,t){return v(this,e,false,t)};function E(e,t,r,n){if(!n){H(typeof r==="boolean","missing or invalid endian");H(t+3<e.length,"Trying to read beyond buffer length")}return i.read(e,t,r,23,4)}s.prototype.readFloatLE=function(e,t){return E(this,e,true,t)};s.prototype.readFloatBE=function(e,t){return E(this,e,false,t)};function w(e,t,r,n){if(!n){H(typeof r==="boolean","missing or invalid endian");H(t+7<e.length,"Trying to read beyond buffer length")}return i.read(e,t,r,52,8)}s.prototype.readDoubleLE=function(e,t){return w(this,e,true,t)};s.prototype.readDoubleBE=function(e,t){return w(this,e,false,t)};s.prototype.writeUInt8=function(e,t,r){var n=this;if(!r){H(e!==undefined&&e!==null,"missing value");H(t!==undefined&&t!==null,"missing offset");H(t<n.length,"trying to write beyond buffer length");V(e,255)}if(t>=n.length)return;n[t]=e};function S(e,t,r,n,i){if(!i){H(t!==undefined&&t!==null,"missing value");H(typeof n==="boolean","missing or invalid endian");H(r!==undefined&&r!==null,"missing offset");H(r+1<e.length,"trying to write beyond buffer length");V(t,65535)}var s=e.length;if(r>=s)return;for(var a=0,o=Math.min(s-r,2);a<o;a++){e[r+a]=(t&255<<8*(n?a:1-a))>>>(n?a:1-a)*8}}s.prototype.writeUInt16LE=function(e,t,r){S(this,e,t,true,r)};s.prototype.writeUInt16BE=function(e,t,r){S(this,e,t,false,r)};function T(e,t,r,n,i){if(!i){H(t!==undefined&&t!==null,"missing value");H(typeof n==="boolean","missing or invalid endian");H(r!==undefined&&r!==null,"missing offset");H(r+3<e.length,"trying to write beyond buffer length");V(t,4294967295)}var s=e.length;if(r>=s)return;for(var a=0,o=Math.min(s-r,4);a<o;a++){e[r+a]=t>>>(n?a:3-a)*8&255}}s.prototype.writeUInt32LE=function(e,t,r){T(this,e,t,true,r)};s.prototype.writeUInt32BE=function(e,t,r){T(this,e,t,false,r)};s.prototype.writeInt8=function(e,t,r){var n=this;if(!r){H(e!==undefined&&e!==null,"missing value");H(t!==undefined&&t!==null,"missing offset");H(t<n.length,"Trying to write beyond buffer length");K(e,127,-128)}if(t>=n.length)return;if(e>=0)n.writeUInt8(e,t,r);else n.writeUInt8(255+e+1,t,r)};function C(e,t,r,n,i){if(!i){H(t!==undefined&&t!==null,"missing value");H(typeof n==="boolean","missing or invalid endian");H(r!==undefined&&r!==null,"missing offset");H(r+1<e.length,"Trying to write beyond buffer length");K(t,32767,-32768)}var s=e.length;if(r>=s)return;if(t>=0)S(e,t,r,n,i);else S(e,65535+t+1,r,n,i)}s.prototype.writeInt16LE=function(e,t,r){C(this,e,t,true,r)};s.prototype.writeInt16BE=function(e,t,r){C(this,e,t,false,r)};function A(e,t,r,n,i){if(!i){H(t!==undefined&&t!==null,"missing value");H(typeof n==="boolean","missing or invalid endian");H(r!==undefined&&r!==null,"missing offset");H(r+3<e.length,"Trying to write beyond buffer length");K(t,2147483647,-2147483648)}var s=e.length;if(r>=s)return;if(t>=0)T(e,t,r,n,i);else T(e,4294967295+t+1,r,n,i)}s.prototype.writeInt32LE=function(e,t,r){A(this,e,t,true,r)};s.prototype.writeInt32BE=function(e,t,r){A(this,e,t,false,r)};function x(e,t,r,n,s){if(!s){H(t!==undefined&&t!==null,"missing value");H(typeof n==="boolean","missing or invalid endian");H(r!==undefined&&r!==null,"missing offset");H(r+3<e.length,"Trying to write beyond buffer length");G(t,3.4028234663852886e38,-3.4028234663852886e38)}var a=e.length;if(r>=a)return;i.write(e,t,r,n,23,4)}s.prototype.writeFloatLE=function(e,t,r){x(this,e,t,true,r)};s.prototype.writeFloatBE=function(e,t,r){x(this,e,t,false,r)};function I(e,t,r,n,s){if(!s){H(t!==undefined&&t!==null,"missing value");H(typeof n==="boolean","missing or invalid endian");H(r!==undefined&&r!==null,"missing offset");H(r+7<e.length,"Trying to write beyond buffer length");G(t,1.7976931348623157e308,-1.7976931348623157e308)}var a=e.length;if(r>=a)return;i.write(e,t,r,n,52,8)}s.prototype.writeDoubleLE=function(e,t,r){I(this,e,t,true,r)};s.prototype.writeDoubleBE=function(e,t,r){I(this,e,t,false,r)};s.prototype.fill=function(e,t,r){if(!e)e=0;if(!t)t=0;if(!r)r=this.length;if(typeof e==="string"){e=e.charCodeAt(0)}H(typeof e==="number"&&!isNaN(e),"value is not a number");H(r>=t,"end < start");if(r===t)return;if(this.length===0)return;H(t>=0&&t<this.length,"start out of bounds");H(r>=0&&r<=this.length,"end out of bounds");for(var n=t;n<r;n++){this[n]=e}};s.prototype.inspect=function(){var e=[];var t=this.length;for(var n=0;n<t;n++){e[n]=M(this[n]);if(n===r.INSPECT_MAX_BYTES){e[n+1]="...";break}}return"<Buffer "+e.join(" ")+">"};function R(){return new s(this).buffer}function k(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}var N=s.prototype;function B(e){e._isBuffer=true;e.write=N.write;e.toString=N.toString;e.toLocaleString=N.toString;e.toJSON=N.toJSON;e.copy=N.copy;e.slice=N.slice;e.readUInt8=N.readUInt8;e.readUInt16LE=N.readUInt16LE;e.readUInt16BE=N.readUInt16BE;e.readUInt32LE=N.readUInt32LE;e.readUInt32BE=N.readUInt32BE;e.readInt8=N.readInt8;e.readInt16LE=N.readInt16LE;e.readInt16BE=N.readInt16BE;e.readInt32LE=N.readInt32LE;e.readInt32BE=N.readInt32BE;e.readFloatLE=N.readFloatLE;e.readFloatBE=N.readFloatBE;e.readDoubleLE=N.readDoubleLE;e.readDoubleBE=N.readDoubleBE;e.writeUInt8=N.writeUInt8;e.writeUInt16LE=N.writeUInt16LE;e.writeUInt16BE=N.writeUInt16BE;e.writeUInt32LE=N.writeUInt32LE;e.writeUInt32BE=N.writeUInt32BE;e.writeInt8=N.writeInt8;e.writeInt16LE=N.writeInt16LE;e.writeInt16BE=N.writeInt16BE;e.writeInt32LE=N.writeInt32LE;e.writeInt32BE=N.writeInt32BE;e.writeFloatLE=N.writeFloatLE;e.writeFloatBE=N.writeFloatBE;e.writeDoubleLE=N.writeDoubleLE;e.writeDoubleBE=N.writeDoubleBE;e.fill=N.fill;e.inspect=N.inspect;e.toArrayBuffer=R;return e}function _(e,t,r){if(typeof e!=="number")return r;e=~~e;if(e>=t)return t;if(e>=0)return e;e+=t;if(e>=0)return e;return 0}function q(e){e=~~Math.ceil(+e);return e<0?0:e}function L(e){return(Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"})(e)}function D(e){return L(e)||s.isBuffer(e)||e&&typeof e==="object"&&typeof e.length==="number"}function M(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function P(e){var t=[];for(var r=0;r<e.length;r++){var n=e.charCodeAt(r);if(n<=127)t.push(e.charCodeAt(r));else{var i=r;if(n>=55296&&n<=57343)r++;var s=encodeURIComponent(e.slice(i,r+1)).substr(1).split("%");for(var a=0;a<s.length;a++)t.push(parseInt(s[a],16))}}return t}function U(e){var t=[];for(var r=0;r<e.length;r++){t.push(e.charCodeAt(r)&255)}return t}function O(e){return n.toByteArray(e)}function j(e,t,r,n){var i;for(var s=0;s<n;s++){if(s+r>=t.length||s>=e.length)break;t[s+r]=e[s]}return s}function z(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}function V(e,t){H(typeof e=="number","cannot write a non-number as a number");H(e>=0,"specified a negative value for writing an unsigned value");H(e<=t,"value is larger than maximum value for type");H(Math.floor(e)===e,"value has a fractional component")}function K(e,t,r){H(typeof e=="number","cannot write a non-number as a number");H(e<=t,"value larger than maximum allowed value");H(e>=r,"value smaller than minimum allowed value");H(Math.floor(e)===e,"value has a fractional component")}function G(e,t,r){H(typeof e=="number","cannot write a non-number as a number");H(e<=t,"value larger than maximum allowed value");H(e>=r,"value smaller than minimum allowed value")}function H(e,t){if(!e)throw new Error(t||"Failed assertion")}},{"base64-js":13,ieee754:14}],13:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var r=typeof Uint8Array!=="undefined"?Uint8Array:Array;var i="0".charCodeAt(0);var s="+".charCodeAt(0);var a="/".charCodeAt(0);var o="0".charCodeAt(0);var u="a".charCodeAt(0);var c="A".charCodeAt(0);function l(e){var t=e.charCodeAt(0);if(t===s)return 62;if(t===a)return 63;if(t<o)return-1;if(t<o+10)return t-o+26+26;if(t<c+26)return t-c;if(t<u+26)return t-u+26}function p(e){var t,n,i,s,a,o;if(e.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var u=e.length;a="="===e.charAt(u-2)?2:"="===e.charAt(u-1)?1:0;o=new r(e.length*3/4-a);i=a>0?e.length-4:e.length;var c=0;function p(e){o[c++]=e}for(t=0,n=0;t<i;t+=4,n+=3){s=l(e.charAt(t))<<18|l(e.charAt(t+1))<<12|l(e.charAt(t+2))<<6|l(e.charAt(t+3));p((s&16711680)>>16);p((s&65280)>>8);p(s&255)}if(a===2){s=l(e.charAt(t))<<2|l(e.charAt(t+1))>>4;p(s&255)}else if(a===1){s=l(e.charAt(t))<<10|l(e.charAt(t+1))<<4|l(e.charAt(t+2))>>2;p(s>>8&255);p(s&255)}return o}function f(e){var t,r=e.length%3,i="",s,a;function o(e){return n.charAt(e)}function u(e){return o(e>>18&63)+o(e>>12&63)+o(e>>6&63)+o(e&63)}for(t=0,a=e.length-r;t<a;t+=3){s=(e[t]<<16)+(e[t+1]<<8)+e[t+2];i+=u(s)}switch(r){case 1:s=e[e.length-1];i+=o(s>>2);i+=o(s<<4&63);i+="==";break;case 2:s=(e[e.length-2]<<8)+e[e.length-1];i+=o(s>>10);i+=o(s>>4&63);i+=o(s<<2&63);i+="=";break}return i}t.exports.toByteArray=p;t.exports.fromByteArray=f})()},{}],14:[function(e,t,r){r.read=function(e,t,r,n,i){var s,a,o=i*8-n-1,u=(1<<o)-1,c=u>>1,l=-7,p=r?i-1:0,f=r?-1:1,m=e[t+p];p+=f;s=m&(1<<-l)-1;m>>=-l;l+=o;for(;l>0;s=s*256+e[t+p],p+=f,l-=8);a=s&(1<<-l)-1;s>>=-l;l+=n;for(;l>0;a=a*256+e[t+p],p+=f,l-=8);if(s===0){s=1-c}else if(s===u){return a?NaN:(m?-1:1)*Infinity}else{a=a+Math.pow(2,n);s=s-c}return(m?-1:1)*a*Math.pow(2,s-n)};r.write=function(e,t,r,n,i,s){var a,o,u,c=s*8-i-1,l=(1<<c)-1,p=l>>1,f=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=n?0:s-1,d=n?1:-1,h=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){o=isNaN(t)?1:0;a=l}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(u=Math.pow(2,-a))<1){a--;u*=2}if(a+p>=1){t+=f/u}else{t+=f*Math.pow(2,1-p)}if(t*u>=2){a++;u/=2}if(a+p>=l){o=0;a=l}else if(a+p>=1){o=(t*u-1)*Math.pow(2,i);a=a+p}else{o=t*Math.pow(2,p-1)*Math.pow(2,i);a=0}}for(;i>=8;e[r+m]=o&255,m+=d,o/=256,i-=8);a=a<<i|o;c+=i;for(;c>0;e[r+m]=a&255,m+=d,a/=256,c-=8);e[r+m-d]|=h*128}},{}],15:[function(e,t,r){var n=typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};(function(e){var i=typeof r=="object"&&r;var s=typeof t=="object"&&t&&t.exports==i&&t;var a=typeof n=="object"&&n;if(a.global===a||a.window===a){e=a}var o,u=2147483647,c=36,l=1,p=26,f=38,m=700,d=72,h=128,y="-",b=/^xn--/,g=/[^ -~]/,v=/.|。|.|。/g,E={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=c-l,S=Math.floor,T=String.fromCharCode,C;function A(e){throw RangeError(E[e])}function x(e,t){var r=e.length;while(r--){e[r]=t(e[r])}return e}function I(e,t){return x(e.split(v),t).join(".")}function R(e){var t=[],r=0,n=e.length,i,s;while(r<n){i=e.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){s=e.charCodeAt(r++);if((s&64512)==56320){t.push(((i&1023)<<10)+(s&1023)+65536)}else{t.push(i);r--}}else{t.push(i)}}return t}function k(e){return x(e,function(e){var t="";if(e>65535){e-=65536;t+=T(e>>>10&1023|55296);e=56320|e&1023}t+=T(e);return t}).join("")}function N(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return c}function B(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function _(e,t,r){var n=0;e=r?S(e/m):e>>1;e+=S(e/t);for(;e>w*p>>1;n+=c){e=S(e/w)}return S(n+(w+1)*e/(e+f))}function q(e){var t=[],r=e.length,n,i=0,s=h,a=d,o,f,m,b,g,v,E,w,T,C;o=e.lastIndexOf(y);if(o<0){o=0}for(f=0;f<o;++f){if(e.charCodeAt(f)>=128){A("not-basic")}t.push(e.charCodeAt(f))}for(m=o>0?o+1:0;m<r;){for(b=i,g=1,v=c;;v+=c){if(m>=r){A("invalid-input")}E=N(e.charCodeAt(m++));if(E>=c||E>S((u-i)/g)){A("overflow")}i+=E*g;w=v<=a?l:v>=a+p?p:v-a;if(E<w){break}C=c-w;if(g>S(u/C)){A("overflow")}g*=C}n=t.length+1;a=_(i-b,n,b==0);if(S(i/n)>u-s){A("overflow")}s+=S(i/n);i%=n;t.splice(i++,0,s)}return k(t)}function L(e){var t,r,n,i,s,a,o,f,m,b,g,v=[],E,w,C,x;e=R(e);E=e.length;t=h;r=0;s=d;for(a=0;a<E;++a){g=e[a];if(g<128){v.push(T(g))}}n=i=v.length;if(i){v.push(y)}while(n<E){for(o=u,a=0;a<E;++a){g=e[a];if(g>=t&&g<o){o=g}}w=n+1;if(o-t>S((u-r)/w)){A("overflow")}r+=(o-t)*w;t=o;for(a=0;a<E;++a){g=e[a];if(g<t&&++r>u){A("overflow")}if(g==t){for(f=r,m=c;;m+=c){b=m<=s?l:m>=s+p?p:m-s;if(f<b){break}x=f-b;C=c-b;v.push(T(B(b+x%C,0)));f=S(x/C)}v.push(T(B(f,0)));s=_(r,w,n==i);r=0;++n}}++r;++t}return v.join("")}function D(e){return I(e,function(e){return b.test(e)?q(e.slice(4).toLowerCase()):e})}function M(e){return I(e,function(e){return g.test(e)?"xn--"+L(e):e})}o={version:"1.2.3",ucs2:{decode:R,encode:k},decode:q,encode:L,toASCII:M,toUnicode:D};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){define(function(){return o})}else if(i&&!i.nodeType){if(s){s.exports=o}else{for(C in o){o.hasOwnProperty(C)&&(i[C]=o[C])}}}else{e.punycode=o}})(this)},{}],16:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,s){t=t||"&";r=r||"=";var a={};if(typeof e!=="string"||e.length===0){return a}var o=/\+/g;e=e.split(t);var u=1e3;if(s&&typeof s.maxKeys==="number"){u=s.maxKeys}var c=e.length;if(u>0&&c>u){c=u}for(var l=0;l<c;++l){var p=e[l].replace(o,"%20"),f=p.indexOf(r),m,d,h,y;if(f>=0){m=p.substr(0,f);d=p.substr(f+1)}else{m=p;d=""}h=decodeURIComponent(m);y=decodeURIComponent(d);if(!n(a,h)){a[h]=y}else if(i(a[h])){a[h].push(y)}else{a[h]=[a[h],y]}}return a};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],17:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,o){t=t||"&";r=r||"=";if(e===null){e=undefined}if(typeof e==="object"){return s(a(e),function(s){var a=encodeURIComponent(n(s))+r;if(i(e[s])){return e[s].map(function(e){return a+encodeURIComponent(n(e))}).join(t)}else{return a+encodeURIComponent(n(e[s]))}}).join(t)}if(!o)return"";return encodeURIComponent(n(o))+r+encodeURIComponent(n(e))};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};function s(e,t){if(e.map)return e.map(t);var r=[];for(var n=0;n<e.length;n++){r.push(t(e[n],n))}return r}var a=Object.keys||function(e){var t=[];for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t.push(r)}return t}},{}],18:[function(e,t,r){"use strict";r.decode=r.parse=e("./decode");r.encode=r.stringify=e("./encode")},{"./decode":16,"./encode":17}],19:[function(e,t,r){t.exports=o;var n=e("inherits");var i=e("process/browser.js").nextTick;var s=e("./readable.js");var a=e("./writable.js");n(o,s);o.prototype.write=a.prototype.write;o.prototype.end=a.prototype.end;o.prototype._write=a.prototype._write;function o(e){if(!(this instanceof o))return new o(e);s.call(this,e);a.call(this,e);if(e&&e.readable===false)this.readable=false;if(e&&e.writable===false)this.writable=false;this.allowHalfOpen=true;if(e&&e.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",u)}function u(){if(this.allowHalfOpen||this._writableState.ended)return;var e=this;i(function(){e.end()})}},{"./readable.js":23,"./writable.js":25,inherits:9,"process/browser.js":21}],20:[function(e,t,r){t.exports=s;var n=e("events").EventEmitter;var i=e("inherits");i(s,n);s.Readable=e("./readable.js");s.Writable=e("./writable.js");s.Duplex=e("./duplex.js");s.Transform=e("./transform.js");s.PassThrough=e("./passthrough.js");s.Stream=s;function s(){n.call(this)}s.prototype.pipe=function(e,t){var r=this;function i(t){if(e.writable){if(false===e.write(t)&&r.pause){r.pause()}}}r.on("data",i);function s(){if(r.readable&&r.resume){r.resume()}}e.on("drain",s);if(!e._isStdio&&(!t||t.end!==false)){r.on("end",o);r.on("close",u)}var a=false;function o(){if(a)return;a=true;e.end()}function u(){if(a)return;a=true;if(typeof e.destroy==="function")e.destroy()}function c(e){l();if(n.listenerCount(this,"error")===0){throw e}}r.on("error",c);e.on("error",c);function l(){r.removeListener("data",i);e.removeListener("drain",s);r.removeListener("end",o);r.removeListener("close",u);r.removeListener("error",c);e.removeListener("error",c);r.removeListener("end",l);r.removeListener("close",l);e.removeListener("close",l)}r.on("end",l);r.on("close",l);e.on("close",l);e.emit("pipe",r);return e}},{"./duplex.js":19,"./passthrough.js":22,"./readable.js":23,"./transform.js":24,"./writable.js":25,events:8,inherits:9}],21:[function(e,t,r){t.exports=e(11)},{}],22:[function(e,t,r){t.exports=s;var n=e("./transform.js");var i=e("inherits");i(s,n);function s(e){if(!(this instanceof s))return new s(e);n.call(this,e)}s.prototype._transform=function(e,t,r){r(null,e)}},{"./transform.js":24,inherits:9}],23:[function(e,t,r){var n=e("__browserify_process");t.exports=p;p.ReadableState=l;var i=e("events").EventEmitter;var s=e("./index.js");var a=e("buffer").Buffer;var o=e("process/browser.js").nextTick;var u;var c=e("inherits");c(p,s);function l(t,r){t=t||{};var n=t.highWaterMark;this.highWaterMark=n||n===0?n:16*1024;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=false;this.ended=false;this.endEmitted=false;this.reading=false;this.calledRead=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!t.objectMode;this.defaultEncoding=t.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(t.encoding){if(!u)u=e("string_decoder").StringDecoder;this.decoder=new u(t.encoding);this.encoding=t.encoding}}function p(e){if(!(this instanceof p))return new p(e);this._readableState=new l(e,this);this.readable=true;s.call(this)}p.prototype.push=function(e,t){var r=this._readableState;if(typeof e==="string"&&!r.objectMode){t=t||r.defaultEncoding;if(t!==r.encoding){e=new a(e,t);t=""}}return f(this,r,e,t,false)};p.prototype.unshift=function(e){var t=this._readableState;return f(this,t,e,"",true)};function f(e,t,r,n,i){var s=b(t,r);if(s){e.emit("error",s)}else if(r===null||r===undefined){t.reading=false;if(!t.ended)g(e,t)}else if(t.objectMode||r&&r.length>0){if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{if(t.decoder&&!i&&!n)r=t.decoder.write(r);t.length+=t.objectMode?1:r.length;if(i){t.buffer.unshift(r)}else{t.reading=false;t.buffer.push(r)}if(t.needReadable)v(e);w(e,t)}}else if(!i){t.reading=false}return m(t)}function m(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}p.prototype.setEncoding=function(t){if(!u)u=e("string_decoder").StringDecoder;this._readableState.decoder=new u(t);this._readableState.encoding=t};var d=8388608;function h(e){if(e>=d){e=d}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function y(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(isNaN(e)||e===null){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=h(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}p.prototype.read=function(e){var t=this._readableState;t.calledRead=true;var r=e;if(typeof e!=="number"||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){v(this);return null}e=y(e,t);if(e===0&&t.ended){if(t.length===0)R(this);return null}var n=t.needReadable;if(t.length-e<=t.highWaterMark)n=true;if(t.ended||t.reading)n=false;if(n){t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(n&&!t.reading)e=y(r,t);var i;if(e>0)i=I(e,t);else i=null;if(i===null){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(t.ended&&!t.endEmitted&&t.length===0)R(this);return i};function b(e,t){var r=null;if(!a.isBuffer(t)&&"string"!==typeof t&&t!==null&&t!==undefined&&!e.objectMode&&!r){r=new TypeError("Invalid non-string/buffer chunk")}return r}function g(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;if(t.length>0)v(e);else R(e)}function v(e){var t=e._readableState;t.needReadable=false;if(t.emittedReadable)return;t.emittedReadable=true;if(t.sync)o(function(){E(e)});else E(e)}function E(e){e.emit("readable")}function w(e,t){if(!t.readingMore){t.readingMore=true;o(function(){S(e,t)})}}function S(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}p.prototype._read=function(e){this.emit("error",new Error("not implemented"))};p.prototype.pipe=function(e,t){var r=this;var s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e);break}s.pipesCount+=1;var a=(!t||t.end!==false)&&e!==n.stdout&&e!==n.stderr;var u=a?l:f;if(s.endEmitted)o(u);else r.once("end",u);e.on("unpipe",c);function c(e){if(e!==r)return;f()}function l(){e.end()}var p=T(r);e.on("drain",p);function f(){e.removeListener("close",h);e.removeListener("finish",y);e.removeListener("drain",p);e.removeListener("error",d);e.removeListener("unpipe",c);r.removeListener("end",l);r.removeListener("end",f);if(!e._writableState||e._writableState.needDrain)p()}var m=i.listenerCount(e,"error");function d(t){b();if(m===0&&i.listenerCount(e,"error")===0)e.emit("error",t)}e.once("error",d);function h(){e.removeListener("finish",y);b()}e.once("close",h);function y(){e.removeListener("close",h);b()}e.once("finish",y);function b(){r.unpipe(e)}e.emit("pipe",r);if(!s.flowing){this.on("readable",A);s.flowing=true;o(function(){C(r)})}return e};function T(e){return function(){var t=this;var r=e._readableState;r.awaitDrain--;if(r.awaitDrain===0)C(e)}}function C(e){var t=e._readableState;var r;t.awaitDrain=0;function n(e,n,i){var s=e.write(r);if(false===s){t.awaitDrain++}}while(t.pipesCount&&null!==(r=e.read())){if(t.pipesCount===1)n(t.pipes,0,null);else k(t.pipes,n);e.emit("data",r);if(t.awaitDrain>0)return}if(t.pipesCount===0){t.flowing=false;if(i.listenerCount(e,"data")>0)x(e);return}t.ranOut=true}function A(){if(this._readableState.ranOut){this._readableState.ranOut=false;C(this)}}p.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;t.pipes=null;t.pipesCount=0;this.removeListener("readable",A);t.flowing=false;if(e)e.emit("unpipe",this);return this}if(!e){var r=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;this.removeListener("readable",A);t.flowing=false;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var i=N(t.pipes,e);if(i===-1)return this;t.pipes.splice(i,1);t.pipesCount-=1;if(t.pipesCount===1)t.pipes=t.pipes[0];e.emit("unpipe",this);return this};p.prototype.on=function(e,t){var r=s.prototype.on.call(this,e,t);if(e==="data"&&!this._readableState.flowing)x(this);if(e==="readable"&&this.readable){var n=this._readableState;if(!n.readableListening){n.readableListening=true;n.emittedReadable=false;n.needReadable=true;if(!n.reading){this.read(0)}else if(n.length){v(this,n)}}}return r};p.prototype.addListener=p.prototype.on;p.prototype.resume=function(){x(this);this.read(0);this.emit("resume")};p.prototype.pause=function(){x(this,true);this.emit("pause")};function x(e,t){var r=e._readableState;if(r.flowing){throw new Error("Cannot switch to old mode now.")}var n=t||false;var i=false;e.readable=true;e.pipe=s.prototype.pipe;e.on=e.addListener=s.prototype.on;e.on("readable",function(){i=true;var t;while(!n&&null!==(t=e.read()))e.emit("data",t);if(t===null){i=false;e._readableState.needReadable=true}});e.pause=function(){n=true;this.emit("pause")};e.resume=function(){n=false;if(i)o(function(){e.emit("readable")});else this.read(0);this.emit("resume")};e.emit("readable")}p.prototype.wrap=function(e){var t=this._readableState;var r=false;var n=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)n.push(e)}n.push(null)});e.on("data",function(i){if(t.decoder)i=t.decoder.write(i);if(!i||!t.objectMode&&!i.length)return;var s=n.push(i);if(!s){r=true;e.pause()}});for(var i in e){if(typeof e[i]==="function"&&typeof this[i]==="undefined"){this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i)}}var s=["error","close","destroy","pause","resume"];k(s,function(t){e.on(t,function(e){return n.emit.apply(n,t,e)})});n._read=function(t){if(r){r=false;e.resume()}};return n};p._fromList=I;function I(e,t){var r=t.buffer;var n=t.length;var i=!!t.decoder;var s=!!t.objectMode;var o;if(r.length===0)return null;if(n===0)o=null;else if(s)o=r.shift();else if(!e||e>=n){if(i)o=r.join("");else o=a.concat(r,n);r.length=0}else{if(e<r[0].length){var u=r[0];o=u.slice(0,e);r[0]=u.slice(e)}else if(e===r[0].length){o=r.shift()}else{if(i)o="";else o=new a(e);var c=0;for(var l=0,p=r.length;l<p&&c<e;l++){var u=r[0];var f=Math.min(e-c,u.length);if(i)o+=u.slice(0,f);else u.copy(o,c,0,f);if(f<u.length)r[0]=u.slice(f);else r.shift();c+=f}}}return o}function R(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted&&t.calledRead){t.ended=true;o(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function k(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}function N(e,t){for(var r=0,n=e.length;r<n;r++){if(e[r]===t)return r}return-1}},{"./index.js":20,__browserify_process:11,buffer:12,events:8,inherits:9,"process/browser.js":21,string_decoder:26}],24:[function(e,t,r){t.exports=o; | |
var n=e("./duplex.js");var i=e("inherits");i(o,n);function s(e,t){this.afterTransform=function(e,r){return a(t,e,r)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function a(e,t,r){var n=e._transformState;n.transforming=false;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null;n.writecb=null;if(r!==null&&r!==undefined)e.push(r);if(i)i(t);var s=e._readableState;s.reading=false;if(s.needReadable||s.length<s.highWaterMark){e._read(s.highWaterMark)}}function o(e){if(!(this instanceof o))return new o(e);n.call(this,e);var t=this._transformState=new s(e,this);var r=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("finish",function(){if("function"===typeof this._flush)this._flush(function(e){u(r,e)});else u(r)})}o.prototype.push=function(e,t){this._transformState.needTransform=false;return n.prototype.push.call(this,e,t)};o.prototype._transform=function(e,t,r){throw new Error("not implemented")};o.prototype._write=function(e,t,r){var n=this._transformState;n.writecb=r;n.writechunk=e;n.writeencoding=t;if(!n.transforming){var i=this._readableState;if(n.needTransform||i.needReadable||i.length<i.highWaterMark)this._read(i.highWaterMark)}};o.prototype._read=function(e){var t=this._transformState;if(t.writechunk&&t.writecb&&!t.transforming){t.transforming=true;this._transform(t.writechunk,t.writeencoding,t.afterTransform)}else{t.needTransform=true}};function u(e,t){if(t)return e.emit("error",t);var r=e._writableState;var n=e._readableState;var i=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(i.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./duplex.js":19,inherits:9}],25:[function(e,t,r){t.exports=p;p.WritableState=l;var n=typeof Uint8Array!=="undefined"?function(e){return e instanceof Uint8Array}:function(e){return e&&e.constructor&&e.constructor.name==="Uint8Array"};var i=typeof ArrayBuffer!=="undefined"?function(e){return e instanceof ArrayBuffer}:function(e){return e&&e.constructor&&e.constructor.name==="ArrayBuffer"};var s=e("inherits");var a=e("./index.js");var o=e("process/browser.js").nextTick;var u=e("buffer").Buffer;s(p,a);function c(e,t,r){this.chunk=e;this.encoding=t;this.callback=r}function l(e,t){e=e||{};var r=e.highWaterMark;this.highWaterMark=r||r===0?r:16*1024;this.objectMode=!!e.objectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var n=e.decodeStrings===false;this.decodeStrings=!n;this.defaultEncoding=e.defaultEncoding||"utf8";this.length=0;this.writing=false;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){v(t,e)};this.writecb=null;this.writelen=0;this.buffer=[]}function p(e){if(!(this instanceof p)&&!(this instanceof a.Duplex))return new p(e);this._writableState=new l(e,this);this.writable=true;a.call(this)}p.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function f(e,t,r){var n=new Error("write after end");e.emit("error",n);o(function(){r(n)})}function m(e,t,r,n){var i=true;if(!u.isBuffer(r)&&"string"!==typeof r&&r!==null&&r!==undefined&&!t.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s);o(function(){n(s)});i=false}return i}p.prototype.write=function(e,t,r){var s=this._writableState;var a=false;if(typeof t==="function"){r=t;t=null}if(n(e))e=new u(e);if(i(e)&&typeof Uint8Array!=="undefined")e=new u(new Uint8Array(e));if(u.isBuffer(e))t="buffer";else if(!t)t=s.defaultEncoding;if(typeof r!=="function")r=function(){};if(s.ended)f(this,s,r);else if(m(this,s,e,r))a=h(this,s,e,t,r);return a};function d(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&typeof t==="string"){t=new u(t,r)}return t}function h(e,t,r,n,i){r=d(t,r,n);var s=t.objectMode?1:r.length;t.length+=s;var a=t.length<t.highWaterMark;t.needDrain=!a;if(t.writing)t.buffer.push(new c(r,n,i));else y(e,t,s,r,n,i);return a}function y(e,t,r,n,i,s){t.writelen=r;t.writecb=s;t.writing=true;t.sync=true;e._write(n,i,t.onwrite);t.sync=false}function b(e,t,r,n,i){if(r)o(function(){i(n)});else i(n);e.emit("error",n)}function g(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function v(e,t){var r=e._writableState;var n=r.sync;var i=r.writecb;g(r);if(t)b(e,r,n,t,i);else{var s=T(e,r);if(!s&&!r.bufferProcessing&&r.buffer.length)S(e,r);if(n){o(function(){E(e,r,s,i)})}else{E(e,r,s,i)}}}function E(e,t,r,n){if(!r)w(e,t);n();if(r)C(e,t)}function w(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function S(e,t){t.bufferProcessing=true;for(var r=0;r<t.buffer.length;r++){var n=t.buffer[r];var i=n.chunk;var s=n.encoding;var a=n.callback;var o=t.objectMode?1:i.length;y(e,t,o,i,s,a);if(t.writing){r++;break}}t.bufferProcessing=false;if(r<t.buffer.length)t.buffer=t.buffer.slice(r);else t.buffer.length=0}p.prototype._write=function(e,t,r){r(new Error("not implemented"))};p.prototype.end=function(e,t,r){var n=this._writableState;if(typeof e==="function"){r=e;e=null;t=null}else if(typeof t==="function"){r=t;t=null}if(typeof e!=="undefined"&&e!==null)this.write(e,t);if(!n.ending&&!n.finished)A(this,n,r)};function T(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function C(e,t){var r=T(e,t);if(r){t.finished=true;e.emit("finish")}return r}function A(e,t,r){t.ending=true;C(e,t);if(r){if(t.finished)o(r);else e.once("finish",r)}t.ended=true}},{"./index.js":20,buffer:12,inherits:9,"process/browser.js":21}],26:[function(e,t,r){var n=e("buffer").Buffer;function i(e){if(e&&!n.isEncoding(e)){throw new Error("Unknown encoding: "+e)}}var s=r.StringDecoder=function(e){this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,"");i(e);switch(this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2;this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=u;break;default:this.write=a;return}this.charBuffer=new n(6);this.charReceived=0;this.charLength=0};s.prototype.write=function(e){var t="";var r=0;while(this.charLength){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;e.copy(this.charBuffer,this.charReceived,r,n);this.charReceived+=n-r;r=n;if(this.charReceived<this.charLength){return""}t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var i=t.charCodeAt(t.length-1);if(i>=55296&&i<=56319){this.charLength+=this.surrogateSize;t="";continue}this.charReceived=this.charLength=0;if(n==e.length)return t;e=e.slice(n,e.length);break}var s=this.detectIncompleteChar(e);var a=e.length;if(this.charLength){e.copy(this.charBuffer,0,e.length-s,a);this.charReceived=s;a-=s}t+=e.toString(this.encoding,0,a);var a=t.length-1;var i=t.charCodeAt(a);if(i>=55296&&i<=56319){var o=this.surrogateSize;this.charLength+=o;this.charReceived+=o;this.charBuffer.copy(this.charBuffer,o,0,o);this.charBuffer.write(t.charAt(t.length-1),this.encoding);return t.substring(0,a)}return t};s.prototype.detectIncompleteChar=function(e){var t=e.length>=3?3:e.length;for(;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}return t};s.prototype.end=function(e){var t="";if(e&&e.length)t=this.write(e);if(this.charReceived){var r=this.charReceived;var n=this.charBuffer;var i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function a(e){return e.toString(this.encoding)}function o(e){var t=this.charReceived=e.length%2;this.charLength=t?2:0;return t}function u(e){var t=this.charReceived=e.length%3;this.charLength=t?3:0;return t}},{buffer:12}],27:[function(e,t,r){(function(){"use strict";var t=e("punycode");r.parse=g;r.resolve=E;r.resolveObject=w;r.format=v;var n=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,s=["<",">",'"',"`"," ","\r","\n"," "],a=["{","}","|","\\","^","~","`"].concat(s),o=["'"].concat(s),u=["%","/","?",";","#"].concat(a).concat(o),c=["/","@","?","#"].concat(s),l=255,p=/^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,f=/^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,m={javascript:true,"javascript:":true},d={javascript:true,"javascript:":true},h={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"ftp:":true,"gopher:":true,"file:":true},y={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},b=e("querystring");function g(e,r,i){if(e&&typeof e==="object"&&e.href)return e;if(typeof e!=="string"){throw new TypeError("Parameter 'url' must be a string, not "+typeof e)}var s={},a=e;a=a.trim();var h=n.exec(a);if(h){h=h[0];var g=h.toLowerCase();s.protocol=g;a=a.substr(h.length)}if(i||h||a.match(/^\/\/[^@\/]+@[^@\/]+/)){var E=a.substr(0,2)==="//";if(E&&!(h&&d[h])){a=a.substr(2);s.slashes=true}}if(!d[h]&&(E||h&&!y[h])){var w=a.indexOf("@");if(w!==-1){var T=a.slice(0,w);var C=true;for(var A=0,x=c.length;A<x;A++){if(T.indexOf(c[A])!==-1){C=false;break}}if(C){s.auth=decodeURIComponent(T);a=a.substr(w+1)}}var I=-1;for(var A=0,x=u.length;A<x;A++){var R=a.indexOf(u[A]);if(R!==-1&&(I<0||R<I))I=R}if(I!==-1){s.host=a.substr(0,I);a=a.substr(I)}else{s.host=a;a=""}var k=S(s.host);var N=Object.keys(k);for(var A=0,x=N.length;A<x;A++){var B=N[A];s[B]=k[B]}s.hostname=s.hostname||"";var _=s.hostname[0]==="["&&s.hostname[s.hostname.length-1]==="]";if(s.hostname.length>l){s.hostname=""}else if(!_){var q=s.hostname.split(/\./);for(var A=0,x=q.length;A<x;A++){var L=q[A];if(!L)continue;if(!L.match(p)){var D="";for(var M=0,P=L.length;M<P;M++){if(L.charCodeAt(M)>127){D+="x"}else{D+=L[M]}}if(!D.match(p)){var U=q.slice(0,A);var O=q.slice(A+1);var j=L.match(f);if(j){U.push(j[1]);O.unshift(j[2])}if(O.length){a="/"+O.join(".")+a}s.hostname=U.join(".");break}}}}s.hostname=s.hostname.toLowerCase();if(!_){var z=s.hostname.split(".");var V=[];for(var A=0;A<z.length;++A){var K=z[A];V.push(K.match(/[^A-Za-z0-9_-]/)?"xn--"+t.encode(K):K)}s.hostname=V.join(".")}s.host=(s.hostname||"")+(s.port?":"+s.port:"");s.href+=s.host;if(_){s.hostname=s.hostname.substr(1,s.hostname.length-2);if(a[0]!=="/"){a="/"+a}}}if(!m[g]){for(var A=0,x=o.length;A<x;A++){var G=o[A];var H=encodeURIComponent(G);if(H===G){H=escape(G)}a=a.split(G).join(H)}}var W=a.indexOf("#");if(W!==-1){s.hash=a.substr(W);a=a.slice(0,W)}var F=a.indexOf("?");if(F!==-1){s.search=a.substr(F);s.query=a.substr(F+1);if(r){s.query=b.parse(s.query)}a=a.slice(0,F)}else if(r){s.search="";s.query={}}if(a)s.pathname=a;if(y[h]&&s.hostname&&!s.pathname){s.pathname="/"}if(s.pathname||s.search){s.path=(s.pathname?s.pathname:"")+(s.search?s.search:"")}s.href=v(s);return s}function v(e){if(typeof e==="string")e=g(e);var t=e.auth||"";if(t){t=encodeURIComponent(t);t=t.replace(/%3A/i,":");t+="@"}var r=e.protocol||"",n=e.pathname||"",i=e.hash||"",s=false,a="";if(e.host!==undefined){s=t+e.host}else if(e.hostname!==undefined){s=t+(e.hostname.indexOf(":")===-1?e.hostname:"["+e.hostname+"]");if(e.port){s+=":"+e.port}}if(e.query&&typeof e.query==="object"&&Object.keys(e.query).length){a=b.stringify(e.query)}var o=e.search||a&&"?"+a||"";if(r&&r.substr(-1)!==":")r+=":";if(e.slashes||(!r||y[r])&&s!==false){s="//"+(s||"");if(n&&n.charAt(0)!=="/")n="/"+n}else if(!s){s=""}if(i&&i.charAt(0)!=="#")i="#"+i;if(o&&o.charAt(0)!=="?")o="?"+o;return r+s+n+o+i}function E(e,t){return v(w(e,t))}function w(e,t){if(!e)return t;e=g(v(e),false,true);t=g(v(t),false,true);e.hash=t.hash;if(t.href===""){e.href=v(e);return e}if(t.slashes&&!t.protocol){t.protocol=e.protocol;if(y[t.protocol]&&t.hostname&&!t.pathname){t.path=t.pathname="/"}t.href=v(t);return t}if(t.protocol&&t.protocol!==e.protocol){if(!y[t.protocol]){t.href=v(t);return t}e.protocol=t.protocol;if(!t.host&&!d[t.protocol]){var r=(t.pathname||"").split("/");while(r.length&&!(t.host=r.shift()));if(!t.host)t.host="";if(!t.hostname)t.hostname="";if(r[0]!=="")r.unshift("");if(r.length<2)r.unshift("");t.pathname=r.join("/")}e.pathname=t.pathname;e.search=t.search;e.query=t.query;e.host=t.host||"";e.auth=t.auth;e.hostname=t.hostname||t.host;e.port=t.port;if(e.pathname!==undefined||e.search!==undefined){e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")}e.slashes=e.slashes||t.slashes;e.href=v(e);return e}var n=e.pathname&&e.pathname.charAt(0)==="/",i=t.host!==undefined||t.pathname&&t.pathname.charAt(0)==="/",s=i||n||e.host&&t.pathname,a=s,o=e.pathname&&e.pathname.split("/")||[],r=t.pathname&&t.pathname.split("/")||[],u=e.protocol&&!y[e.protocol];if(u){delete e.hostname;delete e.port;if(e.host){if(o[0]==="")o[0]=e.host;else o.unshift(e.host)}delete e.host;if(t.protocol){delete t.hostname;delete t.port;if(t.host){if(r[0]==="")r[0]=t.host;else r.unshift(t.host)}delete t.host}s=s&&(r[0]===""||o[0]==="")}if(i){e.host=t.host||t.host===""?t.host:e.host;e.hostname=t.hostname||t.hostname===""?t.hostname:e.hostname;e.search=t.search;e.query=t.query;o=r}else if(r.length){if(!o)o=[];o.pop();o=o.concat(r);e.search=t.search;e.query=t.query}else if("search"in t){if(u){e.hostname=e.host=o.shift();var c=e.host&&e.host.indexOf("@")>0?e.host.split("@"):false;if(c){e.auth=c.shift();e.host=e.hostname=c.shift()}}e.search=t.search;e.query=t.query;if(e.pathname!==undefined||e.search!==undefined){e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")}e.href=v(e);return e}if(!o.length){delete e.pathname;if(!e.search){e.path="/"+e.search}else{delete e.path}e.href=v(e);return e}var l=o.slice(-1)[0];var p=(e.host||t.host)&&(l==="."||l==="..")||l==="";var f=0;for(var m=o.length;m>=0;m--){l=o[m];if(l=="."){o.splice(m,1)}else if(l===".."){o.splice(m,1);f++}else if(f){o.splice(m,1);f--}}if(!s&&!a){for(;f--;f){o.unshift("..")}}if(s&&o[0]!==""&&(!o[0]||o[0].charAt(0)!=="/")){o.unshift("")}if(p&&o.join("/").substr(-1)!=="/"){o.push("")}var h=o[0]===""||o[0]&&o[0].charAt(0)==="/";if(u){e.hostname=e.host=h?"":o.length?o.shift():"";var c=e.host&&e.host.indexOf("@")>0?e.host.split("@"):false;if(c){e.auth=c.shift();e.host=e.hostname=c.shift()}}s=s||e.host&&o.length;if(s&&!h){o.unshift("")}e.pathname=o.join("/");if(e.pathname!==undefined||e.search!==undefined){e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")}e.auth=t.auth||e.auth;e.slashes=e.slashes||t.slashes;e.href=v(e);return e}function S(e){var t={};var r=i.exec(e);if(r){r=r[0];if(r!==":"){t.port=r.substr(1)}e=e.substr(0,e.length-r.length)}if(e)t.hostname=e;return t}})()},{punycode:15,querystring:18}],28:[function(e,t,r){t.exports=function n(e){return e&&typeof e==="object"&&typeof e.copy==="function"&&typeof e.fill==="function"&&typeof e.readUInt8==="function"}},{}],29:[function(e,t,r){var n=e("__browserify_process"),i=typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};var s=/%[sdj%]/g;r.format=function(e){if(!T(e)){var t=[];for(var r=0;r<arguments.length;r++){t.push(u(arguments[r]))}return t.join(" ")}var r=1;var n=arguments;var i=n.length;var a=String(e).replace(s,function(e){if(e==="%%")return"%";if(r>=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return e}});for(var o=n[r];r<i;o=n[++r]){if(E(o)||!I(o)){a+=" "+o}else{a+=" "+u(o)}}return a};r.deprecate=function(e,t){if(A(i.process)){return function(){return r.deprecate(e,t).apply(this,arguments)}}if(n.noDeprecation===true){return e}var s=false;function a(){if(!s){if(n.throwDeprecation){throw new Error(t)}else if(n.traceDeprecation){console.trace(t)}else{console.error(t)}s=true}return e.apply(this,arguments)}return a};var a={};var o;r.debuglog=function(e){if(A(o))o=n.env.NODE_DEBUG||"";e=e.toUpperCase();if(!a[e]){if(new RegExp("\\b"+e+"\\b","i").test(o)){var t=n.pid;a[e]=function(){var n=r.format.apply(r,arguments);console.error("%s %d: %s",e,t,n)}}else{a[e]=function(){}}}return a[e]};function u(e,t){var n={seen:[],stylize:l};if(arguments.length>=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(v(t)){n.showHidden=t}else if(t){r._extend(n,t)}if(A(n.showHidden))n.showHidden=false;if(A(n.depth))n.depth=2;if(A(n.colors))n.colors=false;if(A(n.customInspect))n.customInspect=true;if(n.colors)n.stylize=c;return f(n,e,n.depth)}r.inspect=u;u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};u.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function c(e,t){var r=u.styles[t];if(r){return"["+u.colors[r][0]+"m"+e+"["+u.colors[r][1]+"m"}else{return e}}function l(e,t){return e}function p(e){var t={};e.forEach(function(e,r){t[e]=true});return t}function f(e,t,n){if(e.customInspect&&t&&N(t.inspect)&&t.inspect!==r.inspect&&!(t.constructor&&t.constructor.prototype===t)){var i=t.inspect(n,e);if(!T(i)){i=f(e,i,n)}return i}var s=m(e,t);if(s){return s}var a=Object.keys(t);var o=p(a);if(e.showHidden){a=Object.getOwnPropertyNames(t)}if(k(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0)){return d(t)}if(a.length===0){if(N(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(x(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}if(R(t)){return e.stylize(Date.prototype.toString.call(t),"date")}if(k(t)){return d(t)}}var c="",l=false,v=["{","}"];if(g(t)){l=true;v=["[","]"]}if(N(t)){var E=t.name?": "+t.name:"";c=" [Function"+E+"]"}if(x(t)){c=" "+RegExp.prototype.toString.call(t)}if(R(t)){c=" "+Date.prototype.toUTCString.call(t)}if(k(t)){c=" "+d(t)}if(a.length===0&&(!l||t.length==0)){return v[0]+c+v[1]}if(n<0){if(x(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}else{return e.stylize("[Object]","special")}}e.seen.push(t);var w;if(l){w=h(e,t,n,o,a)}else{w=a.map(function(r){return y(e,t,n,o,r,l)})}e.seen.pop();return b(w,c,v)}function m(e,t){if(A(t))return e.stylize("undefined","undefined");if(T(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(S(t))return e.stylize(""+t,"number");if(v(t))return e.stylize(""+t,"boolean");if(E(t))return e.stylize("null","null")}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,r,n,i){var s=[];for(var a=0,o=t.length;a<o;++a){if(M(t,String(a))){s.push(y(e,t,r,n,String(a),true))}else{s.push("")}}i.forEach(function(i){if(!i.match(/^\d+$/)){s.push(y(e,t,r,n,i,true))}});return s}function y(e,t,r,n,i,s){var a,o,u;u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]};if(u.get){if(u.set){o=e.stylize("[Getter/Setter]","special")}else{o=e.stylize("[Getter]","special")}}else{if(u.set){o=e.stylize("[Setter]","special")}}if(!M(n,i)){a="["+i+"]"}if(!o){if(e.seen.indexOf(u.value)<0){if(E(r)){o=f(e,u.value,null)}else{o=f(e,u.value,r-1)}if(o.indexOf("\n")>-1){if(s){o=o.split("\n").map(function(e){return" "+e}).join("\n").substr(2)}else{o="\n"+o.split("\n").map(function(e){return" "+e}).join("\n")}}}else{o=e.stylize("[Circular]","special")}}if(A(a)){if(s&&i.match(/^\d+$/)){return o}a=JSON.stringify(""+i);if(a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){a=a.substr(1,a.length-2);a=e.stylize(a,"name")}else{a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");a=e.stylize(a,"string")}}return a+": "+o}function b(e,t,r){var n=0;var i=e.reduce(function(e,t){n++;if(t.indexOf("\n")>=0)n++;return e+t.replace(/\[\d\d?m/g,"").length+1},0);if(i>60){return r[0]+(t===""?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]}return r[0]+t+" "+e.join(", ")+" "+r[1]}function g(e){return Array.isArray(e)}r.isArray=g;function v(e){return typeof e==="boolean"}r.isBoolean=v;function E(e){return e===null}r.isNull=E;function w(e){return e==null}r.isNullOrUndefined=w;function S(e){return typeof e==="number"}r.isNumber=S;function T(e){return typeof e==="string"}r.isString=T;function C(e){return typeof e==="symbol"}r.isSymbol=C;function A(e){return e===void 0}r.isUndefined=A;function x(e){return I(e)&&_(e)==="[object RegExp]"}r.isRegExp=x;function I(e){return typeof e==="object"&&e!==null}r.isObject=I;function R(e){return I(e)&&_(e)==="[object Date]"}r.isDate=R;function k(e){return I(e)&&(_(e)==="[object Error]"||e instanceof Error)}r.isError=k;function N(e){return typeof e==="function"}r.isFunction=N;function B(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=B;r.isBuffer=e("./support/isBuffer");function _(e){return Object.prototype.toString.call(e)}function q(e){return e<10?"0"+e.toString(10):e.toString(10)}var L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function D(){var e=new Date;var t=[q(e.getHours()),q(e.getMinutes()),q(e.getSeconds())].join(":");return[e.getDate(),L[e.getMonth()],t].join(" ")}r.log=function(){console.log("%s - %s",D(),r.format.apply(r,arguments))};r.inherits=e("inherits");r._extend=function(e,t){if(!t||!I(t))return e;var r=Object.keys(t);var n=r.length;while(n--){e[r[n]]=t[r[n]]}return e};function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},{"./support/isBuffer":28,__browserify_process:11,inherits:9}],30:[function(e,t,r){var n=e("../core");var i=e("buffer").Buffer;function s(e,t){if(!e){this.rules={type:"structure",members:{}};return}this.options=t;this.rules={};this.set_type(e.type);n.util.each.call(this,e,function(e,t){if(e!=="type")this["set_"+e](t)});if(this.rules.type==="blob"){if(this.rules.payload||this.rules.streaming){this.rules.type="binary"}else{this.rules.type="base64"}}}function a(e,t){s.call(this,e,t)}function o(e,t){s.call(this,e,t)}s.prototype={shapeClass:function(){if(this instanceof a)return a;if(this instanceof o)return o},xmlname:function(){if(this.rules.flattened){return this._xmlname||(this.rules.members||{}).name}else{return this._xmlname}},set_type:function(e){var t={structure:"structure",list:"list",map:"map","boolean":"boolean",timestamp:"timestamp",character:"string","double":"float","float":"float",integer:"integer","long":"integer","short":"integer",string:"string",blob:"blob",biginteger:"integer",bigdecimal:"float"};if(e==="string"){}else if(t[e]){this.rules.type=t[e]}else{throw new Error("unhandled shape type "+e)}},set_members:function(e){var t=this.rules.type;var r=this.shapeClass();if(t==="structure"){this.rules.members={};n.util.each.call(this,e,function(e,t){var n=new r(t,this.options);if(this.swapNames(n)){n.rules.name=e;e=n.xmlname()}this.rules.members[e]=n.rules})}else if(t==="list"){this.rules.members=new r(e,this.options).rules}else if(t==="map"){this.rules.members=new r(e,this.options).rules}else if(t==="blob"){this.rules.members={}}else{throw new Error("unhandled complex shape `"+t+"'")}},set_keys:function(e){var t=this.shapeClass();this.rules.keys=new t(e,this.options).rules},set_timestamp_format:function(e){this.rules.format=e},set_xmlname:function(e){this._xmlname=e;this.rules.name=e},set_location:function(e){this.rules.location=e==="http_status"?"status":e},set_location_name:function(e){this.rules.name=e},set_payload:function(e){if(e)this.rules.payload=true},set_flattened:function(e){if(e)this.rules.flattened=true},set_streaming:function(e){if(e)this.rules.streaming=true},set_wrapper:function(e){if(e)this.rules.wrapper=true},set_xmlattribute:function(e){if(e)this.rules.attribute=true},set_xmlnamespace:function(e){this.rules.xmlns=e},set_documentation:function(e){if(this.options.documentation)this.rules.documentation=e},set_enum:function(e){if(this.options.documentation)this.rules.enum=e},set_shape_name:function(){},set_box:function(){},set_sensitive:function(){}};a.prototype=n.util.merge(s.prototype,{swapNames:function(){return false},set_required:function(){this.rules.required=true},set_member_order:function(e){this.rules.order=e},set_min_length:function(e){if(this.options.documentation)this.rules.min_length=e},set_max_length:function(e){if(this.options.documentation)this.rules.max_length=e},set_pattern:function(e){if(this.options.documentation)this.rules.pattern=e}});o.prototype=n.util.merge(s.prototype,{swapNames:function(e){if(this.options.documentation)return false;return e.xmlname()&&["query","rest-xml"].indexOf(this.options.type)>=0},set_required:function(){},set_member_order:function(){},set_min_length:function(){},set_max_length:function(){},set_pattern:function(){}});function u(e,t){var r=e;function i(){if(t.type.indexOf("rest")<0)return;var i=t.type.indexOf("xml")>=0;var s=false;var a=false;var o=false;n.util.each(e.input.members,function(e,t){if(t.payload){o=true;s=e;delete t.payload;return n.util.abort}});if(!o){var u=[];n.util.each(e.input.members,function(e,t){if(!t.location){u.push(e)}});if(u.length>0){s=u;if(i)a=r.input.shape_name}}if(a)e.input=n.util.merge({wrapper:a},e.input);if(s)e.input=n.util.merge({payload:s},e.input)}function s(){var t=null;n.util.each(e.output.members,function(r,n){if(n.payload&&n.type==="structure"){delete n.payload;t=r}else if(n.payload||n.streaming){delete n.payload;e.output.payload=r}});if(t){var r=e.output.members[t];delete e.output.members[t];n.util.update(e.output.members,r.members)}}e=n.util.copy(e);e.input=new a(e.input,t).rules;e.output=new o(e.output,t).rules;e.input.members=e.input.members||{};e.output.members=e.output.members||{};i();s();if(e.http)delete e.http.response_code;if(t.documentation){e.errors=e.errors.map(function(e){return e.shape_name})}else{delete e.errors;delete e.documentation;delete e.documentation_url;delete e.response_code}return e}function c(e,t){function r(e){return e.replace(/_(\w)/g,function(e,t){return t.toUpperCase()})}function s(){var n=Object.keys(e);n.push("timestamp_format");n.sort().forEach(function(t){c[r(t)]=e[t]});c.timestampFormat=c.timestampFormat||"iso8601";if(c.jsonVersion)c.jsonVersion=c.jsonVersion.toString();if(c.jsonVersion==="1")c.jsonVersion="1.0";if(!t.documentation)delete c.documentation;if(!c.resultWrapped)delete c.resultWrapped;if(!e.type.match(/xml/))delete c.xmlnamespace;delete c.operations;delete c.pagination;delete c.waiters;delete c.type}function a(){c.operations={};n.util.each(e.operations,function(e,r){var n=e[0].toLowerCase()+e.substr(1);n=n.replace(/\d{4}_\d{2}_\d{2}$/,"");var i=new u(r,t);c.operations[n]=i})}function o(){if(e.pagination){c.pagination={};n.util.each(e.pagination,function(e,t){var i={};n.util.each(t,function(e,t){i[r(e)]=t});c.pagination[e[0].toLowerCase()+e.substr(1)]=i})}}if(typeof e==="string"||i.isBuffer(e)){e=JSON.parse(e)}t=t||{};t.type=e.type;var c={};c.format=e.type;s();a();o();return c}n.API={Translator:c};t.exports=c},{"../core":33,buffer:12}],31:[function(e,t,r){window.AWS=t.exports=e("./core");e("./http/xhr");e("./services")},{"./core":33,"./http/xhr":41,"./services":52}],32:[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,dynamoDbCrc32:true},extractCredentials:function l(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":33,"./credentials":34,"./credentials/credential_provider_chain":35}],33:[function(e,t,r){var n={};t.exports=n;e("./util");n.util.update(n,{VERSION:"2.0.0-rc8",ServiceInterface:{},Signers:{},XML:{}});e("./service");e("./credentials");e("./credentials/credential_provider_chain");e("./credentials/temporary_credentials");e("./credentials/web_identity_credentials");e("./credentials/saml_credentials");e("./config");e("./http");e("./sequential_executor");e("./event_listeners");e("./request");e("./signers/request_signer");e("./param_validator");n.events=new n.SequentialExecutor;if(typeof window!=="undefined")window.AWS=n},{"./config":32,"./credentials":34,"./credentials/credential_provider_chain":35,"./credentials/saml_credentials":36,"./credentials/temporary_credentials":37,"./credentials/web_identity_credentials":38,"./event_listeners":39,"./http":40,"./param_validator":43,"./request":44,"./sequential_executor":45,"./service":46,"./signers/request_signer":59,"./util":65}],34:[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":33}],35:[function(e,t,r){var n=e("../core");e("../credentials");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}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":33,"../credentials":34}],36:[function(e,t,r){var n=e("../core");e("../credentials");e("../services/sts");n.SAMLCredentials=n.util.inherit(n.Credentials,{constructor:function i(e){n.Credentials.call(this);this.expired=true;this.service=new n.STS;this.params=e},refresh:function s(e){var t=this;if(!e)e=function(e){if(e)throw e};t.service.assumeRoleWithSAML(t.params,function(r,n){if(!r){t.service.credentialsFrom(n,t)}e(r)})}})},{"../core":33,"../credentials":34,"../services/sts":57}],37:[function(e,t,r){var n=e("../core");e("../credentials");e("../services/sts");n.TemporaryCredentials=n.util.inherit(n.Credentials,{constructor:function i(e){n.Credentials.call(this); | |
this.loadMasterCredentials();this.service=new n.STS;this.expired=true;this.params=e||{};if(this.params.RoleArn){this.params.RoleSessionName=this.params.RoleSessionName||"temporary-credentials"}},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,t.params,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":33,"../credentials":34,"../services/sts":57}],38:[function(e,t,r){var n=e("../core");e("../credentials");e("../services/sts");n.WebIdentityCredentials=n.util.inherit(n.Credentials,{constructor:function i(e){n.Credentials.call(this);this.expired=true;this.service=new n.STS;this.params=e;this.params.RoleSessionName=this.params.RoleSessionName||"web-identity"},refresh:function s(e){var t=this;if(!e)e=function(e){if(e)throw e};t.service.assumeRoleWithWebIdentity(t.params,function(r,n){if(!r){t.service.credentialsFrom(n,t)}e(r)})}})},{"../core":33,"../credentials":34,"../services/sts":57}],39:[function(e,t,r){var n=e("./core");e("./sequential_executor");e("./service_interface/json");e("./service_interface/query");e("./service_interface/rest");e("./service_interface/rest_json");e("./service_interface/rest_xml");var i=e("buffer").Buffer;n.EventListeners={Core:{}};n.EventListeners={Core:(new n.SequentialExecutor).addNamedListeners(function(e,t){t("VALIDATE_CREDENTIALS","validate",function r(e,t){e.service.config.getCredentials(function(e){if(e){e=n.util.error(e,{code:"SigningError",message:"Missing credentials in config"})}t(e)})});e("VALIDATE_REGION","validate",function s(e){if(!e.service.config.region&&!e.service.hasGlobalEndpoint()){throw n.util.error(new Error,{code:"SigningError",message:"Missing region in config"})}});e("VALIDATE_PARAMETERS","validate",function a(e){var t=e.service.api.operations[e.operation].input;(new n.ParamValidator).validate(t,e.params)});e("SET_CONTENT_LENGTH","afterBuild",function o(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 u(e){e.httpRequest.headers["Host"]=e.httpRequest.endpoint.host});t("SIGN","sign",function c(e,t){if(!e.service.api.signatureVersion)return t();e.service.config.getCredentials(function(r,i){try{if(r)return t(r);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);t()}catch(u){t(u)}})});e("SETUP_ERROR","extractError",function l(e){if(this.service.successfulResponse(e,this)){throw null}e.error=n.util.error(new Error,{code:"UnknownError",message:"An unknown error occurred."});e.data=null});e("SETUP_DATA","extractData",function p(e){e.data={};e.error=null});e("SEND","send",function f(e){function t(t){e.httpResponse.stream=t;t.on("headers",function r(i,s){e.request.emitEvent("httpHeaders",[i,s,e]);if(!e.request.httpRequest._streaming){if(n.HttpClient.streamsApiVersion===2){t.on("readable",function a(){var r=t.read();if(r!==null){e.request.emitEvent("httpData",[r,e])}})}else{t.on("data",function o(t){e.request.emitEvent("httpData",[t,e])})}}});t.on("end",function i(){e.request.emitEvent("httpDone",[e])})}function r(t){t.on("sendProgress",function r(t){e.request.emitEvent("httpUploadProgress",[t,e])});t.on("receiveProgress",function n(t){e.request.emitEvent("httpDownloadProgress",[t,e])})}function i(t){t=n.util.error(t,{code:"NetworkingError",region:e.request.httpRequest.region,hostname:e.request.httpRequest.endpoint.hostname,retryable:true});e.request.emitEvent("httpError",[t,e])}var s=n.HttpClient.getInstance();var a=e.request.service.config.httpOptions||{};var o=s.handleRequest(this.httpRequest,a,t,i);r(o)});e("HTTP_HEADERS","httpHeaders",function m(e,t,r){r.httpResponse.statusCode=e;r.httpResponse.headers=t;r.httpResponse.body=new i("");r.httpResponse.buffers=[];r.httpResponse.numBytes=0});e("HTTP_DATA","httpData",function d(e,t){if(e){if(n.util.isNode()){t.httpResponse.numBytes+=e.length;var r=t.httpResponse.headers["content-length"];var s={loaded:t.httpResponse.numBytes,total:r};t.request.emitEvent("httpDownloadProgress",[s,t])}t.httpResponse.buffers.push(new i(e))}});e("HTTP_DONE","httpDone",function h(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;this.completeRequest(e)});e("HTTP_ERROR","httpError",function y(e,t){t.error=e;this.completeRequest(t)});e("FINALIZE_ERROR","retry",function b(e){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 g(e){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 v(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 E(e){if(e.error){if(e.error.redirect&&e.redirectCount<this.service.config.maxRedirects){e.redirectCount++}else if(e.error.retryable&&e.retryCount<this.service.numRetries()){e.retryCount++}else{throw e.error}}});t("RETRY_SIGN","retry",function w(e,t){this.emitEvent("sign",e,t)});t("RETRY_DELAY_SEND","retry",function S(e,t){var r=0;if(!e.error.redirect){r=this.service.retryDelays()[e.retryCount-1]||0}e.error=null;e.data=null;setTimeout(function(){e.request.emitEvent("send",e,t)},r)})}),Logger:(new n.SequentialExecutor).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 l="";if(o)l+="[33m";l+="[AWS "+r.service.serviceIdentifier+" "+u;l+=" "+a.toString()+"s "+t.retryCount+" retries]";if(o)l+="[0;1m";l+=" "+r.operation+"("+c+")";if(o)l+="[0m";return l}var a=s();if(typeof i.log==="function"){i.log(a)}else if(typeof i.write==="function"){i.write(a+"\n")}})}),Json:(new n.SequentialExecutor).addNamedListeners(function(e){var t=n.ServiceInterface.Json;e("BUILD","build",t.buildRequest);e("EXTRACT_DATA","extractData",t.extractData);e("EXTRACT_ERROR","extractError",t.extractError)}),Rest:(new n.SequentialExecutor).addNamedListeners(function(e){var t=n.ServiceInterface.Rest;e("BUILD","build",t.buildRequest);e("EXTRACT_DATA","extractData",t.extractData);e("EXTRACT_ERROR","extractError",t.extractError)}),RestJson:(new n.SequentialExecutor).addNamedListeners(function(e){var t=n.ServiceInterface.RestJson;e("BUILD","build",t.buildRequest);e("EXTRACT_DATA","extractData",t.extractData);e("EXTRACT_ERROR","extractError",t.extractError)}),RestXml:(new n.SequentialExecutor).addNamedListeners(function(e){var t=n.ServiceInterface.RestXml;e("BUILD","build",t.buildRequest);e("EXTRACT_DATA","extractData",t.extractData);e("EXTRACT_ERROR","extractError",t.extractError)}),Query:(new n.SequentialExecutor).addNamedListeners(function(e){var t=n.ServiceInterface.Query;e("BUILD","build",t.buildRequest);e("EXTRACT_DATA","extractData",t.extractData);e("EXTRACT_ERROR","extractError",t.extractError)})}},{"./core":33,"./sequential_executor":45,"./service_interface/json":47,"./service_interface/query":48,"./service_interface/rest":49,"./service_interface/rest_json":50,"./service_interface/rest_xml":51,buffer:12,util:29}],40:[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 l(){this.statusCode=undefined;this.headers={};this.body=undefined}});n.HttpClient=i({});n.HttpClient.getInstance=function p(){if(this.singleton===undefined){this.singleton=new this}return this.singleton}},{"./core":33}],41:[function(e,t,r){var n=e("__browserify_Buffer");var i=e("../core");var s=e("events").EventEmitter;e("../http");i.XHRClient=i.util.inherit({handleRequest:function a(e,t,r,n){var a=this;var o=e.endpoint;var u=new s;var c=o.protocol+"//"+o.hostname;if(o.port!=80&&o.port!=443){c+=":"+o.port}c+=e.path;var l=new XMLHttpRequest;e.stream=l;if(t.timeout){l.timeout=t.timeout}var p=false;l.addEventListener("readystatechange",function(){if(p)return;if(this.readyState===this.HEADERS_RECEIVED){try{l.responseType="arraybuffer"}catch(e){}if(l.status===0){p=true;return}u.statusCode=l.status;u.headers=a.parseHeaders(l.getAllResponseHeaders());u.emit("headers",u.statusCode,u.headers)}else if(this.readyState===this.DONE){a.finishRequest(l,u)}},false);l.upload.addEventListener("progress",function(e){u.emit("sendProgress",e)});l.addEventListener("progress",function(e){u.emit("receiveProgress",e)},false);l.addEventListener("timeout",function(){n(i.util.error(new Error("Timeout"),{code:"TimeoutError"}))},false);l.addEventListener("error",function(){n(i.util.error(new Error("Network Failure"),{code:"NetworkingError"}))},false);r(u);l.open(e.method,c,true);i.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 u},parseHeaders:function o(e){var t={};i.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 u(e,t){var r;if(e.responseType==="arraybuffer"&&e.response){var i=e.response;r=new n(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(e.responseText)}}catch(o){}if(r)t.emit("data",r);t.emit("end")}});i.HttpClient.prototype=i.XHRClient.prototype;i.HttpClient.streamsApiVersion=1},{"../core":33,"../http":40,__browserify_Buffer:10,events:8}],42:[function(e,t,r){var n=e("../core");var i=n.util.inherit;n.JSON={};n.JSON.Builder=i({constructor:function s(e,t){this.rules=e;this.timestampFormat=t.timestampFormat},build:function a(e){return JSON.stringify(this.translate(this.rules,e))},translate:function o(e,t){if(e.type=="structure"){var r={};n.util.each.call(this,t,function(t,n){var i=e.members[t]||{};r[t]=this.translate(i,n)});return r}else if(e.type=="list"){var i=[];n.util.arrayEach.call(this,t,function(t){var r=e.members||{};i.push(this.translate(r,t))});return i}else if(e.type=="map"){var s={};n.util.each.call(this,t,function(t,r){var n=e.members||{};s[t]=this.translate(n,r)});return s}else if(e.type=="timestamp"){var a=e.format||this.timestampFormat;return n.util.date.format(t,a)}else if(e.type=="integer"){return parseInt(t,10)}else if(e.type=="float"){return parseFloat(t)}else{return t}}})},{"../core":33}],43:[function(e,t,r){var n=e("__browserify_Buffer");var i=e("./core");i.ParamValidator=i.util.inherit({validate:function s(e,t,r){var n=(e||{}).members||{};var s=e?e.xml:null;if(s){n=i.util.merge(n,(n[s]||{}).members||{});delete n[s]}return this.validateStructure(n,t||{},r||"params")},validateStructure:function a(e,t,r){this.validateType(r,t,["object"],"structure");for(var n in e){if(!e.hasOwnProperty(n))continue;if(e[n].required&&t[n]===undefined){this.fail("MissingRequiredParameter","Missing required key '"+n+"' in "+r)}}for(n in t){if(!t.hasOwnProperty(n))continue;var i=t[n],s=e[n];if(s!==undefined){var a=[r,n].join(".");this.validateMember(s,i,a)}else{this.fail("UnexpectedParameter","Unexpected key '"+n+"' found in "+r)}}return true},validateMember:function o(e,t,r){var n=e.members||{};switch(e.type){case"structure":return this.validateStructure(n,t,r);case"list":return this.validateList(n,t,r);case"map":return this.validateMap(n,t,r);default:return this.validateScalar(e,t,r)}},validateList:function u(e,t,r){this.validateType(r,t,[Array]);for(var n=0;n<t.length;n++){this.validateMember(e,t[n],r+"["+n+"]")}},validateMap:function c(e,t,r){this.validateType(r,t,["object"],"map");for(var n in t){if(!t.hasOwnProperty(n))continue;this.validateMember(e,t[n],r+"['"+n+"']")}},validateScalar:function l(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 p(e,t){throw i.util.error(new Error(t),{code:e})},validateType:function f(e,t,r,n){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(i.util.isType(t,r[a]))return;if(!n&&!s)r=r.slice();r[a]=i.util.typeName(r[a])}s=true}var o=n;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 m(e,t){if(typeof t==="string"){var r=parseFloat(t);if(r.toString()===t)t=r}return this.validateType(e,t,["number"])},validatePayload:function d(t,r){if(typeof r==="string")return;if(r&&typeof r.byteLength==="number")return;if(i.util.isNode()){var s=e("stream").Stream;if(r instanceof n||r instanceof s)return}var a=["Buffer","Stream","File","Blob","ArrayBuffer","DataView"];if(r){for(var o=0;o<a.length;o++){if(i.util.isType(r,a[o]))return;if(i.util.typeName(r.constructor)===a[o])return}}this.fail("InvalidParameterType","Expected "+t+" to be a "+"string, Buffer, Stream, Blob, or typed array object")}})},{"./core":33,__browserify_Buffer:10,stream:20}],44:[function(e,t,r){var n=e("__browserify_process");var i=e("./core");var s=i.util.inherit;i.Request=s({constructor:function a(e,t,r){var n=e.endpoint;var s=e.config.region;if(e.hasGlobalEndpoint())s="us-east-1";this.service=e;this.operation=t;this.params=r||{};this.httpRequest=new i.HttpRequest(n,s);this.startTime=i.util.date.getDate();i.SequentialExecutor.call(this)},send:function o(e,t){if(e){this.on("complete",function(t){e.call(t,t.error,t.data)})}if(!t)t=new i.Response(this);var r=["validate","build","afterBuild","sign","send"];this.emitEvents(r,t,function(e){if(e){this.failRequest(t)}});return t},abort:function u(){this._events={error:this._events.error,complete:this._events.complete};if(this.httpRequest.stream){this.httpRequest.stream.abort()}var e=new i.Response(this);e.error=i.util.error(new Error("Request aborted by user"),{code:"RequestAbortedError",retryable:false});this.failRequest(e);return this},eachPage:function c(e){function t(r){var n=e.call(r,r.error,r.data);if(n===false)return;if(r.hasNextPage()){r.nextPage().on("complete",t).send()}else{e.call(r,null,null)}}this.on("complete",t).send()},eachItem:function l(e){function t(t,r){if(t)return e(t,null);if(r===null)return e(null,null);var n=this.request.service.paginationConfig(this.request.operation);var s=n.resultKey;if(Array.isArray(s))s=s[0];var a=i.util.jamespath.query(s,r);i.util.arrayEach(a,function(t){i.util.arrayEach(t,function(t){e(null,t)})})}this.eachPage(t)},isPageable:function p(){return this.service.paginationConfig(this.operation)?true:false},createReadStream:function f(){var t=e("stream");var r=this;var s=null;var a=false;if(i.HttpClient.streamsApiVersion===2){s=new t.Readable;s._read=function(){s.push("")}}else{s=new t.Stream;s.readable=true}s.sent=false;s.on("newListener",function(e){if(!s.sent&&(e==="data"||e==="readable")){if(e==="data")a=true;s.sent=true;n.nextTick(function(){r.send()})}});this.on("httpHeaders",function o(e,t,n){if(e<300){this.httpRequest._streaming=true;r.removeListener("httpData",i.EventListeners.Core.HTTP_DATA);r.removeListener("httpError",i.EventListeners.Core.HTTP_ERROR);r.on("httpError",function c(e,t){t.error=e;t.error.retryable=false;this.completeRequest(t)});var o=n.httpResponse.stream;s.response=n;s._read=function(){var e;while(e=o.read()){s.push(e)}s.push("")};var u=["end","error",a?"data":"readable"];i.util.arrayEach(u,function(e){o.on(e,function(t){s.emit(e,t)})})}});this.on("error",function(e){s.emit("error",e)});return s},completeRequest:function m(e){this.emitEvents(["extractError","extractData"],e,function(t){if(t){this.emitEvent("retry",e,function(t){if(t)this.failRequest(e)})}else{this.emitEvent("success",[e],this.unhandledErrorCallback);this.emitEvent("complete",[e],this.unhandledErrorCallback)}})},failRequest:function d(e){this.emitEvent("error",[e.error,e],this.unhandledErrorCallback);this.emitEvent("complete",[e],this.unhandledErrorCallback)},emitEvents:function h(e,t,r){if(!r)r=this.unhandledErrorCallback;if(t.error){r.call(this,t.error)}else if(e.length===0){r.call(this)}else{this.emitEvent(e[0],t,function(n){if(n){r.call(this,n)}else{this.emitEvents(e.slice(1),t,r)}})}},emitEvent:function y(e,t,r){if(!r)r=this.unhandledErrorCallback;var n=null;if(Array.isArray(t)){n=t[t.length-1]}else{n=t;t=this.eventParameters(e,n)}this.emit(e,t,function(e){if(e){n.error=e}r.call(this,e)})},eventParameters:function b(e,t){switch(e){case"validate":case"sign":case"build":case"afterBuild":return[this];default:return[t]}}});i.util.mixin(i.Request,i.SequentialExecutor);i.Response=s({constructor:function g(e){this.request=e;this.data=null;this.error=null;this.retryCount=0;this.redirectCount=0;this.httpResponse=new i.HttpResponse},nextPage:function v(e){var t;var r=this.request.service;var n=this.request.operation;try{t=r.paginationConfig(n,true)}catch(s){this.error=s}if(!this.hasNextPage()){if(e)e(this.error,null);else if(this.error)throw this.error;return null}var a=i.util.copy(this.request.params);if(!this.nextPageTokens){return e?e(null,null):null}else{var o=t.inputToken;if(typeof o==="string")o=[o];for(var u=0;u<o.length;u++){a[o[u]]=this.nextPageTokens[u]}return r.makeRequest(this.request.operation,a,e)}},hasNextPage:function E(){this.cacheNextPageTokens();if(this.nextPageTokens)return true;if(this.nextPageTokens===undefined)return undefined;else return false},cacheNextPageTokens:function w(){if(this.hasOwnProperty("nextPageTokens"))return this.nextPageTokens;this.nextPageTokens=undefined;var e=this.request.service.paginationConfig(this.request.operation);if(!e)return this.nextPageTokens;this.nextPageTokens=null;if(e.moreResults){if(!i.util.jamespath.find(e.moreResults,this.data)){return this.nextPageTokens}}var t=e.outputToken;if(typeof t==="string")t=[t];i.util.arrayEach.call(this,t,function(e){var t=i.util.jamespath.find(e,this.data);if(t){this.nextPageTokens=this.nextPageTokens||[];this.nextPageTokens.push(t)}});return this.nextPageTokens}})},{"./core":33,__browserify_process:11,stream:20}],45:[function(e,t,r){var n=e("__browserify_process");var i=e("./core");var s;i.SequentialExecutor=i.util.inherit({constructor:function a(){this.domain=null;if(e("events").usingDomains){s=e("domain");if(s.active)this.domain=s.active}this._events={}},listeners:function o(e){return this._events[e]?this._events[e].slice(0):[]},on:function u(e,t){if(this._events[e]){this._events[e].push(t)}else{this._events[e]=[t]}return this},onAsync:function c(e,t){t._isAsync=true;return this.on(e,t)},removeListener:function l(e,t){var r=this._events[e];if(r){var n=r.length;var i=-1;for(var s=0;s<n;++s){if(r[s]===t){i=s}}if(i>-1){r.splice(i,1)}}return this},removeAllListeners:function p(e){if(e){delete this._events[e]}else{this._events={}}return this},emit:function f(e,t,r){if(!r)r=this.unhandledErrorCallback;if(s&&this.domain instanceof s.Domain)this.domain.enter();var n=this.listeners(e);var i=n.length;this.callListeners(n,t,r);return i>0},callListeners:function m(e,t,r){if(e.length===0){r.call(this);if(s&&this.domain instanceof s.Domain)this.domain.exit()}else{var n=e.shift();if(n._isAsync){var i=function(n){if(n){r.call(this,n);if(s&&this.domain instanceof s.Domain)this.domain.exit()}else{this.callListeners(e,t,r)}}.bind(this);n.apply(this,t.concat([i]))}else{try{n.apply(this,t);this.callListeners(e,t,r)}catch(a){r.call(this,a);if(s&&this.domain instanceof s.Domain)this.domain.exit()}}}},addListeners:function d(e){var t=this;if(e._events)e=e._events;i.util.each(e,function(e,r){if(typeof r==="function")r=[r];i.util.arrayEach(r,function(r){t.on(e,r)})});return t},addNamedListener:function h(e,t,r){this[e]=r;this.addListener(t,r);return this},addNamedAsyncListener:function y(e,t,r){r._isAsync=true;return this.addNamedListener(e,t,r)},addNamedListeners:function b(e){var t=this;e(function(){t.addNamedListener.apply(t,arguments)},function(){t.addNamedAsyncListener.apply(t,arguments)});return this},unhandledErrorCallback:function g(e){if(e){if(s&&this.domain instanceof s.Domain){e.domainEmitter=this;e.domain=this.domain;e.domainThrown=false;this.domain.emit("error",e)}else if(n.exit){console.error(e.stack?e.stack:e);n.exit(1)}else{throw e}}}});i.SequentialExecutor.prototype.addListener=i.SequentialExecutor.prototype.on},{"./core":33,__browserify_process:11,domain:1,events:8}],46:[function(e,t,r){var n="/";var i=e("./core");var s=e("./api/translator");var a=i.util.inherit;i.Service=a({constructor:function o(e){if(!this.loadServiceClass){throw i.util.error(new Error,"Service must be constructed with `new' operator")}var t=this.loadServiceClass(e||{});if(t)return new t(e);this.initialize(e)},initialize:function u(e){i.util.hideProperties(this,["client"]);this.client=this;this.config=new i.Config(i.config);if(e)this.config.update(e,true);this.setEndpoint(this.config.endpoint)},loadServiceClass:function c(e){var t=e;if(!i.util.isEmpty(this.api)){return}else if(t.apiConfig){return i.Service.defineServiceApi(this.constructor,t.apiConfig)}else if(!this.constructor.services){return}else{t=new i.Config(i.config);t.update(e,true);var r=t.apiVersions[this.constructor.serviceIdentifier];r=r||t.apiVersion;return this.getLatestServiceClass(r)}},getLatestServiceClass:function l(e){e=this.getLatestServiceVersion(e);if(this.constructor.services[e]===null){i.Service.defineServiceApi(this.constructor,e)}return this.constructor.services[e]},getLatestServiceVersion:function p(e){if(!this.constructor.services||this.constructor.services.length===0){throw new Error("No services defined on "+this.constructor.serviceIdentifier)}if(!e){e="latest"}else if(i.util.isType(e,Date)){e=i.util.date.iso8601(e).split("T")[0]}if(Object.hasOwnProperty(this.constructor.services,e)){return e}var t=Object.keys(this.constructor.services).sort();var r=null;for(var n=t.length-1;n>=0;n--){if(t[n][t[n].length-1]!=="*"){r=t[n]}if(t[n].substr(0,10)<=e){return r}}throw new Error("Could not find "+this.constructor.serviceIdentifier+" API to satisfy version constraint `"+e+"'")},api:{},defaultRetryCount:3,makeRequest:function f(e,t,r){if(typeof t==="function"){r=t;t=null}t=t||{};if(this.config.params){var n=this.api.operations[e];if(n){t=i.util.copy(t);i.util.each(this.config.params,function(e,r){if(n.input.members[e]){if(t[e]===undefined||t[e]===null){t[e]=r}}})}}var s=new i.Request(this,e,t);this.addAllRequestListeners(s);if(r)s.send(r);return s},makeUnauthenticatedRequest:function m(e,t,r){if(typeof t==="function"){r=t;t={}}var n=this.makeRequest(e,t);n.removeListener("validate",i.EventListeners.Core.VALIDATE_CREDENTIALS);n.removeListener("sign",i.EventListeners.Core.SIGN);n.addListener("build",function s(e){e.httpRequest.method="GET";e.httpRequest.path="/?"+e.httpRequest.body;e.httpRequest.body="";delete e.httpRequest.headers["Content-Length"];delete e.httpRequest.headers["Content-Type"]});return r?n.send(r):n},addAllRequestListeners:function d(e){var t=[i.events,i.EventListeners.Core,this.serviceInterface()];for(var r=0;r<t.length;r++){if(t[r])e.addListeners(t[r])}if(!this.config.paramValidation){e.removeListener("validate",i.EventListeners.Core.VALIDATE_PARAMETERS)}if(this.config.logger){e.addListeners(i.EventListeners.Logger)}this.setupRequestListeners(e)},setupRequestListeners:function h(){},getSignerClass:function y(){var e=this.api.signatureVersion;if(this.config.signatureVersion)e=this.config.signatureVersion;else if(this.isRegionV4())e="v4";return i.Signers.RequestSigner.getVersion(e)},serviceInterface:function b(){switch(this.api.format){case"query":return i.EventListeners.Query;case"json":return i.EventListeners.Json;case"rest-json":return i.EventListeners.RestJson;case"rest-xml":return i.EventListeners.RestXml}if(this.api.format){throw new Error("Invalid service `format' "+this.api.format+" in API config")}},successfulResponse:function g(e){return e.httpResponse.statusCode<300},numRetries:function v(){if(this.config.maxRetries!==undefined){return this.config.maxRetries}else{return this.defaultRetryCount}},retryDelays:function E(){var e=this.numRetries();var t=[];for(var r=0;r<e;++r){t[r]=Math.pow(2,r)*30}return t},retryableError:function w(e){if(this.networkingError(e))return true;if(this.expiredCredentialsError(e))return true;if(this.throttledError(e))return true;if(e.statusCode>=500)return true;return false},networkingError:function S(e){return e.code=="NetworkingError"},expiredCredentialsError:function T(e){return e.code==="ExpiredTokenException"},throttledError:function C(e){return e.code=="ProvisionedThroughputExceededException"},setEndpoint:function A(e){if(e){this.endpoint=new i.Endpoint(e,this.config)}else if(this.hasGlobalEndpoint()){this.endpoint=new i.Endpoint(this.api.globalEndpoint,this.config)}else{var t=this.api.endpointPrefix+"."+this.config.region+this.endpointSuffix();this.endpoint=new i.Endpoint(t,this.config)}},hasGlobalEndpoint:function x(){if(this.isRegionV4())return false;return this.api.globalEndpoint},endpointSuffix:function I(){var e=".amazonaws.com";if(this.isRegionCN())return e+".cn";else return e},isRegionCN:function R(){if(!this.config.region)return false;return this.config.region.match(/^cn-/)?true:false},isRegionV4:function k(){return this.isRegionCN()},paginationConfig:function N(e,t){function r(e){if(t){var r=new Error;throw i.util.error(r,"No pagination configuration for "+e)}return null}if(!this.api.pagination)return r("service");if(!this.api.pagination[e])return r(e);return this.api.pagination[e]}});i.util.update(i.Service,{defineMethods:function B(e){i.util.each(e.prototype.api.operations,function t(r){if(e.prototype[r])return;e.prototype[r]=function(e,t){return this.makeRequest(r,e,t)}})},defineService:function _(e,t,r){if(!Array.isArray(t)){r=t;t=[]}var n=a(i.Service,r||{});n.Client=n;if(typeof e==="string"){var s={};for(var o=0;o<t.length;o++){s[t[o]]=null}n.services=n.services||s;n.apiVersions=Object.keys(n.services).sort();n.serviceIdentifier=n.serviceIdentifier||e}else{n.prototype.api=e;i.Service.defineMethods(n)}return n},defineServiceApi:function q(t,r,o){var u=a(t,{serviceIdentifier:t.serviceIdentifier});function c(e){if(e.type&&e.api_version){u.prototype.api=new s(e,{documentation:false})}else{u.prototype.api=e}}if(typeof r==="string"){if(o){c(o)}else{var l=t.serviceIdentifier+"-"+r;var p=n+"/../apis/"+l+".json";try{var f=e("fs");c(JSON.parse(f.readFileSync(p)))}catch(m){throw i.util.error(m,{message:"Could not find API configuration "+l})}}if(!t.services.hasOwnProperty(r)){t.apiVersions.push(r)}t.services[r]=u}else{c(r)}i.Service.defineMethods(u);return u}})},{"./api/translator":30,"./core":33,fs:1}],47:[function(e,t,r){var n=e("../core");e("../json/builder");n.ServiceInterface.Json={buildRequest:function i(e){var t=e.httpRequest;var r=e.service.api;var i=r.targetPrefix+"."+r.operations[e.operation].name;var s=r.jsonVersion||"1.0";var a=r.operations[e.operation].input;var o=new n.JSON.Builder(a,r);t.path="/";t.body=o.build(e.params||{});t.headers["Content-Type"]="application/x-amz-json-"+s;t.headers["X-Amz-Target"]=i},extractError:function s(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.util.error(new Error,t)},extractData:function a(e){e.data=JSON.parse(e.httpResponse.body.toString()||"{}")}}},{"../core":33,"../json/builder":42}],48:[function(e,t,r){var n=e("../core");var i=n.util.inherit;e("../xml/parser");n.ServiceInterface.Query={buildRequest:function s(e){var t=e.service.api.operations[e.operation];var r=e.httpRequest;r.path="/";r.headers["Content-Type"]="application/x-www-form-urlencoded; charset=utf-8";r.params={Version:e.service.api.apiVersion,Action:t.name};var i=t.input;if(i)i=i.members;var s=new n.QueryParamSerializer(i,e.service.api);s.serialize(e.params,function(e,t){r.params[e]=t});r.body=n.util.queryParamsToString(r.params)},extractError:function a(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=n.util.error(new Error,{code:t.Code,message:t.Message})}else{e.error=n.util.error(new Error,{code:e.httpResponse.statusCode,message:null})}},extractData:function o(e){var t=e.request;var r=t.service.api.operations[t.operation];var i=r.name+"Result";var s=r.output||{};if(t.service.api.resultWrapped){var a={type:"structure",members:{}};a.members[i]=s;s=a}var o=new n.XML.Parser(s);var u=o.parse(e.httpResponse.body.toString());if(t.service.api.resultWrapped){if(u[i]){n.util.update(u,u[i]);delete u[i]}}n.util.each((r.output||{}).members||{},function(e,t){if(t.wrapper&&u[e]){n.util.update(u,u[e]);delete u[e]}});e.data=u}};n.QueryParamSerializer=i({constructor:function u(e,t){this.rules=e;this.timestampFormat=t?t.timestampFormat:"iso8601"},serialize:function c(e,t){this.serializeStructure("",e,this.rules,t)},serializeStructure:function l(e,t,r,i){var s=this;n.util.each(t,function(t,n){var a=r[t].name||t;var o=e?e+"."+a:a;s.serializeMember(o,n,r[t],i)})},serializeMap:function p(e,t,r,i){var s=1;var a=this;n.util.each(t,function(t,n){var o=r.flattened?".":".entry.";var u=o+s++ +".";var c=u+(r.keys.name||"key");var l=u+(r.members.name||"value");a.serializeMember(e+c,t,r.keys,i);a.serializeMember(e+l,n,r.members,i)})},serializeList:function f(e,t,r,i){var s=this;var a=r.members||{};n.util.arrayEach(t,function(t,n){var o="."+(n+1);if(r.flattened){if(a.name){var u=e.split(".");u.pop(); | |
u.push(a.name);e=u.join(".")}}else{o=".member"+o}s.serializeMember(e+o,t,a,i)})},serializeMember:function m(e,t,r,i){if(r.type==="structure"){this.serializeStructure(e,t,r.members,i)}else if(r.type==="list"){this.serializeList(e,t,r,i)}else if(r.type==="map"){this.serializeMap(e,t,r,i)}else if(r.type==="timestamp"){var s=r.format||this.timestampFormat;i.call(this,e,n.util.date.format(t,s))}else{i.call(this,e,String(t))}}})},{"../core":33,"../xml/parser":67}],49:[function(e,t,r){var n=e("../core");n.ServiceInterface.Rest={buildRequest:function i(e){n.ServiceInterface.Rest.populateMethod(e);n.ServiceInterface.Rest.populateURI(e);n.ServiceInterface.Rest.populateHeaders(e)},extractError:function s(){},extractData:function a(e){var t=e.request;var r={};var i=e.httpResponse;var s=t.service.api.operations[t.operation];var a=(s.output||{}).members||{};var o={};n.util.each(i.headers,function(e,t){o[e.toLowerCase()]=t});n.util.each(a,function(e,t){if(t.location==="header"){var s=(t.name||e).toLowerCase();if(t.type=="map"){r[e]={};n.util.each(i.headers,function(n,i){var s=n.match(new RegExp("^"+t.name+"(.+)","i"));if(s!==null){r[e][s[1]]=i}})}if(o[s]!==undefined){r[e]=o[s]}}if(t.location==="status"){r[e]=parseInt(i.statusCode,10)}});e.data=r},populateMethod:function o(e){e.httpRequest.method=e.service.api.operations[e.operation].http.method},populateURI:function u(e){var t=e.service.api.operations[e.operation];var r=t.http.uri;var i=r.split(/\?/)[0];var s=(t.input||{}).members||{};var a=e.service.escapePathParam||n.ServiceInterface.Rest.escapePathParam;var o=e.service.escapeQuerystringParam||n.ServiceInterface.Rest.escapeQuerystringParam;n.util.each.call(this,s,function(t,n){if(n.location=="uri"&&e.params[t]){var s=i.match("{"+t+"}")?a(e.params[t]):o(e.params[t]);r=r.replace("{"+t+"}",s)}});var u=r.split("?")[0];var c=r.split("?")[1];if(c){var l=[];n.util.arrayEach(c.split("&"),function(e){if(!e.match("{\\w+}"))l.push(e)});r=l.length>0?u+"?"+l.join("&"):u}else{r=u}e.httpRequest.path=r},escapePathParam:function c(e){return n.util.uriEscape(String(e))},escapeQuerystringParam:function l(e){return n.util.uriEscape(String(e))},populateHeaders:function p(e){var t=e.service.api.operations[e.operation];var r=(t.input||{}).members||{};n.util.each.call(this,r,function(t,r){if(r.location==="header"&&e.params[t]){if(r.type==="map"){n.util.each(e.params[t],function(t,n){e.httpRequest.headers[r.name+t]=n})}else{var i=e.params[t];if(r.type==="timestamp"){var s=r.format||e.service.api.timestampFormat;i=n.util.date.format(i,s)}e.httpRequest.headers[r.name||t]=i}}})}}},{"../core":33}],50:[function(e,t,r){var n=e("../core");e("./rest");e("./json");n.ServiceInterface.RestJson={buildRequest:function i(e){n.ServiceInterface.Rest.buildRequest(e);n.ServiceInterface.RestJson.populateBody(e)},extractError:function s(e){n.ServiceInterface.Json.extractError(e)},extractData:function a(e){n.ServiceInterface.Rest.extractData(e);var t=e.request;var r=t.service.api.operations[t.operation].output||{};if(r.payload&&r.members[r.payload]){if(r.members[r.payload].streaming){e.data[r.payload]=e.httpResponse.body}else{e.data[r.payload]=e.httpResponse.body.toString()}}else{var i=e.data;n.ServiceInterface.Json.extractData(e);e.data=n.util.merge(i,e.data)}e.data.RequestId=e.httpResponse.headers["x-amz-request-id"]||e.httpResponse.headers["x-amzn-requestid"]},populateBody:function o(e){var t=e.service.api.operations[e.operation].input;var r=t.payload;var i={};if(typeof r==="string"){var s=t.members[r];i=e.params[r];if(i===undefined)return;if(s.type==="structure"){e.httpRequest.body=this.buildJSON(i,t,e.service.api)}else{e.httpRequest.body=i}}else if(r){n.util.arrayEach(r,function(t){if(e.params[t]!==undefined){i[t]=e.params[t]}});e.httpRequest.body=this.buildJSON(i,t,e.service.api)}},buildJSON:function u(e,t,r){var i=new n.JSON.Builder(t,r);return i.build(e)}}},{"../core":33,"./json":47,"./rest":49}],51:[function(e,t,r){var n=e("../core");e("../xml/builder");e("./rest");n.ServiceInterface.RestXml={buildRequest:function i(e){n.ServiceInterface.Rest.buildRequest(e);n.ServiceInterface.RestXml.populateBody(e)},extractError:function s(e){n.ServiceInterface.Rest.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=n.util.error(new Error,{code:t.Code,message:t.Message})}else{e.error=n.util.error(new Error,{code:e.httpResponse.statusCode,message:null})}},extractData:function a(e){n.ServiceInterface.Rest.extractData(e);var t=e.request;var r=e.httpResponse;var i=t.service.api.operations[t.operation];var s=i.output.members;var a=i.output;var o=a.payload;if(o){if(s[o].streaming){e.data[o]=r.body}else{e.data[o]=r.body.toString()}}else if(r.body.length>0){var u=new n.XML.Parser(i.output||{});n.util.update(e.data,u.parse(r.body.toString()))}e.data.RequestId=r.headers["x-amz-request-id"]||r.headers["x-amzn-requestid"]},populateBody:function o(e){var t=e.service.api.operations[e.operation].input;var r=t.payload;var i={};var s=null;var a=e.params;if(typeof r==="string"){i=t.members[r];a=a[r];if(a===undefined)return;if(i.type==="structure"){s=new n.XML.Builder(r,i.members,e.service.api);e.httpRequest.body=s.toXML(a)}else{e.httpRequest.body=a}}else if(r){n.util.arrayEach(r,function(e){i[e]=t.members[e]});s=new n.XML.Builder(t.wrapper,i,e.service.api);e.httpRequest.body=s.toXML(a)}}}},{"../core":33,"../xml/builder":66,"./rest":49}],52:[function(e,t,r){var n=e("./core");t.exports=n;n.Service.defineServiceApi(e("./services/dynamodb"),"2012-08-10",{format:"json",apiVersion:"2012-08-10",endpointPrefix:"dynamodb",jsonVersion:"1.0",serviceAbbreviation:"DynamoDB",serviceFullName:"Amazon DynamoDB",signatureVersion:"v4",targetPrefix:"DynamoDB_20120810",timestampFormat:"iso8601",operations:{batchGetItem:{name:"BatchGetItem",input:{type:"structure",members:{RequestItems:{type:"map",keys:{},members:{type:"structure",members:{Keys:{type:"list",members:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},required:true},AttributesToGet:{type:"list",members:{}},ConsistentRead:{type:"boolean"}}},required:true},ReturnConsumedCapacity:{}}},output:{type:"structure",members:{Responses:{type:"map",keys:{},members:{type:"list",members:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}}}},UnprocessedKeys:{type:"map",keys:{},members:{type:"structure",members:{Keys:{type:"list",members:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}}},AttributesToGet:{type:"list",members:{}},ConsistentRead:{type:"boolean"}}}},ConsumedCapacity:{type:"list",members:{type:"structure",members:{TableName:{},CapacityUnits:{type:"float"},Table:{type:"structure",members:{CapacityUnits:{type:"float"}}},LocalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}},GlobalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}}}}}}}},batchWriteItem:{name:"BatchWriteItem",input:{type:"structure",members:{RequestItems:{type:"map",keys:{},members:{type:"list",members:{type:"structure",members:{PutRequest:{type:"structure",members:{Item:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},required:true}}},DeleteRequest:{type:"structure",members:{Key:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},required:true}}}}}},required:true},ReturnConsumedCapacity:{},ReturnItemCollectionMetrics:{}}},output:{type:"structure",members:{UnprocessedItems:{type:"map",keys:{},members:{type:"list",members:{type:"structure",members:{PutRequest:{type:"structure",members:{Item:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}}}},DeleteRequest:{type:"structure",members:{Key:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}}}}}}}},ItemCollectionMetrics:{type:"map",keys:{},members:{type:"list",members:{type:"structure",members:{ItemCollectionKey:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},SizeEstimateRangeGB:{type:"list",members:{type:"float"}}}}}},ConsumedCapacity:{type:"list",members:{type:"structure",members:{TableName:{},CapacityUnits:{type:"float"},Table:{type:"structure",members:{CapacityUnits:{type:"float"}}},LocalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}},GlobalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}}}}}}}},createTable:{name:"CreateTable",input:{type:"structure",members:{AttributeDefinitions:{type:"list",members:{type:"structure",members:{AttributeName:{required:true},AttributeType:{required:true}}},required:true},TableName:{required:true},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{required:true},KeyType:{required:true}}},required:true},LocalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{required:true},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{required:true},KeyType:{required:true}}},required:true},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}},required:true}}}},GlobalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{required:true},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{required:true},KeyType:{required:true}}},required:true},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}},required:true},ProvisionedThroughput:{type:"structure",members:{ReadCapacityUnits:{type:"integer",required:true},WriteCapacityUnits:{type:"integer",required:true}},required:true}}}},ProvisionedThroughput:{type:"structure",members:{ReadCapacityUnits:{type:"integer",required:true},WriteCapacityUnits:{type:"integer",required:true}},required:true}}},output:{type:"structure",members:{TableDescription:{type:"structure",members:{AttributeDefinitions:{type:"list",members:{type:"structure",members:{AttributeName:{},AttributeType:{}}}},TableName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},TableStatus:{},CreationDateTime:{type:"timestamp"},ProvisionedThroughput:{type:"structure",members:{LastIncreaseDateTime:{type:"timestamp"},LastDecreaseDateTime:{type:"timestamp"},NumberOfDecreasesToday:{type:"integer"},ReadCapacityUnits:{type:"integer"},WriteCapacityUnits:{type:"integer"}}},TableSizeBytes:{type:"integer"},ItemCount:{type:"integer"},LocalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}}},IndexSizeBytes:{type:"integer"},ItemCount:{type:"integer"}}}},GlobalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}}},IndexStatus:{},ProvisionedThroughput:{type:"structure",members:{LastIncreaseDateTime:{type:"timestamp"},LastDecreaseDateTime:{type:"timestamp"},NumberOfDecreasesToday:{type:"integer"},ReadCapacityUnits:{type:"integer"},WriteCapacityUnits:{type:"integer"}}},IndexSizeBytes:{type:"integer"},ItemCount:{type:"integer"}}}}}}}}},deleteItem:{name:"DeleteItem",input:{type:"structure",members:{TableName:{required:true},Key:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},required:true},Expected:{type:"map",keys:{},members:{type:"structure",members:{Value:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},Exists:{type:"boolean"}}}},ReturnValues:{},ReturnConsumedCapacity:{},ReturnItemCollectionMetrics:{}}},output:{type:"structure",members:{Attributes:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ConsumedCapacity:{type:"structure",members:{TableName:{},CapacityUnits:{type:"float"},Table:{type:"structure",members:{CapacityUnits:{type:"float"}}},LocalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}},GlobalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}}}},ItemCollectionMetrics:{type:"structure",members:{ItemCollectionKey:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},SizeEstimateRangeGB:{type:"list",members:{type:"float"}}}}}}},deleteTable:{name:"DeleteTable",input:{type:"structure",members:{TableName:{required:true}}},output:{type:"structure",members:{TableDescription:{type:"structure",members:{AttributeDefinitions:{type:"list",members:{type:"structure",members:{AttributeName:{},AttributeType:{}}}},TableName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},TableStatus:{},CreationDateTime:{type:"timestamp"},ProvisionedThroughput:{type:"structure",members:{LastIncreaseDateTime:{type:"timestamp"},LastDecreaseDateTime:{type:"timestamp"},NumberOfDecreasesToday:{type:"integer"},ReadCapacityUnits:{type:"integer"},WriteCapacityUnits:{type:"integer"}}},TableSizeBytes:{type:"integer"},ItemCount:{type:"integer"},LocalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}}},IndexSizeBytes:{type:"integer"},ItemCount:{type:"integer"}}}},GlobalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}}},IndexStatus:{},ProvisionedThroughput:{type:"structure",members:{LastIncreaseDateTime:{type:"timestamp"},LastDecreaseDateTime:{type:"timestamp"},NumberOfDecreasesToday:{type:"integer"},ReadCapacityUnits:{type:"integer"},WriteCapacityUnits:{type:"integer"}}},IndexSizeBytes:{type:"integer"},ItemCount:{type:"integer"}}}}}}}}},describeTable:{name:"DescribeTable",input:{type:"structure",members:{TableName:{required:true}}},output:{type:"structure",members:{Table:{type:"structure",members:{AttributeDefinitions:{type:"list",members:{type:"structure",members:{AttributeName:{},AttributeType:{}}}},TableName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},TableStatus:{},CreationDateTime:{type:"timestamp"},ProvisionedThroughput:{type:"structure",members:{LastIncreaseDateTime:{type:"timestamp"},LastDecreaseDateTime:{type:"timestamp"},NumberOfDecreasesToday:{type:"integer"},ReadCapacityUnits:{type:"integer"},WriteCapacityUnits:{type:"integer"}}},TableSizeBytes:{type:"integer"},ItemCount:{type:"integer"},LocalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}}},IndexSizeBytes:{type:"integer"},ItemCount:{type:"integer"}}}},GlobalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}}},IndexStatus:{},ProvisionedThroughput:{type:"structure",members:{LastIncreaseDateTime:{type:"timestamp"},LastDecreaseDateTime:{type:"timestamp"},NumberOfDecreasesToday:{type:"integer"},ReadCapacityUnits:{type:"integer"},WriteCapacityUnits:{type:"integer"}}},IndexSizeBytes:{type:"integer"},ItemCount:{type:"integer"}}}}}}}}},getItem:{name:"GetItem",input:{type:"structure",members:{TableName:{required:true},Key:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},required:true},AttributesToGet:{type:"list",members:{}},ConsistentRead:{type:"boolean"},ReturnConsumedCapacity:{}}},output:{type:"structure",members:{Item:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ConsumedCapacity:{type:"structure",members:{TableName:{},CapacityUnits:{type:"float"},Table:{type:"structure",members:{CapacityUnits:{type:"float"}}},LocalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}},GlobalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}}}}}}},listTables:{name:"ListTables",input:{type:"structure",members:{ExclusiveStartTableName:{},Limit:{type:"integer"}}},output:{type:"structure",members:{TableNames:{type:"list",members:{}},LastEvaluatedTableName:{}}}},putItem:{name:"PutItem",input:{type:"structure",members:{TableName:{required:true},Item:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},required:true},Expected:{type:"map",keys:{},members:{type:"structure",members:{Value:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},Exists:{type:"boolean"}}}},ReturnValues:{},ReturnConsumedCapacity:{},ReturnItemCollectionMetrics:{}}},output:{type:"structure",members:{Attributes:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ConsumedCapacity:{type:"structure",members:{TableName:{},CapacityUnits:{type:"float"},Table:{type:"structure",members:{CapacityUnits:{type:"float"}}},LocalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}},GlobalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}}}},ItemCollectionMetrics:{type:"structure",members:{ItemCollectionKey:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},SizeEstimateRangeGB:{type:"list",members:{type:"float"}}}}}}},query:{name:"Query",input:{type:"structure",members:{TableName:{required:true},IndexName:{},Select:{},AttributesToGet:{type:"list",members:{}},Limit:{type:"integer"},ConsistentRead:{type:"boolean"},KeyConditions:{type:"map",keys:{},members:{type:"structure",members:{AttributeValueList:{type:"list",members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ComparisonOperator:{required:true}}}},ScanIndexForward:{type:"boolean"},ExclusiveStartKey:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ReturnConsumedCapacity:{}}},output:{type:"structure",members:{Items:{type:"list",members:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}}},Count:{type:"integer"},LastEvaluatedKey:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ConsumedCapacity:{type:"structure",members:{TableName:{},CapacityUnits:{type:"float"},Table:{type:"structure",members:{CapacityUnits:{type:"float"}}},LocalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}},GlobalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}}}}}}},scan:{name:"Scan",input:{type:"structure",members:{TableName:{required:true},AttributesToGet:{type:"list",members:{}},Limit:{type:"integer"},Select:{},ScanFilter:{type:"map",keys:{},members:{type:"structure",members:{AttributeValueList:{type:"list",members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ComparisonOperator:{required:true}}}},ExclusiveStartKey:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ReturnConsumedCapacity:{},TotalSegments:{type:"integer"},Segment:{type:"integer"}}},output:{type:"structure",members:{Items:{type:"list",members:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}}},Count:{type:"integer"},ScannedCount:{type:"integer"},LastEvaluatedKey:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ConsumedCapacity:{type:"structure",members:{TableName:{},CapacityUnits:{type:"float"},Table:{type:"structure",members:{CapacityUnits:{type:"float"}}},LocalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}},GlobalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}}}}}}},updateItem:{name:"UpdateItem",input:{type:"structure",members:{TableName:{required:true},Key:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},required:true},AttributeUpdates:{type:"map",keys:{},members:{type:"structure",members:{Value:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},Action:{}}}},Expected:{type:"map",keys:{},members:{type:"structure",members:{Value:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}},Exists:{type:"boolean"}}}},ReturnValues:{},ReturnConsumedCapacity:{},ReturnItemCollectionMetrics:{}}},output:{type:"structure",members:{Attributes:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},ConsumedCapacity:{type:"structure",members:{TableName:{},CapacityUnits:{type:"float"},Table:{type:"structure",members:{CapacityUnits:{type:"float"}}},LocalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}},GlobalSecondaryIndexes:{type:"map",keys:{},members:{type:"structure",members:{CapacityUnits:{type:"float"}}}}}},ItemCollectionMetrics:{type:"structure",members:{ItemCollectionKey:{type:"map",keys:{},members:{type:"structure",members:{S:{},N:{},B:{type:"base64"},SS:{type:"list",members:{}},NS:{type:"list",members:{}},BS:{type:"list",members:{type:"base64"}}}}},SizeEstimateRangeGB:{type:"list",members:{type:"float"}}}}}}},updateTable:{name:"UpdateTable",input:{type:"structure",members:{TableName:{required:true},ProvisionedThroughput:{type:"structure",members:{ReadCapacityUnits:{type:"integer",required:true},WriteCapacityUnits:{type:"integer",required:true}}},GlobalSecondaryIndexUpdates:{type:"list",members:{type:"structure",members:{Update:{type:"structure",members:{IndexName:{required:true},ProvisionedThroughput:{type:"structure",members:{ReadCapacityUnits:{type:"integer",required:true},WriteCapacityUnits:{type:"integer",required:true}},required:true}}}}}}}},output:{type:"structure",members:{TableDescription:{type:"structure",members:{AttributeDefinitions:{type:"list",members:{type:"structure",members:{AttributeName:{},AttributeType:{}}}},TableName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},TableStatus:{},CreationDateTime:{type:"timestamp"},ProvisionedThroughput:{type:"structure",members:{LastIncreaseDateTime:{type:"timestamp"},LastDecreaseDateTime:{type:"timestamp"},NumberOfDecreasesToday:{type:"integer"},ReadCapacityUnits:{type:"integer"},WriteCapacityUnits:{type:"integer"}}},TableSizeBytes:{type:"integer"},ItemCount:{type:"integer"},LocalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}}},IndexSizeBytes:{type:"integer"},ItemCount:{type:"integer"}}}},GlobalSecondaryIndexes:{type:"list",members:{type:"structure",members:{IndexName:{},KeySchema:{type:"list",members:{type:"structure",members:{AttributeName:{},KeyType:{}}}},Projection:{type:"structure",members:{ProjectionType:{},NonKeyAttributes:{type:"list",members:{}}}},IndexStatus:{},ProvisionedThroughput:{type:"structure",members:{LastIncreaseDateTime:{type:"timestamp"},LastDecreaseDateTime:{type:"timestamp"},NumberOfDecreasesToday:{type:"integer"},ReadCapacityUnits:{type:"integer"},WriteCapacityUnits:{type:"integer"}}},IndexSizeBytes:{type:"integer"},ItemCount:{type:"integer"}}}}}}}}}},pagination:{batchGetItem:{inputToken:"RequestItems",outputToken:"UnprocessedKeys",resultKey:"Items"},listTables:{inputToken:"ExclusiveStartTableName",outputToken:"LastEvaluatedTableName",resultKey:"TableNames"},query:{inputToken:"ExclusiveStartKey",outputToken:"LastEvaluatedKey",resultKey:"Items"},scan:{inputToken:"ExclusiveStartKey",outputToken:"LastEvaluatedKey",resultKey:"Items"}}});n.Service.defineServiceApi(e("./services/s3"),"2006-03-01",{format:"rest-xml",apiVersion:"2006-03-01",checksumFormat:"md5",endpointPrefix:"s3",globalEndpoint:"s3.amazonaws.com",serviceAbbreviation:"Amazon S3",serviceFullName:"Amazon Simple Storage Service",signatureVersion:"s3",timestampFormat:"rfc822",xmlnamespace:"http://s3.amazonaws.com/doc/2006-03-01/",operations:{abortMultipartUpload:{name:"AbortMultipartUpload",http:{method:"DELETE",uri:"/{Bucket}/{Key}?uploadId={UploadId}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},Key:{required:true,location:"uri"},UploadId:{required:true,location:"uri"}}},output:{type:"structure",members:{}}},completeMultipartUpload:{name:"CompleteMultipartUpload",http:{method:"POST",uri:"/{Bucket}/{Key}?uploadId={UploadId}"},input:{payload:"MultipartUpload",type:"structure",members:{Bucket:{required:true,location:"uri"},Key:{required:true,location:"uri"},MultipartUpload:{type:"structure",name:"CompleteMultipartUpload",members:{Parts:{type:"list",name:"Part",members:{type:"structure",members:{ETag:{},PartNumber:{type:"integer"}}},flattened:true}}},UploadId:{required:true,location:"uri"}}},output:{type:"structure",members:{Bucket:{},ETag:{},Expiration:{type:"timestamp",location:"header",name:"x-amz-expiration"},Key:{},Location:{},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},VersionId:{location:"header",name:"x-amz-version-id"}}}},copyObject:{name:"CopyObject",alias:"PutObjectCopy",http:{method:"PUT",uri:"/{Bucket}/{Key}"},input:{type:"structure",members:{ACL:{location:"header",name:"x-amz-acl"},Bucket:{required:true,location:"uri"},CacheControl:{location:"header",name:"Cache-Control"},ContentDisposition:{location:"header",name:"Content-Disposition"},ContentEncoding:{location:"header",name:"Content-Encoding"},ContentLanguage:{location:"header",name:"Content-Language"},ContentType:{location:"header",name:"Content-Type"},CopySource:{required:true,location:"header",name:"x-amz-copy-source"},CopySourceIfMatch:{type:"timestamp",location:"header",name:"x-amz-copy-source-if-match"},CopySourceIfModifiedSince:{type:"timestamp",location:"header",name:"x-amz-copy-source-if-modified-since"},CopySourceIfNoneMatch:{type:"timestamp",location:"header",name:"x-amz-copy-source-if-none-match"},CopySourceIfUnmodifiedSince:{type:"timestamp",location:"header",name:"x-amz-copy-source-if-unmodified-since"},Expires:{type:"timestamp",location:"header",name:"Expires"},GrantFullControl:{location:"header",name:"x-amz-grant-full-control"},GrantRead:{location:"header",name:"x-amz-grant-read"},GrantReadACP:{location:"header",name:"x-amz-grant-read-acp"},GrantWriteACP:{location:"header",name:"x-amz-grant-write-acp"},Key:{required:true,location:"uri"},Metadata:{type:"map",location:"header",name:"x-amz-meta-",members:{},keys:{}},MetadataDirective:{location:"header",name:"x-amz-metadata-directive"},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},StorageClass:{location:"header",name:"x-amz-storage-class"},WebsiteRedirectLocation:{location:"header",name:"x-amz-website-redirect-location"}}},output:{type:"structure",members:{CopySourceVersionId:{location:"header",name:"x-amz-copy-source-version-id"},Expiration:{location:"header",name:"x-amz-expiration"},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},ETag:{},LastModified:{}}}},createBucket:{name:"CreateBucket",alias:"PutBucket",http:{method:"PUT",uri:"/{Bucket}"},input:{payload:"CreateBucketConfiguration",type:"structure",members:{ACL:{location:"header",name:"x-amz-acl"},Bucket:{required:true,location:"uri"},CreateBucketConfiguration:{type:"structure",members:{LocationConstraint:{}}},GrantFullControl:{location:"header",name:"x-amz-grant-full-control"},GrantRead:{location:"header",name:"x-amz-grant-read"},GrantReadACP:{location:"header",name:"x-amz-grant-read-acp"},GrantWrite:{location:"header",name:"x-amz-grant-write"},GrantWriteACP:{location:"header",name:"x-amz-grant-write-acp"}}},output:{type:"structure",members:{Location:{location:"header",name:"Location"}}}},createMultipartUpload:{name:"CreateMultipartUpload",alias:"InitiateMultipartUpload",http:{method:"POST",uri:"/{Bucket}/{Key}?uploads"},input:{type:"structure",members:{ACL:{location:"header",name:"x-amz-acl"},Bucket:{required:true,location:"uri"},CacheControl:{location:"header",name:"Cache-Control"},ContentDisposition:{location:"header",name:"Content-Disposition"},ContentEncoding:{location:"header",name:"Content-Encoding"},ContentLanguage:{location:"header",name:"Content-Language"},ContentType:{location:"header",name:"Content-Type"},Expires:{type:"timestamp",location:"header",name:"Expires"},GrantFullControl:{location:"header",name:"x-amz-grant-full-control"},GrantRead:{location:"header",name:"x-amz-grant-read"},GrantReadACP:{location:"header",name:"x-amz-grant-read-acp"},GrantWriteACP:{location:"header",name:"x-amz-grant-write-acp"},Key:{required:true,location:"uri"},Metadata:{type:"map",location:"header",name:"x-amz-meta-",members:{},keys:{}},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},StorageClass:{location:"header",name:"x-amz-storage-class"},WebsiteRedirectLocation:{location:"header",name:"x-amz-website-redirect-location"}}},output:{type:"structure",members:{Bucket:{name:"Bucket"},Key:{},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},UploadId:{}}}},deleteBucket:{name:"DeleteBucket",http:{method:"DELETE",uri:"/{Bucket}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{}}},deleteBucketCors:{name:"DeleteBucketCors",http:{method:"DELETE",uri:"/{Bucket}?cors"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{}}},deleteBucketLifecycle:{name:"DeleteBucketLifecycle",http:{method:"DELETE",uri:"/{Bucket}?lifecycle"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{}}},deleteBucketPolicy:{name:"DeleteBucketPolicy",http:{method:"DELETE",uri:"/{Bucket}?policy"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{}}},deleteBucketTagging:{name:"DeleteBucketTagging",http:{method:"DELETE",uri:"/{Bucket}?tagging"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{}}},deleteBucketWebsite:{name:"DeleteBucketWebsite",http:{method:"DELETE",uri:"/{Bucket}?website"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{}}},deleteObject:{name:"DeleteObject",http:{method:"DELETE",uri:"/{Bucket}/{Key}?versionId={VersionId}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},Key:{required:true,location:"uri"},MFA:{location:"header",name:"x-amz-mfa"},VersionId:{location:"uri"}}},output:{type:"structure",members:{DeleteMarker:{type:"boolean",location:"header",name:"x-amz-delete-marker"},VersionId:{location:"header",name:"x-amz-version-id"}}}},deleteObjects:{name:"DeleteObjects",alias:"DeleteMultipleObjects",http:{method:"POST",uri:"/{Bucket}?delete"},input:{payload:"Delete",type:"structure",members:{Bucket:{required:true,location:"uri"},Delete:{type:"structure",required:true,members:{Objects:{type:"list",required:true,name:"Object",members:{type:"structure",members:{Key:{required:true},VersionId:{}}},flattened:true},Quiet:{type:"boolean"}}},MFA:{location:"header",name:"x-amz-mfa"}}},output:{type:"structure",members:{Deleted:{type:"list",members:{type:"structure",members:{DeleteMarker:{type:"boolean"},DeleteMarkerVersionId:{},Key:{},VersionId:{}}},flattened:true},Error:{type:"list",name:"Errors",members:{type:"structure",members:{Code:{},Key:{},Message:{},VersionId:{}}},flattened:true}}}},getBucketAcl:{name:"GetBucketAcl",http:{method:"GET",uri:"/{Bucket}?acl"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{AccessControlList:{type:"list",name:"Grants",members:{type:"structure",name:"Grant",members:{Grantee:{type:"structure",xmlns:{uri:"http://www.w3.org/2001/XMLSchema-instance",prefix:"xsi"},members:{DisplayName:{},EmailAddress:{},ID:{},"xsi:type":{name:"Type",attribute:true},URI:{}}},Permission:{}}}},Owner:{type:"structure",members:{DisplayName:{},ID:{}}}}}},getBucketCors:{name:"GetBucketCors",http:{method:"GET",uri:"/{Bucket}?cors"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{CORSRule:{type:"list",name:"CORSRules",members:{type:"structure",members:{AllowedHeader:{type:"list",name:"AllowedHeaders",members:{},flattened:true},AllowedMethod:{type:"list",name:"AllowedMethods",members:{},flattened:true},AllowedOrigin:{type:"list",name:"AllowedOrigins",members:{},flattened:true},ExposeHeader:{type:"list",name:"ExposeHeaders",members:{},flattened:true},MaxAgeSeconds:{type:"integer"}}},flattened:true}}}},getBucketLifecycle:{name:"GetBucketLifecycle",http:{method:"GET",uri:"/{Bucket}?lifecycle"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{Rule:{type:"list",name:"Rules",members:{type:"structure",members:{Expiration:{type:"structure",members:{Date:{type:"timestamp",format:"iso8601"},Days:{type:"integer"}}},ID:{},Prefix:{},Status:{},Transition:{type:"structure",members:{Date:{type:"timestamp",format:"iso8601"},Days:{type:"integer"},StorageClass:{}}}}},flattened:true}}}},getBucketLocation:{name:"GetBucketLocation",http:{method:"GET",uri:"/{Bucket}?location"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{LocationConstraint:{}}}},getBucketLogging:{name:"GetBucketLogging",http:{method:"GET",uri:"/{Bucket}?logging"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{LoggingEnabled:{type:"structure",members:{TargetBucket:{},TargetGrants:{type:"list",members:{type:"structure",name:"Grant",members:{Grantee:{type:"structure",xmlns:{uri:"http://www.w3.org/2001/XMLSchema-instance",prefix:"xsi"},members:{DisplayName:{},EmailAddress:{},ID:{},"xsi:type":{name:"Type",attribute:true},URI:{}}},Permission:{}}}},TargetPrefix:{}}}}}},getBucketNotification:{name:"GetBucketNotification",http:{method:"GET",uri:"/{Bucket}?notification"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{TopicConfiguration:{type:"structure",members:{Event:{},Topic:{}}}}}},getBucketPolicy:{name:"GetBucketPolicy",http:{method:"GET",uri:"/{Bucket}?policy"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{Policy:{}},payload:"Policy"}},getBucketRequestPayment:{name:"GetBucketRequestPayment",http:{method:"GET",uri:"/{Bucket}?requestPayment"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{Payer:{}}}},getBucketTagging:{name:"GetBucketTagging",http:{method:"GET",uri:"/{Bucket}?tagging"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{TagSet:{type:"list",members:{type:"structure",name:"Tag",members:{Key:{},Value:{}}}}}}},getBucketVersioning:{name:"GetBucketVersioning",http:{method:"GET",uri:"/{Bucket}?versioning"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{MFADelete:{},Status:{}}}},getBucketWebsite:{name:"GetBucketWebsite",http:{method:"GET",uri:"/{Bucket}?website"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{ErrorDocument:{type:"structure",members:{Key:{}}},IndexDocument:{type:"structure",members:{Suffix:{}}},RedirectAllRequestsTo:{type:"structure",members:{HostName:{},Protocol:{}}},RoutingRules:{type:"list",members:{type:"structure",name:"RoutingRule",members:{Condition:{type:"structure",members:{HttpErrorCodeReturnedEquals:{},KeyPrefixEquals:{}}},Redirect:{type:"structure",members:{HostName:{},HttpRedirectCode:{},Protocol:{},ReplaceKeyPrefixWith:{},ReplaceKeyWith:{}}}}}}}}},getObject:{name:"GetObject",http:{method:"GET",uri:"/{Bucket}/{Key}?versionId={VersionId}&response-content-type={ResponseContentType}&response-content-language={ResponseContentLanguage}&response-expires={ResponseExpires}&response-cache-control={ResponseCacheControl}&response-content-disposition={ResponseContentDisposition}&response-content-encoding={ResponseContentEncoding}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},IfMatch:{location:"header",name:"If-Match"},IfModifiedSince:{type:"timestamp",location:"header",name:"If-Modified-Since"},IfNoneMatch:{location:"header",name:"If-None-Match"},IfUnmodifiedSince:{type:"timestamp",location:"header",name:"If-Unmodified-Since"},Key:{required:true,location:"uri"},Range:{location:"header",name:"Range"},ResponseCacheControl:{location:"uri"},ResponseContentDisposition:{location:"uri"},ResponseContentEncoding:{location:"uri"},ResponseContentLanguage:{location:"uri"},ResponseContentType:{location:"uri"},ResponseExpires:{type:"timestamp",location:"uri"},VersionId:{location:"uri"}}},output:{type:"structure",members:{AcceptRanges:{location:"header",name:"accept-ranges"},Body:{type:"binary",streaming:true},CacheControl:{location:"header",name:"Cache-Control"},ContentDisposition:{location:"header",name:"Content-Disposition"},ContentEncoding:{location:"header",name:"Content-Encoding"},ContentLanguage:{location:"header",name:"Content-Language"},ContentLength:{type:"integer",location:"header",name:"Content-Length"},ContentType:{location:"header",name:"Content-Type"},DeleteMarker:{type:"boolean",location:"header",name:"x-amz-delete-marker"},ETag:{location:"header",name:"ETag"},Expiration:{location:"header",name:"x-amz-expiration"},Expires:{type:"timestamp",location:"header",name:"Expires"},LastModified:{type:"timestamp",location:"header",name:"Last-Modified"},Metadata:{type:"map",location:"header",name:"x-amz-meta-",members:{},keys:{}},MissingMeta:{type:"integer",location:"header",name:"x-amz-missing-meta"},Restore:{location:"header",name:"x-amz-restore"},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},VersionId:{location:"header",name:"x-amz-version-id"},WebsiteRedirectLocation:{location:"header",name:"x-amz-website-redirect-location"}},payload:"Body"}},getObjectAcl:{name:"GetObjectAcl",http:{method:"GET",uri:"/{Bucket}/{Key}?acl&versionId={VersionId}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},Key:{required:true,location:"uri"},VersionId:{location:"uri"}}},output:{type:"structure",members:{AccessControlList:{type:"list",name:"Grants",members:{type:"structure",name:"Grant",members:{Grantee:{type:"structure",xmlns:{uri:"http://www.w3.org/2001/XMLSchema-instance",prefix:"xsi"},members:{DisplayName:{},EmailAddress:{},ID:{},"xsi:type":{name:"Type",attribute:true},URI:{}}},Permission:{}}}},Owner:{type:"structure",members:{DisplayName:{},ID:{}}}}}},getObjectTorrent:{name:"GetObjectTorrent",http:{method:"GET",uri:"/{Bucket}/{Key}?torrent"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},Key:{required:true,location:"uri"}}},output:{type:"structure",members:{Body:{type:"binary",streaming:true}},payload:"Body"}},headBucket:{name:"HeadBucket",http:{method:"HEAD",uri:"/{Bucket}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"}}},output:{type:"structure",members:{}}},headObject:{name:"HeadObject",http:{method:"HEAD",uri:"/{Bucket}/{Key}?versionId={VersionId}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},IfMatch:{location:"header",name:"If-Match"},IfModifiedSince:{type:"timestamp",location:"header",name:"If-Modified-Since"},IfNoneMatch:{location:"header",name:"If-None-Match"},IfUnmodifiedSince:{type:"timestamp",location:"header",name:"If-Unmodified-Since"},Key:{required:true,location:"uri"},Range:{location:"header",name:"Range"},VersionId:{location:"uri"}}},output:{type:"structure",members:{AcceptRanges:{location:"header",name:"accept-ranges"},CacheControl:{location:"header",name:"Cache-Control"},ContentDisposition:{location:"header",name:"Content-Disposition"},ContentEncoding:{location:"header",name:"Content-Encoding"},ContentLanguage:{location:"header",name:"Content-Language"},ContentLength:{type:"integer",location:"header",name:"Content-Length"},ContentType:{location:"header",name:"Content-Type"},DeleteMarker:{type:"boolean",location:"header",name:"x-amz-delete-marker"},ETag:{location:"header",name:"ETag"},Expiration:{location:"header",name:"x-amz-expiration"},Expires:{type:"timestamp",location:"header",name:"Expires"},LastModified:{type:"timestamp",location:"header",name:"Last-Modified"},Metadata:{type:"map",location:"header",name:"x-amz-meta-",members:{},keys:{}},MissingMeta:{type:"integer",location:"header",name:"x-amz-missing-meta"},Restore:{location:"header",name:"x-amz-restore"},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},VersionId:{location:"header",name:"x-amz-version-id"},WebsiteRedirectLocation:{location:"header",name:"x-amz-website-redirect-location"}}}},listBuckets:{name:"ListBuckets",alias:"GetService",http:{method:"GET",uri:"/"},input:{type:"structure",members:{}},output:{type:"structure",members:{Buckets:{type:"list",members:{type:"structure",name:"Bucket",members:{CreationDate:{type:"timestamp"},Name:{}}}},Owner:{type:"structure",members:{DisplayName:{},ID:{}}}}}},listMultipartUploads:{name:"ListMultipartUploads",http:{method:"GET",uri:"/{Bucket}?uploads&prefix={Prefix}&delimiter={Delimiter}&max-uploads={MaxUploads}&key-marker={KeyMarker}&upload-id-marker={UploadIdMarker}&encoding-type={EncodingType}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},Delimiter:{location:"uri"},EncodingType:{location:"uri"},KeyMarker:{location:"uri"},MaxUploads:{type:"integer",location:"uri"},Prefix:{location:"uri"},UploadIdMarker:{location:"uri"}}},output:{type:"structure",members:{Bucket:{},CommonPrefixes:{type:"list",members:{type:"structure",members:{Prefix:{}}},flattened:true},EncodingType:{location:"header",name:"Encoding-Type"},IsTruncated:{type:"boolean"},KeyMarker:{},MaxUploads:{type:"integer"},NextKeyMarker:{},NextUploadIdMarker:{},Prefix:{},UploadIdMarker:{},Upload:{type:"list",name:"Uploads",members:{type:"structure",members:{Initiated:{type:"timestamp"},Initiator:{type:"structure",members:{DisplayName:{},ID:{}}},Key:{},Owner:{type:"structure",members:{DisplayName:{},ID:{}}},StorageClass:{},UploadId:{}}},flattened:true}}}},listObjectVersions:{name:"ListObjectVersions",alias:"GetBucketObjectVersions",http:{method:"GET",uri:"/{Bucket}?versions&delimiter={Delimiter}&key-marker={KeyMarker}&max-keys={MaxKeys}&prefix={Prefix}&version-id-marker={VersionIdMarker}&encoding-type={EncodingType}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},Delimiter:{location:"uri"},EncodingType:{location:"uri"},KeyMarker:{location:"uri"},MaxKeys:{type:"integer",location:"uri"},Prefix:{location:"uri"},VersionIdMarker:{location:"uri"}}},output:{type:"structure",members:{CommonPrefixes:{type:"list",members:{type:"structure",members:{Prefix:{}}},flattened:true},DeleteMarker:{type:"list",name:"DeleteMarkers",members:{type:"structure",members:{IsLatest:{type:"boolean"},Key:{},LastModified:{type:"timestamp"},Owner:{type:"structure",members:{DisplayName:{},ID:{}}},VersionId:{}}},flattened:true},EncodingType:{location:"header",name:"Encoding-Type"},IsTruncated:{type:"boolean"},KeyMarker:{},MaxKeys:{type:"integer"},Name:{},NextKeyMarker:{},NextVersionIdMarker:{},Prefix:{},VersionIdMarker:{},Version:{type:"list",name:"Versions",members:{type:"structure",members:{ETag:{},IsLatest:{type:"boolean"},Key:{},LastModified:{type:"timestamp"},Owner:{type:"structure",members:{DisplayName:{},ID:{}}},Size:{},StorageClass:{},VersionId:{}}},flattened:true}}}},listObjects:{name:"ListObjects",alias:"GetBucket",http:{method:"GET",uri:"/{Bucket}?delimiter={Delimiter}&marker={Marker}&max-keys={MaxKeys}&prefix={Prefix}&encoding-type={EncodingType}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},Delimiter:{location:"uri"},EncodingType:{location:"uri"},Marker:{location:"uri"},MaxKeys:{type:"integer",location:"uri"},Prefix:{location:"uri"}}},output:{type:"structure",members:{CommonPrefixes:{type:"list",members:{type:"structure",members:{Prefix:{}}},flattened:true},Contents:{type:"list",members:{type:"structure",members:{ETag:{},Key:{},LastModified:{type:"timestamp"},Owner:{type:"structure",members:{DisplayName:{},ID:{}}},Size:{type:"integer"},StorageClass:{}}},flattened:true},EncodingType:{location:"header",name:"Encoding-Type"},IsTruncated:{type:"boolean"},Marker:{},MaxKeys:{type:"integer"},Name:{},NextMarker:{},Prefix:{}}}},listParts:{name:"ListParts",http:{method:"GET",uri:"/{Bucket}/{Key}?uploadId={UploadId}&max-parts={MaxParts}&part-number-marker={PartNumberMarker}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},Key:{required:true,location:"uri"},MaxParts:{type:"integer",location:"uri"},PartNumberMarker:{type:"integer",location:"uri"},UploadId:{required:true,location:"uri"}}},output:{type:"structure",members:{Bucket:{},Initiator:{type:"structure",members:{DisplayName:{},ID:{}}},IsTruncated:{type:"boolean"},Key:{},MaxParts:{type:"integer"},NextPartNumberMarker:{type:"integer"},Owner:{type:"structure",members:{DisplayName:{},ID:{}}},PartNumberMarker:{type:"integer"},Part:{type:"list",name:"Parts",members:{type:"structure",members:{ETag:{},LastModified:{type:"timestamp"},PartNumber:{type:"integer"},Size:{type:"integer"}}},flattened:true},StorageClass:{},UploadId:{}}}},putBucketAcl:{name:"PutBucketAcl",http:{method:"PUT",uri:"/{Bucket}?acl"},input:{payload:"AccessControlPolicy",type:"structure",members:{ACL:{location:"header",name:"x-amz-acl"},AccessControlPolicy:{type:"structure",members:{Grants:{type:"list",name:"AccessControlList",members:{type:"structure",name:"Grant",members:{Grantee:{type:"structure",xmlns:{uri:"http://www.w3.org/2001/XMLSchema-instance",prefix:"xsi"},members:{DisplayName:{},EmailAddress:{},ID:{},Type:{required:true,name:"xsi:type",attribute:true},URI:{}}},Permission:{}}}},Owner:{type:"structure",members:{DisplayName:{},ID:{}}}}},Bucket:{required:true,location:"uri"},ContentMD5:{location:"header",name:"Content-MD5"},GrantFullControl:{location:"header",name:"x-amz-grant-full-control"},GrantRead:{location:"header",name:"x-amz-grant-read"},GrantReadACP:{location:"header",name:"x-amz-grant-read-acp"},GrantWrite:{location:"header",name:"x-amz-grant-write"},GrantWriteACP:{location:"header",name:"x-amz-grant-write-acp"}}},output:{type:"structure",members:{}}},putBucketCors:{name:"PutBucketCors",http:{method:"PUT",uri:"/{Bucket}?cors"},input:{payload:"CORSConfiguration",type:"structure",members:{Bucket:{required:true,location:"uri"},CORSConfiguration:{type:"structure",members:{CORSRules:{type:"list",name:"CORSRule",members:{type:"structure",members:{AllowedHeaders:{type:"list",name:"AllowedHeader",members:{},flattened:true},AllowedMethods:{type:"list",name:"AllowedMethod",members:{},flattened:true},AllowedOrigins:{type:"list",name:"AllowedOrigin",members:{},flattened:true},ExposeHeaders:{type:"list",name:"ExposeHeader",members:{},flattened:true},MaxAgeSeconds:{type:"integer"}}},flattened:true}}},ContentMD5:{location:"header",name:"Content-MD5"}}},output:{type:"structure",members:{}}},putBucketLifecycle:{name:"PutBucketLifecycle",http:{method:"PUT",uri:"/{Bucket}?lifecycle"},input:{payload:"LifecycleConfiguration",type:"structure",members:{Bucket:{required:true,location:"uri"},ContentMD5:{location:"header",name:"Content-MD5"},LifecycleConfiguration:{type:"structure",members:{Rules:{type:"list",required:true,name:"Rule",members:{type:"structure",members:{Expiration:{type:"structure",members:{Date:{type:"timestamp",format:"iso8601"},Days:{type:"integer"}}},ID:{},Prefix:{required:true},Status:{required:true},Transition:{type:"structure",members:{Date:{type:"timestamp",format:"iso8601"},Days:{type:"integer"},StorageClass:{}}}}},flattened:true}}}}},output:{type:"structure",members:{}}},putBucketLogging:{name:"PutBucketLogging",http:{method:"PUT",uri:"/{Bucket}?logging"},input:{payload:"BucketLoggingStatus",type:"structure",members:{Bucket:{required:true,location:"uri"},BucketLoggingStatus:{type:"structure",required:true,members:{LoggingEnabled:{type:"structure",members:{TargetBucket:{},TargetGrants:{type:"list",members:{type:"structure",name:"Grant",members:{Grantee:{type:"structure",xmlns:{uri:"http://www.w3.org/2001/XMLSchema-instance",prefix:"xsi"},members:{DisplayName:{},EmailAddress:{},ID:{},Type:{required:true,name:"xsi:type",attribute:true},URI:{}}},Permission:{}}}},TargetPrefix:{}}}}},ContentMD5:{location:"header",name:"Content-MD5"}}},output:{type:"structure",members:{}}},putBucketNotification:{name:"PutBucketNotification",http:{method:"PUT",uri:"/{Bucket}?notification"},input:{payload:"NotificationConfiguration",type:"structure",members:{Bucket:{required:true,location:"uri"},ContentMD5:{location:"header",name:"Content-MD5"},NotificationConfiguration:{type:"structure",required:true,members:{TopicConfiguration:{type:"structure",required:true,members:{Event:{},Topic:{}}}}}}},output:{type:"structure",members:{}}},putBucketPolicy:{name:"PutBucketPolicy",http:{method:"PUT",uri:"/{Bucket}?policy"},input:{payload:"Policy",type:"structure",members:{Bucket:{required:true,location:"uri"},ContentMD5:{location:"header",name:"Content-MD5"},Policy:{required:true}}},output:{type:"structure",members:{}}},putBucketRequestPayment:{name:"PutBucketRequestPayment",http:{method:"PUT",uri:"/{Bucket}?requestPayment"},input:{payload:"RequestPaymentConfiguration",type:"structure",members:{Bucket:{required:true,location:"uri"},ContentMD5:{location:"header",name:"Content-MD5"},RequestPaymentConfiguration:{type:"structure",required:true,members:{Payer:{required:true}}}}},output:{type:"structure",members:{}}},putBucketTagging:{name:"PutBucketTagging",http:{method:"PUT",uri:"/{Bucket}?tagging"},input:{payload:"Tagging",type:"structure",members:{Bucket:{required:true,location:"uri"},ContentMD5:{location:"header",name:"Content-MD5"},Tagging:{type:"structure",required:true,members:{TagSet:{type:"list",required:true,members:{type:"structure",required:true,name:"Tag",members:{Key:{required:true},Value:{required:true}}}}}}}},output:{type:"structure",members:{}}},putBucketVersioning:{name:"PutBucketVersioning",http:{method:"PUT",uri:"/{Bucket}?versioning"},input:{payload:"VersioningConfiguration",type:"structure",members:{Bucket:{required:true,location:"uri"},ContentMD5:{location:"header",name:"Content-MD5"},MFA:{location:"header",name:"x-amz-mfa"},VersioningConfiguration:{type:"structure",required:true,members:{MFADelete:{},Status:{}}}}},output:{type:"structure",members:{}}},putBucketWebsite:{name:"PutBucketWebsite",http:{method:"PUT",uri:"/{Bucket}?website"},input:{payload:"WebsiteConfiguration",type:"structure",members:{Bucket:{required:true,location:"uri"},ContentMD5:{location:"header",name:"Content-MD5"},WebsiteConfiguration:{type:"structure",required:true,members:{ErrorDocument:{type:"structure",members:{Key:{required:true}}},IndexDocument:{type:"structure",members:{Suffix:{required:true}}},RedirectAllRequestsTo:{type:"structure",members:{HostName:{required:true},Protocol:{}}},RoutingRules:{type:"list",members:{type:"structure",name:"RoutingRule",members:{Condition:{type:"structure",members:{HttpErrorCodeReturnedEquals:{},KeyPrefixEquals:{}}},Redirect:{type:"structure",required:true,members:{HostName:{},HttpRedirectCode:{},Protocol:{},ReplaceKeyPrefixWith:{},ReplaceKeyWith:{}}}}}}}}}},output:{type:"structure",members:{}}},putObject:{name:"PutObject",http:{method:"PUT",uri:"/{Bucket}/{Key}"},input:{payload:"Body",type:"structure",members:{ACL:{location:"header",name:"x-amz-acl"},Body:{type:"binary",streaming:true},Bucket:{required:true,location:"uri"},CacheControl:{location:"header",name:"Cache-Control"},ContentDisposition:{location:"header",name:"Content-Disposition"},ContentEncoding:{location:"header",name:"Content-Encoding"},ContentLanguage:{location:"header",name:"Content-Language"},ContentLength:{type:"integer",location:"header",name:"Content-Length"},ContentMD5:{location:"header",name:"Content-MD5"},ContentType:{location:"header",name:"Content-Type"},Expires:{type:"timestamp",location:"header",name:"Expires"},GrantFullControl:{location:"header",name:"x-amz-grant-full-control"},GrantRead:{location:"header",name:"x-amz-grant-read"},GrantReadACP:{location:"header",name:"x-amz-grant-read-acp"},GrantWriteACP:{location:"header",name:"x-amz-grant-write-acp"},Key:{required:true,location:"uri"},Metadata:{type:"map",location:"header",name:"x-amz-meta-",members:{},keys:{}},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},StorageClass:{location:"header",name:"x-amz-storage-class"},WebsiteRedirectLocation:{location:"header",name:"x-amz-website-redirect-location"}}},output:{type:"structure",members:{ETag:{location:"header",name:"ETag"},Expiration:{type:"timestamp",location:"header",name:"x-amz-expiration"},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},VersionId:{location:"header",name:"x-amz-version-id"}}}},putObjectAcl:{name:"PutObjectAcl",http:{method:"PUT",uri:"/{Bucket}/{Key}?acl"},input:{payload:"AccessControlPolicy",type:"structure",members:{ACL:{location:"header",name:"x-amz-acl"},AccessControlPolicy:{type:"structure",members:{Grants:{type:"list",name:"AccessControlList",members:{type:"structure",name:"Grant",members:{Grantee:{type:"structure",xmlns:{uri:"http://www.w3.org/2001/XMLSchema-instance",prefix:"xsi"},members:{DisplayName:{},EmailAddress:{},ID:{},Type:{required:true,name:"xsi:type",attribute:true},URI:{}}},Permission:{}}}},Owner:{type:"structure",members:{DisplayName:{},ID:{}}}}},Bucket:{required:true,location:"uri"},ContentMD5:{location:"header",name:"Content-MD5"},GrantFullControl:{location:"header",name:"x-amz-grant-full-control"},GrantRead:{location:"header",name:"x-amz-grant-read"},GrantReadACP:{location:"header",name:"x-amz-grant-read-acp"},GrantWrite:{location:"header",name:"x-amz-grant-write"},GrantWriteACP:{location:"header",name:"x-amz-grant-write-acp"},Key:{required:true,location:"uri"}}},output:{type:"structure",members:{}}},restoreObject:{name:"RestoreObject",alias:"PostObjectRestore",http:{method:"POST",uri:"/{Bucket}/{Key}?restore"},input:{payload:"RestoreRequest",type:"structure",members:{Bucket:{required:true,location:"uri"},Key:{required:true,location:"uri"},RestoreRequest:{type:"structure",members:{Days:{type:"integer",required:true}}}}},output:{type:"structure",members:{}}},uploadPart:{name:"UploadPart",http:{method:"PUT",uri:"/{Bucket}/{Key}?partNumber={PartNumber}&uploadId={UploadId}"},input:{payload:"Body",type:"structure",members:{Body:{type:"binary",streaming:true},Bucket:{required:true,location:"uri"},ContentLength:{type:"integer",location:"header",name:"Content-Length"},ContentMD5:{location:"header",name:"Content-MD5"},Key:{required:true,location:"uri"},PartNumber:{type:"integer",required:true,location:"uri"},UploadId:{required:true,location:"uri"}}},output:{type:"structure",members:{ETag:{location:"header",name:"ETag"},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"}}}},uploadPartCopy:{name:"UploadPartCopy",http:{method:"PUT",uri:"/{Bucket}/{Key}?partNumber={PartNumber}&uploadId={UploadId}"},input:{type:"structure",members:{Bucket:{required:true,location:"uri"},CopySource:{required:true,location:"header",name:"x-amz-copy-source"},CopySourceIfMatch:{type:"timestamp",location:"header",name:"x-amz-copy-source-if-match"},CopySourceIfModifiedSince:{type:"timestamp",location:"header",name:"x-amz-copy-source-if-modified-since"},CopySourceIfNoneMatch:{type:"timestamp",location:"header",name:"x-amz-copy-source-if-none-match"},CopySourceIfUnmodifiedSince:{type:"timestamp",location:"header",name:"x-amz-copy-source-if-unmodified-since"},CopySourceRange:{location:"header",name:"x-amz-copy-source-range"},Key:{required:true,location:"uri"},PartNumber:{type:"integer",required:true,location:"uri"},UploadId:{required:true,location:"uri"}}},output:{type:"structure",members:{CopySourceVersionId:{location:"header",name:"x-amz-copy-source-version-id"},ServerSideEncryption:{location:"header",name:"x-amz-server-side-encryption"},ETag:{},LastModified:{type:"timestamp"}}}}},pagination:{listMultipartUploads:{limitKey:"MaxUploads",moreResults:"IsTruncated",outputToken:["NextKeyMarker","NextUploadIdMarker"],inputToken:["KeyMarker","UploadIdMarker"],resultKey:"Uploads"},listObjectVersions:{moreResults:"IsTruncated",limitKey:"MaxKeys",outputToken:["NextKeyMarker","NextVersionIdMarker"],inputToken:["KeyMarker","VersionIdMarker"],resultKey:"Versions"},listObjects:{moreResults:"IsTruncated",limitKey:"MaxKeys",outputToken:"NextMarker or Contents[-1].Key",inputToken:"Marker",resultKey:["Contents","CommonPrefixes"]},listParts:{limitKey:"IsTruncated",outputToken:"NextPartNumberMarker",inputToken:"PartNumberMarker",resultKey:"Parts"}}}); | |
n.Service.defineServiceApi(e("./services/sqs"),"2012-11-05",{format:"query",apiVersion:"2012-11-05",endpointPrefix:"sqs",resultWrapped:true,serviceAbbreviation:"Amazon SQS",serviceFullName:"Amazon Simple Queue Service",signatureVersion:"v4",timestampFormat:"iso8601",operations:{addPermission:{name:"AddPermission",input:{type:"structure",members:{QueueUrl:{required:true},Label:{required:true},AWSAccountIds:{type:"list",members:{name:"AWSAccountId"},flattened:true,required:true},Actions:{type:"list",members:{name:"ActionName"},flattened:true,required:true}}},output:{type:"structure",members:{}}},changeMessageVisibility:{name:"ChangeMessageVisibility",input:{type:"structure",members:{QueueUrl:{required:true},ReceiptHandle:{required:true},VisibilityTimeout:{type:"integer",required:true}}},output:{type:"structure",members:{}}},changeMessageVisibilityBatch:{name:"ChangeMessageVisibilityBatch",input:{type:"structure",members:{QueueUrl:{required:true},Entries:{type:"list",members:{type:"structure",members:{Id:{required:true},ReceiptHandle:{required:true},VisibilityTimeout:{type:"integer"}},name:"ChangeMessageVisibilityBatchRequestEntry"},flattened:true,required:true}}},output:{type:"structure",members:{ChangeMessageVisibilityBatchResultEntry:{type:"list",members:{type:"structure",members:{Id:{}},name:"ChangeMessageVisibilityBatchResultEntry"},flattened:true,name:"Successful"},BatchResultErrorEntry:{type:"list",members:{type:"structure",members:{Id:{},SenderFault:{type:"boolean"},Code:{},Message:{}},name:"BatchResultErrorEntry"},flattened:true,name:"Failed"}}}},createQueue:{name:"CreateQueue",input:{type:"structure",members:{QueueName:{required:true},Attributes:{type:"map",keys:{name:"Name"},members:{name:"Value"},flattened:true,name:"Attribute"}}},output:{type:"structure",members:{QueueUrl:{}}}},deleteMessage:{name:"DeleteMessage",input:{type:"structure",members:{QueueUrl:{required:true},ReceiptHandle:{required:true}}},output:{type:"structure",members:{}}},deleteMessageBatch:{name:"DeleteMessageBatch",input:{type:"structure",members:{QueueUrl:{required:true},Entries:{type:"list",members:{type:"structure",members:{Id:{required:true},ReceiptHandle:{required:true}},name:"DeleteMessageBatchRequestEntry"},flattened:true,required:true}}},output:{type:"structure",members:{DeleteMessageBatchResultEntry:{type:"list",members:{type:"structure",members:{Id:{}},name:"DeleteMessageBatchResultEntry"},flattened:true,name:"Successful"},BatchResultErrorEntry:{type:"list",members:{type:"structure",members:{Id:{},SenderFault:{type:"boolean"},Code:{},Message:{}},name:"BatchResultErrorEntry"},flattened:true,name:"Failed"}}}},deleteQueue:{name:"DeleteQueue",input:{type:"structure",members:{QueueUrl:{required:true}}},output:{type:"structure",members:{}}},getQueueAttributes:{name:"GetQueueAttributes",input:{type:"structure",members:{QueueUrl:{required:true},AttributeNames:{type:"list",members:{name:"AttributeName"},flattened:true}}},output:{type:"structure",members:{Attribute:{type:"map",keys:{name:"Name"},members:{name:"Value"},flattened:true,name:"Attributes"}}}},getQueueUrl:{name:"GetQueueUrl",input:{type:"structure",members:{QueueName:{required:true},QueueOwnerAWSAccountId:{}}},output:{type:"structure",members:{QueueUrl:{}}}},listQueues:{name:"ListQueues",input:{type:"structure",members:{QueueNamePrefix:{}}},output:{type:"structure",members:{QueueUrl:{type:"list",members:{name:"QueueUrl"},flattened:true,name:"QueueUrls"}}}},receiveMessage:{name:"ReceiveMessage",input:{type:"structure",members:{QueueUrl:{required:true},AttributeNames:{type:"list",members:{name:"AttributeName"},flattened:true},MaxNumberOfMessages:{type:"integer"},VisibilityTimeout:{type:"integer"},WaitTimeSeconds:{type:"integer"}}},output:{type:"structure",members:{Message:{type:"list",members:{type:"structure",members:{MessageId:{},ReceiptHandle:{},MD5OfBody:{},Body:{},Attribute:{type:"map",keys:{name:"Name"},members:{name:"Value"},flattened:true,name:"Attributes"}},name:"Message"},flattened:true,name:"Messages"}}}},removePermission:{name:"RemovePermission",input:{type:"structure",members:{QueueUrl:{required:true},Label:{required:true}}},output:{type:"structure",members:{}}},sendMessage:{name:"SendMessage",input:{type:"structure",members:{QueueUrl:{required:true},MessageBody:{required:true},DelaySeconds:{type:"integer"}}},output:{type:"structure",members:{MD5OfMessageBody:{},MessageId:{}}}},sendMessageBatch:{name:"SendMessageBatch",input:{type:"structure",members:{QueueUrl:{required:true},Entries:{type:"list",members:{type:"structure",members:{Id:{required:true},MessageBody:{required:true},DelaySeconds:{type:"integer"}},name:"SendMessageBatchRequestEntry"},flattened:true,required:true}}},output:{type:"structure",members:{SendMessageBatchResultEntry:{type:"list",members:{type:"structure",members:{Id:{},MessageId:{},MD5OfMessageBody:{}},name:"SendMessageBatchResultEntry"},flattened:true,name:"Successful"},BatchResultErrorEntry:{type:"list",members:{type:"structure",members:{Id:{},SenderFault:{type:"boolean"},Code:{},Message:{}},name:"BatchResultErrorEntry"},flattened:true,name:"Failed"}}}},setQueueAttributes:{name:"SetQueueAttributes",input:{type:"structure",members:{QueueUrl:{required:true},Attributes:{type:"map",keys:{name:"Name"},members:{name:"Value"},flattened:true,name:"Attribute",required:true}}},output:{type:"structure",members:{}}}},pagination:{listQueues:{resultKey:"QueueUrls"}}});n.Service.defineServiceApi(e("./services/sns"),"2010-03-31",{format:"query",apiVersion:"2010-03-31",endpointPrefix:"sns",resultWrapped:true,serviceAbbreviation:"Amazon SNS",serviceFullName:"Amazon Simple Notification Service",signatureVersion:"v4",timestampFormat:"iso8601",operations:{addPermission:{name:"AddPermission",input:{type:"structure",members:{TopicArn:{required:true},Label:{required:true},AWSAccountId:{type:"list",members:{},required:true},ActionName:{type:"list",members:{},required:true}}},output:{type:"structure",members:{}}},confirmSubscription:{name:"ConfirmSubscription",input:{type:"structure",members:{TopicArn:{required:true},Token:{required:true},AuthenticateOnUnsubscribe:{}}},output:{type:"structure",members:{SubscriptionArn:{}}}},createPlatformApplication:{name:"CreatePlatformApplication",input:{type:"structure",members:{Name:{required:true},Platform:{required:true},Attributes:{type:"map",keys:{},members:{},required:true}}},output:{type:"structure",members:{PlatformApplicationArn:{}}}},createPlatformEndpoint:{name:"CreatePlatformEndpoint",input:{type:"structure",members:{PlatformApplicationArn:{required:true},Token:{required:true},CustomUserData:{},Attributes:{type:"map",keys:{},members:{}}}},output:{type:"structure",members:{EndpointArn:{}}}},createTopic:{name:"CreateTopic",input:{type:"structure",members:{Name:{required:true}}},output:{type:"structure",members:{TopicArn:{}}}},deleteEndpoint:{name:"DeleteEndpoint",input:{type:"structure",members:{EndpointArn:{required:true}}},output:{type:"structure",members:{}}},deletePlatformApplication:{name:"DeletePlatformApplication",input:{type:"structure",members:{PlatformApplicationArn:{required:true}}},output:{type:"structure",members:{}}},deleteTopic:{name:"DeleteTopic",input:{type:"structure",members:{TopicArn:{required:true}}},output:{type:"structure",members:{}}},getEndpointAttributes:{name:"GetEndpointAttributes",input:{type:"structure",members:{EndpointArn:{required:true}}},output:{type:"structure",members:{Attributes:{type:"map",keys:{},members:{}}}}},getPlatformApplicationAttributes:{name:"GetPlatformApplicationAttributes",input:{type:"structure",members:{PlatformApplicationArn:{required:true}}},output:{type:"structure",members:{Attributes:{type:"map",keys:{},members:{}}}}},getSubscriptionAttributes:{name:"GetSubscriptionAttributes",input:{type:"structure",members:{SubscriptionArn:{required:true}}},output:{type:"structure",members:{Attributes:{type:"map",keys:{},members:{}}}}},getTopicAttributes:{name:"GetTopicAttributes",input:{type:"structure",members:{TopicArn:{required:true}}},output:{type:"structure",members:{Attributes:{type:"map",keys:{},members:{}}}}},listEndpointsByPlatformApplication:{name:"ListEndpointsByPlatformApplication",input:{type:"structure",members:{PlatformApplicationArn:{required:true},NextToken:{}}},output:{type:"structure",members:{Endpoints:{type:"list",members:{type:"structure",members:{EndpointArn:{},Attributes:{type:"map",keys:{},members:{}}}}},NextToken:{}}}},listPlatformApplications:{name:"ListPlatformApplications",input:{type:"structure",members:{NextToken:{}}},output:{type:"structure",members:{PlatformApplications:{type:"list",members:{type:"structure",members:{PlatformApplicationArn:{},Attributes:{type:"map",keys:{},members:{}}}}},NextToken:{}}}},listSubscriptions:{name:"ListSubscriptions",input:{type:"structure",members:{NextToken:{}}},output:{type:"structure",members:{Subscriptions:{type:"list",members:{type:"structure",members:{SubscriptionArn:{},Owner:{},Protocol:{},Endpoint:{},TopicArn:{}}}},NextToken:{}}}},listSubscriptionsByTopic:{name:"ListSubscriptionsByTopic",input:{type:"structure",members:{TopicArn:{required:true},NextToken:{}}},output:{type:"structure",members:{Subscriptions:{type:"list",members:{type:"structure",members:{SubscriptionArn:{},Owner:{},Protocol:{},Endpoint:{},TopicArn:{}}}},NextToken:{}}}},listTopics:{name:"ListTopics",input:{type:"structure",members:{NextToken:{}}},output:{type:"structure",members:{Topics:{type:"list",members:{type:"structure",members:{TopicArn:{}}}},NextToken:{}}}},publish:{name:"Publish",input:{type:"structure",members:{TopicArn:{},TargetArn:{},Message:{required:true},Subject:{},MessageStructure:{}}},output:{type:"structure",members:{MessageId:{}}}},removePermission:{name:"RemovePermission",input:{type:"structure",members:{TopicArn:{required:true},Label:{required:true}}},output:{type:"structure",members:{}}},setEndpointAttributes:{name:"SetEndpointAttributes",input:{type:"structure",members:{EndpointArn:{required:true},Attributes:{type:"map",keys:{},members:{},required:true}}},output:{type:"structure",members:{}}},setPlatformApplicationAttributes:{name:"SetPlatformApplicationAttributes",input:{type:"structure",members:{PlatformApplicationArn:{required:true},Attributes:{type:"map",keys:{},members:{},required:true}}},output:{type:"structure",members:{}}},setSubscriptionAttributes:{name:"SetSubscriptionAttributes",input:{type:"structure",members:{SubscriptionArn:{required:true},AttributeName:{required:true},AttributeValue:{}}},output:{type:"structure",members:{}}},setTopicAttributes:{name:"SetTopicAttributes",input:{type:"structure",members:{TopicArn:{required:true},AttributeName:{required:true},AttributeValue:{}}},output:{type:"structure",members:{}}},subscribe:{name:"Subscribe",input:{type:"structure",members:{TopicArn:{required:true},Protocol:{required:true},Endpoint:{}}},output:{type:"structure",members:{SubscriptionArn:{}}}},unsubscribe:{name:"Unsubscribe",input:{type:"structure",members:{SubscriptionArn:{required:true}}},output:{type:"structure",members:{}}}},pagination:{listSubscriptions:{inputToken:"NextToken",outputToken:"NextToken",resultKey:"Subscriptions"},listSubscriptionsByTopic:{inputToken:"NextToken",outputToken:"NextToken",resultKey:"Subscriptions"},listTopics:{inputToken:"NextToken",outputToken:"NextToken",resultKey:"Topics"}}});n.Service.defineServiceApi(e("./services/sts"),"2011-06-15",{format:"query",apiVersion:"2011-06-15",endpointPrefix:"sts",globalEndpoint:"sts.amazonaws.com",resultWrapped:true,serviceAbbreviation:"AWS STS",serviceFullName:"AWS Security Token Service",signatureVersion:"v4",timestampFormat:"iso8601",operations:{assumeRole:{name:"AssumeRole",input:{type:"structure",members:{RoleArn:{required:true},RoleSessionName:{required:true},Policy:{},DurationSeconds:{type:"integer"},ExternalId:{}}},output:{type:"structure",members:{Credentials:{type:"structure",members:{AccessKeyId:{},SecretAccessKey:{},SessionToken:{},Expiration:{type:"timestamp"}}},AssumedRoleUser:{type:"structure",members:{AssumedRoleId:{},Arn:{}}},PackedPolicySize:{type:"integer"}}}},assumeRoleWithSAML:{name:"AssumeRoleWithSAML",input:{type:"structure",members:{RoleArn:{required:true},PrincipalArn:{required:true},SAMLAssertion:{required:true},Policy:{},DurationSeconds:{type:"integer"}}},output:{type:"structure",members:{Credentials:{type:"structure",members:{AccessKeyId:{},SecretAccessKey:{},SessionToken:{},Expiration:{type:"timestamp"}}},AssumedRoleUser:{type:"structure",members:{AssumedRoleId:{},Arn:{}}},PackedPolicySize:{type:"integer"}}}},assumeRoleWithWebIdentity:{name:"AssumeRoleWithWebIdentity",input:{type:"structure",members:{RoleArn:{required:true},RoleSessionName:{required:true},WebIdentityToken:{required:true},ProviderId:{},Policy:{},DurationSeconds:{type:"integer"}}},output:{type:"structure",members:{Credentials:{type:"structure",members:{AccessKeyId:{},SecretAccessKey:{},SessionToken:{},Expiration:{type:"timestamp"}}},SubjectFromWebIdentityToken:{},AssumedRoleUser:{type:"structure",members:{AssumedRoleId:{},Arn:{}}},PackedPolicySize:{type:"integer"}}}},decodeAuthorizationMessage:{name:"DecodeAuthorizationMessage",input:{type:"structure",members:{EncodedMessage:{required:true}}},output:{type:"structure",members:{DecodedMessage:{}}}},getFederationToken:{name:"GetFederationToken",input:{type:"structure",members:{Name:{required:true},Policy:{},DurationSeconds:{type:"integer"}}},output:{type:"structure",members:{Credentials:{type:"structure",members:{AccessKeyId:{},SecretAccessKey:{},SessionToken:{},Expiration:{type:"timestamp"}}},FederatedUser:{type:"structure",members:{FederatedUserId:{},Arn:{}}},PackedPolicySize:{type:"integer"}}}},getSessionToken:{name:"GetSessionToken",input:{type:"structure",members:{DurationSeconds:{type:"integer"},SerialNumber:{},TokenCode:{}}},output:{type:"structure",members:{Credentials:{type:"structure",members:{AccessKeyId:{},SecretAccessKey:{},SessionToken:{},Expiration:{type:"timestamp"}}}}}}}})},{"./core":33,"./services/dynamodb":53,"./services/s3":54,"./services/sns":55,"./services/sqs":56,"./services/sts":57}],53:[function(e,t,r){var n=e("../core");n.DynamoDB=n.Service.defineService("dynamodb",["2012-08-10","2011-12-05"],{setupRequestListeners:function i(e){if(e.service.config.dynamoDbCrc32){e.addListener("extractData",this.checkCrc32)}},checkCrc32:function s(e){if(!e.request.service.crc32IsValid(e)){e.error=n.util.error(new Error,{code:"CRC32CheckFailed",message:"CRC32 integrity check failed",retryable:true})}},crc32IsValid:function a(e){var t=e.httpResponse.headers["x-amz-crc32"];if(!t)return true;return parseInt(t,10)==n.util.crypto.crc32(e.httpResponse.body)},defaultRetryCount:10,retryDelays:function o(){var e=this.numRetries();var t=[];for(var r=0;r<e;++r){if(r===0){t.push(0)}else{t.push(50*Math.pow(2,r-1))}}return t}});t.exports=n.DynamoDB},{"../core":33}],54:[function(e,t,r){var n=e("../core");var i=e("buffer").Buffer;n.S3=n.Service.defineService("s3",["2006-03-01"],{initialize:function s(e){n.Service.prototype.initialize.call(this,e);this.setEndpoint((e||{}).endpoint,e)},setupRequestListeners:function a(e){e.addListener("build",this.addContentType);e.addListener("build",this.populateURI);e.addListener("build",this.computeContentMd5);e.addListener("build",this.computeSha256);e.removeListener("validate",n.EventListeners.Core.VALIDATE_REGION);e.addListener("extractError",this.extractError);e.addListener("extractData",this.extractData)},populateURI:function o(e){var t=e.httpRequest;var r=e.params.Bucket;if(r){if(!e.service.pathStyleBucketName(r)){t.endpoint.host=t.endpoint.hostname=r+"."+t.endpoint.hostname;t.virtualHostedBucket=r;t.path=t.path.replace(new RegExp("^/"+r),"");if(t.path[0]!=="/"){t.path="/"+t.path}}}},addContentType:function u(e){var t=e.httpRequest;if(!t.headers["Content-Type"]){t.headers["Content-Type"]="application/octet-stream"}if(n.util.isBrowser()&&navigator.userAgent.match(/Firefox/)){if(!t.headers["Content-Type"].match(/;/)){var r="; charset=UTF-8";t.headers["Content-Type"]+=r}}},computableChecksumOperations:{putBucketCors:true,putBucketLifecycle:true,putBucketTagging:true,deleteObjects:true},willComputeChecksums:function c(e){if(this.computableChecksumOperations[e.operation])return true;if(!this.config.computeChecksums)return false;if(!i.isBuffer(e.httpRequest.body)&&typeof e.httpRequest.body!=="string"){return false}var t=e.service.api.operations[e.operation].input.members;if(e.service.getSignerClass(e)===n.Signers.V4){if(t.ContentMD5&&!t.ContentMD5.required)return false}if(t.ContentMD5&&!e.params.ContentMD5)return true},computeContentMd5:function l(e){if(e.service.willComputeChecksums(e)){var t=n.util.crypto.md5(e.httpRequest.body,"base64");e.httpRequest.headers["Content-MD5"]=t}},computeSha256:function p(e){if(e.service.getSignerClass(e)===n.Signers.V4){e.httpRequest.headers["X-Amz-Content-Sha256"]=n.util.crypto.sha256(e.httpRequest.body||"","hex")}},pathStyleBucketName:function f(e){if(this.config.s3ForcePathStyle)return true;if(this.dnsCompatibleBucketName(e)){return this.config.sslEnabled&&e.match(/\./)?true:false}else{return true}},dnsCompatibleBucketName:function m(e){var t=e;var r=new RegExp(/^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/);var n=new RegExp(/(\d+\.){3}\d+/);var i=new RegExp(/\.\./);return t.match(r)&&!t.match(n)&&!t.match(i)?true:false},escapePathParam:function d(e){return n.util.uriEscapePath(String(e))},successfulResponse:function h(e){var t=e.request;var r=e.httpResponse;if(t.operation==="completeMultipartUpload"&&r.body.toString().match("<Error>"))return false;else return r.statusCode<300},retryableError:function y(e,t){if(t.operation=="completeMultipartUpload"&&e.statusCode===200){return true}else{var r=n.Service.prototype.retryableError;return r.call(this,e,t)}},extractData:function b(e){var t=e.request;if(t.operation==="getBucketLocation"){var r=e.httpResponse.body.toString().match(/>(.+)<\/Location/);if(r){delete e.data["_"];e.data.LocationConstraint=r[1]}}},extractError:function g(e){var t={304:"NotModified",403:"Forbidden",400:"BadRequest",404:"NotFound"};var r=e.httpResponse.statusCode;var i=e.httpResponse.body;if(t[r]&&i.length===0){e.error=n.util.error(new Error,{code:t[e.httpResponse.statusCode],message:null})}else{var s=new n.XML.Parser({}).parse(i.toString());e.error=n.util.error(new Error,{code:s.Code||r,message:s.Message||null})}},setEndpoint:function v(e){if(e){this.endpoint=new n.Endpoint(e,this.config)}else if(this.config.region&&this.config.region!=="us-east-1"){var t="-";if(this.isRegionV4())t=".";var r="s3"+t+this.config.region+this.endpointSuffix();this.endpoint=new n.Endpoint(r)}else{this.endpoint=new n.Endpoint(this.api.globalEndpoint,this.config)}},getSignedUrl:function E(t,r,i){var s=r.Expires||900;delete r.Expires;var a=e("url");var o=["validate","build","sign"];var u=this.makeRequest(t,r);var c="presigned-expires";function l(){delete u.httpRequest.headers["User-Agent"];delete u.httpRequest.headers["X-Amz-User-Agent"];u.httpRequest.headers[c]=parseInt(n.util.date.unixTimestamp()+s,10).toString()}function p(){var e={};n.util.each(u.httpRequest.headers,function(t,r){if(t===c)t="Expires";e[t]=r});delete u.httpRequest.headers[c];var t=e["Authorization"].split(":");delete e["Authorization"];delete e["Host"];e["AWSAccessKeyId"]=t[0].split(" ")[1];e["Signature"]=t[1];var r=u.httpRequest.endpoint;var i=a.parse(u.httpRequest.path);var s=n.util.queryParamsToString(e);r.pathname=i.pathname;r.search=!i.search?s:i.search+"&"+s}u.on("build",l);u.on("sign",p);u.removeListener("build",this.addContentType);if(!r.Body){u.removeListener("build",this.computeContentMd5)}if(i){u.emitEvents(o,new n.Response(u),function(e){if(e)i(e,null);else i(null,a.format(u.httpRequest.endpoint))})}else{n.util.arrayEach(o,function(e){u.emitEvent(e,[u])});return a.format(u.httpRequest.endpoint)}}});n.S3.prototype.createBucket=function w(e,t){if(!e)e={};var r=this.endpoint.hostname;if(r!=this.api.globalEndpoint&&!e.CreateBucketConfiguration){e.CreateBucketConfiguration={LocationConstraint:this.config.region}}return this.makeRequest("createBucket",e,t)};t.exports=n.S3},{"../core":33,buffer:12,url:27}],55:[function(e,t,r){var n=e("../core");n.SNS=n.Service.defineService("sns",["2010-03-31"]);t.exports=n.SNS},{"../core":33}],56:[function(e,t,r){var n=e("../core");n.SQS=n.Service.defineService("sqs",["2012-11-05"],{setupRequestListeners:function i(e){e.addListener("build",this.buildEndpoint);if(e.service.config.computeChecksums){if(e.operation==="sendMessage"){e.addListener("extractData",this.verifySendMessageChecksum)}else if(e.operation==="sendMessageBatch"){e.addListener("extractData",this.verifySendMessageBatchChecksum)}else if(e.operation==="receiveMessage"){e.addListener("extractData",this.verifyReceiveMessageChecksum)}}},verifySendMessageChecksum:function s(e){if(!e.data)return;var t=e.data.MD5OfMessageBody;var r=this.params.MessageBody;var n=this.service.calculateChecksum(r);if(n!==t){var i='Got "'+e.data.MD5OfMessageBody+'", expecting "'+n+'".';this.service.throwInvalidChecksumError(e,[e.data.MessageId],i)}},verifySendMessageBatchChecksum:function a(e){if(!e.data)return;var t=this.service;var r={};var i=[];var s=[];n.util.arrayEach(e.data.Successful,function(e){r[e.Id]=e});n.util.arrayEach(this.params.Entries,function(e){if(r[e.Id]){var n=r[e.Id].MD5OfMessageBody;var a=e.MessageBody;if(!t.isChecksumValid(n,a)){i.push(e.Id);s.push(r[e.Id].MessageId)}}});if(i.length>0){t.throwInvalidChecksumError(e,s,"Invalid messages: "+i.join(", "))}},verifyReceiveMessageChecksum:function o(e){if(!e.data)return;var t=this.service;var r=[];n.util.arrayEach(e.data.Messages,function(e){var n=e.MD5OfBody;var i=e.Body;if(!t.isChecksumValid(n,i)){r.push(e.MessageId)}});if(r.length>0){t.throwInvalidChecksumError(e,r,"Invalid messages: "+r.join(", "))}},throwInvalidChecksumError:function u(e,t,r){e.error=n.util.error(new Error,{retryable:true,code:"InvalidChecksum",messageIds:t,message:e.request.operation+" returned an invalid MD5 response. "+r})},isChecksumValid:function c(e,t){return this.calculateChecksum(t)===e},calculateChecksum:function l(e){return n.util.crypto.md5(e,"hex")},buildEndpoint:function p(e){var t=e.httpRequest.params.QueueUrl;if(t){e.httpRequest.endpoint=new n.Endpoint(t);var r=e.httpRequest.endpoint.host.match(/^sqs\.(.+?)\./);if(r)e.httpRequest.region=r[1]}}});t.exports=n.SQS},{"../core":33}],57:[function(e,t,r){var n=e("../core");n.STS=n.Service.defineService("sts",["2011-06-15"],{credentialsFrom:function i(e,t){if(!e)return null;if(!t)t=new n.TemporaryCredentials;t.expired=false;t.accessKeyId=e.Credentials.AccessKeyId;t.secretAccessKey=e.Credentials.SecretAccessKey;t.sessionToken=e.Credentials.SessionToken;t.expireTime=e.Credentials.Expiration;return t}});n.STS.prototype.assumeRoleWithWebIdentity=function s(e,t){return this.makeUnauthenticatedRequest("assumeRoleWithWebIdentity",e,t)};n.STS.prototype.assumeRoleWithSAML=function a(e,t){return this.makeUnauthenticatedRequest("assumeRoleWithSAML",e,t)};t.exports=n.STS},{"../core":33}],58:[function(e,t,r){var n=e("../core");e("./v3");var i=n.util.inherit;n.Signers.CloudFront=i(n.Signers.S3,{stringToSign:function s(){return this.request.headers["X-Amz-Date"]}});t.exports=n.Signers.CloudFront},{"../core":33,"./v3":62}],59:[function(e,t,r){var n=e("../core");var i=n.util.inherit;n.Signers.RequestSigner=i({constructor:function s(e){this.request=e}});n.Signers.RequestSigner.getVersion=function a(e){switch(e){case"v2":return n.Signers.V2;case"v3":return n.Signers.V3;case"v4":return n.Signers.V4;case"s3":return n.Signers.S3;case"v3https":return n.Signers.V3Https;case"cloudfront":return n.Signers.CloudFront}throw new Error("Unknown signing version "+e)};e("./v2");e("./v3");e("./v3https");e("./v4");e("./s3");e("./cloudfront")},{"../core":33,"./cloudfront":58,"./s3":60,"./v2":61,"./v3":62,"./v3https":63,"./v4":64}],60:[function(e,t,r){var n=e("../core");var i=n.util.inherit;n.Signers.S3=i(n.Signers.RequestSigner,{subResources:{acl:1,cors:1,lifecycle:1,"delete":1,location:1,logging:1,notification:1,partNumber:1,policy:1,requestPayment:1,restore:1,tagging:1,torrent:1,uploadId:1,uploads:1,versionId:1,versioning:1,versions:1,website:1},responseHeaders:{"response-content-type":1,"response-content-language":1,"response-expires":1,"response-cache-control":1,"response-content-disposition":1,"response-content-encoding":1},addAuthorization:function s(e,t){if(!this.request.headers["presigned-expires"]){this.request.headers["X-Amz-Date"]=n.util.date.rfc822(t)}if(e.sessionToken){this.request.headers["x-amz-security-token"]=e.sessionToken}var r=this.sign(e.secretAccessKey,this.stringToSign());var i="AWS "+e.accessKeyId+":"+r;this.request.headers["Authorization"]=i},stringToSign:function a(){var e=this.request;var t=[];t.push(e.method);t.push(e.headers["Content-MD5"]||"");t.push(e.headers["Content-Type"]||"");t.push(e.headers["presigned-expires"]||"");var r=this.canonicalizedAmzHeaders();if(r)t.push(r);t.push(this.canonicalizedResource());return t.join("\n")},canonicalizedAmzHeaders:function o(){var e=[];n.util.each(this.request.headers,function(t){if(t.match(/^x-amz-/i))e.push(t)});e.sort(function(e,t){return e.toLowerCase()<t.toLowerCase()?-1:1});var t=[];n.util.arrayEach.call(this,e,function(e){t.push(e.toLowerCase()+":"+String(this.request.headers[e]))});return t.join("\n")},canonicalizedResource:function u(){var e=this.request;var t=e.path.split("?");var r=t[0];var i=t[1];var s="";if(e.virtualHostedBucket)s+="/"+e.virtualHostedBucket;s+=r;if(i){var a=[];n.util.arrayEach.call(this,i.split("&"),function(e){var t=e.split("=")[0];var r=e.split("=")[1];if(this.subResources[t]||this.responseHeaders[t]){var n={name:t};if(r!==undefined){if(this.subResources[t]){n.value=r}else{n.value=decodeURIComponent(r)}}a.push(n)}});a.sort(function(e,t){return e.name<t.name?-1:1});if(a.length){i=[];n.util.arrayEach(a,function(e){if(e.value===undefined)i.push(e.name);else i.push(e.name+"="+e.value)});s+="?"+i.join("&")}}return s},sign:function c(e,t){return n.util.crypto.hmac(e,t,"base64","sha1")}});t.exports=n.Signers.S3},{"../core":33}],61:[function(e,t,r){var n=e("../core");var i=n.util.inherit;n.Signers.V2=i(n.Signers.RequestSigner,{addAuthorization:function s(e,t){if(!t)t=n.util.date.getDate();var r=this.request;r.params.Timestamp=n.util.date.iso8601(t);r.params.SignatureVersion="2";r.params.SignatureMethod="HmacSHA256";r.params.AWSAccessKeyId=e.accessKeyId;if(e.sessionToken){r.params.SecurityToken=e.sessionToken}delete r.params.Signature;r.params.Signature=this.signature(e);r.body=n.util.queryParamsToString(r.params);r.headers["Content-Length"]=r.body.length},signature:function a(e){return n.util.crypto.hmac(e.secretAccessKey,this.stringToSign(),"base64")},stringToSign:function o(){var e=[];e.push(this.request.method);e.push(this.request.endpoint.host.toLowerCase());e.push(this.request.pathname());e.push(n.util.queryParamsToString(this.request.params));return e.join("\n")}});t.exports=n.Signers.V2},{"../core":33}],62:[function(e,t,r){var n=e("../core");var i=n.util.inherit;n.Signers.V3=i(n.Signers.RequestSigner,{addAuthorization:function s(e,t){var r=n.util.date.rfc822(t);this.request.headers["X-Amz-Date"]=r;if(e.sessionToken){this.request.headers["x-amz-security-token"]=e.sessionToken}this.request.headers["X-Amzn-Authorization"]=this.authorization(e,r)},authorization:function a(e){return"AWS3 "+"AWSAccessKeyId="+e.accessKeyId+","+"Algorithm=HmacSHA256,"+"SignedHeaders="+this.signedHeaders()+","+"Signature="+this.signature(e)},signedHeaders:function o(){var e=[];n.util.arrayEach(this.headersToSign(),function t(r){e.push(r.toLowerCase())});return e.sort().join(";")},canonicalHeaders:function u(){var e=this.request.headers;var t=[];n.util.arrayEach(this.headersToSign(),function r(n){t.push(n.toLowerCase().trim()+":"+String(e[n]).trim())});return t.sort().join("\n")+"\n"},headersToSign:function c(){var e=[];n.util.each(this.request.headers,function t(r){if(r==="Host"||r==="Content-Encoding"||r.match(/^X-Amz/i)){e.push(r)}});return e},signature:function l(e){return n.util.crypto.hmac(e.secretAccessKey,this.stringToSign(),"base64")},stringToSign:function p(){var e=[];e.push(this.request.method);e.push("/");e.push("");e.push(this.canonicalHeaders());e.push(this.request.body);return n.util.crypto.sha256(e.join("\n"))}});t.exports=n.Signers.V3},{"../core":33}],63:[function(e,t,r){var n=e("../core");var i=n.util.inherit;e("./v3");n.Signers.V3Https=i(n.Signers.V3,{authorization:function s(e){return"AWS3-HTTPS "+"AWSAccessKeyId="+e.accessKeyId+","+"Algorithm=HmacSHA256,"+"Signature="+this.signature(e)},stringToSign:function a(){return this.request.headers["X-Amz-Date"]}});t.exports=n.Signers.V3Https},{"../core":33,"./v3":62}],64:[function(e,t,r){var n=e("../core");var i=n.util.inherit;var s={};n.Signers.V4=i(n.Signers.RequestSigner,{constructor:function a(e,t){n.Signers.RequestSigner.call(this,e);this.serviceName=t},addAuthorization:function o(e,t){var r=n.util.date.iso8601(t).replace(/[:\-]|\.\d{3}/g,"");this.addHeaders(e,r);this.updateBody(e);this.request.headers["Authorization"]=this.authorization(e,r)},addHeaders:function u(e,t){this.request.headers["X-Amz-Date"]=t;if(e.sessionToken){this.request.headers["x-amz-security-token"]=e.sessionToken}},updateBody:function c(e){if(this.request.params){this.request.params.AWSAccessKeyId=e.accessKeyId;if(e.sessionToken){this.request.params.SecurityToken=e.sessionToken}this.request.body=n.util.queryParamsToString(this.request.params);this.request.headers["Content-Length"]=this.request.body.length}},authorization:function l(e,t){var r=[];var n=this.credentialString(t);r.push("AWS4-HMAC-SHA256 Credential="+e.accessKeyId+"/"+n);r.push("SignedHeaders="+this.signedHeaders());r.push("Signature="+this.signature(e,t));return r.join(", ")},signature:function p(e,t){var r=s[this.serviceName];var i=t.substr(0,8);if(!r||r.akid!==e.accessKeyId||r.region!==this.request.region||r.date!==i){var a=e.secretAccessKey;var o=n.util.crypto.hmac("AWS4"+a,i,"buffer");var u=n.util.crypto.hmac(o,this.request.region,"buffer");var c=n.util.crypto.hmac(u,this.serviceName,"buffer");var l=n.util.crypto.hmac(c,"aws4_request","buffer");s[this.serviceName]={region:this.request.region,date:i,key:l,akid:e.accessKeyId}}var p=s[this.serviceName].key;return n.util.crypto.hmac(p,this.stringToSign(t),"hex")},stringToSign:function f(e){var t=[];t.push("AWS4-HMAC-SHA256");t.push(e);t.push(this.credentialString(e));t.push(this.hexEncodedHash(this.canonicalString()));return t.join("\n")},canonicalString:function m(){var e=[];e.push(this.request.method);e.push(this.request.pathname());e.push(this.request.search());e.push(this.canonicalHeaders()+"\n");e.push(this.signedHeaders());e.push(this.hexEncodedBodyHash());return e.join("\n")},canonicalHeaders:function d(){var e=[];n.util.each.call(this,this.request.headers,function(t,r){e.push([t,r])});e.sort(function(e,t){return e[0].toLowerCase()<t[0].toLowerCase()?-1:1});var t=[];n.util.arrayEach.call(this,e,function(e){var r=e[0].toLowerCase();if(this.isSignableHeader(r)){t.push(r+":"+this.canonicalHeaderValues(e[1].toString()))}});return t.join("\n")},canonicalHeaderValues:function h(e){return e.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")},signedHeaders:function y(){var e=[];n.util.each.call(this,this.request.headers,function(t){t=t.toLowerCase();if(this.isSignableHeader(t))e.push(t)});return e.sort().join(";")},credentialString:function b(e){var t=[];t.push(e.substr(0,8));t.push(this.request.region);t.push(this.serviceName);t.push("aws4_request");return t.join("/")},hexEncodedHash:function g(e){return n.util.crypto.sha256(e,"hex")},hexEncodedBodyHash:function v(){if(this.request.headers["X-Amz-Content-Sha256"]){return this.request.headers["X-Amz-Content-Sha256"]}else{return this.hexEncodedHash(this.request.body||"")}},unsignableHeaders:["authorization","content-type","user-agent","x-amz-user-agent","x-amz-content-sha256"],isSignableHeader:function E(e){return this.unsignableHeaders.indexOf(e)<0}}); | |
t.exports=n.Signers.V4},{"../core":33}],65:[function(e,t,r){var n=e("__browserify_process");var i=e("./core");var s=e("crypto");var a=e("buffer").Buffer;i.util={engine:function o(){if(i.util.isBrowser()&&typeof navigator!=="undefined"){return navigator.userAgent}else{return n.platform+"/"+n.version}},userAgent:function u(){var e=i.util.isBrowser()?"js":"nodejs";var t="aws-sdk-"+e+"/"+i.VERSION;if(e==="nodejs")t+=" "+i.util.engine();return t},isBrowser:function c(){return typeof window!=="undefined"},isNode:function l(){return!i.util.isBrowser()},uriEscape:function p(e){var t=encodeURIComponent(e);t=t.replace(/[^A-Za-z0-9_.~\-%]+/g,escape);t=t.replace(/[*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});return t},uriEscapePath:function f(e){var t=[];i.util.arrayEach(e.split("/"),function(e){t.push(i.util.uriEscape(e))});return t.join("/")},urlParse:function m(t){return e("url").parse(t)},queryParamsToString:function d(e){var t=[];var r=i.util.uriEscape;var n=Object.keys(e).sort();i.util.arrayEach(n,function(n){var s=e[n];var a=r(n);var o=a;if(Array.isArray(s)){var u=[];i.util.arrayEach(s,function(e){u.push(r(e))});o=a+"="+u.sort().join("&"+a+"=")}else if(s!==undefined&&s!==null){o=a+"="+r(s)}t.push(o)});return t.join("&")},readFileSync:function h(t){if(typeof window!=="undefined")return null;return e("fs").readFileSync(t,"utf-8")},base64:{encode:function y(e){return new a(e).toString("base64")},decode:function b(e){return new a(e,"base64").toString()}},buffer:{Buffer:a,concat:function(e){var t=0,r=0,n=null,i;for(i=0;i<e.length;i++){t+=e[i].length}n=new a(t);for(i=0;i<e.length;i++){e[i].copy(n,r);r+=e[i].length}return n}},string:{byteLength:function g(t){if(t===null||t===undefined)return 0;if(typeof t==="string")t=new a(t);if(typeof t.byteLength==="number"){return t.byteLength}else if(typeof t.length==="number"){return t.length}else if(typeof t.size==="number"){return t.size}else if(typeof t.path==="string"){return e("fs").lstatSync(t.path).size}else{throw i.util.error(new Error("Cannot determine length of "+t),{object:t})}}},jamespath:{query:function v(e,t){if(!t)return[];var r=[];var n=e.split(/\s+or\s+/);i.util.arrayEach.call(this,n,function(e){var n=[t];var s=e.split(".");i.util.arrayEach.call(this,s,function(e){var t=e.match("^(.+?)(?:\\[(-?\\d+|\\*)\\])?$");var r=[];i.util.arrayEach.call(this,n,function(e){if(t[1]==="*"){i.util.arrayEach.call(this,e,function(e){r.push(e)})}else if(e.hasOwnProperty(t[1])){r.push(e[t[1]])}});n=r;if(t[2]){r=[];i.util.arrayEach.call(this,n,function(e){if(Array.isArray(e)){if(t[2]==="*"){r=r.concat(e)}else{var n=parseInt(t[2],10);if(n<0)n=e.length+n;r.push(e[n])}}});n=r}if(n.length===0)return i.util.abort});if(n.length>0){r=n;return i.util.abort}});return r},find:function E(e,t){return i.util.jamespath.query(e,t)[0]}},date:{getDate:function w(){return new Date},iso8601:function S(e){if(e===undefined){e=i.util.date.getDate()}return e.toISOString()},rfc822:function T(e){if(e===undefined){e=i.util.date.getDate()}return e.toUTCString()},unixTimestamp:function C(e){if(e===undefined){e=i.util.date.getDate()}return e.getTime()/1e3},from:function A(e){if(typeof e==="number"){return new Date(e*1e3)}else{return new Date(e)}},format:function x(e,t){if(!t)t="iso8601";return i.util.date[t](i.util.date.from(e))}},crypto:{crc32Table:[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],crc32:function I(e){var t=i.util.crypto.crc32Table;var r=0^-1;if(typeof e==="string"){e=new a(e)}for(var n=0;n<e.length;n++){var s=e.readUInt8(n);r=r>>>8^t[(r^s)&255]}return(r^-1)>>>0},hmac:function R(e,t,r,n){if(!r)r="binary";if(r==="buffer"){r=undefined}if(!n)n="sha256";if(typeof t==="string")t=new a(t);return s.createHmac(n,e).update(t).digest(r)},md5:function k(e,t){if(!t){t="binary"}if(t==="buffer"){t=undefined}if(typeof e==="string")e=new a(e);return i.util.crypto.createHash("md5").update(e).digest(t)},sha256:function N(e,t){if(!t){t="binary"}if(t==="buffer"){t=undefined}if(typeof e==="string")e=new a(e);return i.util.crypto.createHash("sha256").update(e).digest(t)},toHex:function B(e){var t=[];for(var r=0;r<e.length;r++){t.push(("0"+e.charCodeAt(r).toString(16)).substr(-2,2))}return t.join("")},createHash:function _(e){return s.createHash(e)}},abort:{},each:function q(e,t){for(var r in e){if(e.hasOwnProperty(r)){var n=t.call(this,r,e[r]);if(n===i.util.abort)break}}},arrayEach:function L(e,t){for(var r in e){if(e.hasOwnProperty(r)){var n=t.call(this,e[r],parseInt(r,10));if(n===i.util.abort)break}}},update:function D(e,t){i.util.each(t,function r(t,n){e[t]=n});return e},merge:function M(e,t){return i.util.update(i.util.copy(e),t)},copy:function P(e){if(e===null||e===undefined)return e;var t={};for(var r in e){t[r]=e[r]}return t},isEmpty:function U(e){for(var t in e){if(e.hasOwnProperty(t)){return false}}return true},isType:function O(e,t){if(typeof t==="function")t=i.util.typeName(t);return Object.prototype.toString.call(e)==="[object "+t+"]"},typeName:function j(e){if(e.hasOwnProperty("name"))return e.name;var t=e.toString();var r=t.match(/^\s*function (.+)\(/);return r?r[1]:t},error:function z(e,t){var r=null;if(typeof e.message==="string"&&e.message!==""){if(typeof t==="string"||t&&t.message){r=i.util.copy(e);r.message=e.message}}e.message=e.message||null;if(typeof t==="string"){e.message=t}else{i.util.update(e,t)}if(typeof Object.defineProperty==="function"){Object.defineProperty(e,"name",{writable:true,enumerable:false});Object.defineProperty(e,"message",{enumerable:true})}e.name=e.name||e.code||"Error";e.time=new Date;if(r)e.originalError=r;return e},inherit:function V(e,t){var r=null;if(t===undefined){t=e;e=Object;r={}}else{var n=function s(){};n.prototype=e.prototype;r=new n}if(t.constructor===Object){t.constructor=function(){if(e!==Object){return e.apply(this,arguments)}}}t.constructor.prototype=r;i.util.update(t.constructor.prototype,t);t.constructor.__super__=e;return t.constructor},mixin:function K(){var e=arguments[0];for(var t=1;t<arguments.length;t++){for(var r in arguments[t].prototype){var n=arguments[t].prototype[r];if(r!="constructor"){e.prototype[r]=n}}}return e},hideProperties:function G(e,t){if(typeof Object.defineProperty!=="function")return;i.util.arrayEach(t,function(t){Object.defineProperty(e,t,{enumerable:false,writable:true,configurable:true})})}};t.exports=i.util},{"./core":33,__browserify_process:11,buffer:12,crypto:3,fs:1,url:27}],66:[function(e,t,r){var n=e("../core");var i=e("xmlbuilder");var s=n.util.inherit;n.XML.Builder=s({constructor:function a(e,t,r){this.root=e;this.rules=t;this.xmlns=r.xmlnamespace;this.timestampFormat=r.timestampFormat},toXML:function o(e){var t=i.create(this.root);if(this.xmlns)t.att("xmlns",this.xmlns);this.serializeStructure(this.rules,e,t);return t.root().toString()},serializeStructure:function u(e,t,r){n.util.each.call(this,e||{},function(e,n){var i=t[e];if(i!==undefined){if(n.attribute){r.att(n.name,i)}else{this.serializeMember(e,n,i,r)}}})},serializeList:function c(e,t,r,i){if(t.flattened){n.util.arrayEach.call(this,r,function(r){this.serializeMember(t.name||e,t.members,r,i)})}else{i=i.ele(t.name||e);n.util.arrayEach.call(this,r,function(e){var r=t.members.name||"member";this.serializeMember(r,t.members,e,i)})}},serializeMember:function l(e,t,r,i){var s=e;if(t.type==="structure"){i=i.ele(s);this.serializeStructure(t.members,r,i)}else if(t.type==="list"){this.serializeList(s,t,r,i)}else if(t.type==="timestamp"){var a=t.format||this.timestampFormat;var o=n.util.date.format(r,a);i=i.ele(s,String(o))}else{i=i.ele(s,String(r))}this.applyNamespaces(i,t)},applyNamespaces:function p(e,t){if(t.xmlns){var r="xmlns";if(t.xmlns.prefix)r+=":"+t.xmlns.prefix;e.att(r,t.xmlns.uri)}}})},{"../core":33,xmlbuilder:72}],67:[function(e,t,r){var n=e("../core");var i=n.util.inherit;var s=e("xml2js");n.XML.Parser=i({constructor:function a(e){this.rules=(e||{}).members||{}},options:{explicitCharkey:false,trim:false,normalize:false,explicitRoot:false,emptyTag:null,explicitArray:true,ignoreAttrs:false,mergeAttrs:false,validator:null},parse:function o(e){var t=null;var r=null;var i=new s.Parser(this.options);i.parseString(e,function(e,n){r=e;t=n});if(t){delete t.xmlns;return this.parseStructure(t,this.rules)}else if(r){throw n.util.error(r,{code:"XMLParserError"})}else{return this.parseStructure({},this.rules)}},parseStructure:function u(e,t){var r={};n.util.each.call(this,t,function(e,t){if(t.type=="list"){r[t.name||e]=[]}});n.util.each.call(this,e,function(e,i){if(e=="$"){n.util.each.call(this,i,function(n,i){if(t[n]){var s=t[n];r[s.name||e]=this.parseMember([i],s)}})}else{var s=t[e]||{};r[s.name||e]=this.parseMember(i,s)}});return r},parseMap:function c(e,t){var r={};var i=t.keys||{};var s=t.members||{};var a=i.name||"key";var o=s.name||"value";if(!t.flattened){e=e[0].entry}n.util.arrayEach.call(this,e,function(e){var t=this.parseMember(e[o],s);r[e[a][0]]=t});return r},parseList:function l(e,t){var r=[];var i=t.members||{};var s=i.name||"member";if(t.flattened){n.util.arrayEach.call(this,e,function(e){r.push(this.parseMember([e],i))})}else{n.util.arrayEach.call(this,e,function(e){n.util.arrayEach.call(this,e[s],function(e){r.push(this.parseMember([e],i))})})}return r},parseMember:function p(e,t){if(e[0]===null){if(t.type==="structure")return{};if(t.type==="list")return[];if(t.type==="map")return{};return null}if(e[0]["$"]&&e[0]["$"].encoding=="base64"){return n.util.base64.decode(e[0]["_"])}if(!t.type){if(typeof e[0]==="string"){t.type="string"}else if(e[0]["_"]){t.type="string";e=[e[0]["_"]]}else{t.type="structure"}}if(t.type==="string"){return e[0]}else if(t.type==="structure"){return this.parseStructure(e[0],t.members||{})}else if(t.type==="list"){return this.parseList(e,t)}else if(t.type==="map"){return this.parseMap(e,t)}else if(t.type==="integer"){return parseInt(e[0],10)}else if(t.type==="float"){return parseFloat(e[0])}else if(t.type==="timestamp"){return this.parseTimestamp(e[0])}else if(t.type==="boolean"){return e[0]==="true"}else{var r="unhandled type: "+t.type;throw n.util.error(new Error(r),{code:"XMLParserError"})}},parseTimestamp:function f(e){if(e.match(/^\d+$/)){return new Date(e*1e3)}else if(e.match(/^\d{4}/)){return new Date(e)}else if(e.match(/^\w{3},/)){return new Date(e)}else{throw n.util.error(new Error("unhandled timestamp format: "+e),{code:"TimestampParserError"})}}})},{"../core":33,xml2js:68}],68:[function(e,t,r){(function(){var t,n,i,s={}.hasOwnProperty,a=function(e,t){for(var r in t){if(s.call(t,r))e[r]=t[r]}function n(){this.constructor=e}n.prototype=t.prototype;e.prototype=new n;e.__super__=t.prototype;return e},o=function(e,t){return function(){return e.apply(t,arguments)}};i=e("sax");t=e("events");n=function(e){return typeof e==="object"&&e!=null&&Object.keys(e).length===0};r.defaults={.1:{explicitCharkey:false,trim:true,normalize:true,normalizeTags:false,attrkey:"@",charkey:"#",explicitArray:false,ignoreAttrs:false,mergeAttrs:false,explicitRoot:false,validator:null,xmlns:false},.2:{explicitCharkey:false,trim:false,normalize:false,normalizeTags:false,attrkey:"$",charkey:"_",explicitArray:true,ignoreAttrs:false,mergeAttrs:false,explicitRoot:true,validator:null,xmlns:false}};r.ValidationError=function(e){a(t,e);function t(e){this.message=e}return t}(Error);r.Parser=function(e){a(t,e);function t(e){this.parseString=o(this.parseString,this);this.reset=o(this.reset,this);var t,n,i;this.options={};i=r.defaults["0.2"];for(t in i){if(!s.call(i,t))continue;n=i[t];this.options[t]=n}for(t in e){if(!s.call(e,t))continue;n=e[t];this.options[t]=n}if(this.options.xmlns){this.options.xmlnskey=this.options.attrkey+"ns"}this.reset()}t.prototype.reset=function(){var e,t,r,a,o=this;this.removeAllListeners();this.saxParser=i.parser(true,{trim:false,normalize:false,xmlns:this.options.xmlns});r=false;this.saxParser.onerror=function(e){if(!r){r=true;return o.emit("error",e)}};this.EXPLICIT_CHARKEY=this.options.explicitCharkey;this.resultObject=null;a=[];e=this.options.attrkey;t=this.options.charkey;this.saxParser.onopentag=function(r){var n,i,u;i={};i[t]="";if(!o.options.ignoreAttrs){u=r.attributes;for(n in u){if(!s.call(u,n))continue;if(!(e in i)&&!o.options.mergeAttrs){i[e]={}}if(o.options.mergeAttrs){i[n]=r.attributes[n]}else{i[e][n]=r.attributes[n]}}}i["#name"]=o.options.normalizeTags?r.name.toLowerCase():r.name;if(o.options.xmlns){i[o.options.xmlnskey]={uri:r.uri,local:r.local}}return a.push(i)};this.saxParser.onclosetag=function(){var e,r,i,s,u,c;i=a.pop();r=i["#name"];delete i["#name"];u=a[a.length-1];if(i[t].match(/^\s*$/)){delete i[t]}else{if(o.options.trim){i[t]=i[t].trim()}if(o.options.normalize){i[t]=i[t].replace(/\s{2,}/g," ").trim()}if(Object.keys(i).length===1&&t in i&&!o.EXPLICIT_CHARKEY){i=i[t]}}if(o.options.emptyTag!==void 0&&n(i)){i=o.options.emptyTag}if(o.options.validator!=null){c="/"+function(){var t,r,n;n=[];for(t=0,r=a.length;t<r;t++){e=a[t];n.push(e["#name"])}return n}().concat(r).join("/");i=o.options.validator(c,u&&u[r],i)}if(a.length>0){if(!o.options.explicitArray){if(!(r in u)){return u[r]=i}else if(u[r]instanceof Array){return u[r].push(i)}else{s=u[r];u[r]=[s];return u[r].push(i)}}else{if(!(u[r]instanceof Array)){u[r]=[]}return u[r].push(i)}}else{if(o.options.explicitRoot){s=i;i={};i[r]=s}o.resultObject=i;return o.emit("end",o.resultObject)}};return this.saxParser.ontext=this.saxParser.oncdata=function(e){var r;r=a[a.length-1];if(r){return r[t]+=e}}};t.prototype.parseString=function(e,t){if(t!=null&&typeof t==="function"){this.on("end",function(e){this.reset();return t(null,e)});this.on("error",function(e){this.reset();return t(e)})}if(e.toString().trim()===""){this.emit("end",null);return true}try{return this.saxParser.write(e.toString())}catch(r){return this.emit("error",r.message)}};return t}(t.EventEmitter);r.parseString=function(e,t,n){var i,s,a;if(n!=null){if(typeof n==="function"){i=n}if(typeof t==="object"){s=t}}else{if(typeof t==="function"){i=t}s={}}a=new r.Parser(s);return a.parseString(e,i)}}).call(this)},{events:8,sax:69}],69:[function(e,t,r){(function(t){t.parser=function(e,t){return new n(e,t)};t.SAXParser=n;t.SAXStream=l;t.createStream=c;t.MAX_BUFFER_LENGTH=64*1024;var r=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function n(e,r){if(!(this instanceof n))return new n(e,r);var i=this;s(i);i.q=i.c="";i.bufferCheckPosition=t.MAX_BUFFER_LENGTH;i.opt=r||{};i.opt.lowercase=i.opt.lowercase||i.opt.lowercasetags;i.looseCase=i.opt.lowercase?"toLowerCase":"toUpperCase";i.tags=[];i.closed=i.closedRoot=i.sawRoot=false;i.tag=i.error=null;i.strict=!!e;i.noscript=!!(e||i.opt.noscript);i.state=R.BEGIN;i.ENTITIES=Object.create(t.ENTITIES);i.attribList=[];if(i.opt.xmlns)i.ns=Object.create(w);i.trackPosition=i.opt.position!==false;if(i.trackPosition){i.position=i.line=i.column=0}k(i,"onready")}if(!Object.create)Object.create=function(e){function t(){this.__proto__=e}t.prototype=e;return new t};if(!Object.getPrototypeOf)Object.getPrototypeOf=function(e){return e.__proto__};if(!Object.keys)Object.keys=function(e){var t=[];for(var r in e)if(e.hasOwnProperty(r))t.push(r);return t};function i(e){var n=Math.max(t.MAX_BUFFER_LENGTH,10),i=0;for(var s=0,a=r.length;s<a;s++){var o=e[r[s]].length;if(o>n){switch(r[s]){case"textNode":B(e);break;case"cdata":N(e,"oncdata",e.cdata);e.cdata="";break;case"script":N(e,"onscript",e.script);e.script="";break;default:q(e,"Max buffer length exceeded: "+r[s])}}i=Math.max(i,o)}e.bufferCheckPosition=t.MAX_BUFFER_LENGTH-i+e.position}function s(e){for(var t=0,n=r.length;t<n;t++){e[r[t]]=""}}n.prototype={end:function(){L(this)},write:V,resume:function(){this.error=null;return this},close:function(){return this.write(null)}};try{var a=e("stream").Stream}catch(o){var a=function(){}}var u=t.EVENTS.filter(function(e){return e!=="error"&&e!=="end"});function c(e,t){return new l(e,t)}function l(e,t){if(!(this instanceof l))return new l(e,t);a.apply(this);this._parser=new n(e,t);this.writable=true;this.readable=true;var r=this;this._parser.onend=function(){r.emit("end")};this._parser.onerror=function(e){r.emit("error",e);r._parser.error=null};u.forEach(function(e){Object.defineProperty(r,"on"+e,{get:function(){return r._parser["on"+e]},set:function(t){if(!t){r.removeAllListeners(e);return r._parser["on"+e]=t}r.on(e,t)},enumerable:true,configurable:false})})}l.prototype=Object.create(a.prototype,{constructor:{value:l}});l.prototype.write=function(e){this._parser.write(e.toString());this.emit("data",e);return true};l.prototype.end=function(e){if(e&&e.length)this._parser.write(e.toString());this._parser.end();return true};l.prototype.on=function(e,t){var r=this;if(!r._parser["on"+e]&&u.indexOf(e)!==-1){r._parser["on"+e]=function(){var t=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e);r.emit.apply(r,t)}}return a.prototype.on.call(r,e,t)};var p="\r\n ",f="0124356789",m="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",d="'\"",h=f+m+"#",y=p+">",b="[CDATA[",g="DOCTYPE",v="http://www.w3.org/XML/1998/namespace",E="http://www.w3.org/2000/xmlns/",w={xml:v,xmlns:E};p=C(p);f=C(f);m=C(m);var S=/[:_A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�]/;var T=/[:_A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�·̀-ͯ‿-⁀\.\d-]/;d=C(d);h=C(h);y=C(y);function C(e){return e.split("").reduce(function(e,t){e[t]=true;return e},{})}function A(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function x(e,t){return A(e)?!!t.match(e):e[t]}function I(e,t){return!x(e,t)}var R=0;t.STATE={BEGIN:R++,TEXT:R++,TEXT_ENTITY:R++,OPEN_WAKA:R++,SGML_DECL:R++,SGML_DECL_QUOTED:R++,DOCTYPE:R++,DOCTYPE_QUOTED:R++,DOCTYPE_DTD:R++,DOCTYPE_DTD_QUOTED:R++,COMMENT_STARTING:R++,COMMENT:R++,COMMENT_ENDING:R++,COMMENT_ENDED:R++,CDATA:R++,CDATA_ENDING:R++,CDATA_ENDING_2:R++,PROC_INST:R++,PROC_INST_BODY:R++,PROC_INST_ENDING:R++,OPEN_TAG:R++,OPEN_TAG_SLASH:R++,ATTRIB:R++,ATTRIB_NAME:R++,ATTRIB_NAME_SAW_WHITE:R++,ATTRIB_VALUE:R++,ATTRIB_VALUE_QUOTED:R++,ATTRIB_VALUE_UNQUOTED:R++,ATTRIB_VALUE_ENTITY_Q:R++,ATTRIB_VALUE_ENTITY_U:R++,CLOSE_TAG:R++,CLOSE_TAG_SAW_WHITE:R++,SCRIPT:R++,SCRIPT_ENDING:R++};t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830};Object.keys(t.ENTITIES).forEach(function(e){var r=t.ENTITIES[e];var n=typeof r==="number"?String.fromCharCode(r):r;t.ENTITIES[e]=n});for(var R in t.STATE)t.STATE[t.STATE[R]]=R;R=t.STATE;function k(e,t,r){e[t]&&e[t](r)}function N(e,t,r){if(e.textNode)B(e);k(e,t,r)}function B(e){e.textNode=_(e.opt,e.textNode);if(e.textNode)k(e,"ontext",e.textNode);e.textNode=""}function _(e,t){if(e.trim)t=t.trim();if(e.normalize)t=t.replace(/\s+/g," ");return t}function q(e,t){B(e);if(e.trackPosition){t+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c}t=new Error(t);e.error=t;k(e,"onerror",t);return e}function L(e){if(!e.closedRoot)D(e,"Unclosed root tag");if(e.state!==R.TEXT)q(e,"Unexpected end");B(e);e.c="";e.closed=true;k(e,"onend");n.call(e,e.strict,e.opt);return e}function D(e,t){if(typeof e!=="object"||!(e instanceof n))throw new Error("bad call to strictFail");if(e.strict)q(e,t)}function M(e){if(!e.strict)e.tagName=e.tagName[e.looseCase]();var t=e.tags[e.tags.length-1]||e,r=e.tag={name:e.tagName,attributes:{}};if(e.opt.xmlns)r.ns=t.ns;e.attribList.length=0}function P(e){var t=e.indexOf(":"),r=t<0?["",e]:e.split(":"),n=r[0],i=r[1];if(e==="xmlns"){n="xmlns";i=""}return{prefix:n,local:i}}function U(e){if(!e.strict)e.attribName=e.attribName[e.looseCase]();if(e.attribList.indexOf(e.attribName)!==-1||e.tag.attributes.hasOwnProperty(e.attribName)){return e.attribName=e.attribValue=""}if(e.opt.xmlns){var t=P(e.attribName),r=t.prefix,n=t.local;if(r==="xmlns"){if(n==="xml"&&e.attribValue!==v){D(e,"xml: prefix must be bound to "+v+"\n"+"Actual: "+e.attribValue)}else if(n==="xmlns"&&e.attribValue!==E){D(e,"xmlns: prefix must be bound to "+E+"\n"+"Actual: "+e.attribValue)}else{var i=e.tag,s=e.tags[e.tags.length-1]||e;if(i.ns===s.ns){i.ns=Object.create(s.ns)}i.ns[n]=e.attribValue}}e.attribList.push([e.attribName,e.attribValue])}else{e.tag.attributes[e.attribName]=e.attribValue;N(e,"onattribute",{name:e.attribName,value:e.attribValue})}e.attribName=e.attribValue=""}function O(e,t){if(e.opt.xmlns){var r=e.tag;var n=P(e.tagName);r.prefix=n.prefix;r.local=n.local;r.uri=r.ns[n.prefix]||"";if(r.prefix&&!r.uri){D(e,"Unbound namespace prefix: "+JSON.stringify(e.tagName));r.uri=n.prefix}var i=e.tags[e.tags.length-1]||e;if(r.ns&&i.ns!==r.ns){Object.keys(r.ns).forEach(function(t){N(e,"onopennamespace",{prefix:t,uri:r.ns[t]})})}for(var s=0,a=e.attribList.length;s<a;s++){var o=e.attribList[s];var u=o[0],c=o[1],l=P(u),p=l.prefix,f=l.local,m=p==""?"":r.ns[p]||"",d={name:u,value:c,prefix:p,local:f,uri:m};if(p&&p!="xmlns"&&!m){D(e,"Unbound namespace prefix: "+JSON.stringify(p));d.uri=p}e.tag.attributes[u]=d;N(e,"onattribute",d)}e.attribList.length=0}e.tag.isSelfClosing=!!t;e.sawRoot=true;e.tags.push(e.tag);N(e,"onopentag",e.tag);if(!t){if(!e.noscript&&e.tagName.toLowerCase()==="script"){e.state=R.SCRIPT}else{e.state=R.TEXT}e.tag=null;e.tagName=""}e.attribName=e.attribValue="";e.attribList.length=0}function j(e){if(!e.tagName){D(e,"Weird empty close tag.");e.textNode+="</>";e.state=R.TEXT;return}if(e.script){if(e.tagName!=="script"){e.script+="</"+e.tagName+">";e.tagName="";e.state=R.SCRIPT;return}N(e,"onscript",e.script);e.script=""}var t=e.tags.length;var r=e.tagName;if(!e.strict)r=r[e.looseCase]();var n=r;while(t--){var i=e.tags[t];if(i.name!==n){D(e,"Unexpected close tag")}else break}if(t<0){D(e,"Unmatched closing tag: "+e.tagName);e.textNode+="</"+e.tagName+">";e.state=R.TEXT;return}e.tagName=r;var s=e.tags.length;while(s-->t){var a=e.tag=e.tags.pop();e.tagName=e.tag.name;N(e,"onclosetag",e.tagName);var o={};for(var u in a.ns)o[u]=a.ns[u];var c=e.tags[e.tags.length-1]||e;if(e.opt.xmlns&&a.ns!==c.ns){Object.keys(a.ns).forEach(function(t){var r=a.ns[t];N(e,"onclosenamespace",{prefix:t,uri:r})})}}if(t===0)e.closedRoot=true;e.tagName=e.attribValue=e.attribName="";e.attribList.length=0;e.state=R.TEXT}function z(e){var t=e.entity,r=t.toLowerCase(),n,i="";if(e.ENTITIES[t])return e.ENTITIES[t];if(e.ENTITIES[r])return e.ENTITIES[r];t=r;if(t.charAt(0)==="#"){if(t.charAt(1)==="x"){t=t.slice(2);n=parseInt(t,16);i=n.toString(16)}else{t=t.slice(1);n=parseInt(t,10);i=n.toString(10)}}t=t.replace(/^0+/,"");if(i.toLowerCase()!==t){D(e,"Invalid character entity");return"&"+e.entity+";"}return String.fromCharCode(n)}function V(e){var t=this;if(this.error)throw this.error;if(t.closed)return q(t,"Cannot write after close. Assign an onready handler.");if(e===null)return L(t);var r=0,n="";while(t.c=n=e.charAt(r++)){if(t.trackPosition){t.position++;if(n==="\n"){t.line++;t.column=0}else t.column++}switch(t.state){case R.BEGIN:if(n==="<"){t.state=R.OPEN_WAKA;t.startTagPosition=t.position}else if(I(p,n)){D(t,"Non-whitespace before first tag.");t.textNode=n;t.state=R.TEXT}continue;case R.TEXT:if(t.sawRoot&&!t.closedRoot){var s=r-1;while(n&&n!=="<"&&n!=="&"){n=e.charAt(r++);if(n&&t.trackPosition){t.position++;if(n==="\n"){t.line++;t.column=0}else t.column++}}t.textNode+=e.substring(s,r-1)}if(n==="<"){t.state=R.OPEN_WAKA;t.startTagPosition=t.position}else{if(I(p,n)&&(!t.sawRoot||t.closedRoot))D(t,"Text data outside of root node.");if(n==="&")t.state=R.TEXT_ENTITY;else t.textNode+=n}continue;case R.SCRIPT:if(n==="<"){t.state=R.SCRIPT_ENDING}else t.script+=n;continue;case R.SCRIPT_ENDING:if(n==="/"){t.state=R.CLOSE_TAG}else{t.script+="<"+n;t.state=R.SCRIPT}continue;case R.OPEN_WAKA:if(n==="!"){t.state=R.SGML_DECL;t.sgmlDecl=""}else if(x(p,n)){}else if(x(S,n)){t.state=R.OPEN_TAG;t.tagName=n}else if(n==="/"){t.state=R.CLOSE_TAG;t.tagName=""}else if(n==="?"){t.state=R.PROC_INST;t.procInstName=t.procInstBody=""}else{D(t,"Unencoded <");if(t.startTagPosition+1<t.position){var a=t.position-t.startTagPosition;n=new Array(a).join(" ")+n}t.textNode+="<"+n;t.state=R.TEXT}continue;case R.SGML_DECL:if((t.sgmlDecl+n).toUpperCase()===b){N(t,"onopencdata");t.state=R.CDATA;t.sgmlDecl="";t.cdata=""}else if(t.sgmlDecl+n==="--"){t.state=R.COMMENT;t.comment="";t.sgmlDecl=""}else if((t.sgmlDecl+n).toUpperCase()===g){t.state=R.DOCTYPE;if(t.doctype||t.sawRoot)D(t,"Inappropriately located doctype declaration");t.doctype="";t.sgmlDecl=""}else if(n===">"){N(t,"onsgmldeclaration",t.sgmlDecl);t.sgmlDecl="";t.state=R.TEXT}else if(x(d,n)){t.state=R.SGML_DECL_QUOTED;t.sgmlDecl+=n}else t.sgmlDecl+=n;continue;case R.SGML_DECL_QUOTED:if(n===t.q){t.state=R.SGML_DECL;t.q=""}t.sgmlDecl+=n;continue;case R.DOCTYPE:if(n===">"){t.state=R.TEXT;N(t,"ondoctype",t.doctype);t.doctype=true}else{t.doctype+=n;if(n==="[")t.state=R.DOCTYPE_DTD;else if(x(d,n)){t.state=R.DOCTYPE_QUOTED;t.q=n}}continue;case R.DOCTYPE_QUOTED:t.doctype+=n;if(n===t.q){t.q="";t.state=R.DOCTYPE}continue;case R.DOCTYPE_DTD:t.doctype+=n;if(n==="]")t.state=R.DOCTYPE;else if(x(d,n)){t.state=R.DOCTYPE_DTD_QUOTED;t.q=n}continue;case R.DOCTYPE_DTD_QUOTED:t.doctype+=n;if(n===t.q){t.state=R.DOCTYPE_DTD;t.q=""}continue;case R.COMMENT:if(n==="-")t.state=R.COMMENT_ENDING;else t.comment+=n;continue;case R.COMMENT_ENDING:if(n==="-"){t.state=R.COMMENT_ENDED;t.comment=_(t.opt,t.comment);if(t.comment)N(t,"oncomment",t.comment);t.comment=""}else{t.comment+="-"+n;t.state=R.COMMENT}continue;case R.COMMENT_ENDED:if(n!==">"){D(t,"Malformed comment");t.comment+="--"+n;t.state=R.COMMENT}else t.state=R.TEXT;continue;case R.CDATA:if(n==="]")t.state=R.CDATA_ENDING;else t.cdata+=n;continue;case R.CDATA_ENDING:if(n==="]")t.state=R.CDATA_ENDING_2;else{t.cdata+="]"+n;t.state=R.CDATA}continue;case R.CDATA_ENDING_2:if(n===">"){if(t.cdata)N(t,"oncdata",t.cdata);N(t,"onclosecdata");t.cdata="";t.state=R.TEXT}else if(n==="]"){t.cdata+="]"}else{t.cdata+="]]"+n;t.state=R.CDATA}continue;case R.PROC_INST:if(n==="?")t.state=R.PROC_INST_ENDING;else if(x(p,n))t.state=R.PROC_INST_BODY;else t.procInstName+=n;continue;case R.PROC_INST_BODY:if(!t.procInstBody&&x(p,n))continue;else if(n==="?")t.state=R.PROC_INST_ENDING;else t.procInstBody+=n;continue;case R.PROC_INST_ENDING:if(n===">"){N(t,"onprocessinginstruction",{name:t.procInstName,body:t.procInstBody});t.procInstName=t.procInstBody="";t.state=R.TEXT}else{t.procInstBody+="?"+n;t.state=R.PROC_INST_BODY}continue;case R.OPEN_TAG:if(x(T,n))t.tagName+=n;else{M(t);if(n===">")O(t);else if(n==="/")t.state=R.OPEN_TAG_SLASH;else{if(I(p,n))D(t,"Invalid character in tag name");t.state=R.ATTRIB}}continue;case R.OPEN_TAG_SLASH:if(n===">"){O(t,true);j(t)}else{D(t,"Forward-slash in opening tag not followed by >");t.state=R.ATTRIB}continue;case R.ATTRIB:if(x(p,n))continue;else if(n===">")O(t);else if(n==="/")t.state=R.OPEN_TAG_SLASH; | |
else if(x(S,n)){t.attribName=n;t.attribValue="";t.state=R.ATTRIB_NAME}else D(t,"Invalid attribute name");continue;case R.ATTRIB_NAME:if(n==="=")t.state=R.ATTRIB_VALUE;else if(n===">"){D(t,"Attribute without value");t.attribValue=t.attribName;U(t);O(t)}else if(x(p,n))t.state=R.ATTRIB_NAME_SAW_WHITE;else if(x(T,n))t.attribName+=n;else D(t,"Invalid attribute name");continue;case R.ATTRIB_NAME_SAW_WHITE:if(n==="=")t.state=R.ATTRIB_VALUE;else if(x(p,n))continue;else{D(t,"Attribute without value");t.tag.attributes[t.attribName]="";t.attribValue="";N(t,"onattribute",{name:t.attribName,value:""});t.attribName="";if(n===">")O(t);else if(x(S,n)){t.attribName=n;t.state=R.ATTRIB_NAME}else{D(t,"Invalid attribute name");t.state=R.ATTRIB}}continue;case R.ATTRIB_VALUE:if(x(p,n))continue;else if(x(d,n)){t.q=n;t.state=R.ATTRIB_VALUE_QUOTED}else{D(t,"Unquoted attribute value");t.state=R.ATTRIB_VALUE_UNQUOTED;t.attribValue=n}continue;case R.ATTRIB_VALUE_QUOTED:if(n!==t.q){if(n==="&")t.state=R.ATTRIB_VALUE_ENTITY_Q;else t.attribValue+=n;continue}U(t);t.q="";t.state=R.ATTRIB;continue;case R.ATTRIB_VALUE_UNQUOTED:if(I(y,n)){if(n==="&")t.state=R.ATTRIB_VALUE_ENTITY_U;else t.attribValue+=n;continue}U(t);if(n===">")O(t);else t.state=R.ATTRIB;continue;case R.CLOSE_TAG:if(!t.tagName){if(x(p,n))continue;else if(I(S,n)){if(t.script){t.script+="</"+n;t.state=R.SCRIPT}else{D(t,"Invalid tagname in closing tag.")}}else t.tagName=n}else if(n===">")j(t);else if(x(T,n))t.tagName+=n;else if(t.script){t.script+="</"+t.tagName;t.tagName="";t.state=R.SCRIPT}else{if(I(p,n))D(t,"Invalid tagname in closing tag");t.state=R.CLOSE_TAG_SAW_WHITE}continue;case R.CLOSE_TAG_SAW_WHITE:if(x(p,n))continue;if(n===">")j(t);else D(t,"Invalid characters in closing tag");continue;case R.TEXT_ENTITY:case R.ATTRIB_VALUE_ENTITY_Q:case R.ATTRIB_VALUE_ENTITY_U:switch(t.state){case R.TEXT_ENTITY:var o=R.TEXT,u="textNode";break;case R.ATTRIB_VALUE_ENTITY_Q:var o=R.ATTRIB_VALUE_QUOTED,u="attribValue";break;case R.ATTRIB_VALUE_ENTITY_U:var o=R.ATTRIB_VALUE_UNQUOTED,u="attribValue";break}if(n===";"){t[u]+=z(t);t.entity="";t.state=o}else if(x(h,n))t.entity+=n;else{D(t,"Invalid character entity");t[u]+="&"+t.entity+n;t.entity="";t.state=o}continue;default:throw new Error(t,"Unknown state: "+t.state)}}if(t.position>=t.bufferCheckPosition)i(t);return t}})(typeof r==="undefined"?sax={}:r)},{stream:20}],70:[function(e,t,r){(function(){var r,n;n=e("./XMLFragment");r=function(){function e(e,t,r){var i,s,a;this.children=[];this.rootObject=null;if(this.is(e,"Object")){a=[e,t],t=a[0],r=a[1];e=null}if(e!=null){e=""+e||"";if(t==null){t={version:"1.0"}}}if(t!=null&&!(t.version!=null)){throw new Error("Version number is required")}if(t!=null){t.version=""+t.version||"";if(!t.version.match(/1\.[0-9]+/)){throw new Error("Invalid version number: "+t.version)}i={version:t.version};if(t.encoding!=null){t.encoding=""+t.encoding||"";if(!t.encoding.match(/[A-Za-z](?:[A-Za-z0-9._-]|-)*/)){throw new Error("Invalid encoding: "+t.encoding)}i.encoding=t.encoding}if(t.standalone!=null){i.standalone=t.standalone?"yes":"no"}s=new n(this,"?xml",i);this.children.push(s)}if(r!=null){i={};if(e!=null){i.name=e}if(r.ext!=null){r.ext=""+r.ext||"";i.ext=r.ext}s=new n(this,"!DOCTYPE",i);this.children.push(s)}if(e!=null){this.begin(e)}}e.prototype.begin=function(t,r,i){var s,a;if(!(t!=null)){throw new Error("Root element needs a name")}if(this.rootObject){this.children=[];this.rootObject=null}if(r!=null){s=new e(t,r,i);return s.root()}t=""+t||"";a=new n(this,t,{});a.isRoot=true;a.documentObject=this;this.children.push(a);this.rootObject=a;return a};e.prototype.root=function(){return this.rootObject};e.prototype.end=function(e){return toString(e)};e.prototype.toString=function(e){var t,r,n,i,s;r="";s=this.children;for(n=0,i=s.length;n<i;n++){t=s[n];r+=t.toString(e)}return r};e.prototype.is=function(e,t){var r;r=Object.prototype.toString.call(e).slice(8,-1);return e!=null&&r===t};return e}();t.exports=r}).call(this)},{"./XMLFragment":71}],71:[function(e,t,r){(function(){var e,r={}.hasOwnProperty;e=function(){function e(e,t,r,n){this.isRoot=false;this.documentObject=null;this.parent=e;this.name=t;this.attributes=r;this.value=n;this.children=[]}e.prototype.element=function(t,n,i){var s,a,o,u,c;if(!(t!=null)){throw new Error("Missing element name")}t=""+t||"";this.assertLegalChar(t);if(n==null){n={}}if(this.is(n,"String")&&this.is(i,"Object")){u=[i,n],n=u[0],i=u[1]}else if(this.is(n,"String")){c=[{},n],n=c[0],i=c[1]}for(a in n){if(!r.call(n,a))continue;o=n[a];o=""+o||"";n[a]=this.escape(o)}s=new e(this,t,n);if(i!=null){i=""+i||"";i=this.escape(i);this.assertLegalChar(i);s.raw(i)}this.children.push(s);return s};e.prototype.insertBefore=function(t,n,i){var s,a,o,u,c,l;if(this.isRoot){throw new Error("Cannot insert elements at root level")}if(!(t!=null)){throw new Error("Missing element name")}t=""+t||"";this.assertLegalChar(t);if(n==null){n={}}if(this.is(n,"String")&&this.is(i,"Object")){c=[i,n],n=c[0],i=c[1]}else if(this.is(n,"String")){l=[{},n],n=l[0],i=l[1]}for(o in n){if(!r.call(n,o))continue;u=n[o];u=""+u||"";n[o]=this.escape(u)}s=new e(this.parent,t,n);if(i!=null){i=""+i||"";i=this.escape(i);this.assertLegalChar(i);s.raw(i)}a=this.parent.children.indexOf(this);this.parent.children.splice(a,0,s);return s};e.prototype.insertAfter=function(t,n,i){var s,a,o,u,c,l;if(this.isRoot){throw new Error("Cannot insert elements at root level")}if(!(t!=null)){throw new Error("Missing element name")}t=""+t||"";this.assertLegalChar(t);if(n==null){n={}}if(this.is(n,"String")&&this.is(i,"Object")){c=[i,n],n=c[0],i=c[1]}else if(this.is(n,"String")){l=[{},n],n=l[0],i=l[1]}for(o in n){if(!r.call(n,o))continue;u=n[o];u=""+u||"";n[o]=this.escape(u)}s=new e(this.parent,t,n);if(i!=null){i=""+i||"";i=this.escape(i);this.assertLegalChar(i);s.raw(i)}a=this.parent.children.indexOf(this);this.parent.children.splice(a+1,0,s);return s};e.prototype.remove=function(){var e,t;if(this.isRoot){throw new Error("Cannot remove the root element")}e=this.parent.children.indexOf(this);[].splice.apply(this.parent.children,[e,e-e+1].concat(t=[])),t;return this.parent};e.prototype.text=function(t){var r;if(!(t!=null)){throw new Error("Missing element text")}t=""+t||"";t=this.escape(t);this.assertLegalChar(t);r=new e(this,"",{},t);this.children.push(r);return this};e.prototype.cdata=function(t){var r;if(!(t!=null)){throw new Error("Missing CDATA text")}t=""+t||"";this.assertLegalChar(t);if(t.match(/]]>/)){throw new Error("Invalid CDATA text: "+t)}r=new e(this,"",{},"<![CDATA["+t+"]]>");this.children.push(r);return this};e.prototype.comment=function(t){var r;if(!(t!=null)){throw new Error("Missing comment text")}t=""+t||"";t=this.escape(t);this.assertLegalChar(t);if(t.match(/--/)){throw new Error("Comment text cannot contain double-hypen: "+t)}r=new e(this,"",{},"<!-- "+t+" -->");this.children.push(r);return this};e.prototype.raw=function(t){var r;if(!(t!=null)){throw new Error("Missing raw text")}t=""+t||"";r=new e(this,"",{},t);this.children.push(r);return this};e.prototype.up=function(){if(this.isRoot){throw new Error("This node has no parent. Use doc() if you need to get the document object.")}return this.parent};e.prototype.root=function(){var e;if(this.isRoot){return this}e=this.parent;while(!e.isRoot){e=e.parent}return e};e.prototype.document=function(){return this.root().documentObject};e.prototype.end=function(e){return this.document().toString(e)};e.prototype.prev=function(){var e;if(this.isRoot){throw new Error("Root node has no siblings")}e=this.parent.children.indexOf(this);if(e<1){throw new Error("Already at the first node")}return this.parent.children[e-1]};e.prototype.next=function(){var e;if(this.isRoot){throw new Error("Root node has no siblings")}e=this.parent.children.indexOf(this);if(e===-1||e===this.parent.children.length-1){throw new Error("Already at the last node")}return this.parent.children[e+1]};e.prototype.clone=function(t){var r;r=new e(this.parent,this.name,this.attributes,this.value);if(t){this.children.forEach(function(e){var n;n=e.clone(t);n.parent=r;return r.children.push(n)})}return r};e.prototype.importXMLBuilder=function(e){var t;t=e.root().clone(true);t.parent=this;this.children.push(t);t.isRoot=false;return this};e.prototype.attribute=function(e,t){var r;if(!(e!=null)){throw new Error("Missing attribute name")}if(!(t!=null)){throw new Error("Missing attribute value")}e=""+e||"";t=""+t||"";if((r=this.attributes)==null){this.attributes={}}this.attributes[e]=this.escape(t);return this};e.prototype.removeAttribute=function(e){if(!(e!=null)){throw new Error("Missing attribute name")}e=""+e||"";delete this.attributes[e];return this};e.prototype.toString=function(e,t){var r,n,i,s,a,o,u,c,l,p,f,m;o=e!=null&&e.pretty||false;s=e!=null&&e.indent||" ";a=e!=null&&e.newline||"\n";t||(t=0);c=new Array(t+1).join(s);u="";if(o){u+=c}if(!(this.value!=null)){u+="<"+this.name}else{u+=""+this.value}f=this.attributes;for(r in f){n=f[r];if(this.name==="!DOCTYPE"){u+=" "+n}else{u+=" "+r+'="'+n+'"'}}if(this.children.length===0){if(!(this.value!=null)){u+=this.name==="?xml"?"?>":this.name==="!DOCTYPE"?">":"/>"}if(o){u+=a}}else if(o&&this.children.length===1&&this.children[0].value){u+=">";u+=this.children[0].value;u+="</"+this.name+">";u+=a}else{u+=">";if(o){u+=a}m=this.children;for(l=0,p=m.length;l<p;l++){i=m[l];u+=i.toString(e,t+1)}if(o){u+=c}u+="</"+this.name+">";if(o){u+=a}}return u};e.prototype.escape=function(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")};e.prototype.assertLegalChar=function(e){var t,r;t=/[---̆Ä-ÌøøÔøæ-Ôøø]/;r=e.match(t);if(r){throw new Error("Invalid character ("+r+") in string: "+e)}};e.prototype.is=function(e,t){var r;r=Object.prototype.toString.call(e).slice(8,-1);return e!=null&&r===t};e.prototype.ele=function(e,t,r){return this.element(e,t,r)};e.prototype.txt=function(e){return this.text(e)};e.prototype.dat=function(e){return this.cdata(e)};e.prototype.att=function(e,t){return this.attribute(e,t)};e.prototype.com=function(e){return this.comment(e)};e.prototype.doc=function(){return this.document()};e.prototype.e=function(e,t,r){return this.element(e,t,r)};e.prototype.t=function(e){return this.text(e)};e.prototype.d=function(e){return this.cdata(e)};e.prototype.a=function(e,t){return this.attribute(e,t)};e.prototype.c=function(e){return this.comment(e)};e.prototype.r=function(e){return this.raw(e)};e.prototype.u=function(){return this.up()};return e}();t.exports=e}).call(this)},{}],72:[function(e,t,r){(function(){var r;r=e("./XMLBuilder");t.exports.create=function(e,t,n){if(e!=null){return new r(e,t,n).root()}else{return new r}}}).call(this)},{"./XMLBuilder":70}]},{},[31]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment