From 2925a7260b702ff17315a06fb3764259a163c8a1 Mon Sep 17 00:00:00 2001 From: Landon Grindheim Date: Mon, 31 Jan 2022 15:20:32 +0000 Subject: [PATCH] Bump dockerode --- dist/cleanup/index.js | 297 ++++++++++++++++++++++++++++---------- dist/cleanup/index.js.map | 2 +- dist/main/index.js | 297 ++++++++++++++++++++++++++++---------- dist/main/index.js.map | 2 +- package-lock.json | 12 +- package.json | 2 +- 6 files changed, 453 insertions(+), 159 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 273220b17..93c782f85 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -4020,15 +4020,19 @@ Config.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return /** * Inspect + * + * @param {Object} opts Options (optional) * @param {Function} callback Callback, if specified Docker will be queried. * @return {Object} Name only if callback isn't specified. */ -Config.prototype.inspect = function(callback) { +Config.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/configs/' + this.id, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'config not found', @@ -4037,7 +4041,7 @@ Config.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -4048,7 +4052,7 @@ Config.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -4061,23 +4065,22 @@ Config.prototype.inspect = function(callback) { */ Config.prototype.update = function(opts, callback) { var self = this; - if (!callback && typeof opts === 'function') { - callback = opts; - } + var args = util.processArgs(opts, callback); var optsf = { path: '/configs/' + this.id + '/update?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'config not found', 500: 'server error', 503: 'node is not part of a swarm' }, - options: opts + options: args.opts }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -4088,7 +4091,7 @@ Config.prototype.update = function(opts, callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -4106,6 +4109,7 @@ Config.prototype.remove = function(opts, callback) { var optsf = { path: '/configs/' + this.id, method: 'DELETE', + abortSignal: opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -4196,6 +4200,7 @@ Container.prototype.inspect = function(opts, callback) { path: '/containers/' + this.id + '/json?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such container', @@ -4231,6 +4236,7 @@ Container.prototype.rename = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/rename?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -4268,6 +4274,7 @@ Container.prototype.update = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/update', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -4306,6 +4313,7 @@ Container.prototype.top = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/top?', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such container', @@ -4332,13 +4340,17 @@ Container.prototype.top = function(opts, callback) { /** * Containers changes + * @param {Object} Options * @param {Function} callback Callback */ -Container.prototype.changes = function(callback) { +Container.prototype.changes = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/containers/' + this.id + '/changes', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such container', @@ -4346,7 +4358,7 @@ Container.prototype.changes = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -4357,7 +4369,7 @@ Container.prototype.changes = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -4374,6 +4386,7 @@ Container.prototype.listCheckpoint = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/checkpoints?', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such container', @@ -4411,6 +4424,7 @@ Container.prototype.deleteCheckpoint = function(checkpoint, opts, callback) { var optsf = { path: '/containers/' + this.id + '/checkpoints/' + checkpoint + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -4448,6 +4462,7 @@ Container.prototype.createCheckpoint = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/checkpoints', method: 'POST', + abortSignal: args.opts.abortSignal, allowEmpty: true, statusCodes: { 200: true, //unofficial, but proxies may return it @@ -4477,13 +4492,17 @@ Container.prototype.createCheckpoint = function(opts, callback) { /** * Export + * @param {Object} opts Options (optional) * @param {Function} callback Callback with the octet-stream. */ -Container.prototype.export = function(callback) { +Container.prototype.export = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/containers/' + this.id + '/export', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -4492,7 +4511,7 @@ Container.prototype.export = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -4503,7 +4522,7 @@ Container.prototype.export = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -4520,6 +4539,7 @@ Container.prototype.start = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/start?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -4558,6 +4578,7 @@ Container.prototype.pause = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/pause', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -4594,6 +4615,7 @@ Container.prototype.unpause = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/unpause', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -4632,6 +4654,7 @@ Container.prototype.exec = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/exec', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -4674,6 +4697,7 @@ Container.prototype.commit = function(opts, callback) { var optsf = { path: '/commit?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -4711,6 +4735,7 @@ Container.prototype.stop = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/stop?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -4749,6 +4774,7 @@ Container.prototype.restart = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/restart?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -4786,6 +4812,7 @@ Container.prototype.kill = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/kill?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -4823,6 +4850,7 @@ Container.prototype.resize = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/resize?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -4860,6 +4888,7 @@ Container.prototype.attach = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/attach?', method: 'POST', + abortSignal: args.opts.abortSignal, isStream: true, hijack: args.opts.hijack, openStdin: args.opts.stdin, @@ -4899,6 +4928,7 @@ Container.prototype.wait = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/wait?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -4936,6 +4966,7 @@ Container.prototype.remove = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -4975,6 +5006,7 @@ Container.prototype.copy = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/copy', method: 'POST', + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -5012,6 +5044,7 @@ Container.prototype.getArchive = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/archive?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -5050,6 +5083,7 @@ Container.prototype.infoArchive = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/archive?', method: 'HEAD', + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -5089,6 +5123,7 @@ Container.prototype.putArchive = function(file, opts, callback) { path: '/containers/' + this.id + '/archive?', method: 'PUT', file: file, + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -5128,6 +5163,7 @@ Container.prototype.logs = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/logs?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: args.opts.follow || false, statusCodes: { 200: true, @@ -5168,6 +5204,7 @@ Container.prototype.stats = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/stats?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: isStream, statusCodes: { 200: true, @@ -5248,6 +5285,7 @@ Docker.prototype.createContainer = function(opts, callback) { method: 'POST', options: opts, authconfig: opts.authconfig, + abortSignal: opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -5298,6 +5336,7 @@ Docker.prototype.createImage = function(auth, opts, callback) { method: 'POST', options: opts, authconfig: auth, + abortSignal: opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -5339,6 +5378,7 @@ Docker.prototype.loadImage = function(file, opts, callback) { method: 'POST', options: opts, file: file, + abortSignal: opts && opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -5374,7 +5414,7 @@ Docker.prototype.importImage = function(file, opts, callback) { callback = opts; opts = undefined; } - + if (!opts) opts = {}; @@ -5385,6 +5425,7 @@ Docker.prototype.importImage = function(file, opts, callback) { method: 'POST', options: opts, file: file, + abortSignal: opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -5419,6 +5460,7 @@ Docker.prototype.checkAuth = function(opts, callback) { path: '/auth', method: 'POST', options: opts, + abortSignal: opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -5450,7 +5492,6 @@ Docker.prototype.checkAuth = function(opts, callback) { */ Docker.prototype.buildImage = function(file, opts, callback) { var self = this; - var content; if (!callback && typeof opts === 'function') { callback = opts; @@ -5463,6 +5504,7 @@ Docker.prototype.buildImage = function(file, opts, callback) { method: 'POST', file: file, options: opts, + abortSignal: opts && opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -5610,6 +5652,7 @@ Docker.prototype.listContainers = function(opts, callback) { path: '/containers/json?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -5646,6 +5689,7 @@ Docker.prototype.listImages = function(opts, callback) { path: '/images/json?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -5682,6 +5726,7 @@ Docker.prototype.getImages = function(opts, callback) { path: '/images/get?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -5719,6 +5764,7 @@ Docker.prototype.listServices = function(opts, callback) { path: '/services?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -5754,6 +5800,7 @@ Docker.prototype.listNodes = function(opts, callback) { path: '/nodes?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -5792,6 +5839,7 @@ Docker.prototype.listTasks = function(opts, callback) { path: '/tasks?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -5826,6 +5874,7 @@ Docker.prototype.createSecret = function(opts, callback) { path: '/secrets/create?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -5866,6 +5915,7 @@ Docker.prototype.createConfig = function(opts, callback) { path: '/configs/create?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -5907,6 +5957,7 @@ Docker.prototype.listSecrets = function(opts, callback) { path: '/secrets?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -5942,6 +5993,7 @@ Docker.prototype.listConfigs = function(opts, callback) { path: '/configs?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -5976,6 +6028,7 @@ Docker.prototype.createPlugin = function(opts, callback) { path: '/plugins/create?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -6015,6 +6068,7 @@ Docker.prototype.listPlugins = function(opts, callback) { path: '/plugins?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -6050,6 +6104,7 @@ Docker.prototype.pruneImages = function(opts, callback) { path: '/images/prune?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -6074,21 +6129,24 @@ Docker.prototype.pruneImages = function(opts, callback) { /** * Prune builder + * @param {Object} opts Options (optional) * @param {Function} callback Callback */ -Docker.prototype.pruneBuilder = function(callback) { +Docker.prototype.pruneBuilder = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/build/prune', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -6099,7 +6157,7 @@ Docker.prototype.pruneBuilder = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -6117,6 +6175,7 @@ Docker.prototype.pruneContainers = function(opts, callback) { path: '/containers/prune?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -6152,6 +6211,7 @@ Docker.prototype.pruneVolumes = function(opts, callback) { path: '/volumes/prune?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -6187,6 +6247,7 @@ Docker.prototype.pruneNetworks = function(opts, callback) { path: '/networks/prune?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -6223,6 +6284,7 @@ Docker.prototype.createVolume = function(opts, callback) { method: 'POST', allowEmpty: true, options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -6270,6 +6332,7 @@ Docker.prototype.createService = function(auth, opts, callback) { method: 'POST', options: opts, authconfig: auth, + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 201: true, @@ -6308,6 +6371,7 @@ Docker.prototype.listVolumes = function(opts, callback) { path: '/volumes?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -6343,6 +6407,7 @@ Docker.prototype.createNetwork = function(opts, callback) { path: '/networks/create?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -6382,6 +6447,7 @@ Docker.prototype.listNetworks = function(opts, callback) { path: '/networks?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -6417,6 +6483,7 @@ Docker.prototype.searchImages = function(opts, callback) { method: 'GET', options: opts, authconfig: opts.authconfig, + abortSignal: opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -6441,13 +6508,17 @@ Docker.prototype.searchImages = function(opts, callback) { /** * Info - * @param {Function} callback Callback with info + * @param {Object} opts Options (optional) + * @param {Function} callback Callback with info */ -Docker.prototype.info = function(callback) { +Docker.prototype.info = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var opts = { path: '/info', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -6455,7 +6526,7 @@ Docker.prototype.info = function(callback) { }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(opts, function(err, data) { if (err) { @@ -6466,27 +6537,31 @@ Docker.prototype.info = function(callback) { }); } else { this.modem.dial(opts, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; /** * Version - * @param {Function} callback Callback + * @param {Object} opts Options (optional) + * @param {Function} callback Callback */ -Docker.prototype.version = function(callback) { +Docker.prototype.version = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var opts = { path: '/version', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(opts, function(err, data) { if (err) { @@ -6497,27 +6572,31 @@ Docker.prototype.version = function(callback) { }); } else { this.modem.dial(opts, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; /** * Ping - * @param {Function} callback Callback + * @param {Object} opts Options (optional) + * @param {Function} callback Callback */ -Docker.prototype.ping = function(callback) { +Docker.prototype.ping = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/_ping', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -6528,7 +6607,7 @@ Docker.prototype.ping = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -6536,20 +6615,24 @@ Docker.prototype.ping = function(callback) { /** * SystemDf equivalent to system/df API Engine * get usage data information - * @param {Function} callback Callback + * @param {Object} opts Options (optional) + * @param {Function} callback Callback */ -Docker.prototype.df = function(callback) { +Docker.prototype.df = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/system/df', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -6560,7 +6643,7 @@ Docker.prototype.df = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -6578,6 +6661,7 @@ Docker.prototype.getEvents = function(opts, callback) { path: '/events?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -6799,6 +6883,7 @@ Docker.prototype.swarmInit = function(opts, callback) { var optsf = { path: '/swarm/init', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -6836,6 +6921,7 @@ Docker.prototype.swarmJoin = function(opts, callback) { var optsf = { path: '/swarm/join', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -6873,6 +6959,7 @@ Docker.prototype.swarmLeave = function(opts, callback) { var optsf = { path: '/swarm/leave?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 406: 'node is not part of a Swarm' @@ -6909,6 +6996,7 @@ Docker.prototype.swarmUpdate = function(opts, callback) { var optsf = { path: '/swarm/update?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -6938,13 +7026,17 @@ Docker.prototype.swarmUpdate = function(opts, callback) { * Inspect a Swarm. * Warning: This method is not documented in the API * - * @param {Function} callback Callback + * @param {Object} opts Options (optional) + * @param {Function} callback Callback */ -Docker.prototype.swarmInspect = function(callback) { +Docker.prototype.swarmInspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/swarm', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 406: 'This node is not a swarm manager', @@ -6952,7 +7044,7 @@ Docker.prototype.swarmInspect = function(callback) { } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -6963,7 +7055,7 @@ Docker.prototype.swarmInspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -7014,6 +7106,7 @@ Exec.prototype.start = function(opts, callback) { var optsf = { path: '/exec/' + this.id + '/start', method: 'POST', + abortSignal: args.opts.abortSignal, isStream: true, allowEmpty: true, hijack: args.opts.hijack, @@ -7059,6 +7152,7 @@ Exec.prototype.resize = function(opts, callback) { var optsf = { path: '/exec/' + this.id + '/resize?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such exec', @@ -7087,14 +7181,17 @@ Exec.prototype.resize = function(opts, callback) { /** * Get low-level information about the exec call. * + * @param {Object} opts Options (optional) * @param {function} callback */ -Exec.prototype.inspect = function(callback) { +Exec.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/exec/' + this.id + '/json', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such exec', @@ -7102,7 +7199,7 @@ Exec.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -7114,7 +7211,7 @@ Exec.prototype.inspect = function(callback) { } else { this.modem.dial(optsf, function(err, data) { if (err) return callback(err, data); - callback(err, data); + args.callback(err, data); }); } }; @@ -7299,6 +7396,7 @@ Image.prototype.push = function(opts, callback, auth) { method: 'POST', options: args.opts, authconfig: args.opts.authconfig || auth, + abortSignal: args.opts.abortSignal, isStream: isStream, statusCodes: { 200: true, @@ -7336,6 +7434,7 @@ Image.prototype.tag = function(opts, callback) { path: '/images/' + this.name + '/tag?', method: 'POST', options: opts, + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -7371,10 +7470,10 @@ Image.prototype.remove = function(opts, callback) { var self = this; var args = util.processArgs(opts, callback); - var optsf = { path: '/images/' + this.name + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such image', @@ -7471,6 +7570,7 @@ Network.prototype.remove = function(opts, callback) { var optsf = { path: '/networks/' + this.id, method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -7510,6 +7610,7 @@ Network.prototype.connect = function(opts, callback) { var optsf = { path: '/networks/' + this.id + '/connect', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 201: true, @@ -7548,6 +7649,7 @@ Network.prototype.disconnect = function(opts, callback) { var optsf = { path: '/networks/' + this.id + '/disconnect', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 201: true, @@ -7601,14 +7703,17 @@ Node.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return t /** * Query Docker for Node details. * + * @param {Object} opts Options (optional) * @param {function} callback */ -Node.prototype.inspect = function(callback) { +Node.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/nodes/' + this.id, method: 'GET', + abortSignal: args.abortSignal, statusCodes: { 200: true, 404: 'no such node', @@ -7616,7 +7721,7 @@ Node.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -7627,7 +7732,7 @@ Node.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -7648,6 +7753,7 @@ Node.prototype.update = function(opts, callback) { var optsf = { path: '/nodes/' + this.id + '/update?', method: 'POST', + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 404: 'no such node', @@ -7688,6 +7794,7 @@ Node.prototype.remove = function(opts, callback) { var optsf = { path: '/nodes/' + this.id + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such node', @@ -7738,15 +7845,19 @@ Plugin.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return /** * Inspect + * + * @param {Object} opts Options (optional) * @param {Function} callback Callback, if specified Docker will be queried. * @return {Object} Name only if callback isn't specified. */ -Plugin.prototype.inspect = function(callback) { +Plugin.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/plugins/' + this.name, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'plugin is not installed', @@ -7754,7 +7865,7 @@ Plugin.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -7765,7 +7876,7 @@ Plugin.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -7782,6 +7893,7 @@ Plugin.prototype.remove = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'plugin is not installed', @@ -7809,24 +7921,28 @@ Plugin.prototype.remove = function(opts, callback) { /** * get privileges + * @param {Object} opts Options (optional) * @param {Function} callback Callback * @return {Object} Name only if callback isn't specified. */ -Plugin.prototype.privileges = function(callback) { +Plugin.prototype.privileges = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/plugins/privileges?', method: 'GET', options: { 'remote': this.remote }, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -7837,7 +7953,7 @@ Plugin.prototype.privileges = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -7862,6 +7978,7 @@ Plugin.prototype.pull = function(opts, callback) { var optsf = { path: '/plugins/pull?', method: 'POST', + abortSignal: args.opts.abortSignal, isStream: true, options: args.opts, statusCodes: { @@ -7900,6 +8017,7 @@ Plugin.prototype.enable = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '/enable?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -7935,6 +8053,7 @@ Plugin.prototype.disable = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '/disable', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -7970,6 +8089,7 @@ Plugin.prototype.push = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '/push', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'plugin not installed', @@ -8006,6 +8126,7 @@ Plugin.prototype.configure = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '/set', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'plugin not installed', @@ -8049,6 +8170,7 @@ Plugin.prototype.upgrade = function(auth, opts, callback) { var optsf = { path: '/plugins/' + this.name + '/upgrade?', method: 'POST', + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -8100,15 +8222,18 @@ Secret.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return /** * Inspect + * @param {Object} opts Options (optional) * @param {Function} callback Callback, if specified Docker will be queried. * @return {Object} Name only if callback isn't specified. */ -Secret.prototype.inspect = function(callback) { +Secret.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/secrets/' + this.id, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'secret not found', @@ -8117,7 +8242,7 @@ Secret.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -8128,7 +8253,7 @@ Secret.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -8148,6 +8273,7 @@ Secret.prototype.update = function(opts, callback) { var optsf = { path: '/secrets/' + this.id + '/update?', method: 'POST', + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 404: 'secret not found', @@ -8185,6 +8311,7 @@ Secret.prototype.remove = function(opts, callback) { var optsf = { path: '/secrets/' + this.id, method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -8237,14 +8364,17 @@ Service.prototype[__nccwpck_require__(1669).inspect.custom] = function() { retur /** * Query Docker for service details. * + * @param {Object} opts Options (optional) * @param {function} callback */ -Service.prototype.inspect = function(callback) { +Service.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/services/' + this.id, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such service', @@ -8252,7 +8382,7 @@ Service.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -8263,7 +8393,7 @@ Service.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -8271,14 +8401,17 @@ Service.prototype.inspect = function(callback) { /** * Delete Service * + * @param {Object} opts Options (optional) * @param {function} callback */ -Service.prototype.remove = function(callback) { +Service.prototype.remove = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/services/' + this.id, method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -8287,7 +8420,7 @@ Service.prototype.remove = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -8298,7 +8431,7 @@ Service.prototype.remove = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -8327,6 +8460,7 @@ Service.prototype.update = function(auth, opts, callback) { var optsf = { path: '/services/' + this.id + '/update?', method: 'POST', + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 404: 'no such service', @@ -8366,6 +8500,7 @@ Service.prototype.logs = function(opts, callback) { var optsf = { path: '/services/' + this.id + '/logs?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: args.opts.follow || false, statusCodes: { 200: true, @@ -8423,14 +8558,17 @@ Task.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return t /** * Query Docker for Task details. * + * @param {Object} opts Options (optional) * @param {function} callback */ -Task.prototype.inspect = function(callback) { +Task.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/tasks/' + this.id, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'unknown task', @@ -8438,7 +8576,7 @@ Task.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -8449,7 +8587,7 @@ Task.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -8466,6 +8604,7 @@ Task.prototype.logs = function(opts, callback) { var optsf = { path: '/tasks/' + this.id + '/logs?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: args.opts.follow || false, statusCodes: { 101: true, @@ -8595,15 +8734,18 @@ Volume.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return /** * Inspect + * @param {Object} opts Options (optional) * @param {Function} callback Callback, if specified Docker will be queried. * @return {Object} Name only if callback isn't specified. */ -Volume.prototype.inspect = function(callback) { +Volume.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/volumes/' + this.name, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such volume', @@ -8611,7 +8753,7 @@ Volume.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -8622,7 +8764,7 @@ Volume.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -8639,6 +8781,7 @@ Volume.prototype.remove = function(opts, callback) { var optsf = { path: '/volumes/' + this.name, method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 204: true, 404: 'no such volume', @@ -12848,6 +12991,7 @@ class Channel extends DuplexStream { destroy() { this.end(); this.close(); + return this; } // Session type-specific methods ============================================= @@ -20910,14 +21054,13 @@ const CLIENT_HANDLERS = { */ const errorCode = bufferParser.readUInt32BE(); const errorMsg = bufferParser.readString(true); - const lang = bufferParser.skipString(); bufferParser.clear(); - if (lang === undefined) { - if (reqID !== undefined) - delete sftp._requests[reqID]; - return doFatalSFTPError(sftp, 'Malformed STATUS packet'); - } + // Note: we avoid checking that the error message and language tag are in + // the packet because there are some broken implementations that incorrectly + // omit them. The language tag in general was never really used amongst ssh + // implementations, so in the case of a missing error message we just + // default to something sensible. if (sftp._debug) { const jsonMsg = JSON.stringify(errorMsg); @@ -22208,6 +22351,8 @@ const SUPPORTED_CIPHER = DEFAULT_CIPHER.concat([ 'aes128-cbc', 'blowfish-cbc', '3des-cbc', + 'aes128-gcm', + 'aes256-gcm', // http://tools.ietf.org/html/rfc4345#section-4: 'arcfour256', @@ -27790,6 +27935,8 @@ OpenSSH_Private.prototype = BaseKey; } else { ret = []; } + if (ret instanceof Error) + return ret; // This will need to change if/when OpenSSH ever starts storing multiple // keys in their key files return ret[0]; @@ -35382,7 +35529,7 @@ module.exports = require(__nccwpck_require__.ab + "lib/protocol/crypto/build/Rel /***/ ((module) => { "use strict"; -module.exports = {"i8":"1.5.0"}; +module.exports = {"i8":"1.6.0"}; /***/ }), diff --git a/dist/cleanup/index.js.map b/dist/cleanup/index.js.map index 96a9409c6..369498094 100644 --- a/dist/cleanup/index.js.map +++ b/dist/cleanup/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/command.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/core.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/file-command.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/errors.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/index.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/reader.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/types.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/writer.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/index.js","../webpack://dependabot-updater-action/./node_modules/bcrypt-pbkdf/index.js","../webpack://dependabot-updater-action/./node_modules/bl/BufferList.js","../webpack://dependabot-updater-action/./node_modules/bl/bl.js","../webpack://dependabot-updater-action/./node_modules/chownr/chownr.js","../webpack://dependabot-updater-action/./node_modules/cpu-features/lib/index.js","../webpack://dependabot-updater-action/./node_modules/debug/src/browser.js","../webpack://dependabot-updater-action/./node_modules/debug/src/common.js","../webpack://dependabot-updater-action/./node_modules/debug/src/index.js","../webpack://dependabot-updater-action/./node_modules/debug/src/node.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/http.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/http_duplex.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/modem.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/ssh.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/config.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/container.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/docker.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/exec.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/image.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/network.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/node.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/plugin.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/secret.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/service.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/task.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/util.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/volume.js","../webpack://dependabot-updater-action/./node_modules/end-of-stream/index.js","../webpack://dependabot-updater-action/./node_modules/fs-constants/index.js","../webpack://dependabot-updater-action/./node_modules/has-flag/index.js","../webpack://dependabot-updater-action/./node_modules/inherits/inherits.js","../webpack://dependabot-updater-action/./node_modules/inherits/inherits_browser.js","../webpack://dependabot-updater-action/./node_modules/mkdirp-classic/index.js","../webpack://dependabot-updater-action/./node_modules/ms/index.js","../webpack://dependabot-updater-action/./node_modules/once/once.js","../webpack://dependabot-updater-action/./node_modules/pump/index.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/errors.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_duplex.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_passthrough.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_readable.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_transform.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_writable.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/async_iterator.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/buffer_list.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/destroy.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/end-of-stream.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/from.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/pipeline.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/state.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/stream.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/readable.js","../webpack://dependabot-updater-action/./node_modules/safer-buffer/safer.js","../webpack://dependabot-updater-action/./node_modules/split-ca/index.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/Channel.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/agent.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/client.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/http-agents.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/index.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/Protocol.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/SFTP.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/constants.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto/poly1305.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/handlers.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/handlers.misc.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/kex.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/keyParser.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/node-fs-compat.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/utils.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/zlib.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/server.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/string_decoder/lib/string_decoder.js","../webpack://dependabot-updater-action/./node_modules/string_decoder/node_modules/safe-buffer/index.js","../webpack://dependabot-updater-action/./node_modules/supports-color/index.js","../webpack://dependabot-updater-action/./node_modules/tar-fs/index.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/extract.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/headers.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/index.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/pack.js","../webpack://dependabot-updater-action/./node_modules/tweetnacl/nacl-fast.js","../webpack://dependabot-updater-action/./node_modules/util-deprecate/node.js","../webpack://dependabot-updater-action/./node_modules/wrappy/wrappy.js","../webpack://dependabot-updater-action/./src/cleanup.ts","../webpack://dependabot-updater-action/./node_modules/cpu-features/build/Release/cpufeatures.node","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node","../webpack://dependabot-updater-action/external \"assert\"","../webpack://dependabot-updater-action/external \"buffer\"","../webpack://dependabot-updater-action/external \"child_process\"","../webpack://dependabot-updater-action/external \"constants\"","../webpack://dependabot-updater-action/external \"crypto\"","../webpack://dependabot-updater-action/external \"dns\"","../webpack://dependabot-updater-action/external \"events\"","../webpack://dependabot-updater-action/external \"fs\"","../webpack://dependabot-updater-action/external \"http\"","../webpack://dependabot-updater-action/external \"https\"","../webpack://dependabot-updater-action/external \"net\"","../webpack://dependabot-updater-action/external \"os\"","../webpack://dependabot-updater-action/external \"path\"","../webpack://dependabot-updater-action/external \"querystring\"","../webpack://dependabot-updater-action/external \"stream\"","../webpack://dependabot-updater-action/external \"string_decoder\"","../webpack://dependabot-updater-action/external \"tls\"","../webpack://dependabot-updater-action/external \"tty\"","../webpack://dependabot-updater-action/external \"url\"","../webpack://dependabot-updater-action/external \"util\"","../webpack://dependabot-updater-action/external \"zlib\"","../webpack://dependabot-updater-action/webpack/bootstrap","../webpack://dependabot-updater-action/webpack/runtime/compat","../webpack://dependabot-updater-action/webpack/startup"],"sourcesContent":["\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.issue = exports.issueCommand = void 0;\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\n/**\n * Commands\n *\n * Command Format:\n * ::name key=value,key=value::message\n *\n * Examples:\n * ::warning::This is the message\n * ::set-env name=MY_VAR::some value\n */\nfunction issueCommand(command, properties, message) {\n const cmd = new Command(command, properties, message);\n process.stdout.write(cmd.toString() + os.EOL);\n}\nexports.issueCommand = issueCommand;\nfunction issue(name, message = '') {\n issueCommand(name, {}, message);\n}\nexports.issue = issue;\nconst CMD_STRING = '::';\nclass Command {\n constructor(command, properties, message) {\n if (!command) {\n command = 'missing.command';\n }\n this.command = command;\n this.properties = properties;\n this.message = message;\n }\n toString() {\n let cmdStr = CMD_STRING + this.command;\n if (this.properties && Object.keys(this.properties).length > 0) {\n cmdStr += ' ';\n let first = true;\n for (const key in this.properties) {\n if (this.properties.hasOwnProperty(key)) {\n const val = this.properties[key];\n if (val) {\n if (first) {\n first = false;\n }\n else {\n cmdStr += ',';\n }\n cmdStr += `${key}=${escapeProperty(val)}`;\n }\n }\n }\n }\n cmdStr += `${CMD_STRING}${escapeData(this.message)}`;\n return cmdStr;\n }\n}\nfunction escapeData(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A');\n}\nfunction escapeProperty(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A')\n .replace(/:/g, '%3A')\n .replace(/,/g, '%2C');\n}\n//# sourceMappingURL=command.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;\nconst command_1 = require(\"./command\");\nconst file_command_1 = require(\"./file-command\");\nconst utils_1 = require(\"./utils\");\nconst os = __importStar(require(\"os\"));\nconst path = __importStar(require(\"path\"));\n/**\n * The code to exit an action\n */\nvar ExitCode;\n(function (ExitCode) {\n /**\n * A code indicating that the action was successful\n */\n ExitCode[ExitCode[\"Success\"] = 0] = \"Success\";\n /**\n * A code indicating that the action was a failure\n */\n ExitCode[ExitCode[\"Failure\"] = 1] = \"Failure\";\n})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));\n//-----------------------------------------------------------------------\n// Variables\n//-----------------------------------------------------------------------\n/**\n * Sets env variable for this action and future actions in the job\n * @param name the name of the variable to set\n * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction exportVariable(name, val) {\n const convertedVal = utils_1.toCommandValue(val);\n process.env[name] = convertedVal;\n const filePath = process.env['GITHUB_ENV'] || '';\n if (filePath) {\n const delimiter = '_GitHubActionsFileCommandDelimeter_';\n const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;\n file_command_1.issueCommand('ENV', commandValue);\n }\n else {\n command_1.issueCommand('set-env', { name }, convertedVal);\n }\n}\nexports.exportVariable = exportVariable;\n/**\n * Registers a secret which will get masked from logs\n * @param secret value of the secret\n */\nfunction setSecret(secret) {\n command_1.issueCommand('add-mask', {}, secret);\n}\nexports.setSecret = setSecret;\n/**\n * Prepends inputPath to the PATH (for this action and future actions)\n * @param inputPath\n */\nfunction addPath(inputPath) {\n const filePath = process.env['GITHUB_PATH'] || '';\n if (filePath) {\n file_command_1.issueCommand('PATH', inputPath);\n }\n else {\n command_1.issueCommand('add-path', {}, inputPath);\n }\n process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;\n}\nexports.addPath = addPath;\n/**\n * Gets the value of an input.\n * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.\n * Returns an empty string if the value is not defined.\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns string\n */\nfunction getInput(name, options) {\n const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';\n if (options && options.required && !val) {\n throw new Error(`Input required and not supplied: ${name}`);\n }\n if (options && options.trimWhitespace === false) {\n return val;\n }\n return val.trim();\n}\nexports.getInput = getInput;\n/**\n * Gets the values of an multiline input. Each value is also trimmed.\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns string[]\n *\n */\nfunction getMultilineInput(name, options) {\n const inputs = getInput(name, options)\n .split('\\n')\n .filter(x => x !== '');\n return inputs;\n}\nexports.getMultilineInput = getMultilineInput;\n/**\n * Gets the input value of the boolean type in the YAML 1.2 \"core schema\" specification.\n * Support boolean input list: `true | True | TRUE | false | False | FALSE` .\n * The return value is also in boolean type.\n * ref: https://yaml.org/spec/1.2/spec.html#id2804923\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns boolean\n */\nfunction getBooleanInput(name, options) {\n const trueValue = ['true', 'True', 'TRUE'];\n const falseValue = ['false', 'False', 'FALSE'];\n const val = getInput(name, options);\n if (trueValue.includes(val))\n return true;\n if (falseValue.includes(val))\n return false;\n throw new TypeError(`Input does not meet YAML 1.2 \"Core Schema\" specification: ${name}\\n` +\n `Support boolean input list: \\`true | True | TRUE | false | False | FALSE\\``);\n}\nexports.getBooleanInput = getBooleanInput;\n/**\n * Sets the value of an output.\n *\n * @param name name of the output to set\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction setOutput(name, value) {\n process.stdout.write(os.EOL);\n command_1.issueCommand('set-output', { name }, value);\n}\nexports.setOutput = setOutput;\n/**\n * Enables or disables the echoing of commands into stdout for the rest of the step.\n * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.\n *\n */\nfunction setCommandEcho(enabled) {\n command_1.issue('echo', enabled ? 'on' : 'off');\n}\nexports.setCommandEcho = setCommandEcho;\n//-----------------------------------------------------------------------\n// Results\n//-----------------------------------------------------------------------\n/**\n * Sets the action status to failed.\n * When the action exits it will be with an exit code of 1\n * @param message add error issue message\n */\nfunction setFailed(message) {\n process.exitCode = ExitCode.Failure;\n error(message);\n}\nexports.setFailed = setFailed;\n//-----------------------------------------------------------------------\n// Logging Commands\n//-----------------------------------------------------------------------\n/**\n * Gets whether Actions Step Debug is on or not\n */\nfunction isDebug() {\n return process.env['RUNNER_DEBUG'] === '1';\n}\nexports.isDebug = isDebug;\n/**\n * Writes debug message to user log\n * @param message debug message\n */\nfunction debug(message) {\n command_1.issueCommand('debug', {}, message);\n}\nexports.debug = debug;\n/**\n * Adds an error issue\n * @param message error issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction error(message, properties = {}) {\n command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.error = error;\n/**\n * Adds a warning issue\n * @param message warning issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction warning(message, properties = {}) {\n command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.warning = warning;\n/**\n * Adds a notice issue\n * @param message notice issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction notice(message, properties = {}) {\n command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.notice = notice;\n/**\n * Writes info to log with console.log.\n * @param message info message\n */\nfunction info(message) {\n process.stdout.write(message + os.EOL);\n}\nexports.info = info;\n/**\n * Begin an output group.\n *\n * Output until the next `groupEnd` will be foldable in this group\n *\n * @param name The name of the output group\n */\nfunction startGroup(name) {\n command_1.issue('group', name);\n}\nexports.startGroup = startGroup;\n/**\n * End an output group.\n */\nfunction endGroup() {\n command_1.issue('endgroup');\n}\nexports.endGroup = endGroup;\n/**\n * Wrap an asynchronous function call in a group.\n *\n * Returns the same type as the function itself.\n *\n * @param name The name of the group\n * @param fn The function to wrap in the group\n */\nfunction group(name, fn) {\n return __awaiter(this, void 0, void 0, function* () {\n startGroup(name);\n let result;\n try {\n result = yield fn();\n }\n finally {\n endGroup();\n }\n return result;\n });\n}\nexports.group = group;\n//-----------------------------------------------------------------------\n// Wrapper action state\n//-----------------------------------------------------------------------\n/**\n * Saves state for current action, the state can only be retrieved by this action's post job execution.\n *\n * @param name name of the state to store\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction saveState(name, value) {\n command_1.issueCommand('save-state', { name }, value);\n}\nexports.saveState = saveState;\n/**\n * Gets the value of an state set by this action's main execution.\n *\n * @param name name of the state to get\n * @returns string\n */\nfunction getState(name) {\n return process.env[`STATE_${name}`] || '';\n}\nexports.getState = getState;\n//# sourceMappingURL=core.js.map","\"use strict\";\n// For internal use, subject to change.\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.issueCommand = void 0;\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst fs = __importStar(require(\"fs\"));\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\nfunction issueCommand(command, message) {\n const filePath = process.env[`GITHUB_${command}`];\n if (!filePath) {\n throw new Error(`Unable to find environment variable for file command ${command}`);\n }\n if (!fs.existsSync(filePath)) {\n throw new Error(`Missing file at path: ${filePath}`);\n }\n fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {\n encoding: 'utf8'\n });\n}\nexports.issueCommand = issueCommand;\n//# sourceMappingURL=file-command.js.map","\"use strict\";\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.toCommandProperties = exports.toCommandValue = void 0;\n/**\n * Sanitizes an input into a string so it can be passed into issueCommand safely\n * @param input input to sanitize into a string\n */\nfunction toCommandValue(input) {\n if (input === null || input === undefined) {\n return '';\n }\n else if (typeof input === 'string' || input instanceof String) {\n return input;\n }\n return JSON.stringify(input);\n}\nexports.toCommandValue = toCommandValue;\n/**\n *\n * @param annotationProperties\n * @returns The command properties to send with the actual annotation command\n * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646\n */\nfunction toCommandProperties(annotationProperties) {\n if (!Object.keys(annotationProperties).length) {\n return {};\n }\n return {\n title: annotationProperties.title,\n line: annotationProperties.startLine,\n endLine: annotationProperties.endLine,\n col: annotationProperties.startColumn,\n endColumn: annotationProperties.endColumn\n };\n}\nexports.toCommandProperties = toCommandProperties;\n//# sourceMappingURL=utils.js.map","// Copyright 2011 Mark Cavage All rights reserved.\n\n\nmodule.exports = {\n\n newInvalidAsn1Error: function (msg) {\n var e = new Error();\n e.name = 'InvalidAsn1Error';\n e.message = msg || '';\n return e;\n }\n\n};\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar errors = require('./errors');\nvar types = require('./types');\n\nvar Reader = require('./reader');\nvar Writer = require('./writer');\n\n\n// --- Exports\n\nmodule.exports = {\n\n Reader: Reader,\n\n Writer: Writer\n\n};\n\nfor (var t in types) {\n if (types.hasOwnProperty(t))\n module.exports[t] = types[t];\n}\nfor (var e in errors) {\n if (errors.hasOwnProperty(e))\n module.exports[e] = errors[e];\n}\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar assert = require('assert');\nvar Buffer = require('safer-buffer').Buffer;\n\nvar ASN1 = require('./types');\nvar errors = require('./errors');\n\n\n// --- Globals\n\nvar newInvalidAsn1Error = errors.newInvalidAsn1Error;\n\n\n\n// --- API\n\nfunction Reader(data) {\n if (!data || !Buffer.isBuffer(data))\n throw new TypeError('data must be a node Buffer');\n\n this._buf = data;\n this._size = data.length;\n\n // These hold the \"current\" state\n this._len = 0;\n this._offset = 0;\n}\n\nObject.defineProperty(Reader.prototype, 'length', {\n enumerable: true,\n get: function () { return (this._len); }\n});\n\nObject.defineProperty(Reader.prototype, 'offset', {\n enumerable: true,\n get: function () { return (this._offset); }\n});\n\nObject.defineProperty(Reader.prototype, 'remain', {\n get: function () { return (this._size - this._offset); }\n});\n\nObject.defineProperty(Reader.prototype, 'buffer', {\n get: function () { return (this._buf.slice(this._offset)); }\n});\n\n\n/**\n * Reads a single byte and advances offset; you can pass in `true` to make this\n * a \"peek\" operation (i.e., get the byte, but don't advance the offset).\n *\n * @param {Boolean} peek true means don't move offset.\n * @return {Number} the next byte, null if not enough data.\n */\nReader.prototype.readByte = function (peek) {\n if (this._size - this._offset < 1)\n return null;\n\n var b = this._buf[this._offset] & 0xff;\n\n if (!peek)\n this._offset += 1;\n\n return b;\n};\n\n\nReader.prototype.peek = function () {\n return this.readByte(true);\n};\n\n\n/**\n * Reads a (potentially) variable length off the BER buffer. This call is\n * not really meant to be called directly, as callers have to manipulate\n * the internal buffer afterwards.\n *\n * As a result of this call, you can call `Reader.length`, until the\n * next thing called that does a readLength.\n *\n * @return {Number} the amount of offset to advance the buffer.\n * @throws {InvalidAsn1Error} on bad ASN.1\n */\nReader.prototype.readLength = function (offset) {\n if (offset === undefined)\n offset = this._offset;\n\n if (offset >= this._size)\n return null;\n\n var lenB = this._buf[offset++] & 0xff;\n if (lenB === null)\n return null;\n\n if ((lenB & 0x80) === 0x80) {\n lenB &= 0x7f;\n\n if (lenB === 0)\n throw newInvalidAsn1Error('Indefinite length not supported');\n\n if (lenB > 4)\n throw newInvalidAsn1Error('encoding too long');\n\n if (this._size - offset < lenB)\n return null;\n\n this._len = 0;\n for (var i = 0; i < lenB; i++)\n this._len = (this._len << 8) + (this._buf[offset++] & 0xff);\n\n } else {\n // Wasn't a variable length\n this._len = lenB;\n }\n\n return offset;\n};\n\n\n/**\n * Parses the next sequence in this BER buffer.\n *\n * To get the length of the sequence, call `Reader.length`.\n *\n * @return {Number} the sequence's tag.\n */\nReader.prototype.readSequence = function (tag) {\n var seq = this.peek();\n if (seq === null)\n return null;\n if (tag !== undefined && tag !== seq)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + seq.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n if (o === null)\n return null;\n\n this._offset = o;\n return seq;\n};\n\n\nReader.prototype.readInt = function () {\n return this._readTag(ASN1.Integer);\n};\n\n\nReader.prototype.readBoolean = function () {\n return (this._readTag(ASN1.Boolean) === 0 ? false : true);\n};\n\n\nReader.prototype.readEnumeration = function () {\n return this._readTag(ASN1.Enumeration);\n};\n\n\nReader.prototype.readString = function (tag, retbuf) {\n if (!tag)\n tag = ASN1.OctetString;\n\n var b = this.peek();\n if (b === null)\n return null;\n\n if (b !== tag)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + b.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n\n if (o === null)\n return null;\n\n if (this.length > this._size - o)\n return null;\n\n this._offset = o;\n\n if (this.length === 0)\n return retbuf ? Buffer.alloc(0) : '';\n\n var str = this._buf.slice(this._offset, this._offset + this.length);\n this._offset += this.length;\n\n return retbuf ? str : str.toString('utf8');\n};\n\nReader.prototype.readOID = function (tag) {\n if (!tag)\n tag = ASN1.OID;\n\n var b = this.readString(tag, true);\n if (b === null)\n return null;\n\n var values = [];\n var value = 0;\n\n for (var i = 0; i < b.length; i++) {\n var byte = b[i] & 0xff;\n\n value <<= 7;\n value += byte & 0x7f;\n if ((byte & 0x80) === 0) {\n values.push(value);\n value = 0;\n }\n }\n\n value = values.shift();\n values.unshift(value % 40);\n values.unshift((value / 40) >> 0);\n\n return values.join('.');\n};\n\n\nReader.prototype._readTag = function (tag) {\n assert.ok(tag !== undefined);\n\n var b = this.peek();\n\n if (b === null)\n return null;\n\n if (b !== tag)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + b.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n if (o === null)\n return null;\n\n if (this.length > 4)\n throw newInvalidAsn1Error('Integer too long: ' + this.length);\n\n if (this.length > this._size - o)\n return null;\n this._offset = o;\n\n var fb = this._buf[this._offset];\n var value = 0;\n\n for (var i = 0; i < this.length; i++) {\n value <<= 8;\n value |= (this._buf[this._offset++] & 0xff);\n }\n\n if ((fb & 0x80) === 0x80 && i !== 4)\n value -= (1 << (i * 8));\n\n return value >> 0;\n};\n\n\n\n// --- Exported API\n\nmodule.exports = Reader;\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n\nmodule.exports = {\n EOC: 0,\n Boolean: 1,\n Integer: 2,\n BitString: 3,\n OctetString: 4,\n Null: 5,\n OID: 6,\n ObjectDescriptor: 7,\n External: 8,\n Real: 9, // float\n Enumeration: 10,\n PDV: 11,\n Utf8String: 12,\n RelativeOID: 13,\n Sequence: 16,\n Set: 17,\n NumericString: 18,\n PrintableString: 19,\n T61String: 20,\n VideotexString: 21,\n IA5String: 22,\n UTCTime: 23,\n GeneralizedTime: 24,\n GraphicString: 25,\n VisibleString: 26,\n GeneralString: 28,\n UniversalString: 29,\n CharacterString: 30,\n BMPString: 31,\n Constructor: 32,\n Context: 128\n};\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar assert = require('assert');\nvar Buffer = require('safer-buffer').Buffer;\nvar ASN1 = require('./types');\nvar errors = require('./errors');\n\n\n// --- Globals\n\nvar newInvalidAsn1Error = errors.newInvalidAsn1Error;\n\nvar DEFAULT_OPTS = {\n size: 1024,\n growthFactor: 8\n};\n\n\n// --- Helpers\n\nfunction merge(from, to) {\n assert.ok(from);\n assert.equal(typeof (from), 'object');\n assert.ok(to);\n assert.equal(typeof (to), 'object');\n\n var keys = Object.getOwnPropertyNames(from);\n keys.forEach(function (key) {\n if (to[key])\n return;\n\n var value = Object.getOwnPropertyDescriptor(from, key);\n Object.defineProperty(to, key, value);\n });\n\n return to;\n}\n\n\n\n// --- API\n\nfunction Writer(options) {\n options = merge(DEFAULT_OPTS, options || {});\n\n this._buf = Buffer.alloc(options.size || 1024);\n this._size = this._buf.length;\n this._offset = 0;\n this._options = options;\n\n // A list of offsets in the buffer where we need to insert\n // sequence tag/len pairs.\n this._seq = [];\n}\n\nObject.defineProperty(Writer.prototype, 'buffer', {\n get: function () {\n if (this._seq.length)\n throw newInvalidAsn1Error(this._seq.length + ' unended sequence(s)');\n\n return (this._buf.slice(0, this._offset));\n }\n});\n\nWriter.prototype.writeByte = function (b) {\n if (typeof (b) !== 'number')\n throw new TypeError('argument must be a Number');\n\n this._ensure(1);\n this._buf[this._offset++] = b;\n};\n\n\nWriter.prototype.writeInt = function (i, tag) {\n if (typeof (i) !== 'number')\n throw new TypeError('argument must be a Number');\n if (typeof (tag) !== 'number')\n tag = ASN1.Integer;\n\n var sz = 4;\n\n while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&\n (sz > 1)) {\n sz--;\n i <<= 8;\n }\n\n if (sz > 4)\n throw newInvalidAsn1Error('BER ints cannot be > 0xffffffff');\n\n this._ensure(2 + sz);\n this._buf[this._offset++] = tag;\n this._buf[this._offset++] = sz;\n\n while (sz-- > 0) {\n this._buf[this._offset++] = ((i & 0xff000000) >>> 24);\n i <<= 8;\n }\n\n};\n\n\nWriter.prototype.writeNull = function () {\n this.writeByte(ASN1.Null);\n this.writeByte(0x00);\n};\n\n\nWriter.prototype.writeEnumeration = function (i, tag) {\n if (typeof (i) !== 'number')\n throw new TypeError('argument must be a Number');\n if (typeof (tag) !== 'number')\n tag = ASN1.Enumeration;\n\n return this.writeInt(i, tag);\n};\n\n\nWriter.prototype.writeBoolean = function (b, tag) {\n if (typeof (b) !== 'boolean')\n throw new TypeError('argument must be a Boolean');\n if (typeof (tag) !== 'number')\n tag = ASN1.Boolean;\n\n this._ensure(3);\n this._buf[this._offset++] = tag;\n this._buf[this._offset++] = 0x01;\n this._buf[this._offset++] = b ? 0xff : 0x00;\n};\n\n\nWriter.prototype.writeString = function (s, tag) {\n if (typeof (s) !== 'string')\n throw new TypeError('argument must be a string (was: ' + typeof (s) + ')');\n if (typeof (tag) !== 'number')\n tag = ASN1.OctetString;\n\n var len = Buffer.byteLength(s);\n this.writeByte(tag);\n this.writeLength(len);\n if (len) {\n this._ensure(len);\n this._buf.write(s, this._offset);\n this._offset += len;\n }\n};\n\n\nWriter.prototype.writeBuffer = function (buf, tag) {\n if (typeof (tag) !== 'number')\n throw new TypeError('tag must be a number');\n if (!Buffer.isBuffer(buf))\n throw new TypeError('argument must be a buffer');\n\n this.writeByte(tag);\n this.writeLength(buf.length);\n this._ensure(buf.length);\n buf.copy(this._buf, this._offset, 0, buf.length);\n this._offset += buf.length;\n};\n\n\nWriter.prototype.writeStringArray = function (strings) {\n if ((!strings instanceof Array))\n throw new TypeError('argument must be an Array[String]');\n\n var self = this;\n strings.forEach(function (s) {\n self.writeString(s);\n });\n};\n\n// This is really to solve DER cases, but whatever for now\nWriter.prototype.writeOID = function (s, tag) {\n if (typeof (s) !== 'string')\n throw new TypeError('argument must be a string');\n if (typeof (tag) !== 'number')\n tag = ASN1.OID;\n\n if (!/^([0-9]+\\.){3,}[0-9]+$/.test(s))\n throw new Error('argument is not a valid OID string');\n\n function encodeOctet(bytes, octet) {\n if (octet < 128) {\n bytes.push(octet);\n } else if (octet < 16384) {\n bytes.push((octet >>> 7) | 0x80);\n bytes.push(octet & 0x7F);\n } else if (octet < 2097152) {\n bytes.push((octet >>> 14) | 0x80);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n } else if (octet < 268435456) {\n bytes.push((octet >>> 21) | 0x80);\n bytes.push(((octet >>> 14) | 0x80) & 0xFF);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n } else {\n bytes.push(((octet >>> 28) | 0x80) & 0xFF);\n bytes.push(((octet >>> 21) | 0x80) & 0xFF);\n bytes.push(((octet >>> 14) | 0x80) & 0xFF);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n }\n }\n\n var tmp = s.split('.');\n var bytes = [];\n bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));\n tmp.slice(2).forEach(function (b) {\n encodeOctet(bytes, parseInt(b, 10));\n });\n\n var self = this;\n this._ensure(2 + bytes.length);\n this.writeByte(tag);\n this.writeLength(bytes.length);\n bytes.forEach(function (b) {\n self.writeByte(b);\n });\n};\n\n\nWriter.prototype.writeLength = function (len) {\n if (typeof (len) !== 'number')\n throw new TypeError('argument must be a Number');\n\n this._ensure(4);\n\n if (len <= 0x7f) {\n this._buf[this._offset++] = len;\n } else if (len <= 0xff) {\n this._buf[this._offset++] = 0x81;\n this._buf[this._offset++] = len;\n } else if (len <= 0xffff) {\n this._buf[this._offset++] = 0x82;\n this._buf[this._offset++] = len >> 8;\n this._buf[this._offset++] = len;\n } else if (len <= 0xffffff) {\n this._buf[this._offset++] = 0x83;\n this._buf[this._offset++] = len >> 16;\n this._buf[this._offset++] = len >> 8;\n this._buf[this._offset++] = len;\n } else {\n throw newInvalidAsn1Error('Length too long (> 4 bytes)');\n }\n};\n\nWriter.prototype.startSequence = function (tag) {\n if (typeof (tag) !== 'number')\n tag = ASN1.Sequence | ASN1.Constructor;\n\n this.writeByte(tag);\n this._seq.push(this._offset);\n this._ensure(3);\n this._offset += 3;\n};\n\n\nWriter.prototype.endSequence = function () {\n var seq = this._seq.pop();\n var start = seq + 3;\n var len = this._offset - start;\n\n if (len <= 0x7f) {\n this._shift(start, len, -2);\n this._buf[seq] = len;\n } else if (len <= 0xff) {\n this._shift(start, len, -1);\n this._buf[seq] = 0x81;\n this._buf[seq + 1] = len;\n } else if (len <= 0xffff) {\n this._buf[seq] = 0x82;\n this._buf[seq + 1] = len >> 8;\n this._buf[seq + 2] = len;\n } else if (len <= 0xffffff) {\n this._shift(start, len, 1);\n this._buf[seq] = 0x83;\n this._buf[seq + 1] = len >> 16;\n this._buf[seq + 2] = len >> 8;\n this._buf[seq + 3] = len;\n } else {\n throw newInvalidAsn1Error('Sequence too long');\n }\n};\n\n\nWriter.prototype._shift = function (start, len, shift) {\n assert.ok(start !== undefined);\n assert.ok(len !== undefined);\n assert.ok(shift);\n\n this._buf.copy(this._buf, start + shift, start, start + len);\n this._offset += shift;\n};\n\nWriter.prototype._ensure = function (len) {\n assert.ok(len);\n\n if (this._size - this._offset < len) {\n var sz = this._size * this._options.growthFactor;\n if (sz - this._offset < len)\n sz += len;\n\n var buf = Buffer.alloc(sz);\n\n this._buf.copy(buf, 0, 0, this._offset);\n this._buf = buf;\n this._size = sz;\n }\n};\n\n\n\n// --- Exported API\n\nmodule.exports = Writer;\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n// If you have no idea what ASN.1 or BER is, see this:\n// ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc\n\nvar Ber = require('./ber/index');\n\n\n\n// --- Exported API\n\nmodule.exports = {\n\n Ber: Ber,\n\n BerReader: Ber.Reader,\n\n BerWriter: Ber.Writer\n\n};\n","'use strict';\n\nvar crypto_hash_sha512 = require('tweetnacl').lowlevel.crypto_hash;\n\n/*\n * This file is a 1:1 port from the OpenBSD blowfish.c and bcrypt_pbkdf.c. As a\n * result, it retains the original copyright and license. The two files are\n * under slightly different (but compatible) licenses, and are here combined in\n * one file.\n *\n * Credit for the actual porting work goes to:\n * Devi Mandiri \n */\n\n/*\n * The Blowfish portions are under the following license:\n *\n * Blowfish block cipher for OpenBSD\n * Copyright 1997 Niels Provos \n * All rights reserved.\n *\n * Implementation advice by David Mazieres .\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. The name of the author may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*\n * The bcrypt_pbkdf portions are under the following license:\n *\n * Copyright (c) 2013 Ted Unangst \n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n/*\n * Performance improvements (Javascript-specific):\n *\n * Copyright 2016, Joyent Inc\n * Author: Alex Wilson \n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n// Ported from OpenBSD bcrypt_pbkdf.c v1.9\n\nvar BLF_J = 0;\n\nvar Blowfish = function() {\n this.S = [\n new Uint32Array([\n 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,\n 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,\n 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,\n 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,\n 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,\n 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,\n 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,\n 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,\n 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,\n 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,\n 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,\n 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,\n 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,\n 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,\n 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,\n 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,\n 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,\n 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,\n 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,\n 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,\n 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,\n 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,\n 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,\n 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,\n 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,\n 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,\n 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,\n 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,\n 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,\n 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,\n 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,\n 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,\n 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,\n 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,\n 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,\n 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,\n 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,\n 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,\n 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,\n 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,\n 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,\n 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,\n 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,\n 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,\n 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,\n 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,\n 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,\n 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,\n 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,\n 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,\n 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,\n 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,\n 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,\n 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,\n 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,\n 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,\n 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,\n 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,\n 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,\n 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,\n 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,\n 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,\n 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,\n 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a]),\n new Uint32Array([\n 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,\n 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,\n 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,\n 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,\n 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,\n 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,\n 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,\n 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,\n 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,\n 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,\n 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,\n 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,\n 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,\n 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,\n 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,\n 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,\n 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,\n 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,\n 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,\n 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,\n 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,\n 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,\n 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,\n 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,\n 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,\n 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,\n 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,\n 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,\n 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,\n 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,\n 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,\n 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,\n 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,\n 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,\n 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,\n 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,\n 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,\n 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,\n 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,\n 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,\n 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,\n 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,\n 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,\n 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,\n 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,\n 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,\n 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,\n 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,\n 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,\n 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,\n 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,\n 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,\n 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,\n 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,\n 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,\n 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,\n 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,\n 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,\n 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,\n 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,\n 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,\n 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,\n 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,\n 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7]),\n new Uint32Array([\n 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,\n 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,\n 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,\n 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,\n 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,\n 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,\n 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,\n 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,\n 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,\n 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,\n 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,\n 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,\n 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,\n 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,\n 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,\n 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,\n 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,\n 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,\n 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,\n 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,\n 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,\n 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,\n 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,\n 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,\n 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,\n 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,\n 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,\n 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,\n 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,\n 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,\n 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,\n 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,\n 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,\n 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,\n 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,\n 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,\n 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,\n 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,\n 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,\n 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,\n 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,\n 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,\n 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,\n 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,\n 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,\n 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,\n 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,\n 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,\n 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,\n 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,\n 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,\n 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,\n 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,\n 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,\n 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,\n 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,\n 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,\n 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,\n 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,\n 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,\n 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,\n 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,\n 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,\n 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0]),\n new Uint32Array([\n 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,\n 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,\n 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,\n 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,\n 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,\n 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,\n 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,\n 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,\n 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,\n 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,\n 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,\n 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,\n 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,\n 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,\n 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,\n 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,\n 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,\n 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,\n 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,\n 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,\n 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,\n 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,\n 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,\n 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,\n 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,\n 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,\n 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,\n 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,\n 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,\n 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,\n 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,\n 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,\n 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,\n 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,\n 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,\n 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,\n 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,\n 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,\n 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,\n 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,\n 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,\n 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,\n 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,\n 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,\n 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,\n 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,\n 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,\n 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,\n 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,\n 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,\n 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,\n 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,\n 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,\n 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,\n 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,\n 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,\n 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,\n 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,\n 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,\n 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,\n 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,\n 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,\n 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,\n 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6])\n ];\n this.P = new Uint32Array([\n 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,\n 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,\n 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,\n 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,\n 0x9216d5d9, 0x8979fb1b]);\n};\n\nfunction F(S, x8, i) {\n return (((S[0][x8[i+3]] +\n S[1][x8[i+2]]) ^\n S[2][x8[i+1]]) +\n S[3][x8[i]]);\n};\n\nBlowfish.prototype.encipher = function(x, x8) {\n if (x8 === undefined) {\n x8 = new Uint8Array(x.buffer);\n if (x.byteOffset !== 0)\n x8 = x8.subarray(x.byteOffset);\n }\n x[0] ^= this.P[0];\n for (var i = 1; i < 16; i += 2) {\n x[1] ^= F(this.S, x8, 0) ^ this.P[i];\n x[0] ^= F(this.S, x8, 4) ^ this.P[i+1];\n }\n var t = x[0];\n x[0] = x[1] ^ this.P[17];\n x[1] = t;\n};\n\nBlowfish.prototype.decipher = function(x) {\n var x8 = new Uint8Array(x.buffer);\n if (x.byteOffset !== 0)\n x8 = x8.subarray(x.byteOffset);\n x[0] ^= this.P[17];\n for (var i = 16; i > 0; i -= 2) {\n x[1] ^= F(this.S, x8, 0) ^ this.P[i];\n x[0] ^= F(this.S, x8, 4) ^ this.P[i-1];\n }\n var t = x[0];\n x[0] = x[1] ^ this.P[0];\n x[1] = t;\n};\n\nfunction stream2word(data, databytes){\n var i, temp = 0;\n for (i = 0; i < 4; i++, BLF_J++) {\n if (BLF_J >= databytes) BLF_J = 0;\n temp = (temp << 8) | data[BLF_J];\n }\n return temp;\n};\n\nBlowfish.prototype.expand0state = function(key, keybytes) {\n var d = new Uint32Array(2), i, k;\n var d8 = new Uint8Array(d.buffer);\n\n for (i = 0, BLF_J = 0; i < 18; i++) {\n this.P[i] ^= stream2word(key, keybytes);\n }\n BLF_J = 0;\n\n for (i = 0; i < 18; i += 2) {\n this.encipher(d, d8);\n this.P[i] = d[0];\n this.P[i+1] = d[1];\n }\n\n for (i = 0; i < 4; i++) {\n for (k = 0; k < 256; k += 2) {\n this.encipher(d, d8);\n this.S[i][k] = d[0];\n this.S[i][k+1] = d[1];\n }\n }\n};\n\nBlowfish.prototype.expandstate = function(data, databytes, key, keybytes) {\n var d = new Uint32Array(2), i, k;\n\n for (i = 0, BLF_J = 0; i < 18; i++) {\n this.P[i] ^= stream2word(key, keybytes);\n }\n\n for (i = 0, BLF_J = 0; i < 18; i += 2) {\n d[0] ^= stream2word(data, databytes);\n d[1] ^= stream2word(data, databytes);\n this.encipher(d);\n this.P[i] = d[0];\n this.P[i+1] = d[1];\n }\n\n for (i = 0; i < 4; i++) {\n for (k = 0; k < 256; k += 2) {\n d[0] ^= stream2word(data, databytes);\n d[1] ^= stream2word(data, databytes);\n this.encipher(d);\n this.S[i][k] = d[0];\n this.S[i][k+1] = d[1];\n }\n }\n BLF_J = 0;\n};\n\nBlowfish.prototype.enc = function(data, blocks) {\n for (var i = 0; i < blocks; i++) {\n this.encipher(data.subarray(i*2));\n }\n};\n\nBlowfish.prototype.dec = function(data, blocks) {\n for (var i = 0; i < blocks; i++) {\n this.decipher(data.subarray(i*2));\n }\n};\n\nvar BCRYPT_BLOCKS = 8,\n BCRYPT_HASHSIZE = 32;\n\nfunction bcrypt_hash(sha2pass, sha2salt, out) {\n var state = new Blowfish(),\n cdata = new Uint32Array(BCRYPT_BLOCKS), i,\n ciphertext = new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,\n 99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,\n 105,116,101]); //\"OxychromaticBlowfishSwatDynamite\"\n\n state.expandstate(sha2salt, 64, sha2pass, 64);\n for (i = 0; i < 64; i++) {\n state.expand0state(sha2salt, 64);\n state.expand0state(sha2pass, 64);\n }\n\n for (i = 0; i < BCRYPT_BLOCKS; i++)\n cdata[i] = stream2word(ciphertext, ciphertext.byteLength);\n for (i = 0; i < 64; i++)\n state.enc(cdata, cdata.byteLength / 8);\n\n for (i = 0; i < BCRYPT_BLOCKS; i++) {\n out[4*i+3] = cdata[i] >>> 24;\n out[4*i+2] = cdata[i] >>> 16;\n out[4*i+1] = cdata[i] >>> 8;\n out[4*i+0] = cdata[i];\n }\n};\n\nfunction bcrypt_pbkdf(pass, passlen, salt, saltlen, key, keylen, rounds) {\n var sha2pass = new Uint8Array(64),\n sha2salt = new Uint8Array(64),\n out = new Uint8Array(BCRYPT_HASHSIZE),\n tmpout = new Uint8Array(BCRYPT_HASHSIZE),\n countsalt = new Uint8Array(saltlen+4),\n i, j, amt, stride, dest, count,\n origkeylen = keylen;\n\n if (rounds < 1)\n return -1;\n if (passlen === 0 || saltlen === 0 || keylen === 0 ||\n keylen > (out.byteLength * out.byteLength) || saltlen > (1<<20))\n return -1;\n\n stride = Math.floor((keylen + out.byteLength - 1) / out.byteLength);\n amt = Math.floor((keylen + stride - 1) / stride);\n\n for (i = 0; i < saltlen; i++)\n countsalt[i] = salt[i];\n\n crypto_hash_sha512(sha2pass, pass, passlen);\n\n for (count = 1; keylen > 0; count++) {\n countsalt[saltlen+0] = count >>> 24;\n countsalt[saltlen+1] = count >>> 16;\n countsalt[saltlen+2] = count >>> 8;\n countsalt[saltlen+3] = count;\n\n crypto_hash_sha512(sha2salt, countsalt, saltlen + 4);\n bcrypt_hash(sha2pass, sha2salt, tmpout);\n for (i = out.byteLength; i--;)\n out[i] = tmpout[i];\n\n for (i = 1; i < rounds; i++) {\n crypto_hash_sha512(sha2salt, tmpout, tmpout.byteLength);\n bcrypt_hash(sha2pass, sha2salt, tmpout);\n for (j = 0; j < out.byteLength; j++)\n out[j] ^= tmpout[j];\n }\n\n amt = Math.min(amt, keylen);\n for (i = 0; i < amt; i++) {\n dest = i * stride + (count - 1);\n if (dest >= origkeylen)\n break;\n key[dest] = out[i];\n }\n keylen -= i;\n }\n\n return 0;\n};\n\nmodule.exports = {\n BLOCKS: BCRYPT_BLOCKS,\n HASHSIZE: BCRYPT_HASHSIZE,\n hash: bcrypt_hash,\n pbkdf: bcrypt_pbkdf\n};\n","'use strict'\n\nconst { Buffer } = require('buffer')\nconst symbol = Symbol.for('BufferList')\n\nfunction BufferList (buf) {\n if (!(this instanceof BufferList)) {\n return new BufferList(buf)\n }\n\n BufferList._init.call(this, buf)\n}\n\nBufferList._init = function _init (buf) {\n Object.defineProperty(this, symbol, { value: true })\n\n this._bufs = []\n this.length = 0\n\n if (buf) {\n this.append(buf)\n }\n}\n\nBufferList.prototype._new = function _new (buf) {\n return new BufferList(buf)\n}\n\nBufferList.prototype._offset = function _offset (offset) {\n if (offset === 0) {\n return [0, 0]\n }\n\n let tot = 0\n\n for (let i = 0; i < this._bufs.length; i++) {\n const _t = tot + this._bufs[i].length\n if (offset < _t || i === this._bufs.length - 1) {\n return [i, offset - tot]\n }\n tot = _t\n }\n}\n\nBufferList.prototype._reverseOffset = function (blOffset) {\n const bufferId = blOffset[0]\n let offset = blOffset[1]\n\n for (let i = 0; i < bufferId; i++) {\n offset += this._bufs[i].length\n }\n\n return offset\n}\n\nBufferList.prototype.get = function get (index) {\n if (index > this.length || index < 0) {\n return undefined\n }\n\n const offset = this._offset(index)\n\n return this._bufs[offset[0]][offset[1]]\n}\n\nBufferList.prototype.slice = function slice (start, end) {\n if (typeof start === 'number' && start < 0) {\n start += this.length\n }\n\n if (typeof end === 'number' && end < 0) {\n end += this.length\n }\n\n return this.copy(null, 0, start, end)\n}\n\nBufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {\n if (typeof srcStart !== 'number' || srcStart < 0) {\n srcStart = 0\n }\n\n if (typeof srcEnd !== 'number' || srcEnd > this.length) {\n srcEnd = this.length\n }\n\n if (srcStart >= this.length) {\n return dst || Buffer.alloc(0)\n }\n\n if (srcEnd <= 0) {\n return dst || Buffer.alloc(0)\n }\n\n const copy = !!dst\n const off = this._offset(srcStart)\n const len = srcEnd - srcStart\n let bytes = len\n let bufoff = (copy && dstStart) || 0\n let start = off[1]\n\n // copy/slice everything\n if (srcStart === 0 && srcEnd === this.length) {\n if (!copy) {\n // slice, but full concat if multiple buffers\n return this._bufs.length === 1\n ? this._bufs[0]\n : Buffer.concat(this._bufs, this.length)\n }\n\n // copy, need to copy individual buffers\n for (let i = 0; i < this._bufs.length; i++) {\n this._bufs[i].copy(dst, bufoff)\n bufoff += this._bufs[i].length\n }\n\n return dst\n }\n\n // easy, cheap case where it's a subset of one of the buffers\n if (bytes <= this._bufs[off[0]].length - start) {\n return copy\n ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)\n : this._bufs[off[0]].slice(start, start + bytes)\n }\n\n if (!copy) {\n // a slice, we need something to copy in to\n dst = Buffer.allocUnsafe(len)\n }\n\n for (let i = off[0]; i < this._bufs.length; i++) {\n const l = this._bufs[i].length - start\n\n if (bytes > l) {\n this._bufs[i].copy(dst, bufoff, start)\n bufoff += l\n } else {\n this._bufs[i].copy(dst, bufoff, start, start + bytes)\n bufoff += l\n break\n }\n\n bytes -= l\n\n if (start) {\n start = 0\n }\n }\n\n // safeguard so that we don't return uninitialized memory\n if (dst.length > bufoff) return dst.slice(0, bufoff)\n\n return dst\n}\n\nBufferList.prototype.shallowSlice = function shallowSlice (start, end) {\n start = start || 0\n end = typeof end !== 'number' ? this.length : end\n\n if (start < 0) {\n start += this.length\n }\n\n if (end < 0) {\n end += this.length\n }\n\n if (start === end) {\n return this._new()\n }\n\n const startOffset = this._offset(start)\n const endOffset = this._offset(end)\n const buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)\n\n if (endOffset[1] === 0) {\n buffers.pop()\n } else {\n buffers[buffers.length - 1] = buffers[buffers.length - 1].slice(0, endOffset[1])\n }\n\n if (startOffset[1] !== 0) {\n buffers[0] = buffers[0].slice(startOffset[1])\n }\n\n return this._new(buffers)\n}\n\nBufferList.prototype.toString = function toString (encoding, start, end) {\n return this.slice(start, end).toString(encoding)\n}\n\nBufferList.prototype.consume = function consume (bytes) {\n // first, normalize the argument, in accordance with how Buffer does it\n bytes = Math.trunc(bytes)\n // do nothing if not a positive number\n if (Number.isNaN(bytes) || bytes <= 0) return this\n\n while (this._bufs.length) {\n if (bytes >= this._bufs[0].length) {\n bytes -= this._bufs[0].length\n this.length -= this._bufs[0].length\n this._bufs.shift()\n } else {\n this._bufs[0] = this._bufs[0].slice(bytes)\n this.length -= bytes\n break\n }\n }\n\n return this\n}\n\nBufferList.prototype.duplicate = function duplicate () {\n const copy = this._new()\n\n for (let i = 0; i < this._bufs.length; i++) {\n copy.append(this._bufs[i])\n }\n\n return copy\n}\n\nBufferList.prototype.append = function append (buf) {\n if (buf == null) {\n return this\n }\n\n if (buf.buffer) {\n // append a view of the underlying ArrayBuffer\n this._appendBuffer(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength))\n } else if (Array.isArray(buf)) {\n for (let i = 0; i < buf.length; i++) {\n this.append(buf[i])\n }\n } else if (this._isBufferList(buf)) {\n // unwrap argument into individual BufferLists\n for (let i = 0; i < buf._bufs.length; i++) {\n this.append(buf._bufs[i])\n }\n } else {\n // coerce number arguments to strings, since Buffer(number) does\n // uninitialized memory allocation\n if (typeof buf === 'number') {\n buf = buf.toString()\n }\n\n this._appendBuffer(Buffer.from(buf))\n }\n\n return this\n}\n\nBufferList.prototype._appendBuffer = function appendBuffer (buf) {\n this._bufs.push(buf)\n this.length += buf.length\n}\n\nBufferList.prototype.indexOf = function (search, offset, encoding) {\n if (encoding === undefined && typeof offset === 'string') {\n encoding = offset\n offset = undefined\n }\n\n if (typeof search === 'function' || Array.isArray(search)) {\n throw new TypeError('The \"value\" argument must be one of type string, Buffer, BufferList, or Uint8Array.')\n } else if (typeof search === 'number') {\n search = Buffer.from([search])\n } else if (typeof search === 'string') {\n search = Buffer.from(search, encoding)\n } else if (this._isBufferList(search)) {\n search = search.slice()\n } else if (Array.isArray(search.buffer)) {\n search = Buffer.from(search.buffer, search.byteOffset, search.byteLength)\n } else if (!Buffer.isBuffer(search)) {\n search = Buffer.from(search)\n }\n\n offset = Number(offset || 0)\n\n if (isNaN(offset)) {\n offset = 0\n }\n\n if (offset < 0) {\n offset = this.length + offset\n }\n\n if (offset < 0) {\n offset = 0\n }\n\n if (search.length === 0) {\n return offset > this.length ? this.length : offset\n }\n\n const blOffset = this._offset(offset)\n let blIndex = blOffset[0] // index of which internal buffer we're working on\n let buffOffset = blOffset[1] // offset of the internal buffer we're working on\n\n // scan over each buffer\n for (; blIndex < this._bufs.length; blIndex++) {\n const buff = this._bufs[blIndex]\n\n while (buffOffset < buff.length) {\n const availableWindow = buff.length - buffOffset\n\n if (availableWindow >= search.length) {\n const nativeSearchResult = buff.indexOf(search, buffOffset)\n\n if (nativeSearchResult !== -1) {\n return this._reverseOffset([blIndex, nativeSearchResult])\n }\n\n buffOffset = buff.length - search.length + 1 // end of native search window\n } else {\n const revOffset = this._reverseOffset([blIndex, buffOffset])\n\n if (this._match(revOffset, search)) {\n return revOffset\n }\n\n buffOffset++\n }\n }\n\n buffOffset = 0\n }\n\n return -1\n}\n\nBufferList.prototype._match = function (offset, search) {\n if (this.length - offset < search.length) {\n return false\n }\n\n for (let searchOffset = 0; searchOffset < search.length; searchOffset++) {\n if (this.get(offset + searchOffset) !== search[searchOffset]) {\n return false\n }\n }\n return true\n}\n\n;(function () {\n const methods = {\n readDoubleBE: 8,\n readDoubleLE: 8,\n readFloatBE: 4,\n readFloatLE: 4,\n readInt32BE: 4,\n readInt32LE: 4,\n readUInt32BE: 4,\n readUInt32LE: 4,\n readInt16BE: 2,\n readInt16LE: 2,\n readUInt16BE: 2,\n readUInt16LE: 2,\n readInt8: 1,\n readUInt8: 1,\n readIntBE: null,\n readIntLE: null,\n readUIntBE: null,\n readUIntLE: null\n }\n\n for (const m in methods) {\n (function (m) {\n if (methods[m] === null) {\n BufferList.prototype[m] = function (offset, byteLength) {\n return this.slice(offset, offset + byteLength)[m](0, byteLength)\n }\n } else {\n BufferList.prototype[m] = function (offset = 0) {\n return this.slice(offset, offset + methods[m])[m](0)\n }\n }\n }(m))\n }\n}())\n\n// Used internally by the class and also as an indicator of this object being\n// a `BufferList`. It's not possible to use `instanceof BufferList` in a browser\n// environment because there could be multiple different copies of the\n// BufferList class and some `BufferList`s might be `BufferList`s.\nBufferList.prototype._isBufferList = function _isBufferList (b) {\n return b instanceof BufferList || BufferList.isBufferList(b)\n}\n\nBufferList.isBufferList = function isBufferList (b) {\n return b != null && b[symbol]\n}\n\nmodule.exports = BufferList\n","'use strict'\n\nconst DuplexStream = require('readable-stream').Duplex\nconst inherits = require('inherits')\nconst BufferList = require('./BufferList')\n\nfunction BufferListStream (callback) {\n if (!(this instanceof BufferListStream)) {\n return new BufferListStream(callback)\n }\n\n if (typeof callback === 'function') {\n this._callback = callback\n\n const piper = function piper (err) {\n if (this._callback) {\n this._callback(err)\n this._callback = null\n }\n }.bind(this)\n\n this.on('pipe', function onPipe (src) {\n src.on('error', piper)\n })\n this.on('unpipe', function onUnpipe (src) {\n src.removeListener('error', piper)\n })\n\n callback = null\n }\n\n BufferList._init.call(this, callback)\n DuplexStream.call(this)\n}\n\ninherits(BufferListStream, DuplexStream)\nObject.assign(BufferListStream.prototype, BufferList.prototype)\n\nBufferListStream.prototype._new = function _new (callback) {\n return new BufferListStream(callback)\n}\n\nBufferListStream.prototype._write = function _write (buf, encoding, callback) {\n this._appendBuffer(buf)\n\n if (typeof callback === 'function') {\n callback()\n }\n}\n\nBufferListStream.prototype._read = function _read (size) {\n if (!this.length) {\n return this.push(null)\n }\n\n size = Math.min(size, this.length)\n this.push(this.slice(0, size))\n this.consume(size)\n}\n\nBufferListStream.prototype.end = function end (chunk) {\n DuplexStream.prototype.end.call(this, chunk)\n\n if (this._callback) {\n this._callback(null, this.slice())\n this._callback = null\n }\n}\n\nBufferListStream.prototype._destroy = function _destroy (err, cb) {\n this._bufs.length = 0\n this.length = 0\n cb(err)\n}\n\nBufferListStream.prototype._isBufferList = function _isBufferList (b) {\n return b instanceof BufferListStream || b instanceof BufferList || BufferListStream.isBufferList(b)\n}\n\nBufferListStream.isBufferList = BufferList.isBufferList\n\nmodule.exports = BufferListStream\nmodule.exports.BufferListStream = BufferListStream\nmodule.exports.BufferList = BufferList\n","'use strict'\nconst fs = require('fs')\nconst path = require('path')\n\n/* istanbul ignore next */\nconst LCHOWN = fs.lchown ? 'lchown' : 'chown'\n/* istanbul ignore next */\nconst LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'\n\n/* istanbul ignore next */\nconst needEISDIRHandled = fs.lchown &&\n !process.version.match(/v1[1-9]+\\./) &&\n !process.version.match(/v10\\.[6-9]/)\n\nconst lchownSync = (path, uid, gid) => {\n try {\n return fs[LCHOWNSYNC](path, uid, gid)\n } catch (er) {\n if (er.code !== 'ENOENT')\n throw er\n }\n}\n\n/* istanbul ignore next */\nconst chownSync = (path, uid, gid) => {\n try {\n return fs.chownSync(path, uid, gid)\n } catch (er) {\n if (er.code !== 'ENOENT')\n throw er\n }\n}\n\n/* istanbul ignore next */\nconst handleEISDIR =\n needEISDIRHandled ? (path, uid, gid, cb) => er => {\n // Node prior to v10 had a very questionable implementation of\n // fs.lchown, which would always try to call fs.open on a directory\n // Fall back to fs.chown in those cases.\n if (!er || er.code !== 'EISDIR')\n cb(er)\n else\n fs.chown(path, uid, gid, cb)\n }\n : (_, __, ___, cb) => cb\n\n/* istanbul ignore next */\nconst handleEISDirSync =\n needEISDIRHandled ? (path, uid, gid) => {\n try {\n return lchownSync(path, uid, gid)\n } catch (er) {\n if (er.code !== 'EISDIR')\n throw er\n chownSync(path, uid, gid)\n }\n }\n : (path, uid, gid) => lchownSync(path, uid, gid)\n\n// fs.readdir could only accept an options object as of node v6\nconst nodeVersion = process.version\nlet readdir = (path, options, cb) => fs.readdir(path, options, cb)\nlet readdirSync = (path, options) => fs.readdirSync(path, options)\n/* istanbul ignore next */\nif (/^v4\\./.test(nodeVersion))\n readdir = (path, options, cb) => fs.readdir(path, cb)\n\nconst chown = (cpath, uid, gid, cb) => {\n fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, er => {\n // Skip ENOENT error\n cb(er && er.code !== 'ENOENT' ? er : null)\n }))\n}\n\nconst chownrKid = (p, child, uid, gid, cb) => {\n if (typeof child === 'string')\n return fs.lstat(path.resolve(p, child), (er, stats) => {\n // Skip ENOENT error\n if (er)\n return cb(er.code !== 'ENOENT' ? er : null)\n stats.name = child\n chownrKid(p, stats, uid, gid, cb)\n })\n\n if (child.isDirectory()) {\n chownr(path.resolve(p, child.name), uid, gid, er => {\n if (er)\n return cb(er)\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n })\n } else {\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n }\n}\n\n\nconst chownr = (p, uid, gid, cb) => {\n readdir(p, { withFileTypes: true }, (er, children) => {\n // any error other than ENOTDIR or ENOTSUP means it's not readable,\n // or doesn't exist. give up.\n if (er) {\n if (er.code === 'ENOENT')\n return cb()\n else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')\n return cb(er)\n }\n if (er || !children.length)\n return chown(p, uid, gid, cb)\n\n let len = children.length\n let errState = null\n const then = er => {\n if (errState)\n return\n if (er)\n return cb(errState = er)\n if (-- len === 0)\n return chown(p, uid, gid, cb)\n }\n\n children.forEach(child => chownrKid(p, child, uid, gid, then))\n })\n}\n\nconst chownrKidSync = (p, child, uid, gid) => {\n if (typeof child === 'string') {\n try {\n const stats = fs.lstatSync(path.resolve(p, child))\n stats.name = child\n child = stats\n } catch (er) {\n if (er.code === 'ENOENT')\n return\n else\n throw er\n }\n }\n\n if (child.isDirectory())\n chownrSync(path.resolve(p, child.name), uid, gid)\n\n handleEISDirSync(path.resolve(p, child.name), uid, gid)\n}\n\nconst chownrSync = (p, uid, gid) => {\n let children\n try {\n children = readdirSync(p, { withFileTypes: true })\n } catch (er) {\n if (er.code === 'ENOENT')\n return\n else if (er.code === 'ENOTDIR' || er.code === 'ENOTSUP')\n return handleEISDirSync(p, uid, gid)\n else\n throw er\n }\n\n if (children && children.length)\n children.forEach(child => chownrKidSync(p, child, uid, gid))\n\n return handleEISDirSync(p, uid, gid)\n}\n\nmodule.exports = chownr\nchownr.sync = chownrSync\n","const binding = require('../build/Release/cpufeatures.node');\n\nmodule.exports = binding.getCPUInfo;\n","/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug');\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tlet i;\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n\t\tconst len = split.length;\n\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tif (!split[i]) {\n\t\t\t\t// ignore empty strings\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tnamespaces = split[i].replace(/\\*/g, '.*?');\n\n\t\t\tif (namespaces[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(new RegExp('^' + namespaces + '$'));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names.map(toNamespace),\n\t\t\t...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tif (name[name.length - 1] === '*') {\n\t\t\treturn true;\n\t\t}\n\n\t\tlet i;\n\t\tlet len;\n\n\t\tfor (i = 0, len = createDebug.skips.length; i < len; i++) {\n\t\t\tif (createDebug.skips[i].test(name)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0, len = createDebug.names.length; i < len; i++) {\n\t\t\tif (createDebug.names[i].test(name)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Convert regexp to namespace\n\t*\n\t* @param {RegExp} regxep\n\t* @return {String} namespace\n\t* @api private\n\t*/\n\tfunction toNamespace(regexp) {\n\t\treturn regexp.toString()\n\t\t\t.substring(2, regexp.toString().length - 2)\n\t\t\t.replace(/\\.\\*\\?$/, '*');\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n","/**\n * Detect Electron renderer / nwjs process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {\n\tmodule.exports = require('./browser.js');\n} else {\n\tmodule.exports = require('./node.js');\n}\n","/**\n * Module dependencies.\n */\n\nconst tty = require('tty');\nconst util = require('util');\n\n/**\n * This is the Node.js implementation of `debug()`.\n */\n\nexports.init = init;\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.destroy = util.deprecate(\n\t() => {},\n\t'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'\n);\n\n/**\n * Colors.\n */\n\nexports.colors = [6, 2, 3, 4, 5, 1];\n\ntry {\n\t// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)\n\t// eslint-disable-next-line import/no-extraneous-dependencies\n\tconst supportsColor = require('supports-color');\n\n\tif (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {\n\t\texports.colors = [\n\t\t\t20,\n\t\t\t21,\n\t\t\t26,\n\t\t\t27,\n\t\t\t32,\n\t\t\t33,\n\t\t\t38,\n\t\t\t39,\n\t\t\t40,\n\t\t\t41,\n\t\t\t42,\n\t\t\t43,\n\t\t\t44,\n\t\t\t45,\n\t\t\t56,\n\t\t\t57,\n\t\t\t62,\n\t\t\t63,\n\t\t\t68,\n\t\t\t69,\n\t\t\t74,\n\t\t\t75,\n\t\t\t76,\n\t\t\t77,\n\t\t\t78,\n\t\t\t79,\n\t\t\t80,\n\t\t\t81,\n\t\t\t92,\n\t\t\t93,\n\t\t\t98,\n\t\t\t99,\n\t\t\t112,\n\t\t\t113,\n\t\t\t128,\n\t\t\t129,\n\t\t\t134,\n\t\t\t135,\n\t\t\t148,\n\t\t\t149,\n\t\t\t160,\n\t\t\t161,\n\t\t\t162,\n\t\t\t163,\n\t\t\t164,\n\t\t\t165,\n\t\t\t166,\n\t\t\t167,\n\t\t\t168,\n\t\t\t169,\n\t\t\t170,\n\t\t\t171,\n\t\t\t172,\n\t\t\t173,\n\t\t\t178,\n\t\t\t179,\n\t\t\t184,\n\t\t\t185,\n\t\t\t196,\n\t\t\t197,\n\t\t\t198,\n\t\t\t199,\n\t\t\t200,\n\t\t\t201,\n\t\t\t202,\n\t\t\t203,\n\t\t\t204,\n\t\t\t205,\n\t\t\t206,\n\t\t\t207,\n\t\t\t208,\n\t\t\t209,\n\t\t\t214,\n\t\t\t215,\n\t\t\t220,\n\t\t\t221\n\t\t];\n\t}\n} catch (error) {\n\t// Swallow - we only care if `supports-color` is available; it doesn't have to be.\n}\n\n/**\n * Build up the default `inspectOpts` object from the environment variables.\n *\n * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js\n */\n\nexports.inspectOpts = Object.keys(process.env).filter(key => {\n\treturn /^debug_/i.test(key);\n}).reduce((obj, key) => {\n\t// Camel-case\n\tconst prop = key\n\t\t.substring(6)\n\t\t.toLowerCase()\n\t\t.replace(/_([a-z])/g, (_, k) => {\n\t\t\treturn k.toUpperCase();\n\t\t});\n\n\t// Coerce string value into JS value\n\tlet val = process.env[key];\n\tif (/^(yes|on|true|enabled)$/i.test(val)) {\n\t\tval = true;\n\t} else if (/^(no|off|false|disabled)$/i.test(val)) {\n\t\tval = false;\n\t} else if (val === 'null') {\n\t\tval = null;\n\t} else {\n\t\tval = Number(val);\n\t}\n\n\tobj[prop] = val;\n\treturn obj;\n}, {});\n\n/**\n * Is stdout a TTY? Colored output is enabled when `true`.\n */\n\nfunction useColors() {\n\treturn 'colors' in exports.inspectOpts ?\n\t\tBoolean(exports.inspectOpts.colors) :\n\t\ttty.isatty(process.stderr.fd);\n}\n\n/**\n * Adds ANSI color escape codes if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\tconst {namespace: name, useColors} = this;\n\n\tif (useColors) {\n\t\tconst c = this.color;\n\t\tconst colorCode = '\\u001B[3' + (c < 8 ? c : '8;5;' + c);\n\t\tconst prefix = ` ${colorCode};1m${name} \\u001B[0m`;\n\n\t\targs[0] = prefix + args[0].split('\\n').join('\\n' + prefix);\n\t\targs.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\\u001B[0m');\n\t} else {\n\t\targs[0] = getDate() + name + ' ' + args[0];\n\t}\n}\n\nfunction getDate() {\n\tif (exports.inspectOpts.hideDate) {\n\t\treturn '';\n\t}\n\treturn new Date().toISOString() + ' ';\n}\n\n/**\n * Invokes `util.format()` with the specified arguments and writes to stderr.\n */\n\nfunction log(...args) {\n\treturn process.stderr.write(util.format(...args) + '\\n');\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\tif (namespaces) {\n\t\tprocess.env.DEBUG = namespaces;\n\t} else {\n\t\t// If you set a process.env field to null or undefined, it gets cast to the\n\t\t// string 'null' or 'undefined'. Just delete instead.\n\t\tdelete process.env.DEBUG;\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n\treturn process.env.DEBUG;\n}\n\n/**\n * Init logic for `debug` instances.\n *\n * Create a new `inspectOpts` object in case `useColors` is set\n * differently for a particular `debug` instance.\n */\n\nfunction init(debug) {\n\tdebug.inspectOpts = {};\n\n\tconst keys = Object.keys(exports.inspectOpts);\n\tfor (let i = 0; i < keys.length; i++) {\n\t\tdebug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %o to `util.inspect()`, all on a single line.\n */\n\nformatters.o = function (v) {\n\tthis.inspectOpts.colors = this.useColors;\n\treturn util.inspect(v, this.inspectOpts)\n\t\t.split('\\n')\n\t\t.map(str => str.trim())\n\t\t.join(' ');\n};\n\n/**\n * Map %O to `util.inspect()`, allowing multiple lines if needed.\n */\n\nformatters.O = function (v) {\n\tthis.inspectOpts.colors = this.useColors;\n\treturn util.inspect(v, this.inspectOpts);\n};\n","//Based on follow-redirects v0.0.x\n\nvar nativeHttps = require('https'),\n nativeHttp = require('http'),\n url = require('url'),\n utils = require('./utils');\n\nvar maxRedirects = module.exports.maxRedirects = 5;\n\nvar protocols = {\n https: nativeHttps,\n http: nativeHttp\n};\n\nfor (var protocol in protocols) {\n var h = function() {};\n h.prototype = protocols[protocol];\n h = new h();\n\n h.request = function(h) {\n return function(options, callback, redirectOptions) {\n\n redirectOptions = redirectOptions || {};\n\n var max = (typeof options === 'object' && 'maxRedirects' in options) ? options.maxRedirects : exports.maxRedirects;\n\n var redirect = utils.extend({\n count: 0,\n max: max,\n clientRequest: null,\n userCallback: callback\n }, redirectOptions);\n\n if (redirect.count > redirect.max) {\n var err = new Error('Max redirects exceeded. To allow more redirects, pass options.maxRedirects property.');\n redirect.clientRequest.emit('error', err);\n return redirect.clientRequest;\n }\n\n redirect.count++;\n\n var reqUrl;\n if (typeof options === 'string') {\n reqUrl = options;\n } else {\n reqUrl = url.format(utils.extend({\n protocol: protocol\n }, options));\n }\n\n var clientRequest = Object.getPrototypeOf(h).request(options, redirectCallback(reqUrl, redirect));\n\n if (!redirect.clientRequest) redirect.clientRequest = clientRequest;\n\n function redirectCallback(reqUrl, redirect) {\n return function(res) {\n if (res.statusCode < 300 || res.statusCode > 399) {\n return redirect.userCallback(res);\n }\n\n if (!('location' in res.headers)) {\n return redirect.userCallback(res);\n }\n\n var redirectUrl = url.resolve(reqUrl, res.headers.location);\n\n var proto = url.parse(redirectUrl).protocol;\n proto = proto.substr(0, proto.length - 1);\n return module.exports[proto].get(redirectUrl, redirectCallback(reqUrl, redirect), redirect);\n };\n }\n\n return clientRequest;\n };\n }(h);\n\n // see https://github.com/joyent/node/blob/master/lib/http.js#L1623\n h.get = function(h) {\n return function(options, cb, redirectOptions) {\n var req = h.request(options, cb, redirectOptions);\n req.end();\n return req;\n };\n }(h);\n\n module.exports[protocol] = h;\n}\n","module.exports = HttpDuplex;\n\nvar util = require('util'),\n stream = require('readable-stream');\n\nutil.inherits(HttpDuplex, stream.Duplex);\n\nfunction HttpDuplex(req, res, options) {\n var self = this;\n\n if (!(self instanceof HttpDuplex)) return new HttpDuplex(req, res, options);\n\n stream.Duplex.call(self, options);\n self._output = null;\n\n self.connect(req, res);\n}\n\nHttpDuplex.prototype.connect = function(req, res) {\n var self = this;\n self.req = req;\n self._output = res;\n self.emit('response', res);\n\n res.on('data', function(c) {\n if (!self.push(c)) self._output.pause();\n });\n res.on('end', function() {\n self.push(null);\n });\n};\n\nHttpDuplex.prototype._read = function(n) {\n if (this._output) this._output.resume();\n};\n\nHttpDuplex.prototype._write = function(chunk, encoding, cb) {\n this.req.write(chunk, encoding);\n cb();\n};\n\nHttpDuplex.prototype.end = function(chunk, encoding, cb) {\n this._output.socket.destroy();\n return this.req.end(chunk, encoding, cb);\n};\n\nHttpDuplex.prototype.destroy = function() {\n this.req.destroy();\n this._output.socket.destroy();\n};\n","var querystring = require('querystring'),\n http = require('./http'),\n fs = require('fs'),\n path = require('path'),\n url = require('url'),\n ssh = require('./ssh'),\n HttpDuplex = require('./http_duplex'),\n debug = require('debug')('modem'),\n utils = require('./utils'),\n util = require('util'),\n url = require('url'),\n splitca = require('split-ca'),\n isWin = require('os').type() === 'Windows_NT';\n\nvar defaultOpts = function () {\n var host;\n var opts = {};\n\n if (!process.env.DOCKER_HOST) {\n // Windows socket path: //./pipe/docker_engine ( Windows 10 )\n // Linux & Darwin socket path: /var/run/docker.sock\n opts.socketPath = isWin ? '//./pipe/docker_engine' : '/var/run/docker.sock';\n } else if (process.env.DOCKER_HOST.indexOf('unix://') === 0) {\n // Strip off unix://, fall back to default of /var/run/docker.sock if\n // unix:// was passed without a path\n opts.socketPath = process.env.DOCKER_HOST.substring(7) || '/var/run/docker.sock';\n } else if (process.env.DOCKER_HOST.indexOf('npipe://') === 0) {\n // Strip off npipe://, fall back to default of //./pipe/docker_engine if\n // npipe:// was passed without a path\n opts.socketPath = process.env.DOCKER_HOST.substring(8) || '//./pipe/docker_engine';\n } else {\n var hostStr = process.env.DOCKER_HOST;\n if (hostStr.indexOf('\\/\\/') < 0) {\n hostStr = 'tcp://' + hostStr;\n }\n try {\n host = new url.URL(hostStr);\n } catch (err) {\n throw new Error('DOCKER_HOST env variable should be something like tcp://localhost:1234');\n }\n\n opts.port = host.port;\n\n if (process.env.DOCKER_TLS_VERIFY === '1' || opts.port === '2376') {\n opts.protocol = 'https';\n } else if (host.protocol === 'ssh:') {\n opts.protocol = 'ssh';\n opts.username = host.username;\n opts.sshOptions = {\n agent: process.env.SSH_AUTH_SOCK,\n }\n } else {\n opts.protocol = 'http';\n }\n\n opts.host = host.hostname;\n\n if (process.env.DOCKER_CERT_PATH) {\n opts.ca = splitca(path.join(process.env.DOCKER_CERT_PATH, 'ca.pem'));\n opts.cert = fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'cert.pem'));\n opts.key = fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'key.pem'));\n }\n\n if (process.env.DOCKER_CLIENT_TIMEOUT) {\n opts.timeout = parseInt(process.env.DOCKER_CLIENT_TIMEOUT, 10);\n }\n }\n\n return opts;\n};\n\n\nvar Modem = function (options) {\n var optDefaults = defaultOpts();\n var opts = Object.assign({}, optDefaults, options);\n\n this.host = opts.host;\n\n if(!this.host) {\n this.socketPath = opts.socketPath;\n }\n\n this.port = opts.port;\n this.username = opts.username;\n this.password = opts.password;\n this.version = opts.version;\n this.key = opts.key;\n this.cert = opts.cert;\n this.ca = opts.ca;\n this.timeout = opts.timeout;\n this.connectionTimeout = opts.connectionTimeout;\n this.checkServerIdentity = opts.checkServerIdentity;\n this.agent = opts.agent;\n this.headers = opts.headers || {};\n this.sshOptions = Object.assign({}, options ? options.sshOptions : {}, optDefaults.sshOptions);\n //retrocompabitlity\n if(this.sshOptions.agentForward === undefined) {\n this.sshOptions.agentForward = opts.agentForward;\n }\n\n if (this.key && this.cert && this.ca) {\n this.protocol = 'https';\n }\n this.protocol = opts.protocol || this.protocol || 'http';\n};\n\nModem.prototype.dial = function (options, callback) {\n var opts, address, data;\n var self = this;\n\n if (options.options) {\n opts = options.options;\n }\n\n // Prevent credentials from showing up in URL\n if (opts && opts.authconfig) {\n delete opts.authconfig;\n }\n\n // Prevent abortsignal from showing up in the URL\n if (opts && opts.abortSignal) {\n delete opts.abortSignal;\n }\n\n if (this.version) {\n options.path = '/' + this.version + options.path;\n }\n\n if (this.host) {\n var parsed = url.parse(self.host);\n address = url.format({\n 'protocol': parsed.protocol || self.protocol,\n 'hostname': parsed.hostname || self.host,\n 'port': self.port\n });\n address = url.resolve(address, options.path);\n } else {\n address = options.path;\n }\n\n if (options.path.indexOf('?') !== -1) {\n if (opts && Object.keys(opts).length > 0) {\n address += this.buildQuerystring(opts._query || opts);\n } else {\n address = address.substring(0, address.length - 1);\n }\n }\n\n var optionsf = {\n path: address,\n method: options.method,\n headers: options.headers || Object.assign({}, self.headers),\n key: self.key,\n cert: self.cert,\n ca: self.ca\n };\n\n if (this.checkServerIdentity) {\n optionsf.checkServerIdentity = this.checkServerIdentity;\n }\n\n if (this.agent) {\n optionsf.agent = this.agent;\n }\n\n if (options.authconfig) {\n optionsf.headers['X-Registry-Auth'] = options.authconfig.key || options.authconfig.base64 ||\n Buffer.from(JSON.stringify(options.authconfig)).toString('base64');\n }\n\n if (options.registryconfig) {\n optionsf.headers['X-Registry-Config'] = options.registryconfig.base64 ||\n Buffer.from(JSON.stringify(options.registryconfig)).toString('base64');\n }\n\n if (options.abortSignal) {\n optionsf.signal = options.abortSignal;\n }\n\n if (options.file) {\n if (typeof options.file === 'string') {\n data = fs.createReadStream(path.resolve(options.file));\n } else {\n data = options.file;\n }\n optionsf.headers['Content-Type'] = 'application/tar';\n } else if (opts && options.method === 'POST') {\n data = JSON.stringify(opts._body || opts);\n if (options.allowEmpty) {\n optionsf.headers['Content-Type'] = 'application/json';\n } else {\n if (data !== '{}' && data !== '\"\"') {\n optionsf.headers['Content-Type'] = 'application/json';\n } else {\n data = undefined;\n }\n }\n }\n\n if (typeof data === 'string') {\n optionsf.headers['Content-Length'] = Buffer.byteLength(data);\n } else if (Buffer.isBuffer(data) === true) {\n optionsf.headers['Content-Length'] = data.length;\n } else if (optionsf.method === 'PUT' || options.hijack || options.openStdin) {\n optionsf.headers['Transfer-Encoding'] = 'chunked';\n }\n\n if (options.hijack) {\n optionsf.headers.Connection = 'Upgrade';\n optionsf.headers.Upgrade = 'tcp';\n }\n\n if (this.socketPath) {\n optionsf.socketPath = this.socketPath;\n } else {\n var urlp = url.parse(address);\n optionsf.hostname = urlp.hostname;\n optionsf.port = urlp.port;\n optionsf.path = urlp.path;\n }\n\n this.buildRequest(optionsf, options, data, callback);\n};\n\nModem.prototype.buildRequest = function (options, context, data, callback) {\n var self = this;\n var connectionTimeoutTimer;\n\n var opts = self.protocol === 'ssh' ? Object.assign(options, {\n agent: ssh(Object.assign({}, self.sshOptions, {\n 'host': self.host,\n 'port': self.port,\n 'username': self.username,\n 'password': self.password,\n })),\n protocol: 'http:',\n }) : options;\n\n var req = http[self.protocol === 'ssh' ? 'http' : self.protocol].request(opts, function () { });\n\n debug('Sending: %s', util.inspect(options, {\n showHidden: true,\n depth: null\n }));\n\n if (self.connectionTimeout) {\n connectionTimeoutTimer = setTimeout(function () {\n debug('Connection Timeout of %s ms exceeded', self.connectionTimeout);\n req.abort();\n }, self.connectionTimeout);\n }\n\n if (self.timeout) {\n req.on('socket', function (socket) {\n socket.setTimeout(self.timeout);\n socket.on('timeout', function () {\n debug('Timeout of %s ms exceeded', self.timeout);\n req.abort();\n });\n });\n }\n\n if (context.hijack === true) {\n clearTimeout(connectionTimeoutTimer);\n req.on('upgrade', function (res, sock, head) {\n return callback(null, sock);\n });\n }\n\n req.on('connect', function () {\n clearTimeout(connectionTimeoutTimer);\n });\n\n req.on('disconnect', function () {\n clearTimeout(connectionTimeoutTimer);\n });\n\n req.on('response', function (res) {\n clearTimeout(connectionTimeoutTimer);\n if (context.isStream === true) {\n self.buildPayload(null, context.isStream, context.statusCodes, context.openStdin, req, res, null, callback);\n } else {\n var chunks = [];\n res.on('data', function (chunk) {\n chunks.push(chunk);\n });\n\n res.on('end', function () {\n var buffer = Buffer.concat(chunks);\n var result = buffer.toString();\n\n debug('Received: %s', result);\n\n var json = utils.parseJSON(result) || buffer;\n self.buildPayload(null, context.isStream, context.statusCodes, false, req, res, json, callback);\n });\n }\n });\n\n req.on('error', function (error) {\n clearTimeout(connectionTimeoutTimer);\n self.buildPayload(error, context.isStream, context.statusCodes, false, {}, {}, null, callback);\n });\n\n if (typeof data === 'string' || Buffer.isBuffer(data)) {\n req.write(data);\n } else if (data) {\n data.on('error', function (error) {\n req.destroy(error);\n });\n data.pipe(req);\n }\n\n if (!context.hijack && !context.openStdin && (typeof data === 'string' || data === undefined || Buffer.isBuffer(data))) {\n req.end();\n }\n};\n\nModem.prototype.buildPayload = function (err, isStream, statusCodes, openStdin, req, res, json, cb) {\n if (err) return cb(err, null);\n\n if (statusCodes[res.statusCode] !== true) {\n getCause(isStream, res, json, function (err, cause) {\n var msg = new Error(\n '(HTTP code ' + res.statusCode + ') ' +\n (statusCodes[res.statusCode] || 'unexpected') + ' - ' +\n (cause.message || cause) + ' '\n );\n msg.reason = statusCodes[res.statusCode];\n msg.statusCode = res.statusCode;\n msg.json = json;\n cb(msg, null);\n });\n } else {\n if (openStdin) {\n cb(null, new HttpDuplex(req, res));\n } else if (isStream) {\n cb(null, res);\n } else {\n cb(null, json);\n }\n }\n\n function getCause(isStream, res, json, callback) {\n var chunks = '';\n if (isStream) {\n res.on('data', function (chunk) {\n chunks += chunk;\n });\n res.on('end', function () {\n callback(null, utils.parseJSON(chunks) || chunks);\n });\n } else {\n callback(null, json);\n }\n }\n};\n\nModem.prototype.demuxStream = function (stream, stdout, stderr) {\n var nextDataType = null;\n var nextDataLength = null;\n var buffer = Buffer.from('');\n function processData(data) {\n if (data) {\n buffer = Buffer.concat([buffer, data]);\n }\n if (!nextDataType) {\n if (buffer.length >= 8) {\n var header = bufferSlice(8);\n nextDataType = header.readUInt8(0);\n nextDataLength = header.readUInt32BE(4);\n // It's possible we got a \"data\" that contains multiple messages\n // Process the next one\n processData();\n }\n } else {\n if (buffer.length >= nextDataLength) {\n var content = bufferSlice(nextDataLength);\n if (nextDataType === 1) {\n stdout.write(content);\n } else {\n stderr.write(content);\n }\n nextDataType = null;\n // It's possible we got a \"data\" that contains multiple messages\n // Process the next one\n processData();\n }\n }\n }\n\n function bufferSlice(end) {\n var out = buffer.slice(0, end);\n buffer = Buffer.from(buffer.slice(end, buffer.length));\n return out;\n }\n\n stream.on('data', processData);\n};\n\nModem.prototype.followProgress = function (stream, onFinished, onProgress) {\n var buf = '';\n var output = [];\n var finished = false;\n\n stream.on('data', onStreamEvent);\n stream.on('error', onStreamError);\n stream.on('end', onStreamEnd);\n stream.on('close', onStreamEnd);\n\n function onStreamEvent(data) {\n buf += data.toString();\n pump();\n\n function pump() {\n var pos;\n while ((pos = buf.indexOf('\\n')) >= 0) {\n if (pos == 0) {\n buf = buf.slice(1);\n continue;\n }\n processLine(buf.slice(0, pos));\n buf = buf.slice(pos + 1);\n }\n }\n\n function processLine(line) {\n if (line[line.length - 1] == '\\r') line = line.substr(0, line.length - 1);\n if (line.length > 0) {\n var obj = JSON.parse(line);\n output.push(obj);\n if (onProgress) {\n onProgress(obj);\n }\n }\n }\n };\n\n function onStreamError(err) {\n finished = true;\n stream.removeListener('data', onStreamEvent);\n stream.removeListener('error', onStreamError);\n stream.removeListener('end', onStreamEnd);\n stream.removeListener('close', onStreamEnd);\n onFinished(err, output);\n }\n\n function onStreamEnd() {\n if(!finished) onFinished(null, output);\n finished = true;\n }\n};\n\nModem.prototype.buildQuerystring = function (opts) {\n var clone = {};\n\n // serialize map values as JSON strings, else querystring truncates.\n Object.keys(opts).map(function (key, i) {\n if (opts[key]\n && typeof opts[key] === 'object'\n && !Array.isArray(opts[key])\n // Ref: https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild\n // > cachefrom (string) JSON array of images used for build cache resolution.\n || key === 'cachefrom'\n ) {\n clone[key] = JSON.stringify(opts[key]);\n } else {\n clone[key] = opts[key];\n }\n });\n\n return querystring.stringify(clone);\n};\n\nmodule.exports = Modem;\n","var Client = require('ssh2').Client,\n http = require('http');\n\nmodule.exports = function(opt) {\n var conn = new Client();\n var agent = new http.Agent();\n\n agent.createConnection = function(options, fn) {\n conn.once('ready', function() {\n conn.exec('docker system dial-stdio', function(err, stream) {\n if (err) {\n conn.end();\n agent.destroy();\n return;\n }\n\n fn(null, stream);\n\n stream.once('close', () => {\n conn.end();\n agent.destroy();\n });\n });\n }).connect(opt);\n\n conn.once('end', () => agent.destroy());\n };\n\n return agent;\n};\n","// https://github.com/HenrikJoreteg/extend-object/blob/v0.1.0/extend-object.js\n\nvar arr = [];\nvar each = arr.forEach;\nvar slice = arr.slice;\n\nmodule.exports.extend = function(obj) {\n each.call(slice.call(arguments, 1), function(source) {\n if (source) {\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n });\n return obj;\n};\n\nmodule.exports.parseJSON = function(s) {\n try {\n return JSON.parse(s);\n } catch (e) {\n return null;\n }\n};\n","var util = require('./util');\n\n/**\n * Represents a config\n * @param {Object} modem docker-modem\n * @param {String} id Config's id\n */\nvar Config = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nConfig.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nConfig.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/configs/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Update a config.\n *\n * @param {object} opts\n * @param {function} callback\n */\nConfig.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/configs/' + this.id + '/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Removes the config\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nConfig.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs/' + this.id,\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Config;\n","var extend = require('./util').extend,\n Exec = require('./exec'),\n util = require('./util');\n\n/**\n * Represents a Container\n * @param {Object} modem docker-modem\n * @param {String} id Container's ID\n */\nvar Container = function(modem, id) {\n this.modem = modem;\n this.id = id;\n\n this.defaultOptions = {\n top: {},\n start: {},\n commit: {},\n stop: {},\n pause: {},\n unpause: {},\n restart: {},\n resize: {},\n attach: {},\n remove: {},\n copy: {},\n kill: {},\n exec: {},\n rename: {},\n log: {},\n stats: {},\n getArchive: {},\n infoArchive: {},\n putArchive: {},\n update: {},\n wait: {}\n };\n};\n\nContainer.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if supplied will query Docker.\n * @return {Object} ID only and only if callback isn't supplied.\n */\nContainer.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/json?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Rename\n * @param {Object} opts Rename options\n * @param {Function} callback Callback\n */\nContainer.prototype.rename = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.rename);\n\n var optsf = {\n path: '/containers/' + this.id + '/rename?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update\n * @param {Object} opts Update options\n * @param {Function} callback Callback\n */\nContainer.prototype.update = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.update);\n\n var optsf = {\n path: '/containers/' + this.id + '/update',\n method: 'POST',\n statusCodes: {\n 200: true,\n 204: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Top\n * @param {Object} opts like 'ps_args' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.top = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.top);\n\n var optsf = {\n path: '/containers/' + this.id + '/top?',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Containers changes\n * @param {Function} callback Callback\n */\nContainer.prototype.changes = function(callback) {\n var self = this;\n var optsf = {\n path: '/containers/' + this.id + '/changes',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Checkpoints list\n * @param {Object} opts List checkpoints options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.listCheckpoint = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints?',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Delete checkpoint\n * @param {Object} opts Delete checkpoint options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.deleteCheckpoint = function(checkpoint, opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints/' + checkpoint + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Create checkpoint\n * @param {Object} opts Create checkpoint options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.createCheckpoint = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints',\n method: 'POST',\n allowEmpty: true,\n statusCodes: {\n 200: true, //unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Export\n * @param {Function} callback Callback with the octet-stream.\n */\nContainer.prototype.export = function(callback) {\n var self = this;\n var optsf = {\n path: '/containers/' + this.id + '/export',\n method: 'GET',\n isStream: true,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Start\n * @param {Object} opts Container start options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.start = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.start);\n\n var optsf = {\n path: '/containers/' + this.id + '/start?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 304: 'container already started',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Pause\n * @param {Object} opts Pause options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.pause = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.pause);\n\n var optsf = {\n path: '/containers/' + this.id + '/pause',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Unpause\n * @param {Object} opts Unpause options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.unpause = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.unpause);\n\n var optsf = {\n path: '/containers/' + this.id + '/unpause',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Setup an exec call to a running container\n *\n * @param {object} opts\n * @param {function} callback\n */\nContainer.prototype.exec = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.exec);\n\n var optsf = {\n path: '/containers/' + this.id + '/exec',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 409: 'container stopped/paused',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(new Exec(self.modem, data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, new Exec(self.modem, data.Id));\n });\n }\n};\n\n/**\n * Commit\n * @param {Object} opts Commit options like 'Hostname' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.commit = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.commit);\n\n args.opts.container = this.id;\n\n var optsf = {\n path: '/commit?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Stop\n * @param {Object} opts Container stop options, like 't' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.stop = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.stop);\n\n var optsf = {\n path: '/containers/' + this.id + '/stop?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 304: 'container already stopped',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Restart\n * @param {Object} opts Container restart options, like 't' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.restart = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.restart);\n\n var optsf = {\n path: '/containers/' + this.id + '/restart?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Kill\n * @param {Object} opts Container kill options, like 'signal' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.kill = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.kill);\n\n var optsf = {\n path: '/containers/' + this.id + '/kill?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container resize\n * @param {[type]} opts Resize options. (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.resize = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.resize);\n\n var optsf = {\n path: '/containers/' + this.id + '/resize?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Attach\n * @param {Object} opts Attach options, like 'logs' (optional)\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.attach = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.attach);\n\n var optsf = {\n path: '/containers/' + this.id + '/attach?',\n method: 'POST',\n isStream: true,\n hijack: args.opts.hijack,\n openStdin: args.opts.stdin,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, stream) {\n if (err) {\n return reject(err);\n }\n resolve(stream);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, stream) {\n args.callback(err, stream);\n });\n }\n};\n\n/**\n * Waits for a container to end.\n * @param {[type]} opts Container wait options, like condition. (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.wait = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.wait);\n\n var optsf = {\n path: '/containers/' + this.id + '/wait?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes a container\n * @param {Object} opts Remove options, like 'force' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.remove);\n\n var optsf = {\n path: '/containers/' + this.id + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Copy (WARNING: DEPRECATED since RAPI v1.20)\n * @param {Object} opts Copy options, like 'Resource' (optional)\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.copy = function(opts, callback) {\n var self = this;\n console.log('container.copy is deprecated since Docker v1.8.x');\n var args = util.processArgs(opts, callback, this.defaultOptions.copy);\n\n var optsf = {\n path: '/containers/' + this.id + '/copy',\n method: 'POST',\n isStream: true,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * getArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.getArchive = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.getArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'GET',\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * infoArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.infoArchive = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.infoArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'HEAD',\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * putArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.putArchive = function(file, opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.putArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'PUT',\n file: file,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 403: 'client error, permission denied',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nContainer.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.log);\n\n var optsf = {\n path: '/containers/' + this.id + '/logs?',\n method: 'GET',\n isStream: args.opts.follow || false,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container stats\n * @param {Object} opts Stats options. (optional)\n * @param {Function} callback Callback with data\n */\nContainer.prototype.stats = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.stats);\n var isStream = true;\n if (args.opts.stream === false) {\n isStream = false;\n }\n var optsf = {\n path: '/containers/' + this.id + '/stats?',\n method: 'GET',\n isStream: isStream,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Container;\n","var EventEmitter = require('events').EventEmitter,\n Modem = require('docker-modem'),\n tar = require('tar-fs'),\n zlib = require('zlib'),\n Container = require('./container'),\n Image = require('./image'),\n Volume = require('./volume'),\n Network = require('./network'),\n Service = require('./service'),\n Plugin = require('./plugin'),\n Secret = require('./secret'),\n Config = require('./config'),\n Task = require('./task'),\n Node = require('./node'),\n Exec = require('./exec'),\n util = require('./util'),\n extend = util.extend;\n\nvar Docker = function(opts) {\n if (!(this instanceof Docker)) return new Docker(opts);\n\n var plibrary = global.Promise;\n\n if (opts && opts.Promise) {\n plibrary = opts.Promise;\n\n if (Object.keys(opts).length === 1) {\n opts = undefined;\n }\n }\n\n this.modem = new Modem(opts);\n this.modem.Promise = plibrary;\n};\n\n/**\n * Creates a new container\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createContainer = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/containers/create?',\n method: 'POST',\n options: opts,\n authconfig: opts.authconfig,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 406: 'impossible to attach',\n 500: 'server error'\n }\n };\n\n delete opts.authconfig;\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getContainer(data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, self.getContainer(data.Id));\n });\n }\n};\n\n/**\n * Creates a new image\n * @param {Object} auth Authentication (optional)\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createImage = function(auth, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (!callback && !opts) {\n opts = auth;\n auth = opts.authconfig;\n }\n\n var optsf = {\n path: '/images/create?',\n method: 'POST',\n options: opts,\n authconfig: auth,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Load image\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.loadImage = function(file, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n\n var optsf = {\n path: '/images/load?',\n method: 'POST',\n options: opts,\n file: file,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Import image from a tar archive\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.importImage = function(file, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = undefined;\n }\n \n if (!opts)\n opts = {};\n\n opts.fromSrc = '-';\n\n var optsf = {\n path: '/images/create?',\n method: 'POST',\n options: opts,\n file: file,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Verifies auth\n * @param {Object} opts Options\n * @param {Function} callback Callback\n */\nDocker.prototype.checkAuth = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/auth',\n method: 'POST',\n options: opts,\n statusCodes: {\n 200: true,\n 204: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Builds an image\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.buildImage = function(file, opts, callback) {\n var self = this;\n var content;\n\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n\n function build(file) {\n var optsf = {\n path: '/build?',\n method: 'POST',\n file: file,\n options: opts,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (opts) {\n if (opts.registryconfig) {\n optsf.registryconfig = optsf.options.registryconfig;\n delete optsf.options.registryconfig;\n }\n\n //undocumented?\n if (opts.authconfig) {\n optsf.authconfig = optsf.options.authconfig;\n delete optsf.options.authconfig;\n }\n }\n\n if (callback === undefined) {\n return new self.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n self.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n }\n\n if (file && file.context) {\n var pack = tar.pack(file.context, {\n entries: file.src\n });\n return build(pack.pipe(zlib.createGzip()));\n } else {\n return build(file);\n }\n};\n\n/**\n * Fetches a Container by ID\n * @param {String} id Container's ID\n */\nDocker.prototype.getContainer = function(id) {\n return new Container(this.modem, id);\n};\n\n/**\n * Fetches an Image by name\n * @param {String} name Image's name\n */\nDocker.prototype.getImage = function(name) {\n return new Image(this.modem, name);\n};\n\n/**\n * Fetches a Volume by name\n * @param {String} name Volume's name\n */\nDocker.prototype.getVolume = function(name) {\n return new Volume(this.modem, name);\n};\n\n/**\n * Fetches a Plugin by name\n * @param {String} name Volume's name\n */\nDocker.prototype.getPlugin = function(name, remote) {\n return new Plugin(this.modem, name, remote);\n};\n\n/**\n * Fetches a Service by id\n * @param {String} id Services's id\n */\nDocker.prototype.getService = function(id) {\n return new Service(this.modem, id);\n};\n\n/**\n * Fetches a Task by id\n * @param {String} id Task's id\n */\nDocker.prototype.getTask = function(id) {\n return new Task(this.modem, id);\n};\n\n/**\n * Fetches Node by id\n * @param {String} id Node's id\n */\nDocker.prototype.getNode = function(id) {\n return new Node(this.modem, id);\n};\n\n/**\n * Fetches a Network by id\n * @param {String} id network's id\n */\nDocker.prototype.getNetwork = function(id) {\n return new Network(this.modem, id);\n};\n\n/**\n * Fetches a Secret by id\n * @param {String} id network's id\n */\nDocker.prototype.getSecret = function(id) {\n return new Secret(this.modem, id);\n};\n\n/**\n * Fetches a Config by id\n * @param {String} id network's id\n */\nDocker.prototype.getConfig = function(id) {\n return new Config(this.modem, id);\n};\n\n/**\n * Fetches an Exec instance by ID\n * @param {String} id Exec instance's ID\n */\nDocker.prototype.getExec = function(id) {\n return new Exec(this.modem, id);\n};\n\n/**\n * Lists containers\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listContainers = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/json?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/json?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Get images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.getImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/get?',\n method: 'GET',\n options: args.opts,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Services\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listServices = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/services?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Nodes\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listNodes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such node',\n 500: 'server error',\n 503: 'node is not part of a swarm',\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Tasks\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listTasks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/tasks?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new secret\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createSecret = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n var optsf = {\n path: '/secrets/create?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 406: 'server error or node is not part of a swarm',\n 409: 'name conflicts with an existing object',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getSecret(data.ID));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getSecret(data.ID));\n });\n }\n};\n\n\n/**\n * Creates a new config\n * @param {Object} opts Config options\n * @param {Function} callback Callback\n */\nDocker.prototype.createConfig = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n var optsf = {\n path: '/configs/create?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 406: 'server error or node is not part of a swarm',\n 409: 'name conflicts with an existing object',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getConfig(data.ID));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getConfig(data.ID));\n });\n }\n};\n\n\n/**\n * Lists secrets\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listSecrets = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists configs\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listConfigs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new plugin\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createPlugin = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/plugins/create?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getPlugin(args.opts.name));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getPlugin(args.opts.name));\n });\n }\n};\n\n\n/**\n * Lists plugins\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listPlugins = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/prune?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune builder\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneBuilder = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/build/prune',\n method: 'POST',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Prune containers\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneContainers = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/prune?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune volumes\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneVolumes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/prune?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune networks\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneNetworks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/prune?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Creates a new volume\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createVolume = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/volumes/create?',\n method: 'POST',\n allowEmpty: true,\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getVolume(data.Name));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getVolume(data.Name));\n });\n }\n};\n\n/**\n * Creates a new service\n * @param {Object} auth\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createService = function(auth, opts, callback) {\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (!opts && !callback) {\n opts = auth;\n }\n\n\n var self = this;\n var optsf = {\n path: '/services/create',\n method: 'POST',\n options: opts,\n authconfig: auth,\n statusCodes: {\n 200: true,\n 201: true,\n 500: 'server error'\n }\n };\n\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getService(data.ID || data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, self.getService(data.ID || data.Id));\n });\n }\n};\n\n/**\n * Lists volumes\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listVolumes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new network\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createNetwork = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/networks/create?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'driver not found',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getNetwork(data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getNetwork(data.Id));\n });\n }\n};\n\n/**\n * Lists networks\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listNetworks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Search images\n * @param {Object} opts Options\n * @param {Function} callback Callback\n */\nDocker.prototype.searchImages = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/images/search?',\n method: 'GET',\n options: opts,\n authconfig: opts.authconfig,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Info\n * @param {Function} callback Callback with info\n */\nDocker.prototype.info = function(callback) {\n var self = this;\n var opts = {\n path: '/info',\n method: 'GET',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Version\n * @param {Function} callback Callback\n */\nDocker.prototype.version = function(callback) {\n var self = this;\n var opts = {\n path: '/version',\n method: 'GET',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Ping\n * @param {Function} callback Callback\n */\nDocker.prototype.ping = function(callback) {\n var self = this;\n var optsf = {\n path: '/_ping',\n method: 'GET',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * SystemDf \tequivalent to system/df API Engine\n *\t\tget usage data information\n * @param {Function} callback Callback\n */\nDocker.prototype.df = function(callback) {\n var self = this;\n var optsf = {\n path: '/system/df',\n method: 'GET',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Events\n * @param {Object} opts Events options, like 'since' (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.getEvents = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/events?',\n method: 'GET',\n options: args.opts,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Pull is a wrapper around createImage, parsing image's tags.\n * @param {String} repoTag Repository tag\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n * @param {Object} auth Authentication (optional)\n * @return {Object} Image\n */\nDocker.prototype.pull = function(repoTag, opts, callback, auth) {\n var args = util.processArgs(opts, callback);\n\n var imageSrc = util.parseRepositoryTag(repoTag);\n args.opts.fromImage = imageSrc.repository;\n args.opts.tag = imageSrc.tag || 'latest';\n\n var argsf = [args.opts, args.callback];\n if (auth) {\n argsf = [auth, args.opts, args.callback];\n }\n return this.createImage.apply(this, argsf);\n};\n\n/**\n * Like run command from Docker's CLI\n * @param {String} image Image name to be used.\n * @param {Array} cmd Command to run in array format.\n * @param {Object} streamo Output stream\n * @param {Object} createOptions Container create options (optional)\n * @param {Object} startOptions Container start options (optional)\n * @param {Function} callback Callback\n * @return {Object} EventEmitter\n */\nDocker.prototype.run = function(image, cmd, streamo, createOptions, startOptions, callback) {\n if (typeof arguments[arguments.length - 1] === 'function') {\n return this.runCallback(image, cmd, streamo, createOptions, startOptions, callback);\n } else {\n return this.runPromise(image, cmd, streamo, createOptions, startOptions);\n }\n};\n\n\nDocker.prototype.runCallback = function(image, cmd, streamo, createOptions, startOptions, callback) {\n if (!callback && typeof createOptions === 'function') {\n callback = createOptions;\n createOptions = {};\n startOptions = {};\n } else if (!callback && typeof startOptions === 'function') {\n callback = startOptions;\n startOptions = {};\n }\n\n var hub = new EventEmitter();\n\n function handler(err, container) {\n if (err) return callback(err, null, container);\n\n hub.emit('container', container);\n\n container.attach({\n stream: true,\n stdout: true,\n stderr: true\n }, function handler(err, stream) {\n if (err) return callback(err, null, container);\n\n hub.emit('stream', stream);\n\n if (streamo) {\n if (streamo instanceof Array) {\n stream.on('end', function() {\n try {\n streamo[0].end();\n } catch (e) {}\n try {\n streamo[1].end();\n } catch (e) {}\n });\n container.modem.demuxStream(stream, streamo[0], streamo[1]);\n } else {\n stream.setEncoding('utf8');\n stream.pipe(streamo, {\n end: true\n });\n }\n }\n\n container.start(startOptions, function(err, data) {\n if (err) return callback(err, data, container);\n hub.emit('start', container);\n\n container.wait(function(err, data) {\n hub.emit('data', data);\n callback(err, data, container);\n });\n });\n });\n }\n\n var optsc = {\n 'Hostname': '',\n 'User': '',\n 'AttachStdin': false,\n 'AttachStdout': true,\n 'AttachStderr': true,\n 'Tty': true,\n 'OpenStdin': false,\n 'StdinOnce': false,\n 'Env': null,\n 'Cmd': cmd,\n 'Image': image,\n 'Volumes': {},\n 'VolumesFrom': []\n };\n\n extend(optsc, createOptions);\n\n this.createContainer(optsc, handler);\n\n return hub;\n};\n\nDocker.prototype.runPromise = function(image, cmd, streamo, createOptions, startOptions) {\n var self = this;\n\n createOptions = createOptions || {};\n startOptions = startOptions || {};\n\n var optsc = {\n 'Hostname': '',\n 'User': '',\n 'AttachStdin': false,\n 'AttachStdout': true,\n 'AttachStderr': true,\n 'Tty': true,\n 'OpenStdin': false,\n 'StdinOnce': false,\n 'Env': null,\n 'Cmd': cmd,\n 'Image': image,\n 'Volumes': {},\n 'VolumesFrom': []\n };\n\n extend(optsc, createOptions);\n\n var containero;\n\n return new this.modem.Promise(function(resolve, reject) {\n self.createContainer(optsc).then(function(container) {\n containero = container;\n return container.attach({\n stream: true,\n stdout: true,\n stderr: true\n });\n }).then(function(stream) {\n if (streamo) {\n if (streamo instanceof Array) {\n stream.on('end', function() {\n try {\n streamo[0].end();\n } catch (e) {}\n try {\n streamo[1].end();\n } catch (e) {}\n });\n containero.modem.demuxStream(stream, streamo[0], streamo[1]);\n } else {\n stream.setEncoding('utf8');\n stream.pipe(streamo, {\n end: true\n });\n }\n }\n return containero.start(startOptions);\n }).then(function(data) {\n return containero.wait();\n }).then(function(data) {\n resolve([data, containero]);\n }).catch(function(err) {\n reject(err);\n });\n });\n};\n\n/**\n * Init swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmInit = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/init',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Join swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmJoin = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/join',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Leave swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmLeave = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/leave?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 406: 'node is not part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmUpdate = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Inspect a Swarm.\n * Warning: This method is not documented in the API\n *\n * @param {Function} callback Callback\n */\nDocker.prototype.swarmInspect = function(callback) {\n var self = this;\n var optsf = {\n path: '/swarm',\n method: 'GET',\n statusCodes: {\n 200: true,\n 406: 'This node is not a swarm manager',\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\nDocker.Container = Container;\nDocker.Image = Image;\nDocker.Volume = Volume;\nDocker.Network = Network;\nDocker.Service = Service;\nDocker.Plugin = Plugin;\nDocker.Secret = Secret;\nDocker.Task = Task;\nDocker.Node = Node;\nDocker.Exec = Exec;\n\nmodule.exports = Docker;\n","var util = require('./util');\n\n/**\n * Represents an Exec\n * @param {Object} modem docker-modem\n * @param {String} id Exec's ID\n */\nvar Exec = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nExec.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Start the exec call that was setup.\n *\n * @param {object} opts\n * @param {function} callback\n */\nExec.prototype.start = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/start',\n method: 'POST',\n isStream: true,\n allowEmpty: true,\n hijack: args.opts.hijack,\n openStdin: args.opts.stdin,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such exec',\n 409: 'container stopped/paused',\n 500: 'container not running'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Resize the exec call that was setup.\n *\n * @param {object} opts\n * @param {function} callback\n */\nExec.prototype.resize = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/resize?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'no such exec',\n 500: 'container not running'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Get low-level information about the exec call.\n *\n * @param {function} callback\n */\nExec.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/exec/' + this.id + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such exec',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Exec;\n","var util = require('./util');\n\n/**\n * Represents an image\n * @param {Object} modem docker-modem\n * @param {String} name Image's name\n */\nvar Image = function(modem, name) {\n this.modem = modem;\n this.name = name;\n};\n\nImage.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nImage.prototype.inspect = function(callback) {\n var self = this;\n\n var opts = {\n path: '/images/' + this.name + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Distribution\n * @param {Object} opts\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nImage.prototype.distribution = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n\n var fopts = {\n path: '/distribution/' + this.name + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 401: 'no such image',\n 500: 'server error'\n },\n authconfig: (args.opts) ? args.opts.authconfig : undefined\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(fopts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(fopts, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * History\n * @param {Function} callback Callback\n */\nImage.prototype.history = function(callback) {\n var self = this;\n var opts = {\n path: '/images/' + this.name + '/history',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Get\n * @param {Function} callback Callback with data stream.\n */\nImage.prototype.get = function(callback) {\n var self = this;\n var opts = {\n path: '/images/' + this.name + '/get',\n method: 'GET',\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Push\n * @param {Object} opts Push options, like 'registry' (optional)\n * @param {Function} callback Callback with stream.\n * @param {Object} auth Registry authentication\n */\nImage.prototype.push = function(opts, callback, auth) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var isStream = true;\n if (args.opts.stream === false) {\n isStream = false;\n }\n var optsf = {\n path: '/images/' + this.name + '/push?',\n method: 'POST',\n options: args.opts,\n authconfig: args.opts.authconfig || auth,\n isStream: isStream,\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n delete optsf.options.authconfig;\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Tag\n * @param {Object} opts Tag options, like 'repo' (optional)\n * @param {Function} callback Callback\n */\nImage.prototype.tag = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/images/' + this.name + '/tag?',\n method: 'POST',\n options: opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 400: 'bad parameter',\n 404: 'no such image',\n 409: 'conflict',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Removes the image\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nImage.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n\n var optsf = {\n path: '/images/' + this.name + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Image;\n","var util = require('./util');\n\n/**\n * Represents an network\n * @param {Object} modem docker-modem\n * @param {String} id Network's id\n */\nvar Network = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nNetwork.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Id only if callback isn't specified.\n */\nNetwork.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var opts = {\n path: '/networks/' + this.id + '?',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such network',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes the network\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id,\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such network',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Connects a container to a network\n * @param {[Object]} opts Connect options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.connect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id + '/connect',\n method: 'POST',\n statusCodes: {\n 200: true,\n 201: true,\n 404: 'network or container is not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Disconnects a container from a network\n * @param {[Object]} opts Disconnect options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.disconnect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id + '/disconnect',\n method: 'POST',\n statusCodes: {\n 200: true,\n 201: true,\n 404: 'network or container is not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\n\nmodule.exports = Network;\n","var util = require('./util');\n\n/**\n * Represents an Node\n * @param {Object} modem docker-modem\n * @param {String} id Node's ID\n */\nvar Node = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nNode.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for Node details.\n *\n * @param {function} callback\n */\nNode.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/nodes/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Update a node.\n *\n * @param {object} opts\n * @param {function} callback\n */\nNode.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/nodes/' + this.id + '/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 406: 'node is not part of a swarm',\n 500: 'server error'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Remove a Node.\n * Warning: This method is not documented in the API.\n *\n * @param {object} opts\n * @param {function} callback\n */\nNode.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes/' + this.id + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Node;\n","var util = require('./util');\n\n/**\n * Represents a plugin\n * @param {Object} modem docker-modem\n * @param {String} name Plugin's name\n */\nvar Plugin = function(modem, name, remote) {\n this.modem = modem;\n this.name = name;\n this.remote = remote || name;\n};\n\nPlugin.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nPlugin.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/plugins/' + this.name,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'plugin is not installed',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Removes the plugin\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 404: 'plugin is not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * get privileges\n * @param {Function} callback Callback\n * @return {Object} Name only if callback isn't specified.\n */\nPlugin.prototype.privileges = function(callback) {\n var self = this;\n var optsf = {\n path: '/plugins/privileges?',\n method: 'GET',\n options: {\n 'remote': this.remote\n },\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Installs a new plugin\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nPlugin.prototype.pull = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n if(args.opts._query && !args.opts._query.name) {\n args.opts._query.name = this.name;\n }\n if(args.opts._query && !args.opts._query.remote) {\n args.opts._query.remote = this.remote;\n }\n\n var optsf = {\n path: '/plugins/pull?',\n method: 'POST',\n isStream: true,\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Enable\n * @param {Object} opts Plugin enable options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.enable = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/enable?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Disable\n * @param {Object} opts Plugin disable options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.disable = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/disable',\n method: 'POST',\n statusCodes: {\n 200: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Push\n * @param {Object} opts Plugin push options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.push = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/push',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * COnfigure\n * @param {Object} opts Plugin configure options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.configure = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/set',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Upgrade plugin\n *\n * @param {object} auth\n * @param {object} opts\n * @param {function} callback\n */\nPlugin.prototype.upgrade = function(auth, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n }\n\n var optsf = {\n path: '/plugins/' + this.name + '/upgrade?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n authconfig: auth,\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Plugin;\n","var util = require('./util');\n\n/**\n * Represents a secret\n * @param {Object} modem docker-modem\n * @param {String} id Secret's id\n */\nvar Secret = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nSecret.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nSecret.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/secrets/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'secret not found',\n 406: 'node is not part of a swarm',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Update a secret.\n *\n * @param {object} opts\n * @param {function} callback\n */\nSecret.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/secrets/' + this.id + '/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'secret not found',\n 500: 'server error'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Removes the secret\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nSecret.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets/' + this.id,\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'secret not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Secret;\n","var util = require('./util');\n\n/**\n * Represents an Service\n * @param {Object} modem docker-modem\n * @param {String} id Service's ID\n */\nvar Service = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nService.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for service details.\n *\n * @param {function} callback\n */\nService.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/services/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Delete Service\n *\n * @param {function} callback\n */\nService.prototype.remove = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/services/' + this.id,\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such service',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Update service\n *\n * @param {object} auth\n * @param {object} opts\n * @param {function} callback\n */\nService.prototype.update = function(auth, opts, callback) {\n var self = this;\n if (!callback) {\n var t = typeof opts;\n if(t === 'function'){\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (t === 'undefined'){\n opts = auth;\n auth = opts.authconfig || undefined;\n }\n }\n\n var optsf = {\n path: '/services/' + this.id + '/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error'\n },\n authconfig: auth,\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n\n/**\n * Service logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nService.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, {});\n\n var optsf = {\n path: '/services/' + this.id + '/logs?',\n method: 'GET',\n isStream: args.opts.follow || false,\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Service;\n","var util = require('./util');\n\n/**\n * Represents an Task\n * @param {Object} modem docker-modem\n * @param {String} id Task's ID\n */\nvar Task = function(modem, id) {\n this.modem = modem;\n this.id = id;\n\n this.defaultOptions = {\n log: {}\n };\n};\n\nTask.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for Task details.\n *\n * @param {function} callback\n */\nTask.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/tasks/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'unknown task',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Task logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nTask.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.log);\n\n var optsf = {\n path: '/tasks/' + this.id + '/logs?',\n method: 'GET',\n isStream: args.opts.follow || false,\n statusCodes: {\n 101: true,\n 200: true,\n 404: 'no such container',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Task;\n","// https://github.com/HenrikJoreteg/extend-object/blob/v0.1.0/extend-object.js\n\nvar arr = [];\nvar each = arr.forEach;\nvar slice = arr.slice;\n\nmodule.exports.extend = function(obj) {\n each.call(slice.call(arguments, 1), function(source) {\n if (source) {\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n });\n return obj;\n};\n\nmodule.exports.processArgs = function(opts, callback, defaultOpts) {\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n return {\n callback: callback,\n opts: module.exports.extend({}, defaultOpts, opts)\n };\n};\n\n\n/**\n * Parse the given repo tag name (as a string) and break it out into repo/tag pair.\n * // if given the input http://localhost:8080/woot:latest\n * {\n * repository: 'http://localhost:8080/woot',\n * tag: 'latest'\n * }\n * @param {String} input Input e.g: 'repo/foo', 'ubuntu', 'ubuntu:latest'\n * @return {Object} input parsed into the repo and tag.\n */\nmodule.exports.parseRepositoryTag = function(input) {\n var separatorPos;\n var digestPos = input.indexOf('@');\n var colonPos = input.lastIndexOf(':');\n // @ symbol is more important\n if (digestPos >= 0) {\n separatorPos = digestPos;\n } else if (colonPos >= 0) {\n separatorPos = colonPos;\n } else {\n // no colon nor @\n return {\n repository: input\n };\n }\n\n // last colon is either the tag (or part of a port designation)\n var tag = input.slice(separatorPos + 1);\n\n // if it contains a / its not a tag and is part of the url\n if (tag.indexOf('/') === -1) {\n return {\n repository: input.slice(0, separatorPos),\n tag: tag\n };\n }\n\n return {\n repository: input\n };\n};\n","var util = require('./util');\n\n/**\n * Represents a volume\n * @param {Object} modem docker-modem\n * @param {String} name Volume's name\n */\nvar Volume = function(modem, name) {\n this.modem = modem;\n this.name = name;\n};\n\nVolume.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nVolume.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/volumes/' + this.name,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such volume',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Removes the volume\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nVolume.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/' + this.name,\n method: 'DELETE',\n statusCodes: {\n 204: true,\n 404: 'no such volume',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Volume;\n","var once = require('once');\n\nvar noop = function() {};\n\nvar isRequest = function(stream) {\n\treturn stream.setHeader && typeof stream.abort === 'function';\n};\n\nvar isChildProcess = function(stream) {\n\treturn stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3\n};\n\nvar eos = function(stream, opts, callback) {\n\tif (typeof opts === 'function') return eos(stream, null, opts);\n\tif (!opts) opts = {};\n\n\tcallback = once(callback || noop);\n\n\tvar ws = stream._writableState;\n\tvar rs = stream._readableState;\n\tvar readable = opts.readable || (opts.readable !== false && stream.readable);\n\tvar writable = opts.writable || (opts.writable !== false && stream.writable);\n\tvar cancelled = false;\n\n\tvar onlegacyfinish = function() {\n\t\tif (!stream.writable) onfinish();\n\t};\n\n\tvar onfinish = function() {\n\t\twritable = false;\n\t\tif (!readable) callback.call(stream);\n\t};\n\n\tvar onend = function() {\n\t\treadable = false;\n\t\tif (!writable) callback.call(stream);\n\t};\n\n\tvar onexit = function(exitCode) {\n\t\tcallback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);\n\t};\n\n\tvar onerror = function(err) {\n\t\tcallback.call(stream, err);\n\t};\n\n\tvar onclose = function() {\n\t\tprocess.nextTick(onclosenexttick);\n\t};\n\n\tvar onclosenexttick = function() {\n\t\tif (cancelled) return;\n\t\tif (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close'));\n\t\tif (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close'));\n\t};\n\n\tvar onrequest = function() {\n\t\tstream.req.on('finish', onfinish);\n\t};\n\n\tif (isRequest(stream)) {\n\t\tstream.on('complete', onfinish);\n\t\tstream.on('abort', onclose);\n\t\tif (stream.req) onrequest();\n\t\telse stream.on('request', onrequest);\n\t} else if (writable && !ws) { // legacy streams\n\t\tstream.on('end', onlegacyfinish);\n\t\tstream.on('close', onlegacyfinish);\n\t}\n\n\tif (isChildProcess(stream)) stream.on('exit', onexit);\n\n\tstream.on('end', onend);\n\tstream.on('finish', onfinish);\n\tif (opts.error !== false) stream.on('error', onerror);\n\tstream.on('close', onclose);\n\n\treturn function() {\n\t\tcancelled = true;\n\t\tstream.removeListener('complete', onfinish);\n\t\tstream.removeListener('abort', onclose);\n\t\tstream.removeListener('request', onrequest);\n\t\tif (stream.req) stream.req.removeListener('finish', onfinish);\n\t\tstream.removeListener('end', onlegacyfinish);\n\t\tstream.removeListener('close', onlegacyfinish);\n\t\tstream.removeListener('finish', onfinish);\n\t\tstream.removeListener('exit', onexit);\n\t\tstream.removeListener('end', onend);\n\t\tstream.removeListener('error', onerror);\n\t\tstream.removeListener('close', onclose);\n\t};\n};\n\nmodule.exports = eos;\n","module.exports = require('fs').constants || require('constants')\n","'use strict';\n\nmodule.exports = (flag, argv = process.argv) => {\n\tconst prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');\n\tconst position = argv.indexOf(prefix + flag);\n\tconst terminatorPosition = argv.indexOf('--');\n\treturn position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n};\n","try {\n var util = require('util');\n /* istanbul ignore next */\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n /* istanbul ignore next */\n module.exports = require('./inherits_browser.js');\n}\n","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n }\n}\n","var path = require('path');\nvar fs = require('fs');\nvar _0777 = parseInt('0777', 8);\n\nmodule.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;\n\nfunction mkdirP (p, opts, f, made) {\n if (typeof opts === 'function') {\n f = opts;\n opts = {};\n }\n else if (!opts || typeof opts !== 'object') {\n opts = { mode: opts };\n }\n \n var mode = opts.mode;\n var xfs = opts.fs || fs;\n \n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n \n var cb = f || function () {};\n p = path.resolve(p);\n \n xfs.mkdir(p, mode, function (er) {\n if (!er) {\n made = made || p;\n return cb(null, made);\n }\n switch (er.code) {\n case 'ENOENT':\n mkdirP(path.dirname(p), opts, function (er, made) {\n if (er) cb(er, made);\n else mkdirP(p, opts, cb, made);\n });\n break;\n\n // In the case of any other error, just see if there's a dir\n // there already. If so, then hooray! If not, then something\n // is borked.\n default:\n xfs.stat(p, function (er2, stat) {\n // if the stat fails, then that's super weird.\n // let the original error be the failure reason.\n if (er2 || !stat.isDirectory()) cb(er, made)\n else cb(null, made);\n });\n break;\n }\n });\n}\n\nmkdirP.sync = function sync (p, opts, made) {\n if (!opts || typeof opts !== 'object') {\n opts = { mode: opts };\n }\n \n var mode = opts.mode;\n var xfs = opts.fs || fs;\n \n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n\n p = path.resolve(p);\n\n try {\n xfs.mkdirSync(p, mode);\n made = made || p;\n }\n catch (err0) {\n switch (err0.code) {\n case 'ENOENT' :\n made = sync(path.dirname(p), opts, made);\n sync(p, opts, made);\n break;\n\n // In the case of any other error, just see if there's a dir\n // there already. If so, then hooray! If not, then something\n // is borked.\n default:\n var stat;\n try {\n stat = xfs.statSync(p);\n }\n catch (err1) {\n throw err0;\n }\n if (!stat.isDirectory()) throw err0;\n break;\n }\n }\n\n return made;\n};\n","/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n","var wrappy = require('wrappy')\nmodule.exports = wrappy(once)\nmodule.exports.strict = wrappy(onceStrict)\n\nonce.proto = once(function () {\n Object.defineProperty(Function.prototype, 'once', {\n value: function () {\n return once(this)\n },\n configurable: true\n })\n\n Object.defineProperty(Function.prototype, 'onceStrict', {\n value: function () {\n return onceStrict(this)\n },\n configurable: true\n })\n})\n\nfunction once (fn) {\n var f = function () {\n if (f.called) return f.value\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n f.called = false\n return f\n}\n\nfunction onceStrict (fn) {\n var f = function () {\n if (f.called)\n throw new Error(f.onceError)\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n var name = fn.name || 'Function wrapped with `once`'\n f.onceError = name + \" shouldn't be called more than once\"\n f.called = false\n return f\n}\n","var once = require('once')\nvar eos = require('end-of-stream')\nvar fs = require('fs') // we only need fs to get the ReadStream and WriteStream prototypes\n\nvar noop = function () {}\nvar ancient = /^v?\\.0/.test(process.version)\n\nvar isFn = function (fn) {\n return typeof fn === 'function'\n}\n\nvar isFS = function (stream) {\n if (!ancient) return false // newer node version do not need to care about fs is a special way\n if (!fs) return false // browser\n return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close)\n}\n\nvar isRequest = function (stream) {\n return stream.setHeader && isFn(stream.abort)\n}\n\nvar destroyer = function (stream, reading, writing, callback) {\n callback = once(callback)\n\n var closed = false\n stream.on('close', function () {\n closed = true\n })\n\n eos(stream, {readable: reading, writable: writing}, function (err) {\n if (err) return callback(err)\n closed = true\n callback()\n })\n\n var destroyed = false\n return function (err) {\n if (closed) return\n if (destroyed) return\n destroyed = true\n\n if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks\n if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want\n\n if (isFn(stream.destroy)) return stream.destroy()\n\n callback(err || new Error('stream was destroyed'))\n }\n}\n\nvar call = function (fn) {\n fn()\n}\n\nvar pipe = function (from, to) {\n return from.pipe(to)\n}\n\nvar pump = function () {\n var streams = Array.prototype.slice.call(arguments)\n var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop\n\n if (Array.isArray(streams[0])) streams = streams[0]\n if (streams.length < 2) throw new Error('pump requires two streams per minimum')\n\n var error\n var destroys = streams.map(function (stream, i) {\n var reading = i < streams.length - 1\n var writing = i > 0\n return destroyer(stream, reading, writing, function (err) {\n if (!error) error = err\n if (err) destroys.forEach(call)\n if (reading) return\n destroys.forEach(call)\n callback(error)\n })\n })\n\n return streams.reduce(pipe)\n}\n\nmodule.exports = pump\n","'use strict';\n\nconst codes = {};\n\nfunction createErrorType(code, message, Base) {\n if (!Base) {\n Base = Error\n }\n\n function getMessage (arg1, arg2, arg3) {\n if (typeof message === 'string') {\n return message\n } else {\n return message(arg1, arg2, arg3)\n }\n }\n\n class NodeError extends Base {\n constructor (arg1, arg2, arg3) {\n super(getMessage(arg1, arg2, arg3));\n }\n }\n\n NodeError.prototype.name = Base.name;\n NodeError.prototype.code = code;\n\n codes[code] = NodeError;\n}\n\n// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js\nfunction oneOf(expected, thing) {\n if (Array.isArray(expected)) {\n const len = expected.length;\n expected = expected.map((i) => String(i));\n if (len > 2) {\n return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +\n expected[len - 1];\n } else if (len === 2) {\n return `one of ${thing} ${expected[0]} or ${expected[1]}`;\n } else {\n return `of ${thing} ${expected[0]}`;\n }\n } else {\n return `of ${thing} ${String(expected)}`;\n }\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\nfunction startsWith(str, search, pos) {\n\treturn str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith\nfunction endsWith(str, search, this_len) {\n\tif (this_len === undefined || this_len > str.length) {\n\t\tthis_len = str.length;\n\t}\n\treturn str.substring(this_len - search.length, this_len) === search;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes\nfunction includes(str, search, start) {\n if (typeof start !== 'number') {\n start = 0;\n }\n\n if (start + search.length > str.length) {\n return false;\n } else {\n return str.indexOf(search, start) !== -1;\n }\n}\n\ncreateErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {\n return 'The value \"' + value + '\" is invalid for option \"' + name + '\"'\n}, TypeError);\ncreateErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {\n // determiner: 'must be' or 'must not be'\n let determiner;\n if (typeof expected === 'string' && startsWith(expected, 'not ')) {\n determiner = 'must not be';\n expected = expected.replace(/^not /, '');\n } else {\n determiner = 'must be';\n }\n\n let msg;\n if (endsWith(name, ' argument')) {\n // For cases like 'first argument'\n msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;\n } else {\n const type = includes(name, '.') ? 'property' : 'argument';\n msg = `The \"${name}\" ${type} ${determiner} ${oneOf(expected, 'type')}`;\n }\n\n msg += `. Received type ${typeof actual}`;\n return msg;\n}, TypeError);\ncreateErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');\ncreateErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {\n return 'The ' + name + ' method is not implemented'\n});\ncreateErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');\ncreateErrorType('ERR_STREAM_DESTROYED', function (name) {\n return 'Cannot call ' + name + ' after a stream was destroyed';\n});\ncreateErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');\ncreateErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');\ncreateErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');\ncreateErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);\ncreateErrorType('ERR_UNKNOWN_ENCODING', function (arg) {\n return 'Unknown encoding: ' + arg\n}, TypeError);\ncreateErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');\n\nmodule.exports.codes = codes;\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n'use strict';\n/**/\n\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n\n for (var key in obj) {\n keys.push(key);\n }\n\n return keys;\n};\n/**/\n\n\nmodule.exports = Duplex;\n\nvar Readable = require('./_stream_readable');\n\nvar Writable = require('./_stream_writable');\n\nrequire('inherits')(Duplex, Readable);\n\n{\n // Allow the keys array to be GC'ed.\n var keys = objectKeys(Writable.prototype);\n\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n Readable.call(this, options);\n Writable.call(this, options);\n this.allowHalfOpen = true;\n\n if (options) {\n if (options.readable === false) this.readable = false;\n if (options.writable === false) this.writable = false;\n\n if (options.allowHalfOpen === false) {\n this.allowHalfOpen = false;\n this.once('end', onend);\n }\n }\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.highWaterMark;\n }\n});\nObject.defineProperty(Duplex.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\nObject.defineProperty(Duplex.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.length;\n }\n}); // the no-half-open enforcer\n\nfunction onend() {\n // If the writable side ended, then we're ok.\n if (this._writableState.ended) return; // no more data can be written.\n // But allow more writes to happen in this tick.\n\n process.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\nrequire('inherits')(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n'use strict';\n\nmodule.exports = Readable;\n/**/\n\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n/**/\n\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function EElistenerCount(emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\n\n\nvar Stream = require('./internal/streams/stream');\n/**/\n\n\nvar Buffer = require('buffer').Buffer;\n\nvar OurUint8Array = global.Uint8Array || function () {};\n\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\n\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n/**/\n\n\nvar debugUtil = require('util');\n\nvar debug;\n\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function debug() {};\n}\n/**/\n\n\nvar BufferList = require('./internal/streams/buffer_list');\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nvar _require = require('./internal/streams/state'),\n getHighWaterMark = _require.getHighWaterMark;\n\nvar _require$codes = require('../errors').codes,\n ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,\n ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.\n\n\nvar StringDecoder;\nvar createReadableStreamAsyncIterator;\nvar from;\n\nrequire('inherits')(Readable, Stream);\n\nvar errorOrDestroy = destroyImpl.errorOrDestroy;\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream, isDuplex) {\n Duplex = Duplex || require('./_stream_duplex');\n options = options || {}; // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n\n this.objectMode = !!options.objectMode;\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n\n this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n\n this.sync = true; // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n this.paused = true; // Should close be emitted on destroy. Defaults to true.\n\n this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')\n\n this.autoDestroy = !!options.autoDestroy; // has it been destroyed\n\n this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n\n this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s\n\n this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled\n\n this.readingMore = false;\n this.decoder = null;\n this.encoding = null;\n\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside\n // the ReadableState constructor, at least with V8 6.5\n\n var isDuplex = this instanceof Duplex;\n this._readableState = new ReadableState(options, this, isDuplex); // legacy\n\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._readableState === undefined) {\n return false;\n }\n\n return this._readableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._readableState.destroyed = value;\n }\n});\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\n\nReadable.prototype._destroy = function (err, cb) {\n cb(err);\n}; // Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\n\n\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n}; // Unshift should *always* be something directly out of read()\n\n\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n debug('readableAddChunk', chunk);\n var state = stream._readableState;\n\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n\n if (er) {\n errorOrDestroy(stream, er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());\n } else if (state.destroyed) {\n return false;\n } else {\n state.reading = false;\n\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n maybeReadMore(stream, state);\n }\n } // We can push more data if we are below the highWaterMark.\n // Also, if we have no data yet, we can stand some more bytes.\n // This is to work around cases where hwm=0, such as the repl.\n\n\n return !state.ended && (state.length < state.highWaterMark || state.length === 0);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n state.awaitDrain = 0;\n stream.emit('data', chunk);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n if (state.needReadable) emitReadable(stream);\n }\n\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);\n }\n\n return er;\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n}; // backwards compatibility.\n\n\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n var decoder = new StringDecoder(enc);\n this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8\n\n this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:\n\n var p = this._readableState.buffer.head;\n var content = '';\n\n while (p !== null) {\n content += decoder.write(p.data);\n p = p.next;\n }\n\n this._readableState.buffer.clear();\n\n if (content !== '') this._readableState.buffer.push(content);\n this._readableState.length = content.length;\n return this;\n}; // Don't raise the hwm > 1GB\n\n\nvar MAX_HWM = 0x40000000;\n\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n\n return n;\n} // This function is designed to be inlinable, so please take care when making\n// changes to the function body.\n\n\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n } // If we're asking for more than the current hwm, then raise the hwm.\n\n\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n; // Don't have enough\n\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n\n return state.length;\n} // you can override either this method, or the async _read(n) below.\n\n\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n\n if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.\n\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n } // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n // if we need a readable event, then we need to do some reading.\n\n\n var doRead = state.needReadable;\n debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some\n\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n } // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n\n\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true; // if the length is currently zero, then we *need* a readable event.\n\n if (state.length === 0) state.needReadable = true; // call internal read method\n\n this._read(state.highWaterMark);\n\n state.sync = false; // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = state.length <= state.highWaterMark;\n n = 0;\n } else {\n state.length -= n;\n state.awaitDrain = 0;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.\n\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n debug('onEofChunk');\n if (state.ended) return;\n\n if (state.decoder) {\n var chunk = state.decoder.end();\n\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n\n state.ended = true;\n\n if (state.sync) {\n // if we are sync, wait until next tick to emit the data.\n // Otherwise we risk emitting data in the flow()\n // the readable code triggers during a read() call\n emitReadable(stream);\n } else {\n // emit 'readable' now to make sure it gets picked up.\n state.needReadable = false;\n\n if (!state.emittedReadable) {\n state.emittedReadable = true;\n emitReadable_(stream);\n }\n }\n} // Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\n\n\nfunction emitReadable(stream) {\n var state = stream._readableState;\n debug('emitReadable', state.needReadable, state.emittedReadable);\n state.needReadable = false;\n\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n process.nextTick(emitReadable_, stream);\n }\n}\n\nfunction emitReadable_(stream) {\n var state = stream._readableState;\n debug('emitReadable_', state.destroyed, state.length, state.ended);\n\n if (!state.destroyed && (state.length || state.ended)) {\n stream.emit('readable');\n state.emittedReadable = false;\n } // The stream needs another readable event if\n // 1. It is not flowing, as the flow mechanism will take\n // care of it.\n // 2. It is not ended.\n // 3. It is below the highWaterMark, so we can schedule\n // another readable later.\n\n\n state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;\n flow(stream);\n} // at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\n\n\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n process.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n // Attempt to read more data if we should.\n //\n // The conditions for reading more data are (one of):\n // - Not enough data buffered (state.length < state.highWaterMark). The loop\n // is responsible for filling the buffer with enough data if such data\n // is available. If highWaterMark is 0 and we are not in the flowing mode\n // we should _not_ attempt to buffer any extra data. We'll get more data\n // when the stream consumer calls read() instead.\n // - No data in the buffer, and the stream is in flowing mode. In this mode\n // the loop below is responsible for ensuring read() is called. Failing to\n // call read here would abort the flow and there's no other mechanism for\n // continuing the flow if the stream consumer has just subscribed to the\n // 'data' event.\n //\n // In addition to the above conditions to keep reading data, the following\n // conditions prevent the data from being read:\n // - The stream has ended (state.ended).\n // - There is already a pending 'read' operation (state.reading). This is a\n // case where the the stream has called the implementation defined _read()\n // method, but they are processing the call asynchronously and have _not_\n // called push() with new data. In this case we skip performing more\n // read()s. The execution ends in this method again after the _read() ends\n // up calling push() with more data.\n while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {\n var len = state.length;\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length) // didn't get any data, stop spinning.\n break;\n }\n\n state.readingMore = false;\n} // abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\n\n\nReadable.prototype._read = function (n) {\n errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n\n default:\n state.pipes.push(dest);\n break;\n }\n\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);\n dest.on('unpipe', onunpipe);\n\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n } // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n\n\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n var cleanedUp = false;\n\n function cleanup() {\n debug('cleanup'); // cleanup event handlers once the pipe is broken\n\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n cleanedUp = true; // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n src.on('data', ondata);\n\n function ondata(chunk) {\n debug('ondata');\n var ret = dest.write(chunk);\n debug('dest.write', ret);\n\n if (ret === false) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', state.awaitDrain);\n state.awaitDrain++;\n }\n\n src.pause();\n }\n } // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n\n\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);\n } // Make sure our error handler is attached before userland ones.\n\n\n prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.\n\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n\n dest.once('close', onclose);\n\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n } // tell the dest that it's being piped to\n\n\n dest.emit('pipe', src); // start the flow if it hasn't been started already.\n\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function pipeOnDrainFunctionResult() {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = {\n hasUnpiped: false\n }; // if we're not piping anywhere, then do nothing.\n\n if (state.pipesCount === 0) return this; // just one destination. most common case.\n\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n if (!dest) dest = state.pipes; // got a match.\n\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n } // slow case. multiple pipe destinations.\n\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, {\n hasUnpiped: false\n });\n }\n\n return this;\n } // try to find the right one.\n\n\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n dest.emit('unpipe', this, unpipeInfo);\n return this;\n}; // set up data events if they are asked for\n// Ensure readable listeners eventually get something\n\n\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n var state = this._readableState;\n\n if (ev === 'data') {\n // update readableListening so that resume() may be a no-op\n // a few lines down. This is needed to support once('readable').\n state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused\n\n if (state.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.flowing = false;\n state.emittedReadable = false;\n debug('on readable', state.length, state.reading);\n\n if (state.length) {\n emitReadable(this);\n } else if (!state.reading) {\n process.nextTick(nReadingNextTick, this);\n }\n }\n }\n\n return res;\n};\n\nReadable.prototype.addListener = Readable.prototype.on;\n\nReadable.prototype.removeListener = function (ev, fn) {\n var res = Stream.prototype.removeListener.call(this, ev, fn);\n\n if (ev === 'readable') {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nReadable.prototype.removeAllListeners = function (ev) {\n var res = Stream.prototype.removeAllListeners.apply(this, arguments);\n\n if (ev === 'readable' || ev === undefined) {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nfunction updateReadableListening(self) {\n var state = self._readableState;\n state.readableListening = self.listenerCount('readable') > 0;\n\n if (state.resumeScheduled && !state.paused) {\n // flowing needs to be set to true now, otherwise\n // the upcoming resume will not flow.\n state.flowing = true; // crude way to check if we should resume\n } else if (self.listenerCount('data') > 0) {\n self.resume();\n }\n}\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n} // pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\n\n\nReadable.prototype.resume = function () {\n var state = this._readableState;\n\n if (!state.flowing) {\n debug('resume'); // we flow only if there is no one listening\n // for readable, but we still have to call\n // resume()\n\n state.flowing = !state.readableListening;\n resume(this, state);\n }\n\n state.paused = false;\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n process.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n debug('resume', state.reading);\n\n if (!state.reading) {\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n\n if (this._readableState.flowing !== false) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n\n this._readableState.paused = true;\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n\n while (state.flowing && stream.read() !== null) {\n ;\n }\n} // wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\n\n\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n stream.on('end', function () {\n debug('wrapped end');\n\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode\n\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n\n if (!ret) {\n paused = true;\n stream.pause();\n }\n }); // proxy all the other methods.\n // important when wrapping filters and duplexes.\n\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function methodWrap(method) {\n return function methodWrapReturnFunction() {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n } // proxy certain important events.\n\n\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n } // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n\n\n this._read = function (n) {\n debug('wrapped _read', n);\n\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nif (typeof Symbol === 'function') {\n Readable.prototype[Symbol.asyncIterator] = function () {\n if (createReadableStreamAsyncIterator === undefined) {\n createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');\n }\n\n return createReadableStreamAsyncIterator(this);\n };\n}\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.highWaterMark;\n }\n});\nObject.defineProperty(Readable.prototype, 'readableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState && this._readableState.buffer;\n }\n});\nObject.defineProperty(Readable.prototype, 'readableFlowing', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.flowing;\n },\n set: function set(state) {\n if (this._readableState) {\n this._readableState.flowing = state;\n }\n }\n}); // exposed for testing purposes only.\n\nReadable._fromList = fromList;\nObject.defineProperty(Readable.prototype, 'readableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.length;\n }\n}); // Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\n\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = state.buffer.consume(n, state.decoder);\n }\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n debug('endReadable', state.endEmitted);\n\n if (!state.endEmitted) {\n state.ended = true;\n process.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.\n\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n\n if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the writable side is ready for autoDestroy as well\n var wState = stream._writableState;\n\n if (!wState || wState.autoDestroy && wState.finished) {\n stream.destroy();\n }\n }\n }\n}\n\nif (typeof Symbol === 'function') {\n Readable.from = function (iterable, opts) {\n if (from === undefined) {\n from = require('./internal/streams/from');\n }\n\n return from(Readable, iterable, opts);\n };\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n'use strict';\n\nmodule.exports = Transform;\n\nvar _require$codes = require('../errors').codes,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,\n ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,\n ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;\n\nvar Duplex = require('./_stream_duplex');\n\nrequire('inherits')(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n var cb = ts.writecb;\n\n if (cb === null) {\n return this.emit('error', new ERR_MULTIPLE_CALLBACK());\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n cb(er);\n var rs = this._readableState;\n rs.reading = false;\n\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n Duplex.call(this, options);\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n }; // start out asking for a readable event once data is transformed.\n\n this._readableState.needReadable = true; // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n if (typeof options.flush === 'function') this._flush = options.flush;\n } // When the writable side finishes, then flush out anything remaining.\n\n\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function' && !this._readableState.destroyed) {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n}; // This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\n\n\nTransform.prototype._transform = function (chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n}; // Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\n\n\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && !ts.transforming) {\n ts.transforming = true;\n\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data); // TODO(BridgeAR): Write a test for these two error cases\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n\n if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();\n if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n'use strict';\n\nmodule.exports = Writable;\n/* */\n\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n} // It seems a linked list but it is not\n// there will be only 2 of these for each stream\n\n\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\n\n\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n/**/\n\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\n\nvar Stream = require('./internal/streams/stream');\n/**/\n\n\nvar Buffer = require('buffer').Buffer;\n\nvar OurUint8Array = global.Uint8Array || function () {};\n\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\n\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nvar _require = require('./internal/streams/state'),\n getHighWaterMark = _require.getHighWaterMark;\n\nvar _require$codes = require('../errors').codes,\n ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,\n ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,\n ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,\n ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,\n ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,\n ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;\n\nvar errorOrDestroy = destroyImpl.errorOrDestroy;\n\nrequire('inherits')(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream, isDuplex) {\n Duplex = Duplex || require('./_stream_duplex');\n options = options || {}; // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream,\n // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.\n\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n\n this.objectMode = !!options.objectMode;\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n\n this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called\n\n this.finalCalled = false; // drain event flag.\n\n this.needDrain = false; // at the start of calling end()\n\n this.ending = false; // when end() has been called, and returned\n\n this.ended = false; // when 'finish' is emitted\n\n this.finished = false; // has it been destroyed\n\n this.destroyed = false; // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n\n this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n\n this.length = 0; // a flag to see when we're in the middle of a write.\n\n this.writing = false; // when true all writes will be buffered until .uncork() call\n\n this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n\n this.sync = true; // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n\n this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)\n\n this.onwrite = function (er) {\n onwrite(stream, er);\n }; // the callback that the user supplies to write(chunk,encoding,cb)\n\n\n this.writecb = null; // the amount that is being written when _write is called.\n\n this.writelen = 0;\n this.bufferedRequest = null;\n this.lastBufferedRequest = null; // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n\n this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n\n this.prefinished = false; // True if the error was already emitted and should not be thrown again\n\n this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.\n\n this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')\n\n this.autoDestroy = !!options.autoDestroy; // count buffered requests\n\n this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n\n while (current) {\n out.push(current);\n current = current.next;\n }\n\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function writableStateBufferGetter() {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})(); // Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\n\n\nvar realHasInstance;\n\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function value(object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function realHasInstance(object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n // Checking for a Stream.Duplex instance is faster here instead of inside\n // the WritableState constructor, at least with V8 6.5\n\n var isDuplex = this instanceof Duplex;\n if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);\n this._writableState = new WritableState(options, this, isDuplex); // legacy.\n\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n if (typeof options.writev === 'function') this._writev = options.writev;\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n} // Otherwise people can pipe Writable streams, which is just wrong.\n\n\nWritable.prototype.pipe = function () {\n errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb\n\n errorOrDestroy(stream, er);\n process.nextTick(cb, er);\n} // Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\n\n\nfunction validChunk(stream, state, chunk, cb) {\n var er;\n\n if (chunk === null) {\n er = new ERR_STREAM_NULL_VALUES();\n } else if (typeof chunk !== 'string' && !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);\n }\n\n if (er) {\n errorOrDestroy(stream, er);\n process.nextTick(cb, er);\n return false;\n }\n\n return true;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n if (typeof cb !== 'function') cb = nop;\n if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n return ret;\n};\n\nWritable.prototype.cork = function () {\n this._writableState.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.highWaterMark;\n }\n}); // if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\n\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n\n var len = state.objectMode ? 1 : chunk.length;\n state.length += len;\n var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.\n\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n process.nextTick(cb, er); // this can emit finish, and it will always happen\n // after error\n\n process.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n errorOrDestroy(stream, er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n errorOrDestroy(stream, er); // this can emit finish, but finish must\n // always follow error\n\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();\n onwriteStateUpdate(state);\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state) || stream.destroyed;\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n process.nextTick(afterWrite, stream, state, finished, cb);\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n} // Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\n\n\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it\n\n\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n var count = 0;\n var allBuffers = true;\n\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n\n buffer.allBuffers = allBuffers;\n doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n\n state.pendingcb++;\n state.lastBufferedRequest = null;\n\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks\n\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n } // ignore unnecessary end() calls.\n\n\n if (!state.ending) endWritable(this, state, cb);\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.length;\n }\n});\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\n\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n\n if (err) {\n errorOrDestroy(stream, err);\n }\n\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\n\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function' && !state.destroyed) {\n state.pendingcb++;\n state.finalCalled = true;\n process.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n\n if (need) {\n prefinish(stream, state);\n\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n\n if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the readable side is ready for autoDestroy as well\n var rState = stream._readableState;\n\n if (!rState || rState.autoDestroy && rState.endEmitted) {\n stream.destroy();\n }\n }\n }\n }\n\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n\n if (cb) {\n if (state.finished) process.nextTick(cb);else stream.once('finish', cb);\n }\n\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n } // reuse the free corkReq.\n\n\n state.corkedRequestsFree.next = corkReq;\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._writableState === undefined) {\n return false;\n }\n\n return this._writableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._writableState.destroyed = value;\n }\n});\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\n\nWritable.prototype._destroy = function (err, cb) {\n cb(err);\n};","'use strict';\n\nvar _Object$setPrototypeO;\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar finished = require('./end-of-stream');\n\nvar kLastResolve = Symbol('lastResolve');\nvar kLastReject = Symbol('lastReject');\nvar kError = Symbol('error');\nvar kEnded = Symbol('ended');\nvar kLastPromise = Symbol('lastPromise');\nvar kHandlePromise = Symbol('handlePromise');\nvar kStream = Symbol('stream');\n\nfunction createIterResult(value, done) {\n return {\n value: value,\n done: done\n };\n}\n\nfunction readAndResolve(iter) {\n var resolve = iter[kLastResolve];\n\n if (resolve !== null) {\n var data = iter[kStream].read(); // we defer if data is null\n // we can be expecting either 'end' or\n // 'error'\n\n if (data !== null) {\n iter[kLastPromise] = null;\n iter[kLastResolve] = null;\n iter[kLastReject] = null;\n resolve(createIterResult(data, false));\n }\n }\n}\n\nfunction onReadable(iter) {\n // we wait for the next tick, because it might\n // emit an error with process.nextTick\n process.nextTick(readAndResolve, iter);\n}\n\nfunction wrapForNext(lastPromise, iter) {\n return function (resolve, reject) {\n lastPromise.then(function () {\n if (iter[kEnded]) {\n resolve(createIterResult(undefined, true));\n return;\n }\n\n iter[kHandlePromise](resolve, reject);\n }, reject);\n };\n}\n\nvar AsyncIteratorPrototype = Object.getPrototypeOf(function () {});\nvar ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {\n get stream() {\n return this[kStream];\n },\n\n next: function next() {\n var _this = this;\n\n // if we have detected an error in the meanwhile\n // reject straight away\n var error = this[kError];\n\n if (error !== null) {\n return Promise.reject(error);\n }\n\n if (this[kEnded]) {\n return Promise.resolve(createIterResult(undefined, true));\n }\n\n if (this[kStream].destroyed) {\n // We need to defer via nextTick because if .destroy(err) is\n // called, the error will be emitted via nextTick, and\n // we cannot guarantee that there is no error lingering around\n // waiting to be emitted.\n return new Promise(function (resolve, reject) {\n process.nextTick(function () {\n if (_this[kError]) {\n reject(_this[kError]);\n } else {\n resolve(createIterResult(undefined, true));\n }\n });\n });\n } // if we have multiple next() calls\n // we will wait for the previous Promise to finish\n // this logic is optimized to support for await loops,\n // where next() is only called once at a time\n\n\n var lastPromise = this[kLastPromise];\n var promise;\n\n if (lastPromise) {\n promise = new Promise(wrapForNext(lastPromise, this));\n } else {\n // fast path needed to support multiple this.push()\n // without triggering the next() queue\n var data = this[kStream].read();\n\n if (data !== null) {\n return Promise.resolve(createIterResult(data, false));\n }\n\n promise = new Promise(this[kHandlePromise]);\n }\n\n this[kLastPromise] = promise;\n return promise;\n }\n}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {\n return this;\n}), _defineProperty(_Object$setPrototypeO, \"return\", function _return() {\n var _this2 = this;\n\n // destroy(err, cb) is a private API\n // we can guarantee we have that here, because we control the\n // Readable class this is attached to\n return new Promise(function (resolve, reject) {\n _this2[kStream].destroy(null, function (err) {\n if (err) {\n reject(err);\n return;\n }\n\n resolve(createIterResult(undefined, true));\n });\n });\n}), _Object$setPrototypeO), AsyncIteratorPrototype);\n\nvar createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {\n var _Object$create;\n\n var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {\n value: stream,\n writable: true\n }), _defineProperty(_Object$create, kLastResolve, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kLastReject, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kError, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kEnded, {\n value: stream._readableState.endEmitted,\n writable: true\n }), _defineProperty(_Object$create, kHandlePromise, {\n value: function value(resolve, reject) {\n var data = iterator[kStream].read();\n\n if (data) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n resolve(createIterResult(data, false));\n } else {\n iterator[kLastResolve] = resolve;\n iterator[kLastReject] = reject;\n }\n },\n writable: true\n }), _Object$create));\n iterator[kLastPromise] = null;\n finished(stream, function (err) {\n if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {\n var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise\n // returned by next() and store the error\n\n if (reject !== null) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n reject(err);\n }\n\n iterator[kError] = err;\n return;\n }\n\n var resolve = iterator[kLastResolve];\n\n if (resolve !== null) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n resolve(createIterResult(undefined, true));\n }\n\n iterator[kEnded] = true;\n });\n stream.on('readable', onReadable.bind(null, iterator));\n return iterator;\n};\n\nmodule.exports = createReadableStreamAsyncIterator;","'use strict';\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar _require = require('buffer'),\n Buffer = _require.Buffer;\n\nvar _require2 = require('util'),\n inspect = _require2.inspect;\n\nvar custom = inspect && inspect.custom || 'inspect';\n\nfunction copyBuffer(src, target, offset) {\n Buffer.prototype.copy.call(src, target, offset);\n}\n\nmodule.exports =\n/*#__PURE__*/\nfunction () {\n function BufferList() {\n _classCallCheck(this, BufferList);\n\n this.head = null;\n this.tail = null;\n this.length = 0;\n }\n\n _createClass(BufferList, [{\n key: \"push\",\n value: function push(v) {\n var entry = {\n data: v,\n next: null\n };\n if (this.length > 0) this.tail.next = entry;else this.head = entry;\n this.tail = entry;\n ++this.length;\n }\n }, {\n key: \"unshift\",\n value: function unshift(v) {\n var entry = {\n data: v,\n next: this.head\n };\n if (this.length === 0) this.tail = entry;\n this.head = entry;\n ++this.length;\n }\n }, {\n key: \"shift\",\n value: function shift() {\n if (this.length === 0) return;\n var ret = this.head.data;\n if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;\n --this.length;\n return ret;\n }\n }, {\n key: \"clear\",\n value: function clear() {\n this.head = this.tail = null;\n this.length = 0;\n }\n }, {\n key: \"join\",\n value: function join(s) {\n if (this.length === 0) return '';\n var p = this.head;\n var ret = '' + p.data;\n\n while (p = p.next) {\n ret += s + p.data;\n }\n\n return ret;\n }\n }, {\n key: \"concat\",\n value: function concat(n) {\n if (this.length === 0) return Buffer.alloc(0);\n var ret = Buffer.allocUnsafe(n >>> 0);\n var p = this.head;\n var i = 0;\n\n while (p) {\n copyBuffer(p.data, ret, i);\n i += p.data.length;\n p = p.next;\n }\n\n return ret;\n } // Consumes a specified amount of bytes or characters from the buffered data.\n\n }, {\n key: \"consume\",\n value: function consume(n, hasStrings) {\n var ret;\n\n if (n < this.head.data.length) {\n // `slice` is the same for buffers and strings.\n ret = this.head.data.slice(0, n);\n this.head.data = this.head.data.slice(n);\n } else if (n === this.head.data.length) {\n // First chunk is a perfect match.\n ret = this.shift();\n } else {\n // Result spans more than one buffer.\n ret = hasStrings ? this._getString(n) : this._getBuffer(n);\n }\n\n return ret;\n }\n }, {\n key: \"first\",\n value: function first() {\n return this.head.data;\n } // Consumes a specified amount of characters from the buffered data.\n\n }, {\n key: \"_getString\",\n value: function _getString(n) {\n var p = this.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) this.head = p.next;else this.head = this.tail = null;\n } else {\n this.head = p;\n p.data = str.slice(nb);\n }\n\n break;\n }\n\n ++c;\n }\n\n this.length -= c;\n return ret;\n } // Consumes a specified amount of bytes from the buffered data.\n\n }, {\n key: \"_getBuffer\",\n value: function _getBuffer(n) {\n var ret = Buffer.allocUnsafe(n);\n var p = this.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) this.head = p.next;else this.head = this.tail = null;\n } else {\n this.head = p;\n p.data = buf.slice(nb);\n }\n\n break;\n }\n\n ++c;\n }\n\n this.length -= c;\n return ret;\n } // Make sure the linked list only shows the minimal necessary information.\n\n }, {\n key: custom,\n value: function value(_, options) {\n return inspect(this, _objectSpread({}, options, {\n // Only inspect one level.\n depth: 0,\n // It should not recurse.\n customInspect: false\n }));\n }\n }]);\n\n return BufferList;\n}();","'use strict'; // undocumented cb() API, needed for core, not for public API\n\nfunction destroy(err, cb) {\n var _this = this;\n\n var readableDestroyed = this._readableState && this._readableState.destroyed;\n var writableDestroyed = this._writableState && this._writableState.destroyed;\n\n if (readableDestroyed || writableDestroyed) {\n if (cb) {\n cb(err);\n } else if (err) {\n if (!this._writableState) {\n process.nextTick(emitErrorNT, this, err);\n } else if (!this._writableState.errorEmitted) {\n this._writableState.errorEmitted = true;\n process.nextTick(emitErrorNT, this, err);\n }\n }\n\n return this;\n } // we set destroyed to true before firing error callbacks in order\n // to make it re-entrance safe in case destroy() is called within callbacks\n\n\n if (this._readableState) {\n this._readableState.destroyed = true;\n } // if this is a duplex stream mark the writable part as destroyed as well\n\n\n if (this._writableState) {\n this._writableState.destroyed = true;\n }\n\n this._destroy(err || null, function (err) {\n if (!cb && err) {\n if (!_this._writableState) {\n process.nextTick(emitErrorAndCloseNT, _this, err);\n } else if (!_this._writableState.errorEmitted) {\n _this._writableState.errorEmitted = true;\n process.nextTick(emitErrorAndCloseNT, _this, err);\n } else {\n process.nextTick(emitCloseNT, _this);\n }\n } else if (cb) {\n process.nextTick(emitCloseNT, _this);\n cb(err);\n } else {\n process.nextTick(emitCloseNT, _this);\n }\n });\n\n return this;\n}\n\nfunction emitErrorAndCloseNT(self, err) {\n emitErrorNT(self, err);\n emitCloseNT(self);\n}\n\nfunction emitCloseNT(self) {\n if (self._writableState && !self._writableState.emitClose) return;\n if (self._readableState && !self._readableState.emitClose) return;\n self.emit('close');\n}\n\nfunction undestroy() {\n if (this._readableState) {\n this._readableState.destroyed = false;\n this._readableState.reading = false;\n this._readableState.ended = false;\n this._readableState.endEmitted = false;\n }\n\n if (this._writableState) {\n this._writableState.destroyed = false;\n this._writableState.ended = false;\n this._writableState.ending = false;\n this._writableState.finalCalled = false;\n this._writableState.prefinished = false;\n this._writableState.finished = false;\n this._writableState.errorEmitted = false;\n }\n}\n\nfunction emitErrorNT(self, err) {\n self.emit('error', err);\n}\n\nfunction errorOrDestroy(stream, err) {\n // We have tests that rely on errors being emitted\n // in the same tick, so changing this is semver major.\n // For now when you opt-in to autoDestroy we allow\n // the error to be emitted nextTick. In a future\n // semver major update we should change the default to this.\n var rState = stream._readableState;\n var wState = stream._writableState;\n if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);\n}\n\nmodule.exports = {\n destroy: destroy,\n undestroy: undestroy,\n errorOrDestroy: errorOrDestroy\n};","// Ported from https://github.com/mafintosh/end-of-stream with\n// permission from the author, Mathias Buus (@mafintosh).\n'use strict';\n\nvar ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;\n\nfunction once(callback) {\n var called = false;\n return function () {\n if (called) return;\n called = true;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n callback.apply(this, args);\n };\n}\n\nfunction noop() {}\n\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function';\n}\n\nfunction eos(stream, opts, callback) {\n if (typeof opts === 'function') return eos(stream, null, opts);\n if (!opts) opts = {};\n callback = once(callback || noop);\n var readable = opts.readable || opts.readable !== false && stream.readable;\n var writable = opts.writable || opts.writable !== false && stream.writable;\n\n var onlegacyfinish = function onlegacyfinish() {\n if (!stream.writable) onfinish();\n };\n\n var writableEnded = stream._writableState && stream._writableState.finished;\n\n var onfinish = function onfinish() {\n writable = false;\n writableEnded = true;\n if (!readable) callback.call(stream);\n };\n\n var readableEnded = stream._readableState && stream._readableState.endEmitted;\n\n var onend = function onend() {\n readable = false;\n readableEnded = true;\n if (!writable) callback.call(stream);\n };\n\n var onerror = function onerror(err) {\n callback.call(stream, err);\n };\n\n var onclose = function onclose() {\n var err;\n\n if (readable && !readableEnded) {\n if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();\n return callback.call(stream, err);\n }\n\n if (writable && !writableEnded) {\n if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();\n return callback.call(stream, err);\n }\n };\n\n var onrequest = function onrequest() {\n stream.req.on('finish', onfinish);\n };\n\n if (isRequest(stream)) {\n stream.on('complete', onfinish);\n stream.on('abort', onclose);\n if (stream.req) onrequest();else stream.on('request', onrequest);\n } else if (writable && !stream._writableState) {\n // legacy streams\n stream.on('end', onlegacyfinish);\n stream.on('close', onlegacyfinish);\n }\n\n stream.on('end', onend);\n stream.on('finish', onfinish);\n if (opts.error !== false) stream.on('error', onerror);\n stream.on('close', onclose);\n return function () {\n stream.removeListener('complete', onfinish);\n stream.removeListener('abort', onclose);\n stream.removeListener('request', onrequest);\n if (stream.req) stream.req.removeListener('finish', onfinish);\n stream.removeListener('end', onlegacyfinish);\n stream.removeListener('close', onlegacyfinish);\n stream.removeListener('finish', onfinish);\n stream.removeListener('end', onend);\n stream.removeListener('error', onerror);\n stream.removeListener('close', onclose);\n };\n}\n\nmodule.exports = eos;","'use strict';\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar ERR_INVALID_ARG_TYPE = require('../../../errors').codes.ERR_INVALID_ARG_TYPE;\n\nfunction from(Readable, iterable, opts) {\n var iterator;\n\n if (iterable && typeof iterable.next === 'function') {\n iterator = iterable;\n } else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);\n\n var readable = new Readable(_objectSpread({\n objectMode: true\n }, opts)); // Reading boolean to protect against _read\n // being called before last iteration completion.\n\n var reading = false;\n\n readable._read = function () {\n if (!reading) {\n reading = true;\n next();\n }\n };\n\n function next() {\n return _next2.apply(this, arguments);\n }\n\n function _next2() {\n _next2 = _asyncToGenerator(function* () {\n try {\n var _ref = yield iterator.next(),\n value = _ref.value,\n done = _ref.done;\n\n if (done) {\n readable.push(null);\n } else if (readable.push((yield value))) {\n next();\n } else {\n reading = false;\n }\n } catch (err) {\n readable.destroy(err);\n }\n });\n return _next2.apply(this, arguments);\n }\n\n return readable;\n}\n\nmodule.exports = from;","// Ported from https://github.com/mafintosh/pump with\n// permission from the author, Mathias Buus (@mafintosh).\n'use strict';\n\nvar eos;\n\nfunction once(callback) {\n var called = false;\n return function () {\n if (called) return;\n called = true;\n callback.apply(void 0, arguments);\n };\n}\n\nvar _require$codes = require('../../../errors').codes,\n ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,\n ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;\n\nfunction noop(err) {\n // Rethrow the error if it exists to avoid swallowing it\n if (err) throw err;\n}\n\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function';\n}\n\nfunction destroyer(stream, reading, writing, callback) {\n callback = once(callback);\n var closed = false;\n stream.on('close', function () {\n closed = true;\n });\n if (eos === undefined) eos = require('./end-of-stream');\n eos(stream, {\n readable: reading,\n writable: writing\n }, function (err) {\n if (err) return callback(err);\n closed = true;\n callback();\n });\n var destroyed = false;\n return function (err) {\n if (closed) return;\n if (destroyed) return;\n destroyed = true; // request.destroy just do .end - .abort is what we want\n\n if (isRequest(stream)) return stream.abort();\n if (typeof stream.destroy === 'function') return stream.destroy();\n callback(err || new ERR_STREAM_DESTROYED('pipe'));\n };\n}\n\nfunction call(fn) {\n fn();\n}\n\nfunction pipe(from, to) {\n return from.pipe(to);\n}\n\nfunction popCallback(streams) {\n if (!streams.length) return noop;\n if (typeof streams[streams.length - 1] !== 'function') return noop;\n return streams.pop();\n}\n\nfunction pipeline() {\n for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {\n streams[_key] = arguments[_key];\n }\n\n var callback = popCallback(streams);\n if (Array.isArray(streams[0])) streams = streams[0];\n\n if (streams.length < 2) {\n throw new ERR_MISSING_ARGS('streams');\n }\n\n var error;\n var destroys = streams.map(function (stream, i) {\n var reading = i < streams.length - 1;\n var writing = i > 0;\n return destroyer(stream, reading, writing, function (err) {\n if (!error) error = err;\n if (err) destroys.forEach(call);\n if (reading) return;\n destroys.forEach(call);\n callback(error);\n });\n });\n return streams.reduce(pipe);\n}\n\nmodule.exports = pipeline;","'use strict';\n\nvar ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;\n\nfunction highWaterMarkFrom(options, isDuplex, duplexKey) {\n return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;\n}\n\nfunction getHighWaterMark(state, options, duplexKey, isDuplex) {\n var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);\n\n if (hwm != null) {\n if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {\n var name = isDuplex ? duplexKey : 'highWaterMark';\n throw new ERR_INVALID_OPT_VALUE(name, hwm);\n }\n\n return Math.floor(hwm);\n } // Default value\n\n\n return state.objectMode ? 16 : 16 * 1024;\n}\n\nmodule.exports = {\n getHighWaterMark: getHighWaterMark\n};","module.exports = require('stream');\n","var Stream = require('stream');\nif (process.env.READABLE_STREAM === 'disable' && Stream) {\n module.exports = Stream.Readable;\n Object.assign(module.exports, Stream);\n module.exports.Stream = Stream;\n} else {\n exports = module.exports = require('./lib/_stream_readable.js');\n exports.Stream = Stream || exports;\n exports.Readable = exports;\n exports.Writable = require('./lib/_stream_writable.js');\n exports.Duplex = require('./lib/_stream_duplex.js');\n exports.Transform = require('./lib/_stream_transform.js');\n exports.PassThrough = require('./lib/_stream_passthrough.js');\n exports.finished = require('./lib/internal/streams/end-of-stream.js');\n exports.pipeline = require('./lib/internal/streams/pipeline.js');\n}\n","/* eslint-disable node/no-deprecated-api */\n\n'use strict'\n\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\nvar safer = {}\n\nvar key\n\nfor (key in buffer) {\n if (!buffer.hasOwnProperty(key)) continue\n if (key === 'SlowBuffer' || key === 'Buffer') continue\n safer[key] = buffer[key]\n}\n\nvar Safer = safer.Buffer = {}\nfor (key in Buffer) {\n if (!Buffer.hasOwnProperty(key)) continue\n if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue\n Safer[key] = Buffer[key]\n}\n\nsafer.Buffer.prototype = Buffer.prototype\n\nif (!Safer.from || Safer.from === Uint8Array.from) {\n Safer.from = function (value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('The \"value\" argument must not be of type number. Received type ' + typeof value)\n }\n if (value && typeof value.length === 'undefined') {\n throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)\n }\n return Buffer(value, encodingOrOffset, length)\n }\n}\n\nif (!Safer.alloc) {\n Safer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('The \"size\" argument must be of type number. Received type ' + typeof size)\n }\n if (size < 0 || size >= 2 * (1 << 30)) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n var buf = Buffer(size)\n if (!fill || fill.length === 0) {\n buf.fill(0)\n } else if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n return buf\n }\n}\n\nif (!safer.kStringMaxLength) {\n try {\n safer.kStringMaxLength = process.binding('buffer').kStringMaxLength\n } catch (e) {\n // we can't determine kStringMaxLength in environments where process.binding\n // is unsupported, so let's not set it\n }\n}\n\nif (!safer.constants) {\n safer.constants = {\n MAX_LENGTH: safer.kMaxLength\n }\n if (safer.kStringMaxLength) {\n safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength\n }\n}\n\nmodule.exports = safer\n","var fs = require('fs');\n\nmodule.exports = function (filepath, split, encoding) {\n split = typeof split !== 'undefined' ? split : \"\\n\";\n encoding = typeof encoding !== 'undefined' ? encoding : \"utf8\";\n\n var ca = [];\n var chain = fs.readFileSync(filepath, encoding);\n if(chain.indexOf(\"-END CERTIFICATE-\") < 0 || chain.indexOf(\"-BEGIN CERTIFICATE-\") < 0){\n throw Error(\"File does not contain 'BEGIN CERTIFICATE' or 'END CERTIFICATE'\");\n }\n chain = chain.split(split);\n var cert = [];\n var _i, _len;\n for (_i = 0, _len = chain.length; _i < _len; _i++) {\n var line = chain[_i];\n if (!(line.length !== 0)) {\n continue;\n }\n cert.push(line);\n if (line.match(/-END CERTIFICATE-/)) {\n ca.push(cert.join(split));\n cert = [];\n }\n }\n return ca;\n}\n","'use strict';\n\nconst {\n Duplex: DuplexStream,\n Readable: ReadableStream,\n Writable: WritableStream,\n} = require('stream');\n\nconst {\n CHANNEL_EXTENDED_DATATYPE: { STDERR },\n} = require('./protocol/constants.js');\nconst { bufferSlice } = require('./protocol/utils.js');\n\nconst PACKET_SIZE = 32 * 1024;\nconst MAX_WINDOW = 2 * 1024 * 1024;\nconst WINDOW_THRESHOLD = MAX_WINDOW / 2;\n\nclass ClientStderr extends ReadableStream {\n constructor(channel, streamOpts) {\n super(streamOpts);\n\n this._channel = channel;\n }\n _read(n) {\n if (this._channel._waitChanDrain) {\n this._channel._waitChanDrain = false;\n if (this._channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(this._channel);\n }\n }\n}\n\nclass ServerStderr extends WritableStream {\n constructor(channel) {\n super({ highWaterMark: MAX_WINDOW });\n\n this._channel = channel;\n }\n\n _write(data, encoding, cb) {\n const channel = this._channel;\n const protocol = channel._client._protocol;\n const outgoing = channel.outgoing;\n const packetSize = outgoing.packetSize;\n const id = outgoing.id;\n let window = outgoing.window;\n const len = data.length;\n let p = 0;\n\n if (outgoing.state !== 'open')\n return;\n\n while (len - p > 0 && window > 0) {\n let sliceLen = len - p;\n if (sliceLen > window)\n sliceLen = window;\n if (sliceLen > packetSize)\n sliceLen = packetSize;\n\n if (p === 0 && sliceLen === len)\n protocol.channelExtData(id, data, STDERR);\n else\n protocol.channelExtData(id, bufferSlice(data, p, p + sliceLen), STDERR);\n\n p += sliceLen;\n window -= sliceLen;\n }\n\n outgoing.window = window;\n\n if (len - p > 0) {\n if (window === 0)\n channel._waitWindow = true;\n if (p > 0)\n channel._chunkErr = bufferSlice(data, p, len);\n else\n channel._chunkErr = data;\n channel._chunkcbErr = cb;\n return;\n }\n\n cb();\n }\n}\n\nclass Channel extends DuplexStream {\n constructor(client, info, opts) {\n const streamOpts = {\n highWaterMark: MAX_WINDOW,\n allowHalfOpen: (!opts || (opts && opts.allowHalfOpen !== false)),\n emitClose: false,\n };\n super(streamOpts);\n this.allowHalfOpen = streamOpts.allowHalfOpen;\n\n const server = !!(opts && opts.server);\n\n this.server = server;\n this.type = info.type;\n this.subtype = undefined;\n\n /*\n incoming and outgoing contain these properties:\n {\n id: undefined,\n window: undefined,\n packetSize: undefined,\n state: 'closed'\n }\n */\n this.incoming = info.incoming;\n this.outgoing = info.outgoing;\n this._callbacks = [];\n\n this._client = client;\n this._hasX11 = false;\n this._exit = {\n code: undefined,\n signal: undefined,\n dump: undefined,\n desc: undefined,\n };\n\n this.stdin = this.stdout = this;\n\n if (server)\n this.stderr = new ServerStderr(this);\n else\n this.stderr = new ClientStderr(this, streamOpts);\n\n // Outgoing data\n this._waitWindow = false; // SSH-level backpressure\n\n // Incoming data\n this._waitChanDrain = false; // Channel Readable side backpressure\n\n this._chunk = undefined;\n this._chunkcb = undefined;\n this._chunkErr = undefined;\n this._chunkcbErr = undefined;\n\n this.on('finish', onFinish)\n .on('prefinish', onFinish); // For node v0.11+\n\n this.on('end', onEnd).on('close', onEnd);\n }\n\n _read(n) {\n if (this._waitChanDrain) {\n this._waitChanDrain = false;\n if (this.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(this);\n }\n }\n\n _write(data, encoding, cb) {\n const protocol = this._client._protocol;\n const outgoing = this.outgoing;\n const packetSize = outgoing.packetSize;\n const id = outgoing.id;\n let window = outgoing.window;\n const len = data.length;\n let p = 0;\n\n if (outgoing.state !== 'open')\n return;\n\n while (len - p > 0 && window > 0) {\n let sliceLen = len - p;\n if (sliceLen > window)\n sliceLen = window;\n if (sliceLen > packetSize)\n sliceLen = packetSize;\n\n if (p === 0 && sliceLen === len)\n protocol.channelData(id, data);\n else\n protocol.channelData(id, bufferSlice(data, p, p + sliceLen));\n\n p += sliceLen;\n window -= sliceLen;\n }\n\n outgoing.window = window;\n\n if (len - p > 0) {\n if (window === 0)\n this._waitWindow = true;\n if (p > 0)\n this._chunk = bufferSlice(data, p, len);\n else\n this._chunk = data;\n this._chunkcb = cb;\n return;\n }\n\n cb();\n }\n\n eof() {\n if (this.outgoing.state === 'open') {\n this.outgoing.state = 'eof';\n this._client._protocol.channelEOF(this.outgoing.id);\n }\n }\n\n close() {\n if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {\n this.outgoing.state = 'closing';\n this._client._protocol.channelClose(this.outgoing.id);\n }\n }\n\n destroy() {\n this.end();\n this.close();\n }\n\n // Session type-specific methods =============================================\n setWindow(rows, cols, height, width) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (this.type === 'session'\n && (this.subtype === 'shell' || this.subtype === 'exec')\n && this.writable\n && this.outgoing.state === 'open') {\n this._client._protocol.windowChange(this.outgoing.id,\n rows,\n cols,\n height,\n width);\n }\n }\n\n signal(signalName) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (this.type === 'session'\n && this.writable\n && this.outgoing.state === 'open') {\n this._client._protocol.signal(this.outgoing.id, signalName);\n }\n }\n\n exit(statusOrSignal, coreDumped, msg) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (this.type === 'session'\n && this.writable\n && this.outgoing.state === 'open') {\n if (typeof statusOrSignal === 'number') {\n this._client._protocol.exitStatus(this.outgoing.id, statusOrSignal);\n } else {\n this._client._protocol.exitSignal(this.outgoing.id,\n statusOrSignal,\n coreDumped,\n msg);\n }\n }\n }\n\n}\n\nfunction onFinish() {\n this.eof();\n if (this.server || !this.allowHalfOpen)\n this.close();\n this.writable = false;\n}\n\nfunction onEnd() {\n this.readable = false;\n}\n\nfunction windowAdjust(self) {\n if (self.outgoing.state === 'closed')\n return;\n const amt = MAX_WINDOW - self.incoming.window;\n if (amt <= 0)\n return;\n self.incoming.window += amt;\n self._client._protocol.channelWindowAdjust(self.outgoing.id, amt);\n}\n\nmodule.exports = {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n};\n",null,"// TODO:\n// * add `.connected` or similar property to allow immediate connection\n// status checking\n// * add/improve debug output during user authentication phase\n'use strict';\n\nconst {\n createHash,\n getHashes,\n randomFillSync,\n} = require('crypto');\nconst { Socket } = require('net');\nconst { lookup: dnsLookup } = require('dns');\nconst EventEmitter = require('events');\nconst HASHES = getHashes();\n\nconst {\n COMPAT,\n CHANNEL_EXTENDED_DATATYPE: { STDERR },\n CHANNEL_OPEN_FAILURE,\n DEFAULT_CIPHER,\n DEFAULT_COMPRESSION,\n DEFAULT_KEX,\n DEFAULT_MAC,\n DEFAULT_SERVER_HOST_KEY,\n DISCONNECT_REASON,\n DISCONNECT_REASON_BY_VALUE,\n SUPPORTED_CIPHER,\n SUPPORTED_COMPRESSION,\n SUPPORTED_KEX,\n SUPPORTED_MAC,\n SUPPORTED_SERVER_HOST_KEY,\n} = require('./protocol/constants.js');\nconst { init: cryptoInit } = require('./protocol/crypto.js');\nconst Protocol = require('./protocol/Protocol.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst { SFTP } = require('./protocol/SFTP.js');\nconst {\n bufferCopy,\n makeBufferParser,\n makeError,\n readUInt32BE,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./protocol/utils.js');\n\nconst { AgentContext, createAgent, isAgent } = require('./agent.js');\nconst {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n} = require('./Channel.js');\nconst {\n ChannelManager,\n generateAlgorithmList,\n isWritable,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n} = require('./utils.js');\n\nconst bufferParser = makeBufferParser();\nconst sigParser = makeBufferParser();\nconst RE_OPENSSH = /^OpenSSH_(?:(?![0-4])\\d)|(?:\\d{2,})/;\nconst noop = (err) => {};\n\nclass Client extends EventEmitter {\n constructor() {\n super();\n\n this.config = {\n host: undefined,\n port: undefined,\n localAddress: undefined,\n localPort: undefined,\n forceIPv4: undefined,\n forceIPv6: undefined,\n keepaliveCountMax: undefined,\n keepaliveInterval: undefined,\n readyTimeout: undefined,\n ident: undefined,\n\n username: undefined,\n password: undefined,\n privateKey: undefined,\n tryKeyboard: undefined,\n agent: undefined,\n allowAgentFwd: undefined,\n authHandler: undefined,\n\n hostHashAlgo: undefined,\n hostHashCb: undefined,\n strictVendor: undefined,\n debug: undefined\n };\n\n this._agent = undefined;\n this._readyTimeout = undefined;\n this._chanMgr = undefined;\n this._callbacks = undefined;\n this._forwarding = undefined;\n this._forwardingUnix = undefined;\n this._acceptX11 = undefined;\n this._agentFwdEnabled = undefined;\n this._remoteVer = undefined;\n\n this._protocol = undefined;\n this._sock = undefined;\n this._resetKA = undefined;\n }\n\n connect(cfg) {\n if (this._sock && isWritable(this._sock)) {\n this.once('close', () => {\n this.connect(cfg);\n });\n this.end();\n return this;\n }\n\n this.config.host = cfg.hostname || cfg.host || 'localhost';\n this.config.port = cfg.port || 22;\n this.config.localAddress = (typeof cfg.localAddress === 'string'\n ? cfg.localAddress\n : undefined);\n this.config.localPort = (typeof cfg.localPort === 'string'\n || typeof cfg.localPort === 'number'\n ? cfg.localPort\n : undefined);\n this.config.forceIPv4 = cfg.forceIPv4 || false;\n this.config.forceIPv6 = cfg.forceIPv6 || false;\n this.config.keepaliveCountMax = (typeof cfg.keepaliveCountMax === 'number'\n && cfg.keepaliveCountMax >= 0\n ? cfg.keepaliveCountMax\n : 3);\n this.config.keepaliveInterval = (typeof cfg.keepaliveInterval === 'number'\n && cfg.keepaliveInterval > 0\n ? cfg.keepaliveInterval\n : 0);\n this.config.readyTimeout = (typeof cfg.readyTimeout === 'number'\n && cfg.readyTimeout >= 0\n ? cfg.readyTimeout\n : 20000);\n this.config.ident = (typeof cfg.ident === 'string'\n || Buffer.isBuffer(cfg.ident)\n ? cfg.ident\n : undefined);\n\n const algorithms = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: [],\n },\n sc: undefined,\n };\n let allOfferDefaults = true;\n if (typeof cfg.algorithms === 'object' && cfg.algorithms !== null) {\n algorithms.kex = generateAlgorithmList(cfg.algorithms.kex,\n DEFAULT_KEX,\n SUPPORTED_KEX);\n if (algorithms.kex !== DEFAULT_KEX)\n allOfferDefaults = false;\n\n algorithms.serverHostKey =\n generateAlgorithmList(cfg.algorithms.serverHostKey,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY);\n if (algorithms.serverHostKey !== DEFAULT_SERVER_HOST_KEY)\n allOfferDefaults = false;\n\n algorithms.cs.cipher = generateAlgorithmList(cfg.algorithms.cipher,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER);\n if (algorithms.cs.cipher !== DEFAULT_CIPHER)\n allOfferDefaults = false;\n\n algorithms.cs.mac = generateAlgorithmList(cfg.algorithms.hmac,\n DEFAULT_MAC,\n SUPPORTED_MAC);\n if (algorithms.cs.mac !== DEFAULT_MAC)\n allOfferDefaults = false;\n\n algorithms.cs.compress = generateAlgorithmList(cfg.algorithms.compress,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION);\n if (algorithms.cs.compress !== DEFAULT_COMPRESSION)\n allOfferDefaults = false;\n\n if (!allOfferDefaults)\n algorithms.sc = algorithms.cs;\n }\n\n if (typeof cfg.username === 'string')\n this.config.username = cfg.username;\n else if (typeof cfg.user === 'string')\n this.config.username = cfg.user;\n else\n throw new Error('Invalid username');\n\n this.config.password = (typeof cfg.password === 'string'\n ? cfg.password\n : undefined);\n this.config.privateKey = (typeof cfg.privateKey === 'string'\n || Buffer.isBuffer(cfg.privateKey)\n ? cfg.privateKey\n : undefined);\n this.config.localHostname = (typeof cfg.localHostname === 'string'\n ? cfg.localHostname\n : undefined);\n this.config.localUsername = (typeof cfg.localUsername === 'string'\n ? cfg.localUsername\n : undefined);\n this.config.tryKeyboard = (cfg.tryKeyboard === true);\n if (typeof cfg.agent === 'string' && cfg.agent.length)\n this.config.agent = createAgent(cfg.agent);\n else if (isAgent(cfg.agent))\n this.config.agent = cfg.agent;\n else\n this.config.agent = undefined;\n this.config.allowAgentFwd = (cfg.agentForward === true\n && this.config.agent !== undefined);\n let authHandler = this.config.authHandler = (\n typeof cfg.authHandler === 'function'\n || Array.isArray(cfg.authHandler)\n ? cfg.authHandler\n : undefined\n );\n\n this.config.strictVendor = (typeof cfg.strictVendor === 'boolean'\n ? cfg.strictVendor\n : true);\n\n const debug = this.config.debug = (typeof cfg.debug === 'function'\n ? cfg.debug\n : undefined);\n\n if (cfg.agentForward === true && !this.config.allowAgentFwd) {\n throw new Error(\n 'You must set a valid agent path to allow agent forwarding'\n );\n }\n\n let callbacks = this._callbacks = [];\n this._chanMgr = new ChannelManager(this);\n this._forwarding = {};\n this._forwardingUnix = {};\n this._acceptX11 = 0;\n this._agentFwdEnabled = false;\n this._agent = (this.config.agent ? this.config.agent : undefined);\n this._remoteVer = undefined;\n let privateKey;\n\n if (this.config.privateKey) {\n privateKey = parseKey(this.config.privateKey, cfg.passphrase);\n if (privateKey instanceof Error)\n throw new Error(`Cannot parse privateKey: ${privateKey.message}`);\n if (Array.isArray(privateKey)) {\n // OpenSSH's newer format only stores 1 key for now\n privateKey = privateKey[0];\n }\n if (privateKey.getPrivatePEM() === null) {\n throw new Error(\n 'privateKey value does not contain a (valid) private key'\n );\n }\n }\n\n let hostVerifier;\n if (typeof cfg.hostVerifier === 'function') {\n const hashCb = cfg.hostVerifier;\n let hasher;\n if (HASHES.indexOf(cfg.hostHash) !== -1) {\n // Default to old behavior of hashing on user's behalf\n hasher = createHash(cfg.hostHash);\n }\n hostVerifier = (key, verify) => {\n if (hasher) {\n hasher.update(key);\n key = hasher.digest('hex');\n }\n const ret = hashCb(key, verify);\n if (ret !== undefined)\n verify(ret);\n };\n }\n\n const sock = this._sock = (cfg.sock || new Socket());\n let ready = false;\n let sawHeader = false;\n if (this._protocol)\n this._protocol.cleanup();\n const DEBUG_HANDLER = (!debug ? undefined : (p, display, msg) => {\n debug(`Debug output from server: ${JSON.stringify(msg)}`);\n });\n const proto = this._protocol = new Protocol({\n ident: this.config.ident,\n offer: (allOfferDefaults ? undefined : algorithms),\n onWrite: (data) => {\n if (isWritable(sock))\n sock.write(data);\n },\n onError: (err) => {\n if (err.level === 'handshake')\n clearTimeout(this._readyTimeout);\n if (!proto._destruct)\n sock.removeAllListeners('data');\n this.emit('error', err);\n try {\n sock.end();\n } catch {}\n },\n onHeader: (header) => {\n sawHeader = true;\n this._remoteVer = header.versions.software;\n if (header.greeting)\n this.emit('greeting', header.greeting);\n },\n onHandshakeComplete: (negotiated) => {\n this.emit('handshake', negotiated);\n if (!ready) {\n ready = true;\n proto.service('ssh-userauth');\n }\n },\n debug,\n hostVerifier,\n messageHandlers: {\n DEBUG: DEBUG_HANDLER,\n DISCONNECT: (p, reason, desc) => {\n if (reason !== DISCONNECT_REASON.BY_APPLICATION) {\n if (!desc) {\n desc = DISCONNECT_REASON_BY_VALUE[reason];\n if (desc === undefined)\n desc = `Unexpected disconnection reason: ${reason}`;\n }\n const err = new Error(desc);\n err.code = reason;\n this.emit('error', err);\n }\n sock.end();\n },\n SERVICE_ACCEPT: (p, name) => {\n if (name === 'ssh-userauth')\n tryNextAuth();\n },\n USERAUTH_BANNER: (p, msg) => {\n this.emit('banner', msg);\n },\n USERAUTH_SUCCESS: (p) => {\n // Start keepalive mechanism\n resetKA();\n\n clearTimeout(this._readyTimeout);\n\n this.emit('ready');\n },\n USERAUTH_FAILURE: (p, authMethods, partialSuccess) => {\n if (curAuth.type === 'agent') {\n const pos = curAuth.agentCtx.pos();\n debug && debug(`Client: Agent key #${pos + 1} failed`);\n return tryNextAgentKey();\n }\n\n debug && debug(`Client: ${curAuth.type} auth failed`);\n\n curPartial = partialSuccess;\n curAuthsLeft = authMethods;\n tryNextAuth();\n },\n USERAUTH_PASSWD_CHANGEREQ: (p, prompt) => {\n if (curAuth.type === 'password') {\n // TODO: support a `changePrompt()` on `curAuth` that defaults to\n // emitting 'change password' as before\n this.emit('change password', prompt, (newPassword) => {\n proto.authPassword(\n this.config.username,\n this.config.password,\n newPassword\n );\n });\n }\n },\n USERAUTH_PK_OK: (p) => {\n if (curAuth.type === 'agent') {\n const key = curAuth.agentCtx.currentKey();\n proto.authPK(curAuth.username, key, (buf, cb) => {\n curAuth.agentCtx.sign(key, buf, {}, (err, signed) => {\n if (err) {\n err.level = 'agent';\n this.emit('error', err);\n } else {\n return cb(signed);\n }\n\n tryNextAgentKey();\n });\n });\n } else if (curAuth.type === 'publickey') {\n proto.authPK(curAuth.username, curAuth.key, (buf, cb) => {\n const signature = curAuth.key.sign(buf);\n if (signature instanceof Error) {\n signature.message =\n `Error signing data with key: ${signature.message}`;\n signature.level = 'client-authentication';\n this.emit('error', signature);\n return tryNextAuth();\n }\n cb(signature);\n });\n }\n },\n USERAUTH_INFO_REQUEST: (p, name, instructions, prompts) => {\n if (curAuth.type === 'keyboard-interactive') {\n const nprompts = (Array.isArray(prompts) ? prompts.length : 0);\n if (nprompts === 0) {\n debug && debug(\n 'Client: Sending automatic USERAUTH_INFO_RESPONSE'\n );\n proto.authInfoRes();\n return;\n }\n // We sent a keyboard-interactive user authentication request and\n // now the server is sending us the prompts we need to present to\n // the user\n curAuth.prompt(\n name,\n instructions,\n '',\n prompts,\n (answers) => {\n proto.authInfoRes(answers);\n }\n );\n }\n },\n REQUEST_SUCCESS: (p, data) => {\n if (callbacks.length)\n callbacks.shift()(false, data);\n },\n REQUEST_FAILURE: (p) => {\n if (callbacks.length)\n callbacks.shift()(true);\n },\n GLOBAL_REQUEST: (p, name, wantReply, data) => {\n switch (name) {\n case 'hostkeys-00@openssh.com':\n // Automatically verify keys before passing to end user\n hostKeysProve(this, data, (err, keys) => {\n if (err)\n return;\n this.emit('hostkeys', keys);\n });\n if (wantReply)\n proto.requestSuccess();\n break;\n default:\n // Auto-reject all other global requests, this can be especially\n // useful if the server is sending us dummy keepalive global\n // requests\n if (wantReply)\n proto.requestFailure();\n }\n },\n CHANNEL_OPEN: (p, info) => {\n // Handle incoming requests from server, typically a forwarded TCP or\n // X11 connection\n onCHANNEL_OPEN(this, info);\n },\n CHANNEL_OPEN_CONFIRMATION: (p, info) => {\n const channel = this._chanMgr.get(info.recipient);\n if (typeof channel !== 'function')\n return;\n\n const isSFTP = (channel.type === 'sftp');\n const type = (isSFTP ? 'session' : channel.type);\n const chanInfo = {\n type,\n incoming: {\n id: info.recipient,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n const instance = (\n isSFTP\n ? new SFTP(this, chanInfo, { debug })\n : new Channel(this, chanInfo)\n );\n this._chanMgr.update(info.recipient, instance);\n channel(undefined, instance);\n },\n CHANNEL_OPEN_FAILURE: (p, recipient, reason, description) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'function')\n return;\n\n const info = { reason, description };\n onChannelOpenFailure(this, recipient, info, channel);\n },\n CHANNEL_DATA: (p, recipient, data) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (channel.push(data) === false) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_EXTENDED_DATA: (p, recipient, data, type) => {\n if (type !== STDERR)\n return;\n\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (!channel.stderr.push(data)) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_WINDOW_ADJUST: (p, recipient, amount) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The other side is allowing us to send `amount` more bytes of data\n channel.outgoing.window += amount;\n\n if (channel._waitWindow) {\n channel._waitWindow = false;\n\n if (channel._chunk) {\n channel._write(channel._chunk, null, channel._chunkcb);\n } else if (channel._chunkcb) {\n channel._chunkcb();\n } else if (channel._chunkErr) {\n channel.stderr._write(channel._chunkErr,\n null,\n channel._chunkcbErr);\n } else if (channel._chunkcbErr) {\n channel._chunkcbErr();\n }\n }\n },\n CHANNEL_SUCCESS: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n this._resetKA();\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(false);\n },\n CHANNEL_FAILURE: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n this._resetKA();\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(true);\n },\n CHANNEL_REQUEST: (p, recipient, type, wantReply, data) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n const exit = channel._exit;\n if (exit.code !== undefined)\n return;\n switch (type) {\n case 'exit-status':\n channel.emit('exit', exit.code = data);\n return;\n case 'exit-signal':\n channel.emit('exit',\n exit.code = null,\n exit.signal = `SIG${data.signal}`,\n exit.dump = data.coreDumped,\n exit.desc = data.errorMessage);\n return;\n }\n\n // Keepalive request? OpenSSH will send one as a channel request if\n // there is a channel open\n\n if (wantReply)\n p.channelFailure(channel.outgoing.id);\n },\n CHANNEL_EOF: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.incoming.state !== 'open')\n return;\n channel.incoming.state = 'eof';\n\n if (channel.readable)\n channel.push(null);\n if (channel.stderr.readable)\n channel.stderr.push(null);\n },\n CHANNEL_CLOSE: (p, recipient) => {\n onCHANNEL_CLOSE(this, recipient, this._chanMgr.get(recipient));\n },\n },\n });\n\n sock.pause();\n\n // TODO: check keepalive implementation\n // Keepalive-related\n const kainterval = this.config.keepaliveInterval;\n const kacountmax = this.config.keepaliveCountMax;\n let kacount = 0;\n let katimer;\n const sendKA = () => {\n if (++kacount > kacountmax) {\n clearInterval(katimer);\n if (sock.readable) {\n const err = new Error('Keepalive timeout');\n err.level = 'client-timeout';\n this.emit('error', err);\n sock.destroy();\n }\n return;\n }\n if (isWritable(sock)) {\n // Append dummy callback to keep correct callback order\n callbacks.push(resetKA);\n proto.ping();\n } else {\n clearInterval(katimer);\n }\n };\n function resetKA() {\n if (kainterval > 0) {\n kacount = 0;\n clearInterval(katimer);\n if (isWritable(sock))\n katimer = setInterval(sendKA, kainterval);\n }\n }\n this._resetKA = resetKA;\n\n const onDone = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n if (wasConnected && !sawHeader) {\n const err =\n makeError('Connection lost before handshake', 'protocol', true);\n this.emit('error', err);\n }\n };\n })();\n const onConnect = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n\n wasConnected = true;\n debug && debug('Socket connected');\n this.emit('connect');\n\n cryptoInit.then(() => {\n proto.start();\n sock.on('data', (data) => {\n try {\n proto.parse(data, 0, data.length);\n } catch (ex) {\n this.emit('error', ex);\n try {\n if (isWritable(sock))\n sock.end();\n } catch {}\n }\n });\n\n // Drain stderr if we are connection hopping using an exec stream\n if (sock.stderr && typeof sock.stderr.resume === 'function')\n sock.stderr.resume();\n\n sock.resume();\n }).catch((err) => {\n this.emit('error', err);\n try {\n if (isWritable(sock))\n sock.end();\n } catch {}\n });\n };\n })();\n let wasConnected = false;\n sock.on('connect', onConnect)\n .on('timeout', () => {\n this.emit('timeout');\n }).on('error', (err) => {\n debug && debug(`Socket error: ${err.message}`);\n clearTimeout(this._readyTimeout);\n err.level = 'client-socket';\n this.emit('error', err);\n }).on('end', () => {\n debug && debug('Socket ended');\n onDone();\n proto.cleanup();\n clearTimeout(this._readyTimeout);\n clearInterval(katimer);\n this.emit('end');\n }).on('close', () => {\n debug && debug('Socket closed');\n onDone();\n proto.cleanup();\n clearTimeout(this._readyTimeout);\n clearInterval(katimer);\n this.emit('close');\n\n // Notify outstanding channel requests of disconnection ...\n const callbacks_ = callbacks;\n callbacks = this._callbacks = [];\n const err = new Error('No response from server');\n for (let i = 0; i < callbacks_.length; ++i)\n callbacks_[i](err);\n\n // Simulate error for any channels waiting to be opened\n this._chanMgr.cleanup(err);\n });\n\n // Begin authentication handling ===========================================\n let curAuth;\n let curPartial = null;\n let curAuthsLeft = null;\n const authsAllowed = ['none'];\n if (this.config.password !== undefined)\n authsAllowed.push('password');\n if (privateKey !== undefined)\n authsAllowed.push('publickey');\n if (this._agent !== undefined)\n authsAllowed.push('agent');\n if (this.config.tryKeyboard)\n authsAllowed.push('keyboard-interactive');\n if (privateKey !== undefined\n && this.config.localHostname !== undefined\n && this.config.localUsername !== undefined) {\n authsAllowed.push('hostbased');\n }\n\n if (Array.isArray(authHandler))\n authHandler = makeSimpleAuthHandler(authHandler);\n else if (typeof authHandler !== 'function')\n authHandler = makeSimpleAuthHandler(authsAllowed);\n\n let hasSentAuth = false;\n const doNextAuth = (nextAuth) => {\n if (hasSentAuth)\n return;\n hasSentAuth = true;\n\n if (nextAuth === false) {\n const err = new Error('All configured authentication methods failed');\n err.level = 'client-authentication';\n this.emit('error', err);\n this.end();\n return;\n }\n\n if (typeof nextAuth === 'string') {\n // Remain backwards compatible with original `authHandler()` usage,\n // which only supported passing names of next method to try using data\n // from the `connect()` config object\n\n const type = nextAuth;\n if (authsAllowed.indexOf(type) === -1)\n return skipAuth(`Authentication method not allowed: ${type}`);\n\n const username = this.config.username;\n switch (type) {\n case 'password':\n nextAuth = { type, username, password: this.config.password };\n break;\n case 'publickey':\n nextAuth = { type, username, key: privateKey };\n break;\n case 'hostbased':\n nextAuth = {\n type,\n username,\n key: privateKey,\n localHostname: this.config.localHostname,\n localUsername: this.config.localUsername,\n };\n break;\n case 'agent':\n nextAuth = {\n type,\n username,\n agentCtx: new AgentContext(this._agent),\n };\n break;\n case 'keyboard-interactive':\n nextAuth = {\n type,\n username,\n prompt: (...args) => this.emit('keyboard-interactive', ...args),\n };\n break;\n case 'none':\n nextAuth = { type, username };\n break;\n default:\n return skipAuth(\n `Skipping unsupported authentication method: ${nextAuth}`\n );\n }\n } else if (typeof nextAuth !== 'object' || nextAuth === null) {\n return skipAuth(\n `Skipping invalid authentication attempt: ${nextAuth}`\n );\n } else {\n const username = nextAuth.username;\n if (typeof username !== 'string') {\n return skipAuth(\n `Skipping invalid authentication attempt: ${nextAuth}`\n );\n }\n const type = nextAuth.type;\n switch (type) {\n case 'password': {\n const { password } = nextAuth;\n if (typeof password !== 'string' && !Buffer.isBuffer(password))\n return skipAuth('Skipping invalid password auth attempt');\n nextAuth = { type, username, password };\n break;\n }\n case 'publickey': {\n const key = parseKey(nextAuth.key, nextAuth.passphrase);\n if (key instanceof Error)\n return skipAuth('Skipping invalid key auth attempt');\n if (!key.isPrivateKey())\n return skipAuth('Skipping non-private key');\n nextAuth = { type, username, key };\n break;\n }\n case 'hostbased': {\n const { localHostname, localUsername } = nextAuth;\n const key = parseKey(nextAuth.key, nextAuth.passphrase);\n if (key instanceof Error\n || typeof localHostname !== 'string'\n || typeof localUsername !== 'string') {\n return skipAuth('Skipping invalid hostbased auth attempt');\n }\n if (!key.isPrivateKey())\n return skipAuth('Skipping non-private key');\n nextAuth = { type, username, key, localHostname, localUsername };\n break;\n }\n case 'agent': {\n let agent = nextAuth.agent;\n if (typeof agent === 'string' && agent.length) {\n agent = createAgent(agent);\n } else if (!isAgent(agent)) {\n return skipAuth(\n `Skipping invalid agent: ${nextAuth.agent}`\n );\n }\n nextAuth = { type, username, agentCtx: new AgentContext(agent) };\n break;\n }\n case 'keyboard-interactive': {\n const { prompt } = nextAuth;\n if (typeof prompt !== 'function') {\n return skipAuth(\n 'Skipping invalid keyboard-interactive auth attempt'\n );\n }\n nextAuth = { type, username, prompt };\n break;\n }\n case 'none':\n nextAuth = { type, username };\n break;\n default:\n return skipAuth(\n `Skipping unsupported authentication method: ${nextAuth}`\n );\n }\n }\n curAuth = nextAuth;\n\n // Begin authentication method's process\n try {\n const username = curAuth.username;\n switch (curAuth.type) {\n case 'password':\n proto.authPassword(username, curAuth.password);\n break;\n case 'publickey':\n proto.authPK(username, curAuth.key);\n break;\n case 'hostbased':\n proto.authHostbased(username,\n curAuth.key,\n curAuth.localHostname,\n curAuth.localUsername,\n (buf, cb) => {\n const signature = curAuth.key.sign(buf);\n if (signature instanceof Error) {\n signature.message =\n `Error while signing with key: ${signature.message}`;\n signature.level = 'client-authentication';\n this.emit('error', signature);\n return tryNextAuth();\n }\n\n cb(signature);\n });\n break;\n case 'agent':\n curAuth.agentCtx.init((err) => {\n if (err) {\n err.level = 'agent';\n this.emit('error', err);\n return tryNextAuth();\n }\n tryNextAgentKey();\n });\n break;\n case 'keyboard-interactive':\n proto.authKeyboard(username);\n break;\n case 'none':\n proto.authNone(username);\n break;\n }\n } finally {\n hasSentAuth = false;\n }\n };\n\n function skipAuth(msg) {\n debug && debug(msg);\n process.nextTick(tryNextAuth);\n }\n\n function tryNextAuth() {\n hasSentAuth = false;\n const auth = authHandler(curAuthsLeft, curPartial, doNextAuth);\n if (hasSentAuth || auth === undefined)\n return;\n doNextAuth(auth);\n }\n\n const tryNextAgentKey = () => {\n if (curAuth.type === 'agent') {\n const key = curAuth.agentCtx.nextKey();\n if (key === false) {\n debug && debug('Agent: No more keys left to try');\n debug && debug('Client: agent auth failed');\n tryNextAuth();\n } else {\n const pos = curAuth.agentCtx.pos();\n debug && debug(`Agent: Trying key #${pos + 1}`);\n proto.authPK(curAuth.username, key);\n }\n }\n };\n\n const startTimeout = () => {\n if (this.config.readyTimeout > 0) {\n this._readyTimeout = setTimeout(() => {\n const err = new Error('Timed out while waiting for handshake');\n err.level = 'client-timeout';\n this.emit('error', err);\n sock.destroy();\n }, this.config.readyTimeout);\n }\n };\n\n if (!cfg.sock) {\n let host = this.config.host;\n const forceIPv4 = this.config.forceIPv4;\n const forceIPv6 = this.config.forceIPv6;\n\n debug && debug(`Client: Trying ${host} on port ${this.config.port} ...`);\n\n const doConnect = () => {\n startTimeout();\n sock.connect({\n host,\n port: this.config.port,\n localAddress: this.config.localAddress,\n localPort: this.config.localPort\n });\n sock.setNoDelay(true);\n sock.setMaxListeners(0);\n sock.setTimeout(typeof cfg.timeout === 'number' ? cfg.timeout : 0);\n };\n\n if ((!forceIPv4 && !forceIPv6) || (forceIPv4 && forceIPv6)) {\n doConnect();\n } else {\n dnsLookup(host, (forceIPv4 ? 4 : 6), (err, address, family) => {\n if (err) {\n const type = (forceIPv4 ? 'IPv4' : 'IPv6');\n const error = new Error(\n `Error while looking up ${type} address for '${host}': ${err}`\n );\n clearTimeout(this._readyTimeout);\n error.level = 'client-dns';\n this.emit('error', error);\n this.emit('close');\n return;\n }\n host = address;\n doConnect();\n });\n }\n } else {\n // Custom socket passed in\n startTimeout();\n if (typeof sock.connecting === 'boolean') {\n // net.Socket\n\n if (!sock.connecting) {\n // Already connected\n onConnect();\n }\n } else {\n // Assume socket/stream is already \"connected\"\n onConnect();\n }\n }\n\n return this;\n }\n\n end() {\n if (this._sock && isWritable(this._sock)) {\n this._protocol.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n this._sock.end();\n }\n return this;\n }\n\n destroy() {\n this._sock && isWritable(this._sock) && this._sock.destroy();\n return this;\n }\n\n exec(cmd, opts, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const extraOpts = { allowHalfOpen: (opts.allowHalfOpen !== false) };\n\n openChannel(this, 'session', extraOpts, (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n const todo = [];\n\n function reqCb(err) {\n if (err) {\n chan.close();\n cb(err);\n return;\n }\n if (todo.length)\n todo.shift()();\n }\n\n if (this.config.allowAgentFwd === true\n || (opts\n && opts.agentForward === true\n && this._agent !== undefined)) {\n todo.push(() => reqAgentFwd(chan, reqCb));\n }\n\n if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.env === 'object' && opts.env !== null)\n reqEnv(chan, opts.env);\n if ((typeof opts.pty === 'object' && opts.pty !== null)\n || opts.pty === true) {\n todo.push(() => reqPty(chan, opts.pty, reqCb));\n }\n if ((typeof opts.x11 === 'object' && opts.x11 !== null)\n || opts.x11 === 'number'\n || opts.x11 === true) {\n todo.push(() => reqX11(chan, opts.x11, reqCb));\n }\n }\n\n todo.push(() => reqExec(chan, cmd, opts, cb));\n todo.shift()();\n });\n\n return this;\n }\n\n shell(wndopts, opts, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof wndopts === 'function') {\n cb = wndopts;\n wndopts = opts = undefined;\n } else if (typeof opts === 'function') {\n cb = opts;\n opts = undefined;\n }\n if (wndopts && (wndopts.x11 !== undefined || wndopts.env !== undefined)) {\n opts = wndopts;\n wndopts = undefined;\n }\n\n openChannel(this, 'session', (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n const todo = [];\n\n function reqCb(err) {\n if (err) {\n chan.close();\n cb(err);\n return;\n }\n if (todo.length)\n todo.shift()();\n }\n\n if (this.config.allowAgentFwd === true\n || (opts\n && opts.agentForward === true\n && this._agent !== undefined)) {\n todo.push(() => reqAgentFwd(chan, reqCb));\n }\n\n if (wndopts !== false)\n todo.push(() => reqPty(chan, wndopts, reqCb));\n\n if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.env === 'object' && opts.env !== null)\n reqEnv(chan, opts.env);\n if ((typeof opts.x11 === 'object' && opts.x11 !== null)\n || opts.x11 === 'number'\n || opts.x11 === true) {\n todo.push(() => reqX11(chan, opts.x11, reqCb));\n }\n }\n\n todo.push(() => reqShell(chan, cb));\n todo.shift()();\n });\n\n return this;\n }\n\n subsys(name, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n openChannel(this, 'session', (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n reqSubsystem(chan, name, (err, stream) => {\n if (err) {\n cb(err);\n return;\n }\n\n cb(undefined, stream);\n });\n });\n\n return this;\n }\n\n forwardIn(bindAddr, bindPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request for the server to start forwarding TCP connections to us\n // on a particular address and port\n\n const wantReply = (typeof cb === 'function');\n\n if (wantReply) {\n this._callbacks.push((had_err, data) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to bind to ${bindAddr}:${bindPort}`));\n return;\n }\n\n let realPort = bindPort;\n if (bindPort === 0 && data && data.length >= 4) {\n realPort = readUInt32BE(data, 0);\n if (!(this._protocol._compatFlags & COMPAT.DYN_RPORT_BUG))\n bindPort = realPort;\n }\n\n this._forwarding[`${bindAddr}:${bindPort}`] = realPort;\n\n cb(undefined, realPort);\n });\n }\n\n this._protocol.tcpipForward(bindAddr, bindPort, wantReply);\n\n return this;\n }\n\n unforwardIn(bindAddr, bindPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request to stop forwarding us new connections for a particular\n // address and port\n\n const wantReply = (typeof cb === 'function');\n\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to unbind from ${bindAddr}:${bindPort}`));\n return;\n }\n\n delete this._forwarding[`${bindAddr}:${bindPort}`];\n\n cb();\n });\n }\n\n this._protocol.cancelTcpipForward(bindAddr, bindPort, wantReply);\n\n return this;\n }\n\n forwardOut(srcIP, srcPort, dstIP, dstPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request to forward a TCP connection to the server\n\n const cfg = {\n srcIP: srcIP,\n srcPort: srcPort,\n dstIP: dstIP,\n dstPort: dstPort\n };\n\n if (typeof cb !== 'function')\n cb = noop;\n\n openChannel(this, 'direct-tcpip', cfg, cb);\n\n return this;\n }\n\n openssh_noMoreSessions(cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to disable future sessions'));\n return;\n }\n\n cb();\n });\n }\n\n this._protocol.openssh_noMoreSessions(wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_forwardInStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to bind to ${socketPath}`));\n return;\n }\n this._forwardingUnix[socketPath] = true;\n cb();\n });\n }\n\n this._protocol.openssh_streamLocalForward(socketPath, wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_unforwardInStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to unbind from ${socketPath}`));\n return;\n }\n delete this._forwardingUnix[socketPath];\n cb();\n });\n }\n\n this._protocol.openssh_cancelStreamLocalForward(socketPath, wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_forwardOutStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof cb !== 'function')\n cb = noop;\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n openChannel(this, 'direct-streamlocal@openssh.com', { socketPath }, cb);\n return this;\n }\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n sftp(cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n openChannel(this, 'sftp', (err, sftp) => {\n if (err) {\n cb(err);\n return;\n }\n\n reqSubsystem(sftp, 'sftp', (err, sftp_) => {\n if (err) {\n cb(err);\n return;\n }\n\n function removeListeners() {\n sftp.removeListener('ready', onReady);\n sftp.removeListener('error', onError);\n sftp.removeListener('exit', onExit);\n sftp.removeListener('close', onExit);\n }\n\n function onReady() {\n // TODO: do not remove exit/close in case remote end closes the\n // channel abruptly and we need to notify outstanding callbacks\n removeListeners();\n cb(undefined, sftp);\n }\n\n function onError(err) {\n removeListeners();\n cb(err);\n }\n\n function onExit(code, signal) {\n removeListeners();\n let msg;\n if (typeof code === 'number')\n msg = `Received exit code ${code} while establishing SFTP session`;\n else if (signal !== undefined)\n msg = `Received signal ${signal} while establishing SFTP session`;\n else\n msg = 'Received unexpected SFTP session termination';\n const err = new Error(msg);\n err.code = code;\n err.signal = signal;\n cb(err);\n }\n\n sftp.on('ready', onReady)\n .on('error', onError)\n .on('exit', onExit)\n .on('close', onExit);\n\n sftp._init();\n });\n });\n\n return this;\n }\n}\n\nfunction openChannel(self, type, opts, cb) {\n // Ask the server to open a channel for some purpose\n // (e.g. session (sftp, exec, shell), or forwarding a TCP connection\n const initWindow = MAX_WINDOW;\n const maxPacket = PACKET_SIZE;\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const wrapper = (err, stream) => {\n cb(err, stream);\n };\n wrapper.type = type;\n\n const localChan = self._chanMgr.add(wrapper);\n\n if (localChan === -1) {\n cb(new Error('No free channels available'));\n return;\n }\n\n switch (type) {\n case 'session':\n case 'sftp':\n self._protocol.session(localChan, initWindow, maxPacket);\n break;\n case 'direct-tcpip':\n self._protocol.directTcpip(localChan, initWindow, maxPacket, opts);\n break;\n case 'direct-streamlocal@openssh.com':\n self._protocol.openssh_directStreamLocal(\n localChan, initWindow, maxPacket, opts\n );\n break;\n default:\n throw new Error(`Unsupported channel type: ${type}`);\n }\n}\n\nfunction reqX11(chan, screen, cb) {\n // Asks server to start sending us X11 connections\n const cfg = {\n single: false,\n protocol: 'MIT-MAGIC-COOKIE-1',\n cookie: undefined,\n screen: 0\n };\n\n if (typeof screen === 'function') {\n cb = screen;\n } else if (typeof screen === 'object' && screen !== null) {\n if (typeof screen.single === 'boolean')\n cfg.single = screen.single;\n if (typeof screen.screen === 'number')\n cfg.screen = screen.screen;\n if (typeof screen.protocol === 'string')\n cfg.protocol = screen.protocol;\n if (typeof screen.cookie === 'string')\n cfg.cookie = screen.cookie;\n else if (Buffer.isBuffer(screen.cookie))\n cfg.cookie = screen.cookie.hexSlice(0, screen.cookie.length);\n }\n if (cfg.cookie === undefined)\n cfg.cookie = randomCookie();\n\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n if (wantReply)\n cb(new Error('Channel is not open'));\n return;\n }\n\n if (wantReply) {\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to request X11'));\n return;\n }\n\n chan._hasX11 = true;\n ++chan._client._acceptX11;\n chan.once('close', () => {\n if (chan._client._acceptX11)\n --chan._client._acceptX11;\n });\n\n cb();\n });\n }\n\n chan._client._protocol.x11Forward(chan.outgoing.id, cfg, wantReply);\n}\n\nfunction reqPty(chan, opts, cb) {\n let rows = 24;\n let cols = 80;\n let width = 640;\n let height = 480;\n let term = 'vt100';\n let modes = null;\n\n if (typeof opts === 'function') {\n cb = opts;\n } else if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.rows === 'number')\n rows = opts.rows;\n if (typeof opts.cols === 'number')\n cols = opts.cols;\n if (typeof opts.width === 'number')\n width = opts.width;\n if (typeof opts.height === 'number')\n height = opts.height;\n if (typeof opts.term === 'string')\n term = opts.term;\n if (typeof opts.modes === 'object')\n modes = opts.modes;\n }\n\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n if (wantReply)\n cb(new Error('Channel is not open'));\n return;\n }\n\n if (wantReply) {\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to request a pseudo-terminal'));\n return;\n }\n cb();\n });\n }\n\n chan._client._protocol.pty(chan.outgoing.id,\n rows,\n cols,\n height,\n width,\n term,\n modes,\n wantReply);\n}\n\nfunction reqAgentFwd(chan, cb) {\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n wantReply && cb(new Error('Channel is not open'));\n return;\n }\n if (chan._client._agentFwdEnabled) {\n wantReply && cb(false);\n return;\n }\n\n chan._client._agentFwdEnabled = true;\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n chan._client._agentFwdEnabled = false;\n if (wantReply) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to request agent forwarding'));\n }\n return;\n }\n\n if (wantReply)\n cb();\n });\n\n chan._client._protocol.openssh_agentForward(chan.outgoing.id, true);\n}\n\nfunction reqShell(chan, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to open shell'));\n return;\n }\n chan.subtype = 'shell';\n cb(undefined, chan);\n });\n\n chan._client._protocol.shell(chan.outgoing.id, true);\n}\n\nfunction reqExec(chan, cmd, opts, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to exec'));\n return;\n }\n chan.subtype = 'exec';\n chan.allowHalfOpen = (opts.allowHalfOpen !== false);\n cb(undefined, chan);\n });\n\n chan._client._protocol.exec(chan.outgoing.id, cmd, true);\n}\n\nfunction reqEnv(chan, env) {\n if (chan.outgoing.state !== 'open')\n return;\n\n const keys = Object.keys(env || {});\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n const val = env[key];\n chan._client._protocol.env(chan.outgoing.id, key, val, false);\n }\n}\n\nfunction reqSubsystem(chan, name, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to start subsystem: ${name}`));\n return;\n }\n chan.subtype = 'subsystem';\n cb(undefined, chan);\n });\n\n chan._client._protocol.subsystem(chan.outgoing.id, name, true);\n}\n\n// TODO: inline implementation into single call site\nfunction onCHANNEL_OPEN(self, info) {\n // The server is trying to open a channel with us, this is usually when\n // we asked the server to forward us connections on some port and now they\n // are asking us to accept/deny an incoming connection on their side\n\n let localChan = -1;\n let reason;\n\n const accept = () => {\n const chanInfo = {\n type: info.type,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n const stream = new Channel(self, chanInfo);\n self._chanMgr.update(localChan, stream);\n\n self._protocol.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n return stream;\n };\n const reject = () => {\n if (reason === undefined) {\n if (localChan === -1)\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n else\n reason = CHANNEL_OPEN_FAILURE.CONNECT_FAILED;\n }\n\n if (localChan !== -1)\n self._chanMgr.remove(localChan);\n\n self._protocol.channelOpenFail(info.sender, reason, '');\n };\n const reserveChannel = () => {\n localChan = self._chanMgr.add();\n\n if (localChan === -1) {\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of incoming channel open: '\n + 'no channels available'\n );\n }\n }\n\n return (localChan !== -1);\n };\n\n const data = info.data;\n switch (info.type) {\n case 'forwarded-tcpip': {\n const val = self._forwarding[`${data.destIP}:${data.destPort}`];\n if (val !== undefined && reserveChannel()) {\n if (data.destPort === 0)\n data.destPort = val;\n self.emit('tcp connection', data, accept, reject);\n return;\n }\n break;\n }\n case 'forwarded-streamlocal@openssh.com':\n if (self._forwardingUnix[data.socketPath] !== undefined\n && reserveChannel()) {\n self.emit('unix connection', data, accept, reject);\n return;\n }\n break;\n case 'auth-agent@openssh.com':\n if (self._agentFwdEnabled\n && typeof self._agent.getStream === 'function'\n && reserveChannel()) {\n self._agent.getStream((err, stream) => {\n if (err)\n return reject();\n\n const upstream = accept();\n upstream.pipe(stream).pipe(upstream);\n });\n return;\n }\n break;\n case 'x11':\n if (self._acceptX11 !== 0 && reserveChannel()) {\n self.emit('x11', data, accept, reject);\n return;\n }\n break;\n default:\n // Automatically reject any unsupported channel open requests\n reason = CHANNEL_OPEN_FAILURE.UNKNOWN_CHANNEL_TYPE;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of unsupported incoming channel open '\n + `type: ${info.type}`\n );\n }\n }\n\n if (reason === undefined) {\n reason = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of unexpected incoming channel open for: '\n + info.type\n );\n }\n }\n\n reject();\n}\n\nconst randomCookie = (() => {\n const buffer = Buffer.allocUnsafe(16);\n return () => {\n randomFillSync(buffer, 0, 16);\n return buffer.hexSlice(0, 16);\n };\n})();\n\nfunction makeSimpleAuthHandler(authList) {\n if (!Array.isArray(authList))\n throw new Error('authList must be an array');\n\n let a = 0;\n return (authsLeft, partialSuccess, cb) => {\n if (a === authList.length)\n return false;\n return authList[a++];\n };\n}\n\nfunction hostKeysProve(client, keys_, cb) {\n if (!client._sock || !isWritable(client._sock))\n return;\n\n if (typeof cb !== 'function')\n cb = noop;\n\n if (!Array.isArray(keys_))\n throw new TypeError('Invalid keys argument type');\n\n const keys = [];\n for (const key of keys_) {\n const parsed = parseKey(key);\n if (parsed instanceof Error)\n throw parsed;\n keys.push(parsed);\n }\n\n if (!client.config.strictVendor\n || (client.config.strictVendor && RE_OPENSSH.test(client._remoteVer))) {\n client._callbacks.push((had_err, data) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Server failed to prove supplied keys'));\n return;\n }\n\n // TODO: move all of this parsing/verifying logic out of the client?\n const ret = [];\n let keyIdx = 0;\n bufferParser.init(data, 0);\n while (bufferParser.avail()) {\n if (keyIdx === keys.length)\n break;\n const key = keys[keyIdx++];\n const keyPublic = key.getPublicSSH();\n\n const sigEntry = bufferParser.readString();\n sigParser.init(sigEntry, 0);\n const type = sigParser.readString(true);\n let value = sigParser.readString();\n\n let algo;\n if (type !== key.type) {\n if (key.type === 'ssh-rsa') {\n switch (type) {\n case 'rsa-sha2-256':\n algo = 'sha256';\n break;\n case 'rsa-sha2-512':\n algo = 'sha512';\n break;\n default:\n continue;\n }\n } else {\n continue;\n }\n }\n\n const sessionID = client._protocol._kex.sessionID;\n const verifyData = Buffer.allocUnsafe(\n 4 + 29 + 4 + sessionID.length + 4 + keyPublic.length\n );\n let p = 0;\n writeUInt32BE(verifyData, 29, p);\n verifyData.utf8Write('hostkeys-prove-00@openssh.com', p += 4, 29);\n writeUInt32BE(verifyData, sessionID.length, p += 29);\n bufferCopy(sessionID, verifyData, 0, sessionID.length, p += 4);\n writeUInt32BE(verifyData, keyPublic.length, p += sessionID.length);\n bufferCopy(keyPublic, verifyData, 0, keyPublic.length, p += 4);\n\n if (!(value = sigSSHToASN1(value, type)))\n continue;\n if (key.verify(verifyData, value, algo) === true)\n ret.push(key);\n }\n sigParser.clear();\n bufferParser.clear();\n\n cb(null, ret);\n });\n\n client._protocol.openssh_hostKeysProve(keys);\n return;\n }\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n}\n\nmodule.exports = Client;\n","'use strict';\n\nconst { Agent: HttpAgent } = require('http');\nconst { Agent: HttpsAgent } = require('https');\nconst { connect: tlsConnect } = require('tls');\n\nlet Client;\n\nfor (const ctor of [HttpAgent, HttpsAgent]) {\n class SSHAgent extends ctor {\n constructor(connectCfg, agentOptions) {\n super(agentOptions);\n\n this._connectCfg = connectCfg;\n this._defaultSrcIP = (agentOptions && agentOptions.srcIP) || 'localhost';\n }\n\n createConnection(options, cb) {\n const srcIP = (options && options.localAddress) || this._defaultSrcIP;\n const srcPort = (options && options.localPort) || 0;\n const dstIP = options.host;\n const dstPort = options.port;\n\n if (Client === undefined)\n Client = require('./client.js');\n\n const client = new Client();\n let triedForward = false;\n client.on('ready', () => {\n client.forwardOut(srcIP, srcPort, dstIP, dstPort, (err, stream) => {\n triedForward = true;\n if (err) {\n client.end();\n return cb(err);\n }\n stream.once('close', () => client.end());\n cb(null, decorateStream(stream, ctor, options));\n });\n }).on('error', cb).on('close', () => {\n if (!triedForward)\n cb(new Error('Unexpected connection close'));\n }).connect(this._connectCfg);\n }\n }\n\n exports[ctor === HttpAgent ? 'SSHTTPAgent' : 'SSHTTPSAgent'] = SSHAgent;\n}\n\nfunction noop() {}\n\nfunction decorateStream(stream, ctor, options) {\n if (ctor === HttpAgent) {\n // HTTP\n stream.setKeepAlive = noop;\n stream.setNoDelay = noop;\n stream.setTimeout = noop;\n stream.ref = noop;\n stream.unref = noop;\n stream.destroySoon = stream.destroy;\n return stream;\n }\n\n // HTTPS\n options.socket = stream;\n const wrapped = tlsConnect(options);\n\n // This is a workaround for a regression in node v12.16.3+\n // https://github.com/nodejs/node/issues/35904\n const onClose = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n if (stream.isPaused())\n stream.resume();\n };\n })();\n // 'end' listener is needed because 'close' is not emitted in some scenarios\n // in node v12.x for some unknown reason\n wrapped.on('end', onClose).on('close', onClose);\n\n return wrapped;\n}\n","'use strict';\n\nconst {\n AgentProtocol,\n BaseAgent,\n createAgent,\n CygwinAgent,\n OpenSSHAgent,\n PageantAgent,\n} = require('./agent.js');\nconst {\n SSHTTPAgent: HTTPAgent,\n SSHTTPSAgent: HTTPSAgent,\n} = require('./http-agents.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst {\n flagsToString,\n OPEN_MODE,\n STATUS_CODE,\n stringToFlags,\n} = require('./protocol/SFTP.js');\n\nmodule.exports = {\n AgentProtocol,\n BaseAgent,\n createAgent,\n Client: require('./client.js'),\n CygwinAgent,\n HTTPAgent,\n HTTPSAgent,\n OpenSSHAgent,\n PageantAgent,\n Server: require('./server.js'),\n utils: {\n parseKey,\n sftp: {\n flagsToString,\n OPEN_MODE,\n STATUS_CODE,\n stringToFlags,\n },\n },\n};\n","/*\n TODO:\n * Replace `buffer._pos` usage in keyParser.js and elsewhere\n * Utilize optional \"writev\" support when writing packets from\n cipher.encrypt()\n * Built-in support for automatic re-keying, on by default\n * Revisit receiving unexpected/unknown packets\n * Error (fatal or otherwise) or ignore or pass on to user (in some or all\n cases)?\n * Including server/client check for single directional packet types?\n * Check packets for validity or bail as early as possible?\n * Automatic re-key every 2**31 packets after the last key exchange (sent or\n received), as suggested by RFC4344. OpenSSH currently does this.\n * Automatic re-key every so many blocks depending on cipher. RFC4344:\n Because of a birthday property of block ciphers and some modes of\n operation, implementations must be careful not to encrypt too many\n blocks with the same encryption key.\n\n Let L be the block length (in bits) of an SSH encryption method's\n block cipher (e.g., 128 for AES). If L is at least 128, then, after\n rekeying, an SSH implementation SHOULD NOT encrypt more than 2**(L/4)\n blocks before rekeying again. If L is at least 128, then SSH\n implementations should also attempt to force a rekey before receiving\n more than 2**(L/4) blocks. If L is less than 128 (which is the case\n for older ciphers such as 3DES, Blowfish, CAST-128, and IDEA), then,\n although it may be too expensive to rekey every 2**(L/4) blocks, it\n is still advisable for SSH implementations to follow the original\n recommendation in [RFC4253]: rekey at least once for every gigabyte\n of transmitted data.\n\n Note that if L is less than or equal to 128, then the recommendation\n in this subsection supersedes the recommendation in Section 3.1. If\n an SSH implementation uses a block cipher with a larger block size\n (e.g., Rijndael with 256-bit blocks), then the recommendations in\n Section 3.1 may supersede the recommendations in this subsection\n (depending on the lengths of the packets).\n*/\n\n'use strict';\n\nconst { inspect } = require('util');\n\nconst { bindingAvailable, NullCipher, NullDecipher } = require('./crypto.js');\nconst {\n COMPAT_CHECKS,\n DISCONNECT_REASON,\n MESSAGE,\n SIGNALS,\n TERMINAL_MODE,\n} = require('./constants.js');\nconst {\n DEFAULT_KEXINIT,\n KexInit,\n kexinit,\n onKEXPayload,\n} = require('./kex.js');\nconst {\n parseKey,\n} = require('./keyParser.js');\nconst MESSAGE_HANDLERS = require('./handlers.js');\nconst {\n bufferCopy,\n bufferFill,\n bufferSlice,\n convertSignature,\n sendPacket,\n writeUInt32BE,\n} = require('./utils.js');\nconst {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n} = require('./zlib.js');\n\nconst MODULE_VER = require('../../package.json').version;\n\nconst VALID_DISCONNECT_REASONS = new Map(\n Object.values(DISCONNECT_REASON).map((n) => [n, 1])\n);\nconst IDENT_RAW = Buffer.from(`SSH-2.0-ssh2js${MODULE_VER}`);\nconst IDENT = Buffer.from(`${IDENT_RAW}\\r\\n`);\nconst MAX_LINE_LEN = 8192;\nconst MAX_LINES = 1024;\nconst PING_PAYLOAD = Buffer.from([\n MESSAGE.GLOBAL_REQUEST,\n // \"keepalive@openssh.com\"\n 0, 0, 0, 21,\n 107, 101, 101, 112, 97, 108, 105, 118, 101, 64, 111, 112, 101, 110, 115,\n 115, 104, 46, 99, 111, 109,\n // Request a reply\n 1,\n]);\nconst NO_TERMINAL_MODES_BUFFER = Buffer.from([ TERMINAL_MODE.TTY_OP_END ]);\n\nfunction noop() {}\n\n/*\n Inbound:\n * kexinit payload (needed only until exchange hash is generated)\n * raw ident\n * rekey packet queue\n * expected packet (implemented as separate _parse() function?)\n Outbound:\n * kexinit payload (needed only until exchange hash is generated)\n * rekey packet queue\n * kex secret (needed only until NEWKEYS)\n * exchange hash (needed only until NEWKEYS)\n * session ID (set to exchange hash from initial handshake)\n*/\nclass Protocol {\n constructor(config) {\n const onWrite = config.onWrite;\n if (typeof onWrite !== 'function')\n throw new Error('Missing onWrite function');\n this._onWrite = (data) => { onWrite(data); };\n\n const onError = config.onError;\n if (typeof onError !== 'function')\n throw new Error('Missing onError function');\n this._onError = (err) => { onError(err); };\n\n const debug = config.debug;\n this._debug = (typeof debug === 'function'\n ? (msg) => { debug(msg); }\n : undefined);\n\n const onHeader = config.onHeader;\n this._onHeader = (typeof onHeader === 'function'\n ? (...args) => { onHeader(...args); }\n : noop);\n\n const onPacket = config.onPacket;\n this._onPacket = (typeof onPacket === 'function'\n ? () => { onPacket(); }\n : noop);\n\n let onHandshakeComplete = config.onHandshakeComplete;\n if (typeof onHandshakeComplete !== 'function')\n onHandshakeComplete = noop;\n this._onHandshakeComplete = (...args) => {\n this._debug && this._debug('Handshake completed');\n\n // Process packets queued during a rekey where necessary\n const oldQueue = this._queue;\n if (oldQueue) {\n this._queue = undefined;\n this._debug && this._debug(\n `Draining outbound queue (${oldQueue.length}) ...`\n );\n for (let i = 0; i < oldQueue.length; ++i) {\n const data = oldQueue[i];\n // data === payload only\n\n // XXX: hacky\n let finalized = this._packetRW.write.finalize(data);\n if (finalized === data) {\n const packet = this._cipher.allocPacket(data.length);\n packet.set(data, 5);\n finalized = packet;\n }\n\n sendPacket(this, finalized);\n }\n this._debug && this._debug('... finished draining outbound queue');\n }\n\n onHandshakeComplete(...args);\n };\n this._queue = undefined;\n\n const messageHandlers = config.messageHandlers;\n if (typeof messageHandlers === 'object' && messageHandlers !== null)\n this._handlers = messageHandlers;\n else\n this._handlers = {};\n\n this._onPayload = onPayload.bind(this);\n\n this._server = !!config.server;\n this._banner = undefined;\n let greeting;\n if (this._server) {\n if (typeof config.hostKeys !== 'object' || config.hostKeys === null)\n throw new Error('Missing server host key(s)');\n this._hostKeys = config.hostKeys;\n\n // Greeting displayed before the ssh identification string is sent, this\n // is usually ignored by most clients\n if (typeof config.greeting === 'string' && config.greeting.length) {\n greeting = (config.greeting.slice(-2) === '\\r\\n'\n ? config.greeting\n : `${config.greeting}\\r\\n`);\n }\n\n // Banner shown after the handshake completes, but before user\n // authentication begins\n if (typeof config.banner === 'string' && config.banner.length) {\n this._banner = (config.banner.slice(-2) === '\\r\\n'\n ? config.banner\n : `${config.banner}\\r\\n`);\n }\n } else {\n this._hostKeys = undefined;\n }\n\n let offer = config.offer;\n if (typeof offer !== 'object' || offer === null)\n offer = DEFAULT_KEXINIT;\n else if (offer.constructor !== KexInit)\n offer = new KexInit(offer);\n this._kex = undefined;\n this._kexinit = undefined;\n this._offer = offer;\n this._cipher = new NullCipher(0, this._onWrite);\n this._decipher = undefined;\n this._skipNextInboundPacket = false;\n this._packetRW = {\n read: new PacketReader(),\n write: new PacketWriter(this),\n };\n this._hostVerifier = (!this._server\n && typeof config.hostVerifier === 'function'\n ? config.hostVerifier\n : undefined);\n\n this._parse = parseHeader;\n this._buffer = undefined;\n this._authsQueue = [];\n this._authenticated = false;\n this._remoteIdentRaw = undefined;\n let sentIdent;\n if (typeof config.ident === 'string') {\n this._identRaw = Buffer.from(`SSH-2.0-${config.ident}`);\n\n sentIdent = Buffer.allocUnsafe(this._identRaw.length + 2);\n sentIdent.set(this._identRaw, 0);\n sentIdent[sentIdent.length - 2] = 13; // '\\r'\n sentIdent[sentIdent.length - 1] = 10; // '\\n'\n } else if (Buffer.isBuffer(config.ident)) {\n const fullIdent = Buffer.allocUnsafe(8 + config.ident.length);\n fullIdent.latin1Write('SSH-2.0-', 0, 8);\n fullIdent.set(config.ident, 8);\n this._identRaw = fullIdent;\n\n sentIdent = Buffer.allocUnsafe(fullIdent.length + 2);\n sentIdent.set(fullIdent, 0);\n sentIdent[sentIdent.length - 2] = 13; // '\\r'\n sentIdent[sentIdent.length - 1] = 10; // '\\n'\n } else {\n this._identRaw = IDENT_RAW;\n sentIdent = IDENT;\n }\n this._compatFlags = 0;\n\n if (this._debug) {\n if (bindingAvailable)\n this._debug('Custom crypto binding available');\n else\n this._debug('Custom crypto binding not available');\n }\n\n this._debug && this._debug(\n `Local ident: ${inspect(this._identRaw.toString())}`\n );\n this.start = () => {\n this.start = undefined;\n if (greeting)\n this._onWrite(greeting);\n this._onWrite(sentIdent);\n };\n }\n _destruct(reason) {\n this._packetRW.read.cleanup();\n this._packetRW.write.cleanup();\n this._cipher && this._cipher.free();\n this._decipher && this._decipher.free();\n if (typeof reason !== 'string' || reason.length === 0)\n reason = 'fatal error';\n this.parse = () => {\n throw new Error(`Instance unusable after ${reason}`);\n };\n this._onWrite = () => {\n throw new Error(`Instance unusable after ${reason}`);\n };\n this._destruct = undefined;\n }\n cleanup() {\n this._destruct && this._destruct();\n }\n parse(chunk, i, len) {\n while (i < len)\n i = this._parse(chunk, i, len);\n }\n\n // Protocol message API\n\n // ===========================================================================\n // Common/Shared =============================================================\n // ===========================================================================\n\n // Global\n // ------\n disconnect(reason) {\n const pktLen = 1 + 4 + 4 + 4;\n // We don't use _packetRW.write.* here because we need to make sure that\n // we always get a full packet allocated because this message can be sent\n // at any time -- even during a key exchange\n let p = this._packetRW.write.allocStartKEX;\n const packet = this._packetRW.write.alloc(pktLen, true);\n const end = p + pktLen;\n\n if (!VALID_DISCONNECT_REASONS.has(reason))\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n\n packet[p] = MESSAGE.DISCONNECT;\n writeUInt32BE(packet, reason, ++p);\n packet.fill(0, p += 4, end);\n\n this._debug && this._debug(`Outbound: Sending DISCONNECT (${reason})`);\n sendPacket(this, this._packetRW.write.finalize(packet, true), true);\n }\n ping() {\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(PING_PAYLOAD.length);\n\n packet.set(PING_PAYLOAD, p);\n\n this._debug && this._debug(\n 'Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n rekey() {\n if (this._kexinit === undefined) {\n this._debug && this._debug('Outbound: Initiated explicit rekey');\n this._queue = [];\n kexinit(this);\n } else {\n this._debug && this._debug('Outbound: Ignoring rekey during handshake');\n }\n }\n\n // 'ssh-connection' service-specific\n // ---------------------------------\n requestSuccess(data) {\n let p = this._packetRW.write.allocStart;\n let packet;\n if (Buffer.isBuffer(data)) {\n packet = this._packetRW.write.alloc(1 + data.length);\n\n packet[p] = MESSAGE.REQUEST_SUCCESS;\n\n packet.set(data, ++p);\n } else {\n packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.REQUEST_SUCCESS;\n }\n\n this._debug && this._debug('Outbound: Sending REQUEST_SUCCESS');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n requestFailure() {\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.REQUEST_FAILURE;\n\n this._debug && this._debug('Outbound: Sending REQUEST_FAILURE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelSuccess(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_SUCCESS;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelFailure(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_FAILURE;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelEOF(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_EOF;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_EOF (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelClose(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_CLOSE;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelWindowAdjust(chan, amount) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_WINDOW_ADJUST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, amount, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${chan}, ${amount})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelData(chan, data) {\n const isBuffer = Buffer.isBuffer(data);\n const dataLen = (isBuffer ? data.length : Buffer.byteLength(data));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + dataLen);\n\n packet[p] = MESSAGE.CHANNEL_DATA;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, dataLen, p += 4);\n\n if (isBuffer)\n packet.set(data, p += 4);\n else\n packet.utf8Write(data, p += 4, dataLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_DATA (r:${chan}, ${dataLen})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelExtData(chan, data, type) {\n const isBuffer = Buffer.isBuffer(data);\n const dataLen = (isBuffer ? data.length : Buffer.byteLength(data));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + dataLen);\n\n packet[p] = MESSAGE.CHANNEL_EXTENDED_DATA;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, type, p += 4);\n\n writeUInt32BE(packet, dataLen, p += 4);\n\n if (isBuffer)\n packet.set(data, p += 4);\n else\n packet.utf8Write(data, p += 4, dataLen);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelOpenConfirm(remote, local, initWindow, maxPacket) {\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN_CONFIRMATION;\n\n writeUInt32BE(packet, remote, ++p);\n\n writeUInt32BE(packet, local, p += 4);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${remote}, l:${local})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelOpenFail(remote, reason, desc) {\n if (typeof desc !== 'string')\n desc = '';\n\n const descLen = Buffer.byteLength(desc);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + descLen + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN_FAILURE;\n\n writeUInt32BE(packet, remote, ++p);\n\n writeUInt32BE(packet, reason, p += 4);\n\n writeUInt32BE(packet, descLen, p += 4);\n\n p += 4;\n if (descLen) {\n packet.utf8Write(desc, p, descLen);\n p += descLen;\n }\n\n writeUInt32BE(packet, 0, p); // Empty language tag\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${remote})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // ===========================================================================\n // Client-specific ===========================================================\n // ===========================================================================\n\n // Global\n // ------\n service(name) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const nameLen = Buffer.byteLength(name);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + nameLen);\n\n packet[p] = MESSAGE.SERVICE_REQUEST;\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(name, p += 4, nameLen);\n\n this._debug && this._debug(`Outbound: Sending SERVICE_REQUEST (${name})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // 'ssh-userauth' service-specific\n // -------------------------------\n authPassword(username, password, newPassword) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n const passLen = Buffer.byteLength(password);\n const newPassLen = (newPassword ? Buffer.byteLength(newPassword) : 0);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 8 + 1 + 4 + passLen\n + (newPassword ? 4 + newPassLen : 0)\n );\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 8, p += 14);\n packet.utf8Write('password', p += 4, 8);\n\n packet[p += 8] = (newPassword ? 1 : 0);\n\n writeUInt32BE(packet, passLen, ++p);\n if (Buffer.isBuffer(password))\n bufferCopy(password, packet, 0, passLen, p += 4);\n else\n packet.utf8Write(password, p += 4, passLen);\n\n if (newPassword) {\n writeUInt32BE(packet, newPassLen, p += passLen);\n if (Buffer.isBuffer(newPassword))\n bufferCopy(newPassword, packet, 0, newPassLen, p += 4);\n else\n packet.utf8Write(newPassword, p += 4, newPassLen);\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (changed password)'\n );\n } else {\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (password)'\n );\n }\n\n this._authsQueue.push('password');\n\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authPK(username, pubKey, cbSign) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n pubKey = parseKey(pubKey);\n if (pubKey instanceof Error)\n throw new Error('Invalid key');\n\n const keyType = pubKey.type;\n pubKey = pubKey.getPublicSSH();\n\n const userLen = Buffer.byteLength(username);\n const algoLen = Buffer.byteLength(keyType);\n const pubKeyLen = pubKey.length;\n const sessionID = this._kex.sessionID;\n const sesLen = sessionID.length;\n const payloadLen =\n (cbSign ? 4 + sesLen : 0)\n + 1 + 4 + userLen + 4 + 14 + 4 + 9 + 1 + 4 + algoLen + 4 + pubKeyLen;\n let packet;\n let p;\n if (cbSign) {\n packet = Buffer.allocUnsafe(payloadLen);\n p = 0;\n writeUInt32BE(packet, sesLen, p);\n packet.set(sessionID, p += 4);\n p += sesLen;\n } else {\n packet = this._packetRW.write.alloc(payloadLen);\n p = this._packetRW.write.allocStart;\n }\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 9, p += 14);\n packet.utf8Write('publickey', p += 4, 9);\n\n packet[p += 9] = (cbSign ? 1 : 0);\n\n writeUInt32BE(packet, algoLen, ++p);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, pubKeyLen, p += algoLen);\n packet.set(pubKey, p += 4);\n\n if (!cbSign) {\n this._authsQueue.push('publickey');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (publickey -- check)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n return;\n }\n\n cbSign(packet, (signature) => {\n signature = convertSignature(signature, keyType);\n if (signature === false)\n throw new Error('Error while converting handshake signature');\n\n const sigLen = signature.length;\n p = this._packetRW.write.allocStart;\n packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 9 + 1 + 4 + algoLen + 4 + pubKeyLen + 4\n + 4 + algoLen + 4 + sigLen\n );\n\n // TODO: simply copy from original \"packet\" to new `packet` to avoid\n // having to write each individual field a second time?\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 9, p += 14);\n packet.utf8Write('publickey', p += 4, 9);\n\n packet[p += 9] = 1;\n\n writeUInt32BE(packet, algoLen, ++p);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, pubKeyLen, p += algoLen);\n packet.set(pubKey, p += 4);\n\n writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += pubKeyLen);\n\n writeUInt32BE(packet, algoLen, p += 4);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, sigLen, p += algoLen);\n packet.set(signature, p += 4);\n\n // Servers shouldn't send packet type 60 in response to signed publickey\n // attempts, but if they do, interpret as type 60.\n this._authsQueue.push('publickey');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (publickey)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n });\n }\n authHostbased(username, pubKey, hostname, userlocal, cbSign) {\n // TODO: Make DRY by sharing similar code with authPK()\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n pubKey = parseKey(pubKey);\n if (pubKey instanceof Error)\n throw new Error('Invalid key');\n\n const keyType = pubKey.type;\n pubKey = pubKey.getPublicSSH();\n\n const userLen = Buffer.byteLength(username);\n const algoLen = Buffer.byteLength(keyType);\n const pubKeyLen = pubKey.length;\n const sessionID = this._kex.sessionID;\n const sesLen = sessionID.length;\n const hostnameLen = Buffer.byteLength(hostname);\n const userlocalLen = Buffer.byteLength(userlocal);\n const data = Buffer.allocUnsafe(\n 4 + sesLen + 1 + 4 + userLen + 4 + 14 + 4 + 9 + 4 + algoLen\n + 4 + pubKeyLen + 4 + hostnameLen + 4 + userlocalLen\n );\n let p = 0;\n\n writeUInt32BE(data, sesLen, p);\n data.set(sessionID, p += 4);\n\n data[p += sesLen] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(data, userLen, ++p);\n data.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(data, 14, p += userLen);\n data.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(data, 9, p += 14);\n data.utf8Write('hostbased', p += 4, 9);\n\n writeUInt32BE(data, algoLen, p += 9);\n data.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(data, pubKeyLen, p += algoLen);\n data.set(pubKey, p += 4);\n\n writeUInt32BE(data, hostnameLen, p += pubKeyLen);\n data.utf8Write(hostname, p += 4, hostnameLen);\n\n writeUInt32BE(data, userlocalLen, p += hostnameLen);\n data.utf8Write(userlocal, p += 4, userlocalLen);\n\n cbSign(data, (signature) => {\n signature = convertSignature(signature, keyType);\n if (!signature)\n throw new Error('Error while converting handshake signature');\n\n const sigLen = signature.length;\n const reqDataLen = (data.length - sesLen - 4);\n p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n reqDataLen + 4 + 4 + algoLen + 4 + sigLen\n );\n\n bufferCopy(data, packet, 4 + sesLen, data.length, p);\n\n writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += reqDataLen);\n writeUInt32BE(packet, algoLen, p += 4);\n packet.utf8Write(keyType, p += 4, algoLen);\n writeUInt32BE(packet, sigLen, p += algoLen);\n packet.set(signature, p += 4);\n\n this._authsQueue.push('hostbased');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (hostbased)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n });\n }\n authKeyboard(username) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 20 + 4 + 4\n );\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 20, p += 14);\n packet.utf8Write('keyboard-interactive', p += 4, 20);\n\n writeUInt32BE(packet, 0, p += 20);\n\n writeUInt32BE(packet, 0, p += 4);\n\n this._authsQueue.push('keyboard-interactive');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authNone(username) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + userLen + 4 + 14 + 4 + 4);\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 4, p += 14);\n packet.utf8Write('none', p += 4, 4);\n\n this._authsQueue.push('none');\n\n this._debug && this._debug('Outbound: Sending USERAUTH_REQUEST (none)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authInfoRes(responses) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let responsesTotalLen = 0;\n let responseLens;\n\n if (responses) {\n responseLens = new Array(responses.length);\n for (let i = 0; i < responses.length; ++i) {\n const len = Buffer.byteLength(responses[i]);\n responseLens[i] = len;\n responsesTotalLen += 4 + len;\n }\n }\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + responsesTotalLen);\n\n packet[p] = MESSAGE.USERAUTH_INFO_RESPONSE;\n\n if (responses) {\n writeUInt32BE(packet, responses.length, ++p);\n p += 4;\n for (let i = 0; i < responses.length; ++i) {\n const len = responseLens[i];\n writeUInt32BE(packet, len, p);\n p += 4;\n if (len) {\n packet.utf8Write(responses[i], p, len);\n p += len;\n }\n }\n } else {\n writeUInt32BE(packet, 0, ++p);\n }\n\n this._debug && this._debug('Outbound: Sending USERAUTH_INFO_RESPONSE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // 'ssh-connection' service-specific\n // ---------------------------------\n tcpipForward(bindAddr, bindPort, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const addrLen = Buffer.byteLength(bindAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 13 + 1 + 4 + addrLen + 4);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 13, ++p);\n packet.utf8Write('tcpip-forward', p += 4, 13);\n\n packet[p += 13] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, addrLen, ++p);\n packet.utf8Write(bindAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, bindPort, p += addrLen);\n\n this._debug\n && this._debug('Outbound: Sending GLOBAL_REQUEST (tcpip-forward)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n cancelTcpipForward(bindAddr, bindPort, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const addrLen = Buffer.byteLength(bindAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 20 + 1 + 4 + addrLen + 4);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 20, ++p);\n packet.utf8Write('cancel-tcpip-forward', p += 4, 20);\n\n packet[p += 20] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, addrLen, ++p);\n packet.utf8Write(bindAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, bindPort, p += addrLen);\n\n this._debug\n && this._debug('Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_streamLocalForward(socketPath, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const socketPathLen = Buffer.byteLength(socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 31 + 1 + 4 + socketPathLen\n );\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 31, ++p);\n packet.utf8Write('streamlocal-forward@openssh.com', p += 4, 31);\n\n packet[p += 31] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, socketPathLen, ++p);\n packet.utf8Write(socketPath, p += 4, socketPathLen);\n\n this._debug && this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_cancelStreamLocalForward(socketPath, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const socketPathLen = Buffer.byteLength(socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 38 + 1 + 4 + socketPathLen\n );\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 38, ++p);\n packet.utf8Write('cancel-streamlocal-forward@openssh.com', p += 4, 38);\n\n packet[p += 38] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, socketPathLen, ++p);\n packet.utf8Write(socketPath, p += 4, socketPathLen);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending GLOBAL_REQUEST '\n + '(cancel-streamlocal-forward@openssh.com)'\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n directTcpip(chan, initWindow, maxPacket, cfg) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const srcLen = Buffer.byteLength(cfg.srcIP);\n const dstLen = Buffer.byteLength(cfg.dstIP);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 12 + 4 + 4 + 4 + 4 + srcLen + 4 + 4 + dstLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 12, ++p);\n packet.utf8Write('direct-tcpip', p += 4, 12);\n\n writeUInt32BE(packet, chan, p += 12);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, dstLen, p += 4);\n packet.utf8Write(cfg.dstIP, p += 4, dstLen);\n\n writeUInt32BE(packet, cfg.dstPort, p += dstLen);\n\n writeUInt32BE(packet, srcLen, p += 4);\n packet.utf8Write(cfg.srcIP, p += 4, srcLen);\n\n writeUInt32BE(packet, cfg.srcPort, p += srcLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, direct-tcpip)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_directStreamLocal(chan, initWindow, maxPacket, cfg) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const pathLen = Buffer.byteLength(cfg.socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 30 + 4 + 4 + 4 + 4 + pathLen + 4 + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 30, ++p);\n packet.utf8Write('direct-streamlocal@openssh.com', p += 4, 30);\n\n writeUInt32BE(packet, chan, p += 30);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, pathLen, p += 4);\n packet.utf8Write(cfg.socketPath, p += 4, pathLen);\n\n // zero-fill reserved fields (string and uint32)\n bufferFill(packet, 0, p += pathLen, p + 8);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_OPEN '\n + `(r:${chan}, direct-streamlocal@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_noMoreSessions(wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 28 + 1);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 28, ++p);\n packet.utf8Write('no-more-sessions@openssh.com', p += 4, 28);\n\n packet[p += 28] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n this._debug && this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n session(chan, initWindow, maxPacket) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 7 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 7, ++p);\n packet.utf8Write('session', p += 4, 7);\n\n writeUInt32BE(packet, chan, p += 7);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_OPEN (r:${chan}, session)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n windowChange(chan, rows, cols, height, width) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 13 + 1 + 4 + 4 + 4 + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 13, p += 4);\n packet.utf8Write('window-change', p += 4, 13);\n\n packet[p += 13] = 0;\n\n writeUInt32BE(packet, cols, ++p);\n\n writeUInt32BE(packet, rows, p += 4);\n\n writeUInt32BE(packet, width, p += 4);\n\n writeUInt32BE(packet, height, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, window-change)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n pty(chan, rows, cols, height, width, term, modes, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n if (!term || !term.length)\n term = 'vt100';\n if (modes\n && !Buffer.isBuffer(modes)\n && !Array.isArray(modes)\n && typeof modes === 'object'\n && modes !== null) {\n modes = modesToBytes(modes);\n }\n if (!modes || !modes.length)\n modes = NO_TERMINAL_MODES_BUFFER;\n\n const termLen = term.length;\n const modesLen = modes.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 7 + 1 + 4 + termLen + 4 + 4 + 4 + 4 + 4 + modesLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 7, p += 4);\n packet.utf8Write('pty-req', p += 4, 7);\n\n packet[p += 7] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, termLen, ++p);\n packet.utf8Write(term, p += 4, termLen);\n\n writeUInt32BE(packet, cols, p += termLen);\n\n writeUInt32BE(packet, rows, p += 4);\n\n writeUInt32BE(packet, width, p += 4);\n\n writeUInt32BE(packet, height, p += 4);\n\n writeUInt32BE(packet, modesLen, p += 4);\n p += 4;\n if (Array.isArray(modes)) {\n for (let i = 0; i < modesLen; ++i)\n packet[p++] = modes[i];\n } else if (Buffer.isBuffer(modes)) {\n packet.set(modes, p);\n }\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, pty-req)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n shell(chan, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 5 + 1);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 5, p += 4);\n packet.utf8Write('shell', p += 4, 5);\n\n packet[p += 5] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, shell)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exec(chan, cmd, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const isBuf = Buffer.isBuffer(cmd);\n const cmdLen = (isBuf ? cmd.length : Buffer.byteLength(cmd));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + 1 + 4 + cmdLen);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 4, p += 4);\n packet.utf8Write('exec', p += 4, 4);\n\n packet[p += 4] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, cmdLen, ++p);\n if (isBuf)\n packet.set(cmd, p += 4);\n else\n packet.utf8Write(cmd, p += 4, cmdLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exec: ${cmd})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n signal(chan, signal) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const origSignal = signal;\n\n signal = signal.toUpperCase();\n if (signal.slice(0, 3) === 'SIG')\n signal = signal.slice(3);\n\n if (SIGNALS[signal] !== 1)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n const signalLen = signal.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 6 + 1 + 4 + signalLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 6, p += 4);\n packet.utf8Write('signal', p += 4, 6);\n\n packet[p += 6] = 0;\n\n writeUInt32BE(packet, signalLen, ++p);\n packet.utf8Write(signal, p += 4, signalLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, signal: ${signal})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n env(chan, key, val, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const keyLen = Buffer.byteLength(key);\n const isBuf = Buffer.isBuffer(val);\n const valLen = (isBuf ? val.length : Buffer.byteLength(val));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 3 + 1 + 4 + keyLen + 4 + valLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 3, p += 4);\n packet.utf8Write('env', p += 4, 3);\n\n packet[p += 3] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, keyLen, ++p);\n packet.utf8Write(key, p += 4, keyLen);\n\n writeUInt32BE(packet, valLen, p += keyLen);\n if (isBuf)\n packet.set(val, p += 4);\n else\n packet.utf8Write(val, p += 4, valLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, env: ${key}=${val})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n x11Forward(chan, cfg, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const protocol = cfg.protocol;\n const cookie = cfg.cookie;\n const isBufProto = Buffer.isBuffer(protocol);\n const protoLen = (isBufProto\n ? protocol.length\n : Buffer.byteLength(protocol));\n const isBufCookie = Buffer.isBuffer(cookie);\n const cookieLen = (isBufCookie\n ? cookie.length\n : Buffer.byteLength(cookie));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 7 + 1 + 1 + 4 + protoLen + 4 + cookieLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 7, p += 4);\n packet.utf8Write('x11-req', p += 4, 7);\n\n packet[p += 7] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n packet[++p] = (cfg.single ? 1 : 0);\n\n writeUInt32BE(packet, protoLen, ++p);\n if (isBufProto)\n packet.set(protocol, p += 4);\n else\n packet.utf8Write(protocol, p += 4, protoLen);\n\n writeUInt32BE(packet, cookieLen, p += protoLen);\n if (isBufCookie)\n packet.set(cookie, p += 4);\n else\n packet.latin1Write(cookie, p += 4, cookieLen);\n\n writeUInt32BE(packet, (cfg.screen || 0), p += cookieLen);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, x11-req)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n subsystem(chan, name, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n const nameLen = Buffer.byteLength(name);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 9 + 1 + 4 + nameLen);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 9, p += 4);\n packet.utf8Write('subsystem', p += 4, 9);\n\n packet[p += 9] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(name, p += 4, nameLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, subsystem: ${name})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_agentForward(chan, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 26 + 1);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 26, p += 4);\n packet.utf8Write('auth-agent-req@openssh.com', p += 4, 26);\n\n packet[p += 26] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_REQUEST '\n + `(r:${chan}, auth-agent-req@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_hostKeysProve(keys) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let keysTotal = 0;\n const publicKeys = [];\n for (const key of keys) {\n const publicKey = key.getPublicSSH();\n keysTotal += 4 + publicKey.length;\n publicKeys.push(publicKey);\n }\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 29 + 1 + keysTotal);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 29, ++p);\n packet.utf8Write('hostkeys-prove-00@openssh.com', p += 4, 29);\n\n packet[p += 29] = 1; // want reply\n\n ++p;\n for (const buf of publicKeys) {\n writeUInt32BE(packet, buf.length, p);\n bufferCopy(buf, packet, 0, buf.length, p += 4);\n p += buf.length;\n }\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)'\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // ===========================================================================\n // Server-specific ===========================================================\n // ===========================================================================\n\n // Global\n // ------\n serviceAccept(svcName) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const svcNameLen = Buffer.byteLength(svcName);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + svcNameLen);\n\n packet[p] = MESSAGE.SERVICE_ACCEPT;\n\n writeUInt32BE(packet, svcNameLen, ++p);\n packet.utf8Write(svcName, p += 4, svcNameLen);\n\n this._debug && this._debug(`Outbound: Sending SERVICE_ACCEPT (${svcName})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n\n if (this._server && this._banner && svcName === 'ssh-userauth') {\n const banner = this._banner;\n this._banner = undefined; // Prevent banner from being displayed again\n const bannerLen = Buffer.byteLength(banner);\n p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + bannerLen + 4);\n\n packet[p] = MESSAGE.USERAUTH_BANNER;\n\n writeUInt32BE(packet, bannerLen, ++p);\n packet.utf8Write(banner, p += 4, bannerLen);\n\n writeUInt32BE(packet, 0, p += bannerLen); // Empty language tag\n\n this._debug && this._debug('Outbound: Sending USERAUTH_BANNER');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n }\n // 'ssh-connection' service-specific\n forwardedTcpip(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const boundAddrLen = Buffer.byteLength(cfg.boundAddr);\n const remoteAddrLen = Buffer.byteLength(cfg.remoteAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 15 + 4 + 4 + 4 + 4 + boundAddrLen + 4 + 4 + remoteAddrLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 15, ++p);\n packet.utf8Write('forwarded-tcpip', p += 4, 15);\n\n writeUInt32BE(packet, chan, p += 15);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, boundAddrLen, p += 4);\n packet.utf8Write(cfg.boundAddr, p += 4, boundAddrLen);\n\n writeUInt32BE(packet, cfg.boundPort, p += boundAddrLen);\n\n writeUInt32BE(packet, remoteAddrLen, p += 4);\n packet.utf8Write(cfg.remoteAddr, p += 4, remoteAddrLen);\n\n writeUInt32BE(packet, cfg.remotePort, p += remoteAddrLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, forwarded-tcpip)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n x11(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const addrLen = Buffer.byteLength(cfg.originAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 3 + 4 + 4 + 4 + 4 + addrLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 3, ++p);\n packet.utf8Write('x11', p += 4, 3);\n\n writeUInt32BE(packet, chan, p += 3);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, addrLen, p += 4);\n packet.utf8Write(cfg.originAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, cfg.originPort, p += addrLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, x11)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_authAgent(chan, initWindow, maxPacket) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 22 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 22, ++p);\n packet.utf8Write('auth-agent@openssh.com', p += 4, 22);\n\n writeUInt32BE(packet, chan, p += 22);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, auth-agent@openssh.com)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_forwardedStreamLocal(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const pathLen = Buffer.byteLength(cfg.socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 33 + 4 + 4 + 4 + 4 + pathLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 33, ++p);\n packet.utf8Write('forwarded-streamlocal@openssh.com', p += 4, 33);\n\n writeUInt32BE(packet, chan, p += 33);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, pathLen, p += 4);\n packet.utf8Write(cfg.socketPath, p += 4, pathLen);\n\n writeUInt32BE(packet, 0, p += pathLen);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_OPEN '\n + `(r:${chan}, forwarded-streamlocal@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exitStatus(chan, status) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 11 + 1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-status', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, status, ++p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-status: ${status})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exitSignal(chan, name, coreDumped, msg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n\n const origSignal = name;\n\n if (typeof origSignal !== 'string' || !origSignal)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n let signal = name.toUpperCase();\n if (signal.slice(0, 3) === 'SIG')\n signal = signal.slice(3);\n\n if (SIGNALS[signal] !== 1)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n const nameLen = Buffer.byteLength(signal);\n const msgLen = (msg ? Buffer.byteLength(msg) : 0);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 11 + 1 + 4 + nameLen + 1 + 4 + msgLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-signal', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(signal, p += 4, nameLen);\n\n packet[p += nameLen] = (coreDumped ? 1 : 0);\n\n writeUInt32BE(packet, msgLen, ++p);\n\n p += 4;\n if (msgLen) {\n packet.utf8Write(msg, p, msgLen);\n p += msgLen;\n }\n\n writeUInt32BE(packet, 0, p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-signal: ${name})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n // 'ssh-userauth' service-specific\n authFailure(authMethods, isPartial) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0)\n throw new Error('No auth in progress');\n\n let methods;\n\n if (typeof authMethods === 'boolean') {\n isPartial = authMethods;\n authMethods = undefined;\n }\n\n if (authMethods) {\n methods = [];\n for (let i = 0; i < authMethods.length; ++i) {\n if (authMethods[i].toLowerCase() === 'none')\n continue;\n methods.push(authMethods[i]);\n }\n methods = methods.join(',');\n } else {\n methods = '';\n }\n\n const methodsLen = methods.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + methodsLen + 1);\n\n packet[p] = MESSAGE.USERAUTH_FAILURE;\n\n writeUInt32BE(packet, methodsLen, ++p);\n packet.utf8Write(methods, p += 4, methodsLen);\n\n packet[p += methodsLen] = (isPartial === true ? 1 : 0);\n\n this._authsQueue.shift();\n\n this._debug && this._debug('Outbound: Sending USERAUTH_FAILURE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authSuccess() {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0)\n throw new Error('No auth in progress');\n\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.USERAUTH_SUCCESS;\n\n this._authsQueue.shift();\n this._authenticated = true;\n\n this._debug && this._debug('Outbound: Sending USERAUTH_SUCCESS');\n sendPacket(this, this._packetRW.write.finalize(packet));\n\n if (this._kex.negotiated.cs.compress === 'zlib@openssh.com')\n this._packetRW.read = new ZlibPacketReader();\n if (this._kex.negotiated.sc.compress === 'zlib@openssh.com')\n this._packetRW.write = new ZlibPacketWriter(this);\n }\n authPKOK(keyAlgo, key) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0 || this._authsQueue[0] !== 'publickey')\n throw new Error('\"publickey\" auth not in progress');\n\n // TODO: support parsed key for `key`\n\n const keyAlgoLen = Buffer.byteLength(keyAlgo);\n const keyLen = key.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + keyAlgoLen + 4 + keyLen);\n\n packet[p] = MESSAGE.USERAUTH_PK_OK;\n\n writeUInt32BE(packet, keyAlgoLen, ++p);\n packet.utf8Write(keyAlgo, p += 4, keyAlgoLen);\n\n writeUInt32BE(packet, keyLen, p += keyAlgoLen);\n packet.set(key, p += 4);\n\n this._authsQueue.shift();\n\n this._debug && this._debug('Outbound: Sending USERAUTH_PK_OK');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authPasswdChg(prompt) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const promptLen = Buffer.byteLength(prompt);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + promptLen + 4);\n\n packet[p] = MESSAGE.USERAUTH_PASSWD_CHANGEREQ;\n\n writeUInt32BE(packet, promptLen, ++p);\n packet.utf8Write(prompt, p += 4, promptLen);\n\n writeUInt32BE(packet, 0, p += promptLen); // Empty language tag\n\n this._debug && this._debug('Outbound: Sending USERAUTH_PASSWD_CHANGEREQ');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authInfoReq(name, instructions, prompts) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n let promptsLen = 0;\n const nameLen = name ? Buffer.byteLength(name) : 0;\n const instrLen = instructions ? Buffer.byteLength(instructions) : 0;\n\n for (let i = 0; i < prompts.length; ++i)\n promptsLen += 4 + Buffer.byteLength(prompts[i].prompt) + 1;\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + nameLen + 4 + instrLen + 4 + 4 + promptsLen\n );\n\n packet[p] = MESSAGE.USERAUTH_INFO_REQUEST;\n\n writeUInt32BE(packet, nameLen, ++p);\n p += 4;\n if (name) {\n packet.utf8Write(name, p, nameLen);\n p += nameLen;\n }\n\n writeUInt32BE(packet, instrLen, p);\n p += 4;\n if (instructions) {\n packet.utf8Write(instructions, p, instrLen);\n p += instrLen;\n }\n\n writeUInt32BE(packet, 0, p);\n\n writeUInt32BE(packet, prompts.length, p += 4);\n p += 4;\n for (let i = 0; i < prompts.length; ++i) {\n const prompt = prompts[i];\n const promptLen = Buffer.byteLength(prompt.prompt);\n\n writeUInt32BE(packet, promptLen, p);\n p += 4;\n if (promptLen) {\n packet.utf8Write(prompt.prompt, p, promptLen);\n p += promptLen;\n }\n packet[p++] = (prompt.echo ? 1 : 0);\n }\n\n this._debug && this._debug('Outbound: Sending USERAUTH_INFO_REQUEST');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n}\n\n// SSH-protoversion-softwareversion (SP comments) CR LF\nconst RE_IDENT = /^SSH-(2\\.0|1\\.99)-([^ ]+)(?: (.*))?$/;\n\n// TODO: optimize this by starting n bytes from the end of this._buffer instead\n// of the beginning\nfunction parseHeader(chunk, p, len) {\n let data;\n let chunkOffset;\n if (this._buffer) {\n data = Buffer.allocUnsafe(this._buffer.length + (len - p));\n data.set(this._buffer, 0);\n if (p === 0) {\n data.set(chunk, this._buffer.length);\n } else {\n data.set(new Uint8Array(chunk.buffer,\n chunk.byteOffset + p,\n (len - p)),\n this._buffer.length);\n }\n chunkOffset = this._buffer.length;\n p = 0;\n } else {\n data = chunk;\n chunkOffset = 0;\n }\n const op = p;\n let start = p;\n let end = p;\n let needNL = false;\n let lineLen = 0;\n let lines = 0;\n for (; p < data.length; ++p) {\n const ch = data[p];\n\n if (ch === 13 /* '\\r' */) {\n needNL = true;\n continue;\n }\n\n if (ch === 10 /* '\\n' */) {\n if (end > start\n && end - start > 4\n && data[start] === 83 /* 'S' */\n && data[start + 1] === 83 /* 'S' */\n && data[start + 2] === 72 /* 'H' */\n && data[start + 3] === 45 /* '-' */) {\n\n const full = data.latin1Slice(op, end + 1);\n const identRaw = (start === op ? full : full.slice(start - op));\n const m = RE_IDENT.exec(identRaw);\n if (!m)\n throw new Error('Invalid identification string');\n\n const header = {\n greeting: (start === op ? '' : full.slice(0, start - op)),\n identRaw,\n versions: {\n protocol: m[1],\n software: m[2],\n },\n comments: m[3]\n };\n\n // Needed during handshake\n this._remoteIdentRaw = Buffer.from(identRaw);\n\n this._debug && this._debug(`Remote ident: ${inspect(identRaw)}`);\n this._compatFlags = getCompatFlags(header);\n\n this._buffer = undefined;\n this._decipher =\n new NullDecipher(0, onKEXPayload.bind(this, { firstPacket: true }));\n this._parse = parsePacket;\n\n this._onHeader(header);\n if (!this._destruct) {\n // We disconnected inside _onHeader\n return len;\n }\n\n kexinit(this);\n\n return p + 1 - chunkOffset;\n }\n\n // Only allow pre-ident greetings when we're a client\n if (this._server)\n throw new Error('Greetings from clients not permitted');\n\n if (++lines > MAX_LINES)\n throw new Error('Max greeting lines exceeded');\n\n needNL = false;\n start = p + 1;\n lineLen = 0;\n } else if (needNL) {\n throw new Error('Invalid header: expected newline');\n } else if (++lineLen >= MAX_LINE_LEN) {\n throw new Error('Header line too long');\n }\n\n end = p;\n }\n if (!this._buffer)\n this._buffer = bufferSlice(data, op);\n\n return p - chunkOffset;\n}\n\nfunction parsePacket(chunk, p, len) {\n return this._decipher.decrypt(chunk, p, len);\n}\n\nfunction onPayload(payload) {\n // XXX: move this to the Decipher implementations?\n\n this._onPacket();\n\n if (payload.length === 0) {\n this._debug && this._debug('Inbound: Skipping empty packet payload');\n return;\n }\n\n payload = this._packetRW.read.read(payload);\n\n const type = payload[0];\n if (type === MESSAGE.USERAUTH_SUCCESS\n && !this._server\n && !this._authenticated) {\n this._authenticated = true;\n if (this._kex.negotiated.cs.compress === 'zlib@openssh.com')\n this._packetRW.write = new ZlibPacketWriter(this);\n if (this._kex.negotiated.sc.compress === 'zlib@openssh.com')\n this._packetRW.read = new ZlibPacketReader();\n }\n const handler = MESSAGE_HANDLERS[type];\n if (handler === undefined) {\n this._debug && this._debug(`Inbound: Unsupported message type: ${type}`);\n return;\n }\n\n return handler(this, payload);\n}\n\nfunction getCompatFlags(header) {\n const software = header.versions.software;\n\n let flags = 0;\n\n for (const rule of COMPAT_CHECKS) {\n if (typeof rule[0] === 'string') {\n if (software === rule[0])\n flags |= rule[1];\n } else if (rule[0].test(software)) {\n flags |= rule[1];\n }\n }\n\n return flags;\n}\n\nfunction modesToBytes(modes) {\n const keys = Object.keys(modes);\n const bytes = Buffer.allocUnsafe((5 * keys.length) + 1);\n let b = 0;\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n if (key === 'TTY_OP_END')\n continue;\n\n const opcode = TERMINAL_MODE[key];\n if (opcode === undefined)\n continue;\n\n const val = modes[key];\n if (typeof val === 'number' && isFinite(val)) {\n bytes[b++] = opcode;\n bytes[b++] = val >>> 24;\n bytes[b++] = val >>> 16;\n bytes[b++] = val >>> 8;\n bytes[b++] = val;\n }\n }\n\n bytes[b++] = TERMINAL_MODE.TTY_OP_END;\n\n if (b < bytes.length)\n return bufferSlice(bytes, 0, b);\n\n return bytes;\n}\n\nmodule.exports = Protocol;\n","'use strict';\n\nconst EventEmitter = require('events');\nconst fs = require('fs');\nconst { constants } = fs;\nconst {\n Readable: ReadableStream,\n Writable: WritableStream\n} = require('stream');\nconst { inherits, isDate } = require('util');\n\nconst FastBuffer = Buffer[Symbol.species];\n\nconst {\n bufferCopy,\n bufferSlice,\n makeBufferParser,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst ATTR = {\n SIZE: 0x00000001,\n UIDGID: 0x00000002,\n PERMISSIONS: 0x00000004,\n ACMODTIME: 0x00000008,\n EXTENDED: 0x80000000,\n};\n\n// Large enough to store all possible attributes\nconst ATTRS_BUF = Buffer.alloc(28);\n\nconst STATUS_CODE = {\n OK: 0,\n EOF: 1,\n NO_SUCH_FILE: 2,\n PERMISSION_DENIED: 3,\n FAILURE: 4,\n BAD_MESSAGE: 5,\n NO_CONNECTION: 6,\n CONNECTION_LOST: 7,\n OP_UNSUPPORTED: 8\n};\n\nconst VALID_STATUS_CODES = new Map(\n Object.values(STATUS_CODE).map((n) => [n, 1])\n);\n\nconst STATUS_CODE_STR = {\n [STATUS_CODE.OK]: 'No error',\n [STATUS_CODE.EOF]: 'End of file',\n [STATUS_CODE.NO_SUCH_FILE]: 'No such file or directory',\n [STATUS_CODE.PERMISSION_DENIED]: 'Permission denied',\n [STATUS_CODE.FAILURE]: 'Failure',\n [STATUS_CODE.BAD_MESSAGE]: 'Bad message',\n [STATUS_CODE.NO_CONNECTION]: 'No connection',\n [STATUS_CODE.CONNECTION_LOST]: 'Connection lost',\n [STATUS_CODE.OP_UNSUPPORTED]: 'Operation unsupported',\n};\n\nconst REQUEST = {\n INIT: 1,\n OPEN: 3,\n CLOSE: 4,\n READ: 5,\n WRITE: 6,\n LSTAT: 7,\n FSTAT: 8,\n SETSTAT: 9,\n FSETSTAT: 10,\n OPENDIR: 11,\n READDIR: 12,\n REMOVE: 13,\n MKDIR: 14,\n RMDIR: 15,\n REALPATH: 16,\n STAT: 17,\n RENAME: 18,\n READLINK: 19,\n SYMLINK: 20,\n EXTENDED: 200\n};\n\nconst RESPONSE = {\n VERSION: 2,\n STATUS: 101,\n HANDLE: 102,\n DATA: 103,\n NAME: 104,\n ATTRS: 105,\n EXTENDED: 201\n};\n\nconst OPEN_MODE = {\n READ: 0x00000001,\n WRITE: 0x00000002,\n APPEND: 0x00000004,\n CREAT: 0x00000008,\n TRUNC: 0x00000010,\n EXCL: 0x00000020\n};\n\nconst PKT_RW_OVERHEAD = 2 * 1024;\nconst MAX_REQID = 2 ** 32 - 1;\nconst CLIENT_VERSION_BUFFER = Buffer.from([\n 0, 0, 0, 5 /* length */,\n REQUEST.INIT,\n 0, 0, 0, 3 /* version */\n]);\nconst SERVER_VERSION_BUFFER = Buffer.from([\n 0, 0, 0, 5 /* length */,\n RESPONSE.VERSION,\n 0, 0, 0, 3 /* version */\n]);\n\nconst RE_OPENSSH = /^SSH-2.0-(?:OpenSSH|dropbear)/;\nconst OPENSSH_MAX_PKT_LEN = 256 * 1024;\n\nconst bufferParser = makeBufferParser();\n\nconst fakeStderr = {\n readable: false,\n writable: false,\n push: (data) => {},\n once: () => {},\n on: () => {},\n emit: () => {},\n end: () => {},\n};\n\nfunction noop() {}\n\n// Emulates enough of `Channel` to be able to be used as a drop-in replacement\n// in order to process incoming data with as little overhead as possible\nclass SFTP extends EventEmitter {\n constructor(client, chanInfo, cfg) {\n super();\n\n if (typeof cfg !== 'object' || !cfg)\n cfg = {};\n\n const remoteIdentRaw = client._protocol._remoteIdentRaw;\n\n this.server = !!cfg.server;\n this._debug = (typeof cfg.debug === 'function' ? cfg.debug : undefined);\n this._isOpenSSH = (remoteIdentRaw && RE_OPENSSH.test(remoteIdentRaw));\n\n this._version = -1;\n this._extensions = {};\n this._biOpt = cfg.biOpt;\n this._pktLenBytes = 0;\n this._pktLen = 0;\n this._pktPos = 0;\n this._pktType = 0;\n this._pktData = undefined;\n this._writeReqid = -1;\n this._requests = {};\n this._maxInPktLen = OPENSSH_MAX_PKT_LEN;\n this._maxOutPktLen = 34000;\n this._maxReadLen =\n (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;\n this._maxWriteLen =\n (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;\n\n this.maxOpenHandles = undefined;\n\n // Channel compatibility\n this._client = client;\n this._protocol = client._protocol;\n this._callbacks = [];\n this._hasX11 = false;\n this._exit = {\n code: undefined,\n signal: undefined,\n dump: undefined,\n desc: undefined,\n };\n this._waitWindow = false; // SSH-level backpressure\n this._chunkcb = undefined;\n this._buffer = [];\n this.type = chanInfo.type;\n this.subtype = undefined;\n this.incoming = chanInfo.incoming;\n this.outgoing = chanInfo.outgoing;\n this.stderr = fakeStderr;\n this.readable = true;\n }\n\n // This handles incoming data to parse\n push(data) {\n if (data === null) {\n cleanupRequests(this);\n if (!this.readable)\n return;\n // No more incoming data from the remote side\n this.readable = false;\n this.emit('end');\n return;\n }\n /*\n uint32 length\n byte type\n byte[length - 1] data payload\n */\n let p = 0;\n\n while (p < data.length) {\n if (this._pktLenBytes < 4) {\n let nb = Math.min(4 - this._pktLenBytes, data.length - p);\n this._pktLenBytes += nb;\n\n while (nb--)\n this._pktLen = (this._pktLen << 8) + data[p++];\n\n if (this._pktLenBytes < 4)\n return;\n if (this._pktLen === 0)\n return doFatalSFTPError(this, 'Invalid packet length');\n if (this._pktLen > this._maxInPktLen) {\n const max = this._maxInPktLen;\n return doFatalSFTPError(\n this,\n `Packet length ${this._pktLen} exceeds max length of ${max}`\n );\n }\n if (p >= data.length)\n return;\n }\n if (this._pktPos < this._pktLen) {\n const nb = Math.min(this._pktLen - this._pktPos, data.length - p);\n if (p !== 0 || nb !== data.length) {\n if (nb === this._pktLen) {\n this._pkt = new FastBuffer(data.buffer, data.byteOffset + p, nb);\n } else {\n if (!this._pkt)\n this._pkt = Buffer.allocUnsafe(this._pktLen);\n this._pkt.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._pktPos\n );\n }\n } else if (nb === this._pktLen) {\n this._pkt = data;\n } else {\n if (!this._pkt)\n this._pkt = Buffer.allocUnsafe(this._pktLen);\n this._pkt.set(data, this._pktPos);\n }\n p += nb;\n this._pktPos += nb;\n if (this._pktPos < this._pktLen)\n return;\n }\n\n const type = this._pkt[0];\n const payload = this._pkt;\n\n // Prepare for next packet\n this._pktLen = 0;\n this._pktLenBytes = 0;\n this._pkt = undefined;\n this._pktPos = 0;\n\n const handler = (this.server\n ? SERVER_HANDLERS[type]\n : CLIENT_HANDLERS[type]);\n if (!handler)\n return doFatalSFTPError(this, `Unknown packet type ${type}`);\n\n if (this._version === -1) {\n if (this.server) {\n if (type !== REQUEST.INIT)\n return doFatalSFTPError(this, `Expected INIT packet, got ${type}`);\n } else if (type !== RESPONSE.VERSION) {\n return doFatalSFTPError(this, `Expected VERSION packet, got ${type}`);\n }\n }\n\n if (handler(this, payload) === false)\n return;\n }\n }\n\n end() {\n this.destroy();\n }\n destroy() {\n if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {\n this.outgoing.state = 'closing';\n this._protocol.channelClose(this.outgoing.id);\n }\n }\n _init() {\n this._init = noop;\n if (!this.server)\n sendOrBuffer(this, CLIENT_VERSION_BUFFER);\n }\n\n // ===========================================================================\n // Client-specific ===========================================================\n // ===========================================================================\n createReadStream(path, options) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n return new ReadStream(this, path, options);\n }\n createWriteStream(path, options) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n return new WriteStream(this, path, options);\n }\n open(path, flags_, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (typeof attrs === 'function') {\n cb = attrs;\n attrs = undefined;\n }\n\n const flags = (typeof flags_ === 'number' ? flags_ : stringToFlags(flags_));\n if (flags === null)\n throw new Error(`Unknown flags string: ${flags_}`);\n\n let attrsFlags = 0;\n let attrsLen = 0;\n if (typeof attrs === 'string' || typeof attrs === 'number')\n attrs = { mode: attrs };\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n attrsFlags = attrs.flags;\n attrsLen = attrs.nb;\n }\n\n /*\n uint32 id\n string filename\n uint32 pflags\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.OPEN;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n writeUInt32BE(buf, attrsFlags, p += 4);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPEN`\n );\n }\n close(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.CLOSE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} CLOSE`\n );\n }\n read(handle, buf, off, len, position, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n if (!Buffer.isBuffer(buf))\n throw new Error('buffer is not a Buffer');\n if (off >= buf.length)\n throw new Error('offset is out of bounds');\n if (off + len > buf.length)\n throw new Error('length extends beyond buffer');\n if (position === null)\n throw new Error('null position currently unsupported');\n\n read_(this, handle, buf, off, len, position, cb);\n }\n readData(handle, buf, off, len, position, cb) {\n // Backwards compatibility\n this.read(handle, buf, off, len, position, cb);\n }\n write(handle, buf, off, len, position, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n if (!Buffer.isBuffer(buf))\n throw new Error('buffer is not a Buffer');\n if (off > buf.length)\n throw new Error('offset is out of bounds');\n if (off + len > buf.length)\n throw new Error('length extends beyond buffer');\n if (position === null)\n throw new Error('null position currently unsupported');\n\n if (!len) {\n cb && process.nextTick(cb, undefined, 0);\n return;\n }\n\n const maxDataLen = this._maxWriteLen;\n const overflow = Math.max(len - maxDataLen, 0);\n const origPosition = position;\n\n if (overflow)\n len = maxDataLen;\n\n /*\n uint32 id\n string handle\n uint64 offset\n string data\n */\n const handleLen = handle.length;\n let p = 9;\n const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4 + len);\n\n writeUInt32BE(out, out.length - 4, 0);\n out[4] = REQUEST.WRITE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(out, reqid, 5);\n\n writeUInt32BE(out, handleLen, p);\n out.set(handle, p += 4);\n p += handleLen;\n for (let i = 7; i >= 0; --i) {\n out[p + i] = position & 0xFF;\n position /= 256;\n }\n writeUInt32BE(out, len, p += 8);\n bufferCopy(buf, out, off, off + len, p += 4);\n\n this._requests[reqid] = {\n cb: (err) => {\n if (err) {\n if (typeof cb === 'function')\n cb(err);\n } else if (overflow) {\n this.write(handle,\n buf,\n off + len,\n overflow,\n origPosition + len,\n cb);\n } else if (typeof cb === 'function') {\n cb(undefined, off + len);\n }\n }\n };\n\n const isSent = sendOrBuffer(this, out);\n if (this._debug) {\n const how = (isSent ? 'Sent' : 'Buffered');\n this._debug(`SFTP: Outbound: ${how} WRITE (id:${reqid})`);\n }\n }\n writeData(handle, buf, off, len, position, cb) {\n // Backwards compatibility\n this.write(handle, buf, off, len, position, cb);\n }\n fastGet(remotePath, localPath, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n fastXfer(this, fs, remotePath, localPath, opts, cb);\n }\n fastPut(localPath, remotePath, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n fastXfer(fs, this, localPath, remotePath, opts, cb);\n }\n readFile(path, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, flag: 'r' };\n else if (!options)\n options = { encoding: null, flag: 'r' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n const encoding = options.encoding;\n if (encoding && !Buffer.isEncoding(encoding))\n throw new Error(`Unknown encoding: ${encoding}`);\n\n // First stat the file, so we know the size.\n let size;\n let buffer; // Single buffer with file data\n let buffers; // List for when size is unknown\n let pos = 0;\n let handle;\n\n // SFTPv3 does not support using -1 for read position, so we have to track\n // read position manually\n let bytesRead = 0;\n\n const flag = options.flag || 'r';\n\n const read = () => {\n if (size === 0) {\n buffer = Buffer.allocUnsafe(8192);\n this.read(handle, buffer, 0, 8192, bytesRead, afterRead);\n } else {\n this.read(handle, buffer, pos, size - pos, bytesRead, afterRead);\n }\n };\n\n const afterRead = (er, nbytes) => {\n let eof;\n if (er) {\n eof = (er.code === STATUS_CODE.EOF);\n if (!eof) {\n return this.close(handle, () => {\n return callback && callback(er);\n });\n }\n } else {\n eof = false;\n }\n\n if (eof || (size === 0 && nbytes === 0))\n return close();\n\n bytesRead += nbytes;\n pos += nbytes;\n if (size !== 0) {\n if (pos === size)\n close();\n else\n read();\n } else {\n // Unknown size, just read until we don't get bytes.\n buffers.push(bufferSlice(buffer, 0, nbytes));\n read();\n }\n };\n afterRead._wantEOFError = true;\n\n const close = () => {\n this.close(handle, (er) => {\n if (size === 0) {\n // Collect the data into the buffers list.\n buffer = Buffer.concat(buffers, pos);\n } else if (pos < size) {\n buffer = bufferSlice(buffer, 0, pos);\n }\n\n if (encoding)\n buffer = buffer.toString(encoding);\n return callback && callback(er, buffer);\n });\n };\n\n this.open(path, flag, 0o666, (er, handle_) => {\n if (er)\n return callback && callback(er);\n handle = handle_;\n\n const tryStat = (er, st) => {\n if (er) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.stat(path, (er_, st_) => {\n if (er_) {\n return this.close(handle, () => {\n callback && callback(er);\n });\n }\n tryStat(null, st_);\n });\n return;\n }\n\n size = st.size || 0;\n if (size === 0) {\n // The kernel lies about many files.\n // Go ahead and try to read some bytes.\n buffers = [];\n return read();\n }\n\n buffer = Buffer.allocUnsafe(size);\n read();\n };\n this.fstat(handle, tryStat);\n });\n }\n writeFile(path, data, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, mode: 0o666, flag: 'w' };\n else if (!options)\n options = { encoding: 'utf8', mode: 0o666, flag: 'w' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n if (options.encoding && !Buffer.isEncoding(options.encoding))\n throw new Error(`Unknown encoding: ${options.encoding}`);\n\n const flag = options.flag || 'w';\n this.open(path, flag, options.mode, (openErr, handle) => {\n if (openErr) {\n callback && callback(openErr);\n } else {\n const buffer = (Buffer.isBuffer(data)\n ? data\n : Buffer.from('' + data, options.encoding || 'utf8'));\n const position = (/a/.test(flag) ? null : 0);\n\n // SFTPv3 does not support the notion of 'current position'\n // (null position), so we just attempt to append to the end of the file\n // instead\n if (position === null) {\n const tryStat = (er, st) => {\n if (er) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.stat(path, (er_, st_) => {\n if (er_) {\n return this.close(handle, () => {\n callback && callback(er);\n });\n }\n tryStat(null, st_);\n });\n return;\n }\n writeAll(this, handle, buffer, 0, buffer.length, st.size, callback);\n };\n this.fstat(handle, tryStat);\n return;\n }\n writeAll(this, handle, buffer, 0, buffer.length, position, callback);\n }\n });\n }\n appendFile(path, data, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, mode: 0o666, flag: 'a' };\n else if (!options)\n options = { encoding: 'utf8', mode: 0o666, flag: 'a' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n if (!options.flag)\n options = Object.assign({ flag: 'a' }, options);\n this.writeFile(path, data, options, callback);\n }\n exists(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n this.stat(path, (err) => {\n cb && cb(err ? false : true);\n });\n }\n unlink(filename, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string filename\n */\n const fnameLen = Buffer.byteLength(filename);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + fnameLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.REMOVE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, fnameLen, p);\n buf.utf8Write(filename, p += 4, fnameLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REMOVE`\n );\n }\n rename(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.RENAME;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, oldLen, p);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RENAME`\n );\n }\n mkdir(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'function') {\n cb = attrs;\n attrs = undefined;\n }\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n }\n\n /*\n uint32 id\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.MKDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} MKDIR`\n );\n }\n rmdir(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.RMDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RMDIR`\n );\n }\n readdir(where, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n if (typeof opts !== 'object' || opts === null)\n opts = {};\n\n const doFilter = (opts && opts.full ? false : true);\n\n if (!Buffer.isBuffer(where) && typeof where !== 'string')\n throw new Error('missing directory handle or path');\n\n if (typeof where === 'string') {\n const entries = [];\n let e = 0;\n\n const reread = (err, handle) => {\n if (err)\n return cb(err);\n\n this.readdir(handle, opts, (err, list) => {\n const eof = (err && err.code === STATUS_CODE.EOF);\n\n if (err && !eof)\n return this.close(handle, () => cb(err));\n\n if (eof) {\n return this.close(handle, (err) => {\n if (err)\n return cb(err);\n cb(undefined, entries);\n });\n }\n\n for (let i = 0; i < list.length; ++i, ++e)\n entries[e] = list[i];\n\n reread(undefined, handle);\n });\n };\n return this.opendir(where, reread);\n }\n\n /*\n uint32 id\n string handle\n */\n const handleLen = where.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.READDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(where, p += 4);\n\n this._requests[reqid] = {\n cb: (doFilter\n ? (err, list) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n\n for (let i = list.length - 1; i >= 0; --i) {\n if (list[i].filename === '.' || list[i].filename === '..')\n list.splice(i, 1);\n }\n\n cb(undefined, list);\n }\n : cb)\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READDIR`\n );\n }\n fstat(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.FSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSTAT`\n );\n }\n stat(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.STAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STAT`\n );\n }\n lstat(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.LSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} LSTAT`\n );\n }\n opendir(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.OPENDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPENDIR`\n );\n }\n setstat(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.SETSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SETSTAT`\n );\n }\n fsetstat(handle, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string handle\n ATTRS attrs\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.FSETSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n writeUInt32BE(buf, flags, p += handleLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSETSTAT`\n );\n }\n futimes(handle, atime, mtime, cb) {\n return this.fsetstat(handle, {\n atime: toUnixTimestamp(atime),\n mtime: toUnixTimestamp(mtime)\n }, cb);\n }\n utimes(path, atime, mtime, cb) {\n return this.setstat(path, {\n atime: toUnixTimestamp(atime),\n mtime: toUnixTimestamp(mtime)\n }, cb);\n }\n fchown(handle, uid, gid, cb) {\n return this.fsetstat(handle, {\n uid: uid,\n gid: gid\n }, cb);\n }\n chown(path, uid, gid, cb) {\n return this.setstat(path, {\n uid: uid,\n gid: gid\n }, cb);\n }\n fchmod(handle, mode, cb) {\n return this.fsetstat(handle, {\n mode: mode\n }, cb);\n }\n chmod(path, mode, cb) {\n return this.setstat(path, {\n mode: mode\n }, cb);\n }\n readlink(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.READLINK;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = {\n cb: (err, names) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n if (!names || !names.length)\n return cb(new Error('Response missing link info'));\n cb(undefined, names[0].filename);\n }\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READLINK`\n );\n }\n symlink(targetPath, linkPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string linkpath\n string targetpath\n */\n const linkLen = Buffer.byteLength(linkPath);\n const targetLen = Buffer.byteLength(targetPath);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + linkLen + 4 + targetLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.SYMLINK;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n if (this._isOpenSSH) {\n // OpenSSH has linkpath and targetpath positions switched\n writeUInt32BE(buf, targetLen, p);\n buf.utf8Write(targetPath, p += 4, targetLen);\n writeUInt32BE(buf, linkLen, p += targetLen);\n buf.utf8Write(linkPath, p += 4, linkLen);\n } else {\n writeUInt32BE(buf, linkLen, p);\n buf.utf8Write(linkPath, p += 4, linkLen);\n writeUInt32BE(buf, targetLen, p += linkLen);\n buf.utf8Write(targetPath, p += 4, targetLen);\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SYMLINK`\n );\n }\n realpath(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.REALPATH;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = {\n cb: (err, names) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n if (!names || !names.length)\n return cb(new Error('Response missing path info'));\n cb(undefined, names[0].filename);\n }\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REALPATH`\n );\n }\n // extended requests\n ext_openssh_rename(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['posix-rename@openssh.com'];\n if (!ext || ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"posix-rename@openssh.com\"\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 24 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 24, p);\n buf.utf8Write('posix-rename@openssh.com', p += 4, 24);\n writeUInt32BE(buf, oldLen, p += 24);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} posix-rename@openssh.com`);\n }\n }\n ext_openssh_statvfs(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['statvfs@openssh.com'];\n if (!ext || ext !== '2')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"statvfs@openssh.com\"\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 19 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 19, p);\n buf.utf8Write('statvfs@openssh.com', p += 4, 19);\n writeUInt32BE(buf, pathLen, p += 19);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { extended: 'statvfs@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} statvfs@openssh.com`);\n }\n }\n ext_openssh_fstatvfs(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['fstatvfs@openssh.com'];\n if (!ext || ext !== '2')\n throw new Error('Server does not support this extended request');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string \"fstatvfs@openssh.com\"\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('fstatvfs@openssh.com', p += 4, 20);\n writeUInt32BE(buf, handleLen, p += 20);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { extended: 'fstatvfs@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} fstatvfs@openssh.com`);\n }\n }\n ext_openssh_hardlink(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['hardlink@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"hardlink@openssh.com\"\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('hardlink@openssh.com', p += 4, 20);\n writeUInt32BE(buf, oldLen, p += 20);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} hardlink@openssh.com`);\n }\n }\n ext_openssh_fsync(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['fsync@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string \"fsync@openssh.com\"\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 17 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 17, p);\n buf.utf8Write('fsync@openssh.com', p += 4, 17);\n writeUInt32BE(buf, handleLen, p += 17);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} fsync@openssh.com`\n );\n }\n ext_openssh_lsetstat(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['lsetstat@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string \"lsetstat@openssh.com\"\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('lsetstat@openssh.com', p += 4, 20);\n\n writeUInt32BE(buf, pathLen, p += 20);\n buf.utf8Write(path, p += 4, pathLen);\n\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const status = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${status} lsetstat@openssh.com`);\n }\n }\n ext_openssh_expandPath(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['expand-path@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"expand-path@openssh.com\"\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 23 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 23, p);\n buf.utf8Write('expand-path@openssh.com', p += 4, 23);\n\n writeUInt32BE(buf, pathLen, p += 20);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const status = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${status} expand-path@openssh.com`);\n }\n }\n // ===========================================================================\n // Server-specific ===========================================================\n // ===========================================================================\n handle(reqid, handle) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n const handleLen = handle.length;\n\n if (handleLen > 256)\n throw new Error('handle too large (> 256 bytes)');\n\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.HANDLE;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n if (handleLen)\n buf.set(handle, p += 4);\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} HANDLE`\n );\n }\n status(reqid, code, message) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!VALID_STATUS_CODES.has(code))\n throw new Error(`Bad status code: ${code}`);\n\n message || (message = '');\n\n const msgLen = Buffer.byteLength(message);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 4 + msgLen + 4);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.STATUS;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, code, p);\n\n writeUInt32BE(buf, msgLen, p += 4);\n p += 4;\n if (msgLen) {\n buf.utf8Write(message, p, msgLen);\n p += msgLen;\n }\n\n writeUInt32BE(buf, 0, p); // Empty language tag\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STATUS`\n );\n }\n data(reqid, data, encoding) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n const isBuffer = Buffer.isBuffer(data);\n\n if (!isBuffer && typeof data !== 'string')\n throw new Error('data is not a Buffer or string');\n\n let isUTF8;\n if (!isBuffer && !encoding) {\n encoding = undefined;\n isUTF8 = true;\n }\n\n const dataLen = (\n isBuffer\n ? data.length\n : Buffer.byteLength(data, encoding)\n );\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + dataLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.DATA;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, dataLen, p);\n if (dataLen) {\n if (isBuffer)\n buf.set(data, p += 4);\n else if (isUTF8)\n buf.utf8Write(data, p += 4, dataLen);\n else\n buf.write(data, p += 4, dataLen, encoding);\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} DATA`\n );\n }\n name(reqid, names) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!Array.isArray(names)) {\n if (typeof names !== 'object' || names === null)\n throw new Error('names is not an object or array');\n names = [ names ];\n }\n\n const count = names.length;\n let namesLen = 0;\n let nameAttrs;\n const attrs = [];\n\n for (let i = 0; i < count; ++i) {\n const name = names[i];\n const filename = (\n !name || !name.filename || typeof name.filename !== 'string'\n ? ''\n : name.filename\n );\n namesLen += 4 + Buffer.byteLength(filename);\n const longname = (\n !name || !name.longname || typeof name.longname !== 'string'\n ? ''\n : name.longname\n );\n namesLen += 4 + Buffer.byteLength(longname);\n\n if (typeof name.attrs === 'object' && name.attrs !== null) {\n nameAttrs = attrsToBytes(name.attrs);\n namesLen += 4 + nameAttrs.nb;\n\n if (nameAttrs.nb) {\n let bytes;\n\n if (nameAttrs.nb === ATTRS_BUF.length) {\n bytes = new Uint8Array(ATTRS_BUF);\n } else {\n bytes = new Uint8Array(nameAttrs.nb);\n bufferCopy(ATTRS_BUF, bytes, 0, nameAttrs.nb, 0);\n }\n\n nameAttrs.bytes = bytes;\n }\n\n attrs.push(nameAttrs);\n } else {\n namesLen += 4;\n attrs.push(null);\n }\n }\n\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + namesLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.NAME;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, count, p);\n\n p += 4;\n\n for (let i = 0; i < count; ++i) {\n const name = names[i];\n\n {\n const filename = (\n !name || !name.filename || typeof name.filename !== 'string'\n ? ''\n : name.filename\n );\n const len = Buffer.byteLength(filename);\n writeUInt32BE(buf, len, p);\n p += 4;\n if (len) {\n buf.utf8Write(filename, p, len);\n p += len;\n }\n }\n\n {\n const longname = (\n !name || !name.longname || typeof name.longname !== 'string'\n ? ''\n : name.longname\n );\n const len = Buffer.byteLength(longname);\n writeUInt32BE(buf, len, p);\n p += 4;\n if (len) {\n buf.utf8Write(longname, p, len);\n p += len;\n }\n }\n\n const attr = attrs[i];\n if (attr) {\n writeUInt32BE(buf, attr.flags, p);\n p += 4;\n if (attr.flags && attr.bytes) {\n buf.set(attr.bytes, p);\n p += attr.nb;\n }\n } else {\n writeUInt32BE(buf, 0, p);\n p += 4;\n }\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} NAME`\n );\n }\n attrs(reqid, attrs) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (typeof attrs !== 'object' || attrs === null)\n throw new Error('attrs is not an object');\n\n attrs = attrsToBytes(attrs);\n const flags = attrs.flags;\n const attrsLen = attrs.nb;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.ATTRS;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, flags, p);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} ATTRS`\n );\n }\n}\n\nfunction tryCreateBuffer(size) {\n try {\n return Buffer.allocUnsafe(size);\n } catch (ex) {\n return ex;\n }\n}\n\nfunction read_(self, handle, buf, off, len, position, cb, req_) {\n const maxDataLen = self._maxReadLen;\n const overflow = Math.max(len - maxDataLen, 0);\n\n if (overflow)\n len = maxDataLen;\n\n /*\n uint32 id\n string handle\n uint64 offset\n uint32 len\n */\n const handleLen = handle.length;\n let p = 9;\n let pos = position;\n const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4);\n\n writeUInt32BE(out, out.length - 4, 0);\n out[4] = REQUEST.READ;\n const reqid = self._writeReqid = (self._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(out, reqid, 5);\n\n writeUInt32BE(out, handleLen, p);\n out.set(handle, p += 4);\n p += handleLen;\n for (let i = 7; i >= 0; --i) {\n out[p + i] = pos & 0xFF;\n pos /= 256;\n }\n writeUInt32BE(out, len, p += 8);\n\n if (typeof cb !== 'function')\n cb = noop;\n\n const req = (req_ || {\n nb: 0,\n position,\n off,\n origOff: off,\n len: undefined,\n overflow: undefined,\n cb: (err, data, nb) => {\n const len = req.len;\n const overflow = req.overflow;\n\n if (err) {\n if (cb._wantEOFError || err.code !== STATUS_CODE.EOF)\n return cb(err);\n } else if (nb > len) {\n return cb(new Error('Received more data than requested'));\n } else if (nb === len && overflow) {\n req.nb += nb;\n req.position += nb;\n req.off += nb;\n read_(self, handle, buf, req.off, overflow, req.position, cb, req);\n return;\n }\n\n if (req.origOff === 0 && buf.length === req.nb)\n data = buf;\n else\n data = bufferSlice(buf, req.origOff, req.origOff + req.nb);\n cb(undefined, req.nb + (nb || 0), data, req.position);\n },\n buffer: undefined,\n });\n\n req.len = len;\n req.overflow = overflow;\n\n // TODO: avoid creating multiple buffer slices when we need to re-call read_()\n // because of overflow\n req.buffer = bufferSlice(buf, off, off + len);\n\n self._requests[reqid] = req;\n\n const isBuffered = sendOrBuffer(self, out);\n self._debug && self._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READ`\n );\n}\n\nfunction fastXfer(src, dst, srcPath, dstPath, opts, cb) {\n let concurrency = 64;\n let chunkSize = 32768;\n let onstep;\n let mode;\n let fileSize;\n\n if (typeof opts === 'function') {\n cb = opts;\n } else if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.concurrency === 'number'\n && opts.concurrency > 0\n && !isNaN(opts.concurrency)) {\n concurrency = opts.concurrency;\n }\n if (typeof opts.chunkSize === 'number'\n && opts.chunkSize > 0\n && !isNaN(opts.chunkSize)) {\n chunkSize = opts.chunkSize;\n }\n if (typeof opts.fileSize === 'number'\n && opts.fileSize > 0\n && !isNaN(opts.fileSize)) {\n fileSize = opts.fileSize;\n }\n if (typeof opts.step === 'function')\n onstep = opts.step;\n\n if (typeof opts.mode === 'string' || typeof opts.mode === 'number')\n mode = modeNum(opts.mode);\n }\n\n // Internal state variables\n let fsize;\n let pdst = 0;\n let total = 0;\n let hadError = false;\n let srcHandle;\n let dstHandle;\n let readbuf;\n let bufsize = chunkSize * concurrency;\n\n function onerror(err) {\n if (hadError)\n return;\n\n hadError = true;\n\n let left = 0;\n let cbfinal;\n\n if (srcHandle || dstHandle) {\n cbfinal = () => {\n if (--left === 0)\n cb(err);\n };\n if (srcHandle && (src === fs || src.outgoing.state === 'open'))\n ++left;\n if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))\n ++left;\n if (srcHandle && (src === fs || src.outgoing.state === 'open'))\n src.close(srcHandle, cbfinal);\n if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))\n dst.close(dstHandle, cbfinal);\n } else {\n cb(err);\n }\n }\n\n src.open(srcPath, 'r', (err, sourceHandle) => {\n if (err)\n return onerror(err);\n\n srcHandle = sourceHandle;\n\n if (fileSize === undefined)\n src.fstat(srcHandle, tryStat);\n else\n tryStat(null, { size: fileSize });\n\n function tryStat(err, attrs) {\n if (err) {\n if (src !== fs) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n src.stat(srcPath, (err_, attrs_) => {\n if (err_)\n return onerror(err);\n tryStat(null, attrs_);\n });\n return;\n }\n return onerror(err);\n }\n fsize = attrs.size;\n\n dst.open(dstPath, 'w', (err, destHandle) => {\n if (err)\n return onerror(err);\n\n dstHandle = destHandle;\n\n if (fsize <= 0)\n return onerror();\n\n // Use less memory where possible\n while (bufsize > fsize) {\n if (concurrency === 1) {\n bufsize = fsize;\n break;\n }\n bufsize -= chunkSize;\n --concurrency;\n }\n\n readbuf = tryCreateBuffer(bufsize);\n if (readbuf instanceof Error)\n return onerror(readbuf);\n\n if (mode !== undefined) {\n dst.fchmod(dstHandle, mode, function tryAgain(err) {\n if (err) {\n // Try chmod() for sftp servers that may not support fchmod()\n // for whatever reason\n dst.chmod(dstPath, mode, (err_) => tryAgain());\n return;\n }\n startReads();\n });\n } else {\n startReads();\n }\n\n function onread(err, nb, data, dstpos, datapos, origChunkLen) {\n if (err)\n return onerror(err);\n\n datapos = datapos || 0;\n\n dst.write(dstHandle, readbuf, datapos, nb, dstpos, writeCb);\n\n function writeCb(err) {\n if (err)\n return onerror(err);\n\n total += nb;\n onstep && onstep(total, nb, fsize);\n\n if (nb < origChunkLen)\n return singleRead(datapos, dstpos + nb, origChunkLen - nb);\n\n if (total === fsize) {\n dst.close(dstHandle, (err) => {\n dstHandle = undefined;\n if (err)\n return onerror(err);\n src.close(srcHandle, (err) => {\n srcHandle = undefined;\n if (err)\n return onerror(err);\n cb();\n });\n });\n return;\n }\n\n if (pdst >= fsize)\n return;\n\n const chunk =\n (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);\n singleRead(datapos, pdst, chunk);\n pdst += chunk;\n }\n }\n\n function makeCb(psrc, pdst, chunk) {\n return (err, nb, data) => {\n onread(err, nb, data, pdst, psrc, chunk);\n };\n }\n\n function singleRead(psrc, pdst, chunk) {\n src.read(srcHandle,\n readbuf,\n psrc,\n chunk,\n pdst,\n makeCb(psrc, pdst, chunk));\n }\n\n function startReads() {\n let reads = 0;\n let psrc = 0;\n while (pdst < fsize && reads < concurrency) {\n const chunk =\n (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);\n singleRead(psrc, pdst, chunk);\n psrc += chunk;\n pdst += chunk;\n ++reads;\n }\n }\n });\n }\n });\n}\n\nfunction writeAll(sftp, handle, buffer, offset, length, position, callback_) {\n const callback = (typeof callback_ === 'function' ? callback_ : undefined);\n\n sftp.write(handle,\n buffer,\n offset,\n length,\n position,\n (writeErr, written) => {\n if (writeErr) {\n return sftp.close(handle, () => {\n callback && callback(writeErr);\n });\n }\n if (written === length) {\n sftp.close(handle, callback);\n } else {\n offset += written;\n length -= written;\n position += written;\n writeAll(sftp, handle, buffer, offset, length, position, callback);\n }\n });\n}\n\nclass Stats {\n constructor(initial) {\n this.mode = (initial && initial.mode);\n this.uid = (initial && initial.uid);\n this.gid = (initial && initial.gid);\n this.size = (initial && initial.size);\n this.atime = (initial && initial.atime);\n this.mtime = (initial && initial.mtime);\n this.extended = (initial && initial.extended);\n }\n isDirectory() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFDIR);\n }\n isFile() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFREG);\n }\n isBlockDevice() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFBLK);\n }\n isCharacterDevice() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFCHR);\n }\n isSymbolicLink() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFLNK);\n }\n isFIFO() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFIFO);\n }\n isSocket() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFSOCK);\n }\n}\n\nfunction attrsToBytes(attrs) {\n let flags = 0;\n let nb = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n if (typeof attrs.size === 'number') {\n flags |= ATTR.SIZE;\n const val = attrs.size;\n // Big Endian\n ATTRS_BUF[nb++] = val / 72057594037927940; // 2**56\n ATTRS_BUF[nb++] = val / 281474976710656; // 2**48\n ATTRS_BUF[nb++] = val / 1099511627776; // 2**40\n ATTRS_BUF[nb++] = val / 4294967296; // 2**32\n ATTRS_BUF[nb++] = val / 16777216; // 2**24\n ATTRS_BUF[nb++] = val / 65536; // 2**16\n ATTRS_BUF[nb++] = val / 256; // 2**8\n ATTRS_BUF[nb++] = val;\n }\n if (typeof attrs.uid === 'number' && typeof attrs.gid === 'number') {\n flags |= ATTR.UIDGID;\n const uid = attrs.uid;\n const gid = attrs.gid;\n // Big Endian\n ATTRS_BUF[nb++] = uid >>> 24;\n ATTRS_BUF[nb++] = uid >>> 16;\n ATTRS_BUF[nb++] = uid >>> 8;\n ATTRS_BUF[nb++] = uid;\n ATTRS_BUF[nb++] = gid >>> 24;\n ATTRS_BUF[nb++] = gid >>> 16;\n ATTRS_BUF[nb++] = gid >>> 8;\n ATTRS_BUF[nb++] = gid;\n }\n if (typeof attrs.mode === 'number' || typeof attrs.mode === 'string') {\n const mode = modeNum(attrs.mode);\n flags |= ATTR.PERMISSIONS;\n // Big Endian\n ATTRS_BUF[nb++] = mode >>> 24;\n ATTRS_BUF[nb++] = mode >>> 16;\n ATTRS_BUF[nb++] = mode >>> 8;\n ATTRS_BUF[nb++] = mode;\n }\n if ((typeof attrs.atime === 'number' || isDate(attrs.atime))\n && (typeof attrs.mtime === 'number' || isDate(attrs.mtime))) {\n const atime = toUnixTimestamp(attrs.atime);\n const mtime = toUnixTimestamp(attrs.mtime);\n\n flags |= ATTR.ACMODTIME;\n // Big Endian\n ATTRS_BUF[nb++] = atime >>> 24;\n ATTRS_BUF[nb++] = atime >>> 16;\n ATTRS_BUF[nb++] = atime >>> 8;\n ATTRS_BUF[nb++] = atime;\n ATTRS_BUF[nb++] = mtime >>> 24;\n ATTRS_BUF[nb++] = mtime >>> 16;\n ATTRS_BUF[nb++] = mtime >>> 8;\n ATTRS_BUF[nb++] = mtime;\n }\n // TODO: extended attributes\n }\n\n return { flags, nb };\n}\n\nfunction toUnixTimestamp(time) {\n // eslint-disable-next-line no-self-compare\n if (typeof time === 'number' && time === time) // Valid, non-NaN number\n return time;\n if (isDate(time))\n return parseInt(time.getTime() / 1000, 10);\n throw new Error(`Cannot parse time: ${time}`);\n}\n\nfunction modeNum(mode) {\n // eslint-disable-next-line no-self-compare\n if (typeof mode === 'number' && mode === mode) // Valid, non-NaN number\n return mode;\n if (typeof mode === 'string')\n return modeNum(parseInt(mode, 8));\n throw new Error(`Cannot parse mode: ${mode}`);\n}\n\nconst stringFlagMap = {\n 'r': OPEN_MODE.READ,\n 'r+': OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'w': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE,\n 'wx': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'xw': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'w+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'wx+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'xw+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'a': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE,\n 'ax': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'xa': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'a+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'ax+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'xa+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL\n};\n\nfunction stringToFlags(str) {\n const flags = stringFlagMap[str];\n return (flags !== undefined ? flags : null);\n}\n\nconst flagsToString = (() => {\n const stringFlagMapKeys = Object.keys(stringFlagMap);\n return (flags) => {\n for (let i = 0; i < stringFlagMapKeys.length; ++i) {\n const key = stringFlagMapKeys[i];\n if (stringFlagMap[key] === flags)\n return key;\n }\n return null;\n };\n})();\n\nfunction readAttrs(biOpt) {\n /*\n uint32 flags\n uint64 size present only if flag SSH_FILEXFER_ATTR_SIZE\n uint32 uid present only if flag SSH_FILEXFER_ATTR_UIDGID\n uint32 gid present only if flag SSH_FILEXFER_ATTR_UIDGID\n uint32 permissions present only if flag SSH_FILEXFER_ATTR_PERMISSIONS\n uint32 atime present only if flag SSH_FILEXFER_ACMODTIME\n uint32 mtime present only if flag SSH_FILEXFER_ACMODTIME\n uint32 extended_count present only if flag SSH_FILEXFER_ATTR_EXTENDED\n string extended_type\n string extended_data\n ... more extended data (extended_type - extended_data pairs),\n so that number of pairs equals extended_count\n */\n const flags = bufferParser.readUInt32BE();\n if (flags === undefined)\n return;\n\n const attrs = new Stats();\n if (flags & ATTR.SIZE) {\n const size = bufferParser.readUInt64BE(biOpt);\n if (size === undefined)\n return;\n attrs.size = size;\n }\n\n if (flags & ATTR.UIDGID) {\n const uid = bufferParser.readUInt32BE();\n const gid = bufferParser.readUInt32BE();\n if (gid === undefined)\n return;\n attrs.uid = uid;\n attrs.gid = gid;\n }\n\n if (flags & ATTR.PERMISSIONS) {\n const mode = bufferParser.readUInt32BE();\n if (mode === undefined)\n return;\n attrs.mode = mode;\n }\n\n if (flags & ATTR.ACMODTIME) {\n const atime = bufferParser.readUInt32BE();\n const mtime = bufferParser.readUInt32BE();\n if (mtime === undefined)\n return;\n attrs.atime = atime;\n attrs.mtime = mtime;\n }\n\n if (flags & ATTR.EXTENDED) {\n const count = bufferParser.readUInt32BE();\n if (count === undefined)\n return;\n const extended = {};\n for (let i = 0; i < count; ++i) {\n const type = bufferParser.readString(true);\n const data = bufferParser.readString();\n if (data === undefined)\n return;\n extended[type] = data;\n }\n attrs.extended = extended;\n }\n\n return attrs;\n}\n\nfunction sendOrBuffer(sftp, payload) {\n const ret = tryWritePayload(sftp, payload);\n if (ret !== undefined) {\n sftp._buffer.push(ret);\n return false;\n }\n return true;\n}\n\nfunction tryWritePayload(sftp, payload) {\n const outgoing = sftp.outgoing;\n if (outgoing.state !== 'open')\n return;\n\n if (outgoing.window === 0) {\n sftp._waitWindow = true; // XXX: Unnecessary?\n return payload;\n }\n\n let ret;\n const len = payload.length;\n let p = 0;\n\n while (len - p > 0 && outgoing.window > 0) {\n const actualLen = Math.min(len - p, outgoing.window, outgoing.packetSize);\n outgoing.window -= actualLen;\n if (outgoing.window === 0) {\n sftp._waitWindow = true;\n sftp._chunkcb = drainBuffer;\n }\n\n if (p === 0 && actualLen === len) {\n sftp._protocol.channelData(sftp.outgoing.id, payload);\n } else {\n sftp._protocol.channelData(sftp.outgoing.id,\n bufferSlice(payload, p, p + actualLen));\n }\n\n p += actualLen;\n }\n\n if (len - p > 0) {\n if (p > 0)\n ret = bufferSlice(payload, p, len);\n else\n ret = payload; // XXX: should never get here?\n }\n\n return ret;\n}\n\nfunction drainBuffer() {\n this._chunkcb = undefined;\n const buffer = this._buffer;\n let i = 0;\n while (i < buffer.length) {\n const payload = buffer[i];\n const ret = tryWritePayload(this, payload);\n if (ret !== undefined) {\n if (ret !== payload)\n buffer[i] = ret;\n if (i > 0)\n this._buffer = buffer.slice(i);\n return;\n }\n ++i;\n }\n if (i > 0)\n this._buffer = [];\n}\n\nfunction doFatalSFTPError(sftp, msg, noDebug) {\n const err = new Error(msg);\n err.level = 'sftp-protocol';\n if (!noDebug && sftp._debug)\n sftp._debug(`SFTP: Inbound: ${msg}`);\n sftp.emit('error', err);\n sftp.destroy();\n cleanupRequests(sftp);\n return false;\n}\n\nfunction cleanupRequests(sftp) {\n const keys = Object.keys(sftp._requests);\n if (keys.length === 0)\n return;\n\n const reqs = sftp._requests;\n sftp._requests = {};\n const err = new Error('No response from server');\n for (let i = 0; i < keys.length; ++i) {\n const req = reqs[keys[i]];\n if (typeof req.cb === 'function')\n req.cb(err);\n }\n}\n\nfunction requestLimits(sftp, cb) {\n /*\n uint32 id\n string \"limits@openssh.com\"\n */\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 18);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = sftp._writeReqid = (sftp._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 18, p);\n buf.utf8Write('limits@openssh.com', p += 4, 18);\n\n sftp._requests[reqid] = { extended: 'limits@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(sftp, buf);\n if (sftp._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n sftp._debug(`SFTP: Outbound: ${which} limits@openssh.com`);\n }\n}\n\nconst CLIENT_HANDLERS = {\n [RESPONSE.VERSION]: (sftp, payload) => {\n if (sftp._version !== -1)\n return doFatalSFTPError(sftp, 'Duplicate VERSION packet');\n\n const extensions = {};\n\n /*\n uint32 version\n \n */\n bufferParser.init(payload, 1);\n let version = bufferParser.readUInt32BE();\n while (bufferParser.avail()) {\n const extName = bufferParser.readString(true);\n const extData = bufferParser.readString(true);\n if (extData === undefined) {\n version = undefined;\n break;\n }\n extensions[extName] = extData;\n }\n bufferParser.clear();\n\n if (version === undefined)\n return doFatalSFTPError(sftp, 'Malformed VERSION packet');\n\n if (sftp._debug) {\n const names = Object.keys(extensions);\n if (names.length) {\n sftp._debug(\n `SFTP: Inbound: Received VERSION (v${version}, exts:${names})`\n );\n } else {\n sftp._debug(`SFTP: Inbound: Received VERSION (v${version})`);\n }\n }\n\n sftp._version = version;\n sftp._extensions = extensions;\n\n if (extensions['limits@openssh.com'] === '1') {\n return requestLimits(sftp, (err, limits) => {\n if (!err) {\n if (limits.maxPktLen > 0)\n sftp._maxOutPktLen = limits.maxPktLen;\n if (limits.maxReadLen > 0)\n sftp._maxReadLen = limits.maxReadLen;\n if (limits.maxWriteLen > 0)\n sftp._maxWriteLen = limits.maxWriteLen;\n sftp.maxOpenHandles = (\n limits.maxOpenHandles > 0 ? limits.maxOpenHandles : Infinity\n );\n }\n sftp.emit('ready');\n });\n }\n\n sftp.emit('ready');\n },\n [RESPONSE.STATUS]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n uint32 error/status code\n string error message (ISO-10646 UTF-8)\n string language tag\n */\n const errorCode = bufferParser.readUInt32BE();\n const errorMsg = bufferParser.readString(true);\n const lang = bufferParser.skipString();\n bufferParser.clear();\n\n if (lang === undefined) {\n if (reqID !== undefined)\n delete sftp._requests[reqID];\n return doFatalSFTPError(sftp, 'Malformed STATUS packet');\n }\n\n if (sftp._debug) {\n const jsonMsg = JSON.stringify(errorMsg);\n sftp._debug(\n `SFTP: Inbound: Received STATUS (id:${reqID}, ${errorCode}, ${jsonMsg})`\n );\n }\n const req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n if (req && typeof req.cb === 'function') {\n if (errorCode === STATUS_CODE.OK) {\n req.cb();\n return;\n }\n const err = new Error(errorMsg\n || STATUS_CODE_STR[errorCode]\n || 'Unknown status');\n err.code = errorCode;\n req.cb(err);\n }\n },\n [RESPONSE.HANDLE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined) {\n if (reqID !== undefined)\n delete sftp._requests[reqID];\n return doFatalSFTPError(sftp, 'Malformed HANDLE packet');\n }\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received HANDLE (id:${reqID})`);\n\n const req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n if (req && typeof req.cb === 'function')\n req.cb(undefined, handle);\n },\n [RESPONSE.DATA]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n string data\n */\n if (req && typeof req.cb === 'function') {\n if (req.buffer) {\n // We have already pre-allocated space to store the data\n\n const nb = bufferParser.readString(req.buffer);\n bufferParser.clear();\n\n if (nb !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`\n );\n req.cb(undefined, req.buffer, nb);\n return;\n }\n } else {\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${data.length})`\n );\n req.cb(undefined, data);\n return;\n }\n }\n } else {\n const nb = bufferParser.skipString();\n bufferParser.clear();\n if (nb !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`\n );\n return;\n }\n }\n\n return doFatalSFTPError(sftp, 'Malformed DATA packet');\n },\n [RESPONSE.NAME]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n uint32 count\n repeats count times:\n string filename\n string longname\n ATTRS attrs\n */\n const count = bufferParser.readUInt32BE();\n if (count !== undefined) {\n let names = [];\n for (let i = 0; i < count; ++i) {\n // We are going to assume UTF-8 for filenames despite the SFTPv3\n // spec not specifying an encoding because the specs for newer\n // versions of the protocol all explicitly specify UTF-8 for\n // filenames\n const filename = bufferParser.readString(true);\n\n // `longname` only exists in SFTPv3 and since it typically will\n // contain the filename, we assume it is also UTF-8\n const longname = bufferParser.readString(true);\n\n const attrs = readAttrs(sftp._biOpt);\n if (attrs === undefined) {\n names = undefined;\n break;\n }\n names.push({ filename, longname, attrs });\n }\n if (names !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received NAME (id:${reqID}, ${names.length})`\n );\n bufferParser.clear();\n if (req && typeof req.cb === 'function')\n req.cb(undefined, names);\n return;\n }\n }\n\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed NAME packet');\n },\n [RESPONSE.ATTRS]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n ATTRS attrs\n */\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n if (attrs !== undefined) {\n sftp._debug && sftp._debug(`SFTP: Inbound: Received ATTRS (id:${reqID})`);\n if (req && typeof req.cb === 'function')\n req.cb(undefined, attrs);\n return;\n }\n\n return doFatalSFTPError(sftp, 'Malformed ATTRS packet');\n },\n [RESPONSE.EXTENDED]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n if (reqID !== undefined) {\n const req = sftp._requests[reqID];\n if (req) {\n delete sftp._requests[reqID];\n switch (req.extended) {\n case 'statvfs@openssh.com':\n case 'fstatvfs@openssh.com': {\n /*\n uint64 f_bsize // file system block size\n uint64 f_frsize // fundamental fs block size\n uint64 f_blocks // number of blocks (unit f_frsize)\n uint64 f_bfree // free blocks in file system\n uint64 f_bavail // free blocks for non-root\n uint64 f_files // total file inodes\n uint64 f_ffree // free file inodes\n uint64 f_favail // free file inodes for to non-root\n uint64 f_fsid // file system id\n uint64 f_flag // bit mask of f_flag values\n uint64 f_namemax // maximum filename length\n */\n const biOpt = sftp._biOpt;\n const stats = {\n f_bsize: bufferParser.readUInt64BE(biOpt),\n f_frsize: bufferParser.readUInt64BE(biOpt),\n f_blocks: bufferParser.readUInt64BE(biOpt),\n f_bfree: bufferParser.readUInt64BE(biOpt),\n f_bavail: bufferParser.readUInt64BE(biOpt),\n f_files: bufferParser.readUInt64BE(biOpt),\n f_ffree: bufferParser.readUInt64BE(biOpt),\n f_favail: bufferParser.readUInt64BE(biOpt),\n f_sid: bufferParser.readUInt64BE(biOpt),\n f_flag: bufferParser.readUInt64BE(biOpt),\n f_namemax: bufferParser.readUInt64BE(biOpt),\n };\n if (stats.f_namemax === undefined)\n break;\n if (sftp._debug) {\n sftp._debug(\n 'SFTP: Inbound: Received EXTENDED_REPLY '\n + `(id:${reqID}, ${req.extended})`\n );\n }\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb(undefined, stats);\n return;\n }\n case 'limits@openssh.com': {\n /*\n uint64 max-packet-length\n uint64 max-read-length\n uint64 max-write-length\n uint64 max-open-handles\n */\n const limits = {\n maxPktLen: bufferParser.readUInt64BE(),\n maxReadLen: bufferParser.readUInt64BE(),\n maxWriteLen: bufferParser.readUInt64BE(),\n maxOpenHandles: bufferParser.readUInt64BE(),\n };\n if (limits.maxOpenHandles === undefined)\n break;\n if (sftp._debug) {\n sftp._debug(\n 'SFTP: Inbound: Received EXTENDED_REPLY '\n + `(id:${reqID}, ${req.extended})`\n );\n }\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb(undefined, limits);\n return;\n }\n default:\n // Unknown extended request\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`\n );\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb();\n return;\n }\n } else {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`\n );\n bufferParser.clear();\n return;\n }\n }\n\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed EXTENDED_REPLY packet');\n },\n};\nconst SERVER_HANDLERS = {\n [REQUEST.INIT]: (sftp, payload) => {\n if (sftp._version !== -1)\n return doFatalSFTPError(sftp, 'Duplicate INIT packet');\n\n const extensions = {};\n\n /*\n uint32 version\n \n */\n bufferParser.init(payload, 1);\n let version = bufferParser.readUInt32BE();\n while (bufferParser.avail()) {\n const extName = bufferParser.readString(true);\n const extData = bufferParser.readString(true);\n if (extData === undefined) {\n version = undefined;\n break;\n }\n extensions[extName] = extData;\n }\n bufferParser.clear();\n\n if (version === undefined)\n return doFatalSFTPError(sftp, 'Malformed INIT packet');\n\n if (sftp._debug) {\n const names = Object.keys(extensions);\n if (names.length) {\n sftp._debug(\n `SFTP: Inbound: Received INIT (v${version}, exts:${names})`\n );\n } else {\n sftp._debug(`SFTP: Inbound: Received INIT (v${version})`);\n }\n }\n\n sendOrBuffer(sftp, SERVER_VERSION_BUFFER);\n\n sftp._version = version;\n sftp._extensions = extensions;\n sftp.emit('ready');\n },\n [REQUEST.OPEN]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string filename\n uint32 pflags\n ATTRS attrs\n */\n const filename = bufferParser.readString(true);\n const pflags = bufferParser.readUInt32BE();\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed OPEN packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received OPEN (id:${reqID})`);\n\n if (!sftp.emit('OPEN', reqID, filename, pflags, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.CLOSE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed CLOSE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received CLOSE (id:${reqID})`);\n\n if (!sftp.emit('CLOSE', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READ]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n uint64 offset\n uint32 len\n */\n const handle = bufferParser.readString();\n const offset = bufferParser.readUInt64BE(sftp._biOpt);\n const len = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (len === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed READ packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received READ (id:${reqID})`);\n\n if (!sftp.emit('READ', reqID, handle, offset, len)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.WRITE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n uint64 offset\n string data\n */\n const handle = bufferParser.readString();\n const offset = bufferParser.readUInt64BE(sftp._biOpt);\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed WRITE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received WRITE (id:${reqID})`);\n\n if (!sftp.emit('WRITE', reqID, handle, offset, data)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.LSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed LSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received LSTAT (id:${reqID})`);\n\n if (!sftp.emit('LSTAT', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.FSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed FSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received FSTAT (id:${reqID})`);\n\n if (!sftp.emit('FSTAT', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.SETSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n ATTRS attrs\n */\n const path = bufferParser.readString(true);\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed SETSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received SETSTAT (id:${reqID})`);\n\n if (!sftp.emit('SETSTAT', reqID, path, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.FSETSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n ATTRS attrs\n */\n const handle = bufferParser.readString();\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed FSETSTAT packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received FSETSTAT (id:${reqID})`\n );\n\n if (!sftp.emit('FSETSTAT', reqID, handle, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.OPENDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed OPENDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received OPENDIR (id:${reqID})`);\n\n if (!sftp.emit('OPENDIR', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed READDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received READDIR (id:${reqID})`);\n\n if (!sftp.emit('READDIR', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.REMOVE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed REMOVE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received REMOVE (id:${reqID})`);\n\n if (!sftp.emit('REMOVE', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.MKDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n ATTRS attrs\n */\n const path = bufferParser.readString(true);\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed MKDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received MKDIR (id:${reqID})`);\n\n if (!sftp.emit('MKDIR', reqID, path, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.RMDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed RMDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received RMDIR (id:${reqID})`);\n\n if (!sftp.emit('RMDIR', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.REALPATH]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed REALPATH packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received REALPATH (id:${reqID})`\n );\n\n if (!sftp.emit('REALPATH', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.STAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed STAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received STAT (id:${reqID})`);\n\n if (!sftp.emit('STAT', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.RENAME]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string oldpath\n string newpath\n */\n const oldPath = bufferParser.readString(true);\n const newPath = bufferParser.readString(true);\n bufferParser.clear();\n\n if (newPath === undefined)\n return doFatalSFTPError(sftp, 'Malformed RENAME packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received RENAME (id:${reqID})`);\n\n if (!sftp.emit('RENAME', reqID, oldPath, newPath)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READLINK]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed READLINK packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received READLINK (id:${reqID})`\n );\n\n if (!sftp.emit('READLINK', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.SYMLINK]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string linkpath\n string targetpath\n */\n const linkPath = bufferParser.readString(true);\n const targetPath = bufferParser.readString(true);\n bufferParser.clear();\n\n if (targetPath === undefined)\n return doFatalSFTPError(sftp, 'Malformed SYMLINK packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received SYMLINK (id:${reqID})`);\n\n let handled;\n if (sftp._isOpenSSH) {\n // OpenSSH has linkpath and targetpath positions switched\n handled = sftp.emit('SYMLINK', reqID, targetPath, linkPath);\n } else {\n handled = sftp.emit('SYMLINK', reqID, linkPath, targetPath);\n }\n if (!handled) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.EXTENDED]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string extended-request\n ... any request-specific data ...\n */\n const extName = bufferParser.readString(true);\n if (extName === undefined) {\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed EXTENDED packet');\n }\n\n let extData;\n if (bufferParser.avail())\n extData = bufferParser.readRaw();\n bufferParser.clear();\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED (id:${reqID})`\n );\n\n if (!sftp.emit('EXTENDED', reqID, extName, extData)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n};\n\n// =============================================================================\n// ReadStream/WriteStream-related ==============================================\n// =============================================================================\nconst {\n ERR_INVALID_ARG_TYPE,\n ERR_OUT_OF_RANGE,\n validateNumber\n} = require('./node-fs-compat');\n\nconst kMinPoolSpace = 128;\n\nlet pool;\n// It can happen that we expect to read a large chunk of data, and reserve\n// a large chunk of the pool accordingly, but the read() call only filled\n// a portion of it. If a concurrently executing read() then uses the same pool,\n// the \"reserved\" portion cannot be used, so we allow it to be re-used as a\n// new pool later.\nconst poolFragments = [];\n\nfunction allocNewPool(poolSize) {\n if (poolFragments.length > 0)\n pool = poolFragments.pop();\n else\n pool = Buffer.allocUnsafe(poolSize);\n pool.used = 0;\n}\n\n// Check the `this.start` and `this.end` of stream.\nfunction checkPosition(pos, name) {\n if (!Number.isSafeInteger(pos)) {\n validateNumber(pos, name);\n if (!Number.isInteger(pos))\n throw new ERR_OUT_OF_RANGE(name, 'an integer', pos);\n throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);\n }\n if (pos < 0)\n throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);\n}\n\nfunction roundUpToMultipleOf8(n) {\n return (n + 7) & ~7; // Align to 8 byte boundary.\n}\n\nfunction ReadStream(sftp, path, options) {\n if (options === undefined)\n options = {};\n else if (typeof options === 'string')\n options = { encoding: options };\n else if (options === null || typeof options !== 'object')\n throw new TypeError('\"options\" argument must be a string or an object');\n else\n options = Object.create(options);\n\n // A little bit bigger buffer and water marks by default\n if (options.highWaterMark === undefined)\n options.highWaterMark = 64 * 1024;\n\n // For backwards compat do not emit close on destroy.\n options.emitClose = false;\n options.autoDestroy = false; // Node 14 major change.\n\n ReadableStream.call(this, options);\n\n this.path = path;\n this.flags = options.flags === undefined ? 'r' : options.flags;\n this.mode = options.mode === undefined ? 0o666 : options.mode;\n\n this.start = options.start;\n this.end = options.end;\n this.autoClose = options.autoClose === undefined ? true : options.autoClose;\n this.pos = 0;\n this.bytesRead = 0;\n this.closed = false;\n\n this.handle = options.handle === undefined ? null : options.handle;\n this.sftp = sftp;\n this._opening = false;\n\n if (this.start !== undefined) {\n checkPosition(this.start, 'start');\n\n this.pos = this.start;\n }\n\n if (this.end === undefined) {\n this.end = Infinity;\n } else if (this.end !== Infinity) {\n checkPosition(this.end, 'end');\n\n if (this.start !== undefined && this.start > this.end) {\n throw new ERR_OUT_OF_RANGE(\n 'start',\n `<= \"end\" (here: ${this.end})`,\n this.start\n );\n }\n }\n\n this.on('end', function() {\n if (this.autoClose)\n this.destroy();\n });\n\n if (!Buffer.isBuffer(this.handle))\n this.open();\n}\ninherits(ReadStream, ReadableStream);\n\nReadStream.prototype.open = function() {\n if (this._opening)\n return;\n\n this._opening = true;\n\n this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {\n this._opening = false;\n\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n\n this.handle = handle;\n this.emit('open', handle);\n this.emit('ready');\n // Start the flow of data.\n this.read();\n });\n};\n\nReadStream.prototype._read = function(n) {\n if (!Buffer.isBuffer(this.handle))\n return this.once('open', () => this._read(n));\n\n // XXX: safe to remove this?\n if (this.destroyed)\n return;\n\n if (!pool || pool.length - pool.used < kMinPoolSpace) {\n // Discard the old pool.\n allocNewPool(this.readableHighWaterMark\n || this._readableState.highWaterMark);\n }\n\n // Grab another reference to the pool in the case that while we're\n // in the thread pool another read() finishes up the pool, and\n // allocates a new one.\n const thisPool = pool;\n let toRead = Math.min(pool.length - pool.used, n);\n const start = pool.used;\n\n if (this.end !== undefined)\n toRead = Math.min(this.end - this.pos + 1, toRead);\n\n // Already read everything we were supposed to read!\n // treat as EOF.\n if (toRead <= 0)\n return this.push(null);\n\n // the actual read.\n this.sftp.read(this.handle,\n pool,\n pool.used,\n toRead,\n this.pos,\n (er, bytesRead) => {\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n let b = null;\n\n // Now that we know how much data we have actually read, re-wind the\n // 'used' field if we can, and otherwise allow the remainder of our\n // reservation to be used as a new pool later.\n if (start + toRead === thisPool.used && thisPool === pool) {\n thisPool.used = roundUpToMultipleOf8(thisPool.used + bytesRead - toRead);\n } else {\n // Round down to the next lowest multiple of 8 to ensure the new pool\n // fragment start and end positions are aligned to an 8 byte boundary.\n const alignedEnd = (start + toRead) & ~7;\n const alignedStart = roundUpToMultipleOf8(start + bytesRead);\n if (alignedEnd - alignedStart >= kMinPoolSpace)\n poolFragments.push(thisPool.slice(alignedStart, alignedEnd));\n }\n\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n b = thisPool.slice(start, start + bytesRead);\n }\n\n // Move the pool positions, and internal position for reading.\n this.pos += bytesRead;\n\n this.push(b);\n });\n\n pool.used = roundUpToMultipleOf8(pool.used + toRead);\n};\n\nReadStream.prototype._destroy = function(err, cb) {\n if (this._opening && !Buffer.isBuffer(this.handle)) {\n this.once('open', closeStream.bind(null, this, cb, err));\n return;\n }\n\n closeStream(this, cb, err);\n this.handle = null;\n this._opening = false;\n};\n\nfunction closeStream(stream, cb, err) {\n if (!stream.handle)\n return onclose();\n\n stream.sftp.close(stream.handle, onclose);\n\n function onclose(er) {\n er = er || err;\n cb(er);\n stream.closed = true;\n if (!er)\n stream.emit('close');\n }\n}\n\nReadStream.prototype.close = function(cb) {\n this.destroy(null, cb);\n};\n\nObject.defineProperty(ReadStream.prototype, 'pending', {\n get() {\n return this.handle === null;\n },\n configurable: true\n});\n\n// TODO: add `concurrency` setting to allow more than one in-flight WRITE\n// request to server to improve throughput\nfunction WriteStream(sftp, path, options) {\n if (options === undefined)\n options = {};\n else if (typeof options === 'string')\n options = { encoding: options };\n else if (options === null || typeof options !== 'object')\n throw new TypeError('\"options\" argument must be a string or an object');\n else\n options = Object.create(options);\n\n // For backwards compat do not emit close on destroy.\n options.emitClose = false;\n options.autoDestroy = false; // Node 14 major change.\n\n WritableStream.call(this, options);\n\n this.path = path;\n this.flags = options.flags === undefined ? 'w' : options.flags;\n this.mode = options.mode === undefined ? 0o666 : options.mode;\n\n this.start = options.start;\n this.autoClose = options.autoClose === undefined ? true : options.autoClose;\n this.pos = 0;\n this.bytesWritten = 0;\n this.closed = false;\n\n this.handle = options.handle === undefined ? null : options.handle;\n this.sftp = sftp;\n this._opening = false;\n\n if (this.start !== undefined) {\n checkPosition(this.start, 'start');\n\n this.pos = this.start;\n }\n\n if (options.encoding)\n this.setDefaultEncoding(options.encoding);\n\n // Node v6.x only\n this.on('finish', function() {\n if (this._writableState.finalCalled)\n return;\n if (this.autoClose)\n this.destroy();\n });\n\n if (!Buffer.isBuffer(this.handle))\n this.open();\n}\ninherits(WriteStream, WritableStream);\n\nWriteStream.prototype._final = function(cb) {\n if (this.autoClose)\n this.destroy();\n cb();\n};\n\nWriteStream.prototype.open = function() {\n if (this._opening)\n return;\n\n this._opening = true;\n\n this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {\n this._opening = false;\n\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n\n this.handle = handle;\n\n const tryAgain = (err) => {\n if (err) {\n // Try chmod() for sftp servers that may not support fchmod() for\n // whatever reason\n this.sftp.chmod(this.path, this.mode, (err_) => tryAgain());\n return;\n }\n\n // SFTPv3 requires absolute offsets, no matter the open flag used\n if (this.flags[0] === 'a') {\n const tryStat = (err, st) => {\n if (err) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.sftp.stat(this.path, (err_, st_) => {\n if (err_) {\n this.destroy();\n this.emit('error', err);\n return;\n }\n tryStat(null, st_);\n });\n return;\n }\n\n this.pos = st.size;\n this.emit('open', handle);\n this.emit('ready');\n };\n\n this.sftp.fstat(handle, tryStat);\n return;\n }\n\n this.emit('open', handle);\n this.emit('ready');\n };\n\n this.sftp.fchmod(handle, this.mode, tryAgain);\n });\n};\n\nWriteStream.prototype._write = function(data, encoding, cb) {\n if (!Buffer.isBuffer(data)) {\n const err = new ERR_INVALID_ARG_TYPE('data', 'Buffer', data);\n return this.emit('error', err);\n }\n\n if (!Buffer.isBuffer(this.handle)) {\n return this.once('open', function() {\n this._write(data, encoding, cb);\n });\n }\n\n this.sftp.write(this.handle,\n data,\n 0,\n data.length,\n this.pos,\n (er, bytes) => {\n if (er) {\n if (this.autoClose)\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n cb();\n });\n\n this.pos += data.length;\n};\n\nWriteStream.prototype._writev = function(data, cb) {\n if (!Buffer.isBuffer(this.handle)) {\n return this.once('open', function() {\n this._writev(data, cb);\n });\n }\n\n const sftp = this.sftp;\n const handle = this.handle;\n let writesLeft = data.length;\n\n const onwrite = (er, bytes) => {\n if (er) {\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n if (--writesLeft === 0)\n cb();\n };\n\n // TODO: try to combine chunks to reduce number of requests to the server?\n for (let i = 0; i < data.length; ++i) {\n const chunk = data[i].chunk;\n\n sftp.write(handle, chunk, 0, chunk.length, this.pos, onwrite);\n this.pos += chunk.length;\n }\n};\n\nif (typeof WritableStream.prototype.destroy !== 'function')\n WriteStream.prototype.destroy = ReadStream.prototype.destroy;\n\nWriteStream.prototype._destroy = ReadStream.prototype._destroy;\nWriteStream.prototype.close = function(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on('close', cb);\n }\n\n // If we are not autoClosing, we should call\n // destroy on 'finish'.\n if (!this.autoClose)\n this.on('finish', this.destroy.bind(this));\n\n this.end();\n};\n\n// There is no shutdown() for files.\nWriteStream.prototype.destroySoon = WriteStream.prototype.end;\n\nObject.defineProperty(WriteStream.prototype, 'pending', {\n get() {\n return this.handle === null;\n },\n configurable: true\n});\n// =============================================================================\n\nmodule.exports = {\n flagsToString,\n OPEN_MODE,\n SFTP,\n Stats,\n STATUS_CODE,\n stringToFlags,\n};\n","'use strict';\n\nconst crypto = require('crypto');\n\nlet cpuInfo;\ntry {\n cpuInfo = require('cpu-features')();\n} catch {}\n\nconst { bindingAvailable } = require('./crypto.js');\n\nconst eddsaSupported = (() => {\n if (typeof crypto.sign === 'function'\n && typeof crypto.verify === 'function') {\n const key =\n '-----BEGIN PRIVATE KEY-----\\r\\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD'\n + '/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\\r\\n-----END PRIVATE KEY-----';\n const data = Buffer.from('a');\n let sig;\n let verified;\n try {\n sig = crypto.sign(null, data, key);\n verified = crypto.verify(null, data, key, sig);\n } catch {}\n return (Buffer.isBuffer(sig) && sig.length === 64 && verified === true);\n }\n\n return false;\n})();\n\nconst curve25519Supported = (typeof crypto.diffieHellman === 'function'\n && typeof crypto.generateKeyPairSync === 'function'\n && typeof crypto.createPublicKey === 'function');\n\nconst DEFAULT_KEX = [\n // https://tools.ietf.org/html/rfc5656#section-10.1\n 'ecdh-sha2-nistp256',\n 'ecdh-sha2-nistp384',\n 'ecdh-sha2-nistp521',\n\n // https://tools.ietf.org/html/rfc4419#section-4\n 'diffie-hellman-group-exchange-sha256',\n\n // https://tools.ietf.org/html/rfc8268\n 'diffie-hellman-group14-sha256',\n 'diffie-hellman-group15-sha512',\n 'diffie-hellman-group16-sha512',\n 'diffie-hellman-group17-sha512',\n 'diffie-hellman-group18-sha512',\n];\nif (curve25519Supported) {\n DEFAULT_KEX.unshift('curve25519-sha256');\n DEFAULT_KEX.unshift('curve25519-sha256@libssh.org');\n}\nconst SUPPORTED_KEX = DEFAULT_KEX.concat([\n // https://tools.ietf.org/html/rfc4419#section-4\n 'diffie-hellman-group-exchange-sha1',\n\n 'diffie-hellman-group14-sha1', // REQUIRED\n 'diffie-hellman-group1-sha1', // REQUIRED\n]);\n\n\nconst DEFAULT_SERVER_HOST_KEY = [\n 'ecdsa-sha2-nistp256',\n 'ecdsa-sha2-nistp384',\n 'ecdsa-sha2-nistp521',\n 'rsa-sha2-512', // RFC 8332\n 'rsa-sha2-256', // RFC 8332\n 'ssh-rsa',\n];\nif (eddsaSupported)\n DEFAULT_SERVER_HOST_KEY.unshift('ssh-ed25519');\nconst SUPPORTED_SERVER_HOST_KEY = DEFAULT_SERVER_HOST_KEY.concat([\n 'ssh-dss',\n]);\n\n\nconst DEFAULT_CIPHER = [\n // http://tools.ietf.org/html/rfc5647\n 'aes128-gcm@openssh.com',\n 'aes256-gcm@openssh.com',\n\n // http://tools.ietf.org/html/rfc4344#section-4\n 'aes128-ctr',\n 'aes192-ctr',\n 'aes256-ctr',\n];\nif (cpuInfo && cpuInfo.flags && !cpuInfo.flags.aes) {\n // We know for sure the CPU does not support AES acceleration\n if (bindingAvailable)\n DEFAULT_CIPHER.unshift('chacha20-poly1305@openssh.com');\n else\n DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');\n} else if (bindingAvailable && cpuInfo && cpuInfo.arch === 'x86') {\n // Places chacha20-poly1305 immediately after GCM ciphers since GCM ciphers\n // seem to outperform it on x86, but it seems to be faster than CTR ciphers\n DEFAULT_CIPHER.splice(4, 0, 'chacha20-poly1305@openssh.com');\n} else {\n DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');\n}\nconst SUPPORTED_CIPHER = DEFAULT_CIPHER.concat([\n 'aes256-cbc',\n 'aes192-cbc',\n 'aes128-cbc',\n 'blowfish-cbc',\n '3des-cbc',\n\n // http://tools.ietf.org/html/rfc4345#section-4:\n 'arcfour256',\n 'arcfour128',\n\n 'cast128-cbc',\n 'arcfour',\n]);\n\n\nconst DEFAULT_MAC = [\n 'hmac-sha2-256-etm@openssh.com',\n 'hmac-sha2-512-etm@openssh.com',\n 'hmac-sha1-etm@openssh.com',\n 'hmac-sha2-256',\n 'hmac-sha2-512',\n 'hmac-sha1',\n];\nconst SUPPORTED_MAC = DEFAULT_MAC.concat([\n 'hmac-md5',\n 'hmac-sha2-256-96', // first 96 bits of HMAC-SHA256\n 'hmac-sha2-512-96', // first 96 bits of HMAC-SHA512\n 'hmac-ripemd160',\n 'hmac-sha1-96', // first 96 bits of HMAC-SHA1\n 'hmac-md5-96', // first 96 bits of HMAC-MD5\n]);\n\nconst DEFAULT_COMPRESSION = [\n 'none',\n 'zlib@openssh.com', // ZLIB (LZ77) compression, except\n // compression/decompression does not start until after\n // successful user authentication\n 'zlib', // ZLIB (LZ77) compression\n];\nconst SUPPORTED_COMPRESSION = DEFAULT_COMPRESSION.concat([\n]);\n\n\nconst COMPAT = {\n BAD_DHGEX: 1 << 0,\n OLD_EXIT: 1 << 1,\n DYN_RPORT_BUG: 1 << 2,\n BUG_DHGEX_LARGE: 1 << 3,\n};\n\nmodule.exports = {\n MESSAGE: {\n // Transport layer protocol -- generic (1-19)\n DISCONNECT: 1,\n IGNORE: 2,\n UNIMPLEMENTED: 3,\n DEBUG: 4,\n SERVICE_REQUEST: 5,\n SERVICE_ACCEPT: 6,\n\n // Transport layer protocol -- algorithm negotiation (20-29)\n KEXINIT: 20,\n NEWKEYS: 21,\n\n // Transport layer protocol -- key exchange method-specific (30-49)\n KEXDH_INIT: 30,\n KEXDH_REPLY: 31,\n\n KEXDH_GEX_GROUP: 31,\n KEXDH_GEX_INIT: 32,\n KEXDH_GEX_REPLY: 33,\n KEXDH_GEX_REQUEST: 34,\n\n KEXECDH_INIT: 30,\n KEXECDH_REPLY: 31,\n\n // User auth protocol -- generic (50-59)\n USERAUTH_REQUEST: 50,\n USERAUTH_FAILURE: 51,\n USERAUTH_SUCCESS: 52,\n USERAUTH_BANNER: 53,\n\n // User auth protocol -- user auth method-specific (60-79)\n USERAUTH_PASSWD_CHANGEREQ: 60,\n\n USERAUTH_PK_OK: 60,\n\n USERAUTH_INFO_REQUEST: 60,\n USERAUTH_INFO_RESPONSE: 61,\n\n // Connection protocol -- generic (80-89)\n GLOBAL_REQUEST: 80,\n REQUEST_SUCCESS: 81,\n REQUEST_FAILURE: 82,\n\n // Connection protocol -- channel-related (90-127)\n CHANNEL_OPEN: 90,\n CHANNEL_OPEN_CONFIRMATION: 91,\n CHANNEL_OPEN_FAILURE: 92,\n CHANNEL_WINDOW_ADJUST: 93,\n CHANNEL_DATA: 94,\n CHANNEL_EXTENDED_DATA: 95,\n CHANNEL_EOF: 96,\n CHANNEL_CLOSE: 97,\n CHANNEL_REQUEST: 98,\n CHANNEL_SUCCESS: 99,\n CHANNEL_FAILURE: 100\n\n // Reserved for client protocols (128-191)\n\n // Local extensions (192-155)\n },\n DISCONNECT_REASON: {\n HOST_NOT_ALLOWED_TO_CONNECT: 1,\n PROTOCOL_ERROR: 2,\n KEY_EXCHANGE_FAILED: 3,\n RESERVED: 4,\n MAC_ERROR: 5,\n COMPRESSION_ERROR: 6,\n SERVICE_NOT_AVAILABLE: 7,\n PROTOCOL_VERSION_NOT_SUPPORTED: 8,\n HOST_KEY_NOT_VERIFIABLE: 9,\n CONNECTION_LOST: 10,\n BY_APPLICATION: 11,\n TOO_MANY_CONNECTIONS: 12,\n AUTH_CANCELED_BY_USER: 13,\n NO_MORE_AUTH_METHODS_AVAILABLE: 14,\n ILLEGAL_USER_NAME: 15,\n },\n DISCONNECT_REASON_STR: undefined,\n CHANNEL_OPEN_FAILURE: {\n ADMINISTRATIVELY_PROHIBITED: 1,\n CONNECT_FAILED: 2,\n UNKNOWN_CHANNEL_TYPE: 3,\n RESOURCE_SHORTAGE: 4\n },\n TERMINAL_MODE: {\n TTY_OP_END: 0, // Indicates end of options.\n VINTR: 1, // Interrupt character; 255 if none. Similarly for the\n // other characters. Not all of these characters are\n // supported on all systems.\n VQUIT: 2, // The quit character (sends SIGQUIT signal on POSIX\n // systems).\n VERASE: 3, // Erase the character to left of the cursor.\n VKILL: 4, // Kill the current input line.\n VEOF: 5, // End-of-file character (sends EOF from the\n // terminal).\n VEOL: 6, // End-of-line character in addition to carriage\n // return and/or linefeed.\n VEOL2: 7, // Additional end-of-line character.\n VSTART: 8, // Continues paused output (normally control-Q).\n VSTOP: 9, // Pauses output (normally control-S).\n VSUSP: 10, // Suspends the current program.\n VDSUSP: 11, // Another suspend character.\n VREPRINT: 12, // Reprints the current input line.\n VWERASE: 13, // Erases a word left of cursor.\n VLNEXT: 14, // Enter the next character typed literally, even if\n // it is a special character\n VFLUSH: 15, // Character to flush output.\n VSWTCH: 16, // Switch to a different shell layer.\n VSTATUS: 17, // Prints system status line (load, command, pid,\n // etc).\n VDISCARD: 18, // Toggles the flushing of terminal output.\n IGNPAR: 30, // The ignore parity flag. The parameter SHOULD be 0\n // if this flag is FALSE, and 1 if it is TRUE.\n PARMRK: 31, // Mark parity and framing errors.\n INPCK: 32, // Enable checking of parity errors.\n ISTRIP: 33, // Strip 8th bit off characters.\n INLCR: 34, // Map NL into CR on input.\n IGNCR: 35, // Ignore CR on input.\n ICRNL: 36, // Map CR to NL on input.\n IUCLC: 37, // Translate uppercase characters to lowercase.\n IXON: 38, // Enable output flow control.\n IXANY: 39, // Any char will restart after stop.\n IXOFF: 40, // Enable input flow control.\n IMAXBEL: 41, // Ring bell on input queue full.\n ISIG: 50, // Enable signals INTR, QUIT, [D]SUSP.\n ICANON: 51, // Canonicalize input lines.\n XCASE: 52, // Enable input and output of uppercase characters by\n // preceding their lowercase equivalents with \"\\\".\n ECHO: 53, // Enable echoing.\n ECHOE: 54, // Visually erase chars.\n ECHOK: 55, // Kill character discards current line.\n ECHONL: 56, // Echo NL even if ECHO is off.\n NOFLSH: 57, // Don't flush after interrupt.\n TOSTOP: 58, // Stop background jobs from output.\n IEXTEN: 59, // Enable extensions.\n ECHOCTL: 60, // Echo control characters as ^(Char).\n ECHOKE: 61, // Visual erase for line kill.\n PENDIN: 62, // Retype pending input.\n OPOST: 70, // Enable output processing.\n OLCUC: 71, // Convert lowercase to uppercase.\n ONLCR: 72, // Map NL to CR-NL.\n OCRNL: 73, // Translate carriage return to newline (output).\n ONOCR: 74, // Translate newline to carriage return-newline\n // (output).\n ONLRET: 75, // Newline performs a carriage return (output).\n CS7: 90, // 7 bit mode.\n CS8: 91, // 8 bit mode.\n PARENB: 92, // Parity enable.\n PARODD: 93, // Odd parity, else even.\n TTY_OP_ISPEED: 128, // Specifies the input baud rate in bits per second.\n TTY_OP_OSPEED: 129, // Specifies the output baud rate in bits per second.\n },\n CHANNEL_EXTENDED_DATATYPE: {\n STDERR: 1,\n },\n\n SIGNALS: [\n 'ABRT', 'ALRM', 'FPE', 'HUP', 'ILL', 'INT', 'QUIT', 'SEGV', 'TERM', 'USR1',\n 'USR2', 'KILL', 'PIPE'\n ].reduce((cur, val) => ({ ...cur, [val]: 1 }), {}),\n\n COMPAT,\n COMPAT_CHECKS: [\n [ 'Cisco-1.25', COMPAT.BAD_DHGEX ],\n [ /^Cisco-1\\./, COMPAT.BUG_DHGEX_LARGE ],\n [ /^[0-9.]+$/, COMPAT.OLD_EXIT ], // old SSH.com implementations\n [ /^OpenSSH_5\\.\\d+/, COMPAT.DYN_RPORT_BUG ],\n ],\n\n // KEX proposal-related\n DEFAULT_KEX,\n SUPPORTED_KEX,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER,\n DEFAULT_MAC,\n SUPPORTED_MAC,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION,\n\n curve25519Supported,\n eddsaSupported,\n};\n\nmodule.exports.DISCONNECT_REASON_BY_VALUE =\n Array.from(Object.entries(module.exports.DISCONNECT_REASON))\n .reduce((obj, [key, value]) => ({ ...obj, [value]: key }), {});\n","// TODO:\n// * make max packet size configurable\n// * if decompression is enabled, use `._packet` in decipher instances as\n// input to (sync) zlib inflater with appropriate offset and length to\n// avoid an additional copy of payload data before inflation\n// * factor decompression status into packet length checks\n'use strict';\n\nconst {\n createCipheriv, createDecipheriv, createHmac, randomFillSync, timingSafeEqual\n} = require('crypto');\n\nconst { readUInt32BE, writeUInt32BE } = require('./utils.js');\n\nconst FastBuffer = Buffer[Symbol.species];\nconst MAX_SEQNO = 2 ** 32 - 1;\nconst EMPTY_BUFFER = Buffer.alloc(0);\nconst BUF_INT = Buffer.alloc(4);\nconst DISCARD_CACHE = new Map();\nconst MAX_PACKET_SIZE = 35000;\n\nlet binding;\nlet AESGCMCipher;\nlet ChaChaPolyCipher;\nlet GenericCipher;\nlet AESGCMDecipher;\nlet ChaChaPolyDecipher;\nlet GenericDecipher;\ntry {\n binding = require('./crypto/build/Release/sshcrypto.node');\n ({ AESGCMCipher, ChaChaPolyCipher, GenericCipher,\n AESGCMDecipher, ChaChaPolyDecipher, GenericDecipher } = binding);\n} catch {}\n\nconst CIPHER_STREAM = 1 << 0;\nconst CIPHER_INFO = (() => {\n function info(sslName, blockLen, keyLen, ivLen, authLen, discardLen, flags) {\n return {\n sslName,\n blockLen,\n keyLen,\n ivLen: (ivLen !== 0 || (flags & CIPHER_STREAM)\n ? ivLen\n : blockLen),\n authLen,\n discardLen,\n stream: !!(flags & CIPHER_STREAM),\n };\n }\n\n return {\n 'chacha20-poly1305@openssh.com':\n info('chacha20', 8, 64, 0, 16, 0, CIPHER_STREAM),\n\n 'aes128-gcm': info('aes-128-gcm', 16, 16, 12, 16, 0, CIPHER_STREAM),\n 'aes256-gcm': info('aes-256-gcm', 16, 32, 12, 16, 0, CIPHER_STREAM),\n 'aes128-gcm@openssh.com':\n info('aes-128-gcm', 16, 16, 12, 16, 0, CIPHER_STREAM),\n 'aes256-gcm@openssh.com':\n info('aes-256-gcm', 16, 32, 12, 16, 0, CIPHER_STREAM),\n\n 'aes128-cbc': info('aes-128-cbc', 16, 16, 0, 0, 0, 0),\n 'aes192-cbc': info('aes-192-cbc', 16, 24, 0, 0, 0, 0),\n 'aes256-cbc': info('aes-256-cbc', 16, 32, 0, 0, 0, 0),\n 'rijndael-cbc@lysator.liu.se': info('aes-256-cbc', 16, 32, 0, 0, 0, 0),\n '3des-cbc': info('des-ede3-cbc', 8, 24, 0, 0, 0, 0),\n 'blowfish-cbc': info('bf-cbc', 8, 16, 0, 0, 0, 0),\n 'idea-cbc': info('idea-cbc', 8, 16, 0, 0, 0, 0),\n 'cast128-cbc': info('cast-cbc', 8, 16, 0, 0, 0, 0),\n\n 'aes128-ctr': info('aes-128-ctr', 16, 16, 16, 0, 0, CIPHER_STREAM),\n 'aes192-ctr': info('aes-192-ctr', 16, 24, 16, 0, 0, CIPHER_STREAM),\n 'aes256-ctr': info('aes-256-ctr', 16, 32, 16, 0, 0, CIPHER_STREAM),\n '3des-ctr': info('des-ede3', 8, 24, 8, 0, 0, CIPHER_STREAM),\n 'blowfish-ctr': info('bf-ecb', 8, 16, 8, 0, 0, CIPHER_STREAM),\n 'cast128-ctr': info('cast5-ecb', 8, 16, 8, 0, 0, CIPHER_STREAM),\n\n /* The \"arcfour128\" algorithm is the RC4 cipher, as described in\n [SCHNEIER], using a 128-bit key. The first 1536 bytes of keystream\n generated by the cipher MUST be discarded, and the first byte of the\n first encrypted packet MUST be encrypted using the 1537th byte of\n keystream.\n\n -- http://tools.ietf.org/html/rfc4345#section-4 */\n 'arcfour': info('rc4', 8, 16, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour128': info('rc4', 8, 16, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour256': info('rc4', 8, 32, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour512': info('rc4', 8, 64, 0, 0, 1536, CIPHER_STREAM),\n };\n})();\n\nconst MAC_INFO = (() => {\n function info(sslName, len, actualLen, isETM) {\n return {\n sslName,\n len,\n actualLen,\n isETM,\n };\n }\n\n return {\n 'hmac-md5': info('md5', 16, 16, false),\n 'hmac-md5-96': info('md5', 16, 12, false),\n 'hmac-ripemd160': info('ripemd160', 20, 20, false),\n 'hmac-sha1': info('sha1', 20, 20, false),\n 'hmac-sha1-etm@openssh.com': info('sha1', 20, 20, true),\n 'hmac-sha1-96': info('sha1', 20, 12, false),\n 'hmac-sha2-256': info('sha256', 32, 32, false),\n 'hmac-sha2-256-etm@openssh.com': info('sha256', 32, 32, true),\n 'hmac-sha2-256-96': info('sha256', 32, 12, false),\n 'hmac-sha2-512': info('sha512', 64, 64, false),\n 'hmac-sha2-512-etm@openssh.com': info('sha512', 64, 64, true),\n 'hmac-sha2-512-96': info('sha512', 64, 12, false),\n };\n})();\n\n\n// Should only_be used during the initial handshake\nclass NullCipher {\n constructor(seqno, onWrite) {\n this.outSeqno = seqno;\n this._onWrite = onWrite;\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - (pktLen & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nconst POLY1305_ZEROS = Buffer.alloc(32);\nconst POLY1305_OUT_COMPUTE = Buffer.alloc(16);\nlet POLY1305_WASM_MODULE;\nlet POLY1305_RESULT_MALLOC;\nlet poly1305_auth;\nclass ChaChaPolyCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encKeyMain = enc.cipherKey.slice(0, 32);\n this._encKeyPktLen = enc.cipherKey.slice(32);\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - ((pktLen - 4) & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Generate Poly1305 key\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.outSeqno, 12);\n const polyKey =\n createCipheriv('chacha20', this._encKeyMain, POLY1305_OUT_COMPUTE)\n .update(POLY1305_ZEROS);\n\n // Encrypt packet length\n const pktLenEnc =\n createCipheriv('chacha20', this._encKeyPktLen, POLY1305_OUT_COMPUTE)\n .update(packet.slice(0, 4));\n this._onWrite(pktLenEnc);\n\n // Encrypt rest of packet\n POLY1305_OUT_COMPUTE[0] = 1; // Set counter to 1 (little endian)\n const payloadEnc =\n createCipheriv('chacha20', this._encKeyMain, POLY1305_OUT_COMPUTE)\n .update(packet.slice(4));\n this._onWrite(payloadEnc);\n\n // Calculate Poly1305 MAC\n poly1305_auth(POLY1305_RESULT_MALLOC,\n pktLenEnc,\n pktLenEnc.length,\n payloadEnc,\n payloadEnc.length,\n polyKey);\n const mac = Buffer.allocUnsafe(16);\n mac.set(\n new Uint8Array(POLY1305_WASM_MODULE.HEAPU8.buffer,\n POLY1305_RESULT_MALLOC,\n 16),\n 0\n );\n this._onWrite(mac);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass ChaChaPolyCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._instance = new ChaChaPolyCipher(enc.cipherKey);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - ((pktLen - 4) & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + 16/* MAC */);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet, this.outSeqno);\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass AESGCMCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encSSLName = enc.cipherInfo.sslName;\n this._encKey = enc.cipherKey;\n this._encIV = enc.cipherIV;\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 16 - ((pktLen - 4) & (16 - 1));\n if (padLen < 4)\n padLen += 16;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n const cipher = createCipheriv(this._encSSLName, this._encKey, this._encIV);\n cipher.setAutoPadding(false);\n\n const lenData = packet.slice(0, 4);\n cipher.setAAD(lenData);\n this._onWrite(lenData);\n\n // Encrypt pad length, payload, and padding\n const encrypted = cipher.update(packet.slice(4));\n this._onWrite(encrypted);\n const final = cipher.final();\n // XXX: final.length === 0 always?\n if (final.length)\n this._onWrite(final);\n\n // Generate MAC\n const tag = cipher.getAuthTag();\n this._onWrite(tag);\n\n // Increment counter in IV by 1 for next packet\n ivIncrement(this._encIV);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass AESGCMCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._instance = new AESGCMCipher(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 16 - ((pktLen - 4) & (16 - 1));\n if (padLen < 4)\n padLen += 16;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + 16/* authTag */);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet);\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass GenericCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encBlockLen = enc.cipherInfo.blockLen;\n this._cipherInstance = createCipheriv(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV);\n this._macSSLName = enc.macInfo.sslName;\n this._macKey = enc.macKey;\n this._macActualLen = enc.macInfo.actualLen;\n this._macETM = enc.macInfo.isETM;\n this._aadLen = (this._macETM ? 4 : 0);\n this._dead = false;\n\n const discardLen = enc.cipherInfo.discardLen;\n if (discardLen) {\n let discard = DISCARD_CACHE.get(discardLen);\n if (discard === undefined) {\n discard = Buffer.alloc(discardLen);\n DISCARD_CACHE.set(discardLen, discard);\n }\n this._cipherInstance.update(discard);\n }\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n const blockLen = this._encBlockLen;\n\n let pktLen = 4 + 1 + payloadLen;\n let padLen = blockLen - ((pktLen - this._aadLen) & (blockLen - 1));\n if (padLen < 4)\n padLen += blockLen;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n let mac;\n if (this._macETM) {\n // Encrypt pad length, payload, and padding\n const lenBytes = new Uint8Array(packet.buffer, packet.byteOffset, 4);\n const encrypted = this._cipherInstance.update(\n new Uint8Array(packet.buffer,\n packet.byteOffset + 4,\n packet.length - 4)\n );\n\n this._onWrite(lenBytes);\n this._onWrite(encrypted);\n\n // TODO: look into storing seqno as 4-byte buffer and incrementing like we\n // do for AES-GCM IVs to avoid having to (re)write all 4 bytes every time\n mac = createHmac(this._macSSLName, this._macKey);\n writeUInt32BE(BUF_INT, this.outSeqno, 0);\n mac.update(BUF_INT);\n mac.update(lenBytes);\n mac.update(encrypted);\n } else {\n // Encrypt length field, pad length, payload, and padding\n const encrypted = this._cipherInstance.update(packet);\n this._onWrite(encrypted);\n\n // TODO: look into storing seqno as 4-byte buffer and incrementing like we\n // do for AES-GCM IVs to avoid having to (re)write all 4 bytes every time\n mac = createHmac(this._macSSLName, this._macKey);\n writeUInt32BE(BUF_INT, this.outSeqno, 0);\n mac.update(BUF_INT);\n mac.update(packet);\n }\n\n let digest = mac.digest();\n if (digest.length > this._macActualLen)\n digest = digest.slice(0, this._macActualLen);\n this._onWrite(digest);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass GenericCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encBlockLen = enc.cipherInfo.blockLen;\n this._macLen = enc.macInfo.len;\n this._macActualLen = enc.macInfo.actualLen;\n this._aadLen = (enc.macInfo.isETM ? 4 : 0);\n this._instance = new GenericCipher(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV,\n enc.macInfo.sslName,\n enc.macKey,\n enc.macInfo.isETM);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n const blockLen = this._encBlockLen;\n\n let pktLen = 4 + 1 + payloadLen;\n let padLen = blockLen - ((pktLen - this._aadLen) & (blockLen - 1));\n if (padLen < 4)\n padLen += blockLen;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + this._macLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet, this.outSeqno);\n\n if (this._macActualLen < this._macLen) {\n packet = new FastBuffer(packet.buffer,\n packet.byteOffset,\n (packet.length\n - (this._macLen - this._macActualLen)));\n }\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass NullDecipher {\n constructor(seqno, onPayload) {\n this.inSeqno = seqno;\n this._onPayload = onPayload;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n while (p < dataLen) {\n // Read packet length\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n\n if (this._lenBytes < 4)\n return;\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (4 + this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._packetPos < this._len) {\n const nb = Math.min(this._len - this._packetPos, dataLen - p);\n let chunk;\n if (p !== 0 || nb !== dataLen)\n chunk = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n chunk = data;\n if (nb === this._len) {\n this._packet = chunk;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(chunk, this._packetPos);\n }\n p += nb;\n this._packetPos += nb;\n if (this._packetPos < this._len)\n return;\n }\n\n const payload = (!this._packet\n ? EMPTY_BUFFER\n : new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length\n - this._packet[0] - 1));\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass ChaChaPolyDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decKeyMain = dec.decipherKey.slice(0, 32);\n this._decKeyPktLen = dec.decipherKey.slice(32);\n this._len = 0;\n this._lenBuf = Buffer.alloc(4);\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(16);\n this._calcMac = Buffer.allocUnsafe(16);\n this._macPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length\n if (this._lenPos < 4) {\n let nb = Math.min(4 - this._lenPos, dataLen - p);\n while (nb--)\n this._lenBuf[this._lenPos++] = data[p++];\n if (this._lenPos < 4)\n return;\n\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.inSeqno, 12);\n\n const decLenBytes =\n createDecipheriv('chacha20', this._decKeyPktLen, POLY1305_OUT_COMPUTE)\n .update(this._lenBuf);\n this._len = readUInt32BE(decLenBytes, 0);\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read Poly1305 MAC\n {\n const nb = Math.min(16 - this._macPos, dataLen - p);\n // TODO: avoid copying if entire MAC is in current chunk\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < 16)\n return;\n }\n\n // Generate Poly1305 key\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.inSeqno, 12);\n const polyKey =\n createCipheriv('chacha20', this._decKeyMain, POLY1305_OUT_COMPUTE)\n .update(POLY1305_ZEROS);\n\n // Calculate and compare Poly1305 MACs\n poly1305_auth(POLY1305_RESULT_MALLOC,\n this._lenBuf,\n 4,\n this._packet,\n this._packet.length,\n polyKey);\n\n this._calcMac.set(\n new Uint8Array(POLY1305_WASM_MODULE.HEAPU8.buffer,\n POLY1305_RESULT_MALLOC,\n 16),\n 0\n );\n if (!timingSafeEqual(this._calcMac, this._mac))\n throw new Error('Invalid MAC');\n\n // Decrypt packet\n POLY1305_OUT_COMPUTE[0] = 1; // Set counter to 1 (little endian)\n const packet =\n createDecipheriv('chacha20', this._decKeyMain, POLY1305_OUT_COMPUTE)\n .update(this._packet);\n\n const payload = new FastBuffer(packet.buffer,\n packet.byteOffset + 1,\n packet.length - packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass ChaChaPolyDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new ChaChaPolyDecipher(dec.decipherKey);\n this._len = 0;\n this._lenBuf = Buffer.alloc(4);\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(16);\n this._macPos = 0;\n }\n free() {\n this._instance.free();\n }\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length\n if (this._lenPos < 4) {\n let nb = Math.min(4 - this._lenPos, dataLen - p);\n while (nb--)\n this._lenBuf[this._lenPos++] = data[p++];\n if (this._lenPos < 4)\n return;\n\n this._len = this._instance.decryptLen(this._lenBuf, this.inSeqno);\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read Poly1305 MAC\n {\n const nb = Math.min(16 - this._macPos, dataLen - p);\n // TODO: avoid copying if entire MAC is in current chunk\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < 16)\n return;\n }\n\n this._instance.decrypt(this._packet, this._mac, this.inSeqno);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass AESGCMDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decipherInstance = null;\n this._decipherSSLName = dec.decipherInfo.sslName;\n this._decipherKey = dec.decipherKey;\n this._decipherIV = dec.decipherIV;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._tag = Buffer.allocUnsafe(16);\n this._tagPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length (unencrypted, but AAD)\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n if (this._lenBytes < 4)\n return;\n\n if ((this._len + 20) > MAX_PACKET_SIZE\n || this._len < 16\n || (this._len & 15) !== 0) {\n throw new Error('Bad packet length');\n }\n\n this._decipherInstance = createDecipheriv(\n this._decipherSSLName,\n this._decipherKey,\n this._decipherIV\n );\n this._decipherInstance.setAutoPadding(false);\n this._decipherInstance.setAAD(intToBytes(this._len));\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let decrypted;\n if (p !== 0 || nb !== dataLen) {\n decrypted = this._decipherInstance.update(\n new Uint8Array(data.buffer, data.byteOffset + p, nb)\n );\n } else {\n decrypted = this._decipherInstance.update(data);\n }\n if (decrypted.length) {\n if (nb === this._len) {\n this._packet = decrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(decrypted, this._packetPos);\n }\n this._packetPos += decrypted.length;\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read authentication tag\n {\n const nb = Math.min(16 - this._tagPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._tag.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._tagPos\n );\n } else {\n this._tag.set(data, this._tagPos);\n }\n p += nb;\n this._tagPos += nb;\n if (this._tagPos < 16)\n return;\n }\n\n {\n // Verify authentication tag\n this._decipherInstance.setAuthTag(this._tag);\n\n const decrypted = this._decipherInstance.final();\n\n // XXX: this should never output any data since stream ciphers always\n // return data from .update() and block ciphers must end on a multiple\n // of the block length, which would have caused an exception to be\n // thrown if the total input was not...\n if (decrypted.length) {\n if (this._packet)\n this._packet.set(decrypted, this._packetPos);\n else\n this._packet = decrypted;\n }\n }\n\n const payload = (!this._packet\n ? EMPTY_BUFFER\n : new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length\n - this._packet[0] - 1));\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n ivIncrement(this._decipherIV);\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._tagPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass AESGCMDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new AESGCMDecipher(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV);\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._pktLen = 0;\n this._tag = Buffer.allocUnsafe(16);\n this._tagPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length (unencrypted, but AAD)\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n if (this._lenBytes < 4)\n return;\n\n if ((this._len + 20) > MAX_PACKET_SIZE\n || this._len < 16\n || (this._len & 15) !== 0) {\n throw new Error(`Bad packet length: ${this._len}`);\n }\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read authentication tag\n {\n const nb = Math.min(16 - this._tagPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._tag.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._tagPos\n );\n } else {\n this._tag.set(data, this._tagPos);\n }\n p += nb;\n this._tagPos += nb;\n if (this._tagPos < 16)\n return;\n }\n\n this._instance.decrypt(this._packet, this._len, this._tag);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._pktLen = 0;\n this._tagPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\n// TODO: test incremental .update()s vs. copying to _packet and doing a single\n// .update() after entire packet read -- a single .update() would allow\n// verifying MAC before decrypting for ETM MACs\nclass GenericDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decipherInstance = createDecipheriv(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV);\n this._decipherInstance.setAutoPadding(false);\n this._block = Buffer.allocUnsafe(\n dec.macInfo.isETM ? 4 : dec.decipherInfo.blockLen\n );\n this._blockSize = dec.decipherInfo.blockLen;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(dec.macInfo.actualLen);\n this._macPos = 0;\n this._macSSLName = dec.macInfo.sslName;\n this._macKey = dec.macKey;\n this._macActualLen = dec.macInfo.actualLen;\n this._macETM = dec.macInfo.isETM;\n this._macInstance = null;\n\n const discardLen = dec.decipherInfo.discardLen;\n if (discardLen) {\n let discard = DISCARD_CACHE.get(discardLen);\n if (discard === undefined) {\n discard = Buffer.alloc(discardLen);\n DISCARD_CACHE.set(discardLen, discard);\n }\n this._decipherInstance.update(discard);\n }\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read first encrypted block\n if (this._blockPos < this._block.length) {\n const nb = Math.min(this._block.length - this._blockPos, dataLen - p);\n if (p !== 0 || nb !== dataLen || nb < data.length) {\n this._block.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._blockPos\n );\n } else {\n this._block.set(data, this._blockPos);\n }\n\n p += nb;\n this._blockPos += nb;\n if (this._blockPos < this._block.length)\n return;\n\n let decrypted;\n let need;\n if (this._macETM) {\n this._len = need = readUInt32BE(this._block, 0);\n } else {\n // Decrypt first block to get packet length\n decrypted = this._decipherInstance.update(this._block);\n this._len = readUInt32BE(decrypted, 0);\n need = 4 + this._len - this._blockSize;\n }\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 5\n || (need & (this._blockSize - 1)) !== 0) {\n throw new Error('Bad packet length');\n }\n\n // Create MAC up front to calculate in parallel with decryption\n this._macInstance = createHmac(this._macSSLName, this._macKey);\n\n writeUInt32BE(BUF_INT, this.inSeqno, 0);\n this._macInstance.update(BUF_INT);\n if (this._macETM) {\n this._macInstance.update(this._block);\n } else {\n this._macInstance.update(new Uint8Array(decrypted.buffer,\n decrypted.byteOffset,\n 4));\n this._pktLen = decrypted.length - 4;\n this._packetPos = this._pktLen;\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(\n new Uint8Array(decrypted.buffer,\n decrypted.byteOffset + 4,\n this._packetPos),\n 0\n );\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (this._macETM)\n this._macInstance.update(encrypted);\n const decrypted = this._decipherInstance.update(encrypted);\n if (decrypted.length) {\n if (nb === this._len) {\n this._packet = decrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(decrypted, this._packetPos);\n }\n this._packetPos += decrypted.length;\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read MAC\n {\n const nb = Math.min(this._macActualLen - this._macPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < this._macActualLen)\n return;\n }\n\n // Verify MAC\n if (!this._macETM)\n this._macInstance.update(this._packet);\n let calculated = this._macInstance.digest();\n if (this._macActualLen < calculated.length) {\n calculated = new Uint8Array(calculated.buffer,\n calculated.byteOffset,\n this._macActualLen);\n }\n if (!timingSafeEquals(calculated, this._mac))\n throw new Error('Invalid MAC');\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._macPos = 0;\n this._macInstance = null;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass GenericDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new GenericDecipher(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV,\n dec.macInfo.sslName,\n dec.macKey,\n dec.macInfo.isETM,\n dec.macInfo.actualLen);\n this._block = Buffer.allocUnsafe(\n dec.macInfo.isETM || dec.decipherInfo.stream\n ? 4\n : dec.decipherInfo.blockLen\n );\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(dec.macInfo.actualLen);\n this._macPos = 0;\n this._macActualLen = dec.macInfo.actualLen;\n this._macETM = dec.macInfo.isETM;\n }\n free() {\n this._instance.free();\n }\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read first encrypted block\n if (this._blockPos < this._block.length) {\n const nb = Math.min(this._block.length - this._blockPos, dataLen - p);\n if (p !== 0 || nb !== dataLen || nb < data.length) {\n this._block.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._blockPos\n );\n } else {\n this._block.set(data, this._blockPos);\n }\n\n p += nb;\n this._blockPos += nb;\n if (this._blockPos < this._block.length)\n return;\n\n let need;\n if (this._macETM) {\n this._len = need = readUInt32BE(this._block, 0);\n } else {\n // Decrypt first block to get packet length\n this._instance.decryptBlock(this._block);\n this._len = readUInt32BE(this._block, 0);\n need = 4 + this._len - this._block.length;\n }\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 5\n || (need & (this._block.length - 1)) !== 0) {\n throw new Error('Bad packet length');\n }\n\n if (!this._macETM) {\n this._pktLen = (this._block.length - 4);\n if (this._pktLen) {\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(\n new Uint8Array(this._block.buffer,\n this._block.byteOffset + 4,\n this._pktLen),\n 0\n );\n }\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read MAC\n {\n const nb = Math.min(this._macActualLen - this._macPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < this._macActualLen)\n return;\n }\n\n // Decrypt and verify MAC\n this._instance.decrypt(this._packet,\n this.inSeqno,\n this._block,\n this._mac);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n this._macInstance = null;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\n// Increments unsigned, big endian counter (last 8 bytes) of AES-GCM IV\nfunction ivIncrement(iv) {\n // eslint-disable-next-line no-unused-expressions\n ++iv[11] >>> 8\n && ++iv[10] >>> 8\n && ++iv[9] >>> 8\n && ++iv[8] >>> 8\n && ++iv[7] >>> 8\n && ++iv[6] >>> 8\n && ++iv[5] >>> 8\n && ++iv[4] >>> 8;\n}\n\nconst intToBytes = (() => {\n const ret = Buffer.alloc(4);\n return (n) => {\n ret[0] = (n >>> 24);\n ret[1] = (n >>> 16);\n ret[2] = (n >>> 8);\n ret[3] = n;\n return ret;\n };\n})();\n\nfunction timingSafeEquals(a, b) {\n if (a.length !== b.length) {\n timingSafeEqual(a, a);\n return false;\n }\n return timingSafeEqual(a, b);\n}\n\nfunction createCipher(config) {\n if (typeof config !== 'object' || config === null)\n throw new Error('Invalid config');\n\n if (typeof config.outbound !== 'object' || config.outbound === null)\n throw new Error('Invalid outbound');\n\n const outbound = config.outbound;\n\n if (typeof outbound.onWrite !== 'function')\n throw new Error('Invalid outbound.onWrite');\n\n if (typeof outbound.cipherInfo !== 'object' || outbound.cipherInfo === null)\n throw new Error('Invalid outbound.cipherInfo');\n\n if (!Buffer.isBuffer(outbound.cipherKey)\n || outbound.cipherKey.length !== outbound.cipherInfo.keyLen) {\n throw new Error('Invalid outbound.cipherKey');\n }\n\n if (outbound.cipherInfo.ivLen\n && (!Buffer.isBuffer(outbound.cipherIV)\n || outbound.cipherIV.length !== outbound.cipherInfo.ivLen)) {\n throw new Error('Invalid outbound.cipherIV');\n }\n\n if (typeof outbound.seqno !== 'number'\n || outbound.seqno < 0\n || outbound.seqno > MAX_SEQNO) {\n throw new Error('Invalid outbound.seqno');\n }\n\n const forceNative = !!outbound.forceNative;\n\n switch (outbound.cipherInfo.sslName) {\n case 'aes-128-gcm':\n case 'aes-256-gcm':\n return (AESGCMCipher && !forceNative\n ? new AESGCMCipherBinding(config)\n : new AESGCMCipherNative(config));\n case 'chacha20':\n return (ChaChaPolyCipher && !forceNative\n ? new ChaChaPolyCipherBinding(config)\n : new ChaChaPolyCipherNative(config));\n default: {\n if (typeof outbound.macInfo !== 'object' || outbound.macInfo === null)\n throw new Error('Invalid outbound.macInfo');\n if (!Buffer.isBuffer(outbound.macKey)\n || outbound.macKey.length !== outbound.macInfo.len) {\n throw new Error('Invalid outbound.macKey');\n }\n return (GenericCipher && !forceNative\n ? new GenericCipherBinding(config)\n : new GenericCipherNative(config));\n }\n }\n}\n\nfunction createDecipher(config) {\n if (typeof config !== 'object' || config === null)\n throw new Error('Invalid config');\n\n if (typeof config.inbound !== 'object' || config.inbound === null)\n throw new Error('Invalid inbound');\n\n const inbound = config.inbound;\n\n if (typeof inbound.onPayload !== 'function')\n throw new Error('Invalid inbound.onPayload');\n\n if (typeof inbound.decipherInfo !== 'object'\n || inbound.decipherInfo === null) {\n throw new Error('Invalid inbound.decipherInfo');\n }\n\n if (!Buffer.isBuffer(inbound.decipherKey)\n || inbound.decipherKey.length !== inbound.decipherInfo.keyLen) {\n throw new Error('Invalid inbound.decipherKey');\n }\n\n if (inbound.decipherInfo.ivLen\n && (!Buffer.isBuffer(inbound.decipherIV)\n || inbound.decipherIV.length !== inbound.decipherInfo.ivLen)) {\n throw new Error('Invalid inbound.decipherIV');\n }\n\n if (typeof inbound.seqno !== 'number'\n || inbound.seqno < 0\n || inbound.seqno > MAX_SEQNO) {\n throw new Error('Invalid inbound.seqno');\n }\n\n const forceNative = !!inbound.forceNative;\n\n switch (inbound.decipherInfo.sslName) {\n case 'aes-128-gcm':\n case 'aes-256-gcm':\n return (AESGCMDecipher && !forceNative\n ? new AESGCMDecipherBinding(config)\n : new AESGCMDecipherNative(config));\n case 'chacha20':\n return (ChaChaPolyDecipher && !forceNative\n ? new ChaChaPolyDecipherBinding(config)\n : new ChaChaPolyDecipherNative(config));\n default: {\n if (typeof inbound.macInfo !== 'object' || inbound.macInfo === null)\n throw new Error('Invalid inbound.macInfo');\n if (!Buffer.isBuffer(inbound.macKey)\n || inbound.macKey.length !== inbound.macInfo.len) {\n throw new Error('Invalid inbound.macKey');\n }\n return (GenericDecipher && !forceNative\n ? new GenericDecipherBinding(config)\n : new GenericDecipherNative(config));\n }\n }\n}\n\nmodule.exports = {\n CIPHER_INFO,\n MAC_INFO,\n bindingAvailable: !!binding,\n init: (() => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n try {\n POLY1305_WASM_MODULE = await require('./crypto/poly1305.js')();\n POLY1305_RESULT_MALLOC = POLY1305_WASM_MODULE._malloc(16);\n poly1305_auth = POLY1305_WASM_MODULE.cwrap(\n 'poly1305_auth',\n null,\n ['number', 'array', 'number', 'array', 'number', 'array']\n );\n } catch (ex) {\n return reject(ex);\n }\n resolve();\n });\n })(),\n\n NullCipher,\n createCipher,\n NullDecipher,\n createDecipher,\n};\n","\nvar createPoly1305 = (function() {\n var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;\n if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;\n return (\nfunction(createPoly1305) {\n createPoly1305 = createPoly1305 || {};\n\n\nvar b;b||(b=typeof createPoly1305 !== 'undefined' ? createPoly1305 : {});var q,r;b.ready=new Promise(function(a,c){q=a;r=c});var u={},w;for(w in b)b.hasOwnProperty(w)&&(u[w]=b[w]);var x=\"object\"===typeof window,y=\"function\"===typeof importScripts,z=\"object\"===typeof process&&\"object\"===typeof process.versions&&\"string\"===typeof process.versions.node,B=\"\",C,D,E,F,G;\nif(z)B=y?require(\"path\").dirname(B)+\"/\":__dirname+\"/\",C=function(a,c){var d=H(a);if(d)return c?d:d.toString();F||(F=require(\"fs\"));G||(G=require(\"path\"));a=G.normalize(a);return F.readFileSync(a,c?null:\"utf8\")},E=function(a){a=C(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},D=function(a,c,d){var e=H(a);e&&c(e);F||(F=require(\"fs\"));G||(G=require(\"path\"));a=G.normalize(a);F.readFile(a,function(f,l){f?d(f):c(l.buffer)})},1=m){var oa=g.charCodeAt(++v);m=65536+((m&1023)<<10)|oa&1023}if(127>=m){if(k>=n)break;h[k++]=m}else{if(2047>=m){if(k+1>=n)break;h[k++]=192|m>>6}else{if(65535>=m){if(k+2>=n)break;h[k++]=224|m>>12}else{if(k+3>=n)break;h[k++]=240|m>>18;h[k++]=128|m>>12&63}h[k++]=128|m>>6&63}h[k++]=128|m&63}}h[k]=\n0}}return p},array:function(g){var p=O(g.length);Q.set(g,p);return p}},l=N(a),A=[];a=0;if(e)for(var t=0;t=n);)++k;if(16h?n+=String.fromCharCode(h):(h-=65536,n+=String.fromCharCode(55296|h>>10,56320|h&1023))}}else n+=String.fromCharCode(h)}g=n}}else g=\"\";else g=\"boolean\"===c?!!g:g;return g}(d);0!==a&&fa(a);return d}var ea=\"undefined\"!==typeof TextDecoder?new TextDecoder(\"utf8\"):void 0,ha,Q,P;\nfunction ia(){var a=L.buffer;ha=a;b.HEAP8=Q=new Int8Array(a);b.HEAP16=new Int16Array(a);b.HEAP32=new Int32Array(a);b.HEAPU8=P=new Uint8Array(a);b.HEAPU16=new Uint16Array(a);b.HEAPU32=new Uint32Array(a);b.HEAPF32=new Float32Array(a);b.HEAPF64=new Float64Array(a)}var R,ja=[],ka=[],la=[];function ma(){var a=b.preRun.shift();ja.unshift(a)}var S=0,T=null,U=null;b.preloadedImages={};b.preloadedAudios={};\nfunction K(a){if(b.onAbort)b.onAbort(a);I(a);M=!0;a=new WebAssembly.RuntimeError(\"abort(\"+a+\"). Build with -s ASSERTIONS=1 for more info.\");r(a);throw a;}var V=\"data:application/octet-stream;base64,\",W;W=\"data:application/octet-stream;base64,AGFzbQEAAAABIAZgAX8Bf2ADf39/AGABfwBgAABgAAF/YAZ/f39/f38AAgcBAWEBYQAAAwsKAAEDAQAAAgQFAgQFAXABAQEFBwEBgAKAgAIGCQF/AUGAjMACCwclCQFiAgABYwADAWQACQFlAAgBZgAHAWcABgFoAAUBaQAKAWoBAAqGTQpPAQJ/QYAIKAIAIgEgAEEDakF8cSICaiEAAkAgAkEAIAAgAU0bDQAgAD8AQRB0SwRAIAAQAEUNAQtBgAggADYCACABDwtBhAhBMDYCAEF/C4wFAg5+Cn8gACgCJCEUIAAoAiAhFSAAKAIcIREgACgCGCESIAAoAhQhEyACQRBPBEAgAC0ATEVBGHQhFyAAKAIEIhZBBWytIQ8gACgCCCIYQQVsrSENIAAoAgwiGUEFbK0hCyAAKAIQIhpBBWytIQkgADUCACEIIBqtIRAgGa0hDiAYrSEMIBatIQoDQCASIAEtAAMiEiABLQAEQQh0ciABLQAFQRB0ciABLQAGIhZBGHRyQQJ2Qf///x9xaq0iAyAOfiABLwAAIAEtAAJBEHRyIBNqIBJBGHRBgICAGHFqrSIEIBB+fCARIAEtAAdBCHQgFnIgAS0ACEEQdHIgAS0ACSIRQRh0ckEEdkH///8fcWqtIgUgDH58IAEtAApBCHQgEXIgAS0AC0EQdHIgAS0ADEEYdHJBBnYgFWqtIgYgCn58IBQgF2ogAS8ADSABLQAPQRB0cmqtIgcgCH58IAMgDH4gBCAOfnwgBSAKfnwgBiAIfnwgByAJfnwgAyAKfiAEIAx+fCAFIAh+fCAGIAl+fCAHIAt+fCADIAh+IAQgCn58IAUgCX58IAYgC358IAcgDX58IAMgCX4gBCAIfnwgBSALfnwgBiANfnwgByAPfnwiA0IaiEL/////D4N8IgRCGohC/////w+DfCIFQhqIQv////8Pg3wiBkIaiEL/////D4N8IgdCGoinQQVsIAOnQf///x9xaiITQRp2IASnQf///x9xaiESIAWnQf///x9xIREgBqdB////H3EhFSAHp0H///8fcSEUIBNB////H3EhEyABQRBqIQEgAkEQayICQQ9LDQALCyAAIBQ2AiQgACAVNgIgIAAgETYCHCAAIBI2AhggACATNgIUCwMAAQu2BAEGfwJAIAAoAjgiBARAIABBPGohBQJAIAJBECAEayIDIAIgA0kbIgZFDQAgBkEDcSEHAkAgBkEBa0EDSQRAQQAhAwwBCyAGQXxxIQhBACEDA0AgBSADIARqaiABIANqLQAAOgAAIAUgA0EBciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0ECciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0EDciIEIAAoAjhqaiABIARqLQAAOgAAIANBBGohAyAAKAI4IQQgCEEEayIIDQALCyAHRQ0AA0AgBSADIARqaiABIANqLQAAOgAAIANBAWohAyAAKAI4IQQgB0EBayIHDQALCyAAIAQgBmoiAzYCOCADQRBJDQEgACAFQRAQAiAAQQA2AjggAiAGayECIAEgBmohAQsgAkEQTwRAIAAgASACQXBxIgMQAiACQQ9xIQIgASADaiEBCyACRQ0AIAJBA3EhBCAAQTxqIQVBACEDIAJBAWtBA08EQCACQXxxIQcDQCAFIAAoAjggA2pqIAEgA2otAAA6AAAgBSADQQFyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQJyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQNyIgYgACgCOGpqIAEgBmotAAA6AAAgA0EEaiEDIAdBBGsiBw0ACwsgBARAA0AgBSAAKAI4IANqaiABIANqLQAAOgAAIANBAWohAyAEQQFrIgQNAAsLIAAgACgCOCACajYCOAsLoS0BDH8jAEEQayIMJAACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAEH0AU0EQEGICCgCACIFQRAgAEELakF4cSAAQQtJGyIIQQN2IgJ2IgFBA3EEQCABQX9zQQFxIAJqIgNBA3QiAUG4CGooAgAiBEEIaiEAAkAgBCgCCCICIAFBsAhqIgFGBEBBiAggBUF+IAN3cTYCAAwBCyACIAE2AgwgASACNgIICyAEIANBA3QiAUEDcjYCBCABIARqIgEgASgCBEEBcjYCBAwNCyAIQZAIKAIAIgpNDQEgAQRAAkBBAiACdCIAQQAgAGtyIAEgAnRxIgBBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2aiIDQQN0IgBBuAhqKAIAIgQoAggiASAAQbAIaiIARgRAQYgIIAVBfiADd3EiBTYCAAwBCyABIAA2AgwgACABNgIICyAEQQhqIQAgBCAIQQNyNgIEIAQgCGoiAiADQQN0IgEgCGsiA0EBcjYCBCABIARqIAM2AgAgCgRAIApBA3YiAUEDdEGwCGohB0GcCCgCACEEAn8gBUEBIAF0IgFxRQRAQYgIIAEgBXI2AgAgBwwBCyAHKAIICyEBIAcgBDYCCCABIAQ2AgwgBCAHNgIMIAQgATYCCAtBnAggAjYCAEGQCCADNgIADA0LQYwIKAIAIgZFDQEgBkEAIAZrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QbgKaigCACIBKAIEQXhxIAhrIQMgASECA0ACQCACKAIQIgBFBEAgAigCFCIARQ0BCyAAKAIEQXhxIAhrIgIgAyACIANJIgIbIQMgACABIAIbIQEgACECDAELCyABIAhqIgkgAU0NAiABKAIYIQsgASABKAIMIgRHBEAgASgCCCIAQZgIKAIASRogACAENgIMIAQgADYCCAwMCyABQRRqIgIoAgAiAEUEQCABKAIQIgBFDQQgAUEQaiECCwNAIAIhByAAIgRBFGoiAigCACIADQAgBEEQaiECIAQoAhAiAA0ACyAHQQA2AgAMCwtBfyEIIABBv39LDQAgAEELaiIAQXhxIQhBjAgoAgAiCUUNAEEAIAhrIQMCQAJAAkACf0EAIAhBgAJJDQAaQR8gCEH///8HSw0AGiAAQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgCCAAQRVqdkEBcXJBHGoLIgVBAnRBuApqKAIAIgJFBEBBACEADAELQQAhACAIQQBBGSAFQQF2ayAFQR9GG3QhAQNAAkAgAigCBEF4cSAIayIHIANPDQAgAiEEIAciAw0AQQAhAyACIQAMAwsgACACKAIUIgcgByACIAFBHXZBBHFqKAIQIgJGGyAAIAcbIQAgAUEBdCEBIAINAAsLIAAgBHJFBEBBACEEQQIgBXQiAEEAIABrciAJcSIARQ0DIABBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2akECdEG4CmooAgAhAAsgAEUNAQsDQCAAKAIEQXhxIAhrIgEgA0khAiABIAMgAhshAyAAIAQgAhshBCAAKAIQIgEEfyABBSAAKAIUCyIADQALCyAERQ0AIANBkAgoAgAgCGtPDQAgBCAIaiIGIARNDQEgBCgCGCEFIAQgBCgCDCIBRwRAIAQoAggiAEGYCCgCAEkaIAAgATYCDCABIAA2AggMCgsgBEEUaiICKAIAIgBFBEAgBCgCECIARQ0EIARBEGohAgsDQCACIQcgACIBQRRqIgIoAgAiAA0AIAFBEGohAiABKAIQIgANAAsgB0EANgIADAkLIAhBkAgoAgAiAk0EQEGcCCgCACEDAkAgAiAIayIBQRBPBEBBkAggATYCAEGcCCADIAhqIgA2AgAgACABQQFyNgIEIAIgA2ogATYCACADIAhBA3I2AgQMAQtBnAhBADYCAEGQCEEANgIAIAMgAkEDcjYCBCACIANqIgAgACgCBEEBcjYCBAsgA0EIaiEADAsLIAhBlAgoAgAiBkkEQEGUCCAGIAhrIgE2AgBBoAhBoAgoAgAiAiAIaiIANgIAIAAgAUEBcjYCBCACIAhBA3I2AgQgAkEIaiEADAsLQQAhACAIQS9qIgkCf0HgCygCAARAQegLKAIADAELQewLQn83AgBB5AtCgKCAgICABDcCAEHgCyAMQQxqQXBxQdiq1aoFczYCAEH0C0EANgIAQcQLQQA2AgBBgCALIgFqIgVBACABayIHcSICIAhNDQpBwAsoAgAiBARAQbgLKAIAIgMgAmoiASADTQ0LIAEgBEsNCwtBxAstAABBBHENBQJAAkBBoAgoAgAiAwRAQcgLIQADQCADIAAoAgAiAU8EQCABIAAoAgRqIANLDQMLIAAoAggiAA0ACwtBABABIgFBf0YNBiACIQVB5AsoAgAiA0EBayIAIAFxBEAgAiABayAAIAFqQQAgA2txaiEFCyAFIAhNDQYgBUH+////B0sNBkHACygCACIEBEBBuAsoAgAiAyAFaiIAIANNDQcgACAESw0HCyAFEAEiACABRw0BDAgLIAUgBmsgB3EiBUH+////B0sNBSAFEAEiASAAKAIAIAAoAgRqRg0EIAEhAAsCQCAAQX9GDQAgCEEwaiAFTQ0AQegLKAIAIgEgCSAFa2pBACABa3EiAUH+////B0sEQCAAIQEMCAsgARABQX9HBEAgASAFaiEFIAAhAQwIC0EAIAVrEAEaDAULIAAiAUF/Rw0GDAQLAAtBACEEDAcLQQAhAQwFCyABQX9HDQILQcQLQcQLKAIAQQRyNgIACyACQf7///8HSw0BIAIQASEBQQAQASEAIAFBf0YNASAAQX9GDQEgACABTQ0BIAAgAWsiBSAIQShqTQ0BC0G4C0G4CygCACAFaiIANgIAQbwLKAIAIABJBEBBvAsgADYCAAsCQAJAAkBBoAgoAgAiBwRAQcgLIQADQCABIAAoAgAiAyAAKAIEIgJqRg0CIAAoAggiAA0ACwwCC0GYCCgCACIAQQAgACABTRtFBEBBmAggATYCAAtBACEAQcwLIAU2AgBByAsgATYCAEGoCEF/NgIAQawIQeALKAIANgIAQdQLQQA2AgADQCAAQQN0IgNBuAhqIANBsAhqIgI2AgAgA0G8CGogAjYCACAAQQFqIgBBIEcNAAtBlAggBUEoayIDQXggAWtBB3FBACABQQhqQQdxGyIAayICNgIAQaAIIAAgAWoiADYCACAAIAJBAXI2AgQgASADakEoNgIEQaQIQfALKAIANgIADAILIAAtAAxBCHENACADIAdLDQAgASAHTQ0AIAAgAiAFajYCBEGgCCAHQXggB2tBB3FBACAHQQhqQQdxGyIAaiICNgIAQZQIQZQIKAIAIAVqIgEgAGsiADYCACACIABBAXI2AgQgASAHakEoNgIEQaQIQfALKAIANgIADAELQZgIKAIAIAFLBEBBmAggATYCAAsgASAFaiECQcgLIQACQAJAAkACQAJAAkADQCACIAAoAgBHBEAgACgCCCIADQEMAgsLIAAtAAxBCHFFDQELQcgLIQADQCAHIAAoAgAiAk8EQCACIAAoAgRqIgQgB0sNAwsgACgCCCEADAALAAsgACABNgIAIAAgACgCBCAFajYCBCABQXggAWtBB3FBACABQQhqQQdxG2oiCSAIQQNyNgIEIAJBeCACa0EHcUEAIAJBCGpBB3EbaiIFIAggCWoiBmshAiAFIAdGBEBBoAggBjYCAEGUCEGUCCgCACACaiIANgIAIAYgAEEBcjYCBAwDCyAFQZwIKAIARgRAQZwIIAY2AgBBkAhBkAgoAgAgAmoiADYCACAGIABBAXI2AgQgACAGaiAANgIADAMLIAUoAgQiAEEDcUEBRgRAIABBeHEhBwJAIABB/wFNBEAgBSgCCCIDIABBA3YiAEEDdEGwCGpGGiADIAUoAgwiAUYEQEGICEGICCgCAEF+IAB3cTYCAAwCCyADIAE2AgwgASADNgIIDAELIAUoAhghCAJAIAUgBSgCDCIBRwRAIAUoAggiACABNgIMIAEgADYCCAwBCwJAIAVBFGoiACgCACIDDQAgBUEQaiIAKAIAIgMNAEEAIQEMAQsDQCAAIQQgAyIBQRRqIgAoAgAiAw0AIAFBEGohACABKAIQIgMNAAsgBEEANgIACyAIRQ0AAkAgBSAFKAIcIgNBAnRBuApqIgAoAgBGBEAgACABNgIAIAENAUGMCEGMCCgCAEF+IAN3cTYCAAwCCyAIQRBBFCAIKAIQIAVGG2ogATYCACABRQ0BCyABIAg2AhggBSgCECIABEAgASAANgIQIAAgATYCGAsgBSgCFCIARQ0AIAEgADYCFCAAIAE2AhgLIAUgB2ohBSACIAdqIQILIAUgBSgCBEF+cTYCBCAGIAJBAXI2AgQgAiAGaiACNgIAIAJB/wFNBEAgAkEDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwDC0EfIQAgAkH///8HTQRAIAJBCHYiACAAQYD+P2pBEHZBCHEiA3QiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASADciAAcmsiAEEBdCACIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQQCQEGMCCgCACIDQQEgAHQiAXFFBEBBjAggASADcjYCACAEIAY2AgAgBiAENgIYDAELIAJBAEEZIABBAXZrIABBH0YbdCEAIAQoAgAhAQNAIAEiAygCBEF4cSACRg0DIABBHXYhASAAQQF0IQAgAyABQQRxaiIEKAIQIgENAAsgBCAGNgIQIAYgAzYCGAsgBiAGNgIMIAYgBjYCCAwCC0GUCCAFQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBBoAggACABaiIANgIAIAAgAkEBcjYCBCABIANqQSg2AgRBpAhB8AsoAgA2AgAgByAEQScgBGtBB3FBACAEQSdrQQdxG2pBL2siACAAIAdBEGpJGyICQRs2AgQgAkHQCykCADcCECACQcgLKQIANwIIQdALIAJBCGo2AgBBzAsgBTYCAEHICyABNgIAQdQLQQA2AgAgAkEYaiEAA0AgAEEHNgIEIABBCGohASAAQQRqIQAgASAESQ0ACyACIAdGDQMgAiACKAIEQX5xNgIEIAcgAiAHayIEQQFyNgIEIAIgBDYCACAEQf8BTQRAIARBA3YiAEEDdEGwCGohAgJ/QYgIKAIAIgFBASAAdCIAcUUEQEGICCAAIAFyNgIAIAIMAQsgAigCCAshACACIAc2AgggACAHNgIMIAcgAjYCDCAHIAA2AggMBAtBHyEAIAdCADcCECAEQf///wdNBEAgBEEIdiIAIABBgP4/akEQdkEIcSICdCIAIABBgOAfakEQdkEEcSIBdCIAIABBgIAPakEQdkECcSIAdEEPdiABIAJyIAByayIAQQF0IAQgAEEVanZBAXFyQRxqIQALIAcgADYCHCAAQQJ0QbgKaiEDAkBBjAgoAgAiAkEBIAB0IgFxRQRAQYwIIAEgAnI2AgAgAyAHNgIAIAcgAzYCGAwBCyAEQQBBGSAAQQF2ayAAQR9GG3QhACADKAIAIQEDQCABIgIoAgRBeHEgBEYNBCAAQR12IQEgAEEBdCEAIAIgAUEEcWoiAygCECIBDQALIAMgBzYCECAHIAI2AhgLIAcgBzYCDCAHIAc2AggMAwsgAygCCCIAIAY2AgwgAyAGNgIIIAZBADYCGCAGIAM2AgwgBiAANgIICyAJQQhqIQAMBQsgAigCCCIAIAc2AgwgAiAHNgIIIAdBADYCGCAHIAI2AgwgByAANgIIC0GUCCgCACIAIAhNDQBBlAggACAIayIBNgIAQaAIQaAIKAIAIgIgCGoiADYCACAAIAFBAXI2AgQgAiAIQQNyNgIEIAJBCGohAAwDC0GECEEwNgIAQQAhAAwCCwJAIAVFDQACQCAEKAIcIgJBAnRBuApqIgAoAgAgBEYEQCAAIAE2AgAgAQ0BQYwIIAlBfiACd3EiCTYCAAwCCyAFQRBBFCAFKAIQIARGG2ogATYCACABRQ0BCyABIAU2AhggBCgCECIABEAgASAANgIQIAAgATYCGAsgBCgCFCIARQ0AIAEgADYCFCAAIAE2AhgLAkAgA0EPTQRAIAQgAyAIaiIAQQNyNgIEIAAgBGoiACAAKAIEQQFyNgIEDAELIAQgCEEDcjYCBCAGIANBAXI2AgQgAyAGaiADNgIAIANB/wFNBEAgA0EDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwBC0EfIQAgA0H///8HTQRAIANBCHYiACAAQYD+P2pBEHZBCHEiAnQiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASACciAAcmsiAEEBdCADIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQICQAJAIAlBASAAdCIBcUUEQEGMCCABIAlyNgIAIAIgBjYCACAGIAI2AhgMAQsgA0EAQRkgAEEBdmsgAEEfRht0IQAgAigCACEIA0AgCCIBKAIEQXhxIANGDQIgAEEddiECIABBAXQhACABIAJBBHFqIgIoAhAiCA0ACyACIAY2AhAgBiABNgIYCyAGIAY2AgwgBiAGNgIIDAELIAEoAggiACAGNgIMIAEgBjYCCCAGQQA2AhggBiABNgIMIAYgADYCCAsgBEEIaiEADAELAkAgC0UNAAJAIAEoAhwiAkECdEG4CmoiACgCACABRgRAIAAgBDYCACAEDQFBjAggBkF+IAJ3cTYCAAwCCyALQRBBFCALKAIQIAFGG2ogBDYCACAERQ0BCyAEIAs2AhggASgCECIABEAgBCAANgIQIAAgBDYCGAsgASgCFCIARQ0AIAQgADYCFCAAIAQ2AhgLAkAgA0EPTQRAIAEgAyAIaiIAQQNyNgIEIAAgAWoiACAAKAIEQQFyNgIEDAELIAEgCEEDcjYCBCAJIANBAXI2AgQgAyAJaiADNgIAIAoEQCAKQQN2IgBBA3RBsAhqIQRBnAgoAgAhAgJ/QQEgAHQiACAFcUUEQEGICCAAIAVyNgIAIAQMAQsgBCgCCAshACAEIAI2AgggACACNgIMIAIgBDYCDCACIAA2AggLQZwIIAk2AgBBkAggAzYCAAsgAUEIaiEACyAMQRBqJAAgAAsQACMAIABrQXBxIgAkACAACwYAIAAkAAsEACMAC4AJAgh/BH4jAEGQAWsiBiQAIAYgBS0AA0EYdEGAgIAYcSAFLwAAIAUtAAJBEHRycjYCACAGIAUoAANBAnZBg/7/H3E2AgQgBiAFKAAGQQR2Qf+B/x9xNgIIIAYgBSgACUEGdkH//8AfcTYCDCAFLwANIQggBS0ADyEJIAZCADcCFCAGQgA3AhwgBkEANgIkIAYgCCAJQRB0QYCAPHFyNgIQIAYgBSgAEDYCKCAGIAUoABQ2AiwgBiAFKAAYNgIwIAUoABwhBSAGQQA6AEwgBkEANgI4IAYgBTYCNCAGIAEgAhAEIAQEQCAGIAMgBBAECyAGKAI4IgEEQCAGQTxqIgIgAWpBAToAACABQQFqQQ9NBEAgASAGakE9aiEEAkBBDyABayIDRQ0AIAMgBGoiAUEBa0EAOgAAIARBADoAACADQQNJDQAgAUECa0EAOgAAIARBADoAASABQQNrQQA6AAAgBEEAOgACIANBB0kNACABQQRrQQA6AAAgBEEAOgADIANBCUkNACAEQQAgBGtBA3EiAWoiBEEANgIAIAQgAyABa0F8cSIBaiIDQQRrQQA2AgAgAUEJSQ0AIARBADYCCCAEQQA2AgQgA0EIa0EANgIAIANBDGtBADYCACABQRlJDQAgBEEANgIYIARBADYCFCAEQQA2AhAgBEEANgIMIANBEGtBADYCACADQRRrQQA2AgAgA0EYa0EANgIAIANBHGtBADYCACABIARBBHFBGHIiAWsiA0EgSQ0AIAEgBGohAQNAIAFCADcDGCABQgA3AxAgAUIANwMIIAFCADcDACABQSBqIQEgA0EgayIDQR9LDQALCwsgBkEBOgBMIAYgAkEQEAILIAY1AjQhECAGNQIwIREgBjUCLCEOIAAgBjUCKCAGKAIkIAYoAiAgBigCHCAGKAIYIgNBGnZqIgJBGnZqIgFBGnZqIgtBgICAYHIgAUH///8fcSINIAJB////H3EiCCAGKAIUIAtBGnZBBWxqIgFB////H3EiCUEFaiIFQRp2IANB////H3EgAUEadmoiA2oiAUEadmoiAkEadmoiBEEadmoiDEEfdSIHIANxIAEgDEEfdkEBayIDQf///x9xIgpxciIBQRp0IAUgCnEgByAJcXJyrXwiDzwAACAAIA9CGIg8AAMgACAPQhCIPAACIAAgD0IIiDwAASAAIA4gByAIcSACIApxciICQRR0IAFBBnZyrXwgD0IgiHwiDjwABCAAIA5CGIg8AAcgACAOQhCIPAAGIAAgDkIIiDwABSAAIBEgByANcSAEIApxciIBQQ50IAJBDHZyrXwgDkIgiHwiDjwACCAAIA5CGIg8AAsgACAOQhCIPAAKIAAgDkIIiDwACSAAIBAgAyAMcSAHIAtxckEIdCABQRJ2cq18IA5CIIh8Ig48AAwgACAOQhiIPAAPIAAgDkIQiDwADiAAIA5CCIg8AA0gBkIANwIwIAZCADcCKCAGQgA3AiAgBkIANwIYIAZCADcCECAGQgA3AgggBkIANwIAIAZBkAFqJAALpwwBB38CQCAARQ0AIABBCGsiAyAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQNxRQ0BIAMgAygCACIBayIDQZgIKAIASQ0BIAAgAWohACADQZwIKAIARwRAIAFB/wFNBEAgAygCCCICIAFBA3YiBEEDdEGwCGpGGiACIAMoAgwiAUYEQEGICEGICCgCAEF+IAR3cTYCAAwDCyACIAE2AgwgASACNgIIDAILIAMoAhghBgJAIAMgAygCDCIBRwRAIAMoAggiAiABNgIMIAEgAjYCCAwBCwJAIANBFGoiAigCACIEDQAgA0EQaiICKAIAIgQNAEEAIQEMAQsDQCACIQcgBCIBQRRqIgIoAgAiBA0AIAFBEGohAiABKAIQIgQNAAsgB0EANgIACyAGRQ0BAkAgAyADKAIcIgJBAnRBuApqIgQoAgBGBEAgBCABNgIAIAENAUGMCEGMCCgCAEF+IAJ3cTYCAAwDCyAGQRBBFCAGKAIQIANGG2ogATYCACABRQ0CCyABIAY2AhggAygCECICBEAgASACNgIQIAIgATYCGAsgAygCFCICRQ0BIAEgAjYCFCACIAE2AhgMAQsgBSgCBCIBQQNxQQNHDQBBkAggADYCACAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAA8LIAMgBU8NACAFKAIEIgFBAXFFDQACQCABQQJxRQRAIAVBoAgoAgBGBEBBoAggAzYCAEGUCEGUCCgCACAAaiIANgIAIAMgAEEBcjYCBCADQZwIKAIARw0DQZAIQQA2AgBBnAhBADYCAA8LIAVBnAgoAgBGBEBBnAggAzYCAEGQCEGQCCgCACAAaiIANgIAIAMgAEEBcjYCBCAAIANqIAA2AgAPCyABQXhxIABqIQACQCABQf8BTQRAIAUoAggiAiABQQN2IgRBA3RBsAhqRhogAiAFKAIMIgFGBEBBiAhBiAgoAgBBfiAEd3E2AgAMAgsgAiABNgIMIAEgAjYCCAwBCyAFKAIYIQYCQCAFIAUoAgwiAUcEQCAFKAIIIgJBmAgoAgBJGiACIAE2AgwgASACNgIIDAELAkAgBUEUaiICKAIAIgQNACAFQRBqIgIoAgAiBA0AQQAhAQwBCwNAIAIhByAEIgFBFGoiAigCACIEDQAgAUEQaiECIAEoAhAiBA0ACyAHQQA2AgALIAZFDQACQCAFIAUoAhwiAkECdEG4CmoiBCgCAEYEQCAEIAE2AgAgAQ0BQYwIQYwIKAIAQX4gAndxNgIADAILIAZBEEEUIAYoAhAgBUYbaiABNgIAIAFFDQELIAEgBjYCGCAFKAIQIgIEQCABIAI2AhAgAiABNgIYCyAFKAIUIgJFDQAgASACNgIUIAIgATYCGAsgAyAAQQFyNgIEIAAgA2ogADYCACADQZwIKAIARw0BQZAIIAA2AgAPCyAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAAsgAEH/AU0EQCAAQQN2IgFBA3RBsAhqIQACf0GICCgCACICQQEgAXQiAXFFBEBBiAggASACcjYCACAADAELIAAoAggLIQIgACADNgIIIAIgAzYCDCADIAA2AgwgAyACNgIIDwtBHyECIANCADcCECAAQf///wdNBEAgAEEIdiIBIAFBgP4/akEQdkEIcSIBdCICIAJBgOAfakEQdkEEcSICdCIEIARBgIAPakEQdkECcSIEdEEPdiABIAJyIARyayIBQQF0IAAgAUEVanZBAXFyQRxqIQILIAMgAjYCHCACQQJ0QbgKaiEBAkACQAJAQYwIKAIAIgRBASACdCIHcUUEQEGMCCAEIAdyNgIAIAEgAzYCACADIAE2AhgMAQsgAEEAQRkgAkEBdmsgAkEfRht0IQIgASgCACEBA0AgASIEKAIEQXhxIABGDQIgAkEddiEBIAJBAXQhAiAEIAFBBHFqIgdBEGooAgAiAQ0ACyAHIAM2AhAgAyAENgIYCyADIAM2AgwgAyADNgIIDAELIAQoAggiACADNgIMIAQgAzYCCCADQQA2AhggAyAENgIMIAMgADYCCAtBqAhBqAgoAgBBAWsiAEF/IAAbNgIACwsLCQEAQYEICwIGUA==\";if(!W.startsWith(V)){var na=W;W=b.locateFile?b.locateFile(na,B):B+na}function pa(){var a=W;try{if(a==W&&J)return new Uint8Array(J);var c=H(a);if(c)return c;if(E)return E(a);throw\"both async and sync fetching of the wasm failed\";}catch(d){K(d)}}\nfunction qa(){if(!J&&(x||y)){if(\"function\"===typeof fetch&&!W.startsWith(\"file://\"))return fetch(W,{credentials:\"same-origin\"}).then(function(a){if(!a.ok)throw\"failed to load wasm binary file at '\"+W+\"'\";return a.arrayBuffer()}).catch(function(){return pa()});if(D)return new Promise(function(a,c){D(W,function(d){a(new Uint8Array(d))},c)})}return Promise.resolve().then(function(){return pa()})}\nfunction X(a){for(;0>4;f=(f&15)<<4|l>>2;var t=(l&3)<<6|A;c+=String.fromCharCode(e);64!==l&&(c+=String.fromCharCode(f));64!==A&&(c+=String.fromCharCode(t))}while(d>>=0;if(2147483648=d;d*=2){var e=c*(1+.2/d);e=Math.min(e,a+100663296);e=Math.max(a,e);0>>16);ia();var f=1;break a}catch(l){}f=void 0}if(f)return!0}return!1}};\n(function(){function a(f){b.asm=f.exports;L=b.asm.b;ia();R=b.asm.j;ka.unshift(b.asm.c);S--;b.monitorRunDependencies&&b.monitorRunDependencies(S);0==S&&(null!==T&&(clearInterval(T),T=null),U&&(f=U,U=null,f()))}function c(f){a(f.instance)}function d(f){return qa().then(function(l){return WebAssembly.instantiate(l,e)}).then(f,function(l){I(\"failed to asynchronously prepare wasm: \"+l);K(l)})}var e={a:sa};S++;b.monitorRunDependencies&&b.monitorRunDependencies(S);if(b.instantiateWasm)try{return b.instantiateWasm(e,\na)}catch(f){return I(\"Module.instantiateWasm callback failed with error: \"+f),!1}(function(){return J||\"function\"!==typeof WebAssembly.instantiateStreaming||W.startsWith(V)||W.startsWith(\"file://\")||\"function\"!==typeof fetch?d(c):fetch(W,{credentials:\"same-origin\"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(c,function(l){I(\"wasm streaming compile failed: \"+l);I(\"falling back to ArrayBuffer instantiation\");return d(c)})})})().catch(r);return{}})();\nb.___wasm_call_ctors=function(){return(b.___wasm_call_ctors=b.asm.c).apply(null,arguments)};b._poly1305_auth=function(){return(b._poly1305_auth=b.asm.d).apply(null,arguments)};var da=b.stackSave=function(){return(da=b.stackSave=b.asm.e).apply(null,arguments)},fa=b.stackRestore=function(){return(fa=b.stackRestore=b.asm.f).apply(null,arguments)},O=b.stackAlloc=function(){return(O=b.stackAlloc=b.asm.g).apply(null,arguments)};b._malloc=function(){return(b._malloc=b.asm.h).apply(null,arguments)};\nb._free=function(){return(b._free=b.asm.i).apply(null,arguments)};b.cwrap=function(a,c,d,e){d=d||[];var f=d.every(function(l){return\"number\"===l});return\"string\"!==c&&f&&!e?N(a):function(){return ca(a,c,d,arguments)}};var Y;U=function ta(){Y||Z();Y||(U=ta)};\nfunction Z(){function a(){if(!Y&&(Y=!0,b.calledRun=!0,!M)){X(ka);q(b);if(b.onRuntimeInitialized)b.onRuntimeInitialized();if(b.postRun)for(\"function\"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var c=b.postRun.shift();la.unshift(c)}X(la)}}if(!(0 {\n // eslint-disable-next-line prefer-const\n for (let [type, handler] of Object.entries(handlers)) {\n type = +type;\n if (isFinite(type) && type >= 0 && type < MESSAGE_HANDLERS.length)\n MESSAGE_HANDLERS[type] = handler;\n }\n});\n\nmodule.exports = MESSAGE_HANDLERS;\n","'use strict';\n\nconst {\n bufferSlice,\n bufferParser,\n doFatalError,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst {\n CHANNEL_OPEN_FAILURE,\n COMPAT,\n MESSAGE,\n TERMINAL_MODE,\n} = require('./constants.js');\n\nconst {\n parseKey,\n} = require('./keyParser.js');\n\nconst TERMINAL_MODE_BY_VALUE =\n Array.from(Object.entries(TERMINAL_MODE))\n .reduce((obj, [key, value]) => ({ ...obj, [key]: value }), {});\n\nmodule.exports = {\n // Transport layer protocol ==================================================\n [MESSAGE.DISCONNECT]: (self, payload) => {\n /*\n byte SSH_MSG_DISCONNECT\n uint32 reason code\n string description in ISO-10646 UTF-8 encoding\n string language tag\n */\n bufferParser.init(payload, 1);\n const reason = bufferParser.readUInt32BE();\n const desc = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed DISCONNECT packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: Received DISCONNECT (${reason}, \"${desc}\")`\n );\n\n const handler = self._handlers.DISCONNECT;\n handler && handler(self, reason, desc);\n },\n [MESSAGE.IGNORE]: (self, payload) => {\n /*\n byte SSH_MSG_IGNORE\n string data\n */\n self._debug && self._debug('Inbound: Received IGNORE');\n },\n [MESSAGE.UNIMPLEMENTED]: (self, payload) => {\n /*\n byte SSH_MSG_UNIMPLEMENTED\n uint32 packet sequence number of rejected message\n */\n bufferParser.init(payload, 1);\n const seqno = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (seqno === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed UNIMPLEMENTED packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: Received UNIMPLEMENTED (seqno ${seqno})`);\n },\n [MESSAGE.DEBUG]: (self, payload) => {\n /*\n byte SSH_MSG_DEBUG\n boolean always_display\n string message in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const display = bufferParser.readBool();\n const msg = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed DEBUG packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received DEBUG');\n\n const handler = self._handlers.DEBUG;\n handler && handler(self, display, msg);\n },\n [MESSAGE.SERVICE_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_SERVICE_REQUEST\n string service name\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n bufferParser.clear();\n\n if (name === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed SERVICE_REQUEST packet'\n );\n }\n\n self._debug && self._debug(`Inbound: Received SERVICE_REQUEST (${name})`);\n\n const handler = self._handlers.SERVICE_REQUEST;\n handler && handler(self, name);\n },\n [MESSAGE.SERVICE_ACCEPT]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_SERVICE_ACCEPT\n string service name\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n bufferParser.clear();\n\n if (name === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed SERVICE_ACCEPT packet'\n );\n }\n\n self._debug && self._debug(`Inbound: Received SERVICE_ACCEPT (${name})`);\n\n const handler = self._handlers.SERVICE_ACCEPT;\n handler && handler(self, name);\n },\n\n // User auth protocol -- generic =============================================\n [MESSAGE.USERAUTH_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_USERAUTH_REQUEST\n string user name in ISO-10646 UTF-8 encoding [RFC3629]\n string service name in US-ASCII\n string method name in US-ASCII\n .... method specific fields\n */\n bufferParser.init(payload, 1);\n const user = bufferParser.readString(true);\n const service = bufferParser.readString(true);\n const method = bufferParser.readString(true);\n let methodData;\n let methodDesc;\n switch (method) {\n case 'none':\n methodData = null;\n break;\n case 'password': {\n /*\n boolean \n string plaintext password in ISO-10646 UTF-8 encoding [RFC3629]\n [string new password]\n */\n const isChange = bufferParser.readBool();\n if (isChange !== undefined) {\n methodData = bufferParser.readString(true);\n if (methodData !== undefined && isChange) {\n const newPassword = bufferParser.readString(true);\n if (newPassword !== undefined)\n methodData = { oldPassword: methodData, newPassword };\n else\n methodData = undefined;\n }\n }\n break;\n }\n case 'publickey': {\n /*\n boolean \n string public key algorithm name\n string public key blob\n [string signature]\n */\n const hasSig = bufferParser.readBool();\n if (hasSig !== undefined) {\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n if (hasSig) {\n const blobEnd = bufferParser.pos();\n let signature = bufferParser.readString();\n if (signature !== undefined) {\n if (signature.length > (4 + keyAlgo.length + 4)\n && signature.utf8Slice(4, 4 + keyAlgo.length) === keyAlgo) {\n // Skip algoLen + algo + sigLen\n signature = bufferSlice(signature, 4 + keyAlgo.length + 4);\n }\n\n signature = sigSSHToASN1(signature, keyAlgo);\n if (signature) {\n const sessionID = self._kex.sessionID;\n const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);\n writeUInt32BE(blob, sessionID.length, 0);\n blob.set(sessionID, 4);\n blob.set(\n new Uint8Array(payload.buffer, payload.byteOffset, blobEnd),\n 4 + sessionID.length\n );\n methodData = {\n keyAlgo,\n key,\n signature,\n blob,\n };\n }\n }\n } else {\n methodData = { keyAlgo, key };\n methodDesc = 'publickey -- check';\n }\n }\n break;\n }\n case 'hostbased': {\n /*\n string public key algorithm for host key\n string public host key and certificates for client host\n string client host name expressed as the FQDN in US-ASCII\n string user name on the client host in ISO-10646 UTF-8 encoding\n [RFC3629]\n string signature\n */\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n const localHostname = bufferParser.readString(true);\n const localUsername = bufferParser.readString(true);\n\n const blobEnd = bufferParser.pos();\n let signature = bufferParser.readString();\n if (signature !== undefined) {\n if (signature.length > (4 + keyAlgo.length + 4)\n && signature.utf8Slice(4, 4 + keyAlgo.length) === keyAlgo) {\n // Skip algoLen + algo + sigLen\n signature = bufferSlice(signature, 4 + keyAlgo.length + 4);\n }\n\n signature = sigSSHToASN1(signature, keyAlgo);\n if (signature !== undefined) {\n const sessionID = self._kex.sessionID;\n const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);\n writeUInt32BE(blob, sessionID.length, 0);\n blob.set(sessionID, 4);\n blob.set(\n new Uint8Array(payload.buffer, payload.byteOffset, blobEnd),\n 4 + sessionID.length\n );\n methodData = {\n keyAlgo,\n key,\n signature,\n blob,\n localHostname,\n localUsername,\n };\n }\n }\n break;\n }\n case 'keyboard-interactive':\n /*\n string language tag (as defined in [RFC-3066])\n string submethods (ISO-10646 UTF-8)\n */\n // Skip/ignore language field -- it's deprecated in RFC 4256\n bufferParser.skipString();\n\n methodData = bufferParser.readList();\n break;\n default:\n if (method !== undefined)\n methodData = bufferParser.readRaw();\n }\n bufferParser.clear();\n\n if (methodData === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_REQUEST packet'\n );\n }\n\n if (methodDesc === undefined)\n methodDesc = method;\n\n self._authsQueue.push(method);\n\n self._debug\n && self._debug(`Inbound: Received USERAUTH_REQUEST (${methodDesc})`);\n\n const handler = self._handlers.USERAUTH_REQUEST;\n handler && handler(self, user, service, method, methodData);\n },\n [MESSAGE.USERAUTH_FAILURE]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_FAILURE\n name-list authentications that can continue\n boolean partial success\n */\n bufferParser.init(payload, 1);\n const authMethods = bufferParser.readList();\n const partialSuccess = bufferParser.readBool();\n bufferParser.clear();\n\n if (partialSuccess === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_FAILURE packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: Received USERAUTH_FAILURE (${authMethods})`);\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_FAILURE;\n handler && handler(self, authMethods, partialSuccess);\n },\n [MESSAGE.USERAUTH_SUCCESS]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_SUCCESS\n */\n self._debug && self._debug('Inbound: Received USERAUTH_SUCCESS');\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_SUCCESS;\n handler && handler(self);\n },\n [MESSAGE.USERAUTH_BANNER]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_BANNER\n string message in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const msg = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_BANNER packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_BANNER');\n\n const handler = self._handlers.USERAUTH_BANNER;\n handler && handler(self, msg);\n },\n\n // User auth protocol -- method-specific =====================================\n 60: (self, payload) => {\n if (!self._authsQueue.length) {\n self._debug\n && self._debug('Inbound: Received payload type 60 without auth');\n return;\n }\n\n switch (self._authsQueue[0]) {\n case 'password': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_PASSWD_CHANGEREQ\n string prompt in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const prompt = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet'\n );\n }\n\n self._debug\n && self._debug('Inbound: Received USERAUTH_PASSWD_CHANGEREQ');\n\n const handler = self._handlers.USERAUTH_PASSWD_CHANGEREQ;\n handler && handler(self, prompt);\n break;\n }\n case 'publickey': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_PK_OK\n string public key algorithm name from the request\n string public key blob from the request\n */\n bufferParser.init(payload, 1);\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n bufferParser.clear();\n\n if (key === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_PK_OK packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_PK_OK');\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_PK_OK;\n handler && handler(self, keyAlgo, key);\n break;\n }\n case 'keyboard-interactive': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_INFO_REQUEST\n string name (ISO-10646 UTF-8)\n string instruction (ISO-10646 UTF-8)\n string language tag (as defined in [RFC-3066])\n int num-prompts\n string prompt[1] (ISO-10646 UTF-8)\n boolean echo[1]\n ...\n string prompt[num-prompts] (ISO-10646 UTF-8)\n boolean echo[num-prompts]\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n const instructions = bufferParser.readString(true);\n bufferParser.readString(); // skip lang\n const numPrompts = bufferParser.readUInt32BE();\n let prompts;\n if (numPrompts !== undefined) {\n prompts = new Array(numPrompts);\n let i;\n for (i = 0; i < numPrompts; ++i) {\n const prompt = bufferParser.readString(true);\n const echo = bufferParser.readBool();\n if (echo === undefined)\n break;\n prompts[i] = { prompt, echo };\n }\n if (i !== numPrompts)\n prompts = undefined;\n }\n bufferParser.clear();\n\n if (prompts === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_INFO_REQUEST packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_INFO_REQUEST');\n\n const handler = self._handlers.USERAUTH_INFO_REQUEST;\n handler && handler(self, name, instructions, prompts);\n break;\n }\n default:\n self._debug\n && self._debug('Inbound: Received unexpected payload type 60');\n }\n },\n 61: (self, payload) => {\n if (!self._authsQueue.length) {\n self._debug\n && self._debug('Inbound: Received payload type 61 without auth');\n return;\n }\n /*\n byte SSH_MSG_USERAUTH_INFO_RESPONSE\n int num-responses\n string response[1] (ISO-10646 UTF-8)\n ...\n string response[num-responses] (ISO-10646 UTF-8)\n */\n if (self._authsQueue[0] !== 'keyboard-interactive') {\n return doFatalError(\n self,\n 'Inbound: Received unexpected payload type 61'\n );\n }\n bufferParser.init(payload, 1);\n const numResponses = bufferParser.readUInt32BE();\n let responses;\n if (numResponses !== undefined) {\n responses = new Array(numResponses);\n let i;\n for (i = 0; i < numResponses; ++i) {\n const response = bufferParser.readString(true);\n if (response === undefined)\n break;\n responses[i] = response;\n }\n if (i !== numResponses)\n responses = undefined;\n }\n bufferParser.clear();\n\n if (responses === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_INFO_RESPONSE packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_INFO_RESPONSE');\n\n const handler = self._handlers.USERAUTH_INFO_RESPONSE;\n handler && handler(self, responses);\n },\n\n // Connection protocol -- generic ============================================\n [MESSAGE.GLOBAL_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_GLOBAL_REQUEST\n string request name in US-ASCII only\n boolean want reply\n .... request-specific data follows\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n const wantReply = bufferParser.readBool();\n let data;\n if (wantReply !== undefined) {\n switch (name) {\n case 'tcpip-forward':\n case 'cancel-tcpip-forward': {\n /*\n string address to bind (e.g., \"0.0.0.0\")\n uint32 port number to bind\n */\n const bindAddr = bufferParser.readString(true);\n const bindPort = bufferParser.readUInt32BE();\n if (bindPort !== undefined)\n data = { bindAddr, bindPort };\n break;\n }\n case 'streamlocal-forward@openssh.com':\n case 'cancel-streamlocal-forward@openssh.com': {\n /*\n string socket path\n */\n const socketPath = bufferParser.readString(true);\n if (socketPath !== undefined)\n data = { socketPath };\n break;\n }\n case 'no-more-sessions@openssh.com':\n data = null;\n break;\n case 'hostkeys-00@openssh.com': {\n data = [];\n while (bufferParser.avail() > 0) {\n const keyRaw = bufferParser.readString();\n if (keyRaw === undefined) {\n data = undefined;\n break;\n }\n const key = parseKey(keyRaw);\n if (!(key instanceof Error))\n data.push(key);\n }\n break;\n }\n default:\n data = bufferParser.readRaw();\n }\n }\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed GLOBAL_REQUEST packet'\n );\n }\n\n self._debug && self._debug(`Inbound: GLOBAL_REQUEST (${name})`);\n\n const handler = self._handlers.GLOBAL_REQUEST;\n if (handler)\n handler(self, name, wantReply, data);\n else\n self.requestFailure(); // Auto reject\n },\n [MESSAGE.REQUEST_SUCCESS]: (self, payload) => {\n /*\n byte SSH_MSG_REQUEST_SUCCESS\n .... response specific data\n */\n const data = (payload.length > 1 ? bufferSlice(payload, 1) : null);\n\n self._debug && self._debug('Inbound: REQUEST_SUCCESS');\n\n const handler = self._handlers.REQUEST_SUCCESS;\n handler && handler(self, data);\n },\n [MESSAGE.REQUEST_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_REQUEST_FAILURE\n */\n self._debug && self._debug('Inbound: Received REQUEST_FAILURE');\n\n const handler = self._handlers.REQUEST_FAILURE;\n handler && handler(self);\n },\n\n // Connection protocol -- channel-related ====================================\n [MESSAGE.CHANNEL_OPEN]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN\n string channel type in US-ASCII only\n uint32 sender channel\n uint32 initial window size\n uint32 maximum packet size\n .... channel type specific data follows\n */\n bufferParser.init(payload, 1);\n const type = bufferParser.readString(true);\n const sender = bufferParser.readUInt32BE();\n const window = bufferParser.readUInt32BE();\n const packetSize = bufferParser.readUInt32BE();\n let channelInfo;\n\n switch (type) {\n case 'forwarded-tcpip': // S->C\n case 'direct-tcpip': { // C->S\n /*\n string address that was connected / host to connect\n uint32 port that was connected / port to connect\n string originator IP address\n uint32 originator port\n */\n const destIP = bufferParser.readString(true);\n const destPort = bufferParser.readUInt32BE();\n const srcIP = bufferParser.readString(true);\n const srcPort = bufferParser.readUInt32BE();\n if (srcPort !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { destIP, destPort, srcIP, srcPort }\n };\n }\n break;\n }\n case 'forwarded-streamlocal@openssh.com': // S->C\n case 'direct-streamlocal@openssh.com': { // C->S\n /*\n string socket path\n string reserved for future use\n\n (direct-streamlocal@openssh.com additionally has:)\n uint32 reserved\n */\n const socketPath = bufferParser.readString(true);\n if (socketPath !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { socketPath }\n };\n }\n break;\n }\n case 'x11': { // S->C\n /*\n string originator address (e.g., \"192.168.7.38\")\n uint32 originator port\n */\n const srcIP = bufferParser.readString(true);\n const srcPort = bufferParser.readUInt32BE();\n if (srcPort !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { srcIP, srcPort }\n };\n }\n break;\n }\n default:\n // Includes:\n // 'session' (C->S)\n // 'auth-agent@openssh.com' (S->C)\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: {}\n };\n }\n bufferParser.clear();\n\n if (channelInfo === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_OPEN (s:${sender}, ${type})`);\n\n const handler = self._handlers.CHANNEL_OPEN;\n if (handler) {\n handler(self, channelInfo);\n } else {\n self.channelOpenFail(\n channelInfo.sender,\n CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED,\n '',\n ''\n );\n }\n },\n [MESSAGE.CHANNEL_OPEN_CONFIRMATION]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN_CONFIRMATION\n uint32 recipient channel\n uint32 sender channel\n uint32 initial window size\n uint32 maximum packet size\n .... channel type specific data follows\n */\n // \"The 'recipient channel' is the channel number given in the\n // original open request, and 'sender channel' is the channel number\n // allocated by the other side.\"\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const sender = bufferParser.readUInt32BE();\n const window = bufferParser.readUInt32BE();\n const packetSize = bufferParser.readUInt32BE();\n const data = (bufferParser.avail() ? bufferParser.readRaw() : undefined);\n bufferParser.clear();\n\n if (packetSize === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_OPEN_CONFIRMATION (r:${recipient}, s:${sender})`\n );\n\n const handler = self._handlers.CHANNEL_OPEN_CONFIRMATION;\n if (handler)\n handler(self, { recipient, sender, window, packetSize, data });\n },\n [MESSAGE.CHANNEL_OPEN_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN_FAILURE\n uint32 recipient channel\n uint32 reason code\n string description in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const reason = bufferParser.readUInt32BE();\n const description = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN_FAILURE packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_OPEN_FAILURE;\n handler && handler(self, recipient, reason, description);\n },\n [MESSAGE.CHANNEL_WINDOW_ADJUST]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_WINDOW_ADJUST\n uint32 recipient channel\n uint32 bytes to add\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const bytesToAdd = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (bytesToAdd === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_WINDOW_ADJUST packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_WINDOW_ADJUST (r:${recipient}, ${bytesToAdd})`\n );\n\n const handler = self._handlers.CHANNEL_WINDOW_ADJUST;\n handler && handler(self, recipient, bytesToAdd);\n },\n [MESSAGE.CHANNEL_DATA]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_DATA\n uint32 recipient channel\n string data\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_DATA packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: CHANNEL_DATA (r:${recipient}, ${data.length})`);\n\n const handler = self._handlers.CHANNEL_DATA;\n handler && handler(self, recipient, data);\n },\n [MESSAGE.CHANNEL_EXTENDED_DATA]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_EXTENDED_DATA\n uint32 recipient channel\n uint32 data_type_code\n string data\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const type = bufferParser.readUInt32BE();\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_EXTENDED_DATA packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_EXTENDED_DATA (r:${recipient}, ${data.length})`\n );\n\n const handler = self._handlers.CHANNEL_EXTENDED_DATA;\n handler && handler(self, recipient, data, type);\n },\n [MESSAGE.CHANNEL_EOF]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_EOF\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_EOF packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_EOF (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_EOF;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_CLOSE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_CLOSE\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_CLOSE packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_CLOSE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_CLOSE;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_REQUEST\n uint32 recipient channel\n string request type in US-ASCII characters only\n boolean want reply\n .... type-specific data follows\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const type = bufferParser.readString(true);\n const wantReply = bufferParser.readBool();\n let data;\n if (wantReply !== undefined) {\n switch (type) {\n case 'exit-status': // S->C\n /*\n uint32 exit_status\n */\n data = bufferParser.readUInt32BE();\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'exit-signal': { // S->C\n /*\n string signal name (without the \"SIG\" prefix)\n boolean core dumped\n string error message in ISO-10646 UTF-8 encoding\n string language tag\n */\n let signal;\n let coreDumped;\n if (self._compatFlags & COMPAT.OLD_EXIT) {\n /*\n Instead of `signal name` and `core dumped`, we have just:\n uint32 signal number\n */\n const num = bufferParser.readUInt32BE();\n switch (num) {\n case 1:\n signal = 'HUP';\n break;\n case 2:\n signal = 'INT';\n break;\n case 3:\n signal = 'QUIT';\n break;\n case 6:\n signal = 'ABRT';\n break;\n case 9:\n signal = 'KILL';\n break;\n case 14:\n signal = 'ALRM';\n break;\n case 15:\n signal = 'TERM';\n break;\n default:\n if (num !== undefined) {\n // Unknown or OS-specific\n signal = `UNKNOWN (${num})`;\n }\n }\n coreDumped = false;\n } else {\n signal = bufferParser.readString(true);\n coreDumped = bufferParser.readBool();\n if (coreDumped === undefined)\n signal = undefined;\n }\n const errorMessage = bufferParser.readString(true);\n if (bufferParser.skipString() !== undefined)\n data = { signal, coreDumped, errorMessage };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${signal})`\n );\n break;\n }\n case 'pty-req': { // C->S\n /*\n string TERM environment variable value (e.g., vt100)\n uint32 terminal width, characters (e.g., 80)\n uint32 terminal height, rows (e.g., 24)\n uint32 terminal width, pixels (e.g., 640)\n uint32 terminal height, pixels (e.g., 480)\n string encoded terminal modes\n */\n const term = bufferParser.readString(true);\n const cols = bufferParser.readUInt32BE();\n const rows = bufferParser.readUInt32BE();\n const width = bufferParser.readUInt32BE();\n const height = bufferParser.readUInt32BE();\n const modesBinary = bufferParser.readString();\n if (modesBinary !== undefined) {\n bufferParser.init(modesBinary, 1);\n let modes = {};\n while (bufferParser.avail()) {\n const opcode = bufferParser.readByte();\n if (opcode === TERMINAL_MODE.TTY_OP_END)\n break;\n const name = TERMINAL_MODE_BY_VALUE[opcode];\n const value = bufferParser.readUInt32BE();\n if (opcode === undefined\n || name === undefined\n || value === undefined) {\n modes = undefined;\n break;\n }\n modes[name] = value;\n }\n if (modes !== undefined)\n data = { term, cols, rows, width, height, modes };\n }\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'window-change': { // C->S\n /*\n uint32 terminal width, columns\n uint32 terminal height, rows\n uint32 terminal width, pixels\n uint32 terminal height, pixels\n */\n const cols = bufferParser.readUInt32BE();\n const rows = bufferParser.readUInt32BE();\n const width = bufferParser.readUInt32BE();\n const height = bufferParser.readUInt32BE();\n if (height !== undefined)\n data = { cols, rows, width, height };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'x11-req': { // C->S\n /*\n boolean single connection\n string x11 authentication protocol\n string x11 authentication cookie\n uint32 x11 screen number\n */\n const single = bufferParser.readBool();\n const protocol = bufferParser.readString(true);\n const cookie = bufferParser.readString();\n const screen = bufferParser.readUInt32BE();\n if (screen !== undefined)\n data = { single, protocol, cookie, screen };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'env': { // C->S\n /*\n string variable name\n string variable value\n */\n const name = bufferParser.readString(true);\n const value = bufferParser.readString(true);\n if (value !== undefined)\n data = { name, value };\n if (self._debug) {\n self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: `\n + `${name}=${value})`\n );\n }\n break;\n }\n case 'shell': // C->S\n data = null; // No extra data\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n case 'exec': // C->S\n /*\n string command\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'subsystem': // C->S\n /*\n string subsystem name\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'signal': // C->S\n /*\n string signal name (without the \"SIG\" prefix)\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'xon-xoff': // C->S\n /*\n boolean client can do\n */\n data = bufferParser.readBool();\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'auth-agent-req@openssh.com': // C-S\n data = null; // No extra data\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n default:\n data = (bufferParser.avail() ? bufferParser.readRaw() : null);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n }\n }\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_REQUEST packet'\n );\n }\n\n const handler = self._handlers.CHANNEL_REQUEST;\n handler && handler(self, recipient, type, wantReply, data);\n },\n [MESSAGE.CHANNEL_SUCCESS]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_SUCCESS\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_SUCCESS packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_SUCCESS (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_SUCCESS;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_FAILURE\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_FAILURE packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_FAILURE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_FAILURE;\n handler && handler(self, recipient);\n },\n};\n","'use strict';\n\nconst {\n createDiffieHellman,\n createDiffieHellmanGroup,\n createECDH,\n createHash,\n createPublicKey,\n diffieHellman,\n generateKeyPairSync,\n randomFillSync,\n} = require('crypto');\n\nconst { Ber } = require('asn1');\n\nconst {\n COMPAT,\n curve25519Supported,\n DEFAULT_KEX,\n DEFAULT_SERVER_HOST_KEY,\n DEFAULT_CIPHER,\n DEFAULT_MAC,\n DEFAULT_COMPRESSION,\n DISCONNECT_REASON,\n MESSAGE,\n} = require('./constants.js');\nconst {\n CIPHER_INFO,\n createCipher,\n createDecipher,\n MAC_INFO,\n} = require('./crypto.js');\nconst { parseDERKey } = require('./keyParser.js');\nconst {\n bufferFill,\n bufferParser,\n convertSignature,\n doFatalError,\n FastBuffer,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./utils.js');\nconst {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n} = require('./zlib.js');\n\nlet MESSAGE_HANDLERS;\n\nconst GEX_MIN_BITS = 2048; // RFC 8270\nconst GEX_MAX_BITS = 8192; // RFC 8270\n\nconst EMPTY_BUFFER = Buffer.alloc(0);\n\n// Client/Server\nfunction kexinit(self) {\n /*\n byte SSH_MSG_KEXINIT\n byte[16] cookie (random bytes)\n name-list kex_algorithms\n name-list server_host_key_algorithms\n name-list encryption_algorithms_client_to_server\n name-list encryption_algorithms_server_to_client\n name-list mac_algorithms_client_to_server\n name-list mac_algorithms_server_to_client\n name-list compression_algorithms_client_to_server\n name-list compression_algorithms_server_to_client\n name-list languages_client_to_server\n name-list languages_server_to_client\n boolean first_kex_packet_follows\n uint32 0 (reserved for future extension)\n */\n\n let payload;\n if (self._compatFlags & COMPAT.BAD_DHGEX) {\n const entry = self._offer.lists.kex;\n let kex = entry.array;\n let found = false;\n for (let i = 0; i < kex.length; ++i) {\n if (kex[i].includes('group-exchange')) {\n if (!found) {\n found = true;\n // Copy array lazily\n kex = kex.slice();\n }\n kex.splice(i--, 1);\n }\n }\n if (found) {\n let len = 1 + 16 + self._offer.totalSize + 1 + 4;\n const newKexBuf = Buffer.from(kex.join(','));\n len -= (entry.buffer.length - newKexBuf.length);\n\n const all = self._offer.lists.all;\n const rest = new Uint8Array(\n all.buffer,\n all.byteOffset + 4 + entry.buffer.length,\n all.length - (4 + entry.buffer.length)\n );\n\n payload = Buffer.allocUnsafe(len);\n writeUInt32BE(payload, newKexBuf.length, 17);\n payload.set(newKexBuf, 17 + 4);\n payload.set(rest, 17 + 4 + newKexBuf.length);\n }\n }\n\n if (payload === undefined) {\n payload = Buffer.allocUnsafe(1 + 16 + self._offer.totalSize + 1 + 4);\n self._offer.copyAllTo(payload, 17);\n }\n\n self._debug && self._debug('Outbound: Sending KEXINIT');\n\n payload[0] = MESSAGE.KEXINIT;\n randomFillSync(payload, 1, 16);\n\n // Zero-fill first_kex_packet_follows and reserved bytes\n bufferFill(payload, 0, payload.length - 5);\n\n self._kexinit = payload;\n\n // Needed to correct the starting position in allocated \"packets\" when packets\n // will be buffered due to active key exchange\n self._packetRW.write.allocStart = 0;\n\n // TODO: only create single buffer and set _kexinit as slice of packet instead\n {\n const p = self._packetRW.write.allocStartKEX;\n const packet = self._packetRW.write.alloc(payload.length, true);\n packet.set(payload, p);\n self._cipher.encrypt(self._packetRW.write.finalize(packet, true));\n }\n}\n\nfunction handleKexInit(self, payload) {\n /*\n byte SSH_MSG_KEXINIT\n byte[16] cookie (random bytes)\n name-list kex_algorithms\n name-list server_host_key_algorithms\n name-list encryption_algorithms_client_to_server\n name-list encryption_algorithms_server_to_client\n name-list mac_algorithms_client_to_server\n name-list mac_algorithms_server_to_client\n name-list compression_algorithms_client_to_server\n name-list compression_algorithms_server_to_client\n name-list languages_client_to_server\n name-list languages_server_to_client\n boolean first_kex_packet_follows\n uint32 0 (reserved for future extension)\n */\n const init = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n sc: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n };\n\n bufferParser.init(payload, 17);\n\n if ((init.kex = bufferParser.readList()) === undefined\n || (init.serverHostKey = bufferParser.readList()) === undefined\n || (init.cs.cipher = bufferParser.readList()) === undefined\n || (init.sc.cipher = bufferParser.readList()) === undefined\n || (init.cs.mac = bufferParser.readList()) === undefined\n || (init.sc.mac = bufferParser.readList()) === undefined\n || (init.cs.compress = bufferParser.readList()) === undefined\n || (init.sc.compress = bufferParser.readList()) === undefined\n || (init.cs.lang = bufferParser.readList()) === undefined\n || (init.sc.lang = bufferParser.readList()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n self,\n 'Received malformed KEXINIT',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n const pos = bufferParser.pos();\n const firstFollows = (pos < payload.length && payload[pos] === 1);\n bufferParser.clear();\n\n const local = self._offer;\n const remote = init;\n\n let localKex = local.lists.kex.array;\n if (self._compatFlags & COMPAT.BAD_DHGEX) {\n let found = false;\n for (let i = 0; i < localKex.length; ++i) {\n if (localKex[i].indexOf('group-exchange') !== -1) {\n if (!found) {\n found = true;\n // Copy array lazily\n localKex = localKex.slice();\n }\n localKex.splice(i--, 1);\n }\n }\n }\n\n let clientList;\n let serverList;\n let i;\n const debug = self._debug;\n\n debug && debug('Inbound: Handshake in progress');\n\n // Key exchange method =======================================================\n debug && debug(`Handshake: (local) KEX method: ${localKex}`);\n debug && debug(`Handshake: (remote) KEX method: ${remote.kex}`);\n if (self._server) {\n serverList = localKex;\n clientList = remote.kex;\n } else {\n serverList = remote.kex;\n clientList = localKex;\n }\n // Check for agreeable key exchange algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching key exchange algorithm');\n return doFatalError(\n self,\n 'Handshake failed: no matching key exchange algorithm',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.kex = clientList[i];\n debug && debug(`Handshake: KEX algorithm: ${clientList[i]}`);\n if (firstFollows && (!remote.kex.length || clientList[i] !== remote.kex[0])) {\n // Ignore next inbound packet, it was a wrong first guess at KEX algorithm\n self._skipNextInboundPacket = true;\n }\n\n\n // Server host key format ====================================================\n const localSrvHostKey = local.lists.serverHostKey.array;\n debug && debug(`Handshake: (local) Host key format: ${localSrvHostKey}`);\n debug && debug(\n `Handshake: (remote) Host key format: ${remote.serverHostKey}`\n );\n if (self._server) {\n serverList = localSrvHostKey;\n clientList = remote.serverHostKey;\n } else {\n serverList = remote.serverHostKey;\n clientList = localSrvHostKey;\n }\n // Check for agreeable server host key format\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching host key format');\n return doFatalError(\n self,\n 'Handshake failed: no matching host key format',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.serverHostKey = clientList[i];\n debug && debug(`Handshake: Host key format: ${clientList[i]}`);\n\n\n // Client->Server cipher =====================================================\n const localCSCipher = local.lists.cs.cipher.array;\n debug && debug(`Handshake: (local) C->S cipher: ${localCSCipher}`);\n debug && debug(`Handshake: (remote) C->S cipher: ${remote.cs.cipher}`);\n if (self._server) {\n serverList = localCSCipher;\n clientList = remote.cs.cipher;\n } else {\n serverList = remote.cs.cipher;\n clientList = localCSCipher;\n }\n // Check for agreeable client->server cipher\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S cipher');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S cipher',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.cipher = clientList[i];\n debug && debug(`Handshake: C->S Cipher: ${clientList[i]}`);\n\n\n // Server->Client cipher =====================================================\n const localSCCipher = local.lists.sc.cipher.array;\n debug && debug(`Handshake: (local) S->C cipher: ${localSCCipher}`);\n debug && debug(`Handshake: (remote) S->C cipher: ${remote.sc.cipher}`);\n if (self._server) {\n serverList = localSCCipher;\n clientList = remote.sc.cipher;\n } else {\n serverList = remote.sc.cipher;\n clientList = localSCCipher;\n }\n // Check for agreeable server->client cipher\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C cipher');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C cipher',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.cipher = clientList[i];\n debug && debug(`Handshake: S->C cipher: ${clientList[i]}`);\n\n\n // Client->Server MAC ========================================================\n const localCSMAC = local.lists.cs.mac.array;\n debug && debug(`Handshake: (local) C->S MAC: ${localCSMAC}`);\n debug && debug(`Handshake: (remote) C->S MAC: ${remote.cs.mac}`);\n if (CIPHER_INFO[init.cs.cipher].authLen > 0) {\n init.cs.mac = '';\n debug && debug('Handshake: C->S MAC: ');\n } else {\n if (self._server) {\n serverList = localCSMAC;\n clientList = remote.cs.mac;\n } else {\n serverList = remote.cs.mac;\n clientList = localCSMAC;\n }\n // Check for agreeable client->server hmac algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S MAC');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S MAC',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.mac = clientList[i];\n debug && debug(`Handshake: C->S MAC: ${clientList[i]}`);\n }\n\n\n // Server->Client MAC ========================================================\n const localSCMAC = local.lists.sc.mac.array;\n debug && debug(`Handshake: (local) S->C MAC: ${localSCMAC}`);\n debug && debug(`Handshake: (remote) S->C MAC: ${remote.sc.mac}`);\n if (CIPHER_INFO[init.sc.cipher].authLen > 0) {\n init.sc.mac = '';\n debug && debug('Handshake: S->C MAC: ');\n } else {\n if (self._server) {\n serverList = localSCMAC;\n clientList = remote.sc.mac;\n } else {\n serverList = remote.sc.mac;\n clientList = localSCMAC;\n }\n // Check for agreeable server->client hmac algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C MAC');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C MAC',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.mac = clientList[i];\n debug && debug(`Handshake: S->C MAC: ${clientList[i]}`);\n }\n\n\n // Client->Server compression ================================================\n const localCSCompress = local.lists.cs.compress.array;\n debug && debug(`Handshake: (local) C->S compression: ${localCSCompress}`);\n debug && debug(`Handshake: (remote) C->S compression: ${remote.cs.compress}`);\n if (self._server) {\n serverList = localCSCompress;\n clientList = remote.cs.compress;\n } else {\n serverList = remote.cs.compress;\n clientList = localCSCompress;\n }\n // Check for agreeable client->server compression algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S compression');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S compression',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.compress = clientList[i];\n debug && debug(`Handshake: C->S compression: ${clientList[i]}`);\n\n\n // Server->Client compression ================================================\n const localSCCompress = local.lists.sc.compress.array;\n debug && debug(`Handshake: (local) S->C compression: ${localSCCompress}`);\n debug && debug(`Handshake: (remote) S->C compression: ${remote.sc.compress}`);\n if (self._server) {\n serverList = localSCCompress;\n clientList = remote.sc.compress;\n } else {\n serverList = remote.sc.compress;\n clientList = localSCCompress;\n }\n // Check for agreeable server->client compression algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C compression');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C compression',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.compress = clientList[i];\n debug && debug(`Handshake: S->C compression: ${clientList[i]}`);\n\n init.cs.lang = '';\n init.sc.lang = '';\n\n // XXX: hack -- find a better way to do this\n if (self._kex) {\n if (!self._kexinit) {\n // We received a rekey request, but we haven't sent a KEXINIT in response\n // yet\n kexinit(self);\n }\n self._decipher._onPayload = onKEXPayload.bind(self, { firstPacket: false });\n }\n\n self._kex = createKeyExchange(init, self, payload);\n self._kex.start();\n}\n\nconst createKeyExchange = (() => {\n function convertToMpint(buf) {\n let idx = 0;\n let length = buf.length;\n while (buf[idx] === 0x00) {\n ++idx;\n --length;\n }\n let newBuf;\n if (buf[idx] & 0x80) {\n newBuf = Buffer.allocUnsafe(1 + length);\n newBuf[0] = 0;\n buf.copy(newBuf, 1, idx);\n buf = newBuf;\n } else if (length !== buf.length) {\n newBuf = Buffer.allocUnsafe(length);\n buf.copy(newBuf, 0, idx);\n buf = newBuf;\n }\n return buf;\n }\n\n class KeyExchange {\n constructor(negotiated, protocol, remoteKexinit) {\n this._protocol = protocol;\n\n this.sessionID = (protocol._kex ? protocol._kex.sessionID : undefined);\n this.negotiated = negotiated;\n this._step = 1;\n this._public = null;\n this._dh = null;\n this._sentNEWKEYS = false;\n this._receivedNEWKEYS = false;\n this._finished = false;\n this._hostVerified = false;\n\n // Data needed for initializing cipher/decipher/etc.\n this._kexinit = protocol._kexinit;\n this._remoteKexinit = remoteKexinit;\n this._identRaw = protocol._identRaw;\n this._remoteIdentRaw = protocol._remoteIdentRaw;\n this._hostKey = undefined;\n this._dhData = undefined;\n this._sig = undefined;\n }\n finish() {\n if (this._finished)\n return false;\n this._finished = true;\n\n const isServer = this._protocol._server;\n const negotiated = this.negotiated;\n\n const pubKey = this.convertPublicKey(this._dhData);\n let secret = this.computeSecret(this._dhData);\n if (secret instanceof Error) {\n secret.message =\n `Error while computing DH secret (${this.type}): ${secret.message}`;\n secret.level = 'handshake';\n return doFatalError(\n this._protocol,\n secret,\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n const hash = createHash(this.hashName);\n // V_C\n hashString(hash, (isServer ? this._remoteIdentRaw : this._identRaw));\n // \"V_S\"\n hashString(hash, (isServer ? this._identRaw : this._remoteIdentRaw));\n // \"I_C\"\n hashString(hash, (isServer ? this._remoteKexinit : this._kexinit));\n // \"I_S\"\n hashString(hash, (isServer ? this._kexinit : this._remoteKexinit));\n // \"K_S\"\n const serverPublicHostKey = (isServer\n ? this._hostKey.getPublicSSH()\n : this._hostKey);\n hashString(hash, serverPublicHostKey);\n\n if (this.type === 'groupex') {\n // Group exchange-specific\n const params = this.getDHParams();\n const num = Buffer.allocUnsafe(4);\n // min (uint32)\n writeUInt32BE(num, this._minBits, 0);\n hash.update(num);\n // preferred (uint32)\n writeUInt32BE(num, this._prefBits, 0);\n hash.update(num);\n // max (uint32)\n writeUInt32BE(num, this._maxBits, 0);\n hash.update(num);\n // prime\n hashString(hash, params.prime);\n // generator\n hashString(hash, params.generator);\n }\n\n // method-specific data sent by client\n hashString(hash, (isServer ? pubKey : this.getPublicKey()));\n // method-specific data sent by server\n const serverPublicKey = (isServer ? this.getPublicKey() : pubKey);\n hashString(hash, serverPublicKey);\n // shared secret (\"K\")\n hashString(hash, secret);\n\n // \"H\"\n const exchangeHash = hash.digest();\n\n if (!isServer) {\n bufferParser.init(this._sig, 0);\n const sigType = bufferParser.readString(true);\n\n if (!sigType) {\n return doFatalError(\n this._protocol,\n 'Malformed packet while reading signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (sigType !== negotiated.serverHostKey) {\n return doFatalError(\n this._protocol,\n `Wrong signature type: ${sigType}, `\n + `expected: ${negotiated.serverHostKey}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // \"s\"\n let sigValue = bufferParser.readString();\n\n bufferParser.clear();\n\n if (sigValue === undefined) {\n return doFatalError(\n this._protocol,\n 'Malformed packet while reading signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (!(sigValue = sigSSHToASN1(sigValue, sigType))) {\n return doFatalError(\n this._protocol,\n 'Malformed signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n let parsedHostKey;\n {\n bufferParser.init(this._hostKey, 0);\n const name = bufferParser.readString(true);\n const hostKey = this._hostKey.slice(bufferParser.pos());\n bufferParser.clear();\n parsedHostKey = parseDERKey(hostKey, name);\n if (parsedHostKey instanceof Error) {\n parsedHostKey.level = 'handshake';\n return doFatalError(\n this._protocol,\n parsedHostKey,\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n let hashAlgo;\n // Check if we need to override the default hash algorithm\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256': hashAlgo = 'sha256'; break;\n case 'rsa-sha2-512': hashAlgo = 'sha512'; break;\n }\n\n this._protocol._debug\n && this._protocol._debug('Verifying signature ...');\n\n const verified = parsedHostKey.verify(exchangeHash, sigValue, hashAlgo);\n if (verified !== true) {\n if (verified instanceof Error) {\n this._protocol._debug && this._protocol._debug(\n `Signature verification failed: ${verified.stack}`\n );\n } else {\n this._protocol._debug && this._protocol._debug(\n 'Signature verification failed'\n );\n }\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature verification failed',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug('Verified signature');\n } else {\n // Server\n\n let hashAlgo;\n // Check if we need to override the default hash algorithm\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256': hashAlgo = 'sha256'; break;\n case 'rsa-sha2-512': hashAlgo = 'sha512'; break;\n }\n\n this._protocol._debug && this._protocol._debug(\n 'Generating signature ...'\n );\n\n let signature = this._hostKey.sign(exchangeHash, hashAlgo);\n if (signature instanceof Error) {\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature generation failed for '\n + `${this._hostKey.type} host key: ${signature.message}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n signature = convertSignature(signature, this._hostKey.type);\n if (signature === false) {\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature conversion failed for '\n + `${this._hostKey.type} host key`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // Send KEX reply\n /*\n byte SSH_MSG_KEXDH_REPLY\n / SSH_MSG_KEX_DH_GEX_REPLY\n / SSH_MSG_KEX_ECDH_REPLY\n string server public host key and certificates (K_S)\n string \n string signature of H\n */\n const sigType = this.negotiated.serverHostKey;\n const sigTypeLen = Buffer.byteLength(sigType);\n const sigLen = 4 + sigTypeLen + 4 + signature.length;\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1\n + 4 + serverPublicHostKey.length\n + 4 + serverPublicKey.length\n + 4 + sigLen,\n true\n );\n\n packet[p] = MESSAGE.KEXDH_REPLY;\n\n writeUInt32BE(packet, serverPublicHostKey.length, ++p);\n packet.set(serverPublicHostKey, p += 4);\n\n writeUInt32BE(packet,\n serverPublicKey.length,\n p += serverPublicHostKey.length);\n packet.set(serverPublicKey, p += 4);\n\n writeUInt32BE(packet, sigLen, p += serverPublicKey.length);\n\n writeUInt32BE(packet, sigTypeLen, p += 4);\n packet.utf8Write(sigType, p += 4, sigTypeLen);\n\n writeUInt32BE(packet, signature.length, p += sigTypeLen);\n packet.set(signature, p += 4);\n\n if (this._protocol._debug) {\n let type;\n switch (this.type) {\n case 'group':\n type = 'KEXDH_REPLY';\n break;\n case 'groupex':\n type = 'KEXDH_GEX_REPLY';\n break;\n default:\n type = 'KEXECDH_REPLY';\n }\n this._protocol._debug(`Outbound: Sending ${type}`);\n }\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n trySendNEWKEYS(this);\n\n const completeHandshake = () => {\n if (!this.sessionID)\n this.sessionID = exchangeHash;\n\n {\n const newSecret = Buffer.allocUnsafe(4 + secret.length);\n writeUInt32BE(newSecret, secret.length, 0);\n newSecret.set(secret, 4);\n secret = newSecret;\n }\n\n // Initialize new ciphers, deciphers, etc.\n\n const csCipherInfo = CIPHER_INFO[negotiated.cs.cipher];\n const scCipherInfo = CIPHER_INFO[negotiated.sc.cipher];\n\n const csIV = generateKEXVal(csCipherInfo.ivLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'A');\n const scIV = generateKEXVal(scCipherInfo.ivLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'B');\n const csKey = generateKEXVal(csCipherInfo.keyLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'C');\n const scKey = generateKEXVal(scCipherInfo.keyLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'D');\n let csMacInfo;\n let csMacKey;\n if (!csCipherInfo.authLen) {\n csMacInfo = MAC_INFO[negotiated.cs.mac];\n csMacKey = generateKEXVal(csMacInfo.len,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'E');\n }\n let scMacInfo;\n let scMacKey;\n if (!scCipherInfo.authLen) {\n scMacInfo = MAC_INFO[negotiated.sc.mac];\n scMacKey = generateKEXVal(scMacInfo.len,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'F');\n }\n\n const config = {\n inbound: {\n onPayload: this._protocol._onPayload,\n seqno: this._protocol._decipher.inSeqno,\n decipherInfo: (!isServer ? scCipherInfo : csCipherInfo),\n decipherIV: (!isServer ? scIV : csIV),\n decipherKey: (!isServer ? scKey : csKey),\n macInfo: (!isServer ? scMacInfo : csMacInfo),\n macKey: (!isServer ? scMacKey : csMacKey),\n },\n outbound: {\n onWrite: this._protocol._onWrite,\n seqno: this._protocol._cipher.outSeqno,\n cipherInfo: (isServer ? scCipherInfo : csCipherInfo),\n cipherIV: (isServer ? scIV : csIV),\n cipherKey: (isServer ? scKey : csKey),\n macInfo: (isServer ? scMacInfo : csMacInfo),\n macKey: (isServer ? scMacKey : csMacKey),\n },\n };\n this._protocol._cipher && this._protocol._cipher.free();\n this._protocol._decipher && this._protocol._decipher.free();\n this._protocol._cipher = createCipher(config);\n this._protocol._decipher = createDecipher(config);\n\n const rw = {\n read: undefined,\n write: undefined,\n };\n switch (negotiated.cs.compress) {\n case 'zlib': // starts immediately\n if (isServer)\n rw.read = new ZlibPacketReader();\n else\n rw.write = new ZlibPacketWriter(this._protocol);\n break;\n case 'zlib@openssh.com':\n // Starts after successful user authentication\n\n if (this._protocol._authenticated) {\n // If a rekey happens and this compression method is selected and\n // we already authenticated successfully, we need to start\n // immediately instead\n if (isServer)\n rw.read = new ZlibPacketReader();\n else\n rw.write = new ZlibPacketWriter(this._protocol);\n break;\n }\n // FALLTHROUGH\n default:\n // none -- never any compression/decompression\n\n if (isServer)\n rw.read = new PacketReader();\n else\n rw.write = new PacketWriter(this._protocol);\n }\n switch (negotiated.sc.compress) {\n case 'zlib': // starts immediately\n if (isServer)\n rw.write = new ZlibPacketWriter(this._protocol);\n else\n rw.read = new ZlibPacketReader();\n break;\n case 'zlib@openssh.com':\n // Starts after successful user authentication\n\n if (this._protocol._authenticated) {\n // If a rekey happens and this compression method is selected and\n // we already authenticated successfully, we need to start\n // immediately instead\n if (isServer)\n rw.write = new ZlibPacketWriter(this._protocol);\n else\n rw.read = new ZlibPacketReader();\n break;\n }\n // FALLTHROUGH\n default:\n // none -- never any compression/decompression\n\n if (isServer)\n rw.write = new PacketWriter(this._protocol);\n else\n rw.read = new PacketReader();\n }\n this._protocol._packetRW.read.cleanup();\n this._protocol._packetRW.write.cleanup();\n this._protocol._packetRW = rw;\n\n // Cleanup/reset various state\n this._public = null;\n this._dh = null;\n this._kexinit = this._protocol._kexinit = undefined;\n this._remoteKexinit = undefined;\n this._identRaw = undefined;\n this._remoteIdentRaw = undefined;\n this._hostKey = undefined;\n this._dhData = undefined;\n this._sig = undefined;\n\n this._protocol._onHandshakeComplete(negotiated);\n\n return false;\n };\n if (!isServer)\n return completeHandshake();\n this.finish = completeHandshake;\n }\n\n start() {\n if (!this._protocol._server) {\n if (this._protocol._debug) {\n let type;\n switch (this.type) {\n case 'group':\n type = 'KEXDH_INIT';\n break;\n default:\n type = 'KEXECDH_INIT';\n }\n this._protocol._debug(`Outbound: Sending ${type}`);\n }\n\n const pubKey = this.getPublicKey();\n\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1 + 4 + pubKey.length,\n true\n );\n packet[p] = MESSAGE.KEXDH_INIT;\n writeUInt32BE(packet, pubKey.length, ++p);\n packet.set(pubKey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n }\n getPublicKey() {\n this.generateKeys();\n\n const key = this._public;\n\n if (key)\n return this.convertPublicKey(key);\n }\n convertPublicKey(key) {\n let newKey;\n let idx = 0;\n let len = key.length;\n while (key[idx] === 0x00) {\n ++idx;\n --len;\n }\n\n if (key[idx] & 0x80) {\n newKey = Buffer.allocUnsafe(1 + len);\n newKey[0] = 0;\n key.copy(newKey, 1, idx);\n return newKey;\n }\n\n if (len !== key.length) {\n newKey = Buffer.allocUnsafe(len);\n key.copy(newKey, 0, idx);\n key = newKey;\n }\n return key;\n }\n computeSecret(otherPublicKey) {\n this.generateKeys();\n\n try {\n return convertToMpint(this._dh.computeSecret(otherPublicKey));\n } catch (ex) {\n return ex;\n }\n }\n parse(payload) {\n const type = payload[0];\n switch (this._step) {\n case 1:\n if (this._protocol._server) {\n // Server\n if (type !== MESSAGE.KEXDH_INIT) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_INIT}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH Init'\n );\n /*\n byte SSH_MSG_KEXDH_INIT\n / SSH_MSG_KEX_ECDH_INIT\n string \n */\n bufferParser.init(payload, 1);\n const dhData = bufferParser.readString();\n bufferParser.clear();\n if (dhData === undefined) {\n return doFatalError(\n this._protocol,\n 'Received malformed KEX*_INIT',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // Client public key\n this._dhData = dhData;\n\n let hostKey =\n this._protocol._hostKeys[this.negotiated.serverHostKey];\n if (Array.isArray(hostKey))\n hostKey = hostKey[0];\n this._hostKey = hostKey;\n\n this.finish();\n } else {\n // Client\n if (type !== MESSAGE.KEXDH_REPLY) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_REPLY}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH Reply'\n );\n /*\n byte SSH_MSG_KEXDH_REPLY\n / SSH_MSG_KEX_DH_GEX_REPLY\n / SSH_MSG_KEX_ECDH_REPLY\n string server public host key and certificates (K_S)\n string \n string signature of H\n */\n bufferParser.init(payload, 1);\n let hostPubKey;\n let dhData;\n let sig;\n if ((hostPubKey = bufferParser.readString()) === undefined\n || (dhData = bufferParser.readString()) === undefined\n || (sig = bufferParser.readString()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n this._protocol,\n 'Received malformed KEX*_REPLY',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n bufferParser.clear();\n\n // Check that the host public key type matches what was negotiated\n // during KEXINIT swap\n bufferParser.init(hostPubKey, 0);\n const hostPubKeyType = bufferParser.readString(true);\n bufferParser.clear();\n if (hostPubKeyType === undefined) {\n return doFatalError(\n this._protocol,\n 'Received malformed host public key',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n if (hostPubKeyType !== this.negotiated.serverHostKey) {\n // Check if we need to make an exception\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256':\n case 'rsa-sha2-512':\n if (hostPubKeyType === 'ssh-rsa')\n break;\n // FALLTHROUGH\n default:\n return doFatalError(\n this._protocol,\n 'Host key does not match negotiated type',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n this._hostKey = hostPubKey;\n this._dhData = dhData;\n this._sig = sig;\n\n let checked = false;\n let ret;\n if (this._protocol._hostVerifier === undefined) {\n ret = true;\n this._protocol._debug && this._protocol._debug(\n 'Host accepted by default (no verification)'\n );\n } else {\n ret = this._protocol._hostVerifier(hostPubKey, (permitted) => {\n if (checked)\n return;\n checked = true;\n if (permitted === false) {\n this._protocol._debug && this._protocol._debug(\n 'Host denied (verification failed)'\n );\n return doFatalError(\n this._protocol,\n 'Host denied (verification failed)',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Host accepted (verified)'\n );\n this._hostVerified = true;\n if (this._receivedNEWKEYS)\n this.finish();\n else\n trySendNEWKEYS(this);\n });\n }\n if (ret === undefined) {\n // Async host verification\n ++this._step;\n return;\n }\n checked = true;\n if (ret === false) {\n this._protocol._debug && this._protocol._debug(\n 'Host denied (verification failed)'\n );\n return doFatalError(\n this._protocol,\n 'Host denied (verification failed)',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Host accepted (verified)'\n );\n this._hostVerified = true;\n trySendNEWKEYS(this);\n }\n ++this._step;\n break;\n case 2:\n if (type !== MESSAGE.NEWKEYS) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.NEWKEYS}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Inbound: NEWKEYS'\n );\n this._receivedNEWKEYS = true;\n ++this._step;\n if (this._protocol._server || this._hostVerified)\n return this.finish();\n\n // Signal to current decipher that we need to change to a new decipher\n // for the next packet\n return false;\n default:\n return doFatalError(\n this._protocol,\n `Received unexpected packet ${type} after NEWKEYS`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n }\n\n class Curve25519Exchange extends KeyExchange {\n constructor(hashName, ...args) {\n super(...args);\n\n this.type = '25519';\n this.hashName = hashName;\n this._keys = null;\n }\n generateKeys() {\n if (!this._keys)\n this._keys = generateKeyPairSync('x25519');\n }\n getPublicKey() {\n this.generateKeys();\n\n const key = this._keys.publicKey.export({ type: 'spki', format: 'der' });\n return key.slice(-32); // HACK: avoids parsing DER/BER header\n }\n convertPublicKey(key) {\n let newKey;\n let idx = 0;\n let len = key.length;\n while (key[idx] === 0x00) {\n ++idx;\n --len;\n }\n\n if (key.length === 32)\n return key;\n\n if (len !== key.length) {\n newKey = Buffer.allocUnsafe(len);\n key.copy(newKey, 0, idx);\n key = newKey;\n }\n return key;\n }\n computeSecret(otherPublicKey) {\n this.generateKeys();\n\n try {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.110'); // id-X25519\n asnWriter.endSequence();\n\n // PublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(otherPublicKey.length);\n otherPublicKey.copy(asnWriter._buf,\n asnWriter._offset,\n 0,\n otherPublicKey.length);\n asnWriter._offset += otherPublicKey.length;\n asnWriter.endSequence();\n asnWriter.endSequence();\n\n return convertToMpint(diffieHellman({\n privateKey: this._keys.privateKey,\n publicKey: createPublicKey({\n key: asnWriter.buffer,\n type: 'spki',\n format: 'der',\n }),\n }));\n } catch (ex) {\n return ex;\n }\n }\n }\n\n class ECDHExchange extends KeyExchange {\n constructor(curveName, hashName, ...args) {\n super(...args);\n\n this.type = 'ecdh';\n this.curveName = curveName;\n this.hashName = hashName;\n }\n generateKeys() {\n if (!this._dh) {\n this._dh = createECDH(this.curveName);\n this._public = this._dh.generateKeys();\n }\n }\n }\n\n class DHGroupExchange extends KeyExchange {\n constructor(hashName, ...args) {\n super(...args);\n\n this.type = 'groupex';\n this.hashName = hashName;\n this._prime = null;\n this._generator = null;\n this._minBits = GEX_MIN_BITS;\n this._prefBits = dhEstimate(this.negotiated);\n if (this._protocol._compatFlags & COMPAT.BUG_DHGEX_LARGE)\n this._prefBits = Math.min(this._prefBits, 4096);\n this._maxBits = GEX_MAX_BITS;\n }\n start() {\n if (this._protocol._server)\n return;\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_GEX_REQUEST'\n );\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1 + 4 + 4 + 4,\n true\n );\n packet[p] = MESSAGE.KEXDH_GEX_REQUEST;\n writeUInt32BE(packet, this._minBits, ++p);\n writeUInt32BE(packet, this._prefBits, p += 4);\n writeUInt32BE(packet, this._maxBits, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n generateKeys() {\n if (!this._dh && this._prime && this._generator) {\n this._dh = createDiffieHellman(this._prime, this._generator);\n this._public = this._dh.generateKeys();\n }\n }\n setDHParams(prime, generator) {\n if (!Buffer.isBuffer(prime))\n throw new Error('Invalid prime value');\n if (!Buffer.isBuffer(generator))\n throw new Error('Invalid generator value');\n this._prime = prime;\n this._generator = generator;\n }\n getDHParams() {\n if (this._dh) {\n return {\n prime: convertToMpint(this._dh.getPrime()),\n generator: convertToMpint(this._dh.getGenerator()),\n };\n }\n }\n parse(payload) {\n const type = payload[0];\n switch (this._step) {\n case 1:\n if (this._protocol._server) {\n if (type !== MESSAGE.KEXDH_GEX_REQUEST) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of `\n + MESSAGE.KEXDH_GEX_REQUEST,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n // TODO: allow user implementation to provide safe prime and\n // generator on demand to support group exchange on server side\n return doFatalError(\n this._protocol,\n 'Group exchange not implemented for server',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (type !== MESSAGE.KEXDH_GEX_GROUP) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_GROUP}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Group'\n );\n\n /*\n byte SSH_MSG_KEX_DH_GEX_GROUP\n mpint p, safe prime\n mpint g, generator for subgroup in GF(p)\n */\n bufferParser.init(payload, 1);\n let prime;\n let gen;\n if ((prime = bufferParser.readString()) === undefined\n || (gen = bufferParser.readString()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n this._protocol,\n 'Received malformed KEXDH_GEX_GROUP',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n bufferParser.clear();\n\n // TODO: validate prime\n this.setDHParams(prime, gen);\n this.generateKeys();\n const pubkey = this.getPublicKey();\n\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_GEX_INIT'\n );\n\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet =\n this._protocol._packetRW.write.alloc(1 + 4 + pubkey.length, true);\n packet[p] = MESSAGE.KEXDH_GEX_INIT;\n writeUInt32BE(packet, pubkey.length, ++p);\n packet.set(pubkey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n\n ++this._step;\n break;\n case 2:\n if (this._protocol._server) {\n if (type !== MESSAGE.KEXDH_GEX_INIT) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_INIT}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Init'\n );\n return doFatalError(\n this._protocol,\n 'Group exchange not implemented for server',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n } else if (type !== MESSAGE.KEXDH_GEX_REPLY) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_REPLY}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Reply'\n );\n this._step = 1;\n payload[0] = MESSAGE.KEXDH_REPLY;\n this.parse = KeyExchange.prototype.parse;\n this.parse(payload);\n }\n }\n }\n\n class DHExchange extends KeyExchange {\n constructor(groupName, hashName, ...args) {\n super(...args);\n\n this.type = 'group';\n this.groupName = groupName;\n this.hashName = hashName;\n }\n start() {\n if (!this._protocol._server) {\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_INIT'\n );\n const pubKey = this.getPublicKey();\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet =\n this._protocol._packetRW.write.alloc(1 + 4 + pubKey.length, true);\n packet[p] = MESSAGE.KEXDH_INIT;\n writeUInt32BE(packet, pubKey.length, ++p);\n packet.set(pubKey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n }\n generateKeys() {\n if (!this._dh) {\n this._dh = createDiffieHellmanGroup(this.groupName);\n this._public = this._dh.generateKeys();\n }\n }\n getDHParams() {\n if (this._dh) {\n return {\n prime: convertToMpint(this._dh.getPrime()),\n generator: convertToMpint(this._dh.getGenerator()),\n };\n }\n }\n }\n\n return (negotiated, ...args) => {\n if (typeof negotiated !== 'object' || negotiated === null)\n throw new Error('Invalid negotiated argument');\n const kexType = negotiated.kex;\n if (typeof kexType === 'string') {\n args = [negotiated, ...args];\n switch (kexType) {\n case 'curve25519-sha256':\n case 'curve25519-sha256@libssh.org':\n if (!curve25519Supported)\n break;\n return new Curve25519Exchange('sha256', ...args);\n\n case 'ecdh-sha2-nistp256':\n return new ECDHExchange('prime256v1', 'sha256', ...args);\n case 'ecdh-sha2-nistp384':\n return new ECDHExchange('secp384r1', 'sha384', ...args);\n case 'ecdh-sha2-nistp521':\n return new ECDHExchange('secp521r1', 'sha512', ...args);\n\n case 'diffie-hellman-group1-sha1':\n return new DHExchange('modp2', 'sha1', ...args);\n case 'diffie-hellman-group14-sha1':\n return new DHExchange('modp14', 'sha1', ...args);\n case 'diffie-hellman-group14-sha256':\n return new DHExchange('modp14', 'sha256', ...args);\n case 'diffie-hellman-group15-sha512':\n return new DHExchange('modp15', 'sha512', ...args);\n case 'diffie-hellman-group16-sha512':\n return new DHExchange('modp16', 'sha512', ...args);\n case 'diffie-hellman-group17-sha512':\n return new DHExchange('modp17', 'sha512', ...args);\n case 'diffie-hellman-group18-sha512':\n return new DHExchange('modp18', 'sha512', ...args);\n\n case 'diffie-hellman-group-exchange-sha1':\n return new DHGroupExchange('sha1', ...args);\n case 'diffie-hellman-group-exchange-sha256':\n return new DHGroupExchange('sha256', ...args);\n }\n throw new Error(`Unsupported key exchange algorithm: ${kexType}`);\n }\n throw new Error(`Invalid key exchange type: ${kexType}`);\n };\n})();\n\nconst KexInit = (() => {\n const KEX_PROPERTY_NAMES = [\n 'kex',\n 'serverHostKey',\n ['cs', 'cipher' ],\n ['sc', 'cipher' ],\n ['cs', 'mac' ],\n ['sc', 'mac' ],\n ['cs', 'compress' ],\n ['sc', 'compress' ],\n ['cs', 'lang' ],\n ['sc', 'lang' ],\n ];\n return class KexInit {\n constructor(obj) {\n if (typeof obj !== 'object' || obj === null)\n throw new TypeError('Argument must be an object');\n\n const lists = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n sc: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n\n all: undefined,\n };\n let totalSize = 0;\n for (const prop of KEX_PROPERTY_NAMES) {\n let base;\n let val;\n let desc;\n let key;\n if (typeof prop === 'string') {\n base = lists;\n val = obj[prop];\n desc = key = prop;\n } else {\n const parent = prop[0];\n base = lists[parent];\n key = prop[1];\n val = obj[parent][key];\n desc = `${parent}.${key}`;\n }\n const entry = { array: undefined, buffer: undefined };\n if (Buffer.isBuffer(val)) {\n entry.array = ('' + val).split(',');\n entry.buffer = val;\n totalSize += 4 + val.length;\n } else {\n if (typeof val === 'string')\n val = val.split(',');\n if (Array.isArray(val)) {\n entry.array = val;\n entry.buffer = Buffer.from(val.join(','));\n } else {\n throw new TypeError(`Invalid \\`${desc}\\` type: ${typeof val}`);\n }\n totalSize += 4 + entry.buffer.length;\n }\n base[key] = entry;\n }\n\n const all = Buffer.allocUnsafe(totalSize);\n lists.all = all;\n\n let allPos = 0;\n for (const prop of KEX_PROPERTY_NAMES) {\n let data;\n if (typeof prop === 'string')\n data = lists[prop].buffer;\n else\n data = lists[prop[0]][prop[1]].buffer;\n allPos = writeUInt32BE(all, data.length, allPos);\n all.set(data, allPos);\n allPos += data.length;\n }\n\n this.totalSize = totalSize;\n this.lists = lists;\n }\n copyAllTo(buf, offset) {\n const src = this.lists.all;\n if (typeof offset !== 'number')\n throw new TypeError(`Invalid offset value: ${typeof offset}`);\n if (buf.length - offset < src.length)\n throw new Error('Insufficient space to copy list');\n buf.set(src, offset);\n return src.length;\n }\n };\n})();\n\nconst hashString = (() => {\n const LEN = Buffer.allocUnsafe(4);\n return (hash, buf) => {\n writeUInt32BE(LEN, buf.length, 0);\n hash.update(LEN);\n hash.update(buf);\n };\n})();\n\nfunction generateKEXVal(len, hashName, secret, exchangeHash, sessionID, char) {\n let ret;\n if (len) {\n let digest = createHash(hashName)\n .update(secret)\n .update(exchangeHash)\n .update(char)\n .update(sessionID)\n .digest();\n while (digest.length < len) {\n const chunk = createHash(hashName)\n .update(secret)\n .update(exchangeHash)\n .update(digest)\n .digest();\n const extended = Buffer.allocUnsafe(digest.length + chunk.length);\n extended.set(digest, 0);\n extended.set(chunk, digest.length);\n digest = extended;\n }\n if (digest.length === len)\n ret = digest;\n else\n ret = new FastBuffer(digest.buffer, digest.byteOffset, len);\n } else {\n ret = EMPTY_BUFFER;\n }\n return ret;\n}\n\nfunction onKEXPayload(state, payload) {\n // XXX: move this to the Decipher implementations?\n if (payload.length === 0) {\n this._debug && this._debug('Inbound: Skipping empty packet payload');\n return;\n }\n\n if (this._skipNextInboundPacket) {\n this._skipNextInboundPacket = false;\n return;\n }\n\n payload = this._packetRW.read.read(payload);\n\n const type = payload[0];\n switch (type) {\n case MESSAGE.DISCONNECT:\n case MESSAGE.IGNORE:\n case MESSAGE.UNIMPLEMENTED:\n case MESSAGE.DEBUG:\n if (!MESSAGE_HANDLERS)\n MESSAGE_HANDLERS = require('./handlers.js');\n return MESSAGE_HANDLERS[type](this, payload);\n case MESSAGE.KEXINIT:\n if (!state.firstPacket) {\n return doFatalError(\n this,\n 'Received extra KEXINIT during handshake',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n state.firstPacket = false;\n return handleKexInit(this, payload);\n default:\n if (type < 20 || type > 49) {\n return doFatalError(\n this,\n `Received unexpected packet type ${type}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n return this._kex.parse(payload);\n}\n\nfunction dhEstimate(neg) {\n const csCipher = CIPHER_INFO[neg.cs.cipher];\n const scCipher = CIPHER_INFO[neg.sc.cipher];\n // XXX: if OpenSSH's `umac-*` MACs are ever supported, their key lengths will\n // also need to be considered when calculating `bits`\n const bits = Math.max(\n 0,\n (csCipher.sslName === 'des-ede3-cbc' ? 14 : csCipher.keyLen),\n csCipher.blockLen,\n csCipher.ivLen,\n (scCipher.sslName === 'des-ede3-cbc' ? 14 : scCipher.keyLen),\n scCipher.blockLen,\n scCipher.ivLen\n ) * 8;\n if (bits <= 112)\n return 2048;\n if (bits <= 128)\n return 3072;\n if (bits <= 192)\n return 7680;\n return 8192;\n}\n\nfunction trySendNEWKEYS(kex) {\n if (!kex._sentNEWKEYS) {\n kex._protocol._debug && kex._protocol._debug(\n 'Outbound: Sending NEWKEYS'\n );\n const p = kex._protocol._packetRW.write.allocStartKEX;\n const packet = kex._protocol._packetRW.write.alloc(1, true);\n packet[p] = MESSAGE.NEWKEYS;\n kex._protocol._cipher.encrypt(\n kex._protocol._packetRW.write.finalize(packet, true)\n );\n kex._sentNEWKEYS = true;\n }\n}\n\nmodule.exports = {\n KexInit,\n kexinit,\n onKEXPayload,\n DEFAULT_KEXINIT: new KexInit({\n kex: DEFAULT_KEX,\n serverHostKey: DEFAULT_SERVER_HOST_KEY,\n cs: {\n cipher: DEFAULT_CIPHER,\n mac: DEFAULT_MAC,\n compress: DEFAULT_COMPRESSION,\n lang: [],\n },\n sc: {\n cipher: DEFAULT_CIPHER,\n mac: DEFAULT_MAC,\n compress: DEFAULT_COMPRESSION,\n lang: [],\n },\n }),\n HANDLERS: {\n [MESSAGE.KEXINIT]: handleKexInit,\n },\n};\n","// TODO:\n// * utilize `crypto.create(Private|Public)Key()` and `keyObject.export()`\n// * handle multi-line header values (OpenSSH)?\n// * more thorough validation?\n'use strict';\n\nconst {\n createDecipheriv,\n createECDH,\n createHash,\n createHmac,\n createSign,\n createVerify,\n getCiphers,\n sign: sign_,\n verify: verify_,\n} = require('crypto');\nconst supportedOpenSSLCiphers = getCiphers();\n\nconst { Ber } = require('asn1');\nconst bcrypt_pbkdf = require('bcrypt-pbkdf').pbkdf;\n\nconst { CIPHER_INFO } = require('./crypto.js');\nconst { eddsaSupported, SUPPORTED_CIPHER } = require('./constants.js');\nconst {\n bufferSlice,\n makeBufferParser,\n readString,\n readUInt32BE,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst SYM_HASH_ALGO = Symbol('Hash Algorithm');\nconst SYM_PRIV_PEM = Symbol('Private key PEM');\nconst SYM_PUB_PEM = Symbol('Public key PEM');\nconst SYM_PUB_SSH = Symbol('Public key SSH');\nconst SYM_DECRYPTED = Symbol('Decrypted Key');\n\n// Create OpenSSL cipher name -> SSH cipher name conversion table\nconst CIPHER_INFO_OPENSSL = Object.create(null);\n{\n const keys = Object.keys(CIPHER_INFO);\n for (let i = 0; i < keys.length; ++i) {\n const cipherName = CIPHER_INFO[keys[i]].sslName;\n if (!cipherName || CIPHER_INFO_OPENSSL[cipherName])\n continue;\n CIPHER_INFO_OPENSSL[cipherName] = CIPHER_INFO[keys[i]];\n }\n}\n\nconst binaryKeyParser = makeBufferParser();\n\nfunction makePEM(type, data) {\n data = data.base64Slice(0, data.length);\n let formatted = data.replace(/.{64}/g, '$&\\n');\n if (data.length & 63)\n formatted += '\\n';\n return `-----BEGIN ${type} KEY-----\\n${formatted}-----END ${type} KEY-----`;\n}\n\nfunction combineBuffers(buf1, buf2) {\n const result = Buffer.allocUnsafe(buf1.length + buf2.length);\n result.set(buf1, 0);\n result.set(buf2, buf1.length);\n return result;\n}\n\nfunction skipFields(buf, nfields) {\n const bufLen = buf.length;\n let pos = (buf._pos || 0);\n for (let i = 0; i < nfields; ++i) {\n const left = (bufLen - pos);\n if (pos >= bufLen || left < 4)\n return false;\n const len = readUInt32BE(buf, pos);\n if (left < 4 + len)\n return false;\n pos += 4 + len;\n }\n buf._pos = pos;\n return true;\n}\n\nfunction genOpenSSLRSAPub(n, e) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.113549.1.1.1'); // rsaEncryption\n // algorithm parameters (RSA has none)\n asnWriter.writeNull();\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n asnWriter.startSequence();\n asnWriter.writeBuffer(n, Ber.Integer);\n asnWriter.writeBuffer(e, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHRSAPub(n, e) {\n const publicKey = Buffer.allocUnsafe(4 + 7 + 4 + e.length + 4 + n.length);\n\n writeUInt32BE(publicKey, 7, 0);\n publicKey.utf8Write('ssh-rsa', 4, 7);\n\n let i = 4 + 7;\n writeUInt32BE(publicKey, e.length, i);\n publicKey.set(e, i += 4);\n\n writeUInt32BE(publicKey, n.length, i += e.length);\n publicKey.set(n, i + 4);\n\n return publicKey;\n}\n\nconst genOpenSSLRSAPriv = (() => {\n function genRSAASN1Buf(n, e, d, p, q, dmp1, dmq1, iqmp) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeInt(0x00, Ber.Integer);\n asnWriter.writeBuffer(n, Ber.Integer);\n asnWriter.writeBuffer(e, Ber.Integer);\n asnWriter.writeBuffer(d, Ber.Integer);\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(dmp1, Ber.Integer);\n asnWriter.writeBuffer(dmq1, Ber.Integer);\n asnWriter.writeBuffer(iqmp, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n\n function bigIntFromBuffer(buf) {\n return BigInt(`0x${buf.hexSlice(0, buf.length)}`);\n }\n\n function bigIntToBuffer(bn) {\n let hex = bn.toString(16);\n if ((hex.length & 1) !== 0) {\n hex = `0${hex}`;\n } else {\n const sigbit = hex.charCodeAt(0);\n // BER/DER integers require leading zero byte to denote a positive value\n // when first byte >= 0x80\n if (sigbit === 56/* '8' */\n || sigbit === 57/* '9' */\n || (sigbit >= 97/* 'a' */ && sigbit <= 102/* 'f' */)) {\n hex = `00${hex}`;\n }\n }\n return Buffer.from(hex, 'hex');\n }\n\n return function genOpenSSLRSAPriv(n, e, d, iqmp, p, q) {\n const bn_d = bigIntFromBuffer(d);\n const dmp1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(p) - 1n));\n const dmq1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(q) - 1n));\n return makePEM('RSA PRIVATE',\n genRSAASN1Buf(n, e, d, p, q, dmp1, dmq1, iqmp));\n };\n})();\n\nfunction genOpenSSLDSAPub(p, q, g, y) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.10040.4.1'); // id-dsa\n // algorithm parameters\n asnWriter.startSequence();\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(g, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n asnWriter.writeBuffer(y, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHDSAPub(p, q, g, y) {\n const publicKey = Buffer.allocUnsafe(\n 4 + 7 + 4 + p.length + 4 + q.length + 4 + g.length + 4 + y.length\n );\n\n writeUInt32BE(publicKey, 7, 0);\n publicKey.utf8Write('ssh-dss', 4, 7);\n\n let i = 4 + 7;\n writeUInt32BE(publicKey, p.length, i);\n publicKey.set(p, i += 4);\n\n writeUInt32BE(publicKey, q.length, i += p.length);\n publicKey.set(q, i += 4);\n\n writeUInt32BE(publicKey, g.length, i += q.length);\n publicKey.set(g, i += 4);\n\n writeUInt32BE(publicKey, y.length, i += g.length);\n publicKey.set(y, i + 4);\n\n return publicKey;\n}\n\nfunction genOpenSSLDSAPriv(p, q, g, y, x) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeInt(0x00, Ber.Integer);\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(g, Ber.Integer);\n asnWriter.writeBuffer(y, Ber.Integer);\n asnWriter.writeBuffer(x, Ber.Integer);\n asnWriter.endSequence();\n return makePEM('DSA PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLEdPub(pub) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.112'); // id-Ed25519\n asnWriter.endSequence();\n\n // PublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(pub.length);\n asnWriter._buf.set(pub, asnWriter._offset);\n asnWriter._offset += pub.length;\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHEdPub(pub) {\n const publicKey = Buffer.allocUnsafe(4 + 11 + 4 + pub.length);\n\n writeUInt32BE(publicKey, 11, 0);\n publicKey.utf8Write('ssh-ed25519', 4, 11);\n\n writeUInt32BE(publicKey, pub.length, 15);\n publicKey.set(pub, 19);\n\n return publicKey;\n}\n\nfunction genOpenSSLEdPriv(priv) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // version\n asnWriter.writeInt(0x00, Ber.Integer);\n\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.112'); // id-Ed25519\n asnWriter.endSequence();\n\n // PrivateKey\n asnWriter.startSequence(Ber.OctetString);\n asnWriter.writeBuffer(priv, Ber.OctetString);\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLECDSAPub(oid, Q) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.10045.2.1'); // id-ecPublicKey\n // algorithm parameters (namedCurve)\n asnWriter.writeOID(oid);\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(Q.length);\n asnWriter._buf.set(Q, asnWriter._offset);\n asnWriter._offset += Q.length;\n // end hack\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHECDSAPub(oid, Q) {\n let curveName;\n switch (oid) {\n case '1.2.840.10045.3.1.7':\n // prime256v1/secp256r1\n curveName = 'nistp256';\n break;\n case '1.3.132.0.34':\n // secp384r1\n curveName = 'nistp384';\n break;\n case '1.3.132.0.35':\n // secp521r1\n curveName = 'nistp521';\n break;\n default:\n return;\n }\n\n const publicKey = Buffer.allocUnsafe(4 + 19 + 4 + 8 + 4 + Q.length);\n\n writeUInt32BE(publicKey, 19, 0);\n publicKey.utf8Write(`ecdsa-sha2-${curveName}`, 4, 19);\n\n writeUInt32BE(publicKey, 8, 23);\n publicKey.utf8Write(curveName, 27, 8);\n\n writeUInt32BE(publicKey, Q.length, 35);\n publicKey.set(Q, 39);\n\n return publicKey;\n}\n\nfunction genOpenSSLECDSAPriv(oid, pub, priv) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // version\n asnWriter.writeInt(0x01, Ber.Integer);\n // privateKey\n asnWriter.writeBuffer(priv, Ber.OctetString);\n // parameters (optional)\n asnWriter.startSequence(0xA0);\n asnWriter.writeOID(oid);\n asnWriter.endSequence();\n // publicKey (optional)\n asnWriter.startSequence(0xA1);\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(pub.length);\n asnWriter._buf.set(pub, asnWriter._offset);\n asnWriter._offset += pub.length;\n // end hack\n asnWriter.endSequence();\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('EC PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLECDSAPubFromPriv(curveName, priv) {\n const tempECDH = createECDH(curveName);\n tempECDH.setPrivateKey(priv);\n return tempECDH.getPublicKey();\n}\n\nconst BaseKey = {\n sign: (() => {\n if (typeof sign_ === 'function') {\n return function sign(data, algo) {\n const pem = this[SYM_PRIV_PEM];\n if (pem === null)\n return new Error('No private key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n try {\n return sign_(algo, data, pem);\n } catch (ex) {\n return ex;\n }\n };\n }\n return function sign(data, algo) {\n const pem = this[SYM_PRIV_PEM];\n if (pem === null)\n return new Error('No private key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n const signature = createSign(algo);\n signature.update(data);\n try {\n return signature.sign(pem);\n } catch (ex) {\n return ex;\n }\n };\n })(),\n verify: (() => {\n if (typeof verify_ === 'function') {\n return function verify(data, signature, algo) {\n const pem = this[SYM_PUB_PEM];\n if (pem === null)\n return new Error('No public key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n try {\n return verify_(algo, data, pem, signature);\n } catch (ex) {\n return ex;\n }\n };\n }\n return function verify(data, signature, algo) {\n const pem = this[SYM_PUB_PEM];\n if (pem === null)\n return new Error('No public key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n const verifier = createVerify(algo);\n verifier.update(data);\n try {\n return verifier.verify(pem, signature);\n } catch (ex) {\n return ex;\n }\n };\n })(),\n isPrivateKey: function isPrivateKey() {\n return (this[SYM_PRIV_PEM] !== null);\n },\n getPrivatePEM: function getPrivatePEM() {\n return this[SYM_PRIV_PEM];\n },\n getPublicPEM: function getPublicPEM() {\n return this[SYM_PUB_PEM];\n },\n getPublicSSH: function getPublicSSH() {\n return this[SYM_PUB_SSH];\n },\n equals: function equals(key) {\n const parsed = parseKey(key);\n if (parsed instanceof Error)\n return false;\n return (\n this.type === parsed.type\n && this[SYM_PRIV_PEM] === parsed[SYM_PRIV_PEM]\n && this[SYM_PUB_PEM] === parsed[SYM_PUB_PEM]\n && this[SYM_PUB_SSH] === parsed[SYM_PUB_SSH]\n );\n },\n};\n\n\nfunction OpenSSH_Private(type, comment, privPEM, pubPEM, pubSSH, algo,\n decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nOpenSSH_Private.prototype = BaseKey;\n{\n const regexp = /^-----BEGIN OPENSSH PRIVATE KEY-----(?:\\r\\n|\\n)([\\s\\S]+)(?:\\r\\n|\\n)-----END OPENSSH PRIVATE KEY-----$/;\n OpenSSH_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n let ret;\n const data = Buffer.from(m[1], 'base64');\n if (data.length < 31) // magic (+ magic null term.) + minimum field lengths\n return new Error('Malformed OpenSSH private key');\n const magic = data.utf8Slice(0, 15);\n if (magic !== 'openssh-key-v1\\0')\n return new Error(`Unsupported OpenSSH key magic: ${magic}`);\n\n const cipherName = readString(data, 15, true);\n if (cipherName === undefined)\n return new Error('Malformed OpenSSH private key');\n if (cipherName !== 'none' && SUPPORTED_CIPHER.indexOf(cipherName) === -1)\n return new Error(`Unsupported cipher for OpenSSH key: ${cipherName}`);\n\n const kdfName = readString(data, data._pos, true);\n if (kdfName === undefined)\n return new Error('Malformed OpenSSH private key');\n if (kdfName !== 'none') {\n if (cipherName === 'none')\n return new Error('Malformed OpenSSH private key');\n if (kdfName !== 'bcrypt')\n return new Error(`Unsupported kdf name for OpenSSH key: ${kdfName}`);\n if (!passphrase) {\n return new Error(\n 'Encrypted private OpenSSH key detected, but no passphrase given'\n );\n }\n } else if (cipherName !== 'none') {\n return new Error('Malformed OpenSSH private key');\n }\n\n let encInfo;\n let cipherKey;\n let cipherIV;\n if (cipherName !== 'none')\n encInfo = CIPHER_INFO[cipherName];\n const kdfOptions = readString(data, data._pos);\n if (kdfOptions === undefined)\n return new Error('Malformed OpenSSH private key');\n if (kdfOptions.length) {\n switch (kdfName) {\n case 'none':\n return new Error('Malformed OpenSSH private key');\n case 'bcrypt':\n /*\n string salt\n uint32 rounds\n */\n const salt = readString(kdfOptions, 0);\n if (salt === undefined || kdfOptions._pos + 4 > kdfOptions.length)\n return new Error('Malformed OpenSSH private key');\n const rounds = readUInt32BE(kdfOptions, kdfOptions._pos);\n const gen = Buffer.allocUnsafe(encInfo.keyLen + encInfo.ivLen);\n const r = bcrypt_pbkdf(passphrase,\n passphrase.length,\n salt,\n salt.length,\n gen,\n gen.length,\n rounds);\n if (r !== 0)\n return new Error('Failed to generate information to decrypt key');\n cipherKey = bufferSlice(gen, 0, encInfo.keyLen);\n cipherIV = bufferSlice(gen, encInfo.keyLen, gen.length);\n break;\n }\n } else if (kdfName !== 'none') {\n return new Error('Malformed OpenSSH private key');\n }\n\n if (data._pos + 3 >= data.length)\n return new Error('Malformed OpenSSH private key');\n const keyCount = readUInt32BE(data, data._pos);\n data._pos += 4;\n\n if (keyCount > 0) {\n // TODO: place sensible limit on max `keyCount`\n\n // Read public keys first\n for (let i = 0; i < keyCount; ++i) {\n const pubData = readString(data, data._pos);\n if (pubData === undefined)\n return new Error('Malformed OpenSSH private key');\n const type = readString(pubData, 0, true);\n if (type === undefined)\n return new Error('Malformed OpenSSH private key');\n }\n\n let privBlob = readString(data, data._pos);\n if (privBlob === undefined)\n return new Error('Malformed OpenSSH private key');\n\n if (cipherKey !== undefined) {\n // Encrypted private key(s)\n if (privBlob.length < encInfo.blockLen\n || (privBlob.length % encInfo.blockLen) !== 0) {\n return new Error('Malformed OpenSSH private key');\n }\n try {\n const options = { authTagLength: encInfo.authLen };\n const decipher = createDecipheriv(encInfo.sslName,\n cipherKey,\n cipherIV,\n options);\n if (encInfo.authLen > 0) {\n if (data.length - data._pos < encInfo.authLen)\n return new Error('Malformed OpenSSH private key');\n decipher.setAuthTag(\n bufferSlice(data, data._pos, data._pos += encInfo.authLen)\n );\n }\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n } catch (ex) {\n return ex;\n }\n }\n // Nothing should we follow the private key(s), except a possible\n // authentication tag for relevant ciphers\n if (data._pos !== data.length)\n return new Error('Malformed OpenSSH private key');\n\n ret = parseOpenSSHPrivKeys(privBlob, keyCount, cipherKey !== undefined);\n } else {\n ret = [];\n }\n // This will need to change if/when OpenSSH ever starts storing multiple\n // keys in their key files\n return ret[0];\n };\n\n function parseOpenSSHPrivKeys(data, nkeys, decrypted) {\n const keys = [];\n /*\n uint32 checkint\n uint32 checkint\n string privatekey1\n string comment1\n string privatekey2\n string comment2\n ...\n string privatekeyN\n string commentN\n char 1\n char 2\n char 3\n ...\n char padlen % 255\n */\n if (data.length < 8)\n return new Error('Malformed OpenSSH private key');\n const check1 = readUInt32BE(data, 0);\n const check2 = readUInt32BE(data, 4);\n if (check1 !== check2) {\n if (decrypted) {\n return new Error(\n 'OpenSSH key integrity check failed -- bad passphrase?'\n );\n }\n return new Error('OpenSSH key integrity check failed');\n }\n data._pos = 8;\n let i;\n let oid;\n for (i = 0; i < nkeys; ++i) {\n let algo;\n let privPEM;\n let pubPEM;\n let pubSSH;\n // The OpenSSH documentation for the key format actually lies, the\n // entirety of the private key content is not contained with a string\n // field, it's actually the literal contents of the private key, so to be\n // able to find the end of the key data you need to know the layout/format\n // of each key type ...\n const type = readString(data, data._pos, true);\n if (type === undefined)\n return new Error('Malformed OpenSSH private key');\n\n switch (type) {\n case 'ssh-rsa': {\n /*\n string n -- public\n string e -- public\n string d -- private\n string iqmp -- private\n string p -- private\n string q -- private\n */\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed OpenSSH private key');\n const e = readString(data, data._pos);\n if (e === undefined)\n return new Error('Malformed OpenSSH private key');\n const d = readString(data, data._pos);\n if (d === undefined)\n return new Error('Malformed OpenSSH private key');\n const iqmp = readString(data, data._pos);\n if (iqmp === undefined)\n return new Error('Malformed OpenSSH private key');\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed OpenSSH private key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n privPEM = genOpenSSLRSAPriv(n, e, d, iqmp, p, q);\n algo = 'sha1';\n break;\n }\n case 'ssh-dss': {\n /*\n string p -- public\n string q -- public\n string g -- public\n string y -- public\n string x -- private\n */\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed OpenSSH private key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH private key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed OpenSSH private key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed OpenSSH private key');\n const x = readString(data, data._pos);\n if (x === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n privPEM = genOpenSSLDSAPriv(p, q, g, y, x);\n algo = 'sha1';\n break;\n }\n case 'ssh-ed25519': {\n if (!eddsaSupported)\n return new Error(`Unsupported OpenSSH private key type: ${type}`);\n /*\n * string public key\n * string private key + public key\n */\n const edpub = readString(data, data._pos);\n if (edpub === undefined || edpub.length !== 32)\n return new Error('Malformed OpenSSH private key');\n const edpriv = readString(data, data._pos);\n if (edpriv === undefined || edpriv.length !== 64)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLEdPub(edpub);\n pubSSH = genOpenSSHEdPub(edpub);\n privPEM = genOpenSSLEdPriv(bufferSlice(edpriv, 0, 32));\n algo = null;\n break;\n }\n case 'ecdsa-sha2-nistp256':\n algo = 'sha256';\n oid = '1.2.840.10045.3.1.7';\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp384':\n if (algo === undefined) {\n algo = 'sha384';\n oid = '1.3.132.0.34';\n }\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp521': {\n if (algo === undefined) {\n algo = 'sha512';\n oid = '1.3.132.0.35';\n }\n /*\n string curve name\n string Q -- public\n string d -- private\n */\n // TODO: validate curve name against type\n if (!skipFields(data, 1)) // Skip curve name\n return new Error('Malformed OpenSSH private key');\n const ecpub = readString(data, data._pos);\n if (ecpub === undefined)\n return new Error('Malformed OpenSSH private key');\n const ecpriv = readString(data, data._pos);\n if (ecpriv === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLECDSAPub(oid, ecpub);\n pubSSH = genOpenSSHECDSAPub(oid, ecpub);\n privPEM = genOpenSSLECDSAPriv(oid, ecpub, ecpriv);\n break;\n }\n default:\n return new Error(`Unsupported OpenSSH private key type: ${type}`);\n }\n\n const privComment = readString(data, data._pos, true);\n if (privComment === undefined)\n return new Error('Malformed OpenSSH private key');\n\n keys.push(\n new OpenSSH_Private(type, privComment, privPEM, pubPEM, pubSSH, algo,\n decrypted)\n );\n }\n let cnt = 0;\n for (i = data._pos; i < data.length; ++i) {\n if (data[i] !== (++cnt % 255))\n return new Error('Malformed OpenSSH private key');\n }\n\n return keys;\n }\n}\n\n\nfunction OpenSSH_Old_Private(type, comment, privPEM, pubPEM, pubSSH, algo,\n decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nOpenSSH_Old_Private.prototype = BaseKey;\n{\n const regexp = /^-----BEGIN (RSA|DSA|EC) PRIVATE KEY-----(?:\\r\\n|\\n)((?:[^:]+:\\s*[\\S].*(?:\\r\\n|\\n))*)([\\s\\S]+)(?:\\r\\n|\\n)-----END (RSA|DSA|EC) PRIVATE KEY-----$/;\n OpenSSH_Old_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n let privBlob = Buffer.from(m[3], 'base64');\n let headers = m[2];\n let decrypted = false;\n if (headers !== undefined) {\n // encrypted key\n headers = headers.split(/\\r\\n|\\n/g);\n for (let i = 0; i < headers.length; ++i) {\n const header = headers[i];\n let sepIdx = header.indexOf(':');\n if (header.slice(0, sepIdx) === 'DEK-Info') {\n const val = header.slice(sepIdx + 2);\n sepIdx = val.indexOf(',');\n if (sepIdx === -1)\n continue;\n const cipherName = val.slice(0, sepIdx).toLowerCase();\n if (supportedOpenSSLCiphers.indexOf(cipherName) === -1) {\n return new Error(\n `Cipher (${cipherName}) not supported `\n + 'for encrypted OpenSSH private key'\n );\n }\n const encInfo = CIPHER_INFO_OPENSSL[cipherName];\n if (!encInfo) {\n return new Error(\n `Cipher (${cipherName}) not supported `\n + 'for encrypted OpenSSH private key'\n );\n }\n const cipherIV = Buffer.from(val.slice(sepIdx + 1), 'hex');\n if (cipherIV.length !== encInfo.ivLen)\n return new Error('Malformed encrypted OpenSSH private key');\n if (!passphrase) {\n return new Error(\n 'Encrypted OpenSSH private key detected, but no passphrase given'\n );\n }\n const ivSlice = bufferSlice(cipherIV, 0, 8);\n let cipherKey = createHash('md5')\n .update(passphrase)\n .update(ivSlice)\n .digest();\n while (cipherKey.length < encInfo.keyLen) {\n cipherKey = combineBuffers(\n cipherKey,\n createHash('md5')\n .update(cipherKey)\n .update(passphrase)\n .update(ivSlice)\n .digest()\n );\n }\n if (cipherKey.length > encInfo.keyLen)\n cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);\n try {\n const decipher = createDecipheriv(cipherName, cipherKey, cipherIV);\n decipher.setAutoPadding(false);\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n decrypted = true;\n } catch (ex) {\n return ex;\n }\n }\n }\n }\n\n let type;\n let privPEM;\n let pubPEM;\n let pubSSH;\n let algo;\n let reader;\n let errMsg = 'Malformed OpenSSH private key';\n if (decrypted)\n errMsg += '. Bad passphrase?';\n switch (m[1]) {\n case 'RSA':\n type = 'ssh-rsa';\n privPEM = makePEM('RSA PRIVATE', privBlob);\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n const n = reader.readString(Ber.Integer, true);\n if (n === null)\n return new Error(errMsg);\n const e = reader.readString(Ber.Integer, true);\n if (e === null)\n return new Error(errMsg);\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n } catch {\n return new Error(errMsg);\n }\n algo = 'sha1';\n break;\n case 'DSA':\n type = 'ssh-dss';\n privPEM = makePEM('DSA PRIVATE', privBlob);\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n const p = reader.readString(Ber.Integer, true);\n if (p === null)\n return new Error(errMsg);\n const q = reader.readString(Ber.Integer, true);\n if (q === null)\n return new Error(errMsg);\n const g = reader.readString(Ber.Integer, true);\n if (g === null)\n return new Error(errMsg);\n const y = reader.readString(Ber.Integer, true);\n if (y === null)\n return new Error(errMsg);\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n } catch {\n return new Error(errMsg);\n }\n algo = 'sha1';\n break;\n case 'EC':\n let ecSSLName;\n let ecPriv;\n let ecOID;\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n ecPriv = reader.readString(Ber.OctetString, true);\n reader.readByte(); // Skip \"complex\" context type byte\n const offset = reader.readLength(); // Skip context length\n if (offset !== null) {\n reader._offset = offset;\n ecOID = reader.readOID();\n if (ecOID === null)\n return new Error(errMsg);\n switch (ecOID) {\n case '1.2.840.10045.3.1.7':\n // prime256v1/secp256r1\n ecSSLName = 'prime256v1';\n type = 'ecdsa-sha2-nistp256';\n algo = 'sha256';\n break;\n case '1.3.132.0.34':\n // secp384r1\n ecSSLName = 'secp384r1';\n type = 'ecdsa-sha2-nistp384';\n algo = 'sha384';\n break;\n case '1.3.132.0.35':\n // secp521r1\n ecSSLName = 'secp521r1';\n type = 'ecdsa-sha2-nistp521';\n algo = 'sha512';\n break;\n default:\n return new Error(`Unsupported private key EC OID: ${ecOID}`);\n }\n } else {\n return new Error(errMsg);\n }\n } catch {\n return new Error(errMsg);\n }\n privPEM = makePEM('EC PRIVATE', privBlob);\n const pubBlob = genOpenSSLECDSAPubFromPriv(ecSSLName, ecPriv);\n pubPEM = genOpenSSLECDSAPub(ecOID, pubBlob);\n pubSSH = genOpenSSHECDSAPub(ecOID, pubBlob);\n break;\n }\n\n return new OpenSSH_Old_Private(type, '', privPEM, pubPEM, pubSSH, algo,\n decrypted);\n };\n}\n\n\nfunction PPK_Private(type, comment, privPEM, pubPEM, pubSSH, algo, decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nPPK_Private.prototype = BaseKey;\n{\n const EMPTY_PASSPHRASE = Buffer.alloc(0);\n const PPK_IV = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);\n const PPK_PP1 = Buffer.from([0, 0, 0, 0]);\n const PPK_PP2 = Buffer.from([0, 0, 0, 1]);\n const regexp = /^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\\r?\\nEncryption: (aes256-cbc|none)\\r?\\nComment: ([^\\r\\n]*)\\r?\\nPublic-Lines: \\d+\\r?\\n([\\s\\S]+?)\\r?\\nPrivate-Lines: \\d+\\r?\\n([\\s\\S]+?)\\r?\\nPrivate-MAC: ([^\\r\\n]+)/;\n PPK_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n // m[1] = key type\n // m[2] = encryption type\n // m[3] = comment\n // m[4] = base64-encoded public key data:\n // for \"ssh-rsa\":\n // string \"ssh-rsa\"\n // mpint e (public exponent)\n // mpint n (modulus)\n // for \"ssh-dss\":\n // string \"ssh-dss\"\n // mpint p (modulus)\n // mpint q (prime)\n // mpint g (base number)\n // mpint y (public key parameter: g^x mod p)\n // m[5] = base64-encoded private key data:\n // for \"ssh-rsa\":\n // mpint d (private exponent)\n // mpint p (prime 1)\n // mpint q (prime 2)\n // mpint iqmp ([inverse of q] mod p)\n // for \"ssh-dss\":\n // mpint x (private key parameter)\n // m[6] = SHA1 HMAC over:\n // string name of algorithm (\"ssh-dss\", \"ssh-rsa\")\n // string encryption type\n // string comment\n // string public key data\n // string private-plaintext (including the final padding)\n const cipherName = m[2];\n const encrypted = (cipherName !== 'none');\n if (encrypted && !passphrase) {\n return new Error(\n 'Encrypted PPK private key detected, but no passphrase given'\n );\n }\n\n let privBlob = Buffer.from(m[5], 'base64');\n\n if (encrypted) {\n const encInfo = CIPHER_INFO[cipherName];\n let cipherKey = combineBuffers(\n createHash('sha1').update(PPK_PP1).update(passphrase).digest(),\n createHash('sha1').update(PPK_PP2).update(passphrase).digest()\n );\n if (cipherKey.length > encInfo.keyLen)\n cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);\n try {\n const decipher = createDecipheriv(encInfo.sslName,\n cipherKey,\n PPK_IV);\n decipher.setAutoPadding(false);\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n } catch (ex) {\n return ex;\n }\n }\n\n const type = m[1];\n const comment = m[3];\n const pubBlob = Buffer.from(m[4], 'base64');\n\n const mac = m[6];\n const typeLen = type.length;\n const cipherNameLen = cipherName.length;\n const commentLen = Buffer.byteLength(comment);\n const pubLen = pubBlob.length;\n const privLen = privBlob.length;\n const macData = Buffer.allocUnsafe(4 + typeLen\n + 4 + cipherNameLen\n + 4 + commentLen\n + 4 + pubLen\n + 4 + privLen);\n let p = 0;\n\n writeUInt32BE(macData, typeLen, p);\n macData.utf8Write(type, p += 4, typeLen);\n writeUInt32BE(macData, cipherNameLen, p += typeLen);\n macData.utf8Write(cipherName, p += 4, cipherNameLen);\n writeUInt32BE(macData, commentLen, p += cipherNameLen);\n macData.utf8Write(comment, p += 4, commentLen);\n writeUInt32BE(macData, pubLen, p += commentLen);\n macData.set(pubBlob, p += 4);\n writeUInt32BE(macData, privLen, p += pubLen);\n macData.set(privBlob, p + 4);\n\n if (!passphrase)\n passphrase = EMPTY_PASSPHRASE;\n\n const calcMAC = createHmac(\n 'sha1',\n createHash('sha1')\n .update('putty-private-key-file-mac-key')\n .update(passphrase)\n .digest()\n ).update(macData).digest('hex');\n\n if (calcMAC !== mac) {\n if (encrypted) {\n return new Error(\n 'PPK private key integrity check failed -- bad passphrase?'\n );\n }\n return new Error('PPK private key integrity check failed');\n }\n\n let pubPEM;\n let pubSSH;\n let privPEM;\n pubBlob._pos = 0;\n skipFields(pubBlob, 1); // skip (duplicate) key type\n switch (type) {\n case 'ssh-rsa': {\n const e = readString(pubBlob, pubBlob._pos);\n if (e === undefined)\n return new Error('Malformed PPK public key');\n const n = readString(pubBlob, pubBlob._pos);\n if (n === undefined)\n return new Error('Malformed PPK public key');\n const d = readString(privBlob, 0);\n if (d === undefined)\n return new Error('Malformed PPK private key');\n const p = readString(privBlob, privBlob._pos);\n if (p === undefined)\n return new Error('Malformed PPK private key');\n const q = readString(privBlob, privBlob._pos);\n if (q === undefined)\n return new Error('Malformed PPK private key');\n const iqmp = readString(privBlob, privBlob._pos);\n if (iqmp === undefined)\n return new Error('Malformed PPK private key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n privPEM = genOpenSSLRSAPriv(n, e, d, iqmp, p, q);\n break;\n }\n case 'ssh-dss': {\n const p = readString(pubBlob, pubBlob._pos);\n if (p === undefined)\n return new Error('Malformed PPK public key');\n const q = readString(pubBlob, pubBlob._pos);\n if (q === undefined)\n return new Error('Malformed PPK public key');\n const g = readString(pubBlob, pubBlob._pos);\n if (g === undefined)\n return new Error('Malformed PPK public key');\n const y = readString(pubBlob, pubBlob._pos);\n if (y === undefined)\n return new Error('Malformed PPK public key');\n const x = readString(privBlob, 0);\n if (x === undefined)\n return new Error('Malformed PPK private key');\n\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n privPEM = genOpenSSLDSAPriv(p, q, g, y, x);\n break;\n }\n }\n\n return new PPK_Private(type, comment, privPEM, pubPEM, pubSSH, 'sha1',\n encrypted);\n };\n}\n\n\nfunction OpenSSH_Public(type, comment, pubPEM, pubSSH, algo) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = null;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = false;\n}\nOpenSSH_Public.prototype = BaseKey;\n{\n let regexp;\n if (eddsaSupported)\n regexp = /^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\\s+([\\S].*)?)$/;\n else\n regexp = /^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\\s+([\\S].*)?)$/;\n OpenSSH_Public.parse = (str) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n // m[1] = full type\n // m[2] = base type\n // m[3] = base64-encoded public key\n // m[4] = comment\n\n const fullType = m[1];\n const baseType = m[2];\n const data = Buffer.from(m[3], 'base64');\n const comment = (m[4] || '');\n\n const type = readString(data, data._pos, true);\n if (type === undefined || type.indexOf(baseType) !== 0)\n return new Error('Malformed OpenSSH public key');\n\n return parseDER(data, baseType, comment, fullType);\n };\n}\n\n\nfunction RFC4716_Public(type, comment, pubPEM, pubSSH, algo) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = null;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = false;\n}\nRFC4716_Public.prototype = BaseKey;\n{\n const regexp = /^---- BEGIN SSH2 PUBLIC KEY ----(?:\\r?\\n)((?:.{0,72}\\r?\\n)+)---- END SSH2 PUBLIC KEY ----$/;\n const RE_DATA = /^[A-Z0-9a-z/+=\\r\\n]+$/;\n const RE_HEADER = /^([\\x21-\\x39\\x3B-\\x7E]{1,64}): ((?:[^\\\\]*\\\\\\r?\\n)*[^\\r\\n]+)\\r?\\n/gm;\n const RE_HEADER_ENDS = /\\\\\\r?\\n/g;\n RFC4716_Public.parse = (str) => {\n let m = regexp.exec(str);\n if (m === null)\n return null;\n\n const body = m[1];\n let dataStart = 0;\n let comment = '';\n\n while (m = RE_HEADER.exec(body)) {\n const headerName = m[1];\n const headerValue = m[2].replace(RE_HEADER_ENDS, '');\n if (headerValue.length > 1024) {\n RE_HEADER.lastIndex = 0;\n return new Error('Malformed RFC4716 public key');\n }\n\n dataStart = RE_HEADER.lastIndex;\n\n if (headerName.toLowerCase() === 'comment') {\n comment = headerValue;\n if (comment.length > 1\n && comment.charCodeAt(0) === 34/* '\"' */\n && comment.charCodeAt(comment.length - 1) === 34/* '\"' */) {\n comment = comment.slice(1, -1);\n }\n }\n }\n\n let data = body.slice(dataStart);\n if (!RE_DATA.test(data))\n return new Error('Malformed RFC4716 public key');\n\n data = Buffer.from(data, 'base64');\n\n const type = readString(data, 0, true);\n if (type === undefined)\n return new Error('Malformed RFC4716 public key');\n\n let pubPEM = null;\n let pubSSH = null;\n switch (type) {\n case 'ssh-rsa': {\n const e = readString(data, data._pos);\n if (e === undefined)\n return new Error('Malformed RFC4716 public key');\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed RFC4716 public key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n break;\n }\n case 'ssh-dss': {\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed RFC4716 public key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed RFC4716 public key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed RFC4716 public key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed RFC4716 public key');\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n break;\n }\n default:\n return new Error('Malformed RFC4716 public key');\n }\n\n return new RFC4716_Public(type, comment, pubPEM, pubSSH, 'sha1');\n };\n}\n\n\nfunction parseDER(data, baseType, comment, fullType) {\n if (!isSupportedKeyType(baseType))\n return new Error(`Unsupported OpenSSH public key type: ${baseType}`);\n\n let algo;\n let oid;\n let pubPEM = null;\n let pubSSH = null;\n\n switch (baseType) {\n case 'ssh-rsa': {\n const e = readString(data, data._pos || 0);\n if (e === undefined)\n return new Error('Malformed OpenSSH public key');\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n algo = 'sha1';\n break;\n }\n case 'ssh-dss': {\n const p = readString(data, data._pos || 0);\n if (p === undefined)\n return new Error('Malformed OpenSSH public key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH public key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed OpenSSH public key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n algo = 'sha1';\n break;\n }\n case 'ssh-ed25519': {\n const edpub = readString(data, data._pos || 0);\n if (edpub === undefined || edpub.length !== 32)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLEdPub(edpub);\n pubSSH = genOpenSSHEdPub(edpub);\n algo = null;\n break;\n }\n case 'ecdsa-sha2-nistp256':\n algo = 'sha256';\n oid = '1.2.840.10045.3.1.7';\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp384':\n if (algo === undefined) {\n algo = 'sha384';\n oid = '1.3.132.0.34';\n }\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp521': {\n if (algo === undefined) {\n algo = 'sha512';\n oid = '1.3.132.0.35';\n }\n // TODO: validate curve name against type\n if (!skipFields(data, 1)) // Skip curve name\n return new Error('Malformed OpenSSH public key');\n const ecpub = readString(data, data._pos || 0);\n if (ecpub === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLECDSAPub(oid, ecpub);\n pubSSH = genOpenSSHECDSAPub(oid, ecpub);\n break;\n }\n default:\n return new Error(`Unsupported OpenSSH public key type: ${baseType}`);\n }\n\n return new OpenSSH_Public(fullType, comment, pubPEM, pubSSH, algo);\n}\n\nfunction isSupportedKeyType(type) {\n switch (type) {\n case 'ssh-rsa':\n case 'ssh-dss':\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521':\n return true;\n case 'ssh-ed25519':\n if (eddsaSupported)\n return true;\n // FALLTHROUGH\n default:\n return false;\n }\n}\n\nfunction isParsedKey(val) {\n if (!val)\n return false;\n return (typeof val[SYM_DECRYPTED] === 'boolean');\n}\n\nfunction parseKey(data, passphrase) {\n if (isParsedKey(data))\n return data;\n\n let origBuffer;\n if (Buffer.isBuffer(data)) {\n origBuffer = data;\n data = data.utf8Slice(0, data.length).trim();\n } else if (typeof data === 'string') {\n data = data.trim();\n } else {\n return new Error('Key data must be a Buffer or string');\n }\n\n // eslint-disable-next-line eqeqeq\n if (passphrase != undefined) {\n if (typeof passphrase === 'string')\n passphrase = Buffer.from(passphrase);\n else if (!Buffer.isBuffer(passphrase))\n return new Error('Passphrase must be a string or Buffer when supplied');\n }\n\n let ret;\n\n // First try as printable string format (e.g. PEM)\n\n // Private keys\n if ((ret = OpenSSH_Private.parse(data, passphrase)) !== null)\n return ret;\n if ((ret = OpenSSH_Old_Private.parse(data, passphrase)) !== null)\n return ret;\n if ((ret = PPK_Private.parse(data, passphrase)) !== null)\n return ret;\n\n // Public keys\n if ((ret = OpenSSH_Public.parse(data)) !== null)\n return ret;\n if ((ret = RFC4716_Public.parse(data)) !== null)\n return ret;\n\n // Finally try as a binary format if we were originally passed binary data\n if (origBuffer) {\n binaryKeyParser.init(origBuffer, 0);\n const type = binaryKeyParser.readString(true);\n if (type !== undefined) {\n data = binaryKeyParser.readRaw();\n if (data !== undefined) {\n ret = parseDER(data, type, '', type);\n // Ignore potentially useless errors in case the data was not actually\n // in the binary format\n if (ret instanceof Error)\n ret = null;\n }\n }\n binaryKeyParser.clear();\n }\n\n if (ret)\n return ret;\n\n return new Error('Unsupported key format');\n}\n\nmodule.exports = {\n isParsedKey,\n isSupportedKeyType,\n parseDERKey: (data, type) => parseDER(data, type, '', type),\n parseKey,\n};\n","'use strict';\n\nconst assert = require('assert');\nconst { inspect } = require('util');\n\n// Only use this for integers! Decimal numbers do not work with this function.\nfunction addNumericalSeparator(val) {\n let res = '';\n let i = val.length;\n const start = val[0] === '-' ? 1 : 0;\n for (; i >= start + 4; i -= 3)\n res = `_${val.slice(i - 3, i)}${res}`;\n return `${val.slice(0, i)}${res}`;\n}\n\nfunction oneOf(expected, thing) {\n assert(typeof thing === 'string', '`thing` has to be of type string');\n if (Array.isArray(expected)) {\n const len = expected.length;\n assert(len > 0, 'At least one expected value needs to be specified');\n expected = expected.map((i) => String(i));\n if (len > 2) {\n return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or `\n + expected[len - 1];\n } else if (len === 2) {\n return `one of ${thing} ${expected[0]} or ${expected[1]}`;\n }\n return `of ${thing} ${expected[0]}`;\n }\n return `of ${thing} ${String(expected)}`;\n}\n\n\nexports.ERR_INTERNAL_ASSERTION = class ERR_INTERNAL_ASSERTION extends Error {\n constructor(message) {\n super();\n Error.captureStackTrace(this, ERR_INTERNAL_ASSERTION);\n\n const suffix = 'This is caused by either a bug in ssh2 '\n + 'or incorrect usage of ssh2 internals.\\n'\n + 'Please open an issue with this stack trace at '\n + 'https://github.com/mscdex/ssh2/issues\\n';\n\n this.message = (message === undefined ? suffix : `${message}\\n${suffix}`);\n }\n};\n\nconst MAX_32BIT_INT = 2 ** 32;\nconst MAX_32BIT_BIGINT = (() => {\n try {\n return new Function('return 2n ** 32n')();\n } catch {}\n})();\nexports.ERR_OUT_OF_RANGE = class ERR_OUT_OF_RANGE extends RangeError {\n constructor(str, range, input, replaceDefaultBoolean) {\n super();\n Error.captureStackTrace(this, ERR_OUT_OF_RANGE);\n\n assert(range, 'Missing \"range\" argument');\n let msg = (replaceDefaultBoolean\n ? str\n : `The value of \"${str}\" is out of range.`);\n let received;\n if (Number.isInteger(input) && Math.abs(input) > MAX_32BIT_INT) {\n received = addNumericalSeparator(String(input));\n } else if (typeof input === 'bigint') {\n received = String(input);\n if (input > MAX_32BIT_BIGINT || input < -MAX_32BIT_BIGINT)\n received = addNumericalSeparator(received);\n received += 'n';\n } else {\n received = inspect(input);\n }\n msg += ` It must be ${range}. Received ${received}`;\n\n this.message = msg;\n }\n};\n\nclass ERR_INVALID_ARG_TYPE extends TypeError {\n constructor(name, expected, actual) {\n super();\n Error.captureStackTrace(this, ERR_INVALID_ARG_TYPE);\n\n assert(typeof name === 'string', `'name' must be a string`);\n\n // determiner: 'must be' or 'must not be'\n let determiner;\n if (typeof expected === 'string' && expected.startsWith('not ')) {\n determiner = 'must not be';\n expected = expected.replace(/^not /, '');\n } else {\n determiner = 'must be';\n }\n\n let msg;\n if (name.endsWith(' argument')) {\n // For cases like 'first argument'\n msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;\n } else {\n const type = (name.includes('.') ? 'property' : 'argument');\n msg = `The \"${name}\" ${type} ${determiner} ${oneOf(expected, 'type')}`;\n }\n\n msg += `. Received type ${typeof actual}`;\n\n this.message = msg;\n }\n}\nexports.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;\n\nexports.validateNumber = function validateNumber(value, name) {\n if (typeof value !== 'number')\n throw new ERR_INVALID_ARG_TYPE(name, 'number', value);\n};\n","'use strict';\n\nconst Ber = require('asn1').Ber;\n\nlet DISCONNECT_REASON;\n\nconst FastBuffer = Buffer[Symbol.species];\nconst TypedArrayFill = Object.getPrototypeOf(Uint8Array.prototype).fill;\n\nfunction readUInt32BE(buf, offset) {\n return (buf[offset++] * 16777216)\n + (buf[offset++] * 65536)\n + (buf[offset++] * 256)\n + buf[offset];\n}\n\nfunction bufferCopy(src, dest, srcStart, srcEnd, destStart) {\n if (!destStart)\n destStart = 0;\n if (srcEnd > src.length)\n srcEnd = src.length;\n let nb = srcEnd - srcStart;\n const destLeft = (dest.length - destStart);\n if (nb > destLeft)\n nb = destLeft;\n dest.set(new Uint8Array(src.buffer, src.byteOffset + srcStart, nb),\n destStart);\n return nb;\n}\n\nfunction bufferSlice(buf, start, end) {\n if (end === undefined)\n end = buf.length;\n return new FastBuffer(buf.buffer, buf.byteOffset + start, end - start);\n}\n\nfunction makeBufferParser() {\n let pos = 0;\n let buffer;\n\n const self = {\n init: (buf, start) => {\n buffer = buf;\n pos = (typeof start === 'number' ? start : 0);\n },\n pos: () => pos,\n length: () => (buffer ? buffer.length : 0),\n avail: () => (buffer && pos < buffer.length ? buffer.length - pos : 0),\n clear: () => {\n buffer = undefined;\n },\n readUInt32BE: () => {\n if (!buffer || pos + 3 >= buffer.length)\n return;\n return (buffer[pos++] * 16777216)\n + (buffer[pos++] * 65536)\n + (buffer[pos++] * 256)\n + buffer[pos++];\n },\n readUInt64BE: (behavior) => {\n if (!buffer || pos + 7 >= buffer.length)\n return;\n switch (behavior) {\n case 'always':\n return BigInt(`0x${buffer.hexSlice(pos, pos += 8)}`);\n case 'maybe':\n if (buffer[pos] > 0x1F)\n return BigInt(`0x${buffer.hexSlice(pos, pos += 8)}`);\n // FALLTHROUGH\n default:\n return (buffer[pos++] * 72057594037927940)\n + (buffer[pos++] * 281474976710656)\n + (buffer[pos++] * 1099511627776)\n + (buffer[pos++] * 4294967296)\n + (buffer[pos++] * 16777216)\n + (buffer[pos++] * 65536)\n + (buffer[pos++] * 256)\n + buffer[pos++];\n }\n },\n skip: (n) => {\n if (buffer && n > 0)\n pos += n;\n },\n skipString: () => {\n const len = self.readUInt32BE();\n if (len === undefined)\n return;\n pos += len;\n return (pos <= buffer.length ? len : undefined);\n },\n readByte: () => {\n if (buffer && pos < buffer.length)\n return buffer[pos++];\n },\n readBool: () => {\n if (buffer && pos < buffer.length)\n return !!buffer[pos++];\n },\n readList: () => {\n const list = self.readString(true);\n if (list === undefined)\n return;\n return (list ? list.split(',') : []);\n },\n readString: (dest, maxLen) => {\n if (typeof dest === 'number') {\n maxLen = dest;\n dest = undefined;\n }\n\n const len = self.readUInt32BE();\n if (len === undefined)\n return;\n\n if ((buffer.length - pos) < len\n || (typeof maxLen === 'number' && len > maxLen)) {\n return;\n }\n\n if (dest) {\n if (Buffer.isBuffer(dest))\n return bufferCopy(buffer, dest, pos, pos += len);\n return buffer.utf8Slice(pos, pos += len);\n }\n return bufferSlice(buffer, pos, pos += len);\n },\n readRaw: (len) => {\n if (!buffer)\n return;\n if (typeof len !== 'number')\n return bufferSlice(buffer, pos, pos += (buffer.length - pos));\n if ((buffer.length - pos) >= len)\n return bufferSlice(buffer, pos, pos += len);\n },\n };\n\n return self;\n}\n\nfunction makeError(msg, level, fatal) {\n const err = new Error(msg);\n if (typeof level === 'boolean') {\n fatal = level;\n err.level = 'protocol';\n } else {\n err.level = level || 'protocol';\n }\n err.fatal = !!fatal;\n return err;\n}\n\nfunction writeUInt32BE(buf, value, offset) {\n buf[offset++] = (value >>> 24);\n buf[offset++] = (value >>> 16);\n buf[offset++] = (value >>> 8);\n buf[offset++] = value;\n return offset;\n}\n\nconst utilBufferParser = makeBufferParser();\n\nmodule.exports = {\n bufferCopy,\n bufferSlice,\n FastBuffer,\n bufferFill: (buf, value, start, end) => {\n return TypedArrayFill.call(buf, value, start, end);\n },\n makeError,\n doFatalError: (protocol, msg, level, reason) => {\n let err;\n if (DISCONNECT_REASON === undefined)\n ({ DISCONNECT_REASON } = require('./utils.js'));\n if (msg instanceof Error) {\n // doFatalError(protocol, err[, reason])\n err = msg;\n if (typeof level !== 'number')\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n else\n reason = level;\n } else {\n // doFatalError(protocol, msg[, level[, reason]])\n err = makeError(msg, level, true);\n }\n if (typeof reason !== 'number')\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n protocol.disconnect(reason);\n protocol._destruct();\n protocol._onError(err);\n return Infinity;\n },\n readUInt32BE,\n writeUInt32BE,\n writeUInt32LE: (buf, value, offset) => {\n buf[offset++] = value;\n buf[offset++] = (value >>> 8);\n buf[offset++] = (value >>> 16);\n buf[offset++] = (value >>> 24);\n return offset;\n },\n makeBufferParser,\n bufferParser: makeBufferParser(),\n readString: (buffer, start, dest, maxLen) => {\n if (typeof dest === 'number') {\n maxLen = dest;\n dest = undefined;\n }\n\n if (start === undefined)\n start = 0;\n\n const left = (buffer.length - start);\n if (start < 0 || start >= buffer.length || left < 4)\n return;\n\n const len = readUInt32BE(buffer, start);\n if (left < (4 + len) || (typeof maxLen === 'number' && len > maxLen))\n return;\n\n start += 4;\n const end = start + len;\n buffer._pos = end;\n\n if (dest) {\n if (Buffer.isBuffer(dest))\n return bufferCopy(buffer, dest, start, end);\n return buffer.utf8Slice(start, end);\n }\n return bufferSlice(buffer, start, end);\n },\n sigSSHToASN1: (sig, type) => {\n switch (type) {\n case 'ssh-dss': {\n if (sig.length > 40)\n return sig;\n // Change bare signature r and s values to ASN.1 BER values for OpenSSL\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n let r = sig.slice(0, 20);\n let s = sig.slice(20);\n if (r[0] & 0x80) {\n const rNew = Buffer.allocUnsafe(21);\n rNew[0] = 0x00;\n r.copy(rNew, 1);\n r = rNew;\n } else if (r[0] === 0x00 && !(r[1] & 0x80)) {\n r = r.slice(1);\n }\n if (s[0] & 0x80) {\n const sNew = Buffer.allocUnsafe(21);\n sNew[0] = 0x00;\n s.copy(sNew, 1);\n s = sNew;\n } else if (s[0] === 0x00 && !(s[1] & 0x80)) {\n s = s.slice(1);\n }\n asnWriter.writeBuffer(r, Ber.Integer);\n asnWriter.writeBuffer(s, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521': {\n utilBufferParser.init(sig, 0);\n const r = utilBufferParser.readString();\n const s = utilBufferParser.readString();\n utilBufferParser.clear();\n if (r === undefined || s === undefined)\n return;\n\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeBuffer(r, Ber.Integer);\n asnWriter.writeBuffer(s, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n default:\n return sig;\n }\n },\n convertSignature: (signature, keyType) => {\n switch (keyType) {\n case 'ssh-dss': {\n if (signature.length <= 40)\n return signature;\n // This is a quick and dirty way to get from BER encoded r and s that\n // OpenSSL gives us, to just the bare values back to back (40 bytes\n // total) like OpenSSH (and possibly others) are expecting\n const asnReader = new Ber.Reader(signature);\n asnReader.readSequence();\n let r = asnReader.readString(Ber.Integer, true);\n let s = asnReader.readString(Ber.Integer, true);\n let rOffset = 0;\n let sOffset = 0;\n if (r.length < 20) {\n const rNew = Buffer.allocUnsafe(20);\n rNew.set(r, 1);\n r = rNew;\n r[0] = 0;\n }\n if (s.length < 20) {\n const sNew = Buffer.allocUnsafe(20);\n sNew.set(s, 1);\n s = sNew;\n s[0] = 0;\n }\n if (r.length > 20 && r[0] === 0)\n rOffset = 1;\n if (s.length > 20 && s[0] === 0)\n sOffset = 1;\n const newSig =\n Buffer.allocUnsafe((r.length - rOffset) + (s.length - sOffset));\n bufferCopy(r, newSig, rOffset, r.length, 0);\n bufferCopy(s, newSig, sOffset, s.length, r.length - rOffset);\n return newSig;\n }\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521': {\n if (signature[0] === 0)\n return signature;\n // Convert SSH signature parameters to ASN.1 BER values for OpenSSL\n const asnReader = new Ber.Reader(signature);\n asnReader.readSequence();\n const r = asnReader.readString(Ber.Integer, true);\n const s = asnReader.readString(Ber.Integer, true);\n if (r === null || s === null)\n return;\n const newSig = Buffer.allocUnsafe(4 + r.length + 4 + s.length);\n writeUInt32BE(newSig, r.length, 0);\n newSig.set(r, 4);\n writeUInt32BE(newSig, s.length, 4 + r.length);\n newSig.set(s, 4 + 4 + r.length);\n return newSig;\n }\n }\n\n return signature;\n },\n sendPacket: (proto, packet, bypass) => {\n if (!bypass && proto._kexinit !== undefined) {\n // We're currently in the middle of a handshake\n\n if (proto._queue === undefined)\n proto._queue = [];\n proto._queue.push(packet);\n proto._debug && proto._debug('Outbound: ... packet queued');\n return false;\n }\n proto._cipher.encrypt(packet);\n return true;\n },\n};\n","'use strict';\n\nconst { kMaxLength } = require('buffer');\nconst {\n createInflate,\n constants: {\n DEFLATE,\n INFLATE,\n Z_DEFAULT_CHUNK,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_MEMLEVEL,\n Z_DEFAULT_STRATEGY,\n Z_DEFAULT_WINDOWBITS,\n Z_PARTIAL_FLUSH,\n }\n} = require('zlib');\nconst ZlibHandle = createInflate()._handle.constructor;\n\nfunction processCallback() {\n throw new Error('Should not get here');\n}\n\nfunction zlibOnError(message, errno, code) {\n const self = this._owner;\n // There is no way to cleanly recover.\n // Continuing only obscures problems.\n\n const error = new Error(message);\n error.errno = errno;\n error.code = code;\n self._err = error;\n}\n\nfunction _close(engine) {\n // Caller may invoke .close after a zlib error (which will null _handle).\n if (!engine._handle)\n return;\n\n engine._handle.close();\n engine._handle = null;\n}\n\nclass Zlib {\n constructor(mode) {\n const windowBits = Z_DEFAULT_WINDOWBITS;\n const level = Z_DEFAULT_COMPRESSION;\n const memLevel = Z_DEFAULT_MEMLEVEL;\n const strategy = Z_DEFAULT_STRATEGY;\n const dictionary = undefined;\n\n this._err = undefined;\n this._writeState = new Uint32Array(2);\n this._chunkSize = Z_DEFAULT_CHUNK;\n this._maxOutputLength = kMaxLength;\n this._outBuffer = Buffer.allocUnsafe(this._chunkSize);\n this._outOffset = 0;\n\n this._handle = new ZlibHandle(mode);\n this._handle._owner = this;\n this._handle.onerror = zlibOnError;\n this._handle.init(windowBits,\n level,\n memLevel,\n strategy,\n this._writeState,\n processCallback,\n dictionary);\n }\n\n writeSync(chunk, retChunks) {\n const handle = this._handle;\n if (!handle)\n throw new Error('Invalid Zlib instance');\n\n let availInBefore = chunk.length;\n let availOutBefore = this._chunkSize - this._outOffset;\n let inOff = 0;\n let availOutAfter;\n let availInAfter;\n\n let buffers;\n let nread = 0;\n const state = this._writeState;\n let buffer = this._outBuffer;\n let offset = this._outOffset;\n const chunkSize = this._chunkSize;\n\n while (true) {\n handle.writeSync(Z_PARTIAL_FLUSH,\n chunk, // in\n inOff, // in_off\n availInBefore, // in_len\n buffer, // out\n offset, // out_off\n availOutBefore); // out_len\n if (this._err)\n throw this._err;\n\n availOutAfter = state[0];\n availInAfter = state[1];\n\n const inDelta = availInBefore - availInAfter;\n const have = availOutBefore - availOutAfter;\n\n if (have > 0) {\n const out = (offset === 0 && have === buffer.length\n ? buffer\n : buffer.slice(offset, offset + have));\n offset += have;\n if (!buffers)\n buffers = out;\n else if (buffers.push === undefined)\n buffers = [buffers, out];\n else\n buffers.push(out);\n nread += out.byteLength;\n\n if (nread > this._maxOutputLength) {\n _close(this);\n throw new Error(\n `Output length exceeded maximum of ${this._maxOutputLength}`\n );\n }\n } else if (have !== 0) {\n throw new Error('have should not go down');\n }\n\n // Exhausted the output buffer, or used all the input create a new one.\n if (availOutAfter === 0 || offset >= chunkSize) {\n availOutBefore = chunkSize;\n offset = 0;\n buffer = Buffer.allocUnsafe(chunkSize);\n }\n\n if (availOutAfter === 0) {\n // Not actually done. Need to reprocess.\n // Also, update the availInBefore to the availInAfter value,\n // so that if we have to hit it a third (fourth, etc.) time,\n // it'll have the correct byte counts.\n inOff += inDelta;\n availInBefore = availInAfter;\n } else {\n break;\n }\n }\n\n this._outBuffer = buffer;\n this._outOffset = offset;\n\n if (nread === 0)\n buffers = Buffer.alloc(0);\n\n if (retChunks) {\n buffers.totalLen = nread;\n return buffers;\n }\n\n if (buffers.push === undefined)\n return buffers;\n\n const output = Buffer.allocUnsafe(nread);\n for (let i = 0, p = 0; i < buffers.length; ++i) {\n const buf = buffers[i];\n output.set(buf, p);\n p += buf.length;\n }\n return output;\n }\n}\n\nclass ZlibPacketWriter {\n constructor(protocol) {\n this.allocStart = 0;\n this.allocStartKEX = 0;\n this._protocol = protocol;\n this._zlib = new Zlib(DEFLATE);\n }\n\n cleanup() {\n if (this._zlib)\n _close(this._zlib);\n }\n\n alloc(payloadSize, force) {\n return Buffer.allocUnsafe(payloadSize);\n }\n\n finalize(payload, force) {\n if (this._protocol._kexinit === undefined || force) {\n const output = this._zlib.writeSync(payload, true);\n const packet = this._protocol._cipher.allocPacket(output.totalLen);\n if (output.push === undefined) {\n packet.set(output, 5);\n } else {\n for (let i = 0, p = 5; i < output.length; ++i) {\n const chunk = output[i];\n packet.set(chunk, p);\n p += chunk.length;\n }\n }\n return packet;\n }\n return payload;\n }\n}\n\nclass PacketWriter {\n constructor(protocol) {\n this.allocStart = 5;\n this.allocStartKEX = 5;\n this._protocol = protocol;\n }\n\n cleanup() {}\n\n alloc(payloadSize, force) {\n if (this._protocol._kexinit === undefined || force)\n return this._protocol._cipher.allocPacket(payloadSize);\n return Buffer.allocUnsafe(payloadSize);\n }\n\n finalize(packet, force) {\n return packet;\n }\n}\n\nclass ZlibPacketReader {\n constructor() {\n this._zlib = new Zlib(INFLATE);\n }\n\n cleanup() {\n if (this._zlib)\n _close(this._zlib);\n }\n\n read(data) {\n return this._zlib.writeSync(data, false);\n }\n}\n\nclass PacketReader {\n cleanup() {}\n\n read(data) {\n return data;\n }\n}\n\nmodule.exports = {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n};\n","// TODO:\n// * convert listenerCount() usage to emit() return value checking?\n// * emit error when connection severed early (e.g. before handshake)\n// * add '.connected' or similar property to connection objects to allow\n// immediate connection status checking\n'use strict';\n\nconst { Server: netServer } = require('net');\nconst EventEmitter = require('events');\nconst { listenerCount } = EventEmitter;\n\nconst {\n CHANNEL_OPEN_FAILURE,\n DEFAULT_CIPHER,\n DEFAULT_COMPRESSION,\n DEFAULT_KEX,\n DEFAULT_MAC,\n DEFAULT_SERVER_HOST_KEY,\n DISCONNECT_REASON,\n DISCONNECT_REASON_BY_VALUE,\n SUPPORTED_CIPHER,\n SUPPORTED_COMPRESSION,\n SUPPORTED_KEX,\n SUPPORTED_MAC,\n SUPPORTED_SERVER_HOST_KEY,\n} = require('./protocol/constants.js');\nconst { init: cryptoInit } = require('./protocol/crypto.js');\nconst { KexInit } = require('./protocol/kex.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst Protocol = require('./protocol/Protocol.js');\nconst { SFTP } = require('./protocol/SFTP.js');\nconst { writeUInt32BE } = require('./protocol/utils.js');\n\nconst {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n} = require('./Channel.js');\n\nconst {\n ChannelManager,\n generateAlgorithmList,\n isWritable,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n} = require('./utils.js');\n\nconst MAX_PENDING_AUTHS = 10;\n\nclass AuthContext extends EventEmitter {\n constructor(protocol, username, service, method, cb) {\n super();\n\n this.username = this.user = username;\n this.service = service;\n this.method = method;\n this._initialResponse = false;\n this._finalResponse = false;\n this._multistep = false;\n this._cbfinal = (allowed, methodsLeft, isPartial) => {\n if (!this._finalResponse) {\n this._finalResponse = true;\n cb(this, allowed, methodsLeft, isPartial);\n }\n };\n this._protocol = protocol;\n }\n\n accept() {\n this._cleanup && this._cleanup();\n this._initialResponse = true;\n this._cbfinal(true);\n }\n reject(methodsLeft, isPartial) {\n this._cleanup && this._cleanup();\n this._initialResponse = true;\n this._cbfinal(false, methodsLeft, isPartial);\n }\n}\n\n\nclass KeyboardAuthContext extends AuthContext {\n constructor(protocol, username, service, method, submethods, cb) {\n super(protocol, username, service, method, cb);\n\n this._multistep = true;\n\n this._cb = undefined;\n this._onInfoResponse = (responses) => {\n const callback = this._cb;\n if (callback) {\n this._cb = undefined;\n callback(responses);\n }\n };\n this.submethods = submethods;\n this.on('abort', () => {\n this._cb && this._cb(new Error('Authentication request aborted'));\n });\n }\n\n prompt(prompts, title, instructions, cb) {\n if (!Array.isArray(prompts))\n prompts = [ prompts ];\n\n if (typeof title === 'function') {\n cb = title;\n title = instructions = undefined;\n } else if (typeof instructions === 'function') {\n cb = instructions;\n instructions = undefined;\n } else if (typeof cb !== 'function') {\n cb = undefined;\n }\n\n for (let i = 0; i < prompts.length; ++i) {\n if (typeof prompts[i] === 'string') {\n prompts[i] = {\n prompt: prompts[i],\n echo: true\n };\n }\n }\n\n this._cb = cb;\n this._initialResponse = true;\n\n this._protocol.authInfoReq(title, instructions, prompts);\n }\n}\n\nclass PKAuthContext extends AuthContext {\n constructor(protocol, username, service, method, pkInfo, cb) {\n super(protocol, username, service, method, cb);\n\n this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };\n this.signature = pkInfo.signature;\n this.blob = pkInfo.blob;\n }\n\n accept() {\n if (!this.signature) {\n this._initialResponse = true;\n this._protocol.authPKOK(this.key.algo, this.key.data);\n } else {\n AuthContext.prototype.accept.call(this);\n }\n }\n}\n\nclass HostbasedAuthContext extends AuthContext {\n constructor(protocol, username, service, method, pkInfo, cb) {\n super(protocol, username, service, method, cb);\n\n this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };\n this.signature = pkInfo.signature;\n this.blob = pkInfo.blob;\n this.localHostname = pkInfo.localHostname;\n this.localUsername = pkInfo.localUsername;\n }\n}\n\nclass PwdAuthContext extends AuthContext {\n constructor(protocol, username, service, method, password, cb) {\n super(protocol, username, service, method, cb);\n\n this.password = password;\n this._changeCb = undefined;\n }\n\n requestChange(prompt, cb) {\n if (this._changeCb)\n throw new Error('Change request already in progress');\n if (typeof prompt !== 'string')\n throw new Error('prompt argument must be a string');\n if (typeof cb !== 'function')\n throw new Error('Callback argument must be a function');\n this._changeCb = cb;\n this._protocol.authPasswdChg(prompt);\n }\n}\n\n\nclass Session extends EventEmitter {\n constructor(client, info, localChan) {\n super();\n\n this.type = 'session';\n this.subtype = undefined;\n this.server = true;\n this._ending = false;\n this._channel = undefined;\n this._chanInfo = {\n type: 'session',\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n }\n}\n\n\nclass Server extends EventEmitter {\n constructor(cfg, listener) {\n super();\n\n if (typeof cfg !== 'object' || cfg === null)\n throw new Error('Missing configuration object');\n\n const hostKeys = Object.create(null);\n const hostKeyAlgoOrder = [];\n\n const hostKeys_ = cfg.hostKeys;\n if (!Array.isArray(hostKeys_))\n throw new Error('hostKeys must be an array');\n\n const cfgAlgos = (\n typeof cfg.algorithms === 'object' && cfg.algorithms !== null\n ? cfg.algorithms\n : {}\n );\n\n const hostKeyAlgos = generateAlgorithmList(\n cfgAlgos.serverHostKey,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY\n );\n for (let i = 0; i < hostKeys_.length; ++i) {\n let privateKey;\n if (Buffer.isBuffer(hostKeys_[i]) || typeof hostKeys_[i] === 'string')\n privateKey = parseKey(hostKeys_[i]);\n else\n privateKey = parseKey(hostKeys_[i].key, hostKeys_[i].passphrase);\n\n if (privateKey instanceof Error)\n throw new Error(`Cannot parse privateKey: ${privateKey.message}`);\n\n if (Array.isArray(privateKey)) {\n // OpenSSH's newer format only stores 1 key for now\n privateKey = privateKey[0];\n }\n\n if (privateKey.getPrivatePEM() === null)\n throw new Error('privateKey value contains an invalid private key');\n\n // Discard key if we already found a key of the same type\n if (hostKeyAlgoOrder.includes(privateKey.type))\n continue;\n\n if (privateKey.type === 'ssh-rsa') {\n // SSH supports multiple signature hashing algorithms for RSA, so we add\n // the algorithms in the desired order\n let sha1Pos = hostKeyAlgos.indexOf('ssh-rsa');\n const sha256Pos = hostKeyAlgos.indexOf('rsa-sha2-256');\n const sha512Pos = hostKeyAlgos.indexOf('rsa-sha2-512');\n if (sha1Pos === -1) {\n // Fall back to giving SHA1 the lowest priority\n sha1Pos = Infinity;\n }\n [sha1Pos, sha256Pos, sha512Pos].sort(compareNumbers).forEach((pos) => {\n if (pos === -1)\n return;\n\n let type;\n switch (pos) {\n case sha1Pos: type = 'ssh-rsa'; break;\n case sha256Pos: type = 'rsa-sha2-256'; break;\n case sha512Pos: type = 'rsa-sha2-512'; break;\n default: return;\n }\n\n // Store same RSA key under each hash algorithm name for convenience\n hostKeys[type] = privateKey;\n\n hostKeyAlgoOrder.push(type);\n });\n } else {\n hostKeys[privateKey.type] = privateKey;\n hostKeyAlgoOrder.push(privateKey.type);\n }\n }\n\n const algorithms = {\n kex: generateAlgorithmList(cfgAlgos.kex, DEFAULT_KEX, SUPPORTED_KEX),\n serverHostKey: hostKeyAlgoOrder,\n cs: {\n cipher: generateAlgorithmList(\n cfgAlgos.cipher,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER\n ),\n mac: generateAlgorithmList(cfgAlgos.hmac, DEFAULT_MAC, SUPPORTED_MAC),\n compress: generateAlgorithmList(\n cfgAlgos.compress,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION\n ),\n lang: [],\n },\n sc: undefined,\n };\n algorithms.sc = algorithms.cs;\n\n if (typeof listener === 'function')\n this.on('connection', listener);\n\n const origDebug = (typeof cfg.debug === 'function' ? cfg.debug : undefined);\n const ident = (cfg.ident ? Buffer.from(cfg.ident) : undefined);\n const offer = new KexInit(algorithms);\n\n this._srv = new netServer((socket) => {\n if (this._connections >= this.maxConnections) {\n socket.destroy();\n return;\n }\n ++this._connections;\n socket.once('close', () => {\n --this._connections;\n });\n\n let debug;\n if (origDebug) {\n // Prepend debug output with a unique identifier in case there are\n // multiple clients connected at the same time\n const debugPrefix = `[${process.hrtime().join('.')}] `;\n debug = (msg) => {\n origDebug(`${debugPrefix}${msg}`);\n };\n }\n\n // eslint-disable-next-line no-use-before-define\n new Client(socket, hostKeys, ident, offer, debug, this, cfg);\n }).on('error', (err) => {\n this.emit('error', err);\n }).on('listening', () => {\n this.emit('listening');\n }).on('close', () => {\n this.emit('close');\n });\n this._connections = 0;\n this.maxConnections = Infinity;\n }\n\n injectSocket(socket) {\n this._srv.emit('connection', socket);\n }\n\n listen(...args) {\n this._srv.listen(...args);\n return this;\n }\n\n address() {\n return this._srv.address();\n }\n\n getConnections(cb) {\n this._srv.getConnections(cb);\n return this;\n }\n\n close(cb) {\n this._srv.close(cb);\n return this;\n }\n\n ref() {\n this._srv.ref();\n return this;\n }\n\n unref() {\n this._srv.unref();\n return this;\n }\n}\nServer.KEEPALIVE_CLIENT_INTERVAL = 15000;\nServer.KEEPALIVE_CLIENT_COUNT_MAX = 3;\n\n\nclass Client extends EventEmitter {\n constructor(socket, hostKeys, ident, offer, debug, server, srvCfg) {\n super();\n\n let exchanges = 0;\n let acceptedAuthSvc = false;\n let pendingAuths = [];\n let authCtx;\n let kaTimer;\n let onPacket;\n const unsentGlobalRequestsReplies = [];\n this._sock = socket;\n this._chanMgr = new ChannelManager(this);\n this._debug = debug;\n this.noMoreSessions = false;\n this.authenticated = false;\n\n // Silence pre-header errors\n function onClientPreHeaderError(err) {}\n this.on('error', onClientPreHeaderError);\n\n const DEBUG_HANDLER = (!debug ? undefined : (p, display, msg) => {\n debug(`Debug output from client: ${JSON.stringify(msg)}`);\n });\n\n const kaIntvl = (\n typeof srvCfg.keepaliveInterval === 'number'\n && isFinite(srvCfg.keepaliveInterval)\n && srvCfg.keepaliveInterval > 0\n ? srvCfg.keepaliveInterval\n : (\n typeof Server.KEEPALIVE_CLIENT_INTERVAL === 'number'\n && isFinite(Server.KEEPALIVE_CLIENT_INTERVAL)\n && Server.KEEPALIVE_CLIENT_INTERVAL > 0\n ? Server.KEEPALIVE_CLIENT_INTERVAL\n : -1\n )\n );\n const kaCountMax = (\n typeof srvCfg.keepaliveCountMax === 'number'\n && isFinite(srvCfg.keepaliveCountMax)\n && srvCfg.keepaliveCountMax >= 0\n ? srvCfg.keepaliveCountMax\n : (\n typeof Server.KEEPALIVE_CLIENT_COUNT_MAX === 'number'\n && isFinite(Server.KEEPALIVE_CLIENT_COUNT_MAX)\n && Server.KEEPALIVE_CLIENT_COUNT_MAX >= 0\n ? Server.KEEPALIVE_CLIENT_COUNT_MAX\n : -1\n )\n );\n let kaCurCount = 0;\n if (kaIntvl !== -1 && kaCountMax !== -1) {\n this.once('ready', () => {\n const onClose = () => {\n clearInterval(kaTimer);\n };\n this.on('close', onClose).on('end', onClose);\n kaTimer = setInterval(() => {\n if (++kaCurCount > kaCountMax) {\n clearInterval(kaTimer);\n const err = new Error('Keepalive timeout');\n err.level = 'client-timeout';\n this.emit('error', err);\n this.end();\n } else {\n // XXX: if the server ever starts sending real global requests to\n // the client, we will need to add a dummy callback here to\n // keep the correct reply order\n proto.ping();\n }\n }, kaIntvl);\n });\n // TODO: re-verify keepalive behavior with OpenSSH\n onPacket = () => {\n kaTimer && kaTimer.refresh();\n kaCurCount = 0;\n };\n }\n\n const proto = this._protocol = new Protocol({\n server: true,\n hostKeys,\n ident,\n offer,\n onPacket,\n greeting: srvCfg.greeting,\n banner: srvCfg.banner,\n onWrite: (data) => {\n if (isWritable(socket))\n socket.write(data);\n },\n onError: (err) => {\n if (!proto._destruct)\n socket.removeAllListeners('data');\n this.emit('error', err);\n try {\n socket.end();\n } catch {}\n },\n onHeader: (header) => {\n this.removeListener('error', onClientPreHeaderError);\n\n const info = {\n ip: socket.remoteAddress,\n family: socket.remoteFamily,\n port: socket.remotePort,\n header,\n };\n if (!server.emit('connection', this, info)) {\n // auto reject\n proto.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n socket.end();\n return;\n }\n\n if (header.greeting)\n this.emit('greeting', header.greeting);\n },\n onHandshakeComplete: (negotiated) => {\n if (++exchanges > 1)\n this.emit('rekey');\n this.emit('handshake', negotiated);\n },\n debug,\n messageHandlers: {\n DEBUG: DEBUG_HANDLER,\n DISCONNECT: (p, reason, desc) => {\n if (reason !== DISCONNECT_REASON.BY_APPLICATION) {\n if (!desc) {\n desc = DISCONNECT_REASON_BY_VALUE[reason];\n if (desc === undefined)\n desc = `Unexpected disconnection reason: ${reason}`;\n }\n const err = new Error(desc);\n err.code = reason;\n this.emit('error', err);\n }\n socket.end();\n },\n CHANNEL_OPEN: (p, info) => {\n // Handle incoming requests from client\n\n // Do early reject in some cases to prevent wasteful channel\n // allocation\n if ((info.type === 'session' && this.noMoreSessions)\n || !this.authenticated) {\n const reasonCode = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n return proto.channelOpenFail(info.sender, reasonCode);\n }\n\n let localChan = -1;\n let reason;\n let replied = false;\n\n let accept;\n const reject = () => {\n if (replied)\n return;\n replied = true;\n\n if (reason === undefined) {\n if (localChan === -1)\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n else\n reason = CHANNEL_OPEN_FAILURE.CONNECT_FAILED;\n }\n\n if (localChan !== -1)\n this._chanMgr.remove(localChan);\n proto.channelOpenFail(info.sender, reason, '');\n };\n const reserveChannel = () => {\n localChan = this._chanMgr.add();\n\n if (localChan === -1) {\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n if (debug) {\n debug('Automatic rejection of incoming channel open: '\n + 'no channels available');\n }\n }\n\n return (localChan !== -1);\n };\n\n const data = info.data;\n switch (info.type) {\n case 'session':\n if (listenerCount(this, 'session') && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const instance = new Session(this, info, localChan);\n this._chanMgr.update(localChan, instance);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return instance;\n };\n\n this.emit('session', accept, reject);\n return;\n }\n break;\n case 'direct-tcpip':\n if (listenerCount(this, 'tcpip') && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const chanInfo = {\n type: undefined,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const stream = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(localChan, stream);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return stream;\n };\n\n this.emit('tcpip', accept, reject, data);\n return;\n }\n break;\n case 'direct-streamlocal@openssh.com':\n if (listenerCount(this, 'openssh.streamlocal')\n && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const chanInfo = {\n type: undefined,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const stream = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(localChan, stream);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return stream;\n };\n\n this.emit('openssh.streamlocal', accept, reject, data);\n return;\n }\n break;\n default:\n // Automatically reject any unsupported channel open requests\n reason = CHANNEL_OPEN_FAILURE.UNKNOWN_CHANNEL_TYPE;\n if (debug) {\n debug('Automatic rejection of unsupported incoming channel open'\n + ` type: ${info.type}`);\n }\n }\n\n if (reason === undefined) {\n reason = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n if (debug) {\n debug('Automatic rejection of unexpected incoming channel open'\n + ` for: ${info.type}`);\n }\n }\n\n reject();\n },\n CHANNEL_OPEN_CONFIRMATION: (p, info) => {\n const channel = this._chanMgr.get(info.recipient);\n if (typeof channel !== 'function')\n return;\n\n const chanInfo = {\n type: channel.type,\n incoming: {\n id: info.recipient,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const instance = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(info.recipient, instance);\n channel(undefined, instance);\n },\n CHANNEL_OPEN_FAILURE: (p, recipient, reason, description) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'function')\n return;\n\n const info = { reason, description };\n onChannelOpenFailure(this, recipient, info, channel);\n },\n CHANNEL_DATA: (p, recipient, data) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (channel.push(data) === false) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_EXTENDED_DATA: (p, recipient, data, type) => {\n // NOOP -- should not be sent by client\n },\n CHANNEL_WINDOW_ADJUST: (p, recipient, amount) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n // The other side is allowing us to send `amount` more bytes of data\n channel.outgoing.window += amount;\n\n if (channel._waitWindow) {\n channel._waitWindow = false;\n\n if (channel._chunk) {\n channel._write(channel._chunk, null, channel._chunkcb);\n } else if (channel._chunkcb) {\n channel._chunkcb();\n } else if (channel._chunkErr) {\n channel.stderr._write(channel._chunkErr,\n null,\n channel._chunkcbErr);\n } else if (channel._chunkcbErr) {\n channel._chunkcbErr();\n }\n }\n },\n CHANNEL_SUCCESS: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(false);\n },\n CHANNEL_FAILURE: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(true);\n },\n CHANNEL_REQUEST: (p, recipient, type, wantReply, data) => {\n const session = this._chanMgr.get(recipient);\n if (typeof session !== 'object' || session === null)\n return;\n\n let replied = false;\n let accept;\n let reject;\n\n if (session.constructor !== Session) {\n // normal Channel instance\n if (wantReply)\n proto.channelFailure(session.outgoing.id);\n return;\n }\n\n if (wantReply) {\n // \"real session\" requests will have custom accept behaviors\n if (type !== 'shell'\n && type !== 'exec'\n && type !== 'subsystem') {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n proto.channelSuccess(session._chanInfo.outgoing.id);\n };\n }\n\n reject = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n proto.channelFailure(session._chanInfo.outgoing.id);\n };\n }\n\n if (session._ending) {\n reject && reject();\n return;\n }\n\n switch (type) {\n // \"pre-real session start\" requests\n case 'env':\n if (listenerCount(session, 'env')) {\n session.emit('env', accept, reject, {\n key: data.name,\n val: data.value\n });\n return;\n }\n break;\n case 'pty-req':\n if (listenerCount(session, 'pty')) {\n session.emit('pty', accept, reject, data);\n return;\n }\n break;\n case 'window-change':\n if (listenerCount(session, 'window-change'))\n session.emit('window-change', accept, reject, data);\n else\n reject && reject();\n break;\n case 'x11-req':\n if (listenerCount(session, 'x11')) {\n session.emit('x11', accept, reject, data);\n return;\n }\n break;\n // \"post-real session start\" requests\n case 'signal':\n if (listenerCount(session, 'signal')) {\n session.emit('signal', accept, reject, {\n name: data\n });\n return;\n }\n break;\n // XXX: is `auth-agent-req@openssh.com` really \"post-real session\n // start\"?\n case 'auth-agent-req@openssh.com':\n if (listenerCount(session, 'auth-agent')) {\n session.emit('auth-agent', accept, reject);\n return;\n }\n break;\n // \"real session start\" requests\n case 'shell':\n if (listenerCount(session, 'shell')) {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n const channel = new Channel(\n this, session._chanInfo, { server: true }\n );\n\n channel.subtype = session.subtype = type;\n session._channel = channel;\n\n return channel;\n };\n\n session.emit('shell', accept, reject);\n return;\n }\n break;\n case 'exec':\n if (listenerCount(session, 'exec')) {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n const channel = new Channel(\n this, session._chanInfo, { server: true }\n );\n\n channel.subtype = session.subtype = type;\n session._channel = channel;\n\n return channel;\n };\n\n session.emit('exec', accept, reject, {\n command: data\n });\n return;\n }\n break;\n case 'subsystem': {\n let useSFTP = (data === 'sftp');\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n let instance;\n if (useSFTP) {\n instance = new SFTP(this, session._chanInfo, {\n server: true,\n debug,\n });\n } else {\n instance = new Channel(\n this, session._chanInfo, { server: true }\n );\n instance.subtype =\n session.subtype = `${type}:${data}`;\n }\n session._channel = instance;\n\n return instance;\n };\n\n if (data === 'sftp') {\n if (listenerCount(session, 'sftp')) {\n session.emit('sftp', accept, reject);\n return;\n }\n useSFTP = false;\n }\n if (listenerCount(session, 'subsystem')) {\n session.emit('subsystem', accept, reject, {\n name: data\n });\n return;\n }\n break;\n }\n }\n debug && debug(\n `Automatic rejection of incoming channel request: ${type}`\n );\n reject && reject();\n },\n CHANNEL_EOF: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n if (!channel._ending) {\n channel._ending = true;\n channel.emit('eof');\n channel.emit('end');\n }\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel.incoming.state !== 'open')\n return;\n channel.incoming.state = 'eof';\n\n if (channel.readable)\n channel.push(null);\n },\n CHANNEL_CLOSE: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel._ending = true;\n channel.emit('close');\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n onCHANNEL_CLOSE(this, recipient, channel);\n },\n // Begin service/auth-related ==========================================\n SERVICE_REQUEST: (p, service) => {\n if (exchanges === 0\n || acceptedAuthSvc\n || this.authenticated\n || service !== 'ssh-userauth') {\n proto.disconnect(DISCONNECT_REASON.SERVICE_NOT_AVAILABLE);\n socket.end();\n return;\n }\n\n acceptedAuthSvc = true;\n proto.serviceAccept(service);\n },\n USERAUTH_REQUEST: (p, username, service, method, methodData) => {\n if (exchanges === 0\n || this.authenticated\n || (authCtx\n && (authCtx.username !== username\n || authCtx.service !== service))\n // TODO: support hostbased auth\n || (method !== 'password'\n && method !== 'publickey'\n && method !== 'hostbased'\n && method !== 'keyboard-interactive'\n && method !== 'none')\n || pendingAuths.length === MAX_PENDING_AUTHS) {\n proto.disconnect(DISCONNECT_REASON.PROTOCOL_ERROR);\n socket.end();\n return;\n } else if (service !== 'ssh-connection') {\n proto.disconnect(DISCONNECT_REASON.SERVICE_NOT_AVAILABLE);\n socket.end();\n return;\n }\n\n let ctx;\n switch (method) {\n case 'keyboard-interactive':\n ctx = new KeyboardAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'publickey':\n ctx = new PKAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'hostbased':\n ctx = new HostbasedAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'password':\n if (authCtx\n && authCtx instanceof PwdAuthContext\n && authCtx._changeCb) {\n const cb = authCtx._changeCb;\n authCtx._changeCb = undefined;\n cb(methodData.newPassword);\n return;\n }\n ctx = new PwdAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'none':\n ctx = new AuthContext(proto, username, service, method,\n onAuthDecide);\n break;\n }\n\n if (authCtx) {\n if (!authCtx._initialResponse) {\n return pendingAuths.push(ctx);\n } else if (authCtx._multistep && !authCtx._finalResponse) {\n // RFC 4252 says to silently abort the current auth request if a\n // new auth request comes in before the final response from an\n // auth method that requires additional request/response exchanges\n // -- this means keyboard-interactive for now ...\n authCtx._cleanup && authCtx._cleanup();\n authCtx.emit('abort');\n }\n }\n\n authCtx = ctx;\n\n if (listenerCount(this, 'authentication'))\n this.emit('authentication', authCtx);\n else\n authCtx.reject();\n },\n USERAUTH_INFO_RESPONSE: (p, responses) => {\n if (authCtx && authCtx instanceof KeyboardAuthContext)\n authCtx._onInfoResponse(responses);\n },\n // End service/auth-related ============================================\n GLOBAL_REQUEST: (p, name, wantReply, data) => {\n const reply = {\n type: null,\n buf: null\n };\n\n function setReply(type, buf) {\n reply.type = type;\n reply.buf = buf;\n sendReplies();\n }\n\n if (wantReply)\n unsentGlobalRequestsReplies.push(reply);\n\n if ((name === 'tcpip-forward'\n || name === 'cancel-tcpip-forward'\n || name === 'no-more-sessions@openssh.com'\n || name === 'streamlocal-forward@openssh.com'\n || name === 'cancel-streamlocal-forward@openssh.com')\n && listenerCount(this, 'request')\n && this.authenticated) {\n let accept;\n let reject;\n\n if (wantReply) {\n let replied = false;\n accept = (chosenPort) => {\n if (replied)\n return;\n replied = true;\n let bufPort;\n if (name === 'tcpip-forward'\n && data.bindPort === 0\n && typeof chosenPort === 'number') {\n bufPort = Buffer.allocUnsafe(4);\n writeUInt32BE(bufPort, chosenPort, 0);\n }\n setReply('SUCCESS', bufPort);\n };\n reject = () => {\n if (replied)\n return;\n replied = true;\n setReply('FAILURE');\n };\n }\n\n if (name === 'no-more-sessions@openssh.com') {\n this.noMoreSessions = true;\n accept && accept();\n return;\n }\n\n this.emit('request', accept, reject, name, data);\n } else if (wantReply) {\n setReply('FAILURE');\n }\n },\n },\n });\n\n socket.pause();\n cryptoInit.then(() => {\n proto.start();\n socket.on('data', (data) => {\n try {\n proto.parse(data, 0, data.length);\n } catch (ex) {\n this.emit('error', ex);\n try {\n if (isWritable(socket))\n socket.end();\n } catch {}\n }\n });\n socket.resume();\n }).catch((err) => {\n this.emit('error', err);\n try {\n if (isWritable(socket))\n socket.end();\n } catch {}\n });\n socket.on('error', (err) => {\n err.level = 'socket';\n this.emit('error', err);\n }).once('end', () => {\n debug && debug('Socket ended');\n proto.cleanup();\n this.emit('end');\n }).once('close', () => {\n debug && debug('Socket closed');\n proto.cleanup();\n this.emit('close');\n\n const err = new Error('No response from server');\n\n // Simulate error for pending channels and close any open channels\n this._chanMgr.cleanup(err);\n });\n\n const onAuthDecide = (ctx, allowed, methodsLeft, isPartial) => {\n if (authCtx === ctx && !this.authenticated) {\n if (allowed) {\n authCtx = undefined;\n this.authenticated = true;\n proto.authSuccess();\n pendingAuths = [];\n this.emit('ready');\n } else {\n proto.authFailure(methodsLeft, isPartial);\n if (pendingAuths.length) {\n authCtx = pendingAuths.pop();\n if (listenerCount(this, 'authentication'))\n this.emit('authentication', authCtx);\n else\n authCtx.reject();\n }\n }\n }\n };\n\n function sendReplies() {\n while (unsentGlobalRequestsReplies.length > 0\n && unsentGlobalRequestsReplies[0].type) {\n const reply = unsentGlobalRequestsReplies.shift();\n if (reply.type === 'SUCCESS')\n proto.requestSuccess(reply.buf);\n if (reply.type === 'FAILURE')\n proto.requestFailure();\n }\n }\n }\n\n end() {\n if (this._sock && isWritable(this._sock)) {\n this._protocol.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n this._sock.end();\n }\n return this;\n }\n\n x11(originAddr, originPort, cb) {\n const opts = { originAddr, originPort };\n openChannel(this, 'x11', opts, cb);\n return this;\n }\n\n forwardOut(boundAddr, boundPort, remoteAddr, remotePort, cb) {\n const opts = { boundAddr, boundPort, remoteAddr, remotePort };\n openChannel(this, 'forwarded-tcpip', opts, cb);\n return this;\n }\n\n openssh_forwardOutStreamLocal(socketPath, cb) {\n const opts = { socketPath };\n openChannel(this, 'forwarded-streamlocal@openssh.com', opts, cb);\n return this;\n }\n\n rekey(cb) {\n let error;\n\n try {\n this._protocol.rekey();\n } catch (ex) {\n error = ex;\n }\n\n // TODO: re-throw error if no callback?\n\n if (typeof cb === 'function') {\n if (error)\n process.nextTick(cb, error);\n else\n this.once('rekey', cb);\n }\n }\n}\n\n\nfunction openChannel(self, type, opts, cb) {\n // Ask the client to open a channel for some purpose (e.g. a forwarded TCP\n // connection)\n const initWindow = MAX_WINDOW;\n const maxPacket = PACKET_SIZE;\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const wrapper = (err, stream) => {\n cb(err, stream);\n };\n wrapper.type = type;\n\n const localChan = self._chanMgr.add(wrapper);\n\n if (localChan === -1) {\n cb(new Error('No free channels available'));\n return;\n }\n\n switch (type) {\n case 'forwarded-tcpip':\n self._protocol.forwardedTcpip(localChan, initWindow, maxPacket, opts);\n break;\n case 'x11':\n self._protocol.x11(localChan, initWindow, maxPacket, opts);\n break;\n case 'forwarded-streamlocal@openssh.com':\n self._protocol.openssh_forwardedStreamLocal(\n localChan, initWindow, maxPacket, opts\n );\n break;\n default:\n throw new Error(`Unsupported channel type: ${type}`);\n }\n}\n\nfunction compareNumbers(a, b) {\n return a - b;\n}\n\nmodule.exports = Server;\nmodule.exports.IncomingClient = Client;\n","'use strict';\n\nconst { SFTP } = require('./protocol/SFTP.js');\n\nconst MAX_CHANNEL = 2 ** 32 - 1;\n\nfunction onChannelOpenFailure(self, recipient, info, cb) {\n self._chanMgr.remove(recipient);\n if (typeof cb !== 'function')\n return;\n\n let err;\n if (info instanceof Error) {\n err = info;\n } else if (typeof info === 'object' && info !== null) {\n err = new Error(`(SSH) Channel open failure: ${info.description}`);\n err.reason = info.reason;\n } else {\n err = new Error(\n '(SSH) Channel open failure: server closed channel unexpectedly'\n );\n err.reason = '';\n }\n\n cb(err);\n}\n\nfunction onCHANNEL_CLOSE(self, recipient, channel, err, dead) {\n if (typeof channel === 'function') {\n // We got CHANNEL_CLOSE instead of CHANNEL_OPEN_FAILURE when\n // requesting to open a channel\n onChannelOpenFailure(self, recipient, err, channel);\n return;\n }\n\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.incoming && channel.incoming.state === 'closed')\n return;\n\n self._chanMgr.remove(recipient);\n\n if (channel.server && channel.constructor.name === 'Session')\n return;\n\n channel.incoming.state = 'closed';\n\n if (channel.readable)\n channel.push(null);\n if (channel.server) {\n if (channel.stderr.writable)\n channel.stderr.end();\n } else if (channel.stderr.readable) {\n channel.stderr.push(null);\n }\n\n if (channel.constructor !== SFTP\n && (channel.outgoing.state === 'open'\n || channel.outgoing.state === 'eof')\n && !dead) {\n channel.close();\n }\n if (channel.outgoing.state === 'closing')\n channel.outgoing.state = 'closed';\n\n const readState = channel._readableState;\n const writeState = channel._writableState;\n if (writeState && !writeState.ending && !writeState.finished && !dead)\n channel.end();\n\n // Take care of any outstanding channel requests\n const chanCallbacks = channel._callbacks;\n channel._callbacks = [];\n for (let i = 0; i < chanCallbacks.length; ++i)\n chanCallbacks[i](true);\n\n if (channel.server) {\n if (!channel.readable\n || channel.destroyed\n || (readState && readState.endEmitted)) {\n channel.emit('close');\n } else {\n channel.once('end', () => channel.emit('close'));\n }\n } else {\n let doClose;\n switch (channel.type) {\n case 'direct-streamlocal@openssh.com':\n case 'direct-tcpip':\n doClose = () => channel.emit('close');\n break;\n default: {\n // Align more with node child processes, where the close event gets\n // the same arguments as the exit event\n const exit = channel._exit;\n doClose = () => {\n if (exit.code === null)\n channel.emit('close', exit.code, exit.signal, exit.dump, exit.desc);\n else\n channel.emit('close', exit.code);\n };\n }\n }\n if (!channel.readable\n || channel.destroyed\n || (readState && readState.endEmitted)) {\n doClose();\n } else {\n channel.once('end', doClose);\n }\n\n const errReadState = channel.stderr._readableState;\n if (!channel.stderr.readable\n || channel.stderr.destroyed\n || (errReadState && errReadState.endEmitted)) {\n channel.stderr.emit('close');\n } else {\n channel.stderr.once('end', () => channel.stderr.emit('close'));\n }\n }\n}\n\nclass ChannelManager {\n constructor(client) {\n this._client = client;\n this._channels = {};\n this._cur = -1;\n this._count = 0;\n }\n add(val) {\n // Attempt to reserve an id\n\n let id;\n // Optimized paths\n if (this._cur < MAX_CHANNEL) {\n id = ++this._cur;\n } else if (this._count === 0) {\n // Revert and reset back to fast path once we no longer have any channels\n // open\n this._cur = 0;\n id = 0;\n } else {\n // Slower lookup path\n\n // This path is triggered we have opened at least MAX_CHANNEL channels\n // while having at least one channel open at any given time, so we have\n // to search for a free id.\n const channels = this._channels;\n for (let i = 0; i < MAX_CHANNEL; ++i) {\n if (channels[i] === undefined) {\n id = i;\n break;\n }\n }\n }\n\n if (id === undefined)\n return -1;\n\n this._channels[id] = (val || true);\n ++this._count;\n\n return id;\n }\n update(id, val) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n if (val && this._channels[id])\n this._channels[id] = val;\n }\n get(id) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n return this._channels[id];\n }\n remove(id) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n if (this._channels[id]) {\n delete this._channels[id];\n if (this._count)\n --this._count;\n }\n }\n cleanup(err) {\n const channels = this._channels;\n this._channels = {};\n this._cur = -1;\n this._count = 0;\n\n const chanIDs = Object.keys(channels);\n const client = this._client;\n for (let i = 0; i < chanIDs.length; ++i) {\n const id = +chanIDs[i];\n const channel = channels[id];\n onCHANNEL_CLOSE(client, id, channel._channel || channel, err, true);\n }\n }\n}\n\nconst isRegExp = (() => {\n const toString = Object.prototype.toString;\n return (val) => toString.call(val) === '[object RegExp]';\n})();\n\nfunction generateAlgorithmList(algoList, defaultList, supportedList) {\n if (Array.isArray(algoList) && algoList.length > 0) {\n // Exact list\n for (let i = 0; i < algoList.length; ++i) {\n if (supportedList.indexOf(algoList[i]) === -1)\n throw new Error(`Unsupported algorithm: ${algoList[i]}`);\n }\n return algoList;\n }\n\n if (typeof algoList === 'object' && algoList !== null) {\n // Operations based on the default list\n const keys = Object.keys(algoList);\n let list = defaultList;\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n let val = algoList[key];\n switch (key) {\n case 'append':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = 0; j < val.length; ++j) {\n const append = val[j];\n if (typeof append === 'string') {\n if (!append || list.indexOf(append) !== -1)\n continue;\n if (supportedList.indexOf(append) === -1)\n throw new Error(`Unsupported algorithm: ${append}`);\n if (list === defaultList)\n list = list.slice();\n list.push(append);\n } else if (isRegExp(append)) {\n for (let k = 0; k < supportedList.length; ++k) {\n const algo = supportedList[k];\n if (append.test(algo)) {\n if (list.indexOf(algo) !== -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.push(algo);\n }\n }\n }\n }\n }\n break;\n case 'prepend':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = val.length; j >= 0; --j) {\n const prepend = val[j];\n if (typeof prepend === 'string') {\n if (!prepend || list.indexOf(prepend) !== -1)\n continue;\n if (supportedList.indexOf(prepend) === -1)\n throw new Error(`Unsupported algorithm: ${prepend}`);\n if (list === defaultList)\n list = list.slice();\n list.unshift(prepend);\n } else if (isRegExp(prepend)) {\n for (let k = supportedList.length; k >= 0; --k) {\n const algo = supportedList[k];\n if (prepend.test(algo)) {\n if (list.indexOf(algo) !== -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.unshift(algo);\n }\n }\n }\n }\n }\n break;\n case 'remove':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = 0; j < val.length; ++j) {\n const search = val[j];\n if (typeof search === 'string') {\n if (!search)\n continue;\n const idx = list.indexOf(search);\n if (idx === -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.splice(idx, 1);\n } else if (isRegExp(search)) {\n for (let k = 0; k < list.length; ++k) {\n if (search.test(list[k])) {\n if (list === defaultList)\n list = list.slice();\n list.splice(k, 1);\n --k;\n }\n }\n }\n }\n }\n break;\n }\n }\n\n return list;\n }\n\n return defaultList;\n}\n\nmodule.exports = {\n ChannelManager,\n generateAlgorithmList,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n isWritable: (stream) => {\n // XXX: hack to workaround regression in node\n // See: https://github.com/nodejs/node/issues/36029\n return (stream\n && stream.writable\n && stream._readableState\n && stream._readableState.ended === false);\n },\n};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\n/**/\n\nvar isEncoding = Buffer.isEncoding || function (encoding) {\n encoding = '' + encoding;\n switch (encoding && encoding.toLowerCase()) {\n case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':\n return true;\n default:\n return false;\n }\n};\n\nfunction _normalizeEncoding(enc) {\n if (!enc) return 'utf8';\n var retried;\n while (true) {\n switch (enc) {\n case 'utf8':\n case 'utf-8':\n return 'utf8';\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return 'utf16le';\n case 'latin1':\n case 'binary':\n return 'latin1';\n case 'base64':\n case 'ascii':\n case 'hex':\n return enc;\n default:\n if (retried) return; // undefined\n enc = ('' + enc).toLowerCase();\n retried = true;\n }\n }\n};\n\n// Do not cache `Buffer.isEncoding` when checking encoding names as some\n// modules monkey-patch it to support additional encodings\nfunction normalizeEncoding(enc) {\n var nenc = _normalizeEncoding(enc);\n if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);\n return nenc || enc;\n}\n\n// StringDecoder provides an interface for efficiently splitting a series of\n// buffers into a series of JS strings without breaking apart multi-byte\n// characters.\nexports.StringDecoder = StringDecoder;\nfunction StringDecoder(encoding) {\n this.encoding = normalizeEncoding(encoding);\n var nb;\n switch (this.encoding) {\n case 'utf16le':\n this.text = utf16Text;\n this.end = utf16End;\n nb = 4;\n break;\n case 'utf8':\n this.fillLast = utf8FillLast;\n nb = 4;\n break;\n case 'base64':\n this.text = base64Text;\n this.end = base64End;\n nb = 3;\n break;\n default:\n this.write = simpleWrite;\n this.end = simpleEnd;\n return;\n }\n this.lastNeed = 0;\n this.lastTotal = 0;\n this.lastChar = Buffer.allocUnsafe(nb);\n}\n\nStringDecoder.prototype.write = function (buf) {\n if (buf.length === 0) return '';\n var r;\n var i;\n if (this.lastNeed) {\n r = this.fillLast(buf);\n if (r === undefined) return '';\n i = this.lastNeed;\n this.lastNeed = 0;\n } else {\n i = 0;\n }\n if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);\n return r || '';\n};\n\nStringDecoder.prototype.end = utf8End;\n\n// Returns only complete characters in a Buffer\nStringDecoder.prototype.text = utf8Text;\n\n// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer\nStringDecoder.prototype.fillLast = function (buf) {\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);\n this.lastNeed -= buf.length;\n};\n\n// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a\n// continuation byte. If an invalid byte is detected, -2 is returned.\nfunction utf8CheckByte(byte) {\n if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;\n return byte >> 6 === 0x02 ? -1 : -2;\n}\n\n// Checks at most 3 bytes at the end of a Buffer in order to detect an\n// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)\n// needed to complete the UTF-8 character (if applicable) are returned.\nfunction utf8CheckIncomplete(self, buf, i) {\n var j = buf.length - 1;\n if (j < i) return 0;\n var nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 1;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 2;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) {\n if (nb === 2) nb = 0;else self.lastNeed = nb - 3;\n }\n return nb;\n }\n return 0;\n}\n\n// Validates as many continuation bytes for a multi-byte UTF-8 character as\n// needed or are available. If we see a non-continuation byte where we expect\n// one, we \"replace\" the validated continuation bytes we've seen so far with\n// a single UTF-8 replacement character ('\\ufffd'), to match v8's UTF-8 decoding\n// behavior. The continuation byte check is included three times in the case\n// where all of the continuation bytes for a character exist in the same buffer.\n// It is also done this way as a slight performance increase instead of using a\n// loop.\nfunction utf8CheckExtraBytes(self, buf, p) {\n if ((buf[0] & 0xC0) !== 0x80) {\n self.lastNeed = 0;\n return '\\ufffd';\n }\n if (self.lastNeed > 1 && buf.length > 1) {\n if ((buf[1] & 0xC0) !== 0x80) {\n self.lastNeed = 1;\n return '\\ufffd';\n }\n if (self.lastNeed > 2 && buf.length > 2) {\n if ((buf[2] & 0xC0) !== 0x80) {\n self.lastNeed = 2;\n return '\\ufffd';\n }\n }\n }\n}\n\n// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.\nfunction utf8FillLast(buf) {\n var p = this.lastTotal - this.lastNeed;\n var r = utf8CheckExtraBytes(this, buf, p);\n if (r !== undefined) return r;\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, p, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, p, 0, buf.length);\n this.lastNeed -= buf.length;\n}\n\n// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a\n// partial character, the character's bytes are buffered until the required\n// number of bytes are available.\nfunction utf8Text(buf, i) {\n var total = utf8CheckIncomplete(this, buf, i);\n if (!this.lastNeed) return buf.toString('utf8', i);\n this.lastTotal = total;\n var end = buf.length - (total - this.lastNeed);\n buf.copy(this.lastChar, 0, end);\n return buf.toString('utf8', i, end);\n}\n\n// For UTF-8, a replacement character is added when ending on a partial\n// character.\nfunction utf8End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + '\\ufffd';\n return r;\n}\n\n// UTF-16LE typically needs two bytes per character, but even if we have an even\n// number of bytes available, we need to check if we end on a leading/high\n// surrogate. In that case, we need to wait for the next two bytes in order to\n// decode the last character properly.\nfunction utf16Text(buf, i) {\n if ((buf.length - i) % 2 === 0) {\n var r = buf.toString('utf16le', i);\n if (r) {\n var c = r.charCodeAt(r.length - 1);\n if (c >= 0xD800 && c <= 0xDBFF) {\n this.lastNeed = 2;\n this.lastTotal = 4;\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n return r.slice(0, -1);\n }\n }\n return r;\n }\n this.lastNeed = 1;\n this.lastTotal = 2;\n this.lastChar[0] = buf[buf.length - 1];\n return buf.toString('utf16le', i, buf.length - 1);\n}\n\n// For UTF-16LE we do not explicitly append special replacement characters if we\n// end on a partial character, we simply let v8 handle that.\nfunction utf16End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) {\n var end = this.lastTotal - this.lastNeed;\n return r + this.lastChar.toString('utf16le', 0, end);\n }\n return r;\n}\n\nfunction base64Text(buf, i) {\n var n = (buf.length - i) % 3;\n if (n === 0) return buf.toString('base64', i);\n this.lastNeed = 3 - n;\n this.lastTotal = 3;\n if (n === 1) {\n this.lastChar[0] = buf[buf.length - 1];\n } else {\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n }\n return buf.toString('base64', i, buf.length - n);\n}\n\nfunction base64End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);\n return r;\n}\n\n// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)\nfunction simpleWrite(buf) {\n return buf.toString(this.encoding);\n}\n\nfunction simpleEnd(buf) {\n return buf && buf.length ? this.write(buf) : '';\n}","/*! safe-buffer. MIT License. Feross Aboukhadijeh */\n/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.prototype = Object.create(Buffer.prototype)\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\nconst os = require('os');\nconst tty = require('tty');\nconst hasFlag = require('has-flag');\n\nconst {env} = process;\n\nlet forceColor;\nif (hasFlag('no-color') ||\n\thasFlag('no-colors') ||\n\thasFlag('color=false') ||\n\thasFlag('color=never')) {\n\tforceColor = 0;\n} else if (hasFlag('color') ||\n\thasFlag('colors') ||\n\thasFlag('color=true') ||\n\thasFlag('color=always')) {\n\tforceColor = 1;\n}\n\nif ('FORCE_COLOR' in env) {\n\tif (env.FORCE_COLOR === 'true') {\n\t\tforceColor = 1;\n\t} else if (env.FORCE_COLOR === 'false') {\n\t\tforceColor = 0;\n\t} else {\n\t\tforceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);\n\t}\n}\n\nfunction translateLevel(level) {\n\tif (level === 0) {\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tlevel,\n\t\thasBasic: true,\n\t\thas256: level >= 2,\n\t\thas16m: level >= 3\n\t};\n}\n\nfunction supportsColor(haveStream, streamIsTTY) {\n\tif (forceColor === 0) {\n\t\treturn 0;\n\t}\n\n\tif (hasFlag('color=16m') ||\n\t\thasFlag('color=full') ||\n\t\thasFlag('color=truecolor')) {\n\t\treturn 3;\n\t}\n\n\tif (hasFlag('color=256')) {\n\t\treturn 2;\n\t}\n\n\tif (haveStream && !streamIsTTY && forceColor === undefined) {\n\t\treturn 0;\n\t}\n\n\tconst min = forceColor || 0;\n\n\tif (env.TERM === 'dumb') {\n\t\treturn min;\n\t}\n\n\tif (process.platform === 'win32') {\n\t\t// Windows 10 build 10586 is the first Windows release that supports 256 colors.\n\t\t// Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n\t\tconst osRelease = os.release().split('.');\n\t\tif (\n\t\t\tNumber(osRelease[0]) >= 10 &&\n\t\t\tNumber(osRelease[2]) >= 10586\n\t\t) {\n\t\t\treturn Number(osRelease[2]) >= 14931 ? 3 : 2;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif ('CI' in env) {\n\t\tif (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn min;\n\t}\n\n\tif ('TEAMCITY_VERSION' in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;\n\t}\n\n\tif (env.COLORTERM === 'truecolor') {\n\t\treturn 3;\n\t}\n\n\tif ('TERM_PROGRAM' in env) {\n\t\tconst version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);\n\n\t\tswitch (env.TERM_PROGRAM) {\n\t\t\tcase 'iTerm.app':\n\t\t\t\treturn version >= 3 ? 3 : 2;\n\t\t\tcase 'Apple_Terminal':\n\t\t\t\treturn 2;\n\t\t\t// No default\n\t\t}\n\t}\n\n\tif (/-256(color)?$/i.test(env.TERM)) {\n\t\treturn 2;\n\t}\n\n\tif (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {\n\t\treturn 1;\n\t}\n\n\tif ('COLORTERM' in env) {\n\t\treturn 1;\n\t}\n\n\treturn min;\n}\n\nfunction getSupportLevel(stream) {\n\tconst level = supportsColor(stream, stream && stream.isTTY);\n\treturn translateLevel(level);\n}\n\nmodule.exports = {\n\tsupportsColor: getSupportLevel,\n\tstdout: translateLevel(supportsColor(true, tty.isatty(1))),\n\tstderr: translateLevel(supportsColor(true, tty.isatty(2)))\n};\n","var chownr = require('chownr')\nvar tar = require('tar-stream')\nvar pump = require('pump')\nvar mkdirp = require('mkdirp-classic')\nvar fs = require('fs')\nvar path = require('path')\nvar os = require('os')\n\nvar win32 = os.platform() === 'win32'\n\nvar noop = function () {}\n\nvar echo = function (name) {\n return name\n}\n\nvar normalize = !win32 ? echo : function (name) {\n return name.replace(/\\\\/g, '/').replace(/[:?<>|]/g, '_')\n}\n\nvar statAll = function (fs, stat, cwd, ignore, entries, sort) {\n var queue = entries || ['.']\n\n return function loop (callback) {\n if (!queue.length) return callback()\n var next = queue.shift()\n var nextAbs = path.join(cwd, next)\n\n stat(nextAbs, function (err, stat) {\n if (err) return callback(err)\n\n if (!stat.isDirectory()) return callback(null, next, stat)\n\n fs.readdir(nextAbs, function (err, files) {\n if (err) return callback(err)\n\n if (sort) files.sort()\n for (var i = 0; i < files.length; i++) {\n if (!ignore(path.join(cwd, next, files[i]))) queue.push(path.join(next, files[i]))\n }\n\n callback(null, next, stat)\n })\n })\n }\n}\n\nvar strip = function (map, level) {\n return function (header) {\n header.name = header.name.split('/').slice(level).join('/')\n\n var linkname = header.linkname\n if (linkname && (header.type === 'link' || path.isAbsolute(linkname))) {\n header.linkname = linkname.split('/').slice(level).join('/')\n }\n\n return map(header)\n }\n}\n\nexports.pack = function (cwd, opts) {\n if (!cwd) cwd = '.'\n if (!opts) opts = {}\n\n var xfs = opts.fs || fs\n var ignore = opts.ignore || opts.filter || noop\n var map = opts.map || noop\n var mapStream = opts.mapStream || echo\n var statNext = statAll(xfs, opts.dereference ? xfs.stat : xfs.lstat, cwd, ignore, opts.entries, opts.sort)\n var strict = opts.strict !== false\n var umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()\n var dmode = typeof opts.dmode === 'number' ? opts.dmode : 0\n var fmode = typeof opts.fmode === 'number' ? opts.fmode : 0\n var pack = opts.pack || tar.pack()\n var finish = opts.finish || noop\n\n if (opts.strip) map = strip(map, opts.strip)\n\n if (opts.readable) {\n dmode |= parseInt(555, 8)\n fmode |= parseInt(444, 8)\n }\n if (opts.writable) {\n dmode |= parseInt(333, 8)\n fmode |= parseInt(222, 8)\n }\n\n var onsymlink = function (filename, header) {\n xfs.readlink(path.join(cwd, filename), function (err, linkname) {\n if (err) return pack.destroy(err)\n header.linkname = normalize(linkname)\n pack.entry(header, onnextentry)\n })\n }\n\n var onstat = function (err, filename, stat) {\n if (err) return pack.destroy(err)\n if (!filename) {\n if (opts.finalize !== false) pack.finalize()\n return finish(pack)\n }\n\n if (stat.isSocket()) return onnextentry() // tar does not support sockets...\n\n var header = {\n name: normalize(filename),\n mode: (stat.mode | (stat.isDirectory() ? dmode : fmode)) & umask,\n mtime: stat.mtime,\n size: stat.size,\n type: 'file',\n uid: stat.uid,\n gid: stat.gid\n }\n\n if (stat.isDirectory()) {\n header.size = 0\n header.type = 'directory'\n header = map(header) || header\n return pack.entry(header, onnextentry)\n }\n\n if (stat.isSymbolicLink()) {\n header.size = 0\n header.type = 'symlink'\n header = map(header) || header\n return onsymlink(filename, header)\n }\n\n // TODO: add fifo etc...\n\n header = map(header) || header\n\n if (!stat.isFile()) {\n if (strict) return pack.destroy(new Error('unsupported type for ' + filename))\n return onnextentry()\n }\n\n var entry = pack.entry(header, onnextentry)\n if (!entry) return\n\n var rs = mapStream(xfs.createReadStream(path.join(cwd, filename)), header)\n\n rs.on('error', function (err) { // always forward errors on destroy\n entry.destroy(err)\n })\n\n pump(rs, entry)\n }\n\n var onnextentry = function (err) {\n if (err) return pack.destroy(err)\n statNext(onstat)\n }\n\n onnextentry()\n\n return pack\n}\n\nvar head = function (list) {\n return list.length ? list[list.length - 1] : null\n}\n\nvar processGetuid = function () {\n return process.getuid ? process.getuid() : -1\n}\n\nvar processUmask = function () {\n return process.umask ? process.umask() : 0\n}\n\nexports.extract = function (cwd, opts) {\n if (!cwd) cwd = '.'\n if (!opts) opts = {}\n\n var xfs = opts.fs || fs\n var ignore = opts.ignore || opts.filter || noop\n var map = opts.map || noop\n var mapStream = opts.mapStream || echo\n var own = opts.chown !== false && !win32 && processGetuid() === 0\n var extract = opts.extract || tar.extract()\n var stack = []\n var now = new Date()\n var umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()\n var dmode = typeof opts.dmode === 'number' ? opts.dmode : 0\n var fmode = typeof opts.fmode === 'number' ? opts.fmode : 0\n var strict = opts.strict !== false\n\n if (opts.strip) map = strip(map, opts.strip)\n\n if (opts.readable) {\n dmode |= parseInt(555, 8)\n fmode |= parseInt(444, 8)\n }\n if (opts.writable) {\n dmode |= parseInt(333, 8)\n fmode |= parseInt(222, 8)\n }\n\n var utimesParent = function (name, cb) { // we just set the mtime on the parent dir again everytime we write an entry\n var top\n while ((top = head(stack)) && name.slice(0, top[0].length) !== top[0]) stack.pop()\n if (!top) return cb()\n xfs.utimes(top[0], now, top[1], cb)\n }\n\n var utimes = function (name, header, cb) {\n if (opts.utimes === false) return cb()\n\n if (header.type === 'directory') return xfs.utimes(name, now, header.mtime, cb)\n if (header.type === 'symlink') return utimesParent(name, cb) // TODO: how to set mtime on link?\n\n xfs.utimes(name, now, header.mtime, function (err) {\n if (err) return cb(err)\n utimesParent(name, cb)\n })\n }\n\n var chperm = function (name, header, cb) {\n var link = header.type === 'symlink'\n\n /* eslint-disable node/no-deprecated-api */\n var chmod = link ? xfs.lchmod : xfs.chmod\n var chown = link ? xfs.lchown : xfs.chown\n /* eslint-enable node/no-deprecated-api */\n\n if (!chmod) return cb()\n\n var mode = (header.mode | (header.type === 'directory' ? dmode : fmode)) & umask\n chmod(name, mode, function (err) {\n if (err) return cb(err)\n if (!own) return cb()\n if (!chown) return cb()\n chown(name, header.uid, header.gid, cb)\n })\n }\n\n extract.on('entry', function (header, stream, next) {\n header = map(header) || header\n header.name = normalize(header.name)\n var name = path.join(cwd, path.join('/', header.name))\n\n if (ignore(name, header)) {\n stream.resume()\n return next()\n }\n\n var stat = function (err) {\n if (err) return next(err)\n utimes(name, header, function (err) {\n if (err) return next(err)\n if (win32) return next()\n chperm(name, header, next)\n })\n }\n\n var onsymlink = function () {\n if (win32) return next() // skip symlinks on win for now before it can be tested\n xfs.unlink(name, function () {\n xfs.symlink(header.linkname, name, stat)\n })\n }\n\n var onlink = function () {\n if (win32) return next() // skip links on win for now before it can be tested\n xfs.unlink(name, function () {\n var srcpath = path.join(cwd, path.join('/', header.linkname))\n\n xfs.link(srcpath, name, function (err) {\n if (err && err.code === 'EPERM' && opts.hardlinkAsFilesFallback) {\n stream = xfs.createReadStream(srcpath)\n return onfile()\n }\n\n stat(err)\n })\n })\n }\n\n var onfile = function () {\n var ws = xfs.createWriteStream(name)\n var rs = mapStream(stream, header)\n\n ws.on('error', function (err) { // always forward errors on destroy\n rs.destroy(err)\n })\n\n pump(rs, ws, function (err) {\n if (err) return next(err)\n ws.on('close', stat)\n })\n }\n\n if (header.type === 'directory') {\n stack.push([name, header.mtime])\n return mkdirfix(name, {\n fs: xfs, own: own, uid: header.uid, gid: header.gid\n }, stat)\n }\n\n var dir = path.dirname(name)\n\n validate(xfs, dir, path.join(cwd, '.'), function (err, valid) {\n if (err) return next(err)\n if (!valid) return next(new Error(dir + ' is not a valid path'))\n\n mkdirfix(dir, {\n fs: xfs, own: own, uid: header.uid, gid: header.gid\n }, function (err) {\n if (err) return next(err)\n\n switch (header.type) {\n case 'file': return onfile()\n case 'link': return onlink()\n case 'symlink': return onsymlink()\n }\n\n if (strict) return next(new Error('unsupported type for ' + name + ' (' + header.type + ')'))\n\n stream.resume()\n next()\n })\n })\n })\n\n if (opts.finish) extract.on('finish', opts.finish)\n\n return extract\n}\n\nfunction validate (fs, name, root, cb) {\n if (name === root) return cb(null, true)\n fs.lstat(name, function (err, st) {\n if (err && err.code !== 'ENOENT') return cb(err)\n if (err || st.isDirectory()) return validate(fs, path.join(name, '..'), root, cb)\n cb(null, false)\n })\n}\n\nfunction mkdirfix (name, opts, cb) {\n mkdirp(name, { fs: opts.fs }, function (err, made) {\n if (!err && made && opts.own) {\n chownr(made, opts.uid, opts.gid, cb)\n } else {\n cb(err)\n }\n })\n}\n","var util = require('util')\nvar bl = require('bl')\nvar headers = require('./headers')\n\nvar Writable = require('readable-stream').Writable\nvar PassThrough = require('readable-stream').PassThrough\n\nvar noop = function () {}\n\nvar overflow = function (size) {\n size &= 511\n return size && 512 - size\n}\n\nvar emptyStream = function (self, offset) {\n var s = new Source(self, offset)\n s.end()\n return s\n}\n\nvar mixinPax = function (header, pax) {\n if (pax.path) header.name = pax.path\n if (pax.linkpath) header.linkname = pax.linkpath\n if (pax.size) header.size = parseInt(pax.size, 10)\n header.pax = pax\n return header\n}\n\nvar Source = function (self, offset) {\n this._parent = self\n this.offset = offset\n PassThrough.call(this, { autoDestroy: false })\n}\n\nutil.inherits(Source, PassThrough)\n\nSource.prototype.destroy = function (err) {\n this._parent.destroy(err)\n}\n\nvar Extract = function (opts) {\n if (!(this instanceof Extract)) return new Extract(opts)\n Writable.call(this, opts)\n\n opts = opts || {}\n\n this._offset = 0\n this._buffer = bl()\n this._missing = 0\n this._partial = false\n this._onparse = noop\n this._header = null\n this._stream = null\n this._overflow = null\n this._cb = null\n this._locked = false\n this._destroyed = false\n this._pax = null\n this._paxGlobal = null\n this._gnuLongPath = null\n this._gnuLongLinkPath = null\n\n var self = this\n var b = self._buffer\n\n var oncontinue = function () {\n self._continue()\n }\n\n var onunlock = function (err) {\n self._locked = false\n if (err) return self.destroy(err)\n if (!self._stream) oncontinue()\n }\n\n var onstreamend = function () {\n self._stream = null\n var drain = overflow(self._header.size)\n if (drain) self._parse(drain, ondrain)\n else self._parse(512, onheader)\n if (!self._locked) oncontinue()\n }\n\n var ondrain = function () {\n self._buffer.consume(overflow(self._header.size))\n self._parse(512, onheader)\n oncontinue()\n }\n\n var onpaxglobalheader = function () {\n var size = self._header.size\n self._paxGlobal = headers.decodePax(b.slice(0, size))\n b.consume(size)\n onstreamend()\n }\n\n var onpaxheader = function () {\n var size = self._header.size\n self._pax = headers.decodePax(b.slice(0, size))\n if (self._paxGlobal) self._pax = Object.assign({}, self._paxGlobal, self._pax)\n b.consume(size)\n onstreamend()\n }\n\n var ongnulongpath = function () {\n var size = self._header.size\n this._gnuLongPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)\n b.consume(size)\n onstreamend()\n }\n\n var ongnulonglinkpath = function () {\n var size = self._header.size\n this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)\n b.consume(size)\n onstreamend()\n }\n\n var onheader = function () {\n var offset = self._offset\n var header\n try {\n header = self._header = headers.decode(b.slice(0, 512), opts.filenameEncoding, opts.allowUnknownFormat)\n } catch (err) {\n self.emit('error', err)\n }\n b.consume(512)\n\n if (!header) {\n self._parse(512, onheader)\n oncontinue()\n return\n }\n if (header.type === 'gnu-long-path') {\n self._parse(header.size, ongnulongpath)\n oncontinue()\n return\n }\n if (header.type === 'gnu-long-link-path') {\n self._parse(header.size, ongnulonglinkpath)\n oncontinue()\n return\n }\n if (header.type === 'pax-global-header') {\n self._parse(header.size, onpaxglobalheader)\n oncontinue()\n return\n }\n if (header.type === 'pax-header') {\n self._parse(header.size, onpaxheader)\n oncontinue()\n return\n }\n\n if (self._gnuLongPath) {\n header.name = self._gnuLongPath\n self._gnuLongPath = null\n }\n\n if (self._gnuLongLinkPath) {\n header.linkname = self._gnuLongLinkPath\n self._gnuLongLinkPath = null\n }\n\n if (self._pax) {\n self._header = header = mixinPax(header, self._pax)\n self._pax = null\n }\n\n self._locked = true\n\n if (!header.size || header.type === 'directory') {\n self._parse(512, onheader)\n self.emit('entry', header, emptyStream(self, offset), onunlock)\n return\n }\n\n self._stream = new Source(self, offset)\n\n self.emit('entry', header, self._stream, onunlock)\n self._parse(header.size, onstreamend)\n oncontinue()\n }\n\n this._onheader = onheader\n this._parse(512, onheader)\n}\n\nutil.inherits(Extract, Writable)\n\nExtract.prototype.destroy = function (err) {\n if (this._destroyed) return\n this._destroyed = true\n\n if (err) this.emit('error', err)\n this.emit('close')\n if (this._stream) this._stream.emit('close')\n}\n\nExtract.prototype._parse = function (size, onparse) {\n if (this._destroyed) return\n this._offset += size\n this._missing = size\n if (onparse === this._onheader) this._partial = false\n this._onparse = onparse\n}\n\nExtract.prototype._continue = function () {\n if (this._destroyed) return\n var cb = this._cb\n this._cb = noop\n if (this._overflow) this._write(this._overflow, undefined, cb)\n else cb()\n}\n\nExtract.prototype._write = function (data, enc, cb) {\n if (this._destroyed) return\n\n var s = this._stream\n var b = this._buffer\n var missing = this._missing\n if (data.length) this._partial = true\n\n // we do not reach end-of-chunk now. just forward it\n\n if (data.length < missing) {\n this._missing -= data.length\n this._overflow = null\n if (s) return s.write(data, cb)\n b.append(data)\n return cb()\n }\n\n // end-of-chunk. the parser should call cb.\n\n this._cb = cb\n this._missing = 0\n\n var overflow = null\n if (data.length > missing) {\n overflow = data.slice(missing)\n data = data.slice(0, missing)\n }\n\n if (s) s.end(data)\n else b.append(data)\n\n this._overflow = overflow\n this._onparse()\n}\n\nExtract.prototype._final = function (cb) {\n if (this._partial) return this.destroy(new Error('Unexpected end of data'))\n cb()\n}\n\nmodule.exports = Extract\n","var alloc = Buffer.alloc\n\nvar ZEROS = '0000000000000000000'\nvar SEVENS = '7777777777777777777'\nvar ZERO_OFFSET = '0'.charCodeAt(0)\nvar USTAR_MAGIC = Buffer.from('ustar\\x00', 'binary')\nvar USTAR_VER = Buffer.from('00', 'binary')\nvar GNU_MAGIC = Buffer.from('ustar\\x20', 'binary')\nvar GNU_VER = Buffer.from('\\x20\\x00', 'binary')\nvar MASK = parseInt('7777', 8)\nvar MAGIC_OFFSET = 257\nvar VERSION_OFFSET = 263\n\nvar clamp = function (index, len, defaultValue) {\n if (typeof index !== 'number') return defaultValue\n index = ~~index // Coerce to integer.\n if (index >= len) return len\n if (index >= 0) return index\n index += len\n if (index >= 0) return index\n return 0\n}\n\nvar toType = function (flag) {\n switch (flag) {\n case 0:\n return 'file'\n case 1:\n return 'link'\n case 2:\n return 'symlink'\n case 3:\n return 'character-device'\n case 4:\n return 'block-device'\n case 5:\n return 'directory'\n case 6:\n return 'fifo'\n case 7:\n return 'contiguous-file'\n case 72:\n return 'pax-header'\n case 55:\n return 'pax-global-header'\n case 27:\n return 'gnu-long-link-path'\n case 28:\n case 30:\n return 'gnu-long-path'\n }\n\n return null\n}\n\nvar toTypeflag = function (flag) {\n switch (flag) {\n case 'file':\n return 0\n case 'link':\n return 1\n case 'symlink':\n return 2\n case 'character-device':\n return 3\n case 'block-device':\n return 4\n case 'directory':\n return 5\n case 'fifo':\n return 6\n case 'contiguous-file':\n return 7\n case 'pax-header':\n return 72\n }\n\n return 0\n}\n\nvar indexOf = function (block, num, offset, end) {\n for (; offset < end; offset++) {\n if (block[offset] === num) return offset\n }\n return end\n}\n\nvar cksum = function (block) {\n var sum = 8 * 32\n for (var i = 0; i < 148; i++) sum += block[i]\n for (var j = 156; j < 512; j++) sum += block[j]\n return sum\n}\n\nvar encodeOct = function (val, n) {\n val = val.toString(8)\n if (val.length > n) return SEVENS.slice(0, n) + ' '\n else return ZEROS.slice(0, n - val.length) + val + ' '\n}\n\n/* Copied from the node-tar repo and modified to meet\n * tar-stream coding standard.\n *\n * Source: https://github.com/npm/node-tar/blob/51b6627a1f357d2eb433e7378e5f05e83b7aa6cd/lib/header.js#L349\n */\nfunction parse256 (buf) {\n // first byte MUST be either 80 or FF\n // 80 for positive, FF for 2's comp\n var positive\n if (buf[0] === 0x80) positive = true\n else if (buf[0] === 0xFF) positive = false\n else return null\n\n // build up a base-256 tuple from the least sig to the highest\n var tuple = []\n for (var i = buf.length - 1; i > 0; i--) {\n var byte = buf[i]\n if (positive) tuple.push(byte)\n else tuple.push(0xFF - byte)\n }\n\n var sum = 0\n var l = tuple.length\n for (i = 0; i < l; i++) {\n sum += tuple[i] * Math.pow(256, i)\n }\n\n return positive ? sum : -1 * sum\n}\n\nvar decodeOct = function (val, offset, length) {\n val = val.slice(offset, offset + length)\n offset = 0\n\n // If prefixed with 0x80 then parse as a base-256 integer\n if (val[offset] & 0x80) {\n return parse256(val)\n } else {\n // Older versions of tar can prefix with spaces\n while (offset < val.length && val[offset] === 32) offset++\n var end = clamp(indexOf(val, 32, offset, val.length), val.length, val.length)\n while (offset < end && val[offset] === 0) offset++\n if (end === offset) return 0\n return parseInt(val.slice(offset, end).toString(), 8)\n }\n}\n\nvar decodeStr = function (val, offset, length, encoding) {\n return val.slice(offset, indexOf(val, 0, offset, offset + length)).toString(encoding)\n}\n\nvar addLength = function (str) {\n var len = Buffer.byteLength(str)\n var digits = Math.floor(Math.log(len) / Math.log(10)) + 1\n if (len + digits >= Math.pow(10, digits)) digits++\n\n return (len + digits) + str\n}\n\nexports.decodeLongPath = function (buf, encoding) {\n return decodeStr(buf, 0, buf.length, encoding)\n}\n\nexports.encodePax = function (opts) { // TODO: encode more stuff in pax\n var result = ''\n if (opts.name) result += addLength(' path=' + opts.name + '\\n')\n if (opts.linkname) result += addLength(' linkpath=' + opts.linkname + '\\n')\n var pax = opts.pax\n if (pax) {\n for (var key in pax) {\n result += addLength(' ' + key + '=' + pax[key] + '\\n')\n }\n }\n return Buffer.from(result)\n}\n\nexports.decodePax = function (buf) {\n var result = {}\n\n while (buf.length) {\n var i = 0\n while (i < buf.length && buf[i] !== 32) i++\n var len = parseInt(buf.slice(0, i).toString(), 10)\n if (!len) return result\n\n var b = buf.slice(i + 1, len - 1).toString()\n var keyIndex = b.indexOf('=')\n if (keyIndex === -1) return result\n result[b.slice(0, keyIndex)] = b.slice(keyIndex + 1)\n\n buf = buf.slice(len)\n }\n\n return result\n}\n\nexports.encode = function (opts) {\n var buf = alloc(512)\n var name = opts.name\n var prefix = ''\n\n if (opts.typeflag === 5 && name[name.length - 1] !== '/') name += '/'\n if (Buffer.byteLength(name) !== name.length) return null // utf-8\n\n while (Buffer.byteLength(name) > 100) {\n var i = name.indexOf('/')\n if (i === -1) return null\n prefix += prefix ? '/' + name.slice(0, i) : name.slice(0, i)\n name = name.slice(i + 1)\n }\n\n if (Buffer.byteLength(name) > 100 || Buffer.byteLength(prefix) > 155) return null\n if (opts.linkname && Buffer.byteLength(opts.linkname) > 100) return null\n\n buf.write(name)\n buf.write(encodeOct(opts.mode & MASK, 6), 100)\n buf.write(encodeOct(opts.uid, 6), 108)\n buf.write(encodeOct(opts.gid, 6), 116)\n buf.write(encodeOct(opts.size, 11), 124)\n buf.write(encodeOct((opts.mtime.getTime() / 1000) | 0, 11), 136)\n\n buf[156] = ZERO_OFFSET + toTypeflag(opts.type)\n\n if (opts.linkname) buf.write(opts.linkname, 157)\n\n USTAR_MAGIC.copy(buf, MAGIC_OFFSET)\n USTAR_VER.copy(buf, VERSION_OFFSET)\n if (opts.uname) buf.write(opts.uname, 265)\n if (opts.gname) buf.write(opts.gname, 297)\n buf.write(encodeOct(opts.devmajor || 0, 6), 329)\n buf.write(encodeOct(opts.devminor || 0, 6), 337)\n\n if (prefix) buf.write(prefix, 345)\n\n buf.write(encodeOct(cksum(buf), 6), 148)\n\n return buf\n}\n\nexports.decode = function (buf, filenameEncoding, allowUnknownFormat) {\n var typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET\n\n var name = decodeStr(buf, 0, 100, filenameEncoding)\n var mode = decodeOct(buf, 100, 8)\n var uid = decodeOct(buf, 108, 8)\n var gid = decodeOct(buf, 116, 8)\n var size = decodeOct(buf, 124, 12)\n var mtime = decodeOct(buf, 136, 12)\n var type = toType(typeflag)\n var linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100, filenameEncoding)\n var uname = decodeStr(buf, 265, 32)\n var gname = decodeStr(buf, 297, 32)\n var devmajor = decodeOct(buf, 329, 8)\n var devminor = decodeOct(buf, 337, 8)\n\n var c = cksum(buf)\n\n // checksum is still initial value if header was null.\n if (c === 8 * 32) return null\n\n // valid checksum\n if (c !== decodeOct(buf, 148, 8)) throw new Error('Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?')\n\n if (USTAR_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0) {\n // ustar (posix) format.\n // prepend prefix, if present.\n if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + '/' + name\n } else if (GNU_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0 &&\n GNU_VER.compare(buf, VERSION_OFFSET, VERSION_OFFSET + 2) === 0) {\n // 'gnu'/'oldgnu' format. Similar to ustar, but has support for incremental and\n // multi-volume tarballs.\n } else {\n if (!allowUnknownFormat) {\n throw new Error('Invalid tar header: unknown format.')\n }\n }\n\n // to support old tar versions that use trailing / to indicate dirs\n if (typeflag === 0 && name && name[name.length - 1] === '/') typeflag = 5\n\n return {\n name,\n mode,\n uid,\n gid,\n size,\n mtime: new Date(1000 * mtime),\n type,\n linkname,\n uname,\n gname,\n devmajor,\n devminor\n }\n}\n","exports.extract = require('./extract')\nexports.pack = require('./pack')\n","var constants = require('fs-constants')\nvar eos = require('end-of-stream')\nvar inherits = require('inherits')\nvar alloc = Buffer.alloc\n\nvar Readable = require('readable-stream').Readable\nvar Writable = require('readable-stream').Writable\nvar StringDecoder = require('string_decoder').StringDecoder\n\nvar headers = require('./headers')\n\nvar DMODE = parseInt('755', 8)\nvar FMODE = parseInt('644', 8)\n\nvar END_OF_TAR = alloc(1024)\n\nvar noop = function () {}\n\nvar overflow = function (self, size) {\n size &= 511\n if (size) self.push(END_OF_TAR.slice(0, 512 - size))\n}\n\nfunction modeToType (mode) {\n switch (mode & constants.S_IFMT) {\n case constants.S_IFBLK: return 'block-device'\n case constants.S_IFCHR: return 'character-device'\n case constants.S_IFDIR: return 'directory'\n case constants.S_IFIFO: return 'fifo'\n case constants.S_IFLNK: return 'symlink'\n }\n\n return 'file'\n}\n\nvar Sink = function (to) {\n Writable.call(this)\n this.written = 0\n this._to = to\n this._destroyed = false\n}\n\ninherits(Sink, Writable)\n\nSink.prototype._write = function (data, enc, cb) {\n this.written += data.length\n if (this._to.push(data)) return cb()\n this._to._drain = cb\n}\n\nSink.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar LinkSink = function () {\n Writable.call(this)\n this.linkname = ''\n this._decoder = new StringDecoder('utf-8')\n this._destroyed = false\n}\n\ninherits(LinkSink, Writable)\n\nLinkSink.prototype._write = function (data, enc, cb) {\n this.linkname += this._decoder.write(data)\n cb()\n}\n\nLinkSink.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar Void = function () {\n Writable.call(this)\n this._destroyed = false\n}\n\ninherits(Void, Writable)\n\nVoid.prototype._write = function (data, enc, cb) {\n cb(new Error('No body allowed for this entry'))\n}\n\nVoid.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar Pack = function (opts) {\n if (!(this instanceof Pack)) return new Pack(opts)\n Readable.call(this, opts)\n\n this._drain = noop\n this._finalized = false\n this._finalizing = false\n this._destroyed = false\n this._stream = null\n}\n\ninherits(Pack, Readable)\n\nPack.prototype.entry = function (header, buffer, callback) {\n if (this._stream) throw new Error('already piping an entry')\n if (this._finalized || this._destroyed) return\n\n if (typeof buffer === 'function') {\n callback = buffer\n buffer = null\n }\n\n if (!callback) callback = noop\n\n var self = this\n\n if (!header.size || header.type === 'symlink') header.size = 0\n if (!header.type) header.type = modeToType(header.mode)\n if (!header.mode) header.mode = header.type === 'directory' ? DMODE : FMODE\n if (!header.uid) header.uid = 0\n if (!header.gid) header.gid = 0\n if (!header.mtime) header.mtime = new Date()\n\n if (typeof buffer === 'string') buffer = Buffer.from(buffer)\n if (Buffer.isBuffer(buffer)) {\n header.size = buffer.length\n this._encode(header)\n var ok = this.push(buffer)\n overflow(self, header.size)\n if (ok) process.nextTick(callback)\n else this._drain = callback\n return new Void()\n }\n\n if (header.type === 'symlink' && !header.linkname) {\n var linkSink = new LinkSink()\n eos(linkSink, function (err) {\n if (err) { // stream was closed\n self.destroy()\n return callback(err)\n }\n\n header.linkname = linkSink.linkname\n self._encode(header)\n callback()\n })\n\n return linkSink\n }\n\n this._encode(header)\n\n if (header.type !== 'file' && header.type !== 'contiguous-file') {\n process.nextTick(callback)\n return new Void()\n }\n\n var sink = new Sink(this)\n\n this._stream = sink\n\n eos(sink, function (err) {\n self._stream = null\n\n if (err) { // stream was closed\n self.destroy()\n return callback(err)\n }\n\n if (sink.written !== header.size) { // corrupting tar\n self.destroy()\n return callback(new Error('size mismatch'))\n }\n\n overflow(self, header.size)\n if (self._finalizing) self.finalize()\n callback()\n })\n\n return sink\n}\n\nPack.prototype.finalize = function () {\n if (this._stream) {\n this._finalizing = true\n return\n }\n\n if (this._finalized) return\n this._finalized = true\n this.push(END_OF_TAR)\n this.push(null)\n}\n\nPack.prototype.destroy = function (err) {\n if (this._destroyed) return\n this._destroyed = true\n\n if (err) this.emit('error', err)\n this.emit('close')\n if (this._stream && this._stream.destroy) this._stream.destroy()\n}\n\nPack.prototype._encode = function (header) {\n if (!header.pax) {\n var buf = headers.encode(header)\n if (buf) {\n this.push(buf)\n return\n }\n }\n this._encodePax(header)\n}\n\nPack.prototype._encodePax = function (header) {\n var paxHeader = headers.encodePax({\n name: header.name,\n linkname: header.linkname,\n pax: header.pax\n })\n\n var newHeader = {\n name: 'PaxHeader',\n mode: header.mode,\n uid: header.uid,\n gid: header.gid,\n size: paxHeader.length,\n mtime: header.mtime,\n type: 'pax-header',\n linkname: header.linkname && 'PaxHeader',\n uname: header.uname,\n gname: header.gname,\n devmajor: header.devmajor,\n devminor: header.devminor\n }\n\n this.push(headers.encode(newHeader))\n this.push(paxHeader)\n overflow(this, paxHeader.length)\n\n newHeader.size = header.size\n newHeader.type = header.type\n this.push(headers.encode(newHeader))\n}\n\nPack.prototype._read = function (n) {\n var drain = this._drain\n this._drain = noop\n drain()\n}\n\nmodule.exports = Pack\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = (x[j] + 128) >> 8;\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i, mlen;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n mlen = -1;\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n mlen = n;\n return mlen;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n var t, i;\n for (i = 0; i < arguments.length; i++) {\n if ((t = Object.prototype.toString.call(arguments[i])) !== '[object Uint8Array]')\n throw new TypeError('unexpected type ' + t + ', use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\n// TODO: Completely remove this in v0.15.\nif (!nacl.util) {\n nacl.util = {};\n nacl.util.decodeUTF8 = nacl.util.encodeUTF8 = nacl.util.encodeBase64 = nacl.util.decodeBase64 = function() {\n throw new Error('nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js');\n };\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return false;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return false;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n if (arguments.length !== 2)\n throw new Error('nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?');\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","\n/**\n * For Node.js, simply re-export the core `util.deprecate` function.\n */\n\nmodule.exports = require('util').deprecate;\n","// Returns a wrapper function that returns a wrapped callback\n// The wrapper function should do some stuff, and return a\n// presumably different callback function.\n// This makes sure that own properties are retained, so that\n// decorations and such are not lost along the way.\nmodule.exports = wrappy\nfunction wrappy (fn, cb) {\n if (fn && cb) return wrappy(fn)(cb)\n\n if (typeof fn !== 'function')\n throw new TypeError('need wrapper function')\n\n Object.keys(fn).forEach(function (k) {\n wrapper[k] = fn[k]\n })\n\n return wrapper\n\n function wrapper() {\n var args = new Array(arguments.length)\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i]\n }\n var ret = fn.apply(this, args)\n var cb = args[args.length-1]\n if (typeof ret === 'function' && ret !== cb) {\n Object.keys(cb).forEach(function (k) {\n ret[k] = cb[k]\n })\n }\n return ret\n }\n}\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.run = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst dockerode_1 = __importDefault(require(\"dockerode\"));\nfunction run() {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n const docker = new dockerode_1.default();\n const untilFilter = JSON.stringify({ until: '24h' });\n yield docker.pruneNetworks({ filters: untilFilter });\n yield docker.pruneContainers({ filters: untilFilter });\n }\n catch (error) {\n core.debug(`Error cleaning up: ${error.message}`);\n }\n });\n}\nexports.run = run;\nrun();\n","module.exports = __non_webpack_require__(__webpack_require__.ab + \"build/Release/cpufeatures.node\")","module.exports = __non_webpack_require__(__webpack_require__.ab + \"lib/protocol/crypto/build/Release/sshcrypto.node\")","module.exports = require(\"assert\");","module.exports = require(\"buffer\");","module.exports = require(\"child_process\");","module.exports = require(\"constants\");","module.exports = require(\"crypto\");","module.exports = require(\"dns\");","module.exports = require(\"events\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","module.exports = require(\"net\");","module.exports = require(\"os\");","module.exports = require(\"path\");","module.exports = require(\"querystring\");","module.exports = require(\"stream\");","module.exports = require(\"string_decoder\");","module.exports = require(\"tls\");","module.exports = require(\"tty\");","module.exports = require(\"url\");","module.exports = require(\"util\");","module.exports = require(\"zlib\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\tvar threw = true;\n\ttry {\n\t\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\t\tthrew = false;\n\t} finally {\n\t\tif(threw) delete __webpack_module_cache__[moduleId];\n\t}\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","\nif (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = __dirname + \"/\";","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(3812);\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AChTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5TA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC3iBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC3YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtKA;AACA;AACA;;;A;;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5QA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACpQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1dA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3hCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClvDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7FA;;;A;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACnmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxrBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC9MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACjNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACvGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC/DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AChGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;AC1BA;;;A;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrSA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;ACzNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC79DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC5hEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjsHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjkDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAGA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC7rCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtyDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACx8CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACt1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC/UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;ACvSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3VA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtSA;AACA;;;A;;;;;ACDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACn1EA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClDA;;A;;;;;ACAA;;A;;;;;;A;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7BA;AACA;;;;ACDA;AACA;AACA;AACA;;;;A","sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/command.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/core.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/file-command.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/errors.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/index.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/reader.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/types.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/writer.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/index.js","../webpack://dependabot-updater-action/./node_modules/bcrypt-pbkdf/index.js","../webpack://dependabot-updater-action/./node_modules/bl/BufferList.js","../webpack://dependabot-updater-action/./node_modules/bl/bl.js","../webpack://dependabot-updater-action/./node_modules/chownr/chownr.js","../webpack://dependabot-updater-action/./node_modules/cpu-features/lib/index.js","../webpack://dependabot-updater-action/./node_modules/debug/src/browser.js","../webpack://dependabot-updater-action/./node_modules/debug/src/common.js","../webpack://dependabot-updater-action/./node_modules/debug/src/index.js","../webpack://dependabot-updater-action/./node_modules/debug/src/node.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/http.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/http_duplex.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/modem.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/ssh.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/config.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/container.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/docker.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/exec.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/image.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/network.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/node.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/plugin.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/secret.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/service.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/task.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/util.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/volume.js","../webpack://dependabot-updater-action/./node_modules/end-of-stream/index.js","../webpack://dependabot-updater-action/./node_modules/fs-constants/index.js","../webpack://dependabot-updater-action/./node_modules/has-flag/index.js","../webpack://dependabot-updater-action/./node_modules/inherits/inherits.js","../webpack://dependabot-updater-action/./node_modules/inherits/inherits_browser.js","../webpack://dependabot-updater-action/./node_modules/mkdirp-classic/index.js","../webpack://dependabot-updater-action/./node_modules/ms/index.js","../webpack://dependabot-updater-action/./node_modules/once/once.js","../webpack://dependabot-updater-action/./node_modules/pump/index.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/errors.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_duplex.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_passthrough.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_readable.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_transform.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_writable.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/async_iterator.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/buffer_list.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/destroy.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/end-of-stream.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/from.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/pipeline.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/state.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/stream.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/readable.js","../webpack://dependabot-updater-action/./node_modules/safer-buffer/safer.js","../webpack://dependabot-updater-action/./node_modules/split-ca/index.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/Channel.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/agent.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/client.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/http-agents.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/index.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/Protocol.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/SFTP.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/constants.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto/poly1305.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/handlers.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/handlers.misc.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/kex.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/keyParser.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/node-fs-compat.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/utils.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/zlib.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/server.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/string_decoder/lib/string_decoder.js","../webpack://dependabot-updater-action/./node_modules/string_decoder/node_modules/safe-buffer/index.js","../webpack://dependabot-updater-action/./node_modules/supports-color/index.js","../webpack://dependabot-updater-action/./node_modules/tar-fs/index.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/extract.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/headers.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/index.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/pack.js","../webpack://dependabot-updater-action/./node_modules/tweetnacl/nacl-fast.js","../webpack://dependabot-updater-action/./node_modules/util-deprecate/node.js","../webpack://dependabot-updater-action/./node_modules/wrappy/wrappy.js","../webpack://dependabot-updater-action/./src/cleanup.ts","../webpack://dependabot-updater-action/./node_modules/cpu-features/build/Release/cpufeatures.node","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node","../webpack://dependabot-updater-action/external \"assert\"","../webpack://dependabot-updater-action/external \"buffer\"","../webpack://dependabot-updater-action/external \"child_process\"","../webpack://dependabot-updater-action/external \"constants\"","../webpack://dependabot-updater-action/external \"crypto\"","../webpack://dependabot-updater-action/external \"dns\"","../webpack://dependabot-updater-action/external \"events\"","../webpack://dependabot-updater-action/external \"fs\"","../webpack://dependabot-updater-action/external \"http\"","../webpack://dependabot-updater-action/external \"https\"","../webpack://dependabot-updater-action/external \"net\"","../webpack://dependabot-updater-action/external \"os\"","../webpack://dependabot-updater-action/external \"path\"","../webpack://dependabot-updater-action/external \"querystring\"","../webpack://dependabot-updater-action/external \"stream\"","../webpack://dependabot-updater-action/external \"string_decoder\"","../webpack://dependabot-updater-action/external \"tls\"","../webpack://dependabot-updater-action/external \"tty\"","../webpack://dependabot-updater-action/external \"url\"","../webpack://dependabot-updater-action/external \"util\"","../webpack://dependabot-updater-action/external \"zlib\"","../webpack://dependabot-updater-action/webpack/bootstrap","../webpack://dependabot-updater-action/webpack/runtime/compat","../webpack://dependabot-updater-action/webpack/startup"],"sourcesContent":["\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.issue = exports.issueCommand = void 0;\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\n/**\n * Commands\n *\n * Command Format:\n * ::name key=value,key=value::message\n *\n * Examples:\n * ::warning::This is the message\n * ::set-env name=MY_VAR::some value\n */\nfunction issueCommand(command, properties, message) {\n const cmd = new Command(command, properties, message);\n process.stdout.write(cmd.toString() + os.EOL);\n}\nexports.issueCommand = issueCommand;\nfunction issue(name, message = '') {\n issueCommand(name, {}, message);\n}\nexports.issue = issue;\nconst CMD_STRING = '::';\nclass Command {\n constructor(command, properties, message) {\n if (!command) {\n command = 'missing.command';\n }\n this.command = command;\n this.properties = properties;\n this.message = message;\n }\n toString() {\n let cmdStr = CMD_STRING + this.command;\n if (this.properties && Object.keys(this.properties).length > 0) {\n cmdStr += ' ';\n let first = true;\n for (const key in this.properties) {\n if (this.properties.hasOwnProperty(key)) {\n const val = this.properties[key];\n if (val) {\n if (first) {\n first = false;\n }\n else {\n cmdStr += ',';\n }\n cmdStr += `${key}=${escapeProperty(val)}`;\n }\n }\n }\n }\n cmdStr += `${CMD_STRING}${escapeData(this.message)}`;\n return cmdStr;\n }\n}\nfunction escapeData(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A');\n}\nfunction escapeProperty(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A')\n .replace(/:/g, '%3A')\n .replace(/,/g, '%2C');\n}\n//# sourceMappingURL=command.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;\nconst command_1 = require(\"./command\");\nconst file_command_1 = require(\"./file-command\");\nconst utils_1 = require(\"./utils\");\nconst os = __importStar(require(\"os\"));\nconst path = __importStar(require(\"path\"));\n/**\n * The code to exit an action\n */\nvar ExitCode;\n(function (ExitCode) {\n /**\n * A code indicating that the action was successful\n */\n ExitCode[ExitCode[\"Success\"] = 0] = \"Success\";\n /**\n * A code indicating that the action was a failure\n */\n ExitCode[ExitCode[\"Failure\"] = 1] = \"Failure\";\n})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));\n//-----------------------------------------------------------------------\n// Variables\n//-----------------------------------------------------------------------\n/**\n * Sets env variable for this action and future actions in the job\n * @param name the name of the variable to set\n * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction exportVariable(name, val) {\n const convertedVal = utils_1.toCommandValue(val);\n process.env[name] = convertedVal;\n const filePath = process.env['GITHUB_ENV'] || '';\n if (filePath) {\n const delimiter = '_GitHubActionsFileCommandDelimeter_';\n const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;\n file_command_1.issueCommand('ENV', commandValue);\n }\n else {\n command_1.issueCommand('set-env', { name }, convertedVal);\n }\n}\nexports.exportVariable = exportVariable;\n/**\n * Registers a secret which will get masked from logs\n * @param secret value of the secret\n */\nfunction setSecret(secret) {\n command_1.issueCommand('add-mask', {}, secret);\n}\nexports.setSecret = setSecret;\n/**\n * Prepends inputPath to the PATH (for this action and future actions)\n * @param inputPath\n */\nfunction addPath(inputPath) {\n const filePath = process.env['GITHUB_PATH'] || '';\n if (filePath) {\n file_command_1.issueCommand('PATH', inputPath);\n }\n else {\n command_1.issueCommand('add-path', {}, inputPath);\n }\n process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;\n}\nexports.addPath = addPath;\n/**\n * Gets the value of an input.\n * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.\n * Returns an empty string if the value is not defined.\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns string\n */\nfunction getInput(name, options) {\n const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';\n if (options && options.required && !val) {\n throw new Error(`Input required and not supplied: ${name}`);\n }\n if (options && options.trimWhitespace === false) {\n return val;\n }\n return val.trim();\n}\nexports.getInput = getInput;\n/**\n * Gets the values of an multiline input. Each value is also trimmed.\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns string[]\n *\n */\nfunction getMultilineInput(name, options) {\n const inputs = getInput(name, options)\n .split('\\n')\n .filter(x => x !== '');\n return inputs;\n}\nexports.getMultilineInput = getMultilineInput;\n/**\n * Gets the input value of the boolean type in the YAML 1.2 \"core schema\" specification.\n * Support boolean input list: `true | True | TRUE | false | False | FALSE` .\n * The return value is also in boolean type.\n * ref: https://yaml.org/spec/1.2/spec.html#id2804923\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns boolean\n */\nfunction getBooleanInput(name, options) {\n const trueValue = ['true', 'True', 'TRUE'];\n const falseValue = ['false', 'False', 'FALSE'];\n const val = getInput(name, options);\n if (trueValue.includes(val))\n return true;\n if (falseValue.includes(val))\n return false;\n throw new TypeError(`Input does not meet YAML 1.2 \"Core Schema\" specification: ${name}\\n` +\n `Support boolean input list: \\`true | True | TRUE | false | False | FALSE\\``);\n}\nexports.getBooleanInput = getBooleanInput;\n/**\n * Sets the value of an output.\n *\n * @param name name of the output to set\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction setOutput(name, value) {\n process.stdout.write(os.EOL);\n command_1.issueCommand('set-output', { name }, value);\n}\nexports.setOutput = setOutput;\n/**\n * Enables or disables the echoing of commands into stdout for the rest of the step.\n * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.\n *\n */\nfunction setCommandEcho(enabled) {\n command_1.issue('echo', enabled ? 'on' : 'off');\n}\nexports.setCommandEcho = setCommandEcho;\n//-----------------------------------------------------------------------\n// Results\n//-----------------------------------------------------------------------\n/**\n * Sets the action status to failed.\n * When the action exits it will be with an exit code of 1\n * @param message add error issue message\n */\nfunction setFailed(message) {\n process.exitCode = ExitCode.Failure;\n error(message);\n}\nexports.setFailed = setFailed;\n//-----------------------------------------------------------------------\n// Logging Commands\n//-----------------------------------------------------------------------\n/**\n * Gets whether Actions Step Debug is on or not\n */\nfunction isDebug() {\n return process.env['RUNNER_DEBUG'] === '1';\n}\nexports.isDebug = isDebug;\n/**\n * Writes debug message to user log\n * @param message debug message\n */\nfunction debug(message) {\n command_1.issueCommand('debug', {}, message);\n}\nexports.debug = debug;\n/**\n * Adds an error issue\n * @param message error issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction error(message, properties = {}) {\n command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.error = error;\n/**\n * Adds a warning issue\n * @param message warning issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction warning(message, properties = {}) {\n command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.warning = warning;\n/**\n * Adds a notice issue\n * @param message notice issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction notice(message, properties = {}) {\n command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.notice = notice;\n/**\n * Writes info to log with console.log.\n * @param message info message\n */\nfunction info(message) {\n process.stdout.write(message + os.EOL);\n}\nexports.info = info;\n/**\n * Begin an output group.\n *\n * Output until the next `groupEnd` will be foldable in this group\n *\n * @param name The name of the output group\n */\nfunction startGroup(name) {\n command_1.issue('group', name);\n}\nexports.startGroup = startGroup;\n/**\n * End an output group.\n */\nfunction endGroup() {\n command_1.issue('endgroup');\n}\nexports.endGroup = endGroup;\n/**\n * Wrap an asynchronous function call in a group.\n *\n * Returns the same type as the function itself.\n *\n * @param name The name of the group\n * @param fn The function to wrap in the group\n */\nfunction group(name, fn) {\n return __awaiter(this, void 0, void 0, function* () {\n startGroup(name);\n let result;\n try {\n result = yield fn();\n }\n finally {\n endGroup();\n }\n return result;\n });\n}\nexports.group = group;\n//-----------------------------------------------------------------------\n// Wrapper action state\n//-----------------------------------------------------------------------\n/**\n * Saves state for current action, the state can only be retrieved by this action's post job execution.\n *\n * @param name name of the state to store\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction saveState(name, value) {\n command_1.issueCommand('save-state', { name }, value);\n}\nexports.saveState = saveState;\n/**\n * Gets the value of an state set by this action's main execution.\n *\n * @param name name of the state to get\n * @returns string\n */\nfunction getState(name) {\n return process.env[`STATE_${name}`] || '';\n}\nexports.getState = getState;\n//# sourceMappingURL=core.js.map","\"use strict\";\n// For internal use, subject to change.\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.issueCommand = void 0;\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst fs = __importStar(require(\"fs\"));\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\nfunction issueCommand(command, message) {\n const filePath = process.env[`GITHUB_${command}`];\n if (!filePath) {\n throw new Error(`Unable to find environment variable for file command ${command}`);\n }\n if (!fs.existsSync(filePath)) {\n throw new Error(`Missing file at path: ${filePath}`);\n }\n fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {\n encoding: 'utf8'\n });\n}\nexports.issueCommand = issueCommand;\n//# sourceMappingURL=file-command.js.map","\"use strict\";\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.toCommandProperties = exports.toCommandValue = void 0;\n/**\n * Sanitizes an input into a string so it can be passed into issueCommand safely\n * @param input input to sanitize into a string\n */\nfunction toCommandValue(input) {\n if (input === null || input === undefined) {\n return '';\n }\n else if (typeof input === 'string' || input instanceof String) {\n return input;\n }\n return JSON.stringify(input);\n}\nexports.toCommandValue = toCommandValue;\n/**\n *\n * @param annotationProperties\n * @returns The command properties to send with the actual annotation command\n * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646\n */\nfunction toCommandProperties(annotationProperties) {\n if (!Object.keys(annotationProperties).length) {\n return {};\n }\n return {\n title: annotationProperties.title,\n line: annotationProperties.startLine,\n endLine: annotationProperties.endLine,\n col: annotationProperties.startColumn,\n endColumn: annotationProperties.endColumn\n };\n}\nexports.toCommandProperties = toCommandProperties;\n//# sourceMappingURL=utils.js.map","// Copyright 2011 Mark Cavage All rights reserved.\n\n\nmodule.exports = {\n\n newInvalidAsn1Error: function (msg) {\n var e = new Error();\n e.name = 'InvalidAsn1Error';\n e.message = msg || '';\n return e;\n }\n\n};\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar errors = require('./errors');\nvar types = require('./types');\n\nvar Reader = require('./reader');\nvar Writer = require('./writer');\n\n\n// --- Exports\n\nmodule.exports = {\n\n Reader: Reader,\n\n Writer: Writer\n\n};\n\nfor (var t in types) {\n if (types.hasOwnProperty(t))\n module.exports[t] = types[t];\n}\nfor (var e in errors) {\n if (errors.hasOwnProperty(e))\n module.exports[e] = errors[e];\n}\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar assert = require('assert');\nvar Buffer = require('safer-buffer').Buffer;\n\nvar ASN1 = require('./types');\nvar errors = require('./errors');\n\n\n// --- Globals\n\nvar newInvalidAsn1Error = errors.newInvalidAsn1Error;\n\n\n\n// --- API\n\nfunction Reader(data) {\n if (!data || !Buffer.isBuffer(data))\n throw new TypeError('data must be a node Buffer');\n\n this._buf = data;\n this._size = data.length;\n\n // These hold the \"current\" state\n this._len = 0;\n this._offset = 0;\n}\n\nObject.defineProperty(Reader.prototype, 'length', {\n enumerable: true,\n get: function () { return (this._len); }\n});\n\nObject.defineProperty(Reader.prototype, 'offset', {\n enumerable: true,\n get: function () { return (this._offset); }\n});\n\nObject.defineProperty(Reader.prototype, 'remain', {\n get: function () { return (this._size - this._offset); }\n});\n\nObject.defineProperty(Reader.prototype, 'buffer', {\n get: function () { return (this._buf.slice(this._offset)); }\n});\n\n\n/**\n * Reads a single byte and advances offset; you can pass in `true` to make this\n * a \"peek\" operation (i.e., get the byte, but don't advance the offset).\n *\n * @param {Boolean} peek true means don't move offset.\n * @return {Number} the next byte, null if not enough data.\n */\nReader.prototype.readByte = function (peek) {\n if (this._size - this._offset < 1)\n return null;\n\n var b = this._buf[this._offset] & 0xff;\n\n if (!peek)\n this._offset += 1;\n\n return b;\n};\n\n\nReader.prototype.peek = function () {\n return this.readByte(true);\n};\n\n\n/**\n * Reads a (potentially) variable length off the BER buffer. This call is\n * not really meant to be called directly, as callers have to manipulate\n * the internal buffer afterwards.\n *\n * As a result of this call, you can call `Reader.length`, until the\n * next thing called that does a readLength.\n *\n * @return {Number} the amount of offset to advance the buffer.\n * @throws {InvalidAsn1Error} on bad ASN.1\n */\nReader.prototype.readLength = function (offset) {\n if (offset === undefined)\n offset = this._offset;\n\n if (offset >= this._size)\n return null;\n\n var lenB = this._buf[offset++] & 0xff;\n if (lenB === null)\n return null;\n\n if ((lenB & 0x80) === 0x80) {\n lenB &= 0x7f;\n\n if (lenB === 0)\n throw newInvalidAsn1Error('Indefinite length not supported');\n\n if (lenB > 4)\n throw newInvalidAsn1Error('encoding too long');\n\n if (this._size - offset < lenB)\n return null;\n\n this._len = 0;\n for (var i = 0; i < lenB; i++)\n this._len = (this._len << 8) + (this._buf[offset++] & 0xff);\n\n } else {\n // Wasn't a variable length\n this._len = lenB;\n }\n\n return offset;\n};\n\n\n/**\n * Parses the next sequence in this BER buffer.\n *\n * To get the length of the sequence, call `Reader.length`.\n *\n * @return {Number} the sequence's tag.\n */\nReader.prototype.readSequence = function (tag) {\n var seq = this.peek();\n if (seq === null)\n return null;\n if (tag !== undefined && tag !== seq)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + seq.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n if (o === null)\n return null;\n\n this._offset = o;\n return seq;\n};\n\n\nReader.prototype.readInt = function () {\n return this._readTag(ASN1.Integer);\n};\n\n\nReader.prototype.readBoolean = function () {\n return (this._readTag(ASN1.Boolean) === 0 ? false : true);\n};\n\n\nReader.prototype.readEnumeration = function () {\n return this._readTag(ASN1.Enumeration);\n};\n\n\nReader.prototype.readString = function (tag, retbuf) {\n if (!tag)\n tag = ASN1.OctetString;\n\n var b = this.peek();\n if (b === null)\n return null;\n\n if (b !== tag)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + b.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n\n if (o === null)\n return null;\n\n if (this.length > this._size - o)\n return null;\n\n this._offset = o;\n\n if (this.length === 0)\n return retbuf ? Buffer.alloc(0) : '';\n\n var str = this._buf.slice(this._offset, this._offset + this.length);\n this._offset += this.length;\n\n return retbuf ? str : str.toString('utf8');\n};\n\nReader.prototype.readOID = function (tag) {\n if (!tag)\n tag = ASN1.OID;\n\n var b = this.readString(tag, true);\n if (b === null)\n return null;\n\n var values = [];\n var value = 0;\n\n for (var i = 0; i < b.length; i++) {\n var byte = b[i] & 0xff;\n\n value <<= 7;\n value += byte & 0x7f;\n if ((byte & 0x80) === 0) {\n values.push(value);\n value = 0;\n }\n }\n\n value = values.shift();\n values.unshift(value % 40);\n values.unshift((value / 40) >> 0);\n\n return values.join('.');\n};\n\n\nReader.prototype._readTag = function (tag) {\n assert.ok(tag !== undefined);\n\n var b = this.peek();\n\n if (b === null)\n return null;\n\n if (b !== tag)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + b.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n if (o === null)\n return null;\n\n if (this.length > 4)\n throw newInvalidAsn1Error('Integer too long: ' + this.length);\n\n if (this.length > this._size - o)\n return null;\n this._offset = o;\n\n var fb = this._buf[this._offset];\n var value = 0;\n\n for (var i = 0; i < this.length; i++) {\n value <<= 8;\n value |= (this._buf[this._offset++] & 0xff);\n }\n\n if ((fb & 0x80) === 0x80 && i !== 4)\n value -= (1 << (i * 8));\n\n return value >> 0;\n};\n\n\n\n// --- Exported API\n\nmodule.exports = Reader;\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n\nmodule.exports = {\n EOC: 0,\n Boolean: 1,\n Integer: 2,\n BitString: 3,\n OctetString: 4,\n Null: 5,\n OID: 6,\n ObjectDescriptor: 7,\n External: 8,\n Real: 9, // float\n Enumeration: 10,\n PDV: 11,\n Utf8String: 12,\n RelativeOID: 13,\n Sequence: 16,\n Set: 17,\n NumericString: 18,\n PrintableString: 19,\n T61String: 20,\n VideotexString: 21,\n IA5String: 22,\n UTCTime: 23,\n GeneralizedTime: 24,\n GraphicString: 25,\n VisibleString: 26,\n GeneralString: 28,\n UniversalString: 29,\n CharacterString: 30,\n BMPString: 31,\n Constructor: 32,\n Context: 128\n};\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar assert = require('assert');\nvar Buffer = require('safer-buffer').Buffer;\nvar ASN1 = require('./types');\nvar errors = require('./errors');\n\n\n// --- Globals\n\nvar newInvalidAsn1Error = errors.newInvalidAsn1Error;\n\nvar DEFAULT_OPTS = {\n size: 1024,\n growthFactor: 8\n};\n\n\n// --- Helpers\n\nfunction merge(from, to) {\n assert.ok(from);\n assert.equal(typeof (from), 'object');\n assert.ok(to);\n assert.equal(typeof (to), 'object');\n\n var keys = Object.getOwnPropertyNames(from);\n keys.forEach(function (key) {\n if (to[key])\n return;\n\n var value = Object.getOwnPropertyDescriptor(from, key);\n Object.defineProperty(to, key, value);\n });\n\n return to;\n}\n\n\n\n// --- API\n\nfunction Writer(options) {\n options = merge(DEFAULT_OPTS, options || {});\n\n this._buf = Buffer.alloc(options.size || 1024);\n this._size = this._buf.length;\n this._offset = 0;\n this._options = options;\n\n // A list of offsets in the buffer where we need to insert\n // sequence tag/len pairs.\n this._seq = [];\n}\n\nObject.defineProperty(Writer.prototype, 'buffer', {\n get: function () {\n if (this._seq.length)\n throw newInvalidAsn1Error(this._seq.length + ' unended sequence(s)');\n\n return (this._buf.slice(0, this._offset));\n }\n});\n\nWriter.prototype.writeByte = function (b) {\n if (typeof (b) !== 'number')\n throw new TypeError('argument must be a Number');\n\n this._ensure(1);\n this._buf[this._offset++] = b;\n};\n\n\nWriter.prototype.writeInt = function (i, tag) {\n if (typeof (i) !== 'number')\n throw new TypeError('argument must be a Number');\n if (typeof (tag) !== 'number')\n tag = ASN1.Integer;\n\n var sz = 4;\n\n while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&\n (sz > 1)) {\n sz--;\n i <<= 8;\n }\n\n if (sz > 4)\n throw newInvalidAsn1Error('BER ints cannot be > 0xffffffff');\n\n this._ensure(2 + sz);\n this._buf[this._offset++] = tag;\n this._buf[this._offset++] = sz;\n\n while (sz-- > 0) {\n this._buf[this._offset++] = ((i & 0xff000000) >>> 24);\n i <<= 8;\n }\n\n};\n\n\nWriter.prototype.writeNull = function () {\n this.writeByte(ASN1.Null);\n this.writeByte(0x00);\n};\n\n\nWriter.prototype.writeEnumeration = function (i, tag) {\n if (typeof (i) !== 'number')\n throw new TypeError('argument must be a Number');\n if (typeof (tag) !== 'number')\n tag = ASN1.Enumeration;\n\n return this.writeInt(i, tag);\n};\n\n\nWriter.prototype.writeBoolean = function (b, tag) {\n if (typeof (b) !== 'boolean')\n throw new TypeError('argument must be a Boolean');\n if (typeof (tag) !== 'number')\n tag = ASN1.Boolean;\n\n this._ensure(3);\n this._buf[this._offset++] = tag;\n this._buf[this._offset++] = 0x01;\n this._buf[this._offset++] = b ? 0xff : 0x00;\n};\n\n\nWriter.prototype.writeString = function (s, tag) {\n if (typeof (s) !== 'string')\n throw new TypeError('argument must be a string (was: ' + typeof (s) + ')');\n if (typeof (tag) !== 'number')\n tag = ASN1.OctetString;\n\n var len = Buffer.byteLength(s);\n this.writeByte(tag);\n this.writeLength(len);\n if (len) {\n this._ensure(len);\n this._buf.write(s, this._offset);\n this._offset += len;\n }\n};\n\n\nWriter.prototype.writeBuffer = function (buf, tag) {\n if (typeof (tag) !== 'number')\n throw new TypeError('tag must be a number');\n if (!Buffer.isBuffer(buf))\n throw new TypeError('argument must be a buffer');\n\n this.writeByte(tag);\n this.writeLength(buf.length);\n this._ensure(buf.length);\n buf.copy(this._buf, this._offset, 0, buf.length);\n this._offset += buf.length;\n};\n\n\nWriter.prototype.writeStringArray = function (strings) {\n if ((!strings instanceof Array))\n throw new TypeError('argument must be an Array[String]');\n\n var self = this;\n strings.forEach(function (s) {\n self.writeString(s);\n });\n};\n\n// This is really to solve DER cases, but whatever for now\nWriter.prototype.writeOID = function (s, tag) {\n if (typeof (s) !== 'string')\n throw new TypeError('argument must be a string');\n if (typeof (tag) !== 'number')\n tag = ASN1.OID;\n\n if (!/^([0-9]+\\.){3,}[0-9]+$/.test(s))\n throw new Error('argument is not a valid OID string');\n\n function encodeOctet(bytes, octet) {\n if (octet < 128) {\n bytes.push(octet);\n } else if (octet < 16384) {\n bytes.push((octet >>> 7) | 0x80);\n bytes.push(octet & 0x7F);\n } else if (octet < 2097152) {\n bytes.push((octet >>> 14) | 0x80);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n } else if (octet < 268435456) {\n bytes.push((octet >>> 21) | 0x80);\n bytes.push(((octet >>> 14) | 0x80) & 0xFF);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n } else {\n bytes.push(((octet >>> 28) | 0x80) & 0xFF);\n bytes.push(((octet >>> 21) | 0x80) & 0xFF);\n bytes.push(((octet >>> 14) | 0x80) & 0xFF);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n }\n }\n\n var tmp = s.split('.');\n var bytes = [];\n bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));\n tmp.slice(2).forEach(function (b) {\n encodeOctet(bytes, parseInt(b, 10));\n });\n\n var self = this;\n this._ensure(2 + bytes.length);\n this.writeByte(tag);\n this.writeLength(bytes.length);\n bytes.forEach(function (b) {\n self.writeByte(b);\n });\n};\n\n\nWriter.prototype.writeLength = function (len) {\n if (typeof (len) !== 'number')\n throw new TypeError('argument must be a Number');\n\n this._ensure(4);\n\n if (len <= 0x7f) {\n this._buf[this._offset++] = len;\n } else if (len <= 0xff) {\n this._buf[this._offset++] = 0x81;\n this._buf[this._offset++] = len;\n } else if (len <= 0xffff) {\n this._buf[this._offset++] = 0x82;\n this._buf[this._offset++] = len >> 8;\n this._buf[this._offset++] = len;\n } else if (len <= 0xffffff) {\n this._buf[this._offset++] = 0x83;\n this._buf[this._offset++] = len >> 16;\n this._buf[this._offset++] = len >> 8;\n this._buf[this._offset++] = len;\n } else {\n throw newInvalidAsn1Error('Length too long (> 4 bytes)');\n }\n};\n\nWriter.prototype.startSequence = function (tag) {\n if (typeof (tag) !== 'number')\n tag = ASN1.Sequence | ASN1.Constructor;\n\n this.writeByte(tag);\n this._seq.push(this._offset);\n this._ensure(3);\n this._offset += 3;\n};\n\n\nWriter.prototype.endSequence = function () {\n var seq = this._seq.pop();\n var start = seq + 3;\n var len = this._offset - start;\n\n if (len <= 0x7f) {\n this._shift(start, len, -2);\n this._buf[seq] = len;\n } else if (len <= 0xff) {\n this._shift(start, len, -1);\n this._buf[seq] = 0x81;\n this._buf[seq + 1] = len;\n } else if (len <= 0xffff) {\n this._buf[seq] = 0x82;\n this._buf[seq + 1] = len >> 8;\n this._buf[seq + 2] = len;\n } else if (len <= 0xffffff) {\n this._shift(start, len, 1);\n this._buf[seq] = 0x83;\n this._buf[seq + 1] = len >> 16;\n this._buf[seq + 2] = len >> 8;\n this._buf[seq + 3] = len;\n } else {\n throw newInvalidAsn1Error('Sequence too long');\n }\n};\n\n\nWriter.prototype._shift = function (start, len, shift) {\n assert.ok(start !== undefined);\n assert.ok(len !== undefined);\n assert.ok(shift);\n\n this._buf.copy(this._buf, start + shift, start, start + len);\n this._offset += shift;\n};\n\nWriter.prototype._ensure = function (len) {\n assert.ok(len);\n\n if (this._size - this._offset < len) {\n var sz = this._size * this._options.growthFactor;\n if (sz - this._offset < len)\n sz += len;\n\n var buf = Buffer.alloc(sz);\n\n this._buf.copy(buf, 0, 0, this._offset);\n this._buf = buf;\n this._size = sz;\n }\n};\n\n\n\n// --- Exported API\n\nmodule.exports = Writer;\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n// If you have no idea what ASN.1 or BER is, see this:\n// ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc\n\nvar Ber = require('./ber/index');\n\n\n\n// --- Exported API\n\nmodule.exports = {\n\n Ber: Ber,\n\n BerReader: Ber.Reader,\n\n BerWriter: Ber.Writer\n\n};\n","'use strict';\n\nvar crypto_hash_sha512 = require('tweetnacl').lowlevel.crypto_hash;\n\n/*\n * This file is a 1:1 port from the OpenBSD blowfish.c and bcrypt_pbkdf.c. As a\n * result, it retains the original copyright and license. The two files are\n * under slightly different (but compatible) licenses, and are here combined in\n * one file.\n *\n * Credit for the actual porting work goes to:\n * Devi Mandiri \n */\n\n/*\n * The Blowfish portions are under the following license:\n *\n * Blowfish block cipher for OpenBSD\n * Copyright 1997 Niels Provos \n * All rights reserved.\n *\n * Implementation advice by David Mazieres .\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. The name of the author may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*\n * The bcrypt_pbkdf portions are under the following license:\n *\n * Copyright (c) 2013 Ted Unangst \n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n/*\n * Performance improvements (Javascript-specific):\n *\n * Copyright 2016, Joyent Inc\n * Author: Alex Wilson \n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n// Ported from OpenBSD bcrypt_pbkdf.c v1.9\n\nvar BLF_J = 0;\n\nvar Blowfish = function() {\n this.S = [\n new Uint32Array([\n 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,\n 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,\n 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,\n 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,\n 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,\n 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,\n 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,\n 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,\n 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,\n 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,\n 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,\n 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,\n 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,\n 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,\n 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,\n 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,\n 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,\n 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,\n 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,\n 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,\n 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,\n 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,\n 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,\n 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,\n 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,\n 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,\n 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,\n 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,\n 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,\n 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,\n 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,\n 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,\n 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,\n 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,\n 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,\n 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,\n 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,\n 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,\n 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,\n 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,\n 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,\n 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,\n 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,\n 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,\n 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,\n 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,\n 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,\n 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,\n 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,\n 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,\n 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,\n 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,\n 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,\n 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,\n 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,\n 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,\n 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,\n 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,\n 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,\n 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,\n 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,\n 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,\n 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,\n 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a]),\n new Uint32Array([\n 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,\n 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,\n 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,\n 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,\n 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,\n 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,\n 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,\n 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,\n 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,\n 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,\n 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,\n 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,\n 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,\n 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,\n 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,\n 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,\n 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,\n 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,\n 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,\n 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,\n 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,\n 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,\n 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,\n 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,\n 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,\n 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,\n 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,\n 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,\n 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,\n 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,\n 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,\n 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,\n 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,\n 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,\n 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,\n 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,\n 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,\n 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,\n 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,\n 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,\n 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,\n 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,\n 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,\n 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,\n 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,\n 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,\n 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,\n 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,\n 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,\n 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,\n 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,\n 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,\n 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,\n 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,\n 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,\n 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,\n 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,\n 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,\n 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,\n 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,\n 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,\n 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,\n 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,\n 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7]),\n new Uint32Array([\n 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,\n 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,\n 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,\n 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,\n 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,\n 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,\n 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,\n 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,\n 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,\n 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,\n 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,\n 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,\n 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,\n 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,\n 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,\n 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,\n 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,\n 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,\n 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,\n 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,\n 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,\n 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,\n 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,\n 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,\n 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,\n 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,\n 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,\n 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,\n 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,\n 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,\n 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,\n 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,\n 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,\n 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,\n 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,\n 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,\n 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,\n 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,\n 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,\n 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,\n 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,\n 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,\n 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,\n 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,\n 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,\n 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,\n 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,\n 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,\n 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,\n 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,\n 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,\n 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,\n 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,\n 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,\n 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,\n 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,\n 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,\n 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,\n 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,\n 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,\n 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,\n 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,\n 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,\n 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0]),\n new Uint32Array([\n 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,\n 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,\n 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,\n 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,\n 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,\n 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,\n 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,\n 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,\n 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,\n 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,\n 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,\n 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,\n 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,\n 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,\n 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,\n 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,\n 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,\n 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,\n 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,\n 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,\n 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,\n 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,\n 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,\n 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,\n 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,\n 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,\n 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,\n 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,\n 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,\n 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,\n 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,\n 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,\n 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,\n 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,\n 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,\n 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,\n 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,\n 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,\n 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,\n 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,\n 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,\n 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,\n 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,\n 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,\n 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,\n 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,\n 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,\n 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,\n 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,\n 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,\n 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,\n 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,\n 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,\n 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,\n 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,\n 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,\n 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,\n 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,\n 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,\n 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,\n 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,\n 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,\n 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,\n 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6])\n ];\n this.P = new Uint32Array([\n 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,\n 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,\n 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,\n 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,\n 0x9216d5d9, 0x8979fb1b]);\n};\n\nfunction F(S, x8, i) {\n return (((S[0][x8[i+3]] +\n S[1][x8[i+2]]) ^\n S[2][x8[i+1]]) +\n S[3][x8[i]]);\n};\n\nBlowfish.prototype.encipher = function(x, x8) {\n if (x8 === undefined) {\n x8 = new Uint8Array(x.buffer);\n if (x.byteOffset !== 0)\n x8 = x8.subarray(x.byteOffset);\n }\n x[0] ^= this.P[0];\n for (var i = 1; i < 16; i += 2) {\n x[1] ^= F(this.S, x8, 0) ^ this.P[i];\n x[0] ^= F(this.S, x8, 4) ^ this.P[i+1];\n }\n var t = x[0];\n x[0] = x[1] ^ this.P[17];\n x[1] = t;\n};\n\nBlowfish.prototype.decipher = function(x) {\n var x8 = new Uint8Array(x.buffer);\n if (x.byteOffset !== 0)\n x8 = x8.subarray(x.byteOffset);\n x[0] ^= this.P[17];\n for (var i = 16; i > 0; i -= 2) {\n x[1] ^= F(this.S, x8, 0) ^ this.P[i];\n x[0] ^= F(this.S, x8, 4) ^ this.P[i-1];\n }\n var t = x[0];\n x[0] = x[1] ^ this.P[0];\n x[1] = t;\n};\n\nfunction stream2word(data, databytes){\n var i, temp = 0;\n for (i = 0; i < 4; i++, BLF_J++) {\n if (BLF_J >= databytes) BLF_J = 0;\n temp = (temp << 8) | data[BLF_J];\n }\n return temp;\n};\n\nBlowfish.prototype.expand0state = function(key, keybytes) {\n var d = new Uint32Array(2), i, k;\n var d8 = new Uint8Array(d.buffer);\n\n for (i = 0, BLF_J = 0; i < 18; i++) {\n this.P[i] ^= stream2word(key, keybytes);\n }\n BLF_J = 0;\n\n for (i = 0; i < 18; i += 2) {\n this.encipher(d, d8);\n this.P[i] = d[0];\n this.P[i+1] = d[1];\n }\n\n for (i = 0; i < 4; i++) {\n for (k = 0; k < 256; k += 2) {\n this.encipher(d, d8);\n this.S[i][k] = d[0];\n this.S[i][k+1] = d[1];\n }\n }\n};\n\nBlowfish.prototype.expandstate = function(data, databytes, key, keybytes) {\n var d = new Uint32Array(2), i, k;\n\n for (i = 0, BLF_J = 0; i < 18; i++) {\n this.P[i] ^= stream2word(key, keybytes);\n }\n\n for (i = 0, BLF_J = 0; i < 18; i += 2) {\n d[0] ^= stream2word(data, databytes);\n d[1] ^= stream2word(data, databytes);\n this.encipher(d);\n this.P[i] = d[0];\n this.P[i+1] = d[1];\n }\n\n for (i = 0; i < 4; i++) {\n for (k = 0; k < 256; k += 2) {\n d[0] ^= stream2word(data, databytes);\n d[1] ^= stream2word(data, databytes);\n this.encipher(d);\n this.S[i][k] = d[0];\n this.S[i][k+1] = d[1];\n }\n }\n BLF_J = 0;\n};\n\nBlowfish.prototype.enc = function(data, blocks) {\n for (var i = 0; i < blocks; i++) {\n this.encipher(data.subarray(i*2));\n }\n};\n\nBlowfish.prototype.dec = function(data, blocks) {\n for (var i = 0; i < blocks; i++) {\n this.decipher(data.subarray(i*2));\n }\n};\n\nvar BCRYPT_BLOCKS = 8,\n BCRYPT_HASHSIZE = 32;\n\nfunction bcrypt_hash(sha2pass, sha2salt, out) {\n var state = new Blowfish(),\n cdata = new Uint32Array(BCRYPT_BLOCKS), i,\n ciphertext = new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,\n 99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,\n 105,116,101]); //\"OxychromaticBlowfishSwatDynamite\"\n\n state.expandstate(sha2salt, 64, sha2pass, 64);\n for (i = 0; i < 64; i++) {\n state.expand0state(sha2salt, 64);\n state.expand0state(sha2pass, 64);\n }\n\n for (i = 0; i < BCRYPT_BLOCKS; i++)\n cdata[i] = stream2word(ciphertext, ciphertext.byteLength);\n for (i = 0; i < 64; i++)\n state.enc(cdata, cdata.byteLength / 8);\n\n for (i = 0; i < BCRYPT_BLOCKS; i++) {\n out[4*i+3] = cdata[i] >>> 24;\n out[4*i+2] = cdata[i] >>> 16;\n out[4*i+1] = cdata[i] >>> 8;\n out[4*i+0] = cdata[i];\n }\n};\n\nfunction bcrypt_pbkdf(pass, passlen, salt, saltlen, key, keylen, rounds) {\n var sha2pass = new Uint8Array(64),\n sha2salt = new Uint8Array(64),\n out = new Uint8Array(BCRYPT_HASHSIZE),\n tmpout = new Uint8Array(BCRYPT_HASHSIZE),\n countsalt = new Uint8Array(saltlen+4),\n i, j, amt, stride, dest, count,\n origkeylen = keylen;\n\n if (rounds < 1)\n return -1;\n if (passlen === 0 || saltlen === 0 || keylen === 0 ||\n keylen > (out.byteLength * out.byteLength) || saltlen > (1<<20))\n return -1;\n\n stride = Math.floor((keylen + out.byteLength - 1) / out.byteLength);\n amt = Math.floor((keylen + stride - 1) / stride);\n\n for (i = 0; i < saltlen; i++)\n countsalt[i] = salt[i];\n\n crypto_hash_sha512(sha2pass, pass, passlen);\n\n for (count = 1; keylen > 0; count++) {\n countsalt[saltlen+0] = count >>> 24;\n countsalt[saltlen+1] = count >>> 16;\n countsalt[saltlen+2] = count >>> 8;\n countsalt[saltlen+3] = count;\n\n crypto_hash_sha512(sha2salt, countsalt, saltlen + 4);\n bcrypt_hash(sha2pass, sha2salt, tmpout);\n for (i = out.byteLength; i--;)\n out[i] = tmpout[i];\n\n for (i = 1; i < rounds; i++) {\n crypto_hash_sha512(sha2salt, tmpout, tmpout.byteLength);\n bcrypt_hash(sha2pass, sha2salt, tmpout);\n for (j = 0; j < out.byteLength; j++)\n out[j] ^= tmpout[j];\n }\n\n amt = Math.min(amt, keylen);\n for (i = 0; i < amt; i++) {\n dest = i * stride + (count - 1);\n if (dest >= origkeylen)\n break;\n key[dest] = out[i];\n }\n keylen -= i;\n }\n\n return 0;\n};\n\nmodule.exports = {\n BLOCKS: BCRYPT_BLOCKS,\n HASHSIZE: BCRYPT_HASHSIZE,\n hash: bcrypt_hash,\n pbkdf: bcrypt_pbkdf\n};\n","'use strict'\n\nconst { Buffer } = require('buffer')\nconst symbol = Symbol.for('BufferList')\n\nfunction BufferList (buf) {\n if (!(this instanceof BufferList)) {\n return new BufferList(buf)\n }\n\n BufferList._init.call(this, buf)\n}\n\nBufferList._init = function _init (buf) {\n Object.defineProperty(this, symbol, { value: true })\n\n this._bufs = []\n this.length = 0\n\n if (buf) {\n this.append(buf)\n }\n}\n\nBufferList.prototype._new = function _new (buf) {\n return new BufferList(buf)\n}\n\nBufferList.prototype._offset = function _offset (offset) {\n if (offset === 0) {\n return [0, 0]\n }\n\n let tot = 0\n\n for (let i = 0; i < this._bufs.length; i++) {\n const _t = tot + this._bufs[i].length\n if (offset < _t || i === this._bufs.length - 1) {\n return [i, offset - tot]\n }\n tot = _t\n }\n}\n\nBufferList.prototype._reverseOffset = function (blOffset) {\n const bufferId = blOffset[0]\n let offset = blOffset[1]\n\n for (let i = 0; i < bufferId; i++) {\n offset += this._bufs[i].length\n }\n\n return offset\n}\n\nBufferList.prototype.get = function get (index) {\n if (index > this.length || index < 0) {\n return undefined\n }\n\n const offset = this._offset(index)\n\n return this._bufs[offset[0]][offset[1]]\n}\n\nBufferList.prototype.slice = function slice (start, end) {\n if (typeof start === 'number' && start < 0) {\n start += this.length\n }\n\n if (typeof end === 'number' && end < 0) {\n end += this.length\n }\n\n return this.copy(null, 0, start, end)\n}\n\nBufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {\n if (typeof srcStart !== 'number' || srcStart < 0) {\n srcStart = 0\n }\n\n if (typeof srcEnd !== 'number' || srcEnd > this.length) {\n srcEnd = this.length\n }\n\n if (srcStart >= this.length) {\n return dst || Buffer.alloc(0)\n }\n\n if (srcEnd <= 0) {\n return dst || Buffer.alloc(0)\n }\n\n const copy = !!dst\n const off = this._offset(srcStart)\n const len = srcEnd - srcStart\n let bytes = len\n let bufoff = (copy && dstStart) || 0\n let start = off[1]\n\n // copy/slice everything\n if (srcStart === 0 && srcEnd === this.length) {\n if (!copy) {\n // slice, but full concat if multiple buffers\n return this._bufs.length === 1\n ? this._bufs[0]\n : Buffer.concat(this._bufs, this.length)\n }\n\n // copy, need to copy individual buffers\n for (let i = 0; i < this._bufs.length; i++) {\n this._bufs[i].copy(dst, bufoff)\n bufoff += this._bufs[i].length\n }\n\n return dst\n }\n\n // easy, cheap case where it's a subset of one of the buffers\n if (bytes <= this._bufs[off[0]].length - start) {\n return copy\n ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)\n : this._bufs[off[0]].slice(start, start + bytes)\n }\n\n if (!copy) {\n // a slice, we need something to copy in to\n dst = Buffer.allocUnsafe(len)\n }\n\n for (let i = off[0]; i < this._bufs.length; i++) {\n const l = this._bufs[i].length - start\n\n if (bytes > l) {\n this._bufs[i].copy(dst, bufoff, start)\n bufoff += l\n } else {\n this._bufs[i].copy(dst, bufoff, start, start + bytes)\n bufoff += l\n break\n }\n\n bytes -= l\n\n if (start) {\n start = 0\n }\n }\n\n // safeguard so that we don't return uninitialized memory\n if (dst.length > bufoff) return dst.slice(0, bufoff)\n\n return dst\n}\n\nBufferList.prototype.shallowSlice = function shallowSlice (start, end) {\n start = start || 0\n end = typeof end !== 'number' ? this.length : end\n\n if (start < 0) {\n start += this.length\n }\n\n if (end < 0) {\n end += this.length\n }\n\n if (start === end) {\n return this._new()\n }\n\n const startOffset = this._offset(start)\n const endOffset = this._offset(end)\n const buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)\n\n if (endOffset[1] === 0) {\n buffers.pop()\n } else {\n buffers[buffers.length - 1] = buffers[buffers.length - 1].slice(0, endOffset[1])\n }\n\n if (startOffset[1] !== 0) {\n buffers[0] = buffers[0].slice(startOffset[1])\n }\n\n return this._new(buffers)\n}\n\nBufferList.prototype.toString = function toString (encoding, start, end) {\n return this.slice(start, end).toString(encoding)\n}\n\nBufferList.prototype.consume = function consume (bytes) {\n // first, normalize the argument, in accordance with how Buffer does it\n bytes = Math.trunc(bytes)\n // do nothing if not a positive number\n if (Number.isNaN(bytes) || bytes <= 0) return this\n\n while (this._bufs.length) {\n if (bytes >= this._bufs[0].length) {\n bytes -= this._bufs[0].length\n this.length -= this._bufs[0].length\n this._bufs.shift()\n } else {\n this._bufs[0] = this._bufs[0].slice(bytes)\n this.length -= bytes\n break\n }\n }\n\n return this\n}\n\nBufferList.prototype.duplicate = function duplicate () {\n const copy = this._new()\n\n for (let i = 0; i < this._bufs.length; i++) {\n copy.append(this._bufs[i])\n }\n\n return copy\n}\n\nBufferList.prototype.append = function append (buf) {\n if (buf == null) {\n return this\n }\n\n if (buf.buffer) {\n // append a view of the underlying ArrayBuffer\n this._appendBuffer(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength))\n } else if (Array.isArray(buf)) {\n for (let i = 0; i < buf.length; i++) {\n this.append(buf[i])\n }\n } else if (this._isBufferList(buf)) {\n // unwrap argument into individual BufferLists\n for (let i = 0; i < buf._bufs.length; i++) {\n this.append(buf._bufs[i])\n }\n } else {\n // coerce number arguments to strings, since Buffer(number) does\n // uninitialized memory allocation\n if (typeof buf === 'number') {\n buf = buf.toString()\n }\n\n this._appendBuffer(Buffer.from(buf))\n }\n\n return this\n}\n\nBufferList.prototype._appendBuffer = function appendBuffer (buf) {\n this._bufs.push(buf)\n this.length += buf.length\n}\n\nBufferList.prototype.indexOf = function (search, offset, encoding) {\n if (encoding === undefined && typeof offset === 'string') {\n encoding = offset\n offset = undefined\n }\n\n if (typeof search === 'function' || Array.isArray(search)) {\n throw new TypeError('The \"value\" argument must be one of type string, Buffer, BufferList, or Uint8Array.')\n } else if (typeof search === 'number') {\n search = Buffer.from([search])\n } else if (typeof search === 'string') {\n search = Buffer.from(search, encoding)\n } else if (this._isBufferList(search)) {\n search = search.slice()\n } else if (Array.isArray(search.buffer)) {\n search = Buffer.from(search.buffer, search.byteOffset, search.byteLength)\n } else if (!Buffer.isBuffer(search)) {\n search = Buffer.from(search)\n }\n\n offset = Number(offset || 0)\n\n if (isNaN(offset)) {\n offset = 0\n }\n\n if (offset < 0) {\n offset = this.length + offset\n }\n\n if (offset < 0) {\n offset = 0\n }\n\n if (search.length === 0) {\n return offset > this.length ? this.length : offset\n }\n\n const blOffset = this._offset(offset)\n let blIndex = blOffset[0] // index of which internal buffer we're working on\n let buffOffset = blOffset[1] // offset of the internal buffer we're working on\n\n // scan over each buffer\n for (; blIndex < this._bufs.length; blIndex++) {\n const buff = this._bufs[blIndex]\n\n while (buffOffset < buff.length) {\n const availableWindow = buff.length - buffOffset\n\n if (availableWindow >= search.length) {\n const nativeSearchResult = buff.indexOf(search, buffOffset)\n\n if (nativeSearchResult !== -1) {\n return this._reverseOffset([blIndex, nativeSearchResult])\n }\n\n buffOffset = buff.length - search.length + 1 // end of native search window\n } else {\n const revOffset = this._reverseOffset([blIndex, buffOffset])\n\n if (this._match(revOffset, search)) {\n return revOffset\n }\n\n buffOffset++\n }\n }\n\n buffOffset = 0\n }\n\n return -1\n}\n\nBufferList.prototype._match = function (offset, search) {\n if (this.length - offset < search.length) {\n return false\n }\n\n for (let searchOffset = 0; searchOffset < search.length; searchOffset++) {\n if (this.get(offset + searchOffset) !== search[searchOffset]) {\n return false\n }\n }\n return true\n}\n\n;(function () {\n const methods = {\n readDoubleBE: 8,\n readDoubleLE: 8,\n readFloatBE: 4,\n readFloatLE: 4,\n readInt32BE: 4,\n readInt32LE: 4,\n readUInt32BE: 4,\n readUInt32LE: 4,\n readInt16BE: 2,\n readInt16LE: 2,\n readUInt16BE: 2,\n readUInt16LE: 2,\n readInt8: 1,\n readUInt8: 1,\n readIntBE: null,\n readIntLE: null,\n readUIntBE: null,\n readUIntLE: null\n }\n\n for (const m in methods) {\n (function (m) {\n if (methods[m] === null) {\n BufferList.prototype[m] = function (offset, byteLength) {\n return this.slice(offset, offset + byteLength)[m](0, byteLength)\n }\n } else {\n BufferList.prototype[m] = function (offset = 0) {\n return this.slice(offset, offset + methods[m])[m](0)\n }\n }\n }(m))\n }\n}())\n\n// Used internally by the class and also as an indicator of this object being\n// a `BufferList`. It's not possible to use `instanceof BufferList` in a browser\n// environment because there could be multiple different copies of the\n// BufferList class and some `BufferList`s might be `BufferList`s.\nBufferList.prototype._isBufferList = function _isBufferList (b) {\n return b instanceof BufferList || BufferList.isBufferList(b)\n}\n\nBufferList.isBufferList = function isBufferList (b) {\n return b != null && b[symbol]\n}\n\nmodule.exports = BufferList\n","'use strict'\n\nconst DuplexStream = require('readable-stream').Duplex\nconst inherits = require('inherits')\nconst BufferList = require('./BufferList')\n\nfunction BufferListStream (callback) {\n if (!(this instanceof BufferListStream)) {\n return new BufferListStream(callback)\n }\n\n if (typeof callback === 'function') {\n this._callback = callback\n\n const piper = function piper (err) {\n if (this._callback) {\n this._callback(err)\n this._callback = null\n }\n }.bind(this)\n\n this.on('pipe', function onPipe (src) {\n src.on('error', piper)\n })\n this.on('unpipe', function onUnpipe (src) {\n src.removeListener('error', piper)\n })\n\n callback = null\n }\n\n BufferList._init.call(this, callback)\n DuplexStream.call(this)\n}\n\ninherits(BufferListStream, DuplexStream)\nObject.assign(BufferListStream.prototype, BufferList.prototype)\n\nBufferListStream.prototype._new = function _new (callback) {\n return new BufferListStream(callback)\n}\n\nBufferListStream.prototype._write = function _write (buf, encoding, callback) {\n this._appendBuffer(buf)\n\n if (typeof callback === 'function') {\n callback()\n }\n}\n\nBufferListStream.prototype._read = function _read (size) {\n if (!this.length) {\n return this.push(null)\n }\n\n size = Math.min(size, this.length)\n this.push(this.slice(0, size))\n this.consume(size)\n}\n\nBufferListStream.prototype.end = function end (chunk) {\n DuplexStream.prototype.end.call(this, chunk)\n\n if (this._callback) {\n this._callback(null, this.slice())\n this._callback = null\n }\n}\n\nBufferListStream.prototype._destroy = function _destroy (err, cb) {\n this._bufs.length = 0\n this.length = 0\n cb(err)\n}\n\nBufferListStream.prototype._isBufferList = function _isBufferList (b) {\n return b instanceof BufferListStream || b instanceof BufferList || BufferListStream.isBufferList(b)\n}\n\nBufferListStream.isBufferList = BufferList.isBufferList\n\nmodule.exports = BufferListStream\nmodule.exports.BufferListStream = BufferListStream\nmodule.exports.BufferList = BufferList\n","'use strict'\nconst fs = require('fs')\nconst path = require('path')\n\n/* istanbul ignore next */\nconst LCHOWN = fs.lchown ? 'lchown' : 'chown'\n/* istanbul ignore next */\nconst LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'\n\n/* istanbul ignore next */\nconst needEISDIRHandled = fs.lchown &&\n !process.version.match(/v1[1-9]+\\./) &&\n !process.version.match(/v10\\.[6-9]/)\n\nconst lchownSync = (path, uid, gid) => {\n try {\n return fs[LCHOWNSYNC](path, uid, gid)\n } catch (er) {\n if (er.code !== 'ENOENT')\n throw er\n }\n}\n\n/* istanbul ignore next */\nconst chownSync = (path, uid, gid) => {\n try {\n return fs.chownSync(path, uid, gid)\n } catch (er) {\n if (er.code !== 'ENOENT')\n throw er\n }\n}\n\n/* istanbul ignore next */\nconst handleEISDIR =\n needEISDIRHandled ? (path, uid, gid, cb) => er => {\n // Node prior to v10 had a very questionable implementation of\n // fs.lchown, which would always try to call fs.open on a directory\n // Fall back to fs.chown in those cases.\n if (!er || er.code !== 'EISDIR')\n cb(er)\n else\n fs.chown(path, uid, gid, cb)\n }\n : (_, __, ___, cb) => cb\n\n/* istanbul ignore next */\nconst handleEISDirSync =\n needEISDIRHandled ? (path, uid, gid) => {\n try {\n return lchownSync(path, uid, gid)\n } catch (er) {\n if (er.code !== 'EISDIR')\n throw er\n chownSync(path, uid, gid)\n }\n }\n : (path, uid, gid) => lchownSync(path, uid, gid)\n\n// fs.readdir could only accept an options object as of node v6\nconst nodeVersion = process.version\nlet readdir = (path, options, cb) => fs.readdir(path, options, cb)\nlet readdirSync = (path, options) => fs.readdirSync(path, options)\n/* istanbul ignore next */\nif (/^v4\\./.test(nodeVersion))\n readdir = (path, options, cb) => fs.readdir(path, cb)\n\nconst chown = (cpath, uid, gid, cb) => {\n fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, er => {\n // Skip ENOENT error\n cb(er && er.code !== 'ENOENT' ? er : null)\n }))\n}\n\nconst chownrKid = (p, child, uid, gid, cb) => {\n if (typeof child === 'string')\n return fs.lstat(path.resolve(p, child), (er, stats) => {\n // Skip ENOENT error\n if (er)\n return cb(er.code !== 'ENOENT' ? er : null)\n stats.name = child\n chownrKid(p, stats, uid, gid, cb)\n })\n\n if (child.isDirectory()) {\n chownr(path.resolve(p, child.name), uid, gid, er => {\n if (er)\n return cb(er)\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n })\n } else {\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n }\n}\n\n\nconst chownr = (p, uid, gid, cb) => {\n readdir(p, { withFileTypes: true }, (er, children) => {\n // any error other than ENOTDIR or ENOTSUP means it's not readable,\n // or doesn't exist. give up.\n if (er) {\n if (er.code === 'ENOENT')\n return cb()\n else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')\n return cb(er)\n }\n if (er || !children.length)\n return chown(p, uid, gid, cb)\n\n let len = children.length\n let errState = null\n const then = er => {\n if (errState)\n return\n if (er)\n return cb(errState = er)\n if (-- len === 0)\n return chown(p, uid, gid, cb)\n }\n\n children.forEach(child => chownrKid(p, child, uid, gid, then))\n })\n}\n\nconst chownrKidSync = (p, child, uid, gid) => {\n if (typeof child === 'string') {\n try {\n const stats = fs.lstatSync(path.resolve(p, child))\n stats.name = child\n child = stats\n } catch (er) {\n if (er.code === 'ENOENT')\n return\n else\n throw er\n }\n }\n\n if (child.isDirectory())\n chownrSync(path.resolve(p, child.name), uid, gid)\n\n handleEISDirSync(path.resolve(p, child.name), uid, gid)\n}\n\nconst chownrSync = (p, uid, gid) => {\n let children\n try {\n children = readdirSync(p, { withFileTypes: true })\n } catch (er) {\n if (er.code === 'ENOENT')\n return\n else if (er.code === 'ENOTDIR' || er.code === 'ENOTSUP')\n return handleEISDirSync(p, uid, gid)\n else\n throw er\n }\n\n if (children && children.length)\n children.forEach(child => chownrKidSync(p, child, uid, gid))\n\n return handleEISDirSync(p, uid, gid)\n}\n\nmodule.exports = chownr\nchownr.sync = chownrSync\n","const binding = require('../build/Release/cpufeatures.node');\n\nmodule.exports = binding.getCPUInfo;\n","/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug');\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tlet i;\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n\t\tconst len = split.length;\n\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tif (!split[i]) {\n\t\t\t\t// ignore empty strings\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tnamespaces = split[i].replace(/\\*/g, '.*?');\n\n\t\t\tif (namespaces[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(new RegExp('^' + namespaces + '$'));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names.map(toNamespace),\n\t\t\t...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tif (name[name.length - 1] === '*') {\n\t\t\treturn true;\n\t\t}\n\n\t\tlet i;\n\t\tlet len;\n\n\t\tfor (i = 0, len = createDebug.skips.length; i < len; i++) {\n\t\t\tif (createDebug.skips[i].test(name)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0, len = createDebug.names.length; i < len; i++) {\n\t\t\tif (createDebug.names[i].test(name)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Convert regexp to namespace\n\t*\n\t* @param {RegExp} regxep\n\t* @return {String} namespace\n\t* @api private\n\t*/\n\tfunction toNamespace(regexp) {\n\t\treturn regexp.toString()\n\t\t\t.substring(2, regexp.toString().length - 2)\n\t\t\t.replace(/\\.\\*\\?$/, '*');\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n","/**\n * Detect Electron renderer / nwjs process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {\n\tmodule.exports = require('./browser.js');\n} else {\n\tmodule.exports = require('./node.js');\n}\n","/**\n * Module dependencies.\n */\n\nconst tty = require('tty');\nconst util = require('util');\n\n/**\n * This is the Node.js implementation of `debug()`.\n */\n\nexports.init = init;\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.destroy = util.deprecate(\n\t() => {},\n\t'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'\n);\n\n/**\n * Colors.\n */\n\nexports.colors = [6, 2, 3, 4, 5, 1];\n\ntry {\n\t// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)\n\t// eslint-disable-next-line import/no-extraneous-dependencies\n\tconst supportsColor = require('supports-color');\n\n\tif (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {\n\t\texports.colors = [\n\t\t\t20,\n\t\t\t21,\n\t\t\t26,\n\t\t\t27,\n\t\t\t32,\n\t\t\t33,\n\t\t\t38,\n\t\t\t39,\n\t\t\t40,\n\t\t\t41,\n\t\t\t42,\n\t\t\t43,\n\t\t\t44,\n\t\t\t45,\n\t\t\t56,\n\t\t\t57,\n\t\t\t62,\n\t\t\t63,\n\t\t\t68,\n\t\t\t69,\n\t\t\t74,\n\t\t\t75,\n\t\t\t76,\n\t\t\t77,\n\t\t\t78,\n\t\t\t79,\n\t\t\t80,\n\t\t\t81,\n\t\t\t92,\n\t\t\t93,\n\t\t\t98,\n\t\t\t99,\n\t\t\t112,\n\t\t\t113,\n\t\t\t128,\n\t\t\t129,\n\t\t\t134,\n\t\t\t135,\n\t\t\t148,\n\t\t\t149,\n\t\t\t160,\n\t\t\t161,\n\t\t\t162,\n\t\t\t163,\n\t\t\t164,\n\t\t\t165,\n\t\t\t166,\n\t\t\t167,\n\t\t\t168,\n\t\t\t169,\n\t\t\t170,\n\t\t\t171,\n\t\t\t172,\n\t\t\t173,\n\t\t\t178,\n\t\t\t179,\n\t\t\t184,\n\t\t\t185,\n\t\t\t196,\n\t\t\t197,\n\t\t\t198,\n\t\t\t199,\n\t\t\t200,\n\t\t\t201,\n\t\t\t202,\n\t\t\t203,\n\t\t\t204,\n\t\t\t205,\n\t\t\t206,\n\t\t\t207,\n\t\t\t208,\n\t\t\t209,\n\t\t\t214,\n\t\t\t215,\n\t\t\t220,\n\t\t\t221\n\t\t];\n\t}\n} catch (error) {\n\t// Swallow - we only care if `supports-color` is available; it doesn't have to be.\n}\n\n/**\n * Build up the default `inspectOpts` object from the environment variables.\n *\n * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js\n */\n\nexports.inspectOpts = Object.keys(process.env).filter(key => {\n\treturn /^debug_/i.test(key);\n}).reduce((obj, key) => {\n\t// Camel-case\n\tconst prop = key\n\t\t.substring(6)\n\t\t.toLowerCase()\n\t\t.replace(/_([a-z])/g, (_, k) => {\n\t\t\treturn k.toUpperCase();\n\t\t});\n\n\t// Coerce string value into JS value\n\tlet val = process.env[key];\n\tif (/^(yes|on|true|enabled)$/i.test(val)) {\n\t\tval = true;\n\t} else if (/^(no|off|false|disabled)$/i.test(val)) {\n\t\tval = false;\n\t} else if (val === 'null') {\n\t\tval = null;\n\t} else {\n\t\tval = Number(val);\n\t}\n\n\tobj[prop] = val;\n\treturn obj;\n}, {});\n\n/**\n * Is stdout a TTY? Colored output is enabled when `true`.\n */\n\nfunction useColors() {\n\treturn 'colors' in exports.inspectOpts ?\n\t\tBoolean(exports.inspectOpts.colors) :\n\t\ttty.isatty(process.stderr.fd);\n}\n\n/**\n * Adds ANSI color escape codes if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\tconst {namespace: name, useColors} = this;\n\n\tif (useColors) {\n\t\tconst c = this.color;\n\t\tconst colorCode = '\\u001B[3' + (c < 8 ? c : '8;5;' + c);\n\t\tconst prefix = ` ${colorCode};1m${name} \\u001B[0m`;\n\n\t\targs[0] = prefix + args[0].split('\\n').join('\\n' + prefix);\n\t\targs.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\\u001B[0m');\n\t} else {\n\t\targs[0] = getDate() + name + ' ' + args[0];\n\t}\n}\n\nfunction getDate() {\n\tif (exports.inspectOpts.hideDate) {\n\t\treturn '';\n\t}\n\treturn new Date().toISOString() + ' ';\n}\n\n/**\n * Invokes `util.format()` with the specified arguments and writes to stderr.\n */\n\nfunction log(...args) {\n\treturn process.stderr.write(util.format(...args) + '\\n');\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\tif (namespaces) {\n\t\tprocess.env.DEBUG = namespaces;\n\t} else {\n\t\t// If you set a process.env field to null or undefined, it gets cast to the\n\t\t// string 'null' or 'undefined'. Just delete instead.\n\t\tdelete process.env.DEBUG;\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n\treturn process.env.DEBUG;\n}\n\n/**\n * Init logic for `debug` instances.\n *\n * Create a new `inspectOpts` object in case `useColors` is set\n * differently for a particular `debug` instance.\n */\n\nfunction init(debug) {\n\tdebug.inspectOpts = {};\n\n\tconst keys = Object.keys(exports.inspectOpts);\n\tfor (let i = 0; i < keys.length; i++) {\n\t\tdebug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %o to `util.inspect()`, all on a single line.\n */\n\nformatters.o = function (v) {\n\tthis.inspectOpts.colors = this.useColors;\n\treturn util.inspect(v, this.inspectOpts)\n\t\t.split('\\n')\n\t\t.map(str => str.trim())\n\t\t.join(' ');\n};\n\n/**\n * Map %O to `util.inspect()`, allowing multiple lines if needed.\n */\n\nformatters.O = function (v) {\n\tthis.inspectOpts.colors = this.useColors;\n\treturn util.inspect(v, this.inspectOpts);\n};\n","//Based on follow-redirects v0.0.x\n\nvar nativeHttps = require('https'),\n nativeHttp = require('http'),\n url = require('url'),\n utils = require('./utils');\n\nvar maxRedirects = module.exports.maxRedirects = 5;\n\nvar protocols = {\n https: nativeHttps,\n http: nativeHttp\n};\n\nfor (var protocol in protocols) {\n var h = function() {};\n h.prototype = protocols[protocol];\n h = new h();\n\n h.request = function(h) {\n return function(options, callback, redirectOptions) {\n\n redirectOptions = redirectOptions || {};\n\n var max = (typeof options === 'object' && 'maxRedirects' in options) ? options.maxRedirects : exports.maxRedirects;\n\n var redirect = utils.extend({\n count: 0,\n max: max,\n clientRequest: null,\n userCallback: callback\n }, redirectOptions);\n\n if (redirect.count > redirect.max) {\n var err = new Error('Max redirects exceeded. To allow more redirects, pass options.maxRedirects property.');\n redirect.clientRequest.emit('error', err);\n return redirect.clientRequest;\n }\n\n redirect.count++;\n\n var reqUrl;\n if (typeof options === 'string') {\n reqUrl = options;\n } else {\n reqUrl = url.format(utils.extend({\n protocol: protocol\n }, options));\n }\n\n var clientRequest = Object.getPrototypeOf(h).request(options, redirectCallback(reqUrl, redirect));\n\n if (!redirect.clientRequest) redirect.clientRequest = clientRequest;\n\n function redirectCallback(reqUrl, redirect) {\n return function(res) {\n if (res.statusCode < 300 || res.statusCode > 399) {\n return redirect.userCallback(res);\n }\n\n if (!('location' in res.headers)) {\n return redirect.userCallback(res);\n }\n\n var redirectUrl = url.resolve(reqUrl, res.headers.location);\n\n var proto = url.parse(redirectUrl).protocol;\n proto = proto.substr(0, proto.length - 1);\n return module.exports[proto].get(redirectUrl, redirectCallback(reqUrl, redirect), redirect);\n };\n }\n\n return clientRequest;\n };\n }(h);\n\n // see https://github.com/joyent/node/blob/master/lib/http.js#L1623\n h.get = function(h) {\n return function(options, cb, redirectOptions) {\n var req = h.request(options, cb, redirectOptions);\n req.end();\n return req;\n };\n }(h);\n\n module.exports[protocol] = h;\n}\n","module.exports = HttpDuplex;\n\nvar util = require('util'),\n stream = require('readable-stream');\n\nutil.inherits(HttpDuplex, stream.Duplex);\n\nfunction HttpDuplex(req, res, options) {\n var self = this;\n\n if (!(self instanceof HttpDuplex)) return new HttpDuplex(req, res, options);\n\n stream.Duplex.call(self, options);\n self._output = null;\n\n self.connect(req, res);\n}\n\nHttpDuplex.prototype.connect = function(req, res) {\n var self = this;\n self.req = req;\n self._output = res;\n self.emit('response', res);\n\n res.on('data', function(c) {\n if (!self.push(c)) self._output.pause();\n });\n res.on('end', function() {\n self.push(null);\n });\n};\n\nHttpDuplex.prototype._read = function(n) {\n if (this._output) this._output.resume();\n};\n\nHttpDuplex.prototype._write = function(chunk, encoding, cb) {\n this.req.write(chunk, encoding);\n cb();\n};\n\nHttpDuplex.prototype.end = function(chunk, encoding, cb) {\n this._output.socket.destroy();\n return this.req.end(chunk, encoding, cb);\n};\n\nHttpDuplex.prototype.destroy = function() {\n this.req.destroy();\n this._output.socket.destroy();\n};\n","var querystring = require('querystring'),\n http = require('./http'),\n fs = require('fs'),\n path = require('path'),\n url = require('url'),\n ssh = require('./ssh'),\n HttpDuplex = require('./http_duplex'),\n debug = require('debug')('modem'),\n utils = require('./utils'),\n util = require('util'),\n url = require('url'),\n splitca = require('split-ca'),\n isWin = require('os').type() === 'Windows_NT';\n\nvar defaultOpts = function () {\n var host;\n var opts = {};\n\n if (!process.env.DOCKER_HOST) {\n // Windows socket path: //./pipe/docker_engine ( Windows 10 )\n // Linux & Darwin socket path: /var/run/docker.sock\n opts.socketPath = isWin ? '//./pipe/docker_engine' : '/var/run/docker.sock';\n } else if (process.env.DOCKER_HOST.indexOf('unix://') === 0) {\n // Strip off unix://, fall back to default of /var/run/docker.sock if\n // unix:// was passed without a path\n opts.socketPath = process.env.DOCKER_HOST.substring(7) || '/var/run/docker.sock';\n } else if (process.env.DOCKER_HOST.indexOf('npipe://') === 0) {\n // Strip off npipe://, fall back to default of //./pipe/docker_engine if\n // npipe:// was passed without a path\n opts.socketPath = process.env.DOCKER_HOST.substring(8) || '//./pipe/docker_engine';\n } else {\n var hostStr = process.env.DOCKER_HOST;\n if (hostStr.indexOf('\\/\\/') < 0) {\n hostStr = 'tcp://' + hostStr;\n }\n try {\n host = new url.URL(hostStr);\n } catch (err) {\n throw new Error('DOCKER_HOST env variable should be something like tcp://localhost:1234');\n }\n\n opts.port = host.port;\n\n if (process.env.DOCKER_TLS_VERIFY === '1' || opts.port === '2376') {\n opts.protocol = 'https';\n } else if (host.protocol === 'ssh:') {\n opts.protocol = 'ssh';\n opts.username = host.username;\n opts.sshOptions = {\n agent: process.env.SSH_AUTH_SOCK,\n }\n } else {\n opts.protocol = 'http';\n }\n\n opts.host = host.hostname;\n\n if (process.env.DOCKER_CERT_PATH) {\n opts.ca = splitca(path.join(process.env.DOCKER_CERT_PATH, 'ca.pem'));\n opts.cert = fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'cert.pem'));\n opts.key = fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'key.pem'));\n }\n\n if (process.env.DOCKER_CLIENT_TIMEOUT) {\n opts.timeout = parseInt(process.env.DOCKER_CLIENT_TIMEOUT, 10);\n }\n }\n\n return opts;\n};\n\n\nvar Modem = function (options) {\n var optDefaults = defaultOpts();\n var opts = Object.assign({}, optDefaults, options);\n\n this.host = opts.host;\n\n if(!this.host) {\n this.socketPath = opts.socketPath;\n }\n\n this.port = opts.port;\n this.username = opts.username;\n this.password = opts.password;\n this.version = opts.version;\n this.key = opts.key;\n this.cert = opts.cert;\n this.ca = opts.ca;\n this.timeout = opts.timeout;\n this.connectionTimeout = opts.connectionTimeout;\n this.checkServerIdentity = opts.checkServerIdentity;\n this.agent = opts.agent;\n this.headers = opts.headers || {};\n this.sshOptions = Object.assign({}, options ? options.sshOptions : {}, optDefaults.sshOptions);\n //retrocompabitlity\n if(this.sshOptions.agentForward === undefined) {\n this.sshOptions.agentForward = opts.agentForward;\n }\n\n if (this.key && this.cert && this.ca) {\n this.protocol = 'https';\n }\n this.protocol = opts.protocol || this.protocol || 'http';\n};\n\nModem.prototype.dial = function (options, callback) {\n var opts, address, data;\n var self = this;\n\n if (options.options) {\n opts = options.options;\n }\n\n // Prevent credentials from showing up in URL\n if (opts && opts.authconfig) {\n delete opts.authconfig;\n }\n\n // Prevent abortsignal from showing up in the URL\n if (opts && opts.abortSignal) {\n delete opts.abortSignal;\n }\n\n if (this.version) {\n options.path = '/' + this.version + options.path;\n }\n\n if (this.host) {\n var parsed = url.parse(self.host);\n address = url.format({\n 'protocol': parsed.protocol || self.protocol,\n 'hostname': parsed.hostname || self.host,\n 'port': self.port\n });\n address = url.resolve(address, options.path);\n } else {\n address = options.path;\n }\n\n if (options.path.indexOf('?') !== -1) {\n if (opts && Object.keys(opts).length > 0) {\n address += this.buildQuerystring(opts._query || opts);\n } else {\n address = address.substring(0, address.length - 1);\n }\n }\n\n var optionsf = {\n path: address,\n method: options.method,\n headers: options.headers || Object.assign({}, self.headers),\n key: self.key,\n cert: self.cert,\n ca: self.ca\n };\n\n if (this.checkServerIdentity) {\n optionsf.checkServerIdentity = this.checkServerIdentity;\n }\n\n if (this.agent) {\n optionsf.agent = this.agent;\n }\n\n if (options.authconfig) {\n optionsf.headers['X-Registry-Auth'] = options.authconfig.key || options.authconfig.base64 ||\n Buffer.from(JSON.stringify(options.authconfig)).toString('base64');\n }\n\n if (options.registryconfig) {\n optionsf.headers['X-Registry-Config'] = options.registryconfig.base64 ||\n Buffer.from(JSON.stringify(options.registryconfig)).toString('base64');\n }\n\n if (options.abortSignal) {\n optionsf.signal = options.abortSignal;\n }\n\n if (options.file) {\n if (typeof options.file === 'string') {\n data = fs.createReadStream(path.resolve(options.file));\n } else {\n data = options.file;\n }\n optionsf.headers['Content-Type'] = 'application/tar';\n } else if (opts && options.method === 'POST') {\n data = JSON.stringify(opts._body || opts);\n if (options.allowEmpty) {\n optionsf.headers['Content-Type'] = 'application/json';\n } else {\n if (data !== '{}' && data !== '\"\"') {\n optionsf.headers['Content-Type'] = 'application/json';\n } else {\n data = undefined;\n }\n }\n }\n\n if (typeof data === 'string') {\n optionsf.headers['Content-Length'] = Buffer.byteLength(data);\n } else if (Buffer.isBuffer(data) === true) {\n optionsf.headers['Content-Length'] = data.length;\n } else if (optionsf.method === 'PUT' || options.hijack || options.openStdin) {\n optionsf.headers['Transfer-Encoding'] = 'chunked';\n }\n\n if (options.hijack) {\n optionsf.headers.Connection = 'Upgrade';\n optionsf.headers.Upgrade = 'tcp';\n }\n\n if (this.socketPath) {\n optionsf.socketPath = this.socketPath;\n } else {\n var urlp = url.parse(address);\n optionsf.hostname = urlp.hostname;\n optionsf.port = urlp.port;\n optionsf.path = urlp.path;\n }\n\n this.buildRequest(optionsf, options, data, callback);\n};\n\nModem.prototype.buildRequest = function (options, context, data, callback) {\n var self = this;\n var connectionTimeoutTimer;\n\n var opts = self.protocol === 'ssh' ? Object.assign(options, {\n agent: ssh(Object.assign({}, self.sshOptions, {\n 'host': self.host,\n 'port': self.port,\n 'username': self.username,\n 'password': self.password,\n })),\n protocol: 'http:',\n }) : options;\n\n var req = http[self.protocol === 'ssh' ? 'http' : self.protocol].request(opts, function () { });\n\n debug('Sending: %s', util.inspect(options, {\n showHidden: true,\n depth: null\n }));\n\n if (self.connectionTimeout) {\n connectionTimeoutTimer = setTimeout(function () {\n debug('Connection Timeout of %s ms exceeded', self.connectionTimeout);\n req.abort();\n }, self.connectionTimeout);\n }\n\n if (self.timeout) {\n req.on('socket', function (socket) {\n socket.setTimeout(self.timeout);\n socket.on('timeout', function () {\n debug('Timeout of %s ms exceeded', self.timeout);\n req.abort();\n });\n });\n }\n\n if (context.hijack === true) {\n clearTimeout(connectionTimeoutTimer);\n req.on('upgrade', function (res, sock, head) {\n return callback(null, sock);\n });\n }\n\n req.on('connect', function () {\n clearTimeout(connectionTimeoutTimer);\n });\n\n req.on('disconnect', function () {\n clearTimeout(connectionTimeoutTimer);\n });\n\n req.on('response', function (res) {\n clearTimeout(connectionTimeoutTimer);\n if (context.isStream === true) {\n self.buildPayload(null, context.isStream, context.statusCodes, context.openStdin, req, res, null, callback);\n } else {\n var chunks = [];\n res.on('data', function (chunk) {\n chunks.push(chunk);\n });\n\n res.on('end', function () {\n var buffer = Buffer.concat(chunks);\n var result = buffer.toString();\n\n debug('Received: %s', result);\n\n var json = utils.parseJSON(result) || buffer;\n self.buildPayload(null, context.isStream, context.statusCodes, false, req, res, json, callback);\n });\n }\n });\n\n req.on('error', function (error) {\n clearTimeout(connectionTimeoutTimer);\n self.buildPayload(error, context.isStream, context.statusCodes, false, {}, {}, null, callback);\n });\n\n if (typeof data === 'string' || Buffer.isBuffer(data)) {\n req.write(data);\n } else if (data) {\n data.on('error', function (error) {\n req.destroy(error);\n });\n data.pipe(req);\n }\n\n if (!context.hijack && !context.openStdin && (typeof data === 'string' || data === undefined || Buffer.isBuffer(data))) {\n req.end();\n }\n};\n\nModem.prototype.buildPayload = function (err, isStream, statusCodes, openStdin, req, res, json, cb) {\n if (err) return cb(err, null);\n\n if (statusCodes[res.statusCode] !== true) {\n getCause(isStream, res, json, function (err, cause) {\n var msg = new Error(\n '(HTTP code ' + res.statusCode + ') ' +\n (statusCodes[res.statusCode] || 'unexpected') + ' - ' +\n (cause.message || cause) + ' '\n );\n msg.reason = statusCodes[res.statusCode];\n msg.statusCode = res.statusCode;\n msg.json = json;\n cb(msg, null);\n });\n } else {\n if (openStdin) {\n cb(null, new HttpDuplex(req, res));\n } else if (isStream) {\n cb(null, res);\n } else {\n cb(null, json);\n }\n }\n\n function getCause(isStream, res, json, callback) {\n var chunks = '';\n if (isStream) {\n res.on('data', function (chunk) {\n chunks += chunk;\n });\n res.on('end', function () {\n callback(null, utils.parseJSON(chunks) || chunks);\n });\n } else {\n callback(null, json);\n }\n }\n};\n\nModem.prototype.demuxStream = function (stream, stdout, stderr) {\n var nextDataType = null;\n var nextDataLength = null;\n var buffer = Buffer.from('');\n function processData(data) {\n if (data) {\n buffer = Buffer.concat([buffer, data]);\n }\n if (!nextDataType) {\n if (buffer.length >= 8) {\n var header = bufferSlice(8);\n nextDataType = header.readUInt8(0);\n nextDataLength = header.readUInt32BE(4);\n // It's possible we got a \"data\" that contains multiple messages\n // Process the next one\n processData();\n }\n } else {\n if (buffer.length >= nextDataLength) {\n var content = bufferSlice(nextDataLength);\n if (nextDataType === 1) {\n stdout.write(content);\n } else {\n stderr.write(content);\n }\n nextDataType = null;\n // It's possible we got a \"data\" that contains multiple messages\n // Process the next one\n processData();\n }\n }\n }\n\n function bufferSlice(end) {\n var out = buffer.slice(0, end);\n buffer = Buffer.from(buffer.slice(end, buffer.length));\n return out;\n }\n\n stream.on('data', processData);\n};\n\nModem.prototype.followProgress = function (stream, onFinished, onProgress) {\n var buf = '';\n var output = [];\n var finished = false;\n\n stream.on('data', onStreamEvent);\n stream.on('error', onStreamError);\n stream.on('end', onStreamEnd);\n stream.on('close', onStreamEnd);\n\n function onStreamEvent(data) {\n buf += data.toString();\n pump();\n\n function pump() {\n var pos;\n while ((pos = buf.indexOf('\\n')) >= 0) {\n if (pos == 0) {\n buf = buf.slice(1);\n continue;\n }\n processLine(buf.slice(0, pos));\n buf = buf.slice(pos + 1);\n }\n }\n\n function processLine(line) {\n if (line[line.length - 1] == '\\r') line = line.substr(0, line.length - 1);\n if (line.length > 0) {\n var obj = JSON.parse(line);\n output.push(obj);\n if (onProgress) {\n onProgress(obj);\n }\n }\n }\n };\n\n function onStreamError(err) {\n finished = true;\n stream.removeListener('data', onStreamEvent);\n stream.removeListener('error', onStreamError);\n stream.removeListener('end', onStreamEnd);\n stream.removeListener('close', onStreamEnd);\n onFinished(err, output);\n }\n\n function onStreamEnd() {\n if(!finished) onFinished(null, output);\n finished = true;\n }\n};\n\nModem.prototype.buildQuerystring = function (opts) {\n var clone = {};\n\n // serialize map values as JSON strings, else querystring truncates.\n Object.keys(opts).map(function (key, i) {\n if (opts[key]\n && typeof opts[key] === 'object'\n && !Array.isArray(opts[key])\n // Ref: https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild\n // > cachefrom (string) JSON array of images used for build cache resolution.\n || key === 'cachefrom'\n ) {\n clone[key] = JSON.stringify(opts[key]);\n } else {\n clone[key] = opts[key];\n }\n });\n\n return querystring.stringify(clone);\n};\n\nmodule.exports = Modem;\n","var Client = require('ssh2').Client,\n http = require('http');\n\nmodule.exports = function(opt) {\n var conn = new Client();\n var agent = new http.Agent();\n\n agent.createConnection = function(options, fn) {\n conn.once('ready', function() {\n conn.exec('docker system dial-stdio', function(err, stream) {\n if (err) {\n conn.end();\n agent.destroy();\n return;\n }\n\n fn(null, stream);\n\n stream.once('close', () => {\n conn.end();\n agent.destroy();\n });\n });\n }).connect(opt);\n\n conn.once('end', () => agent.destroy());\n };\n\n return agent;\n};\n","// https://github.com/HenrikJoreteg/extend-object/blob/v0.1.0/extend-object.js\n\nvar arr = [];\nvar each = arr.forEach;\nvar slice = arr.slice;\n\nmodule.exports.extend = function(obj) {\n each.call(slice.call(arguments, 1), function(source) {\n if (source) {\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n });\n return obj;\n};\n\nmodule.exports.parseJSON = function(s) {\n try {\n return JSON.parse(s);\n } catch (e) {\n return null;\n }\n};\n","var util = require('./util');\n\n/**\n * Represents a config\n * @param {Object} modem docker-modem\n * @param {String} id Config's id\n */\nvar Config = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nConfig.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n *\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nConfig.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs/' + this.id,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update a config.\n *\n * @param {object} opts\n * @param {function} callback\n */\nConfig.prototype.update = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs/' + this.id + '/update?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Removes the config\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nConfig.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs/' + this.id,\n method: 'DELETE',\n abortSignal: opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Config;\n","var extend = require('./util').extend,\n Exec = require('./exec'),\n util = require('./util');\n\n/**\n * Represents a Container\n * @param {Object} modem docker-modem\n * @param {String} id Container's ID\n */\nvar Container = function(modem, id) {\n this.modem = modem;\n this.id = id;\n\n this.defaultOptions = {\n top: {},\n start: {},\n commit: {},\n stop: {},\n pause: {},\n unpause: {},\n restart: {},\n resize: {},\n attach: {},\n remove: {},\n copy: {},\n kill: {},\n exec: {},\n rename: {},\n log: {},\n stats: {},\n getArchive: {},\n infoArchive: {},\n putArchive: {},\n update: {},\n wait: {}\n };\n};\n\nContainer.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if supplied will query Docker.\n * @return {Object} ID only and only if callback isn't supplied.\n */\nContainer.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/json?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Rename\n * @param {Object} opts Rename options\n * @param {Function} callback Callback\n */\nContainer.prototype.rename = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.rename);\n\n var optsf = {\n path: '/containers/' + this.id + '/rename?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update\n * @param {Object} opts Update options\n * @param {Function} callback Callback\n */\nContainer.prototype.update = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.update);\n\n var optsf = {\n path: '/containers/' + this.id + '/update',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Top\n * @param {Object} opts like 'ps_args' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.top = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.top);\n\n var optsf = {\n path: '/containers/' + this.id + '/top?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Containers changes\n * @param {Object} Options\n * @param {Function} callback Callback\n */\nContainer.prototype.changes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/changes',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Checkpoints list\n * @param {Object} opts List checkpoints options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.listCheckpoint = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Delete checkpoint\n * @param {Object} opts Delete checkpoint options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.deleteCheckpoint = function(checkpoint, opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints/' + checkpoint + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Create checkpoint\n * @param {Object} opts Create checkpoint options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.createCheckpoint = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n allowEmpty: true,\n statusCodes: {\n 200: true, //unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Export\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback with the octet-stream.\n */\nContainer.prototype.export = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/export',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Start\n * @param {Object} opts Container start options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.start = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.start);\n\n var optsf = {\n path: '/containers/' + this.id + '/start?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 304: 'container already started',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Pause\n * @param {Object} opts Pause options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.pause = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.pause);\n\n var optsf = {\n path: '/containers/' + this.id + '/pause',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Unpause\n * @param {Object} opts Unpause options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.unpause = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.unpause);\n\n var optsf = {\n path: '/containers/' + this.id + '/unpause',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Setup an exec call to a running container\n *\n * @param {object} opts\n * @param {function} callback\n */\nContainer.prototype.exec = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.exec);\n\n var optsf = {\n path: '/containers/' + this.id + '/exec',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 409: 'container stopped/paused',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(new Exec(self.modem, data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, new Exec(self.modem, data.Id));\n });\n }\n};\n\n/**\n * Commit\n * @param {Object} opts Commit options like 'Hostname' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.commit = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.commit);\n\n args.opts.container = this.id;\n\n var optsf = {\n path: '/commit?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Stop\n * @param {Object} opts Container stop options, like 't' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.stop = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.stop);\n\n var optsf = {\n path: '/containers/' + this.id + '/stop?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 304: 'container already stopped',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Restart\n * @param {Object} opts Container restart options, like 't' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.restart = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.restart);\n\n var optsf = {\n path: '/containers/' + this.id + '/restart?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Kill\n * @param {Object} opts Container kill options, like 'signal' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.kill = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.kill);\n\n var optsf = {\n path: '/containers/' + this.id + '/kill?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container resize\n * @param {[type]} opts Resize options. (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.resize = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.resize);\n\n var optsf = {\n path: '/containers/' + this.id + '/resize?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Attach\n * @param {Object} opts Attach options, like 'logs' (optional)\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.attach = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.attach);\n\n var optsf = {\n path: '/containers/' + this.id + '/attach?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n hijack: args.opts.hijack,\n openStdin: args.opts.stdin,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, stream) {\n if (err) {\n return reject(err);\n }\n resolve(stream);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, stream) {\n args.callback(err, stream);\n });\n }\n};\n\n/**\n * Waits for a container to end.\n * @param {[type]} opts Container wait options, like condition. (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.wait = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.wait);\n\n var optsf = {\n path: '/containers/' + this.id + '/wait?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes a container\n * @param {Object} opts Remove options, like 'force' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.remove);\n\n var optsf = {\n path: '/containers/' + this.id + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Copy (WARNING: DEPRECATED since RAPI v1.20)\n * @param {Object} opts Copy options, like 'Resource' (optional)\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.copy = function(opts, callback) {\n var self = this;\n console.log('container.copy is deprecated since Docker v1.8.x');\n var args = util.processArgs(opts, callback, this.defaultOptions.copy);\n\n var optsf = {\n path: '/containers/' + this.id + '/copy',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * getArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.getArchive = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.getArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * infoArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.infoArchive = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.infoArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'HEAD',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * putArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.putArchive = function(file, opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.putArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'PUT',\n file: file,\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 403: 'client error, permission denied',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nContainer.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.log);\n\n var optsf = {\n path: '/containers/' + this.id + '/logs?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: args.opts.follow || false,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container stats\n * @param {Object} opts Stats options. (optional)\n * @param {Function} callback Callback with data\n */\nContainer.prototype.stats = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.stats);\n var isStream = true;\n if (args.opts.stream === false) {\n isStream = false;\n }\n var optsf = {\n path: '/containers/' + this.id + '/stats?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: isStream,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Container;\n","var EventEmitter = require('events').EventEmitter,\n Modem = require('docker-modem'),\n tar = require('tar-fs'),\n zlib = require('zlib'),\n Container = require('./container'),\n Image = require('./image'),\n Volume = require('./volume'),\n Network = require('./network'),\n Service = require('./service'),\n Plugin = require('./plugin'),\n Secret = require('./secret'),\n Config = require('./config'),\n Task = require('./task'),\n Node = require('./node'),\n Exec = require('./exec'),\n util = require('./util'),\n extend = util.extend;\n\nvar Docker = function(opts) {\n if (!(this instanceof Docker)) return new Docker(opts);\n\n var plibrary = global.Promise;\n\n if (opts && opts.Promise) {\n plibrary = opts.Promise;\n\n if (Object.keys(opts).length === 1) {\n opts = undefined;\n }\n }\n\n this.modem = new Modem(opts);\n this.modem.Promise = plibrary;\n};\n\n/**\n * Creates a new container\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createContainer = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/containers/create?',\n method: 'POST',\n options: opts,\n authconfig: opts.authconfig,\n abortSignal: opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 406: 'impossible to attach',\n 500: 'server error'\n }\n };\n\n delete opts.authconfig;\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getContainer(data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, self.getContainer(data.Id));\n });\n }\n};\n\n/**\n * Creates a new image\n * @param {Object} auth Authentication (optional)\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createImage = function(auth, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (!callback && !opts) {\n opts = auth;\n auth = opts.authconfig;\n }\n\n var optsf = {\n path: '/images/create?',\n method: 'POST',\n options: opts,\n authconfig: auth,\n abortSignal: opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Load image\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.loadImage = function(file, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n\n var optsf = {\n path: '/images/load?',\n method: 'POST',\n options: opts,\n file: file,\n abortSignal: opts && opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Import image from a tar archive\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.importImage = function(file, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = undefined;\n }\n\n if (!opts)\n opts = {};\n\n opts.fromSrc = '-';\n\n var optsf = {\n path: '/images/create?',\n method: 'POST',\n options: opts,\n file: file,\n abortSignal: opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Verifies auth\n * @param {Object} opts Options\n * @param {Function} callback Callback\n */\nDocker.prototype.checkAuth = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/auth',\n method: 'POST',\n options: opts,\n abortSignal: opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Builds an image\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.buildImage = function(file, opts, callback) {\n var self = this;\n\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n\n function build(file) {\n var optsf = {\n path: '/build?',\n method: 'POST',\n file: file,\n options: opts,\n abortSignal: opts && opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (opts) {\n if (opts.registryconfig) {\n optsf.registryconfig = optsf.options.registryconfig;\n delete optsf.options.registryconfig;\n }\n\n //undocumented?\n if (opts.authconfig) {\n optsf.authconfig = optsf.options.authconfig;\n delete optsf.options.authconfig;\n }\n }\n\n if (callback === undefined) {\n return new self.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n self.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n }\n\n if (file && file.context) {\n var pack = tar.pack(file.context, {\n entries: file.src\n });\n return build(pack.pipe(zlib.createGzip()));\n } else {\n return build(file);\n }\n};\n\n/**\n * Fetches a Container by ID\n * @param {String} id Container's ID\n */\nDocker.prototype.getContainer = function(id) {\n return new Container(this.modem, id);\n};\n\n/**\n * Fetches an Image by name\n * @param {String} name Image's name\n */\nDocker.prototype.getImage = function(name) {\n return new Image(this.modem, name);\n};\n\n/**\n * Fetches a Volume by name\n * @param {String} name Volume's name\n */\nDocker.prototype.getVolume = function(name) {\n return new Volume(this.modem, name);\n};\n\n/**\n * Fetches a Plugin by name\n * @param {String} name Volume's name\n */\nDocker.prototype.getPlugin = function(name, remote) {\n return new Plugin(this.modem, name, remote);\n};\n\n/**\n * Fetches a Service by id\n * @param {String} id Services's id\n */\nDocker.prototype.getService = function(id) {\n return new Service(this.modem, id);\n};\n\n/**\n * Fetches a Task by id\n * @param {String} id Task's id\n */\nDocker.prototype.getTask = function(id) {\n return new Task(this.modem, id);\n};\n\n/**\n * Fetches Node by id\n * @param {String} id Node's id\n */\nDocker.prototype.getNode = function(id) {\n return new Node(this.modem, id);\n};\n\n/**\n * Fetches a Network by id\n * @param {String} id network's id\n */\nDocker.prototype.getNetwork = function(id) {\n return new Network(this.modem, id);\n};\n\n/**\n * Fetches a Secret by id\n * @param {String} id network's id\n */\nDocker.prototype.getSecret = function(id) {\n return new Secret(this.modem, id);\n};\n\n/**\n * Fetches a Config by id\n * @param {String} id network's id\n */\nDocker.prototype.getConfig = function(id) {\n return new Config(this.modem, id);\n};\n\n/**\n * Fetches an Exec instance by ID\n * @param {String} id Exec instance's ID\n */\nDocker.prototype.getExec = function(id) {\n return new Exec(this.modem, id);\n};\n\n/**\n * Lists containers\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listContainers = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/json?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/json?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Get images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.getImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/get?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Services\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listServices = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/services?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Nodes\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listNodes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such node',\n 500: 'server error',\n 503: 'node is not part of a swarm',\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Tasks\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listTasks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/tasks?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new secret\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createSecret = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n var optsf = {\n path: '/secrets/create?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 406: 'server error or node is not part of a swarm',\n 409: 'name conflicts with an existing object',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getSecret(data.ID));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getSecret(data.ID));\n });\n }\n};\n\n\n/**\n * Creates a new config\n * @param {Object} opts Config options\n * @param {Function} callback Callback\n */\nDocker.prototype.createConfig = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n var optsf = {\n path: '/configs/create?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 406: 'server error or node is not part of a swarm',\n 409: 'name conflicts with an existing object',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getConfig(data.ID));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getConfig(data.ID));\n });\n }\n};\n\n\n/**\n * Lists secrets\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listSecrets = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists configs\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listConfigs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new plugin\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createPlugin = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/plugins/create?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getPlugin(args.opts.name));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getPlugin(args.opts.name));\n });\n }\n};\n\n\n/**\n * Lists plugins\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listPlugins = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/prune?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune builder\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneBuilder = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/build/prune',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune containers\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneContainers = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/prune?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune volumes\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneVolumes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/prune?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune networks\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneNetworks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/prune?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Creates a new volume\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createVolume = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/volumes/create?',\n method: 'POST',\n allowEmpty: true,\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getVolume(data.Name));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getVolume(data.Name));\n });\n }\n};\n\n/**\n * Creates a new service\n * @param {Object} auth\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createService = function(auth, opts, callback) {\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (!opts && !callback) {\n opts = auth;\n }\n\n\n var self = this;\n var optsf = {\n path: '/services/create',\n method: 'POST',\n options: opts,\n authconfig: auth,\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 201: true,\n 500: 'server error'\n }\n };\n\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getService(data.ID || data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, self.getService(data.ID || data.Id));\n });\n }\n};\n\n/**\n * Lists volumes\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listVolumes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new network\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createNetwork = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/networks/create?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'driver not found',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getNetwork(data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getNetwork(data.Id));\n });\n }\n};\n\n/**\n * Lists networks\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listNetworks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Search images\n * @param {Object} opts Options\n * @param {Function} callback Callback\n */\nDocker.prototype.searchImages = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/images/search?',\n method: 'GET',\n options: opts,\n authconfig: opts.authconfig,\n abortSignal: opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Info\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback with info\n */\nDocker.prototype.info = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var opts = {\n path: '/info',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Version\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.version = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var opts = {\n path: '/version',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Ping\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.ping = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/_ping',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * SystemDf \tequivalent to system/df API Engine\n *\t\tget usage data information\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.df = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/system/df',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Events\n * @param {Object} opts Events options, like 'since' (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.getEvents = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/events?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Pull is a wrapper around createImage, parsing image's tags.\n * @param {String} repoTag Repository tag\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n * @param {Object} auth Authentication (optional)\n * @return {Object} Image\n */\nDocker.prototype.pull = function(repoTag, opts, callback, auth) {\n var args = util.processArgs(opts, callback);\n\n var imageSrc = util.parseRepositoryTag(repoTag);\n args.opts.fromImage = imageSrc.repository;\n args.opts.tag = imageSrc.tag || 'latest';\n\n var argsf = [args.opts, args.callback];\n if (auth) {\n argsf = [auth, args.opts, args.callback];\n }\n return this.createImage.apply(this, argsf);\n};\n\n/**\n * Like run command from Docker's CLI\n * @param {String} image Image name to be used.\n * @param {Array} cmd Command to run in array format.\n * @param {Object} streamo Output stream\n * @param {Object} createOptions Container create options (optional)\n * @param {Object} startOptions Container start options (optional)\n * @param {Function} callback Callback\n * @return {Object} EventEmitter\n */\nDocker.prototype.run = function(image, cmd, streamo, createOptions, startOptions, callback) {\n if (typeof arguments[arguments.length - 1] === 'function') {\n return this.runCallback(image, cmd, streamo, createOptions, startOptions, callback);\n } else {\n return this.runPromise(image, cmd, streamo, createOptions, startOptions);\n }\n};\n\n\nDocker.prototype.runCallback = function(image, cmd, streamo, createOptions, startOptions, callback) {\n if (!callback && typeof createOptions === 'function') {\n callback = createOptions;\n createOptions = {};\n startOptions = {};\n } else if (!callback && typeof startOptions === 'function') {\n callback = startOptions;\n startOptions = {};\n }\n\n var hub = new EventEmitter();\n\n function handler(err, container) {\n if (err) return callback(err, null, container);\n\n hub.emit('container', container);\n\n container.attach({\n stream: true,\n stdout: true,\n stderr: true\n }, function handler(err, stream) {\n if (err) return callback(err, null, container);\n\n hub.emit('stream', stream);\n\n if (streamo) {\n if (streamo instanceof Array) {\n stream.on('end', function() {\n try {\n streamo[0].end();\n } catch (e) {}\n try {\n streamo[1].end();\n } catch (e) {}\n });\n container.modem.demuxStream(stream, streamo[0], streamo[1]);\n } else {\n stream.setEncoding('utf8');\n stream.pipe(streamo, {\n end: true\n });\n }\n }\n\n container.start(startOptions, function(err, data) {\n if (err) return callback(err, data, container);\n hub.emit('start', container);\n\n container.wait(function(err, data) {\n hub.emit('data', data);\n callback(err, data, container);\n });\n });\n });\n }\n\n var optsc = {\n 'Hostname': '',\n 'User': '',\n 'AttachStdin': false,\n 'AttachStdout': true,\n 'AttachStderr': true,\n 'Tty': true,\n 'OpenStdin': false,\n 'StdinOnce': false,\n 'Env': null,\n 'Cmd': cmd,\n 'Image': image,\n 'Volumes': {},\n 'VolumesFrom': []\n };\n\n extend(optsc, createOptions);\n\n this.createContainer(optsc, handler);\n\n return hub;\n};\n\nDocker.prototype.runPromise = function(image, cmd, streamo, createOptions, startOptions) {\n var self = this;\n\n createOptions = createOptions || {};\n startOptions = startOptions || {};\n\n var optsc = {\n 'Hostname': '',\n 'User': '',\n 'AttachStdin': false,\n 'AttachStdout': true,\n 'AttachStderr': true,\n 'Tty': true,\n 'OpenStdin': false,\n 'StdinOnce': false,\n 'Env': null,\n 'Cmd': cmd,\n 'Image': image,\n 'Volumes': {},\n 'VolumesFrom': []\n };\n\n extend(optsc, createOptions);\n\n var containero;\n\n return new this.modem.Promise(function(resolve, reject) {\n self.createContainer(optsc).then(function(container) {\n containero = container;\n return container.attach({\n stream: true,\n stdout: true,\n stderr: true\n });\n }).then(function(stream) {\n if (streamo) {\n if (streamo instanceof Array) {\n stream.on('end', function() {\n try {\n streamo[0].end();\n } catch (e) {}\n try {\n streamo[1].end();\n } catch (e) {}\n });\n containero.modem.demuxStream(stream, streamo[0], streamo[1]);\n } else {\n stream.setEncoding('utf8');\n stream.pipe(streamo, {\n end: true\n });\n }\n }\n return containero.start(startOptions);\n }).then(function(data) {\n return containero.wait();\n }).then(function(data) {\n resolve([data, containero]);\n }).catch(function(err) {\n reject(err);\n });\n });\n};\n\n/**\n * Init swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmInit = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/init',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Join swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmJoin = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/join',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Leave swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmLeave = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/leave?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 406: 'node is not part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmUpdate = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/update?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Inspect a Swarm.\n * Warning: This method is not documented in the API\n *\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.swarmInspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 406: 'This node is not a swarm manager',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nDocker.Container = Container;\nDocker.Image = Image;\nDocker.Volume = Volume;\nDocker.Network = Network;\nDocker.Service = Service;\nDocker.Plugin = Plugin;\nDocker.Secret = Secret;\nDocker.Task = Task;\nDocker.Node = Node;\nDocker.Exec = Exec;\n\nmodule.exports = Docker;\n","var util = require('./util');\n\n/**\n * Represents an Exec\n * @param {Object} modem docker-modem\n * @param {String} id Exec's ID\n */\nvar Exec = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nExec.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Start the exec call that was setup.\n *\n * @param {object} opts\n * @param {function} callback\n */\nExec.prototype.start = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/start',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n allowEmpty: true,\n hijack: args.opts.hijack,\n openStdin: args.opts.stdin,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such exec',\n 409: 'container stopped/paused',\n 500: 'container not running'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Resize the exec call that was setup.\n *\n * @param {object} opts\n * @param {function} callback\n */\nExec.prototype.resize = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/resize?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such exec',\n 500: 'container not running'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Get low-level information about the exec call.\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nExec.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/json',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such exec',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Exec;\n","var util = require('./util');\n\n/**\n * Represents an image\n * @param {Object} modem docker-modem\n * @param {String} name Image's name\n */\nvar Image = function(modem, name) {\n this.modem = modem;\n this.name = name;\n};\n\nImage.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nImage.prototype.inspect = function(callback) {\n var self = this;\n\n var opts = {\n path: '/images/' + this.name + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Distribution\n * @param {Object} opts\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nImage.prototype.distribution = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n\n var fopts = {\n path: '/distribution/' + this.name + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 401: 'no such image',\n 500: 'server error'\n },\n authconfig: (args.opts) ? args.opts.authconfig : undefined\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(fopts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(fopts, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * History\n * @param {Function} callback Callback\n */\nImage.prototype.history = function(callback) {\n var self = this;\n var opts = {\n path: '/images/' + this.name + '/history',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Get\n * @param {Function} callback Callback with data stream.\n */\nImage.prototype.get = function(callback) {\n var self = this;\n var opts = {\n path: '/images/' + this.name + '/get',\n method: 'GET',\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Push\n * @param {Object} opts Push options, like 'registry' (optional)\n * @param {Function} callback Callback with stream.\n * @param {Object} auth Registry authentication\n */\nImage.prototype.push = function(opts, callback, auth) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var isStream = true;\n if (args.opts.stream === false) {\n isStream = false;\n }\n var optsf = {\n path: '/images/' + this.name + '/push?',\n method: 'POST',\n options: args.opts,\n authconfig: args.opts.authconfig || auth,\n abortSignal: args.opts.abortSignal,\n isStream: isStream,\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n delete optsf.options.authconfig;\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Tag\n * @param {Object} opts Tag options, like 'repo' (optional)\n * @param {Function} callback Callback\n */\nImage.prototype.tag = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/images/' + this.name + '/tag?',\n method: 'POST',\n options: opts,\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 400: 'bad parameter',\n 404: 'no such image',\n 409: 'conflict',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Removes the image\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nImage.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/' + this.name + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Image;\n","var util = require('./util');\n\n/**\n * Represents an network\n * @param {Object} modem docker-modem\n * @param {String} id Network's id\n */\nvar Network = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nNetwork.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Id only if callback isn't specified.\n */\nNetwork.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var opts = {\n path: '/networks/' + this.id + '?',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such network',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes the network\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id,\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such network',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Connects a container to a network\n * @param {[Object]} opts Connect options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.connect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id + '/connect',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 201: true,\n 404: 'network or container is not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Disconnects a container from a network\n * @param {[Object]} opts Disconnect options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.disconnect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id + '/disconnect',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 201: true,\n 404: 'network or container is not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\n\nmodule.exports = Network;\n","var util = require('./util');\n\n/**\n * Represents an Node\n * @param {Object} modem docker-modem\n * @param {String} id Node's ID\n */\nvar Node = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nNode.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for Node details.\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nNode.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes/' + this.id,\n method: 'GET',\n abortSignal: args.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Update a node.\n *\n * @param {object} opts\n * @param {function} callback\n */\nNode.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/nodes/' + this.id + '/update?',\n method: 'POST',\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 406: 'node is not part of a swarm',\n 500: 'server error'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Remove a Node.\n * Warning: This method is not documented in the API.\n *\n * @param {object} opts\n * @param {function} callback\n */\nNode.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes/' + this.id + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Node;\n","var util = require('./util');\n\n/**\n * Represents a plugin\n * @param {Object} modem docker-modem\n * @param {String} name Plugin's name\n */\nvar Plugin = function(modem, name, remote) {\n this.modem = modem;\n this.name = name;\n this.remote = remote || name;\n};\n\nPlugin.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n *\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nPlugin.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'plugin is not installed',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes the plugin\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'plugin is not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * get privileges\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n * @return {Object} Name only if callback isn't specified.\n */\nPlugin.prototype.privileges = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/privileges?',\n method: 'GET',\n options: {\n 'remote': this.remote\n },\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Installs a new plugin\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nPlugin.prototype.pull = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n if(args.opts._query && !args.opts._query.name) {\n args.opts._query.name = this.name;\n }\n if(args.opts._query && !args.opts._query.remote) {\n args.opts._query.remote = this.remote;\n }\n\n var optsf = {\n path: '/plugins/pull?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Enable\n * @param {Object} opts Plugin enable options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.enable = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/enable?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Disable\n * @param {Object} opts Plugin disable options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.disable = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/disable',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Push\n * @param {Object} opts Plugin push options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.push = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/push',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * COnfigure\n * @param {Object} opts Plugin configure options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.configure = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/set',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Upgrade plugin\n *\n * @param {object} auth\n * @param {object} opts\n * @param {function} callback\n */\nPlugin.prototype.upgrade = function(auth, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n }\n\n var optsf = {\n path: '/plugins/' + this.name + '/upgrade?',\n method: 'POST',\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n authconfig: auth,\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Plugin;\n","var util = require('./util');\n\n/**\n * Represents a secret\n * @param {Object} modem docker-modem\n * @param {String} id Secret's id\n */\nvar Secret = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nSecret.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nSecret.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets/' + this.id,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'secret not found',\n 406: 'node is not part of a swarm',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update a secret.\n *\n * @param {object} opts\n * @param {function} callback\n */\nSecret.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/secrets/' + this.id + '/update?',\n method: 'POST',\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'secret not found',\n 500: 'server error'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Removes the secret\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nSecret.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets/' + this.id,\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'secret not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Secret;\n","var util = require('./util');\n\n/**\n * Represents an Service\n * @param {Object} modem docker-modem\n * @param {String} id Service's ID\n */\nvar Service = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nService.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for service details.\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nService.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/services/' + this.id,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Delete Service\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nService.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/services/' + this.id,\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such service',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update service\n *\n * @param {object} auth\n * @param {object} opts\n * @param {function} callback\n */\nService.prototype.update = function(auth, opts, callback) {\n var self = this;\n if (!callback) {\n var t = typeof opts;\n if(t === 'function'){\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (t === 'undefined'){\n opts = auth;\n auth = opts.authconfig || undefined;\n }\n }\n\n var optsf = {\n path: '/services/' + this.id + '/update?',\n method: 'POST',\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error'\n },\n authconfig: auth,\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n\n/**\n * Service logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nService.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, {});\n\n var optsf = {\n path: '/services/' + this.id + '/logs?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: args.opts.follow || false,\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Service;\n","var util = require('./util');\n\n/**\n * Represents an Task\n * @param {Object} modem docker-modem\n * @param {String} id Task's ID\n */\nvar Task = function(modem, id) {\n this.modem = modem;\n this.id = id;\n\n this.defaultOptions = {\n log: {}\n };\n};\n\nTask.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for Task details.\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nTask.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/tasks/' + this.id,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'unknown task',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Task logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nTask.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.log);\n\n var optsf = {\n path: '/tasks/' + this.id + '/logs?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: args.opts.follow || false,\n statusCodes: {\n 101: true,\n 200: true,\n 404: 'no such container',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Task;\n","// https://github.com/HenrikJoreteg/extend-object/blob/v0.1.0/extend-object.js\n\nvar arr = [];\nvar each = arr.forEach;\nvar slice = arr.slice;\n\nmodule.exports.extend = function(obj) {\n each.call(slice.call(arguments, 1), function(source) {\n if (source) {\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n });\n return obj;\n};\n\nmodule.exports.processArgs = function(opts, callback, defaultOpts) {\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n return {\n callback: callback,\n opts: module.exports.extend({}, defaultOpts, opts)\n };\n};\n\n\n/**\n * Parse the given repo tag name (as a string) and break it out into repo/tag pair.\n * // if given the input http://localhost:8080/woot:latest\n * {\n * repository: 'http://localhost:8080/woot',\n * tag: 'latest'\n * }\n * @param {String} input Input e.g: 'repo/foo', 'ubuntu', 'ubuntu:latest'\n * @return {Object} input parsed into the repo and tag.\n */\nmodule.exports.parseRepositoryTag = function(input) {\n var separatorPos;\n var digestPos = input.indexOf('@');\n var colonPos = input.lastIndexOf(':');\n // @ symbol is more important\n if (digestPos >= 0) {\n separatorPos = digestPos;\n } else if (colonPos >= 0) {\n separatorPos = colonPos;\n } else {\n // no colon nor @\n return {\n repository: input\n };\n }\n\n // last colon is either the tag (or part of a port designation)\n var tag = input.slice(separatorPos + 1);\n\n // if it contains a / its not a tag and is part of the url\n if (tag.indexOf('/') === -1) {\n return {\n repository: input.slice(0, separatorPos),\n tag: tag\n };\n }\n\n return {\n repository: input\n };\n};\n","var util = require('./util');\n\n/**\n * Represents a volume\n * @param {Object} modem docker-modem\n * @param {String} name Volume's name\n */\nvar Volume = function(modem, name) {\n this.modem = modem;\n this.name = name;\n};\n\nVolume.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nVolume.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/' + this.name,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such volume',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes the volume\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nVolume.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/' + this.name,\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 204: true,\n 404: 'no such volume',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Volume;\n","var once = require('once');\n\nvar noop = function() {};\n\nvar isRequest = function(stream) {\n\treturn stream.setHeader && typeof stream.abort === 'function';\n};\n\nvar isChildProcess = function(stream) {\n\treturn stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3\n};\n\nvar eos = function(stream, opts, callback) {\n\tif (typeof opts === 'function') return eos(stream, null, opts);\n\tif (!opts) opts = {};\n\n\tcallback = once(callback || noop);\n\n\tvar ws = stream._writableState;\n\tvar rs = stream._readableState;\n\tvar readable = opts.readable || (opts.readable !== false && stream.readable);\n\tvar writable = opts.writable || (opts.writable !== false && stream.writable);\n\tvar cancelled = false;\n\n\tvar onlegacyfinish = function() {\n\t\tif (!stream.writable) onfinish();\n\t};\n\n\tvar onfinish = function() {\n\t\twritable = false;\n\t\tif (!readable) callback.call(stream);\n\t};\n\n\tvar onend = function() {\n\t\treadable = false;\n\t\tif (!writable) callback.call(stream);\n\t};\n\n\tvar onexit = function(exitCode) {\n\t\tcallback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);\n\t};\n\n\tvar onerror = function(err) {\n\t\tcallback.call(stream, err);\n\t};\n\n\tvar onclose = function() {\n\t\tprocess.nextTick(onclosenexttick);\n\t};\n\n\tvar onclosenexttick = function() {\n\t\tif (cancelled) return;\n\t\tif (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close'));\n\t\tif (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close'));\n\t};\n\n\tvar onrequest = function() {\n\t\tstream.req.on('finish', onfinish);\n\t};\n\n\tif (isRequest(stream)) {\n\t\tstream.on('complete', onfinish);\n\t\tstream.on('abort', onclose);\n\t\tif (stream.req) onrequest();\n\t\telse stream.on('request', onrequest);\n\t} else if (writable && !ws) { // legacy streams\n\t\tstream.on('end', onlegacyfinish);\n\t\tstream.on('close', onlegacyfinish);\n\t}\n\n\tif (isChildProcess(stream)) stream.on('exit', onexit);\n\n\tstream.on('end', onend);\n\tstream.on('finish', onfinish);\n\tif (opts.error !== false) stream.on('error', onerror);\n\tstream.on('close', onclose);\n\n\treturn function() {\n\t\tcancelled = true;\n\t\tstream.removeListener('complete', onfinish);\n\t\tstream.removeListener('abort', onclose);\n\t\tstream.removeListener('request', onrequest);\n\t\tif (stream.req) stream.req.removeListener('finish', onfinish);\n\t\tstream.removeListener('end', onlegacyfinish);\n\t\tstream.removeListener('close', onlegacyfinish);\n\t\tstream.removeListener('finish', onfinish);\n\t\tstream.removeListener('exit', onexit);\n\t\tstream.removeListener('end', onend);\n\t\tstream.removeListener('error', onerror);\n\t\tstream.removeListener('close', onclose);\n\t};\n};\n\nmodule.exports = eos;\n","module.exports = require('fs').constants || require('constants')\n","'use strict';\n\nmodule.exports = (flag, argv = process.argv) => {\n\tconst prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');\n\tconst position = argv.indexOf(prefix + flag);\n\tconst terminatorPosition = argv.indexOf('--');\n\treturn position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n};\n","try {\n var util = require('util');\n /* istanbul ignore next */\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n /* istanbul ignore next */\n module.exports = require('./inherits_browser.js');\n}\n","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n }\n}\n","var path = require('path');\nvar fs = require('fs');\nvar _0777 = parseInt('0777', 8);\n\nmodule.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;\n\nfunction mkdirP (p, opts, f, made) {\n if (typeof opts === 'function') {\n f = opts;\n opts = {};\n }\n else if (!opts || typeof opts !== 'object') {\n opts = { mode: opts };\n }\n \n var mode = opts.mode;\n var xfs = opts.fs || fs;\n \n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n \n var cb = f || function () {};\n p = path.resolve(p);\n \n xfs.mkdir(p, mode, function (er) {\n if (!er) {\n made = made || p;\n return cb(null, made);\n }\n switch (er.code) {\n case 'ENOENT':\n mkdirP(path.dirname(p), opts, function (er, made) {\n if (er) cb(er, made);\n else mkdirP(p, opts, cb, made);\n });\n break;\n\n // In the case of any other error, just see if there's a dir\n // there already. If so, then hooray! If not, then something\n // is borked.\n default:\n xfs.stat(p, function (er2, stat) {\n // if the stat fails, then that's super weird.\n // let the original error be the failure reason.\n if (er2 || !stat.isDirectory()) cb(er, made)\n else cb(null, made);\n });\n break;\n }\n });\n}\n\nmkdirP.sync = function sync (p, opts, made) {\n if (!opts || typeof opts !== 'object') {\n opts = { mode: opts };\n }\n \n var mode = opts.mode;\n var xfs = opts.fs || fs;\n \n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n\n p = path.resolve(p);\n\n try {\n xfs.mkdirSync(p, mode);\n made = made || p;\n }\n catch (err0) {\n switch (err0.code) {\n case 'ENOENT' :\n made = sync(path.dirname(p), opts, made);\n sync(p, opts, made);\n break;\n\n // In the case of any other error, just see if there's a dir\n // there already. If so, then hooray! If not, then something\n // is borked.\n default:\n var stat;\n try {\n stat = xfs.statSync(p);\n }\n catch (err1) {\n throw err0;\n }\n if (!stat.isDirectory()) throw err0;\n break;\n }\n }\n\n return made;\n};\n","/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n","var wrappy = require('wrappy')\nmodule.exports = wrappy(once)\nmodule.exports.strict = wrappy(onceStrict)\n\nonce.proto = once(function () {\n Object.defineProperty(Function.prototype, 'once', {\n value: function () {\n return once(this)\n },\n configurable: true\n })\n\n Object.defineProperty(Function.prototype, 'onceStrict', {\n value: function () {\n return onceStrict(this)\n },\n configurable: true\n })\n})\n\nfunction once (fn) {\n var f = function () {\n if (f.called) return f.value\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n f.called = false\n return f\n}\n\nfunction onceStrict (fn) {\n var f = function () {\n if (f.called)\n throw new Error(f.onceError)\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n var name = fn.name || 'Function wrapped with `once`'\n f.onceError = name + \" shouldn't be called more than once\"\n f.called = false\n return f\n}\n","var once = require('once')\nvar eos = require('end-of-stream')\nvar fs = require('fs') // we only need fs to get the ReadStream and WriteStream prototypes\n\nvar noop = function () {}\nvar ancient = /^v?\\.0/.test(process.version)\n\nvar isFn = function (fn) {\n return typeof fn === 'function'\n}\n\nvar isFS = function (stream) {\n if (!ancient) return false // newer node version do not need to care about fs is a special way\n if (!fs) return false // browser\n return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close)\n}\n\nvar isRequest = function (stream) {\n return stream.setHeader && isFn(stream.abort)\n}\n\nvar destroyer = function (stream, reading, writing, callback) {\n callback = once(callback)\n\n var closed = false\n stream.on('close', function () {\n closed = true\n })\n\n eos(stream, {readable: reading, writable: writing}, function (err) {\n if (err) return callback(err)\n closed = true\n callback()\n })\n\n var destroyed = false\n return function (err) {\n if (closed) return\n if (destroyed) return\n destroyed = true\n\n if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks\n if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want\n\n if (isFn(stream.destroy)) return stream.destroy()\n\n callback(err || new Error('stream was destroyed'))\n }\n}\n\nvar call = function (fn) {\n fn()\n}\n\nvar pipe = function (from, to) {\n return from.pipe(to)\n}\n\nvar pump = function () {\n var streams = Array.prototype.slice.call(arguments)\n var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop\n\n if (Array.isArray(streams[0])) streams = streams[0]\n if (streams.length < 2) throw new Error('pump requires two streams per minimum')\n\n var error\n var destroys = streams.map(function (stream, i) {\n var reading = i < streams.length - 1\n var writing = i > 0\n return destroyer(stream, reading, writing, function (err) {\n if (!error) error = err\n if (err) destroys.forEach(call)\n if (reading) return\n destroys.forEach(call)\n callback(error)\n })\n })\n\n return streams.reduce(pipe)\n}\n\nmodule.exports = pump\n","'use strict';\n\nconst codes = {};\n\nfunction createErrorType(code, message, Base) {\n if (!Base) {\n Base = Error\n }\n\n function getMessage (arg1, arg2, arg3) {\n if (typeof message === 'string') {\n return message\n } else {\n return message(arg1, arg2, arg3)\n }\n }\n\n class NodeError extends Base {\n constructor (arg1, arg2, arg3) {\n super(getMessage(arg1, arg2, arg3));\n }\n }\n\n NodeError.prototype.name = Base.name;\n NodeError.prototype.code = code;\n\n codes[code] = NodeError;\n}\n\n// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js\nfunction oneOf(expected, thing) {\n if (Array.isArray(expected)) {\n const len = expected.length;\n expected = expected.map((i) => String(i));\n if (len > 2) {\n return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +\n expected[len - 1];\n } else if (len === 2) {\n return `one of ${thing} ${expected[0]} or ${expected[1]}`;\n } else {\n return `of ${thing} ${expected[0]}`;\n }\n } else {\n return `of ${thing} ${String(expected)}`;\n }\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\nfunction startsWith(str, search, pos) {\n\treturn str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith\nfunction endsWith(str, search, this_len) {\n\tif (this_len === undefined || this_len > str.length) {\n\t\tthis_len = str.length;\n\t}\n\treturn str.substring(this_len - search.length, this_len) === search;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes\nfunction includes(str, search, start) {\n if (typeof start !== 'number') {\n start = 0;\n }\n\n if (start + search.length > str.length) {\n return false;\n } else {\n return str.indexOf(search, start) !== -1;\n }\n}\n\ncreateErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {\n return 'The value \"' + value + '\" is invalid for option \"' + name + '\"'\n}, TypeError);\ncreateErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {\n // determiner: 'must be' or 'must not be'\n let determiner;\n if (typeof expected === 'string' && startsWith(expected, 'not ')) {\n determiner = 'must not be';\n expected = expected.replace(/^not /, '');\n } else {\n determiner = 'must be';\n }\n\n let msg;\n if (endsWith(name, ' argument')) {\n // For cases like 'first argument'\n msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;\n } else {\n const type = includes(name, '.') ? 'property' : 'argument';\n msg = `The \"${name}\" ${type} ${determiner} ${oneOf(expected, 'type')}`;\n }\n\n msg += `. Received type ${typeof actual}`;\n return msg;\n}, TypeError);\ncreateErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');\ncreateErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {\n return 'The ' + name + ' method is not implemented'\n});\ncreateErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');\ncreateErrorType('ERR_STREAM_DESTROYED', function (name) {\n return 'Cannot call ' + name + ' after a stream was destroyed';\n});\ncreateErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');\ncreateErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');\ncreateErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');\ncreateErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);\ncreateErrorType('ERR_UNKNOWN_ENCODING', function (arg) {\n return 'Unknown encoding: ' + arg\n}, TypeError);\ncreateErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');\n\nmodule.exports.codes = codes;\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n'use strict';\n/**/\n\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n\n for (var key in obj) {\n keys.push(key);\n }\n\n return keys;\n};\n/**/\n\n\nmodule.exports = Duplex;\n\nvar Readable = require('./_stream_readable');\n\nvar Writable = require('./_stream_writable');\n\nrequire('inherits')(Duplex, Readable);\n\n{\n // Allow the keys array to be GC'ed.\n var keys = objectKeys(Writable.prototype);\n\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n Readable.call(this, options);\n Writable.call(this, options);\n this.allowHalfOpen = true;\n\n if (options) {\n if (options.readable === false) this.readable = false;\n if (options.writable === false) this.writable = false;\n\n if (options.allowHalfOpen === false) {\n this.allowHalfOpen = false;\n this.once('end', onend);\n }\n }\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.highWaterMark;\n }\n});\nObject.defineProperty(Duplex.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\nObject.defineProperty(Duplex.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.length;\n }\n}); // the no-half-open enforcer\n\nfunction onend() {\n // If the writable side ended, then we're ok.\n if (this._writableState.ended) return; // no more data can be written.\n // But allow more writes to happen in this tick.\n\n process.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\nrequire('inherits')(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n'use strict';\n\nmodule.exports = Readable;\n/**/\n\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n/**/\n\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function EElistenerCount(emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\n\n\nvar Stream = require('./internal/streams/stream');\n/**/\n\n\nvar Buffer = require('buffer').Buffer;\n\nvar OurUint8Array = global.Uint8Array || function () {};\n\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\n\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n/**/\n\n\nvar debugUtil = require('util');\n\nvar debug;\n\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function debug() {};\n}\n/**/\n\n\nvar BufferList = require('./internal/streams/buffer_list');\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nvar _require = require('./internal/streams/state'),\n getHighWaterMark = _require.getHighWaterMark;\n\nvar _require$codes = require('../errors').codes,\n ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,\n ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.\n\n\nvar StringDecoder;\nvar createReadableStreamAsyncIterator;\nvar from;\n\nrequire('inherits')(Readable, Stream);\n\nvar errorOrDestroy = destroyImpl.errorOrDestroy;\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream, isDuplex) {\n Duplex = Duplex || require('./_stream_duplex');\n options = options || {}; // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n\n this.objectMode = !!options.objectMode;\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n\n this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n\n this.sync = true; // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n this.paused = true; // Should close be emitted on destroy. Defaults to true.\n\n this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')\n\n this.autoDestroy = !!options.autoDestroy; // has it been destroyed\n\n this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n\n this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s\n\n this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled\n\n this.readingMore = false;\n this.decoder = null;\n this.encoding = null;\n\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside\n // the ReadableState constructor, at least with V8 6.5\n\n var isDuplex = this instanceof Duplex;\n this._readableState = new ReadableState(options, this, isDuplex); // legacy\n\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._readableState === undefined) {\n return false;\n }\n\n return this._readableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._readableState.destroyed = value;\n }\n});\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\n\nReadable.prototype._destroy = function (err, cb) {\n cb(err);\n}; // Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\n\n\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n}; // Unshift should *always* be something directly out of read()\n\n\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n debug('readableAddChunk', chunk);\n var state = stream._readableState;\n\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n\n if (er) {\n errorOrDestroy(stream, er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());\n } else if (state.destroyed) {\n return false;\n } else {\n state.reading = false;\n\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n maybeReadMore(stream, state);\n }\n } // We can push more data if we are below the highWaterMark.\n // Also, if we have no data yet, we can stand some more bytes.\n // This is to work around cases where hwm=0, such as the repl.\n\n\n return !state.ended && (state.length < state.highWaterMark || state.length === 0);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n state.awaitDrain = 0;\n stream.emit('data', chunk);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n if (state.needReadable) emitReadable(stream);\n }\n\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);\n }\n\n return er;\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n}; // backwards compatibility.\n\n\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n var decoder = new StringDecoder(enc);\n this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8\n\n this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:\n\n var p = this._readableState.buffer.head;\n var content = '';\n\n while (p !== null) {\n content += decoder.write(p.data);\n p = p.next;\n }\n\n this._readableState.buffer.clear();\n\n if (content !== '') this._readableState.buffer.push(content);\n this._readableState.length = content.length;\n return this;\n}; // Don't raise the hwm > 1GB\n\n\nvar MAX_HWM = 0x40000000;\n\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n\n return n;\n} // This function is designed to be inlinable, so please take care when making\n// changes to the function body.\n\n\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n } // If we're asking for more than the current hwm, then raise the hwm.\n\n\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n; // Don't have enough\n\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n\n return state.length;\n} // you can override either this method, or the async _read(n) below.\n\n\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n\n if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.\n\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n } // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n // if we need a readable event, then we need to do some reading.\n\n\n var doRead = state.needReadable;\n debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some\n\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n } // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n\n\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true; // if the length is currently zero, then we *need* a readable event.\n\n if (state.length === 0) state.needReadable = true; // call internal read method\n\n this._read(state.highWaterMark);\n\n state.sync = false; // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = state.length <= state.highWaterMark;\n n = 0;\n } else {\n state.length -= n;\n state.awaitDrain = 0;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.\n\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n debug('onEofChunk');\n if (state.ended) return;\n\n if (state.decoder) {\n var chunk = state.decoder.end();\n\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n\n state.ended = true;\n\n if (state.sync) {\n // if we are sync, wait until next tick to emit the data.\n // Otherwise we risk emitting data in the flow()\n // the readable code triggers during a read() call\n emitReadable(stream);\n } else {\n // emit 'readable' now to make sure it gets picked up.\n state.needReadable = false;\n\n if (!state.emittedReadable) {\n state.emittedReadable = true;\n emitReadable_(stream);\n }\n }\n} // Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\n\n\nfunction emitReadable(stream) {\n var state = stream._readableState;\n debug('emitReadable', state.needReadable, state.emittedReadable);\n state.needReadable = false;\n\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n process.nextTick(emitReadable_, stream);\n }\n}\n\nfunction emitReadable_(stream) {\n var state = stream._readableState;\n debug('emitReadable_', state.destroyed, state.length, state.ended);\n\n if (!state.destroyed && (state.length || state.ended)) {\n stream.emit('readable');\n state.emittedReadable = false;\n } // The stream needs another readable event if\n // 1. It is not flowing, as the flow mechanism will take\n // care of it.\n // 2. It is not ended.\n // 3. It is below the highWaterMark, so we can schedule\n // another readable later.\n\n\n state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;\n flow(stream);\n} // at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\n\n\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n process.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n // Attempt to read more data if we should.\n //\n // The conditions for reading more data are (one of):\n // - Not enough data buffered (state.length < state.highWaterMark). The loop\n // is responsible for filling the buffer with enough data if such data\n // is available. If highWaterMark is 0 and we are not in the flowing mode\n // we should _not_ attempt to buffer any extra data. We'll get more data\n // when the stream consumer calls read() instead.\n // - No data in the buffer, and the stream is in flowing mode. In this mode\n // the loop below is responsible for ensuring read() is called. Failing to\n // call read here would abort the flow and there's no other mechanism for\n // continuing the flow if the stream consumer has just subscribed to the\n // 'data' event.\n //\n // In addition to the above conditions to keep reading data, the following\n // conditions prevent the data from being read:\n // - The stream has ended (state.ended).\n // - There is already a pending 'read' operation (state.reading). This is a\n // case where the the stream has called the implementation defined _read()\n // method, but they are processing the call asynchronously and have _not_\n // called push() with new data. In this case we skip performing more\n // read()s. The execution ends in this method again after the _read() ends\n // up calling push() with more data.\n while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {\n var len = state.length;\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length) // didn't get any data, stop spinning.\n break;\n }\n\n state.readingMore = false;\n} // abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\n\n\nReadable.prototype._read = function (n) {\n errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n\n default:\n state.pipes.push(dest);\n break;\n }\n\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);\n dest.on('unpipe', onunpipe);\n\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n } // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n\n\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n var cleanedUp = false;\n\n function cleanup() {\n debug('cleanup'); // cleanup event handlers once the pipe is broken\n\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n cleanedUp = true; // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n src.on('data', ondata);\n\n function ondata(chunk) {\n debug('ondata');\n var ret = dest.write(chunk);\n debug('dest.write', ret);\n\n if (ret === false) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', state.awaitDrain);\n state.awaitDrain++;\n }\n\n src.pause();\n }\n } // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n\n\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);\n } // Make sure our error handler is attached before userland ones.\n\n\n prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.\n\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n\n dest.once('close', onclose);\n\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n } // tell the dest that it's being piped to\n\n\n dest.emit('pipe', src); // start the flow if it hasn't been started already.\n\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function pipeOnDrainFunctionResult() {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = {\n hasUnpiped: false\n }; // if we're not piping anywhere, then do nothing.\n\n if (state.pipesCount === 0) return this; // just one destination. most common case.\n\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n if (!dest) dest = state.pipes; // got a match.\n\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n } // slow case. multiple pipe destinations.\n\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, {\n hasUnpiped: false\n });\n }\n\n return this;\n } // try to find the right one.\n\n\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n dest.emit('unpipe', this, unpipeInfo);\n return this;\n}; // set up data events if they are asked for\n// Ensure readable listeners eventually get something\n\n\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n var state = this._readableState;\n\n if (ev === 'data') {\n // update readableListening so that resume() may be a no-op\n // a few lines down. This is needed to support once('readable').\n state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused\n\n if (state.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.flowing = false;\n state.emittedReadable = false;\n debug('on readable', state.length, state.reading);\n\n if (state.length) {\n emitReadable(this);\n } else if (!state.reading) {\n process.nextTick(nReadingNextTick, this);\n }\n }\n }\n\n return res;\n};\n\nReadable.prototype.addListener = Readable.prototype.on;\n\nReadable.prototype.removeListener = function (ev, fn) {\n var res = Stream.prototype.removeListener.call(this, ev, fn);\n\n if (ev === 'readable') {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nReadable.prototype.removeAllListeners = function (ev) {\n var res = Stream.prototype.removeAllListeners.apply(this, arguments);\n\n if (ev === 'readable' || ev === undefined) {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nfunction updateReadableListening(self) {\n var state = self._readableState;\n state.readableListening = self.listenerCount('readable') > 0;\n\n if (state.resumeScheduled && !state.paused) {\n // flowing needs to be set to true now, otherwise\n // the upcoming resume will not flow.\n state.flowing = true; // crude way to check if we should resume\n } else if (self.listenerCount('data') > 0) {\n self.resume();\n }\n}\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n} // pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\n\n\nReadable.prototype.resume = function () {\n var state = this._readableState;\n\n if (!state.flowing) {\n debug('resume'); // we flow only if there is no one listening\n // for readable, but we still have to call\n // resume()\n\n state.flowing = !state.readableListening;\n resume(this, state);\n }\n\n state.paused = false;\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n process.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n debug('resume', state.reading);\n\n if (!state.reading) {\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n\n if (this._readableState.flowing !== false) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n\n this._readableState.paused = true;\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n\n while (state.flowing && stream.read() !== null) {\n ;\n }\n} // wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\n\n\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n stream.on('end', function () {\n debug('wrapped end');\n\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode\n\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n\n if (!ret) {\n paused = true;\n stream.pause();\n }\n }); // proxy all the other methods.\n // important when wrapping filters and duplexes.\n\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function methodWrap(method) {\n return function methodWrapReturnFunction() {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n } // proxy certain important events.\n\n\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n } // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n\n\n this._read = function (n) {\n debug('wrapped _read', n);\n\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nif (typeof Symbol === 'function') {\n Readable.prototype[Symbol.asyncIterator] = function () {\n if (createReadableStreamAsyncIterator === undefined) {\n createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');\n }\n\n return createReadableStreamAsyncIterator(this);\n };\n}\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.highWaterMark;\n }\n});\nObject.defineProperty(Readable.prototype, 'readableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState && this._readableState.buffer;\n }\n});\nObject.defineProperty(Readable.prototype, 'readableFlowing', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.flowing;\n },\n set: function set(state) {\n if (this._readableState) {\n this._readableState.flowing = state;\n }\n }\n}); // exposed for testing purposes only.\n\nReadable._fromList = fromList;\nObject.defineProperty(Readable.prototype, 'readableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.length;\n }\n}); // Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\n\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = state.buffer.consume(n, state.decoder);\n }\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n debug('endReadable', state.endEmitted);\n\n if (!state.endEmitted) {\n state.ended = true;\n process.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.\n\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n\n if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the writable side is ready for autoDestroy as well\n var wState = stream._writableState;\n\n if (!wState || wState.autoDestroy && wState.finished) {\n stream.destroy();\n }\n }\n }\n}\n\nif (typeof Symbol === 'function') {\n Readable.from = function (iterable, opts) {\n if (from === undefined) {\n from = require('./internal/streams/from');\n }\n\n return from(Readable, iterable, opts);\n };\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n'use strict';\n\nmodule.exports = Transform;\n\nvar _require$codes = require('../errors').codes,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,\n ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,\n ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;\n\nvar Duplex = require('./_stream_duplex');\n\nrequire('inherits')(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n var cb = ts.writecb;\n\n if (cb === null) {\n return this.emit('error', new ERR_MULTIPLE_CALLBACK());\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n cb(er);\n var rs = this._readableState;\n rs.reading = false;\n\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n Duplex.call(this, options);\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n }; // start out asking for a readable event once data is transformed.\n\n this._readableState.needReadable = true; // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n if (typeof options.flush === 'function') this._flush = options.flush;\n } // When the writable side finishes, then flush out anything remaining.\n\n\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function' && !this._readableState.destroyed) {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n}; // This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\n\n\nTransform.prototype._transform = function (chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n}; // Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\n\n\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && !ts.transforming) {\n ts.transforming = true;\n\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data); // TODO(BridgeAR): Write a test for these two error cases\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n\n if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();\n if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n'use strict';\n\nmodule.exports = Writable;\n/* */\n\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n} // It seems a linked list but it is not\n// there will be only 2 of these for each stream\n\n\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\n\n\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n/**/\n\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\n\nvar Stream = require('./internal/streams/stream');\n/**/\n\n\nvar Buffer = require('buffer').Buffer;\n\nvar OurUint8Array = global.Uint8Array || function () {};\n\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\n\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nvar _require = require('./internal/streams/state'),\n getHighWaterMark = _require.getHighWaterMark;\n\nvar _require$codes = require('../errors').codes,\n ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,\n ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,\n ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,\n ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,\n ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,\n ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;\n\nvar errorOrDestroy = destroyImpl.errorOrDestroy;\n\nrequire('inherits')(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream, isDuplex) {\n Duplex = Duplex || require('./_stream_duplex');\n options = options || {}; // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream,\n // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.\n\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n\n this.objectMode = !!options.objectMode;\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n\n this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called\n\n this.finalCalled = false; // drain event flag.\n\n this.needDrain = false; // at the start of calling end()\n\n this.ending = false; // when end() has been called, and returned\n\n this.ended = false; // when 'finish' is emitted\n\n this.finished = false; // has it been destroyed\n\n this.destroyed = false; // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n\n this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n\n this.length = 0; // a flag to see when we're in the middle of a write.\n\n this.writing = false; // when true all writes will be buffered until .uncork() call\n\n this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n\n this.sync = true; // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n\n this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)\n\n this.onwrite = function (er) {\n onwrite(stream, er);\n }; // the callback that the user supplies to write(chunk,encoding,cb)\n\n\n this.writecb = null; // the amount that is being written when _write is called.\n\n this.writelen = 0;\n this.bufferedRequest = null;\n this.lastBufferedRequest = null; // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n\n this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n\n this.prefinished = false; // True if the error was already emitted and should not be thrown again\n\n this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.\n\n this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')\n\n this.autoDestroy = !!options.autoDestroy; // count buffered requests\n\n this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n\n while (current) {\n out.push(current);\n current = current.next;\n }\n\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function writableStateBufferGetter() {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})(); // Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\n\n\nvar realHasInstance;\n\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function value(object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function realHasInstance(object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n // Checking for a Stream.Duplex instance is faster here instead of inside\n // the WritableState constructor, at least with V8 6.5\n\n var isDuplex = this instanceof Duplex;\n if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);\n this._writableState = new WritableState(options, this, isDuplex); // legacy.\n\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n if (typeof options.writev === 'function') this._writev = options.writev;\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n} // Otherwise people can pipe Writable streams, which is just wrong.\n\n\nWritable.prototype.pipe = function () {\n errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb\n\n errorOrDestroy(stream, er);\n process.nextTick(cb, er);\n} // Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\n\n\nfunction validChunk(stream, state, chunk, cb) {\n var er;\n\n if (chunk === null) {\n er = new ERR_STREAM_NULL_VALUES();\n } else if (typeof chunk !== 'string' && !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);\n }\n\n if (er) {\n errorOrDestroy(stream, er);\n process.nextTick(cb, er);\n return false;\n }\n\n return true;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n if (typeof cb !== 'function') cb = nop;\n if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n return ret;\n};\n\nWritable.prototype.cork = function () {\n this._writableState.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.highWaterMark;\n }\n}); // if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\n\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n\n var len = state.objectMode ? 1 : chunk.length;\n state.length += len;\n var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.\n\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n process.nextTick(cb, er); // this can emit finish, and it will always happen\n // after error\n\n process.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n errorOrDestroy(stream, er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n errorOrDestroy(stream, er); // this can emit finish, but finish must\n // always follow error\n\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();\n onwriteStateUpdate(state);\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state) || stream.destroyed;\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n process.nextTick(afterWrite, stream, state, finished, cb);\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n} // Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\n\n\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it\n\n\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n var count = 0;\n var allBuffers = true;\n\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n\n buffer.allBuffers = allBuffers;\n doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n\n state.pendingcb++;\n state.lastBufferedRequest = null;\n\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks\n\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n } // ignore unnecessary end() calls.\n\n\n if (!state.ending) endWritable(this, state, cb);\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.length;\n }\n});\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\n\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n\n if (err) {\n errorOrDestroy(stream, err);\n }\n\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\n\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function' && !state.destroyed) {\n state.pendingcb++;\n state.finalCalled = true;\n process.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n\n if (need) {\n prefinish(stream, state);\n\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n\n if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the readable side is ready for autoDestroy as well\n var rState = stream._readableState;\n\n if (!rState || rState.autoDestroy && rState.endEmitted) {\n stream.destroy();\n }\n }\n }\n }\n\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n\n if (cb) {\n if (state.finished) process.nextTick(cb);else stream.once('finish', cb);\n }\n\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n } // reuse the free corkReq.\n\n\n state.corkedRequestsFree.next = corkReq;\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._writableState === undefined) {\n return false;\n }\n\n return this._writableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._writableState.destroyed = value;\n }\n});\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\n\nWritable.prototype._destroy = function (err, cb) {\n cb(err);\n};","'use strict';\n\nvar _Object$setPrototypeO;\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar finished = require('./end-of-stream');\n\nvar kLastResolve = Symbol('lastResolve');\nvar kLastReject = Symbol('lastReject');\nvar kError = Symbol('error');\nvar kEnded = Symbol('ended');\nvar kLastPromise = Symbol('lastPromise');\nvar kHandlePromise = Symbol('handlePromise');\nvar kStream = Symbol('stream');\n\nfunction createIterResult(value, done) {\n return {\n value: value,\n done: done\n };\n}\n\nfunction readAndResolve(iter) {\n var resolve = iter[kLastResolve];\n\n if (resolve !== null) {\n var data = iter[kStream].read(); // we defer if data is null\n // we can be expecting either 'end' or\n // 'error'\n\n if (data !== null) {\n iter[kLastPromise] = null;\n iter[kLastResolve] = null;\n iter[kLastReject] = null;\n resolve(createIterResult(data, false));\n }\n }\n}\n\nfunction onReadable(iter) {\n // we wait for the next tick, because it might\n // emit an error with process.nextTick\n process.nextTick(readAndResolve, iter);\n}\n\nfunction wrapForNext(lastPromise, iter) {\n return function (resolve, reject) {\n lastPromise.then(function () {\n if (iter[kEnded]) {\n resolve(createIterResult(undefined, true));\n return;\n }\n\n iter[kHandlePromise](resolve, reject);\n }, reject);\n };\n}\n\nvar AsyncIteratorPrototype = Object.getPrototypeOf(function () {});\nvar ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {\n get stream() {\n return this[kStream];\n },\n\n next: function next() {\n var _this = this;\n\n // if we have detected an error in the meanwhile\n // reject straight away\n var error = this[kError];\n\n if (error !== null) {\n return Promise.reject(error);\n }\n\n if (this[kEnded]) {\n return Promise.resolve(createIterResult(undefined, true));\n }\n\n if (this[kStream].destroyed) {\n // We need to defer via nextTick because if .destroy(err) is\n // called, the error will be emitted via nextTick, and\n // we cannot guarantee that there is no error lingering around\n // waiting to be emitted.\n return new Promise(function (resolve, reject) {\n process.nextTick(function () {\n if (_this[kError]) {\n reject(_this[kError]);\n } else {\n resolve(createIterResult(undefined, true));\n }\n });\n });\n } // if we have multiple next() calls\n // we will wait for the previous Promise to finish\n // this logic is optimized to support for await loops,\n // where next() is only called once at a time\n\n\n var lastPromise = this[kLastPromise];\n var promise;\n\n if (lastPromise) {\n promise = new Promise(wrapForNext(lastPromise, this));\n } else {\n // fast path needed to support multiple this.push()\n // without triggering the next() queue\n var data = this[kStream].read();\n\n if (data !== null) {\n return Promise.resolve(createIterResult(data, false));\n }\n\n promise = new Promise(this[kHandlePromise]);\n }\n\n this[kLastPromise] = promise;\n return promise;\n }\n}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {\n return this;\n}), _defineProperty(_Object$setPrototypeO, \"return\", function _return() {\n var _this2 = this;\n\n // destroy(err, cb) is a private API\n // we can guarantee we have that here, because we control the\n // Readable class this is attached to\n return new Promise(function (resolve, reject) {\n _this2[kStream].destroy(null, function (err) {\n if (err) {\n reject(err);\n return;\n }\n\n resolve(createIterResult(undefined, true));\n });\n });\n}), _Object$setPrototypeO), AsyncIteratorPrototype);\n\nvar createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {\n var _Object$create;\n\n var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {\n value: stream,\n writable: true\n }), _defineProperty(_Object$create, kLastResolve, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kLastReject, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kError, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kEnded, {\n value: stream._readableState.endEmitted,\n writable: true\n }), _defineProperty(_Object$create, kHandlePromise, {\n value: function value(resolve, reject) {\n var data = iterator[kStream].read();\n\n if (data) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n resolve(createIterResult(data, false));\n } else {\n iterator[kLastResolve] = resolve;\n iterator[kLastReject] = reject;\n }\n },\n writable: true\n }), _Object$create));\n iterator[kLastPromise] = null;\n finished(stream, function (err) {\n if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {\n var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise\n // returned by next() and store the error\n\n if (reject !== null) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n reject(err);\n }\n\n iterator[kError] = err;\n return;\n }\n\n var resolve = iterator[kLastResolve];\n\n if (resolve !== null) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n resolve(createIterResult(undefined, true));\n }\n\n iterator[kEnded] = true;\n });\n stream.on('readable', onReadable.bind(null, iterator));\n return iterator;\n};\n\nmodule.exports = createReadableStreamAsyncIterator;","'use strict';\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar _require = require('buffer'),\n Buffer = _require.Buffer;\n\nvar _require2 = require('util'),\n inspect = _require2.inspect;\n\nvar custom = inspect && inspect.custom || 'inspect';\n\nfunction copyBuffer(src, target, offset) {\n Buffer.prototype.copy.call(src, target, offset);\n}\n\nmodule.exports =\n/*#__PURE__*/\nfunction () {\n function BufferList() {\n _classCallCheck(this, BufferList);\n\n this.head = null;\n this.tail = null;\n this.length = 0;\n }\n\n _createClass(BufferList, [{\n key: \"push\",\n value: function push(v) {\n var entry = {\n data: v,\n next: null\n };\n if (this.length > 0) this.tail.next = entry;else this.head = entry;\n this.tail = entry;\n ++this.length;\n }\n }, {\n key: \"unshift\",\n value: function unshift(v) {\n var entry = {\n data: v,\n next: this.head\n };\n if (this.length === 0) this.tail = entry;\n this.head = entry;\n ++this.length;\n }\n }, {\n key: \"shift\",\n value: function shift() {\n if (this.length === 0) return;\n var ret = this.head.data;\n if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;\n --this.length;\n return ret;\n }\n }, {\n key: \"clear\",\n value: function clear() {\n this.head = this.tail = null;\n this.length = 0;\n }\n }, {\n key: \"join\",\n value: function join(s) {\n if (this.length === 0) return '';\n var p = this.head;\n var ret = '' + p.data;\n\n while (p = p.next) {\n ret += s + p.data;\n }\n\n return ret;\n }\n }, {\n key: \"concat\",\n value: function concat(n) {\n if (this.length === 0) return Buffer.alloc(0);\n var ret = Buffer.allocUnsafe(n >>> 0);\n var p = this.head;\n var i = 0;\n\n while (p) {\n copyBuffer(p.data, ret, i);\n i += p.data.length;\n p = p.next;\n }\n\n return ret;\n } // Consumes a specified amount of bytes or characters from the buffered data.\n\n }, {\n key: \"consume\",\n value: function consume(n, hasStrings) {\n var ret;\n\n if (n < this.head.data.length) {\n // `slice` is the same for buffers and strings.\n ret = this.head.data.slice(0, n);\n this.head.data = this.head.data.slice(n);\n } else if (n === this.head.data.length) {\n // First chunk is a perfect match.\n ret = this.shift();\n } else {\n // Result spans more than one buffer.\n ret = hasStrings ? this._getString(n) : this._getBuffer(n);\n }\n\n return ret;\n }\n }, {\n key: \"first\",\n value: function first() {\n return this.head.data;\n } // Consumes a specified amount of characters from the buffered data.\n\n }, {\n key: \"_getString\",\n value: function _getString(n) {\n var p = this.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) this.head = p.next;else this.head = this.tail = null;\n } else {\n this.head = p;\n p.data = str.slice(nb);\n }\n\n break;\n }\n\n ++c;\n }\n\n this.length -= c;\n return ret;\n } // Consumes a specified amount of bytes from the buffered data.\n\n }, {\n key: \"_getBuffer\",\n value: function _getBuffer(n) {\n var ret = Buffer.allocUnsafe(n);\n var p = this.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) this.head = p.next;else this.head = this.tail = null;\n } else {\n this.head = p;\n p.data = buf.slice(nb);\n }\n\n break;\n }\n\n ++c;\n }\n\n this.length -= c;\n return ret;\n } // Make sure the linked list only shows the minimal necessary information.\n\n }, {\n key: custom,\n value: function value(_, options) {\n return inspect(this, _objectSpread({}, options, {\n // Only inspect one level.\n depth: 0,\n // It should not recurse.\n customInspect: false\n }));\n }\n }]);\n\n return BufferList;\n}();","'use strict'; // undocumented cb() API, needed for core, not for public API\n\nfunction destroy(err, cb) {\n var _this = this;\n\n var readableDestroyed = this._readableState && this._readableState.destroyed;\n var writableDestroyed = this._writableState && this._writableState.destroyed;\n\n if (readableDestroyed || writableDestroyed) {\n if (cb) {\n cb(err);\n } else if (err) {\n if (!this._writableState) {\n process.nextTick(emitErrorNT, this, err);\n } else if (!this._writableState.errorEmitted) {\n this._writableState.errorEmitted = true;\n process.nextTick(emitErrorNT, this, err);\n }\n }\n\n return this;\n } // we set destroyed to true before firing error callbacks in order\n // to make it re-entrance safe in case destroy() is called within callbacks\n\n\n if (this._readableState) {\n this._readableState.destroyed = true;\n } // if this is a duplex stream mark the writable part as destroyed as well\n\n\n if (this._writableState) {\n this._writableState.destroyed = true;\n }\n\n this._destroy(err || null, function (err) {\n if (!cb && err) {\n if (!_this._writableState) {\n process.nextTick(emitErrorAndCloseNT, _this, err);\n } else if (!_this._writableState.errorEmitted) {\n _this._writableState.errorEmitted = true;\n process.nextTick(emitErrorAndCloseNT, _this, err);\n } else {\n process.nextTick(emitCloseNT, _this);\n }\n } else if (cb) {\n process.nextTick(emitCloseNT, _this);\n cb(err);\n } else {\n process.nextTick(emitCloseNT, _this);\n }\n });\n\n return this;\n}\n\nfunction emitErrorAndCloseNT(self, err) {\n emitErrorNT(self, err);\n emitCloseNT(self);\n}\n\nfunction emitCloseNT(self) {\n if (self._writableState && !self._writableState.emitClose) return;\n if (self._readableState && !self._readableState.emitClose) return;\n self.emit('close');\n}\n\nfunction undestroy() {\n if (this._readableState) {\n this._readableState.destroyed = false;\n this._readableState.reading = false;\n this._readableState.ended = false;\n this._readableState.endEmitted = false;\n }\n\n if (this._writableState) {\n this._writableState.destroyed = false;\n this._writableState.ended = false;\n this._writableState.ending = false;\n this._writableState.finalCalled = false;\n this._writableState.prefinished = false;\n this._writableState.finished = false;\n this._writableState.errorEmitted = false;\n }\n}\n\nfunction emitErrorNT(self, err) {\n self.emit('error', err);\n}\n\nfunction errorOrDestroy(stream, err) {\n // We have tests that rely on errors being emitted\n // in the same tick, so changing this is semver major.\n // For now when you opt-in to autoDestroy we allow\n // the error to be emitted nextTick. In a future\n // semver major update we should change the default to this.\n var rState = stream._readableState;\n var wState = stream._writableState;\n if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);\n}\n\nmodule.exports = {\n destroy: destroy,\n undestroy: undestroy,\n errorOrDestroy: errorOrDestroy\n};","// Ported from https://github.com/mafintosh/end-of-stream with\n// permission from the author, Mathias Buus (@mafintosh).\n'use strict';\n\nvar ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;\n\nfunction once(callback) {\n var called = false;\n return function () {\n if (called) return;\n called = true;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n callback.apply(this, args);\n };\n}\n\nfunction noop() {}\n\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function';\n}\n\nfunction eos(stream, opts, callback) {\n if (typeof opts === 'function') return eos(stream, null, opts);\n if (!opts) opts = {};\n callback = once(callback || noop);\n var readable = opts.readable || opts.readable !== false && stream.readable;\n var writable = opts.writable || opts.writable !== false && stream.writable;\n\n var onlegacyfinish = function onlegacyfinish() {\n if (!stream.writable) onfinish();\n };\n\n var writableEnded = stream._writableState && stream._writableState.finished;\n\n var onfinish = function onfinish() {\n writable = false;\n writableEnded = true;\n if (!readable) callback.call(stream);\n };\n\n var readableEnded = stream._readableState && stream._readableState.endEmitted;\n\n var onend = function onend() {\n readable = false;\n readableEnded = true;\n if (!writable) callback.call(stream);\n };\n\n var onerror = function onerror(err) {\n callback.call(stream, err);\n };\n\n var onclose = function onclose() {\n var err;\n\n if (readable && !readableEnded) {\n if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();\n return callback.call(stream, err);\n }\n\n if (writable && !writableEnded) {\n if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();\n return callback.call(stream, err);\n }\n };\n\n var onrequest = function onrequest() {\n stream.req.on('finish', onfinish);\n };\n\n if (isRequest(stream)) {\n stream.on('complete', onfinish);\n stream.on('abort', onclose);\n if (stream.req) onrequest();else stream.on('request', onrequest);\n } else if (writable && !stream._writableState) {\n // legacy streams\n stream.on('end', onlegacyfinish);\n stream.on('close', onlegacyfinish);\n }\n\n stream.on('end', onend);\n stream.on('finish', onfinish);\n if (opts.error !== false) stream.on('error', onerror);\n stream.on('close', onclose);\n return function () {\n stream.removeListener('complete', onfinish);\n stream.removeListener('abort', onclose);\n stream.removeListener('request', onrequest);\n if (stream.req) stream.req.removeListener('finish', onfinish);\n stream.removeListener('end', onlegacyfinish);\n stream.removeListener('close', onlegacyfinish);\n stream.removeListener('finish', onfinish);\n stream.removeListener('end', onend);\n stream.removeListener('error', onerror);\n stream.removeListener('close', onclose);\n };\n}\n\nmodule.exports = eos;","'use strict';\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar ERR_INVALID_ARG_TYPE = require('../../../errors').codes.ERR_INVALID_ARG_TYPE;\n\nfunction from(Readable, iterable, opts) {\n var iterator;\n\n if (iterable && typeof iterable.next === 'function') {\n iterator = iterable;\n } else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);\n\n var readable = new Readable(_objectSpread({\n objectMode: true\n }, opts)); // Reading boolean to protect against _read\n // being called before last iteration completion.\n\n var reading = false;\n\n readable._read = function () {\n if (!reading) {\n reading = true;\n next();\n }\n };\n\n function next() {\n return _next2.apply(this, arguments);\n }\n\n function _next2() {\n _next2 = _asyncToGenerator(function* () {\n try {\n var _ref = yield iterator.next(),\n value = _ref.value,\n done = _ref.done;\n\n if (done) {\n readable.push(null);\n } else if (readable.push((yield value))) {\n next();\n } else {\n reading = false;\n }\n } catch (err) {\n readable.destroy(err);\n }\n });\n return _next2.apply(this, arguments);\n }\n\n return readable;\n}\n\nmodule.exports = from;","// Ported from https://github.com/mafintosh/pump with\n// permission from the author, Mathias Buus (@mafintosh).\n'use strict';\n\nvar eos;\n\nfunction once(callback) {\n var called = false;\n return function () {\n if (called) return;\n called = true;\n callback.apply(void 0, arguments);\n };\n}\n\nvar _require$codes = require('../../../errors').codes,\n ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,\n ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;\n\nfunction noop(err) {\n // Rethrow the error if it exists to avoid swallowing it\n if (err) throw err;\n}\n\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function';\n}\n\nfunction destroyer(stream, reading, writing, callback) {\n callback = once(callback);\n var closed = false;\n stream.on('close', function () {\n closed = true;\n });\n if (eos === undefined) eos = require('./end-of-stream');\n eos(stream, {\n readable: reading,\n writable: writing\n }, function (err) {\n if (err) return callback(err);\n closed = true;\n callback();\n });\n var destroyed = false;\n return function (err) {\n if (closed) return;\n if (destroyed) return;\n destroyed = true; // request.destroy just do .end - .abort is what we want\n\n if (isRequest(stream)) return stream.abort();\n if (typeof stream.destroy === 'function') return stream.destroy();\n callback(err || new ERR_STREAM_DESTROYED('pipe'));\n };\n}\n\nfunction call(fn) {\n fn();\n}\n\nfunction pipe(from, to) {\n return from.pipe(to);\n}\n\nfunction popCallback(streams) {\n if (!streams.length) return noop;\n if (typeof streams[streams.length - 1] !== 'function') return noop;\n return streams.pop();\n}\n\nfunction pipeline() {\n for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {\n streams[_key] = arguments[_key];\n }\n\n var callback = popCallback(streams);\n if (Array.isArray(streams[0])) streams = streams[0];\n\n if (streams.length < 2) {\n throw new ERR_MISSING_ARGS('streams');\n }\n\n var error;\n var destroys = streams.map(function (stream, i) {\n var reading = i < streams.length - 1;\n var writing = i > 0;\n return destroyer(stream, reading, writing, function (err) {\n if (!error) error = err;\n if (err) destroys.forEach(call);\n if (reading) return;\n destroys.forEach(call);\n callback(error);\n });\n });\n return streams.reduce(pipe);\n}\n\nmodule.exports = pipeline;","'use strict';\n\nvar ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;\n\nfunction highWaterMarkFrom(options, isDuplex, duplexKey) {\n return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;\n}\n\nfunction getHighWaterMark(state, options, duplexKey, isDuplex) {\n var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);\n\n if (hwm != null) {\n if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {\n var name = isDuplex ? duplexKey : 'highWaterMark';\n throw new ERR_INVALID_OPT_VALUE(name, hwm);\n }\n\n return Math.floor(hwm);\n } // Default value\n\n\n return state.objectMode ? 16 : 16 * 1024;\n}\n\nmodule.exports = {\n getHighWaterMark: getHighWaterMark\n};","module.exports = require('stream');\n","var Stream = require('stream');\nif (process.env.READABLE_STREAM === 'disable' && Stream) {\n module.exports = Stream.Readable;\n Object.assign(module.exports, Stream);\n module.exports.Stream = Stream;\n} else {\n exports = module.exports = require('./lib/_stream_readable.js');\n exports.Stream = Stream || exports;\n exports.Readable = exports;\n exports.Writable = require('./lib/_stream_writable.js');\n exports.Duplex = require('./lib/_stream_duplex.js');\n exports.Transform = require('./lib/_stream_transform.js');\n exports.PassThrough = require('./lib/_stream_passthrough.js');\n exports.finished = require('./lib/internal/streams/end-of-stream.js');\n exports.pipeline = require('./lib/internal/streams/pipeline.js');\n}\n","/* eslint-disable node/no-deprecated-api */\n\n'use strict'\n\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\nvar safer = {}\n\nvar key\n\nfor (key in buffer) {\n if (!buffer.hasOwnProperty(key)) continue\n if (key === 'SlowBuffer' || key === 'Buffer') continue\n safer[key] = buffer[key]\n}\n\nvar Safer = safer.Buffer = {}\nfor (key in Buffer) {\n if (!Buffer.hasOwnProperty(key)) continue\n if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue\n Safer[key] = Buffer[key]\n}\n\nsafer.Buffer.prototype = Buffer.prototype\n\nif (!Safer.from || Safer.from === Uint8Array.from) {\n Safer.from = function (value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('The \"value\" argument must not be of type number. Received type ' + typeof value)\n }\n if (value && typeof value.length === 'undefined') {\n throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)\n }\n return Buffer(value, encodingOrOffset, length)\n }\n}\n\nif (!Safer.alloc) {\n Safer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('The \"size\" argument must be of type number. Received type ' + typeof size)\n }\n if (size < 0 || size >= 2 * (1 << 30)) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n var buf = Buffer(size)\n if (!fill || fill.length === 0) {\n buf.fill(0)\n } else if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n return buf\n }\n}\n\nif (!safer.kStringMaxLength) {\n try {\n safer.kStringMaxLength = process.binding('buffer').kStringMaxLength\n } catch (e) {\n // we can't determine kStringMaxLength in environments where process.binding\n // is unsupported, so let's not set it\n }\n}\n\nif (!safer.constants) {\n safer.constants = {\n MAX_LENGTH: safer.kMaxLength\n }\n if (safer.kStringMaxLength) {\n safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength\n }\n}\n\nmodule.exports = safer\n","var fs = require('fs');\n\nmodule.exports = function (filepath, split, encoding) {\n split = typeof split !== 'undefined' ? split : \"\\n\";\n encoding = typeof encoding !== 'undefined' ? encoding : \"utf8\";\n\n var ca = [];\n var chain = fs.readFileSync(filepath, encoding);\n if(chain.indexOf(\"-END CERTIFICATE-\") < 0 || chain.indexOf(\"-BEGIN CERTIFICATE-\") < 0){\n throw Error(\"File does not contain 'BEGIN CERTIFICATE' or 'END CERTIFICATE'\");\n }\n chain = chain.split(split);\n var cert = [];\n var _i, _len;\n for (_i = 0, _len = chain.length; _i < _len; _i++) {\n var line = chain[_i];\n if (!(line.length !== 0)) {\n continue;\n }\n cert.push(line);\n if (line.match(/-END CERTIFICATE-/)) {\n ca.push(cert.join(split));\n cert = [];\n }\n }\n return ca;\n}\n","'use strict';\n\nconst {\n Duplex: DuplexStream,\n Readable: ReadableStream,\n Writable: WritableStream,\n} = require('stream');\n\nconst {\n CHANNEL_EXTENDED_DATATYPE: { STDERR },\n} = require('./protocol/constants.js');\nconst { bufferSlice } = require('./protocol/utils.js');\n\nconst PACKET_SIZE = 32 * 1024;\nconst MAX_WINDOW = 2 * 1024 * 1024;\nconst WINDOW_THRESHOLD = MAX_WINDOW / 2;\n\nclass ClientStderr extends ReadableStream {\n constructor(channel, streamOpts) {\n super(streamOpts);\n\n this._channel = channel;\n }\n _read(n) {\n if (this._channel._waitChanDrain) {\n this._channel._waitChanDrain = false;\n if (this._channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(this._channel);\n }\n }\n}\n\nclass ServerStderr extends WritableStream {\n constructor(channel) {\n super({ highWaterMark: MAX_WINDOW });\n\n this._channel = channel;\n }\n\n _write(data, encoding, cb) {\n const channel = this._channel;\n const protocol = channel._client._protocol;\n const outgoing = channel.outgoing;\n const packetSize = outgoing.packetSize;\n const id = outgoing.id;\n let window = outgoing.window;\n const len = data.length;\n let p = 0;\n\n if (outgoing.state !== 'open')\n return;\n\n while (len - p > 0 && window > 0) {\n let sliceLen = len - p;\n if (sliceLen > window)\n sliceLen = window;\n if (sliceLen > packetSize)\n sliceLen = packetSize;\n\n if (p === 0 && sliceLen === len)\n protocol.channelExtData(id, data, STDERR);\n else\n protocol.channelExtData(id, bufferSlice(data, p, p + sliceLen), STDERR);\n\n p += sliceLen;\n window -= sliceLen;\n }\n\n outgoing.window = window;\n\n if (len - p > 0) {\n if (window === 0)\n channel._waitWindow = true;\n if (p > 0)\n channel._chunkErr = bufferSlice(data, p, len);\n else\n channel._chunkErr = data;\n channel._chunkcbErr = cb;\n return;\n }\n\n cb();\n }\n}\n\nclass Channel extends DuplexStream {\n constructor(client, info, opts) {\n const streamOpts = {\n highWaterMark: MAX_WINDOW,\n allowHalfOpen: (!opts || (opts && opts.allowHalfOpen !== false)),\n emitClose: false,\n };\n super(streamOpts);\n this.allowHalfOpen = streamOpts.allowHalfOpen;\n\n const server = !!(opts && opts.server);\n\n this.server = server;\n this.type = info.type;\n this.subtype = undefined;\n\n /*\n incoming and outgoing contain these properties:\n {\n id: undefined,\n window: undefined,\n packetSize: undefined,\n state: 'closed'\n }\n */\n this.incoming = info.incoming;\n this.outgoing = info.outgoing;\n this._callbacks = [];\n\n this._client = client;\n this._hasX11 = false;\n this._exit = {\n code: undefined,\n signal: undefined,\n dump: undefined,\n desc: undefined,\n };\n\n this.stdin = this.stdout = this;\n\n if (server)\n this.stderr = new ServerStderr(this);\n else\n this.stderr = new ClientStderr(this, streamOpts);\n\n // Outgoing data\n this._waitWindow = false; // SSH-level backpressure\n\n // Incoming data\n this._waitChanDrain = false; // Channel Readable side backpressure\n\n this._chunk = undefined;\n this._chunkcb = undefined;\n this._chunkErr = undefined;\n this._chunkcbErr = undefined;\n\n this.on('finish', onFinish)\n .on('prefinish', onFinish); // For node v0.11+\n\n this.on('end', onEnd).on('close', onEnd);\n }\n\n _read(n) {\n if (this._waitChanDrain) {\n this._waitChanDrain = false;\n if (this.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(this);\n }\n }\n\n _write(data, encoding, cb) {\n const protocol = this._client._protocol;\n const outgoing = this.outgoing;\n const packetSize = outgoing.packetSize;\n const id = outgoing.id;\n let window = outgoing.window;\n const len = data.length;\n let p = 0;\n\n if (outgoing.state !== 'open')\n return;\n\n while (len - p > 0 && window > 0) {\n let sliceLen = len - p;\n if (sliceLen > window)\n sliceLen = window;\n if (sliceLen > packetSize)\n sliceLen = packetSize;\n\n if (p === 0 && sliceLen === len)\n protocol.channelData(id, data);\n else\n protocol.channelData(id, bufferSlice(data, p, p + sliceLen));\n\n p += sliceLen;\n window -= sliceLen;\n }\n\n outgoing.window = window;\n\n if (len - p > 0) {\n if (window === 0)\n this._waitWindow = true;\n if (p > 0)\n this._chunk = bufferSlice(data, p, len);\n else\n this._chunk = data;\n this._chunkcb = cb;\n return;\n }\n\n cb();\n }\n\n eof() {\n if (this.outgoing.state === 'open') {\n this.outgoing.state = 'eof';\n this._client._protocol.channelEOF(this.outgoing.id);\n }\n }\n\n close() {\n if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {\n this.outgoing.state = 'closing';\n this._client._protocol.channelClose(this.outgoing.id);\n }\n }\n\n destroy() {\n this.end();\n this.close();\n return this;\n }\n\n // Session type-specific methods =============================================\n setWindow(rows, cols, height, width) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (this.type === 'session'\n && (this.subtype === 'shell' || this.subtype === 'exec')\n && this.writable\n && this.outgoing.state === 'open') {\n this._client._protocol.windowChange(this.outgoing.id,\n rows,\n cols,\n height,\n width);\n }\n }\n\n signal(signalName) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (this.type === 'session'\n && this.writable\n && this.outgoing.state === 'open') {\n this._client._protocol.signal(this.outgoing.id, signalName);\n }\n }\n\n exit(statusOrSignal, coreDumped, msg) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (this.type === 'session'\n && this.writable\n && this.outgoing.state === 'open') {\n if (typeof statusOrSignal === 'number') {\n this._client._protocol.exitStatus(this.outgoing.id, statusOrSignal);\n } else {\n this._client._protocol.exitSignal(this.outgoing.id,\n statusOrSignal,\n coreDumped,\n msg);\n }\n }\n }\n\n}\n\nfunction onFinish() {\n this.eof();\n if (this.server || !this.allowHalfOpen)\n this.close();\n this.writable = false;\n}\n\nfunction onEnd() {\n this.readable = false;\n}\n\nfunction windowAdjust(self) {\n if (self.outgoing.state === 'closed')\n return;\n const amt = MAX_WINDOW - self.incoming.window;\n if (amt <= 0)\n return;\n self.incoming.window += amt;\n self._client._protocol.channelWindowAdjust(self.outgoing.id, amt);\n}\n\nmodule.exports = {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n};\n",null,"// TODO:\n// * add `.connected` or similar property to allow immediate connection\n// status checking\n// * add/improve debug output during user authentication phase\n'use strict';\n\nconst {\n createHash,\n getHashes,\n randomFillSync,\n} = require('crypto');\nconst { Socket } = require('net');\nconst { lookup: dnsLookup } = require('dns');\nconst EventEmitter = require('events');\nconst HASHES = getHashes();\n\nconst {\n COMPAT,\n CHANNEL_EXTENDED_DATATYPE: { STDERR },\n CHANNEL_OPEN_FAILURE,\n DEFAULT_CIPHER,\n DEFAULT_COMPRESSION,\n DEFAULT_KEX,\n DEFAULT_MAC,\n DEFAULT_SERVER_HOST_KEY,\n DISCONNECT_REASON,\n DISCONNECT_REASON_BY_VALUE,\n SUPPORTED_CIPHER,\n SUPPORTED_COMPRESSION,\n SUPPORTED_KEX,\n SUPPORTED_MAC,\n SUPPORTED_SERVER_HOST_KEY,\n} = require('./protocol/constants.js');\nconst { init: cryptoInit } = require('./protocol/crypto.js');\nconst Protocol = require('./protocol/Protocol.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst { SFTP } = require('./protocol/SFTP.js');\nconst {\n bufferCopy,\n makeBufferParser,\n makeError,\n readUInt32BE,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./protocol/utils.js');\n\nconst { AgentContext, createAgent, isAgent } = require('./agent.js');\nconst {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n} = require('./Channel.js');\nconst {\n ChannelManager,\n generateAlgorithmList,\n isWritable,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n} = require('./utils.js');\n\nconst bufferParser = makeBufferParser();\nconst sigParser = makeBufferParser();\nconst RE_OPENSSH = /^OpenSSH_(?:(?![0-4])\\d)|(?:\\d{2,})/;\nconst noop = (err) => {};\n\nclass Client extends EventEmitter {\n constructor() {\n super();\n\n this.config = {\n host: undefined,\n port: undefined,\n localAddress: undefined,\n localPort: undefined,\n forceIPv4: undefined,\n forceIPv6: undefined,\n keepaliveCountMax: undefined,\n keepaliveInterval: undefined,\n readyTimeout: undefined,\n ident: undefined,\n\n username: undefined,\n password: undefined,\n privateKey: undefined,\n tryKeyboard: undefined,\n agent: undefined,\n allowAgentFwd: undefined,\n authHandler: undefined,\n\n hostHashAlgo: undefined,\n hostHashCb: undefined,\n strictVendor: undefined,\n debug: undefined\n };\n\n this._agent = undefined;\n this._readyTimeout = undefined;\n this._chanMgr = undefined;\n this._callbacks = undefined;\n this._forwarding = undefined;\n this._forwardingUnix = undefined;\n this._acceptX11 = undefined;\n this._agentFwdEnabled = undefined;\n this._remoteVer = undefined;\n\n this._protocol = undefined;\n this._sock = undefined;\n this._resetKA = undefined;\n }\n\n connect(cfg) {\n if (this._sock && isWritable(this._sock)) {\n this.once('close', () => {\n this.connect(cfg);\n });\n this.end();\n return this;\n }\n\n this.config.host = cfg.hostname || cfg.host || 'localhost';\n this.config.port = cfg.port || 22;\n this.config.localAddress = (typeof cfg.localAddress === 'string'\n ? cfg.localAddress\n : undefined);\n this.config.localPort = (typeof cfg.localPort === 'string'\n || typeof cfg.localPort === 'number'\n ? cfg.localPort\n : undefined);\n this.config.forceIPv4 = cfg.forceIPv4 || false;\n this.config.forceIPv6 = cfg.forceIPv6 || false;\n this.config.keepaliveCountMax = (typeof cfg.keepaliveCountMax === 'number'\n && cfg.keepaliveCountMax >= 0\n ? cfg.keepaliveCountMax\n : 3);\n this.config.keepaliveInterval = (typeof cfg.keepaliveInterval === 'number'\n && cfg.keepaliveInterval > 0\n ? cfg.keepaliveInterval\n : 0);\n this.config.readyTimeout = (typeof cfg.readyTimeout === 'number'\n && cfg.readyTimeout >= 0\n ? cfg.readyTimeout\n : 20000);\n this.config.ident = (typeof cfg.ident === 'string'\n || Buffer.isBuffer(cfg.ident)\n ? cfg.ident\n : undefined);\n\n const algorithms = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: [],\n },\n sc: undefined,\n };\n let allOfferDefaults = true;\n if (typeof cfg.algorithms === 'object' && cfg.algorithms !== null) {\n algorithms.kex = generateAlgorithmList(cfg.algorithms.kex,\n DEFAULT_KEX,\n SUPPORTED_KEX);\n if (algorithms.kex !== DEFAULT_KEX)\n allOfferDefaults = false;\n\n algorithms.serverHostKey =\n generateAlgorithmList(cfg.algorithms.serverHostKey,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY);\n if (algorithms.serverHostKey !== DEFAULT_SERVER_HOST_KEY)\n allOfferDefaults = false;\n\n algorithms.cs.cipher = generateAlgorithmList(cfg.algorithms.cipher,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER);\n if (algorithms.cs.cipher !== DEFAULT_CIPHER)\n allOfferDefaults = false;\n\n algorithms.cs.mac = generateAlgorithmList(cfg.algorithms.hmac,\n DEFAULT_MAC,\n SUPPORTED_MAC);\n if (algorithms.cs.mac !== DEFAULT_MAC)\n allOfferDefaults = false;\n\n algorithms.cs.compress = generateAlgorithmList(cfg.algorithms.compress,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION);\n if (algorithms.cs.compress !== DEFAULT_COMPRESSION)\n allOfferDefaults = false;\n\n if (!allOfferDefaults)\n algorithms.sc = algorithms.cs;\n }\n\n if (typeof cfg.username === 'string')\n this.config.username = cfg.username;\n else if (typeof cfg.user === 'string')\n this.config.username = cfg.user;\n else\n throw new Error('Invalid username');\n\n this.config.password = (typeof cfg.password === 'string'\n ? cfg.password\n : undefined);\n this.config.privateKey = (typeof cfg.privateKey === 'string'\n || Buffer.isBuffer(cfg.privateKey)\n ? cfg.privateKey\n : undefined);\n this.config.localHostname = (typeof cfg.localHostname === 'string'\n ? cfg.localHostname\n : undefined);\n this.config.localUsername = (typeof cfg.localUsername === 'string'\n ? cfg.localUsername\n : undefined);\n this.config.tryKeyboard = (cfg.tryKeyboard === true);\n if (typeof cfg.agent === 'string' && cfg.agent.length)\n this.config.agent = createAgent(cfg.agent);\n else if (isAgent(cfg.agent))\n this.config.agent = cfg.agent;\n else\n this.config.agent = undefined;\n this.config.allowAgentFwd = (cfg.agentForward === true\n && this.config.agent !== undefined);\n let authHandler = this.config.authHandler = (\n typeof cfg.authHandler === 'function'\n || Array.isArray(cfg.authHandler)\n ? cfg.authHandler\n : undefined\n );\n\n this.config.strictVendor = (typeof cfg.strictVendor === 'boolean'\n ? cfg.strictVendor\n : true);\n\n const debug = this.config.debug = (typeof cfg.debug === 'function'\n ? cfg.debug\n : undefined);\n\n if (cfg.agentForward === true && !this.config.allowAgentFwd) {\n throw new Error(\n 'You must set a valid agent path to allow agent forwarding'\n );\n }\n\n let callbacks = this._callbacks = [];\n this._chanMgr = new ChannelManager(this);\n this._forwarding = {};\n this._forwardingUnix = {};\n this._acceptX11 = 0;\n this._agentFwdEnabled = false;\n this._agent = (this.config.agent ? this.config.agent : undefined);\n this._remoteVer = undefined;\n let privateKey;\n\n if (this.config.privateKey) {\n privateKey = parseKey(this.config.privateKey, cfg.passphrase);\n if (privateKey instanceof Error)\n throw new Error(`Cannot parse privateKey: ${privateKey.message}`);\n if (Array.isArray(privateKey)) {\n // OpenSSH's newer format only stores 1 key for now\n privateKey = privateKey[0];\n }\n if (privateKey.getPrivatePEM() === null) {\n throw new Error(\n 'privateKey value does not contain a (valid) private key'\n );\n }\n }\n\n let hostVerifier;\n if (typeof cfg.hostVerifier === 'function') {\n const hashCb = cfg.hostVerifier;\n let hasher;\n if (HASHES.indexOf(cfg.hostHash) !== -1) {\n // Default to old behavior of hashing on user's behalf\n hasher = createHash(cfg.hostHash);\n }\n hostVerifier = (key, verify) => {\n if (hasher) {\n hasher.update(key);\n key = hasher.digest('hex');\n }\n const ret = hashCb(key, verify);\n if (ret !== undefined)\n verify(ret);\n };\n }\n\n const sock = this._sock = (cfg.sock || new Socket());\n let ready = false;\n let sawHeader = false;\n if (this._protocol)\n this._protocol.cleanup();\n const DEBUG_HANDLER = (!debug ? undefined : (p, display, msg) => {\n debug(`Debug output from server: ${JSON.stringify(msg)}`);\n });\n const proto = this._protocol = new Protocol({\n ident: this.config.ident,\n offer: (allOfferDefaults ? undefined : algorithms),\n onWrite: (data) => {\n if (isWritable(sock))\n sock.write(data);\n },\n onError: (err) => {\n if (err.level === 'handshake')\n clearTimeout(this._readyTimeout);\n if (!proto._destruct)\n sock.removeAllListeners('data');\n this.emit('error', err);\n try {\n sock.end();\n } catch {}\n },\n onHeader: (header) => {\n sawHeader = true;\n this._remoteVer = header.versions.software;\n if (header.greeting)\n this.emit('greeting', header.greeting);\n },\n onHandshakeComplete: (negotiated) => {\n this.emit('handshake', negotiated);\n if (!ready) {\n ready = true;\n proto.service('ssh-userauth');\n }\n },\n debug,\n hostVerifier,\n messageHandlers: {\n DEBUG: DEBUG_HANDLER,\n DISCONNECT: (p, reason, desc) => {\n if (reason !== DISCONNECT_REASON.BY_APPLICATION) {\n if (!desc) {\n desc = DISCONNECT_REASON_BY_VALUE[reason];\n if (desc === undefined)\n desc = `Unexpected disconnection reason: ${reason}`;\n }\n const err = new Error(desc);\n err.code = reason;\n this.emit('error', err);\n }\n sock.end();\n },\n SERVICE_ACCEPT: (p, name) => {\n if (name === 'ssh-userauth')\n tryNextAuth();\n },\n USERAUTH_BANNER: (p, msg) => {\n this.emit('banner', msg);\n },\n USERAUTH_SUCCESS: (p) => {\n // Start keepalive mechanism\n resetKA();\n\n clearTimeout(this._readyTimeout);\n\n this.emit('ready');\n },\n USERAUTH_FAILURE: (p, authMethods, partialSuccess) => {\n if (curAuth.type === 'agent') {\n const pos = curAuth.agentCtx.pos();\n debug && debug(`Client: Agent key #${pos + 1} failed`);\n return tryNextAgentKey();\n }\n\n debug && debug(`Client: ${curAuth.type} auth failed`);\n\n curPartial = partialSuccess;\n curAuthsLeft = authMethods;\n tryNextAuth();\n },\n USERAUTH_PASSWD_CHANGEREQ: (p, prompt) => {\n if (curAuth.type === 'password') {\n // TODO: support a `changePrompt()` on `curAuth` that defaults to\n // emitting 'change password' as before\n this.emit('change password', prompt, (newPassword) => {\n proto.authPassword(\n this.config.username,\n this.config.password,\n newPassword\n );\n });\n }\n },\n USERAUTH_PK_OK: (p) => {\n if (curAuth.type === 'agent') {\n const key = curAuth.agentCtx.currentKey();\n proto.authPK(curAuth.username, key, (buf, cb) => {\n curAuth.agentCtx.sign(key, buf, {}, (err, signed) => {\n if (err) {\n err.level = 'agent';\n this.emit('error', err);\n } else {\n return cb(signed);\n }\n\n tryNextAgentKey();\n });\n });\n } else if (curAuth.type === 'publickey') {\n proto.authPK(curAuth.username, curAuth.key, (buf, cb) => {\n const signature = curAuth.key.sign(buf);\n if (signature instanceof Error) {\n signature.message =\n `Error signing data with key: ${signature.message}`;\n signature.level = 'client-authentication';\n this.emit('error', signature);\n return tryNextAuth();\n }\n cb(signature);\n });\n }\n },\n USERAUTH_INFO_REQUEST: (p, name, instructions, prompts) => {\n if (curAuth.type === 'keyboard-interactive') {\n const nprompts = (Array.isArray(prompts) ? prompts.length : 0);\n if (nprompts === 0) {\n debug && debug(\n 'Client: Sending automatic USERAUTH_INFO_RESPONSE'\n );\n proto.authInfoRes();\n return;\n }\n // We sent a keyboard-interactive user authentication request and\n // now the server is sending us the prompts we need to present to\n // the user\n curAuth.prompt(\n name,\n instructions,\n '',\n prompts,\n (answers) => {\n proto.authInfoRes(answers);\n }\n );\n }\n },\n REQUEST_SUCCESS: (p, data) => {\n if (callbacks.length)\n callbacks.shift()(false, data);\n },\n REQUEST_FAILURE: (p) => {\n if (callbacks.length)\n callbacks.shift()(true);\n },\n GLOBAL_REQUEST: (p, name, wantReply, data) => {\n switch (name) {\n case 'hostkeys-00@openssh.com':\n // Automatically verify keys before passing to end user\n hostKeysProve(this, data, (err, keys) => {\n if (err)\n return;\n this.emit('hostkeys', keys);\n });\n if (wantReply)\n proto.requestSuccess();\n break;\n default:\n // Auto-reject all other global requests, this can be especially\n // useful if the server is sending us dummy keepalive global\n // requests\n if (wantReply)\n proto.requestFailure();\n }\n },\n CHANNEL_OPEN: (p, info) => {\n // Handle incoming requests from server, typically a forwarded TCP or\n // X11 connection\n onCHANNEL_OPEN(this, info);\n },\n CHANNEL_OPEN_CONFIRMATION: (p, info) => {\n const channel = this._chanMgr.get(info.recipient);\n if (typeof channel !== 'function')\n return;\n\n const isSFTP = (channel.type === 'sftp');\n const type = (isSFTP ? 'session' : channel.type);\n const chanInfo = {\n type,\n incoming: {\n id: info.recipient,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n const instance = (\n isSFTP\n ? new SFTP(this, chanInfo, { debug })\n : new Channel(this, chanInfo)\n );\n this._chanMgr.update(info.recipient, instance);\n channel(undefined, instance);\n },\n CHANNEL_OPEN_FAILURE: (p, recipient, reason, description) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'function')\n return;\n\n const info = { reason, description };\n onChannelOpenFailure(this, recipient, info, channel);\n },\n CHANNEL_DATA: (p, recipient, data) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (channel.push(data) === false) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_EXTENDED_DATA: (p, recipient, data, type) => {\n if (type !== STDERR)\n return;\n\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (!channel.stderr.push(data)) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_WINDOW_ADJUST: (p, recipient, amount) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The other side is allowing us to send `amount` more bytes of data\n channel.outgoing.window += amount;\n\n if (channel._waitWindow) {\n channel._waitWindow = false;\n\n if (channel._chunk) {\n channel._write(channel._chunk, null, channel._chunkcb);\n } else if (channel._chunkcb) {\n channel._chunkcb();\n } else if (channel._chunkErr) {\n channel.stderr._write(channel._chunkErr,\n null,\n channel._chunkcbErr);\n } else if (channel._chunkcbErr) {\n channel._chunkcbErr();\n }\n }\n },\n CHANNEL_SUCCESS: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n this._resetKA();\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(false);\n },\n CHANNEL_FAILURE: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n this._resetKA();\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(true);\n },\n CHANNEL_REQUEST: (p, recipient, type, wantReply, data) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n const exit = channel._exit;\n if (exit.code !== undefined)\n return;\n switch (type) {\n case 'exit-status':\n channel.emit('exit', exit.code = data);\n return;\n case 'exit-signal':\n channel.emit('exit',\n exit.code = null,\n exit.signal = `SIG${data.signal}`,\n exit.dump = data.coreDumped,\n exit.desc = data.errorMessage);\n return;\n }\n\n // Keepalive request? OpenSSH will send one as a channel request if\n // there is a channel open\n\n if (wantReply)\n p.channelFailure(channel.outgoing.id);\n },\n CHANNEL_EOF: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.incoming.state !== 'open')\n return;\n channel.incoming.state = 'eof';\n\n if (channel.readable)\n channel.push(null);\n if (channel.stderr.readable)\n channel.stderr.push(null);\n },\n CHANNEL_CLOSE: (p, recipient) => {\n onCHANNEL_CLOSE(this, recipient, this._chanMgr.get(recipient));\n },\n },\n });\n\n sock.pause();\n\n // TODO: check keepalive implementation\n // Keepalive-related\n const kainterval = this.config.keepaliveInterval;\n const kacountmax = this.config.keepaliveCountMax;\n let kacount = 0;\n let katimer;\n const sendKA = () => {\n if (++kacount > kacountmax) {\n clearInterval(katimer);\n if (sock.readable) {\n const err = new Error('Keepalive timeout');\n err.level = 'client-timeout';\n this.emit('error', err);\n sock.destroy();\n }\n return;\n }\n if (isWritable(sock)) {\n // Append dummy callback to keep correct callback order\n callbacks.push(resetKA);\n proto.ping();\n } else {\n clearInterval(katimer);\n }\n };\n function resetKA() {\n if (kainterval > 0) {\n kacount = 0;\n clearInterval(katimer);\n if (isWritable(sock))\n katimer = setInterval(sendKA, kainterval);\n }\n }\n this._resetKA = resetKA;\n\n const onDone = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n if (wasConnected && !sawHeader) {\n const err =\n makeError('Connection lost before handshake', 'protocol', true);\n this.emit('error', err);\n }\n };\n })();\n const onConnect = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n\n wasConnected = true;\n debug && debug('Socket connected');\n this.emit('connect');\n\n cryptoInit.then(() => {\n proto.start();\n sock.on('data', (data) => {\n try {\n proto.parse(data, 0, data.length);\n } catch (ex) {\n this.emit('error', ex);\n try {\n if (isWritable(sock))\n sock.end();\n } catch {}\n }\n });\n\n // Drain stderr if we are connection hopping using an exec stream\n if (sock.stderr && typeof sock.stderr.resume === 'function')\n sock.stderr.resume();\n\n sock.resume();\n }).catch((err) => {\n this.emit('error', err);\n try {\n if (isWritable(sock))\n sock.end();\n } catch {}\n });\n };\n })();\n let wasConnected = false;\n sock.on('connect', onConnect)\n .on('timeout', () => {\n this.emit('timeout');\n }).on('error', (err) => {\n debug && debug(`Socket error: ${err.message}`);\n clearTimeout(this._readyTimeout);\n err.level = 'client-socket';\n this.emit('error', err);\n }).on('end', () => {\n debug && debug('Socket ended');\n onDone();\n proto.cleanup();\n clearTimeout(this._readyTimeout);\n clearInterval(katimer);\n this.emit('end');\n }).on('close', () => {\n debug && debug('Socket closed');\n onDone();\n proto.cleanup();\n clearTimeout(this._readyTimeout);\n clearInterval(katimer);\n this.emit('close');\n\n // Notify outstanding channel requests of disconnection ...\n const callbacks_ = callbacks;\n callbacks = this._callbacks = [];\n const err = new Error('No response from server');\n for (let i = 0; i < callbacks_.length; ++i)\n callbacks_[i](err);\n\n // Simulate error for any channels waiting to be opened\n this._chanMgr.cleanup(err);\n });\n\n // Begin authentication handling ===========================================\n let curAuth;\n let curPartial = null;\n let curAuthsLeft = null;\n const authsAllowed = ['none'];\n if (this.config.password !== undefined)\n authsAllowed.push('password');\n if (privateKey !== undefined)\n authsAllowed.push('publickey');\n if (this._agent !== undefined)\n authsAllowed.push('agent');\n if (this.config.tryKeyboard)\n authsAllowed.push('keyboard-interactive');\n if (privateKey !== undefined\n && this.config.localHostname !== undefined\n && this.config.localUsername !== undefined) {\n authsAllowed.push('hostbased');\n }\n\n if (Array.isArray(authHandler))\n authHandler = makeSimpleAuthHandler(authHandler);\n else if (typeof authHandler !== 'function')\n authHandler = makeSimpleAuthHandler(authsAllowed);\n\n let hasSentAuth = false;\n const doNextAuth = (nextAuth) => {\n if (hasSentAuth)\n return;\n hasSentAuth = true;\n\n if (nextAuth === false) {\n const err = new Error('All configured authentication methods failed');\n err.level = 'client-authentication';\n this.emit('error', err);\n this.end();\n return;\n }\n\n if (typeof nextAuth === 'string') {\n // Remain backwards compatible with original `authHandler()` usage,\n // which only supported passing names of next method to try using data\n // from the `connect()` config object\n\n const type = nextAuth;\n if (authsAllowed.indexOf(type) === -1)\n return skipAuth(`Authentication method not allowed: ${type}`);\n\n const username = this.config.username;\n switch (type) {\n case 'password':\n nextAuth = { type, username, password: this.config.password };\n break;\n case 'publickey':\n nextAuth = { type, username, key: privateKey };\n break;\n case 'hostbased':\n nextAuth = {\n type,\n username,\n key: privateKey,\n localHostname: this.config.localHostname,\n localUsername: this.config.localUsername,\n };\n break;\n case 'agent':\n nextAuth = {\n type,\n username,\n agentCtx: new AgentContext(this._agent),\n };\n break;\n case 'keyboard-interactive':\n nextAuth = {\n type,\n username,\n prompt: (...args) => this.emit('keyboard-interactive', ...args),\n };\n break;\n case 'none':\n nextAuth = { type, username };\n break;\n default:\n return skipAuth(\n `Skipping unsupported authentication method: ${nextAuth}`\n );\n }\n } else if (typeof nextAuth !== 'object' || nextAuth === null) {\n return skipAuth(\n `Skipping invalid authentication attempt: ${nextAuth}`\n );\n } else {\n const username = nextAuth.username;\n if (typeof username !== 'string') {\n return skipAuth(\n `Skipping invalid authentication attempt: ${nextAuth}`\n );\n }\n const type = nextAuth.type;\n switch (type) {\n case 'password': {\n const { password } = nextAuth;\n if (typeof password !== 'string' && !Buffer.isBuffer(password))\n return skipAuth('Skipping invalid password auth attempt');\n nextAuth = { type, username, password };\n break;\n }\n case 'publickey': {\n const key = parseKey(nextAuth.key, nextAuth.passphrase);\n if (key instanceof Error)\n return skipAuth('Skipping invalid key auth attempt');\n if (!key.isPrivateKey())\n return skipAuth('Skipping non-private key');\n nextAuth = { type, username, key };\n break;\n }\n case 'hostbased': {\n const { localHostname, localUsername } = nextAuth;\n const key = parseKey(nextAuth.key, nextAuth.passphrase);\n if (key instanceof Error\n || typeof localHostname !== 'string'\n || typeof localUsername !== 'string') {\n return skipAuth('Skipping invalid hostbased auth attempt');\n }\n if (!key.isPrivateKey())\n return skipAuth('Skipping non-private key');\n nextAuth = { type, username, key, localHostname, localUsername };\n break;\n }\n case 'agent': {\n let agent = nextAuth.agent;\n if (typeof agent === 'string' && agent.length) {\n agent = createAgent(agent);\n } else if (!isAgent(agent)) {\n return skipAuth(\n `Skipping invalid agent: ${nextAuth.agent}`\n );\n }\n nextAuth = { type, username, agentCtx: new AgentContext(agent) };\n break;\n }\n case 'keyboard-interactive': {\n const { prompt } = nextAuth;\n if (typeof prompt !== 'function') {\n return skipAuth(\n 'Skipping invalid keyboard-interactive auth attempt'\n );\n }\n nextAuth = { type, username, prompt };\n break;\n }\n case 'none':\n nextAuth = { type, username };\n break;\n default:\n return skipAuth(\n `Skipping unsupported authentication method: ${nextAuth}`\n );\n }\n }\n curAuth = nextAuth;\n\n // Begin authentication method's process\n try {\n const username = curAuth.username;\n switch (curAuth.type) {\n case 'password':\n proto.authPassword(username, curAuth.password);\n break;\n case 'publickey':\n proto.authPK(username, curAuth.key);\n break;\n case 'hostbased':\n proto.authHostbased(username,\n curAuth.key,\n curAuth.localHostname,\n curAuth.localUsername,\n (buf, cb) => {\n const signature = curAuth.key.sign(buf);\n if (signature instanceof Error) {\n signature.message =\n `Error while signing with key: ${signature.message}`;\n signature.level = 'client-authentication';\n this.emit('error', signature);\n return tryNextAuth();\n }\n\n cb(signature);\n });\n break;\n case 'agent':\n curAuth.agentCtx.init((err) => {\n if (err) {\n err.level = 'agent';\n this.emit('error', err);\n return tryNextAuth();\n }\n tryNextAgentKey();\n });\n break;\n case 'keyboard-interactive':\n proto.authKeyboard(username);\n break;\n case 'none':\n proto.authNone(username);\n break;\n }\n } finally {\n hasSentAuth = false;\n }\n };\n\n function skipAuth(msg) {\n debug && debug(msg);\n process.nextTick(tryNextAuth);\n }\n\n function tryNextAuth() {\n hasSentAuth = false;\n const auth = authHandler(curAuthsLeft, curPartial, doNextAuth);\n if (hasSentAuth || auth === undefined)\n return;\n doNextAuth(auth);\n }\n\n const tryNextAgentKey = () => {\n if (curAuth.type === 'agent') {\n const key = curAuth.agentCtx.nextKey();\n if (key === false) {\n debug && debug('Agent: No more keys left to try');\n debug && debug('Client: agent auth failed');\n tryNextAuth();\n } else {\n const pos = curAuth.agentCtx.pos();\n debug && debug(`Agent: Trying key #${pos + 1}`);\n proto.authPK(curAuth.username, key);\n }\n }\n };\n\n const startTimeout = () => {\n if (this.config.readyTimeout > 0) {\n this._readyTimeout = setTimeout(() => {\n const err = new Error('Timed out while waiting for handshake');\n err.level = 'client-timeout';\n this.emit('error', err);\n sock.destroy();\n }, this.config.readyTimeout);\n }\n };\n\n if (!cfg.sock) {\n let host = this.config.host;\n const forceIPv4 = this.config.forceIPv4;\n const forceIPv6 = this.config.forceIPv6;\n\n debug && debug(`Client: Trying ${host} on port ${this.config.port} ...`);\n\n const doConnect = () => {\n startTimeout();\n sock.connect({\n host,\n port: this.config.port,\n localAddress: this.config.localAddress,\n localPort: this.config.localPort\n });\n sock.setNoDelay(true);\n sock.setMaxListeners(0);\n sock.setTimeout(typeof cfg.timeout === 'number' ? cfg.timeout : 0);\n };\n\n if ((!forceIPv4 && !forceIPv6) || (forceIPv4 && forceIPv6)) {\n doConnect();\n } else {\n dnsLookup(host, (forceIPv4 ? 4 : 6), (err, address, family) => {\n if (err) {\n const type = (forceIPv4 ? 'IPv4' : 'IPv6');\n const error = new Error(\n `Error while looking up ${type} address for '${host}': ${err}`\n );\n clearTimeout(this._readyTimeout);\n error.level = 'client-dns';\n this.emit('error', error);\n this.emit('close');\n return;\n }\n host = address;\n doConnect();\n });\n }\n } else {\n // Custom socket passed in\n startTimeout();\n if (typeof sock.connecting === 'boolean') {\n // net.Socket\n\n if (!sock.connecting) {\n // Already connected\n onConnect();\n }\n } else {\n // Assume socket/stream is already \"connected\"\n onConnect();\n }\n }\n\n return this;\n }\n\n end() {\n if (this._sock && isWritable(this._sock)) {\n this._protocol.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n this._sock.end();\n }\n return this;\n }\n\n destroy() {\n this._sock && isWritable(this._sock) && this._sock.destroy();\n return this;\n }\n\n exec(cmd, opts, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const extraOpts = { allowHalfOpen: (opts.allowHalfOpen !== false) };\n\n openChannel(this, 'session', extraOpts, (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n const todo = [];\n\n function reqCb(err) {\n if (err) {\n chan.close();\n cb(err);\n return;\n }\n if (todo.length)\n todo.shift()();\n }\n\n if (this.config.allowAgentFwd === true\n || (opts\n && opts.agentForward === true\n && this._agent !== undefined)) {\n todo.push(() => reqAgentFwd(chan, reqCb));\n }\n\n if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.env === 'object' && opts.env !== null)\n reqEnv(chan, opts.env);\n if ((typeof opts.pty === 'object' && opts.pty !== null)\n || opts.pty === true) {\n todo.push(() => reqPty(chan, opts.pty, reqCb));\n }\n if ((typeof opts.x11 === 'object' && opts.x11 !== null)\n || opts.x11 === 'number'\n || opts.x11 === true) {\n todo.push(() => reqX11(chan, opts.x11, reqCb));\n }\n }\n\n todo.push(() => reqExec(chan, cmd, opts, cb));\n todo.shift()();\n });\n\n return this;\n }\n\n shell(wndopts, opts, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof wndopts === 'function') {\n cb = wndopts;\n wndopts = opts = undefined;\n } else if (typeof opts === 'function') {\n cb = opts;\n opts = undefined;\n }\n if (wndopts && (wndopts.x11 !== undefined || wndopts.env !== undefined)) {\n opts = wndopts;\n wndopts = undefined;\n }\n\n openChannel(this, 'session', (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n const todo = [];\n\n function reqCb(err) {\n if (err) {\n chan.close();\n cb(err);\n return;\n }\n if (todo.length)\n todo.shift()();\n }\n\n if (this.config.allowAgentFwd === true\n || (opts\n && opts.agentForward === true\n && this._agent !== undefined)) {\n todo.push(() => reqAgentFwd(chan, reqCb));\n }\n\n if (wndopts !== false)\n todo.push(() => reqPty(chan, wndopts, reqCb));\n\n if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.env === 'object' && opts.env !== null)\n reqEnv(chan, opts.env);\n if ((typeof opts.x11 === 'object' && opts.x11 !== null)\n || opts.x11 === 'number'\n || opts.x11 === true) {\n todo.push(() => reqX11(chan, opts.x11, reqCb));\n }\n }\n\n todo.push(() => reqShell(chan, cb));\n todo.shift()();\n });\n\n return this;\n }\n\n subsys(name, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n openChannel(this, 'session', (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n reqSubsystem(chan, name, (err, stream) => {\n if (err) {\n cb(err);\n return;\n }\n\n cb(undefined, stream);\n });\n });\n\n return this;\n }\n\n forwardIn(bindAddr, bindPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request for the server to start forwarding TCP connections to us\n // on a particular address and port\n\n const wantReply = (typeof cb === 'function');\n\n if (wantReply) {\n this._callbacks.push((had_err, data) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to bind to ${bindAddr}:${bindPort}`));\n return;\n }\n\n let realPort = bindPort;\n if (bindPort === 0 && data && data.length >= 4) {\n realPort = readUInt32BE(data, 0);\n if (!(this._protocol._compatFlags & COMPAT.DYN_RPORT_BUG))\n bindPort = realPort;\n }\n\n this._forwarding[`${bindAddr}:${bindPort}`] = realPort;\n\n cb(undefined, realPort);\n });\n }\n\n this._protocol.tcpipForward(bindAddr, bindPort, wantReply);\n\n return this;\n }\n\n unforwardIn(bindAddr, bindPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request to stop forwarding us new connections for a particular\n // address and port\n\n const wantReply = (typeof cb === 'function');\n\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to unbind from ${bindAddr}:${bindPort}`));\n return;\n }\n\n delete this._forwarding[`${bindAddr}:${bindPort}`];\n\n cb();\n });\n }\n\n this._protocol.cancelTcpipForward(bindAddr, bindPort, wantReply);\n\n return this;\n }\n\n forwardOut(srcIP, srcPort, dstIP, dstPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request to forward a TCP connection to the server\n\n const cfg = {\n srcIP: srcIP,\n srcPort: srcPort,\n dstIP: dstIP,\n dstPort: dstPort\n };\n\n if (typeof cb !== 'function')\n cb = noop;\n\n openChannel(this, 'direct-tcpip', cfg, cb);\n\n return this;\n }\n\n openssh_noMoreSessions(cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to disable future sessions'));\n return;\n }\n\n cb();\n });\n }\n\n this._protocol.openssh_noMoreSessions(wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_forwardInStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to bind to ${socketPath}`));\n return;\n }\n this._forwardingUnix[socketPath] = true;\n cb();\n });\n }\n\n this._protocol.openssh_streamLocalForward(socketPath, wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_unforwardInStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to unbind from ${socketPath}`));\n return;\n }\n delete this._forwardingUnix[socketPath];\n cb();\n });\n }\n\n this._protocol.openssh_cancelStreamLocalForward(socketPath, wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_forwardOutStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof cb !== 'function')\n cb = noop;\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n openChannel(this, 'direct-streamlocal@openssh.com', { socketPath }, cb);\n return this;\n }\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n sftp(cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n openChannel(this, 'sftp', (err, sftp) => {\n if (err) {\n cb(err);\n return;\n }\n\n reqSubsystem(sftp, 'sftp', (err, sftp_) => {\n if (err) {\n cb(err);\n return;\n }\n\n function removeListeners() {\n sftp.removeListener('ready', onReady);\n sftp.removeListener('error', onError);\n sftp.removeListener('exit', onExit);\n sftp.removeListener('close', onExit);\n }\n\n function onReady() {\n // TODO: do not remove exit/close in case remote end closes the\n // channel abruptly and we need to notify outstanding callbacks\n removeListeners();\n cb(undefined, sftp);\n }\n\n function onError(err) {\n removeListeners();\n cb(err);\n }\n\n function onExit(code, signal) {\n removeListeners();\n let msg;\n if (typeof code === 'number')\n msg = `Received exit code ${code} while establishing SFTP session`;\n else if (signal !== undefined)\n msg = `Received signal ${signal} while establishing SFTP session`;\n else\n msg = 'Received unexpected SFTP session termination';\n const err = new Error(msg);\n err.code = code;\n err.signal = signal;\n cb(err);\n }\n\n sftp.on('ready', onReady)\n .on('error', onError)\n .on('exit', onExit)\n .on('close', onExit);\n\n sftp._init();\n });\n });\n\n return this;\n }\n}\n\nfunction openChannel(self, type, opts, cb) {\n // Ask the server to open a channel for some purpose\n // (e.g. session (sftp, exec, shell), or forwarding a TCP connection\n const initWindow = MAX_WINDOW;\n const maxPacket = PACKET_SIZE;\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const wrapper = (err, stream) => {\n cb(err, stream);\n };\n wrapper.type = type;\n\n const localChan = self._chanMgr.add(wrapper);\n\n if (localChan === -1) {\n cb(new Error('No free channels available'));\n return;\n }\n\n switch (type) {\n case 'session':\n case 'sftp':\n self._protocol.session(localChan, initWindow, maxPacket);\n break;\n case 'direct-tcpip':\n self._protocol.directTcpip(localChan, initWindow, maxPacket, opts);\n break;\n case 'direct-streamlocal@openssh.com':\n self._protocol.openssh_directStreamLocal(\n localChan, initWindow, maxPacket, opts\n );\n break;\n default:\n throw new Error(`Unsupported channel type: ${type}`);\n }\n}\n\nfunction reqX11(chan, screen, cb) {\n // Asks server to start sending us X11 connections\n const cfg = {\n single: false,\n protocol: 'MIT-MAGIC-COOKIE-1',\n cookie: undefined,\n screen: 0\n };\n\n if (typeof screen === 'function') {\n cb = screen;\n } else if (typeof screen === 'object' && screen !== null) {\n if (typeof screen.single === 'boolean')\n cfg.single = screen.single;\n if (typeof screen.screen === 'number')\n cfg.screen = screen.screen;\n if (typeof screen.protocol === 'string')\n cfg.protocol = screen.protocol;\n if (typeof screen.cookie === 'string')\n cfg.cookie = screen.cookie;\n else if (Buffer.isBuffer(screen.cookie))\n cfg.cookie = screen.cookie.hexSlice(0, screen.cookie.length);\n }\n if (cfg.cookie === undefined)\n cfg.cookie = randomCookie();\n\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n if (wantReply)\n cb(new Error('Channel is not open'));\n return;\n }\n\n if (wantReply) {\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to request X11'));\n return;\n }\n\n chan._hasX11 = true;\n ++chan._client._acceptX11;\n chan.once('close', () => {\n if (chan._client._acceptX11)\n --chan._client._acceptX11;\n });\n\n cb();\n });\n }\n\n chan._client._protocol.x11Forward(chan.outgoing.id, cfg, wantReply);\n}\n\nfunction reqPty(chan, opts, cb) {\n let rows = 24;\n let cols = 80;\n let width = 640;\n let height = 480;\n let term = 'vt100';\n let modes = null;\n\n if (typeof opts === 'function') {\n cb = opts;\n } else if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.rows === 'number')\n rows = opts.rows;\n if (typeof opts.cols === 'number')\n cols = opts.cols;\n if (typeof opts.width === 'number')\n width = opts.width;\n if (typeof opts.height === 'number')\n height = opts.height;\n if (typeof opts.term === 'string')\n term = opts.term;\n if (typeof opts.modes === 'object')\n modes = opts.modes;\n }\n\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n if (wantReply)\n cb(new Error('Channel is not open'));\n return;\n }\n\n if (wantReply) {\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to request a pseudo-terminal'));\n return;\n }\n cb();\n });\n }\n\n chan._client._protocol.pty(chan.outgoing.id,\n rows,\n cols,\n height,\n width,\n term,\n modes,\n wantReply);\n}\n\nfunction reqAgentFwd(chan, cb) {\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n wantReply && cb(new Error('Channel is not open'));\n return;\n }\n if (chan._client._agentFwdEnabled) {\n wantReply && cb(false);\n return;\n }\n\n chan._client._agentFwdEnabled = true;\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n chan._client._agentFwdEnabled = false;\n if (wantReply) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to request agent forwarding'));\n }\n return;\n }\n\n if (wantReply)\n cb();\n });\n\n chan._client._protocol.openssh_agentForward(chan.outgoing.id, true);\n}\n\nfunction reqShell(chan, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to open shell'));\n return;\n }\n chan.subtype = 'shell';\n cb(undefined, chan);\n });\n\n chan._client._protocol.shell(chan.outgoing.id, true);\n}\n\nfunction reqExec(chan, cmd, opts, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to exec'));\n return;\n }\n chan.subtype = 'exec';\n chan.allowHalfOpen = (opts.allowHalfOpen !== false);\n cb(undefined, chan);\n });\n\n chan._client._protocol.exec(chan.outgoing.id, cmd, true);\n}\n\nfunction reqEnv(chan, env) {\n if (chan.outgoing.state !== 'open')\n return;\n\n const keys = Object.keys(env || {});\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n const val = env[key];\n chan._client._protocol.env(chan.outgoing.id, key, val, false);\n }\n}\n\nfunction reqSubsystem(chan, name, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to start subsystem: ${name}`));\n return;\n }\n chan.subtype = 'subsystem';\n cb(undefined, chan);\n });\n\n chan._client._protocol.subsystem(chan.outgoing.id, name, true);\n}\n\n// TODO: inline implementation into single call site\nfunction onCHANNEL_OPEN(self, info) {\n // The server is trying to open a channel with us, this is usually when\n // we asked the server to forward us connections on some port and now they\n // are asking us to accept/deny an incoming connection on their side\n\n let localChan = -1;\n let reason;\n\n const accept = () => {\n const chanInfo = {\n type: info.type,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n const stream = new Channel(self, chanInfo);\n self._chanMgr.update(localChan, stream);\n\n self._protocol.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n return stream;\n };\n const reject = () => {\n if (reason === undefined) {\n if (localChan === -1)\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n else\n reason = CHANNEL_OPEN_FAILURE.CONNECT_FAILED;\n }\n\n if (localChan !== -1)\n self._chanMgr.remove(localChan);\n\n self._protocol.channelOpenFail(info.sender, reason, '');\n };\n const reserveChannel = () => {\n localChan = self._chanMgr.add();\n\n if (localChan === -1) {\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of incoming channel open: '\n + 'no channels available'\n );\n }\n }\n\n return (localChan !== -1);\n };\n\n const data = info.data;\n switch (info.type) {\n case 'forwarded-tcpip': {\n const val = self._forwarding[`${data.destIP}:${data.destPort}`];\n if (val !== undefined && reserveChannel()) {\n if (data.destPort === 0)\n data.destPort = val;\n self.emit('tcp connection', data, accept, reject);\n return;\n }\n break;\n }\n case 'forwarded-streamlocal@openssh.com':\n if (self._forwardingUnix[data.socketPath] !== undefined\n && reserveChannel()) {\n self.emit('unix connection', data, accept, reject);\n return;\n }\n break;\n case 'auth-agent@openssh.com':\n if (self._agentFwdEnabled\n && typeof self._agent.getStream === 'function'\n && reserveChannel()) {\n self._agent.getStream((err, stream) => {\n if (err)\n return reject();\n\n const upstream = accept();\n upstream.pipe(stream).pipe(upstream);\n });\n return;\n }\n break;\n case 'x11':\n if (self._acceptX11 !== 0 && reserveChannel()) {\n self.emit('x11', data, accept, reject);\n return;\n }\n break;\n default:\n // Automatically reject any unsupported channel open requests\n reason = CHANNEL_OPEN_FAILURE.UNKNOWN_CHANNEL_TYPE;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of unsupported incoming channel open '\n + `type: ${info.type}`\n );\n }\n }\n\n if (reason === undefined) {\n reason = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of unexpected incoming channel open for: '\n + info.type\n );\n }\n }\n\n reject();\n}\n\nconst randomCookie = (() => {\n const buffer = Buffer.allocUnsafe(16);\n return () => {\n randomFillSync(buffer, 0, 16);\n return buffer.hexSlice(0, 16);\n };\n})();\n\nfunction makeSimpleAuthHandler(authList) {\n if (!Array.isArray(authList))\n throw new Error('authList must be an array');\n\n let a = 0;\n return (authsLeft, partialSuccess, cb) => {\n if (a === authList.length)\n return false;\n return authList[a++];\n };\n}\n\nfunction hostKeysProve(client, keys_, cb) {\n if (!client._sock || !isWritable(client._sock))\n return;\n\n if (typeof cb !== 'function')\n cb = noop;\n\n if (!Array.isArray(keys_))\n throw new TypeError('Invalid keys argument type');\n\n const keys = [];\n for (const key of keys_) {\n const parsed = parseKey(key);\n if (parsed instanceof Error)\n throw parsed;\n keys.push(parsed);\n }\n\n if (!client.config.strictVendor\n || (client.config.strictVendor && RE_OPENSSH.test(client._remoteVer))) {\n client._callbacks.push((had_err, data) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Server failed to prove supplied keys'));\n return;\n }\n\n // TODO: move all of this parsing/verifying logic out of the client?\n const ret = [];\n let keyIdx = 0;\n bufferParser.init(data, 0);\n while (bufferParser.avail()) {\n if (keyIdx === keys.length)\n break;\n const key = keys[keyIdx++];\n const keyPublic = key.getPublicSSH();\n\n const sigEntry = bufferParser.readString();\n sigParser.init(sigEntry, 0);\n const type = sigParser.readString(true);\n let value = sigParser.readString();\n\n let algo;\n if (type !== key.type) {\n if (key.type === 'ssh-rsa') {\n switch (type) {\n case 'rsa-sha2-256':\n algo = 'sha256';\n break;\n case 'rsa-sha2-512':\n algo = 'sha512';\n break;\n default:\n continue;\n }\n } else {\n continue;\n }\n }\n\n const sessionID = client._protocol._kex.sessionID;\n const verifyData = Buffer.allocUnsafe(\n 4 + 29 + 4 + sessionID.length + 4 + keyPublic.length\n );\n let p = 0;\n writeUInt32BE(verifyData, 29, p);\n verifyData.utf8Write('hostkeys-prove-00@openssh.com', p += 4, 29);\n writeUInt32BE(verifyData, sessionID.length, p += 29);\n bufferCopy(sessionID, verifyData, 0, sessionID.length, p += 4);\n writeUInt32BE(verifyData, keyPublic.length, p += sessionID.length);\n bufferCopy(keyPublic, verifyData, 0, keyPublic.length, p += 4);\n\n if (!(value = sigSSHToASN1(value, type)))\n continue;\n if (key.verify(verifyData, value, algo) === true)\n ret.push(key);\n }\n sigParser.clear();\n bufferParser.clear();\n\n cb(null, ret);\n });\n\n client._protocol.openssh_hostKeysProve(keys);\n return;\n }\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n}\n\nmodule.exports = Client;\n","'use strict';\n\nconst { Agent: HttpAgent } = require('http');\nconst { Agent: HttpsAgent } = require('https');\nconst { connect: tlsConnect } = require('tls');\n\nlet Client;\n\nfor (const ctor of [HttpAgent, HttpsAgent]) {\n class SSHAgent extends ctor {\n constructor(connectCfg, agentOptions) {\n super(agentOptions);\n\n this._connectCfg = connectCfg;\n this._defaultSrcIP = (agentOptions && agentOptions.srcIP) || 'localhost';\n }\n\n createConnection(options, cb) {\n const srcIP = (options && options.localAddress) || this._defaultSrcIP;\n const srcPort = (options && options.localPort) || 0;\n const dstIP = options.host;\n const dstPort = options.port;\n\n if (Client === undefined)\n Client = require('./client.js');\n\n const client = new Client();\n let triedForward = false;\n client.on('ready', () => {\n client.forwardOut(srcIP, srcPort, dstIP, dstPort, (err, stream) => {\n triedForward = true;\n if (err) {\n client.end();\n return cb(err);\n }\n stream.once('close', () => client.end());\n cb(null, decorateStream(stream, ctor, options));\n });\n }).on('error', cb).on('close', () => {\n if (!triedForward)\n cb(new Error('Unexpected connection close'));\n }).connect(this._connectCfg);\n }\n }\n\n exports[ctor === HttpAgent ? 'SSHTTPAgent' : 'SSHTTPSAgent'] = SSHAgent;\n}\n\nfunction noop() {}\n\nfunction decorateStream(stream, ctor, options) {\n if (ctor === HttpAgent) {\n // HTTP\n stream.setKeepAlive = noop;\n stream.setNoDelay = noop;\n stream.setTimeout = noop;\n stream.ref = noop;\n stream.unref = noop;\n stream.destroySoon = stream.destroy;\n return stream;\n }\n\n // HTTPS\n options.socket = stream;\n const wrapped = tlsConnect(options);\n\n // This is a workaround for a regression in node v12.16.3+\n // https://github.com/nodejs/node/issues/35904\n const onClose = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n if (stream.isPaused())\n stream.resume();\n };\n })();\n // 'end' listener is needed because 'close' is not emitted in some scenarios\n // in node v12.x for some unknown reason\n wrapped.on('end', onClose).on('close', onClose);\n\n return wrapped;\n}\n","'use strict';\n\nconst {\n AgentProtocol,\n BaseAgent,\n createAgent,\n CygwinAgent,\n OpenSSHAgent,\n PageantAgent,\n} = require('./agent.js');\nconst {\n SSHTTPAgent: HTTPAgent,\n SSHTTPSAgent: HTTPSAgent,\n} = require('./http-agents.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst {\n flagsToString,\n OPEN_MODE,\n STATUS_CODE,\n stringToFlags,\n} = require('./protocol/SFTP.js');\n\nmodule.exports = {\n AgentProtocol,\n BaseAgent,\n createAgent,\n Client: require('./client.js'),\n CygwinAgent,\n HTTPAgent,\n HTTPSAgent,\n OpenSSHAgent,\n PageantAgent,\n Server: require('./server.js'),\n utils: {\n parseKey,\n sftp: {\n flagsToString,\n OPEN_MODE,\n STATUS_CODE,\n stringToFlags,\n },\n },\n};\n","/*\n TODO:\n * Replace `buffer._pos` usage in keyParser.js and elsewhere\n * Utilize optional \"writev\" support when writing packets from\n cipher.encrypt()\n * Built-in support for automatic re-keying, on by default\n * Revisit receiving unexpected/unknown packets\n * Error (fatal or otherwise) or ignore or pass on to user (in some or all\n cases)?\n * Including server/client check for single directional packet types?\n * Check packets for validity or bail as early as possible?\n * Automatic re-key every 2**31 packets after the last key exchange (sent or\n received), as suggested by RFC4344. OpenSSH currently does this.\n * Automatic re-key every so many blocks depending on cipher. RFC4344:\n Because of a birthday property of block ciphers and some modes of\n operation, implementations must be careful not to encrypt too many\n blocks with the same encryption key.\n\n Let L be the block length (in bits) of an SSH encryption method's\n block cipher (e.g., 128 for AES). If L is at least 128, then, after\n rekeying, an SSH implementation SHOULD NOT encrypt more than 2**(L/4)\n blocks before rekeying again. If L is at least 128, then SSH\n implementations should also attempt to force a rekey before receiving\n more than 2**(L/4) blocks. If L is less than 128 (which is the case\n for older ciphers such as 3DES, Blowfish, CAST-128, and IDEA), then,\n although it may be too expensive to rekey every 2**(L/4) blocks, it\n is still advisable for SSH implementations to follow the original\n recommendation in [RFC4253]: rekey at least once for every gigabyte\n of transmitted data.\n\n Note that if L is less than or equal to 128, then the recommendation\n in this subsection supersedes the recommendation in Section 3.1. If\n an SSH implementation uses a block cipher with a larger block size\n (e.g., Rijndael with 256-bit blocks), then the recommendations in\n Section 3.1 may supersede the recommendations in this subsection\n (depending on the lengths of the packets).\n*/\n\n'use strict';\n\nconst { inspect } = require('util');\n\nconst { bindingAvailable, NullCipher, NullDecipher } = require('./crypto.js');\nconst {\n COMPAT_CHECKS,\n DISCONNECT_REASON,\n MESSAGE,\n SIGNALS,\n TERMINAL_MODE,\n} = require('./constants.js');\nconst {\n DEFAULT_KEXINIT,\n KexInit,\n kexinit,\n onKEXPayload,\n} = require('./kex.js');\nconst {\n parseKey,\n} = require('./keyParser.js');\nconst MESSAGE_HANDLERS = require('./handlers.js');\nconst {\n bufferCopy,\n bufferFill,\n bufferSlice,\n convertSignature,\n sendPacket,\n writeUInt32BE,\n} = require('./utils.js');\nconst {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n} = require('./zlib.js');\n\nconst MODULE_VER = require('../../package.json').version;\n\nconst VALID_DISCONNECT_REASONS = new Map(\n Object.values(DISCONNECT_REASON).map((n) => [n, 1])\n);\nconst IDENT_RAW = Buffer.from(`SSH-2.0-ssh2js${MODULE_VER}`);\nconst IDENT = Buffer.from(`${IDENT_RAW}\\r\\n`);\nconst MAX_LINE_LEN = 8192;\nconst MAX_LINES = 1024;\nconst PING_PAYLOAD = Buffer.from([\n MESSAGE.GLOBAL_REQUEST,\n // \"keepalive@openssh.com\"\n 0, 0, 0, 21,\n 107, 101, 101, 112, 97, 108, 105, 118, 101, 64, 111, 112, 101, 110, 115,\n 115, 104, 46, 99, 111, 109,\n // Request a reply\n 1,\n]);\nconst NO_TERMINAL_MODES_BUFFER = Buffer.from([ TERMINAL_MODE.TTY_OP_END ]);\n\nfunction noop() {}\n\n/*\n Inbound:\n * kexinit payload (needed only until exchange hash is generated)\n * raw ident\n * rekey packet queue\n * expected packet (implemented as separate _parse() function?)\n Outbound:\n * kexinit payload (needed only until exchange hash is generated)\n * rekey packet queue\n * kex secret (needed only until NEWKEYS)\n * exchange hash (needed only until NEWKEYS)\n * session ID (set to exchange hash from initial handshake)\n*/\nclass Protocol {\n constructor(config) {\n const onWrite = config.onWrite;\n if (typeof onWrite !== 'function')\n throw new Error('Missing onWrite function');\n this._onWrite = (data) => { onWrite(data); };\n\n const onError = config.onError;\n if (typeof onError !== 'function')\n throw new Error('Missing onError function');\n this._onError = (err) => { onError(err); };\n\n const debug = config.debug;\n this._debug = (typeof debug === 'function'\n ? (msg) => { debug(msg); }\n : undefined);\n\n const onHeader = config.onHeader;\n this._onHeader = (typeof onHeader === 'function'\n ? (...args) => { onHeader(...args); }\n : noop);\n\n const onPacket = config.onPacket;\n this._onPacket = (typeof onPacket === 'function'\n ? () => { onPacket(); }\n : noop);\n\n let onHandshakeComplete = config.onHandshakeComplete;\n if (typeof onHandshakeComplete !== 'function')\n onHandshakeComplete = noop;\n this._onHandshakeComplete = (...args) => {\n this._debug && this._debug('Handshake completed');\n\n // Process packets queued during a rekey where necessary\n const oldQueue = this._queue;\n if (oldQueue) {\n this._queue = undefined;\n this._debug && this._debug(\n `Draining outbound queue (${oldQueue.length}) ...`\n );\n for (let i = 0; i < oldQueue.length; ++i) {\n const data = oldQueue[i];\n // data === payload only\n\n // XXX: hacky\n let finalized = this._packetRW.write.finalize(data);\n if (finalized === data) {\n const packet = this._cipher.allocPacket(data.length);\n packet.set(data, 5);\n finalized = packet;\n }\n\n sendPacket(this, finalized);\n }\n this._debug && this._debug('... finished draining outbound queue');\n }\n\n onHandshakeComplete(...args);\n };\n this._queue = undefined;\n\n const messageHandlers = config.messageHandlers;\n if (typeof messageHandlers === 'object' && messageHandlers !== null)\n this._handlers = messageHandlers;\n else\n this._handlers = {};\n\n this._onPayload = onPayload.bind(this);\n\n this._server = !!config.server;\n this._banner = undefined;\n let greeting;\n if (this._server) {\n if (typeof config.hostKeys !== 'object' || config.hostKeys === null)\n throw new Error('Missing server host key(s)');\n this._hostKeys = config.hostKeys;\n\n // Greeting displayed before the ssh identification string is sent, this\n // is usually ignored by most clients\n if (typeof config.greeting === 'string' && config.greeting.length) {\n greeting = (config.greeting.slice(-2) === '\\r\\n'\n ? config.greeting\n : `${config.greeting}\\r\\n`);\n }\n\n // Banner shown after the handshake completes, but before user\n // authentication begins\n if (typeof config.banner === 'string' && config.banner.length) {\n this._banner = (config.banner.slice(-2) === '\\r\\n'\n ? config.banner\n : `${config.banner}\\r\\n`);\n }\n } else {\n this._hostKeys = undefined;\n }\n\n let offer = config.offer;\n if (typeof offer !== 'object' || offer === null)\n offer = DEFAULT_KEXINIT;\n else if (offer.constructor !== KexInit)\n offer = new KexInit(offer);\n this._kex = undefined;\n this._kexinit = undefined;\n this._offer = offer;\n this._cipher = new NullCipher(0, this._onWrite);\n this._decipher = undefined;\n this._skipNextInboundPacket = false;\n this._packetRW = {\n read: new PacketReader(),\n write: new PacketWriter(this),\n };\n this._hostVerifier = (!this._server\n && typeof config.hostVerifier === 'function'\n ? config.hostVerifier\n : undefined);\n\n this._parse = parseHeader;\n this._buffer = undefined;\n this._authsQueue = [];\n this._authenticated = false;\n this._remoteIdentRaw = undefined;\n let sentIdent;\n if (typeof config.ident === 'string') {\n this._identRaw = Buffer.from(`SSH-2.0-${config.ident}`);\n\n sentIdent = Buffer.allocUnsafe(this._identRaw.length + 2);\n sentIdent.set(this._identRaw, 0);\n sentIdent[sentIdent.length - 2] = 13; // '\\r'\n sentIdent[sentIdent.length - 1] = 10; // '\\n'\n } else if (Buffer.isBuffer(config.ident)) {\n const fullIdent = Buffer.allocUnsafe(8 + config.ident.length);\n fullIdent.latin1Write('SSH-2.0-', 0, 8);\n fullIdent.set(config.ident, 8);\n this._identRaw = fullIdent;\n\n sentIdent = Buffer.allocUnsafe(fullIdent.length + 2);\n sentIdent.set(fullIdent, 0);\n sentIdent[sentIdent.length - 2] = 13; // '\\r'\n sentIdent[sentIdent.length - 1] = 10; // '\\n'\n } else {\n this._identRaw = IDENT_RAW;\n sentIdent = IDENT;\n }\n this._compatFlags = 0;\n\n if (this._debug) {\n if (bindingAvailable)\n this._debug('Custom crypto binding available');\n else\n this._debug('Custom crypto binding not available');\n }\n\n this._debug && this._debug(\n `Local ident: ${inspect(this._identRaw.toString())}`\n );\n this.start = () => {\n this.start = undefined;\n if (greeting)\n this._onWrite(greeting);\n this._onWrite(sentIdent);\n };\n }\n _destruct(reason) {\n this._packetRW.read.cleanup();\n this._packetRW.write.cleanup();\n this._cipher && this._cipher.free();\n this._decipher && this._decipher.free();\n if (typeof reason !== 'string' || reason.length === 0)\n reason = 'fatal error';\n this.parse = () => {\n throw new Error(`Instance unusable after ${reason}`);\n };\n this._onWrite = () => {\n throw new Error(`Instance unusable after ${reason}`);\n };\n this._destruct = undefined;\n }\n cleanup() {\n this._destruct && this._destruct();\n }\n parse(chunk, i, len) {\n while (i < len)\n i = this._parse(chunk, i, len);\n }\n\n // Protocol message API\n\n // ===========================================================================\n // Common/Shared =============================================================\n // ===========================================================================\n\n // Global\n // ------\n disconnect(reason) {\n const pktLen = 1 + 4 + 4 + 4;\n // We don't use _packetRW.write.* here because we need to make sure that\n // we always get a full packet allocated because this message can be sent\n // at any time -- even during a key exchange\n let p = this._packetRW.write.allocStartKEX;\n const packet = this._packetRW.write.alloc(pktLen, true);\n const end = p + pktLen;\n\n if (!VALID_DISCONNECT_REASONS.has(reason))\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n\n packet[p] = MESSAGE.DISCONNECT;\n writeUInt32BE(packet, reason, ++p);\n packet.fill(0, p += 4, end);\n\n this._debug && this._debug(`Outbound: Sending DISCONNECT (${reason})`);\n sendPacket(this, this._packetRW.write.finalize(packet, true), true);\n }\n ping() {\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(PING_PAYLOAD.length);\n\n packet.set(PING_PAYLOAD, p);\n\n this._debug && this._debug(\n 'Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n rekey() {\n if (this._kexinit === undefined) {\n this._debug && this._debug('Outbound: Initiated explicit rekey');\n this._queue = [];\n kexinit(this);\n } else {\n this._debug && this._debug('Outbound: Ignoring rekey during handshake');\n }\n }\n\n // 'ssh-connection' service-specific\n // ---------------------------------\n requestSuccess(data) {\n let p = this._packetRW.write.allocStart;\n let packet;\n if (Buffer.isBuffer(data)) {\n packet = this._packetRW.write.alloc(1 + data.length);\n\n packet[p] = MESSAGE.REQUEST_SUCCESS;\n\n packet.set(data, ++p);\n } else {\n packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.REQUEST_SUCCESS;\n }\n\n this._debug && this._debug('Outbound: Sending REQUEST_SUCCESS');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n requestFailure() {\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.REQUEST_FAILURE;\n\n this._debug && this._debug('Outbound: Sending REQUEST_FAILURE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelSuccess(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_SUCCESS;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelFailure(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_FAILURE;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelEOF(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_EOF;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_EOF (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelClose(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_CLOSE;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelWindowAdjust(chan, amount) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_WINDOW_ADJUST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, amount, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${chan}, ${amount})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelData(chan, data) {\n const isBuffer = Buffer.isBuffer(data);\n const dataLen = (isBuffer ? data.length : Buffer.byteLength(data));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + dataLen);\n\n packet[p] = MESSAGE.CHANNEL_DATA;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, dataLen, p += 4);\n\n if (isBuffer)\n packet.set(data, p += 4);\n else\n packet.utf8Write(data, p += 4, dataLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_DATA (r:${chan}, ${dataLen})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelExtData(chan, data, type) {\n const isBuffer = Buffer.isBuffer(data);\n const dataLen = (isBuffer ? data.length : Buffer.byteLength(data));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + dataLen);\n\n packet[p] = MESSAGE.CHANNEL_EXTENDED_DATA;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, type, p += 4);\n\n writeUInt32BE(packet, dataLen, p += 4);\n\n if (isBuffer)\n packet.set(data, p += 4);\n else\n packet.utf8Write(data, p += 4, dataLen);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelOpenConfirm(remote, local, initWindow, maxPacket) {\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN_CONFIRMATION;\n\n writeUInt32BE(packet, remote, ++p);\n\n writeUInt32BE(packet, local, p += 4);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${remote}, l:${local})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelOpenFail(remote, reason, desc) {\n if (typeof desc !== 'string')\n desc = '';\n\n const descLen = Buffer.byteLength(desc);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + descLen + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN_FAILURE;\n\n writeUInt32BE(packet, remote, ++p);\n\n writeUInt32BE(packet, reason, p += 4);\n\n writeUInt32BE(packet, descLen, p += 4);\n\n p += 4;\n if (descLen) {\n packet.utf8Write(desc, p, descLen);\n p += descLen;\n }\n\n writeUInt32BE(packet, 0, p); // Empty language tag\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${remote})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // ===========================================================================\n // Client-specific ===========================================================\n // ===========================================================================\n\n // Global\n // ------\n service(name) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const nameLen = Buffer.byteLength(name);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + nameLen);\n\n packet[p] = MESSAGE.SERVICE_REQUEST;\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(name, p += 4, nameLen);\n\n this._debug && this._debug(`Outbound: Sending SERVICE_REQUEST (${name})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // 'ssh-userauth' service-specific\n // -------------------------------\n authPassword(username, password, newPassword) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n const passLen = Buffer.byteLength(password);\n const newPassLen = (newPassword ? Buffer.byteLength(newPassword) : 0);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 8 + 1 + 4 + passLen\n + (newPassword ? 4 + newPassLen : 0)\n );\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 8, p += 14);\n packet.utf8Write('password', p += 4, 8);\n\n packet[p += 8] = (newPassword ? 1 : 0);\n\n writeUInt32BE(packet, passLen, ++p);\n if (Buffer.isBuffer(password))\n bufferCopy(password, packet, 0, passLen, p += 4);\n else\n packet.utf8Write(password, p += 4, passLen);\n\n if (newPassword) {\n writeUInt32BE(packet, newPassLen, p += passLen);\n if (Buffer.isBuffer(newPassword))\n bufferCopy(newPassword, packet, 0, newPassLen, p += 4);\n else\n packet.utf8Write(newPassword, p += 4, newPassLen);\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (changed password)'\n );\n } else {\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (password)'\n );\n }\n\n this._authsQueue.push('password');\n\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authPK(username, pubKey, cbSign) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n pubKey = parseKey(pubKey);\n if (pubKey instanceof Error)\n throw new Error('Invalid key');\n\n const keyType = pubKey.type;\n pubKey = pubKey.getPublicSSH();\n\n const userLen = Buffer.byteLength(username);\n const algoLen = Buffer.byteLength(keyType);\n const pubKeyLen = pubKey.length;\n const sessionID = this._kex.sessionID;\n const sesLen = sessionID.length;\n const payloadLen =\n (cbSign ? 4 + sesLen : 0)\n + 1 + 4 + userLen + 4 + 14 + 4 + 9 + 1 + 4 + algoLen + 4 + pubKeyLen;\n let packet;\n let p;\n if (cbSign) {\n packet = Buffer.allocUnsafe(payloadLen);\n p = 0;\n writeUInt32BE(packet, sesLen, p);\n packet.set(sessionID, p += 4);\n p += sesLen;\n } else {\n packet = this._packetRW.write.alloc(payloadLen);\n p = this._packetRW.write.allocStart;\n }\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 9, p += 14);\n packet.utf8Write('publickey', p += 4, 9);\n\n packet[p += 9] = (cbSign ? 1 : 0);\n\n writeUInt32BE(packet, algoLen, ++p);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, pubKeyLen, p += algoLen);\n packet.set(pubKey, p += 4);\n\n if (!cbSign) {\n this._authsQueue.push('publickey');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (publickey -- check)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n return;\n }\n\n cbSign(packet, (signature) => {\n signature = convertSignature(signature, keyType);\n if (signature === false)\n throw new Error('Error while converting handshake signature');\n\n const sigLen = signature.length;\n p = this._packetRW.write.allocStart;\n packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 9 + 1 + 4 + algoLen + 4 + pubKeyLen + 4\n + 4 + algoLen + 4 + sigLen\n );\n\n // TODO: simply copy from original \"packet\" to new `packet` to avoid\n // having to write each individual field a second time?\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 9, p += 14);\n packet.utf8Write('publickey', p += 4, 9);\n\n packet[p += 9] = 1;\n\n writeUInt32BE(packet, algoLen, ++p);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, pubKeyLen, p += algoLen);\n packet.set(pubKey, p += 4);\n\n writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += pubKeyLen);\n\n writeUInt32BE(packet, algoLen, p += 4);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, sigLen, p += algoLen);\n packet.set(signature, p += 4);\n\n // Servers shouldn't send packet type 60 in response to signed publickey\n // attempts, but if they do, interpret as type 60.\n this._authsQueue.push('publickey');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (publickey)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n });\n }\n authHostbased(username, pubKey, hostname, userlocal, cbSign) {\n // TODO: Make DRY by sharing similar code with authPK()\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n pubKey = parseKey(pubKey);\n if (pubKey instanceof Error)\n throw new Error('Invalid key');\n\n const keyType = pubKey.type;\n pubKey = pubKey.getPublicSSH();\n\n const userLen = Buffer.byteLength(username);\n const algoLen = Buffer.byteLength(keyType);\n const pubKeyLen = pubKey.length;\n const sessionID = this._kex.sessionID;\n const sesLen = sessionID.length;\n const hostnameLen = Buffer.byteLength(hostname);\n const userlocalLen = Buffer.byteLength(userlocal);\n const data = Buffer.allocUnsafe(\n 4 + sesLen + 1 + 4 + userLen + 4 + 14 + 4 + 9 + 4 + algoLen\n + 4 + pubKeyLen + 4 + hostnameLen + 4 + userlocalLen\n );\n let p = 0;\n\n writeUInt32BE(data, sesLen, p);\n data.set(sessionID, p += 4);\n\n data[p += sesLen] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(data, userLen, ++p);\n data.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(data, 14, p += userLen);\n data.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(data, 9, p += 14);\n data.utf8Write('hostbased', p += 4, 9);\n\n writeUInt32BE(data, algoLen, p += 9);\n data.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(data, pubKeyLen, p += algoLen);\n data.set(pubKey, p += 4);\n\n writeUInt32BE(data, hostnameLen, p += pubKeyLen);\n data.utf8Write(hostname, p += 4, hostnameLen);\n\n writeUInt32BE(data, userlocalLen, p += hostnameLen);\n data.utf8Write(userlocal, p += 4, userlocalLen);\n\n cbSign(data, (signature) => {\n signature = convertSignature(signature, keyType);\n if (!signature)\n throw new Error('Error while converting handshake signature');\n\n const sigLen = signature.length;\n const reqDataLen = (data.length - sesLen - 4);\n p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n reqDataLen + 4 + 4 + algoLen + 4 + sigLen\n );\n\n bufferCopy(data, packet, 4 + sesLen, data.length, p);\n\n writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += reqDataLen);\n writeUInt32BE(packet, algoLen, p += 4);\n packet.utf8Write(keyType, p += 4, algoLen);\n writeUInt32BE(packet, sigLen, p += algoLen);\n packet.set(signature, p += 4);\n\n this._authsQueue.push('hostbased');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (hostbased)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n });\n }\n authKeyboard(username) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 20 + 4 + 4\n );\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 20, p += 14);\n packet.utf8Write('keyboard-interactive', p += 4, 20);\n\n writeUInt32BE(packet, 0, p += 20);\n\n writeUInt32BE(packet, 0, p += 4);\n\n this._authsQueue.push('keyboard-interactive');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authNone(username) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + userLen + 4 + 14 + 4 + 4);\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 4, p += 14);\n packet.utf8Write('none', p += 4, 4);\n\n this._authsQueue.push('none');\n\n this._debug && this._debug('Outbound: Sending USERAUTH_REQUEST (none)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authInfoRes(responses) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let responsesTotalLen = 0;\n let responseLens;\n\n if (responses) {\n responseLens = new Array(responses.length);\n for (let i = 0; i < responses.length; ++i) {\n const len = Buffer.byteLength(responses[i]);\n responseLens[i] = len;\n responsesTotalLen += 4 + len;\n }\n }\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + responsesTotalLen);\n\n packet[p] = MESSAGE.USERAUTH_INFO_RESPONSE;\n\n if (responses) {\n writeUInt32BE(packet, responses.length, ++p);\n p += 4;\n for (let i = 0; i < responses.length; ++i) {\n const len = responseLens[i];\n writeUInt32BE(packet, len, p);\n p += 4;\n if (len) {\n packet.utf8Write(responses[i], p, len);\n p += len;\n }\n }\n } else {\n writeUInt32BE(packet, 0, ++p);\n }\n\n this._debug && this._debug('Outbound: Sending USERAUTH_INFO_RESPONSE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // 'ssh-connection' service-specific\n // ---------------------------------\n tcpipForward(bindAddr, bindPort, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const addrLen = Buffer.byteLength(bindAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 13 + 1 + 4 + addrLen + 4);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 13, ++p);\n packet.utf8Write('tcpip-forward', p += 4, 13);\n\n packet[p += 13] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, addrLen, ++p);\n packet.utf8Write(bindAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, bindPort, p += addrLen);\n\n this._debug\n && this._debug('Outbound: Sending GLOBAL_REQUEST (tcpip-forward)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n cancelTcpipForward(bindAddr, bindPort, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const addrLen = Buffer.byteLength(bindAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 20 + 1 + 4 + addrLen + 4);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 20, ++p);\n packet.utf8Write('cancel-tcpip-forward', p += 4, 20);\n\n packet[p += 20] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, addrLen, ++p);\n packet.utf8Write(bindAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, bindPort, p += addrLen);\n\n this._debug\n && this._debug('Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_streamLocalForward(socketPath, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const socketPathLen = Buffer.byteLength(socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 31 + 1 + 4 + socketPathLen\n );\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 31, ++p);\n packet.utf8Write('streamlocal-forward@openssh.com', p += 4, 31);\n\n packet[p += 31] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, socketPathLen, ++p);\n packet.utf8Write(socketPath, p += 4, socketPathLen);\n\n this._debug && this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_cancelStreamLocalForward(socketPath, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const socketPathLen = Buffer.byteLength(socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 38 + 1 + 4 + socketPathLen\n );\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 38, ++p);\n packet.utf8Write('cancel-streamlocal-forward@openssh.com', p += 4, 38);\n\n packet[p += 38] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, socketPathLen, ++p);\n packet.utf8Write(socketPath, p += 4, socketPathLen);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending GLOBAL_REQUEST '\n + '(cancel-streamlocal-forward@openssh.com)'\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n directTcpip(chan, initWindow, maxPacket, cfg) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const srcLen = Buffer.byteLength(cfg.srcIP);\n const dstLen = Buffer.byteLength(cfg.dstIP);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 12 + 4 + 4 + 4 + 4 + srcLen + 4 + 4 + dstLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 12, ++p);\n packet.utf8Write('direct-tcpip', p += 4, 12);\n\n writeUInt32BE(packet, chan, p += 12);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, dstLen, p += 4);\n packet.utf8Write(cfg.dstIP, p += 4, dstLen);\n\n writeUInt32BE(packet, cfg.dstPort, p += dstLen);\n\n writeUInt32BE(packet, srcLen, p += 4);\n packet.utf8Write(cfg.srcIP, p += 4, srcLen);\n\n writeUInt32BE(packet, cfg.srcPort, p += srcLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, direct-tcpip)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_directStreamLocal(chan, initWindow, maxPacket, cfg) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const pathLen = Buffer.byteLength(cfg.socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 30 + 4 + 4 + 4 + 4 + pathLen + 4 + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 30, ++p);\n packet.utf8Write('direct-streamlocal@openssh.com', p += 4, 30);\n\n writeUInt32BE(packet, chan, p += 30);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, pathLen, p += 4);\n packet.utf8Write(cfg.socketPath, p += 4, pathLen);\n\n // zero-fill reserved fields (string and uint32)\n bufferFill(packet, 0, p += pathLen, p + 8);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_OPEN '\n + `(r:${chan}, direct-streamlocal@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_noMoreSessions(wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 28 + 1);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 28, ++p);\n packet.utf8Write('no-more-sessions@openssh.com', p += 4, 28);\n\n packet[p += 28] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n this._debug && this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n session(chan, initWindow, maxPacket) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 7 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 7, ++p);\n packet.utf8Write('session', p += 4, 7);\n\n writeUInt32BE(packet, chan, p += 7);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_OPEN (r:${chan}, session)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n windowChange(chan, rows, cols, height, width) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 13 + 1 + 4 + 4 + 4 + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 13, p += 4);\n packet.utf8Write('window-change', p += 4, 13);\n\n packet[p += 13] = 0;\n\n writeUInt32BE(packet, cols, ++p);\n\n writeUInt32BE(packet, rows, p += 4);\n\n writeUInt32BE(packet, width, p += 4);\n\n writeUInt32BE(packet, height, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, window-change)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n pty(chan, rows, cols, height, width, term, modes, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n if (!term || !term.length)\n term = 'vt100';\n if (modes\n && !Buffer.isBuffer(modes)\n && !Array.isArray(modes)\n && typeof modes === 'object'\n && modes !== null) {\n modes = modesToBytes(modes);\n }\n if (!modes || !modes.length)\n modes = NO_TERMINAL_MODES_BUFFER;\n\n const termLen = term.length;\n const modesLen = modes.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 7 + 1 + 4 + termLen + 4 + 4 + 4 + 4 + 4 + modesLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 7, p += 4);\n packet.utf8Write('pty-req', p += 4, 7);\n\n packet[p += 7] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, termLen, ++p);\n packet.utf8Write(term, p += 4, termLen);\n\n writeUInt32BE(packet, cols, p += termLen);\n\n writeUInt32BE(packet, rows, p += 4);\n\n writeUInt32BE(packet, width, p += 4);\n\n writeUInt32BE(packet, height, p += 4);\n\n writeUInt32BE(packet, modesLen, p += 4);\n p += 4;\n if (Array.isArray(modes)) {\n for (let i = 0; i < modesLen; ++i)\n packet[p++] = modes[i];\n } else if (Buffer.isBuffer(modes)) {\n packet.set(modes, p);\n }\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, pty-req)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n shell(chan, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 5 + 1);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 5, p += 4);\n packet.utf8Write('shell', p += 4, 5);\n\n packet[p += 5] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, shell)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exec(chan, cmd, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const isBuf = Buffer.isBuffer(cmd);\n const cmdLen = (isBuf ? cmd.length : Buffer.byteLength(cmd));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + 1 + 4 + cmdLen);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 4, p += 4);\n packet.utf8Write('exec', p += 4, 4);\n\n packet[p += 4] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, cmdLen, ++p);\n if (isBuf)\n packet.set(cmd, p += 4);\n else\n packet.utf8Write(cmd, p += 4, cmdLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exec: ${cmd})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n signal(chan, signal) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const origSignal = signal;\n\n signal = signal.toUpperCase();\n if (signal.slice(0, 3) === 'SIG')\n signal = signal.slice(3);\n\n if (SIGNALS[signal] !== 1)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n const signalLen = signal.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 6 + 1 + 4 + signalLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 6, p += 4);\n packet.utf8Write('signal', p += 4, 6);\n\n packet[p += 6] = 0;\n\n writeUInt32BE(packet, signalLen, ++p);\n packet.utf8Write(signal, p += 4, signalLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, signal: ${signal})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n env(chan, key, val, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const keyLen = Buffer.byteLength(key);\n const isBuf = Buffer.isBuffer(val);\n const valLen = (isBuf ? val.length : Buffer.byteLength(val));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 3 + 1 + 4 + keyLen + 4 + valLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 3, p += 4);\n packet.utf8Write('env', p += 4, 3);\n\n packet[p += 3] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, keyLen, ++p);\n packet.utf8Write(key, p += 4, keyLen);\n\n writeUInt32BE(packet, valLen, p += keyLen);\n if (isBuf)\n packet.set(val, p += 4);\n else\n packet.utf8Write(val, p += 4, valLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, env: ${key}=${val})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n x11Forward(chan, cfg, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const protocol = cfg.protocol;\n const cookie = cfg.cookie;\n const isBufProto = Buffer.isBuffer(protocol);\n const protoLen = (isBufProto\n ? protocol.length\n : Buffer.byteLength(protocol));\n const isBufCookie = Buffer.isBuffer(cookie);\n const cookieLen = (isBufCookie\n ? cookie.length\n : Buffer.byteLength(cookie));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 7 + 1 + 1 + 4 + protoLen + 4 + cookieLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 7, p += 4);\n packet.utf8Write('x11-req', p += 4, 7);\n\n packet[p += 7] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n packet[++p] = (cfg.single ? 1 : 0);\n\n writeUInt32BE(packet, protoLen, ++p);\n if (isBufProto)\n packet.set(protocol, p += 4);\n else\n packet.utf8Write(protocol, p += 4, protoLen);\n\n writeUInt32BE(packet, cookieLen, p += protoLen);\n if (isBufCookie)\n packet.set(cookie, p += 4);\n else\n packet.latin1Write(cookie, p += 4, cookieLen);\n\n writeUInt32BE(packet, (cfg.screen || 0), p += cookieLen);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, x11-req)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n subsystem(chan, name, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n const nameLen = Buffer.byteLength(name);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 9 + 1 + 4 + nameLen);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 9, p += 4);\n packet.utf8Write('subsystem', p += 4, 9);\n\n packet[p += 9] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(name, p += 4, nameLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, subsystem: ${name})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_agentForward(chan, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 26 + 1);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 26, p += 4);\n packet.utf8Write('auth-agent-req@openssh.com', p += 4, 26);\n\n packet[p += 26] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_REQUEST '\n + `(r:${chan}, auth-agent-req@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_hostKeysProve(keys) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let keysTotal = 0;\n const publicKeys = [];\n for (const key of keys) {\n const publicKey = key.getPublicSSH();\n keysTotal += 4 + publicKey.length;\n publicKeys.push(publicKey);\n }\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 29 + 1 + keysTotal);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 29, ++p);\n packet.utf8Write('hostkeys-prove-00@openssh.com', p += 4, 29);\n\n packet[p += 29] = 1; // want reply\n\n ++p;\n for (const buf of publicKeys) {\n writeUInt32BE(packet, buf.length, p);\n bufferCopy(buf, packet, 0, buf.length, p += 4);\n p += buf.length;\n }\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)'\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // ===========================================================================\n // Server-specific ===========================================================\n // ===========================================================================\n\n // Global\n // ------\n serviceAccept(svcName) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const svcNameLen = Buffer.byteLength(svcName);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + svcNameLen);\n\n packet[p] = MESSAGE.SERVICE_ACCEPT;\n\n writeUInt32BE(packet, svcNameLen, ++p);\n packet.utf8Write(svcName, p += 4, svcNameLen);\n\n this._debug && this._debug(`Outbound: Sending SERVICE_ACCEPT (${svcName})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n\n if (this._server && this._banner && svcName === 'ssh-userauth') {\n const banner = this._banner;\n this._banner = undefined; // Prevent banner from being displayed again\n const bannerLen = Buffer.byteLength(banner);\n p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + bannerLen + 4);\n\n packet[p] = MESSAGE.USERAUTH_BANNER;\n\n writeUInt32BE(packet, bannerLen, ++p);\n packet.utf8Write(banner, p += 4, bannerLen);\n\n writeUInt32BE(packet, 0, p += bannerLen); // Empty language tag\n\n this._debug && this._debug('Outbound: Sending USERAUTH_BANNER');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n }\n // 'ssh-connection' service-specific\n forwardedTcpip(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const boundAddrLen = Buffer.byteLength(cfg.boundAddr);\n const remoteAddrLen = Buffer.byteLength(cfg.remoteAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 15 + 4 + 4 + 4 + 4 + boundAddrLen + 4 + 4 + remoteAddrLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 15, ++p);\n packet.utf8Write('forwarded-tcpip', p += 4, 15);\n\n writeUInt32BE(packet, chan, p += 15);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, boundAddrLen, p += 4);\n packet.utf8Write(cfg.boundAddr, p += 4, boundAddrLen);\n\n writeUInt32BE(packet, cfg.boundPort, p += boundAddrLen);\n\n writeUInt32BE(packet, remoteAddrLen, p += 4);\n packet.utf8Write(cfg.remoteAddr, p += 4, remoteAddrLen);\n\n writeUInt32BE(packet, cfg.remotePort, p += remoteAddrLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, forwarded-tcpip)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n x11(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const addrLen = Buffer.byteLength(cfg.originAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 3 + 4 + 4 + 4 + 4 + addrLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 3, ++p);\n packet.utf8Write('x11', p += 4, 3);\n\n writeUInt32BE(packet, chan, p += 3);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, addrLen, p += 4);\n packet.utf8Write(cfg.originAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, cfg.originPort, p += addrLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, x11)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_authAgent(chan, initWindow, maxPacket) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 22 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 22, ++p);\n packet.utf8Write('auth-agent@openssh.com', p += 4, 22);\n\n writeUInt32BE(packet, chan, p += 22);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, auth-agent@openssh.com)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_forwardedStreamLocal(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const pathLen = Buffer.byteLength(cfg.socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 33 + 4 + 4 + 4 + 4 + pathLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 33, ++p);\n packet.utf8Write('forwarded-streamlocal@openssh.com', p += 4, 33);\n\n writeUInt32BE(packet, chan, p += 33);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, pathLen, p += 4);\n packet.utf8Write(cfg.socketPath, p += 4, pathLen);\n\n writeUInt32BE(packet, 0, p += pathLen);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_OPEN '\n + `(r:${chan}, forwarded-streamlocal@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exitStatus(chan, status) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 11 + 1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-status', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, status, ++p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-status: ${status})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exitSignal(chan, name, coreDumped, msg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n\n const origSignal = name;\n\n if (typeof origSignal !== 'string' || !origSignal)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n let signal = name.toUpperCase();\n if (signal.slice(0, 3) === 'SIG')\n signal = signal.slice(3);\n\n if (SIGNALS[signal] !== 1)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n const nameLen = Buffer.byteLength(signal);\n const msgLen = (msg ? Buffer.byteLength(msg) : 0);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 11 + 1 + 4 + nameLen + 1 + 4 + msgLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-signal', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(signal, p += 4, nameLen);\n\n packet[p += nameLen] = (coreDumped ? 1 : 0);\n\n writeUInt32BE(packet, msgLen, ++p);\n\n p += 4;\n if (msgLen) {\n packet.utf8Write(msg, p, msgLen);\n p += msgLen;\n }\n\n writeUInt32BE(packet, 0, p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-signal: ${name})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n // 'ssh-userauth' service-specific\n authFailure(authMethods, isPartial) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0)\n throw new Error('No auth in progress');\n\n let methods;\n\n if (typeof authMethods === 'boolean') {\n isPartial = authMethods;\n authMethods = undefined;\n }\n\n if (authMethods) {\n methods = [];\n for (let i = 0; i < authMethods.length; ++i) {\n if (authMethods[i].toLowerCase() === 'none')\n continue;\n methods.push(authMethods[i]);\n }\n methods = methods.join(',');\n } else {\n methods = '';\n }\n\n const methodsLen = methods.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + methodsLen + 1);\n\n packet[p] = MESSAGE.USERAUTH_FAILURE;\n\n writeUInt32BE(packet, methodsLen, ++p);\n packet.utf8Write(methods, p += 4, methodsLen);\n\n packet[p += methodsLen] = (isPartial === true ? 1 : 0);\n\n this._authsQueue.shift();\n\n this._debug && this._debug('Outbound: Sending USERAUTH_FAILURE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authSuccess() {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0)\n throw new Error('No auth in progress');\n\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.USERAUTH_SUCCESS;\n\n this._authsQueue.shift();\n this._authenticated = true;\n\n this._debug && this._debug('Outbound: Sending USERAUTH_SUCCESS');\n sendPacket(this, this._packetRW.write.finalize(packet));\n\n if (this._kex.negotiated.cs.compress === 'zlib@openssh.com')\n this._packetRW.read = new ZlibPacketReader();\n if (this._kex.negotiated.sc.compress === 'zlib@openssh.com')\n this._packetRW.write = new ZlibPacketWriter(this);\n }\n authPKOK(keyAlgo, key) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0 || this._authsQueue[0] !== 'publickey')\n throw new Error('\"publickey\" auth not in progress');\n\n // TODO: support parsed key for `key`\n\n const keyAlgoLen = Buffer.byteLength(keyAlgo);\n const keyLen = key.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + keyAlgoLen + 4 + keyLen);\n\n packet[p] = MESSAGE.USERAUTH_PK_OK;\n\n writeUInt32BE(packet, keyAlgoLen, ++p);\n packet.utf8Write(keyAlgo, p += 4, keyAlgoLen);\n\n writeUInt32BE(packet, keyLen, p += keyAlgoLen);\n packet.set(key, p += 4);\n\n this._authsQueue.shift();\n\n this._debug && this._debug('Outbound: Sending USERAUTH_PK_OK');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authPasswdChg(prompt) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const promptLen = Buffer.byteLength(prompt);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + promptLen + 4);\n\n packet[p] = MESSAGE.USERAUTH_PASSWD_CHANGEREQ;\n\n writeUInt32BE(packet, promptLen, ++p);\n packet.utf8Write(prompt, p += 4, promptLen);\n\n writeUInt32BE(packet, 0, p += promptLen); // Empty language tag\n\n this._debug && this._debug('Outbound: Sending USERAUTH_PASSWD_CHANGEREQ');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authInfoReq(name, instructions, prompts) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n let promptsLen = 0;\n const nameLen = name ? Buffer.byteLength(name) : 0;\n const instrLen = instructions ? Buffer.byteLength(instructions) : 0;\n\n for (let i = 0; i < prompts.length; ++i)\n promptsLen += 4 + Buffer.byteLength(prompts[i].prompt) + 1;\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + nameLen + 4 + instrLen + 4 + 4 + promptsLen\n );\n\n packet[p] = MESSAGE.USERAUTH_INFO_REQUEST;\n\n writeUInt32BE(packet, nameLen, ++p);\n p += 4;\n if (name) {\n packet.utf8Write(name, p, nameLen);\n p += nameLen;\n }\n\n writeUInt32BE(packet, instrLen, p);\n p += 4;\n if (instructions) {\n packet.utf8Write(instructions, p, instrLen);\n p += instrLen;\n }\n\n writeUInt32BE(packet, 0, p);\n\n writeUInt32BE(packet, prompts.length, p += 4);\n p += 4;\n for (let i = 0; i < prompts.length; ++i) {\n const prompt = prompts[i];\n const promptLen = Buffer.byteLength(prompt.prompt);\n\n writeUInt32BE(packet, promptLen, p);\n p += 4;\n if (promptLen) {\n packet.utf8Write(prompt.prompt, p, promptLen);\n p += promptLen;\n }\n packet[p++] = (prompt.echo ? 1 : 0);\n }\n\n this._debug && this._debug('Outbound: Sending USERAUTH_INFO_REQUEST');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n}\n\n// SSH-protoversion-softwareversion (SP comments) CR LF\nconst RE_IDENT = /^SSH-(2\\.0|1\\.99)-([^ ]+)(?: (.*))?$/;\n\n// TODO: optimize this by starting n bytes from the end of this._buffer instead\n// of the beginning\nfunction parseHeader(chunk, p, len) {\n let data;\n let chunkOffset;\n if (this._buffer) {\n data = Buffer.allocUnsafe(this._buffer.length + (len - p));\n data.set(this._buffer, 0);\n if (p === 0) {\n data.set(chunk, this._buffer.length);\n } else {\n data.set(new Uint8Array(chunk.buffer,\n chunk.byteOffset + p,\n (len - p)),\n this._buffer.length);\n }\n chunkOffset = this._buffer.length;\n p = 0;\n } else {\n data = chunk;\n chunkOffset = 0;\n }\n const op = p;\n let start = p;\n let end = p;\n let needNL = false;\n let lineLen = 0;\n let lines = 0;\n for (; p < data.length; ++p) {\n const ch = data[p];\n\n if (ch === 13 /* '\\r' */) {\n needNL = true;\n continue;\n }\n\n if (ch === 10 /* '\\n' */) {\n if (end > start\n && end - start > 4\n && data[start] === 83 /* 'S' */\n && data[start + 1] === 83 /* 'S' */\n && data[start + 2] === 72 /* 'H' */\n && data[start + 3] === 45 /* '-' */) {\n\n const full = data.latin1Slice(op, end + 1);\n const identRaw = (start === op ? full : full.slice(start - op));\n const m = RE_IDENT.exec(identRaw);\n if (!m)\n throw new Error('Invalid identification string');\n\n const header = {\n greeting: (start === op ? '' : full.slice(0, start - op)),\n identRaw,\n versions: {\n protocol: m[1],\n software: m[2],\n },\n comments: m[3]\n };\n\n // Needed during handshake\n this._remoteIdentRaw = Buffer.from(identRaw);\n\n this._debug && this._debug(`Remote ident: ${inspect(identRaw)}`);\n this._compatFlags = getCompatFlags(header);\n\n this._buffer = undefined;\n this._decipher =\n new NullDecipher(0, onKEXPayload.bind(this, { firstPacket: true }));\n this._parse = parsePacket;\n\n this._onHeader(header);\n if (!this._destruct) {\n // We disconnected inside _onHeader\n return len;\n }\n\n kexinit(this);\n\n return p + 1 - chunkOffset;\n }\n\n // Only allow pre-ident greetings when we're a client\n if (this._server)\n throw new Error('Greetings from clients not permitted');\n\n if (++lines > MAX_LINES)\n throw new Error('Max greeting lines exceeded');\n\n needNL = false;\n start = p + 1;\n lineLen = 0;\n } else if (needNL) {\n throw new Error('Invalid header: expected newline');\n } else if (++lineLen >= MAX_LINE_LEN) {\n throw new Error('Header line too long');\n }\n\n end = p;\n }\n if (!this._buffer)\n this._buffer = bufferSlice(data, op);\n\n return p - chunkOffset;\n}\n\nfunction parsePacket(chunk, p, len) {\n return this._decipher.decrypt(chunk, p, len);\n}\n\nfunction onPayload(payload) {\n // XXX: move this to the Decipher implementations?\n\n this._onPacket();\n\n if (payload.length === 0) {\n this._debug && this._debug('Inbound: Skipping empty packet payload');\n return;\n }\n\n payload = this._packetRW.read.read(payload);\n\n const type = payload[0];\n if (type === MESSAGE.USERAUTH_SUCCESS\n && !this._server\n && !this._authenticated) {\n this._authenticated = true;\n if (this._kex.negotiated.cs.compress === 'zlib@openssh.com')\n this._packetRW.write = new ZlibPacketWriter(this);\n if (this._kex.negotiated.sc.compress === 'zlib@openssh.com')\n this._packetRW.read = new ZlibPacketReader();\n }\n const handler = MESSAGE_HANDLERS[type];\n if (handler === undefined) {\n this._debug && this._debug(`Inbound: Unsupported message type: ${type}`);\n return;\n }\n\n return handler(this, payload);\n}\n\nfunction getCompatFlags(header) {\n const software = header.versions.software;\n\n let flags = 0;\n\n for (const rule of COMPAT_CHECKS) {\n if (typeof rule[0] === 'string') {\n if (software === rule[0])\n flags |= rule[1];\n } else if (rule[0].test(software)) {\n flags |= rule[1];\n }\n }\n\n return flags;\n}\n\nfunction modesToBytes(modes) {\n const keys = Object.keys(modes);\n const bytes = Buffer.allocUnsafe((5 * keys.length) + 1);\n let b = 0;\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n if (key === 'TTY_OP_END')\n continue;\n\n const opcode = TERMINAL_MODE[key];\n if (opcode === undefined)\n continue;\n\n const val = modes[key];\n if (typeof val === 'number' && isFinite(val)) {\n bytes[b++] = opcode;\n bytes[b++] = val >>> 24;\n bytes[b++] = val >>> 16;\n bytes[b++] = val >>> 8;\n bytes[b++] = val;\n }\n }\n\n bytes[b++] = TERMINAL_MODE.TTY_OP_END;\n\n if (b < bytes.length)\n return bufferSlice(bytes, 0, b);\n\n return bytes;\n}\n\nmodule.exports = Protocol;\n","'use strict';\n\nconst EventEmitter = require('events');\nconst fs = require('fs');\nconst { constants } = fs;\nconst {\n Readable: ReadableStream,\n Writable: WritableStream\n} = require('stream');\nconst { inherits, isDate } = require('util');\n\nconst FastBuffer = Buffer[Symbol.species];\n\nconst {\n bufferCopy,\n bufferSlice,\n makeBufferParser,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst ATTR = {\n SIZE: 0x00000001,\n UIDGID: 0x00000002,\n PERMISSIONS: 0x00000004,\n ACMODTIME: 0x00000008,\n EXTENDED: 0x80000000,\n};\n\n// Large enough to store all possible attributes\nconst ATTRS_BUF = Buffer.alloc(28);\n\nconst STATUS_CODE = {\n OK: 0,\n EOF: 1,\n NO_SUCH_FILE: 2,\n PERMISSION_DENIED: 3,\n FAILURE: 4,\n BAD_MESSAGE: 5,\n NO_CONNECTION: 6,\n CONNECTION_LOST: 7,\n OP_UNSUPPORTED: 8\n};\n\nconst VALID_STATUS_CODES = new Map(\n Object.values(STATUS_CODE).map((n) => [n, 1])\n);\n\nconst STATUS_CODE_STR = {\n [STATUS_CODE.OK]: 'No error',\n [STATUS_CODE.EOF]: 'End of file',\n [STATUS_CODE.NO_SUCH_FILE]: 'No such file or directory',\n [STATUS_CODE.PERMISSION_DENIED]: 'Permission denied',\n [STATUS_CODE.FAILURE]: 'Failure',\n [STATUS_CODE.BAD_MESSAGE]: 'Bad message',\n [STATUS_CODE.NO_CONNECTION]: 'No connection',\n [STATUS_CODE.CONNECTION_LOST]: 'Connection lost',\n [STATUS_CODE.OP_UNSUPPORTED]: 'Operation unsupported',\n};\n\nconst REQUEST = {\n INIT: 1,\n OPEN: 3,\n CLOSE: 4,\n READ: 5,\n WRITE: 6,\n LSTAT: 7,\n FSTAT: 8,\n SETSTAT: 9,\n FSETSTAT: 10,\n OPENDIR: 11,\n READDIR: 12,\n REMOVE: 13,\n MKDIR: 14,\n RMDIR: 15,\n REALPATH: 16,\n STAT: 17,\n RENAME: 18,\n READLINK: 19,\n SYMLINK: 20,\n EXTENDED: 200\n};\n\nconst RESPONSE = {\n VERSION: 2,\n STATUS: 101,\n HANDLE: 102,\n DATA: 103,\n NAME: 104,\n ATTRS: 105,\n EXTENDED: 201\n};\n\nconst OPEN_MODE = {\n READ: 0x00000001,\n WRITE: 0x00000002,\n APPEND: 0x00000004,\n CREAT: 0x00000008,\n TRUNC: 0x00000010,\n EXCL: 0x00000020\n};\n\nconst PKT_RW_OVERHEAD = 2 * 1024;\nconst MAX_REQID = 2 ** 32 - 1;\nconst CLIENT_VERSION_BUFFER = Buffer.from([\n 0, 0, 0, 5 /* length */,\n REQUEST.INIT,\n 0, 0, 0, 3 /* version */\n]);\nconst SERVER_VERSION_BUFFER = Buffer.from([\n 0, 0, 0, 5 /* length */,\n RESPONSE.VERSION,\n 0, 0, 0, 3 /* version */\n]);\n\nconst RE_OPENSSH = /^SSH-2.0-(?:OpenSSH|dropbear)/;\nconst OPENSSH_MAX_PKT_LEN = 256 * 1024;\n\nconst bufferParser = makeBufferParser();\n\nconst fakeStderr = {\n readable: false,\n writable: false,\n push: (data) => {},\n once: () => {},\n on: () => {},\n emit: () => {},\n end: () => {},\n};\n\nfunction noop() {}\n\n// Emulates enough of `Channel` to be able to be used as a drop-in replacement\n// in order to process incoming data with as little overhead as possible\nclass SFTP extends EventEmitter {\n constructor(client, chanInfo, cfg) {\n super();\n\n if (typeof cfg !== 'object' || !cfg)\n cfg = {};\n\n const remoteIdentRaw = client._protocol._remoteIdentRaw;\n\n this.server = !!cfg.server;\n this._debug = (typeof cfg.debug === 'function' ? cfg.debug : undefined);\n this._isOpenSSH = (remoteIdentRaw && RE_OPENSSH.test(remoteIdentRaw));\n\n this._version = -1;\n this._extensions = {};\n this._biOpt = cfg.biOpt;\n this._pktLenBytes = 0;\n this._pktLen = 0;\n this._pktPos = 0;\n this._pktType = 0;\n this._pktData = undefined;\n this._writeReqid = -1;\n this._requests = {};\n this._maxInPktLen = OPENSSH_MAX_PKT_LEN;\n this._maxOutPktLen = 34000;\n this._maxReadLen =\n (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;\n this._maxWriteLen =\n (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;\n\n this.maxOpenHandles = undefined;\n\n // Channel compatibility\n this._client = client;\n this._protocol = client._protocol;\n this._callbacks = [];\n this._hasX11 = false;\n this._exit = {\n code: undefined,\n signal: undefined,\n dump: undefined,\n desc: undefined,\n };\n this._waitWindow = false; // SSH-level backpressure\n this._chunkcb = undefined;\n this._buffer = [];\n this.type = chanInfo.type;\n this.subtype = undefined;\n this.incoming = chanInfo.incoming;\n this.outgoing = chanInfo.outgoing;\n this.stderr = fakeStderr;\n this.readable = true;\n }\n\n // This handles incoming data to parse\n push(data) {\n if (data === null) {\n cleanupRequests(this);\n if (!this.readable)\n return;\n // No more incoming data from the remote side\n this.readable = false;\n this.emit('end');\n return;\n }\n /*\n uint32 length\n byte type\n byte[length - 1] data payload\n */\n let p = 0;\n\n while (p < data.length) {\n if (this._pktLenBytes < 4) {\n let nb = Math.min(4 - this._pktLenBytes, data.length - p);\n this._pktLenBytes += nb;\n\n while (nb--)\n this._pktLen = (this._pktLen << 8) + data[p++];\n\n if (this._pktLenBytes < 4)\n return;\n if (this._pktLen === 0)\n return doFatalSFTPError(this, 'Invalid packet length');\n if (this._pktLen > this._maxInPktLen) {\n const max = this._maxInPktLen;\n return doFatalSFTPError(\n this,\n `Packet length ${this._pktLen} exceeds max length of ${max}`\n );\n }\n if (p >= data.length)\n return;\n }\n if (this._pktPos < this._pktLen) {\n const nb = Math.min(this._pktLen - this._pktPos, data.length - p);\n if (p !== 0 || nb !== data.length) {\n if (nb === this._pktLen) {\n this._pkt = new FastBuffer(data.buffer, data.byteOffset + p, nb);\n } else {\n if (!this._pkt)\n this._pkt = Buffer.allocUnsafe(this._pktLen);\n this._pkt.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._pktPos\n );\n }\n } else if (nb === this._pktLen) {\n this._pkt = data;\n } else {\n if (!this._pkt)\n this._pkt = Buffer.allocUnsafe(this._pktLen);\n this._pkt.set(data, this._pktPos);\n }\n p += nb;\n this._pktPos += nb;\n if (this._pktPos < this._pktLen)\n return;\n }\n\n const type = this._pkt[0];\n const payload = this._pkt;\n\n // Prepare for next packet\n this._pktLen = 0;\n this._pktLenBytes = 0;\n this._pkt = undefined;\n this._pktPos = 0;\n\n const handler = (this.server\n ? SERVER_HANDLERS[type]\n : CLIENT_HANDLERS[type]);\n if (!handler)\n return doFatalSFTPError(this, `Unknown packet type ${type}`);\n\n if (this._version === -1) {\n if (this.server) {\n if (type !== REQUEST.INIT)\n return doFatalSFTPError(this, `Expected INIT packet, got ${type}`);\n } else if (type !== RESPONSE.VERSION) {\n return doFatalSFTPError(this, `Expected VERSION packet, got ${type}`);\n }\n }\n\n if (handler(this, payload) === false)\n return;\n }\n }\n\n end() {\n this.destroy();\n }\n destroy() {\n if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {\n this.outgoing.state = 'closing';\n this._protocol.channelClose(this.outgoing.id);\n }\n }\n _init() {\n this._init = noop;\n if (!this.server)\n sendOrBuffer(this, CLIENT_VERSION_BUFFER);\n }\n\n // ===========================================================================\n // Client-specific ===========================================================\n // ===========================================================================\n createReadStream(path, options) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n return new ReadStream(this, path, options);\n }\n createWriteStream(path, options) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n return new WriteStream(this, path, options);\n }\n open(path, flags_, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (typeof attrs === 'function') {\n cb = attrs;\n attrs = undefined;\n }\n\n const flags = (typeof flags_ === 'number' ? flags_ : stringToFlags(flags_));\n if (flags === null)\n throw new Error(`Unknown flags string: ${flags_}`);\n\n let attrsFlags = 0;\n let attrsLen = 0;\n if (typeof attrs === 'string' || typeof attrs === 'number')\n attrs = { mode: attrs };\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n attrsFlags = attrs.flags;\n attrsLen = attrs.nb;\n }\n\n /*\n uint32 id\n string filename\n uint32 pflags\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.OPEN;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n writeUInt32BE(buf, attrsFlags, p += 4);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPEN`\n );\n }\n close(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.CLOSE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} CLOSE`\n );\n }\n read(handle, buf, off, len, position, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n if (!Buffer.isBuffer(buf))\n throw new Error('buffer is not a Buffer');\n if (off >= buf.length)\n throw new Error('offset is out of bounds');\n if (off + len > buf.length)\n throw new Error('length extends beyond buffer');\n if (position === null)\n throw new Error('null position currently unsupported');\n\n read_(this, handle, buf, off, len, position, cb);\n }\n readData(handle, buf, off, len, position, cb) {\n // Backwards compatibility\n this.read(handle, buf, off, len, position, cb);\n }\n write(handle, buf, off, len, position, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n if (!Buffer.isBuffer(buf))\n throw new Error('buffer is not a Buffer');\n if (off > buf.length)\n throw new Error('offset is out of bounds');\n if (off + len > buf.length)\n throw new Error('length extends beyond buffer');\n if (position === null)\n throw new Error('null position currently unsupported');\n\n if (!len) {\n cb && process.nextTick(cb, undefined, 0);\n return;\n }\n\n const maxDataLen = this._maxWriteLen;\n const overflow = Math.max(len - maxDataLen, 0);\n const origPosition = position;\n\n if (overflow)\n len = maxDataLen;\n\n /*\n uint32 id\n string handle\n uint64 offset\n string data\n */\n const handleLen = handle.length;\n let p = 9;\n const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4 + len);\n\n writeUInt32BE(out, out.length - 4, 0);\n out[4] = REQUEST.WRITE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(out, reqid, 5);\n\n writeUInt32BE(out, handleLen, p);\n out.set(handle, p += 4);\n p += handleLen;\n for (let i = 7; i >= 0; --i) {\n out[p + i] = position & 0xFF;\n position /= 256;\n }\n writeUInt32BE(out, len, p += 8);\n bufferCopy(buf, out, off, off + len, p += 4);\n\n this._requests[reqid] = {\n cb: (err) => {\n if (err) {\n if (typeof cb === 'function')\n cb(err);\n } else if (overflow) {\n this.write(handle,\n buf,\n off + len,\n overflow,\n origPosition + len,\n cb);\n } else if (typeof cb === 'function') {\n cb(undefined, off + len);\n }\n }\n };\n\n const isSent = sendOrBuffer(this, out);\n if (this._debug) {\n const how = (isSent ? 'Sent' : 'Buffered');\n this._debug(`SFTP: Outbound: ${how} WRITE (id:${reqid})`);\n }\n }\n writeData(handle, buf, off, len, position, cb) {\n // Backwards compatibility\n this.write(handle, buf, off, len, position, cb);\n }\n fastGet(remotePath, localPath, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n fastXfer(this, fs, remotePath, localPath, opts, cb);\n }\n fastPut(localPath, remotePath, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n fastXfer(fs, this, localPath, remotePath, opts, cb);\n }\n readFile(path, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, flag: 'r' };\n else if (!options)\n options = { encoding: null, flag: 'r' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n const encoding = options.encoding;\n if (encoding && !Buffer.isEncoding(encoding))\n throw new Error(`Unknown encoding: ${encoding}`);\n\n // First stat the file, so we know the size.\n let size;\n let buffer; // Single buffer with file data\n let buffers; // List for when size is unknown\n let pos = 0;\n let handle;\n\n // SFTPv3 does not support using -1 for read position, so we have to track\n // read position manually\n let bytesRead = 0;\n\n const flag = options.flag || 'r';\n\n const read = () => {\n if (size === 0) {\n buffer = Buffer.allocUnsafe(8192);\n this.read(handle, buffer, 0, 8192, bytesRead, afterRead);\n } else {\n this.read(handle, buffer, pos, size - pos, bytesRead, afterRead);\n }\n };\n\n const afterRead = (er, nbytes) => {\n let eof;\n if (er) {\n eof = (er.code === STATUS_CODE.EOF);\n if (!eof) {\n return this.close(handle, () => {\n return callback && callback(er);\n });\n }\n } else {\n eof = false;\n }\n\n if (eof || (size === 0 && nbytes === 0))\n return close();\n\n bytesRead += nbytes;\n pos += nbytes;\n if (size !== 0) {\n if (pos === size)\n close();\n else\n read();\n } else {\n // Unknown size, just read until we don't get bytes.\n buffers.push(bufferSlice(buffer, 0, nbytes));\n read();\n }\n };\n afterRead._wantEOFError = true;\n\n const close = () => {\n this.close(handle, (er) => {\n if (size === 0) {\n // Collect the data into the buffers list.\n buffer = Buffer.concat(buffers, pos);\n } else if (pos < size) {\n buffer = bufferSlice(buffer, 0, pos);\n }\n\n if (encoding)\n buffer = buffer.toString(encoding);\n return callback && callback(er, buffer);\n });\n };\n\n this.open(path, flag, 0o666, (er, handle_) => {\n if (er)\n return callback && callback(er);\n handle = handle_;\n\n const tryStat = (er, st) => {\n if (er) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.stat(path, (er_, st_) => {\n if (er_) {\n return this.close(handle, () => {\n callback && callback(er);\n });\n }\n tryStat(null, st_);\n });\n return;\n }\n\n size = st.size || 0;\n if (size === 0) {\n // The kernel lies about many files.\n // Go ahead and try to read some bytes.\n buffers = [];\n return read();\n }\n\n buffer = Buffer.allocUnsafe(size);\n read();\n };\n this.fstat(handle, tryStat);\n });\n }\n writeFile(path, data, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, mode: 0o666, flag: 'w' };\n else if (!options)\n options = { encoding: 'utf8', mode: 0o666, flag: 'w' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n if (options.encoding && !Buffer.isEncoding(options.encoding))\n throw new Error(`Unknown encoding: ${options.encoding}`);\n\n const flag = options.flag || 'w';\n this.open(path, flag, options.mode, (openErr, handle) => {\n if (openErr) {\n callback && callback(openErr);\n } else {\n const buffer = (Buffer.isBuffer(data)\n ? data\n : Buffer.from('' + data, options.encoding || 'utf8'));\n const position = (/a/.test(flag) ? null : 0);\n\n // SFTPv3 does not support the notion of 'current position'\n // (null position), so we just attempt to append to the end of the file\n // instead\n if (position === null) {\n const tryStat = (er, st) => {\n if (er) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.stat(path, (er_, st_) => {\n if (er_) {\n return this.close(handle, () => {\n callback && callback(er);\n });\n }\n tryStat(null, st_);\n });\n return;\n }\n writeAll(this, handle, buffer, 0, buffer.length, st.size, callback);\n };\n this.fstat(handle, tryStat);\n return;\n }\n writeAll(this, handle, buffer, 0, buffer.length, position, callback);\n }\n });\n }\n appendFile(path, data, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, mode: 0o666, flag: 'a' };\n else if (!options)\n options = { encoding: 'utf8', mode: 0o666, flag: 'a' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n if (!options.flag)\n options = Object.assign({ flag: 'a' }, options);\n this.writeFile(path, data, options, callback);\n }\n exists(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n this.stat(path, (err) => {\n cb && cb(err ? false : true);\n });\n }\n unlink(filename, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string filename\n */\n const fnameLen = Buffer.byteLength(filename);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + fnameLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.REMOVE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, fnameLen, p);\n buf.utf8Write(filename, p += 4, fnameLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REMOVE`\n );\n }\n rename(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.RENAME;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, oldLen, p);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RENAME`\n );\n }\n mkdir(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'function') {\n cb = attrs;\n attrs = undefined;\n }\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n }\n\n /*\n uint32 id\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.MKDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} MKDIR`\n );\n }\n rmdir(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.RMDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RMDIR`\n );\n }\n readdir(where, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n if (typeof opts !== 'object' || opts === null)\n opts = {};\n\n const doFilter = (opts && opts.full ? false : true);\n\n if (!Buffer.isBuffer(where) && typeof where !== 'string')\n throw new Error('missing directory handle or path');\n\n if (typeof where === 'string') {\n const entries = [];\n let e = 0;\n\n const reread = (err, handle) => {\n if (err)\n return cb(err);\n\n this.readdir(handle, opts, (err, list) => {\n const eof = (err && err.code === STATUS_CODE.EOF);\n\n if (err && !eof)\n return this.close(handle, () => cb(err));\n\n if (eof) {\n return this.close(handle, (err) => {\n if (err)\n return cb(err);\n cb(undefined, entries);\n });\n }\n\n for (let i = 0; i < list.length; ++i, ++e)\n entries[e] = list[i];\n\n reread(undefined, handle);\n });\n };\n return this.opendir(where, reread);\n }\n\n /*\n uint32 id\n string handle\n */\n const handleLen = where.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.READDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(where, p += 4);\n\n this._requests[reqid] = {\n cb: (doFilter\n ? (err, list) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n\n for (let i = list.length - 1; i >= 0; --i) {\n if (list[i].filename === '.' || list[i].filename === '..')\n list.splice(i, 1);\n }\n\n cb(undefined, list);\n }\n : cb)\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READDIR`\n );\n }\n fstat(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.FSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSTAT`\n );\n }\n stat(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.STAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STAT`\n );\n }\n lstat(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.LSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} LSTAT`\n );\n }\n opendir(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.OPENDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPENDIR`\n );\n }\n setstat(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.SETSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SETSTAT`\n );\n }\n fsetstat(handle, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string handle\n ATTRS attrs\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.FSETSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n writeUInt32BE(buf, flags, p += handleLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSETSTAT`\n );\n }\n futimes(handle, atime, mtime, cb) {\n return this.fsetstat(handle, {\n atime: toUnixTimestamp(atime),\n mtime: toUnixTimestamp(mtime)\n }, cb);\n }\n utimes(path, atime, mtime, cb) {\n return this.setstat(path, {\n atime: toUnixTimestamp(atime),\n mtime: toUnixTimestamp(mtime)\n }, cb);\n }\n fchown(handle, uid, gid, cb) {\n return this.fsetstat(handle, {\n uid: uid,\n gid: gid\n }, cb);\n }\n chown(path, uid, gid, cb) {\n return this.setstat(path, {\n uid: uid,\n gid: gid\n }, cb);\n }\n fchmod(handle, mode, cb) {\n return this.fsetstat(handle, {\n mode: mode\n }, cb);\n }\n chmod(path, mode, cb) {\n return this.setstat(path, {\n mode: mode\n }, cb);\n }\n readlink(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.READLINK;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = {\n cb: (err, names) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n if (!names || !names.length)\n return cb(new Error('Response missing link info'));\n cb(undefined, names[0].filename);\n }\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READLINK`\n );\n }\n symlink(targetPath, linkPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string linkpath\n string targetpath\n */\n const linkLen = Buffer.byteLength(linkPath);\n const targetLen = Buffer.byteLength(targetPath);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + linkLen + 4 + targetLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.SYMLINK;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n if (this._isOpenSSH) {\n // OpenSSH has linkpath and targetpath positions switched\n writeUInt32BE(buf, targetLen, p);\n buf.utf8Write(targetPath, p += 4, targetLen);\n writeUInt32BE(buf, linkLen, p += targetLen);\n buf.utf8Write(linkPath, p += 4, linkLen);\n } else {\n writeUInt32BE(buf, linkLen, p);\n buf.utf8Write(linkPath, p += 4, linkLen);\n writeUInt32BE(buf, targetLen, p += linkLen);\n buf.utf8Write(targetPath, p += 4, targetLen);\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SYMLINK`\n );\n }\n realpath(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.REALPATH;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = {\n cb: (err, names) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n if (!names || !names.length)\n return cb(new Error('Response missing path info'));\n cb(undefined, names[0].filename);\n }\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REALPATH`\n );\n }\n // extended requests\n ext_openssh_rename(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['posix-rename@openssh.com'];\n if (!ext || ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"posix-rename@openssh.com\"\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 24 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 24, p);\n buf.utf8Write('posix-rename@openssh.com', p += 4, 24);\n writeUInt32BE(buf, oldLen, p += 24);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} posix-rename@openssh.com`);\n }\n }\n ext_openssh_statvfs(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['statvfs@openssh.com'];\n if (!ext || ext !== '2')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"statvfs@openssh.com\"\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 19 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 19, p);\n buf.utf8Write('statvfs@openssh.com', p += 4, 19);\n writeUInt32BE(buf, pathLen, p += 19);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { extended: 'statvfs@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} statvfs@openssh.com`);\n }\n }\n ext_openssh_fstatvfs(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['fstatvfs@openssh.com'];\n if (!ext || ext !== '2')\n throw new Error('Server does not support this extended request');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string \"fstatvfs@openssh.com\"\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('fstatvfs@openssh.com', p += 4, 20);\n writeUInt32BE(buf, handleLen, p += 20);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { extended: 'fstatvfs@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} fstatvfs@openssh.com`);\n }\n }\n ext_openssh_hardlink(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['hardlink@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"hardlink@openssh.com\"\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('hardlink@openssh.com', p += 4, 20);\n writeUInt32BE(buf, oldLen, p += 20);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} hardlink@openssh.com`);\n }\n }\n ext_openssh_fsync(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['fsync@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string \"fsync@openssh.com\"\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 17 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 17, p);\n buf.utf8Write('fsync@openssh.com', p += 4, 17);\n writeUInt32BE(buf, handleLen, p += 17);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} fsync@openssh.com`\n );\n }\n ext_openssh_lsetstat(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['lsetstat@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string \"lsetstat@openssh.com\"\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('lsetstat@openssh.com', p += 4, 20);\n\n writeUInt32BE(buf, pathLen, p += 20);\n buf.utf8Write(path, p += 4, pathLen);\n\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const status = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${status} lsetstat@openssh.com`);\n }\n }\n ext_openssh_expandPath(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['expand-path@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"expand-path@openssh.com\"\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 23 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 23, p);\n buf.utf8Write('expand-path@openssh.com', p += 4, 23);\n\n writeUInt32BE(buf, pathLen, p += 20);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const status = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${status} expand-path@openssh.com`);\n }\n }\n // ===========================================================================\n // Server-specific ===========================================================\n // ===========================================================================\n handle(reqid, handle) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n const handleLen = handle.length;\n\n if (handleLen > 256)\n throw new Error('handle too large (> 256 bytes)');\n\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.HANDLE;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n if (handleLen)\n buf.set(handle, p += 4);\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} HANDLE`\n );\n }\n status(reqid, code, message) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!VALID_STATUS_CODES.has(code))\n throw new Error(`Bad status code: ${code}`);\n\n message || (message = '');\n\n const msgLen = Buffer.byteLength(message);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 4 + msgLen + 4);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.STATUS;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, code, p);\n\n writeUInt32BE(buf, msgLen, p += 4);\n p += 4;\n if (msgLen) {\n buf.utf8Write(message, p, msgLen);\n p += msgLen;\n }\n\n writeUInt32BE(buf, 0, p); // Empty language tag\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STATUS`\n );\n }\n data(reqid, data, encoding) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n const isBuffer = Buffer.isBuffer(data);\n\n if (!isBuffer && typeof data !== 'string')\n throw new Error('data is not a Buffer or string');\n\n let isUTF8;\n if (!isBuffer && !encoding) {\n encoding = undefined;\n isUTF8 = true;\n }\n\n const dataLen = (\n isBuffer\n ? data.length\n : Buffer.byteLength(data, encoding)\n );\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + dataLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.DATA;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, dataLen, p);\n if (dataLen) {\n if (isBuffer)\n buf.set(data, p += 4);\n else if (isUTF8)\n buf.utf8Write(data, p += 4, dataLen);\n else\n buf.write(data, p += 4, dataLen, encoding);\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} DATA`\n );\n }\n name(reqid, names) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!Array.isArray(names)) {\n if (typeof names !== 'object' || names === null)\n throw new Error('names is not an object or array');\n names = [ names ];\n }\n\n const count = names.length;\n let namesLen = 0;\n let nameAttrs;\n const attrs = [];\n\n for (let i = 0; i < count; ++i) {\n const name = names[i];\n const filename = (\n !name || !name.filename || typeof name.filename !== 'string'\n ? ''\n : name.filename\n );\n namesLen += 4 + Buffer.byteLength(filename);\n const longname = (\n !name || !name.longname || typeof name.longname !== 'string'\n ? ''\n : name.longname\n );\n namesLen += 4 + Buffer.byteLength(longname);\n\n if (typeof name.attrs === 'object' && name.attrs !== null) {\n nameAttrs = attrsToBytes(name.attrs);\n namesLen += 4 + nameAttrs.nb;\n\n if (nameAttrs.nb) {\n let bytes;\n\n if (nameAttrs.nb === ATTRS_BUF.length) {\n bytes = new Uint8Array(ATTRS_BUF);\n } else {\n bytes = new Uint8Array(nameAttrs.nb);\n bufferCopy(ATTRS_BUF, bytes, 0, nameAttrs.nb, 0);\n }\n\n nameAttrs.bytes = bytes;\n }\n\n attrs.push(nameAttrs);\n } else {\n namesLen += 4;\n attrs.push(null);\n }\n }\n\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + namesLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.NAME;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, count, p);\n\n p += 4;\n\n for (let i = 0; i < count; ++i) {\n const name = names[i];\n\n {\n const filename = (\n !name || !name.filename || typeof name.filename !== 'string'\n ? ''\n : name.filename\n );\n const len = Buffer.byteLength(filename);\n writeUInt32BE(buf, len, p);\n p += 4;\n if (len) {\n buf.utf8Write(filename, p, len);\n p += len;\n }\n }\n\n {\n const longname = (\n !name || !name.longname || typeof name.longname !== 'string'\n ? ''\n : name.longname\n );\n const len = Buffer.byteLength(longname);\n writeUInt32BE(buf, len, p);\n p += 4;\n if (len) {\n buf.utf8Write(longname, p, len);\n p += len;\n }\n }\n\n const attr = attrs[i];\n if (attr) {\n writeUInt32BE(buf, attr.flags, p);\n p += 4;\n if (attr.flags && attr.bytes) {\n buf.set(attr.bytes, p);\n p += attr.nb;\n }\n } else {\n writeUInt32BE(buf, 0, p);\n p += 4;\n }\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} NAME`\n );\n }\n attrs(reqid, attrs) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (typeof attrs !== 'object' || attrs === null)\n throw new Error('attrs is not an object');\n\n attrs = attrsToBytes(attrs);\n const flags = attrs.flags;\n const attrsLen = attrs.nb;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.ATTRS;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, flags, p);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} ATTRS`\n );\n }\n}\n\nfunction tryCreateBuffer(size) {\n try {\n return Buffer.allocUnsafe(size);\n } catch (ex) {\n return ex;\n }\n}\n\nfunction read_(self, handle, buf, off, len, position, cb, req_) {\n const maxDataLen = self._maxReadLen;\n const overflow = Math.max(len - maxDataLen, 0);\n\n if (overflow)\n len = maxDataLen;\n\n /*\n uint32 id\n string handle\n uint64 offset\n uint32 len\n */\n const handleLen = handle.length;\n let p = 9;\n let pos = position;\n const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4);\n\n writeUInt32BE(out, out.length - 4, 0);\n out[4] = REQUEST.READ;\n const reqid = self._writeReqid = (self._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(out, reqid, 5);\n\n writeUInt32BE(out, handleLen, p);\n out.set(handle, p += 4);\n p += handleLen;\n for (let i = 7; i >= 0; --i) {\n out[p + i] = pos & 0xFF;\n pos /= 256;\n }\n writeUInt32BE(out, len, p += 8);\n\n if (typeof cb !== 'function')\n cb = noop;\n\n const req = (req_ || {\n nb: 0,\n position,\n off,\n origOff: off,\n len: undefined,\n overflow: undefined,\n cb: (err, data, nb) => {\n const len = req.len;\n const overflow = req.overflow;\n\n if (err) {\n if (cb._wantEOFError || err.code !== STATUS_CODE.EOF)\n return cb(err);\n } else if (nb > len) {\n return cb(new Error('Received more data than requested'));\n } else if (nb === len && overflow) {\n req.nb += nb;\n req.position += nb;\n req.off += nb;\n read_(self, handle, buf, req.off, overflow, req.position, cb, req);\n return;\n }\n\n if (req.origOff === 0 && buf.length === req.nb)\n data = buf;\n else\n data = bufferSlice(buf, req.origOff, req.origOff + req.nb);\n cb(undefined, req.nb + (nb || 0), data, req.position);\n },\n buffer: undefined,\n });\n\n req.len = len;\n req.overflow = overflow;\n\n // TODO: avoid creating multiple buffer slices when we need to re-call read_()\n // because of overflow\n req.buffer = bufferSlice(buf, off, off + len);\n\n self._requests[reqid] = req;\n\n const isBuffered = sendOrBuffer(self, out);\n self._debug && self._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READ`\n );\n}\n\nfunction fastXfer(src, dst, srcPath, dstPath, opts, cb) {\n let concurrency = 64;\n let chunkSize = 32768;\n let onstep;\n let mode;\n let fileSize;\n\n if (typeof opts === 'function') {\n cb = opts;\n } else if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.concurrency === 'number'\n && opts.concurrency > 0\n && !isNaN(opts.concurrency)) {\n concurrency = opts.concurrency;\n }\n if (typeof opts.chunkSize === 'number'\n && opts.chunkSize > 0\n && !isNaN(opts.chunkSize)) {\n chunkSize = opts.chunkSize;\n }\n if (typeof opts.fileSize === 'number'\n && opts.fileSize > 0\n && !isNaN(opts.fileSize)) {\n fileSize = opts.fileSize;\n }\n if (typeof opts.step === 'function')\n onstep = opts.step;\n\n if (typeof opts.mode === 'string' || typeof opts.mode === 'number')\n mode = modeNum(opts.mode);\n }\n\n // Internal state variables\n let fsize;\n let pdst = 0;\n let total = 0;\n let hadError = false;\n let srcHandle;\n let dstHandle;\n let readbuf;\n let bufsize = chunkSize * concurrency;\n\n function onerror(err) {\n if (hadError)\n return;\n\n hadError = true;\n\n let left = 0;\n let cbfinal;\n\n if (srcHandle || dstHandle) {\n cbfinal = () => {\n if (--left === 0)\n cb(err);\n };\n if (srcHandle && (src === fs || src.outgoing.state === 'open'))\n ++left;\n if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))\n ++left;\n if (srcHandle && (src === fs || src.outgoing.state === 'open'))\n src.close(srcHandle, cbfinal);\n if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))\n dst.close(dstHandle, cbfinal);\n } else {\n cb(err);\n }\n }\n\n src.open(srcPath, 'r', (err, sourceHandle) => {\n if (err)\n return onerror(err);\n\n srcHandle = sourceHandle;\n\n if (fileSize === undefined)\n src.fstat(srcHandle, tryStat);\n else\n tryStat(null, { size: fileSize });\n\n function tryStat(err, attrs) {\n if (err) {\n if (src !== fs) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n src.stat(srcPath, (err_, attrs_) => {\n if (err_)\n return onerror(err);\n tryStat(null, attrs_);\n });\n return;\n }\n return onerror(err);\n }\n fsize = attrs.size;\n\n dst.open(dstPath, 'w', (err, destHandle) => {\n if (err)\n return onerror(err);\n\n dstHandle = destHandle;\n\n if (fsize <= 0)\n return onerror();\n\n // Use less memory where possible\n while (bufsize > fsize) {\n if (concurrency === 1) {\n bufsize = fsize;\n break;\n }\n bufsize -= chunkSize;\n --concurrency;\n }\n\n readbuf = tryCreateBuffer(bufsize);\n if (readbuf instanceof Error)\n return onerror(readbuf);\n\n if (mode !== undefined) {\n dst.fchmod(dstHandle, mode, function tryAgain(err) {\n if (err) {\n // Try chmod() for sftp servers that may not support fchmod()\n // for whatever reason\n dst.chmod(dstPath, mode, (err_) => tryAgain());\n return;\n }\n startReads();\n });\n } else {\n startReads();\n }\n\n function onread(err, nb, data, dstpos, datapos, origChunkLen) {\n if (err)\n return onerror(err);\n\n datapos = datapos || 0;\n\n dst.write(dstHandle, readbuf, datapos, nb, dstpos, writeCb);\n\n function writeCb(err) {\n if (err)\n return onerror(err);\n\n total += nb;\n onstep && onstep(total, nb, fsize);\n\n if (nb < origChunkLen)\n return singleRead(datapos, dstpos + nb, origChunkLen - nb);\n\n if (total === fsize) {\n dst.close(dstHandle, (err) => {\n dstHandle = undefined;\n if (err)\n return onerror(err);\n src.close(srcHandle, (err) => {\n srcHandle = undefined;\n if (err)\n return onerror(err);\n cb();\n });\n });\n return;\n }\n\n if (pdst >= fsize)\n return;\n\n const chunk =\n (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);\n singleRead(datapos, pdst, chunk);\n pdst += chunk;\n }\n }\n\n function makeCb(psrc, pdst, chunk) {\n return (err, nb, data) => {\n onread(err, nb, data, pdst, psrc, chunk);\n };\n }\n\n function singleRead(psrc, pdst, chunk) {\n src.read(srcHandle,\n readbuf,\n psrc,\n chunk,\n pdst,\n makeCb(psrc, pdst, chunk));\n }\n\n function startReads() {\n let reads = 0;\n let psrc = 0;\n while (pdst < fsize && reads < concurrency) {\n const chunk =\n (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);\n singleRead(psrc, pdst, chunk);\n psrc += chunk;\n pdst += chunk;\n ++reads;\n }\n }\n });\n }\n });\n}\n\nfunction writeAll(sftp, handle, buffer, offset, length, position, callback_) {\n const callback = (typeof callback_ === 'function' ? callback_ : undefined);\n\n sftp.write(handle,\n buffer,\n offset,\n length,\n position,\n (writeErr, written) => {\n if (writeErr) {\n return sftp.close(handle, () => {\n callback && callback(writeErr);\n });\n }\n if (written === length) {\n sftp.close(handle, callback);\n } else {\n offset += written;\n length -= written;\n position += written;\n writeAll(sftp, handle, buffer, offset, length, position, callback);\n }\n });\n}\n\nclass Stats {\n constructor(initial) {\n this.mode = (initial && initial.mode);\n this.uid = (initial && initial.uid);\n this.gid = (initial && initial.gid);\n this.size = (initial && initial.size);\n this.atime = (initial && initial.atime);\n this.mtime = (initial && initial.mtime);\n this.extended = (initial && initial.extended);\n }\n isDirectory() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFDIR);\n }\n isFile() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFREG);\n }\n isBlockDevice() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFBLK);\n }\n isCharacterDevice() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFCHR);\n }\n isSymbolicLink() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFLNK);\n }\n isFIFO() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFIFO);\n }\n isSocket() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFSOCK);\n }\n}\n\nfunction attrsToBytes(attrs) {\n let flags = 0;\n let nb = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n if (typeof attrs.size === 'number') {\n flags |= ATTR.SIZE;\n const val = attrs.size;\n // Big Endian\n ATTRS_BUF[nb++] = val / 72057594037927940; // 2**56\n ATTRS_BUF[nb++] = val / 281474976710656; // 2**48\n ATTRS_BUF[nb++] = val / 1099511627776; // 2**40\n ATTRS_BUF[nb++] = val / 4294967296; // 2**32\n ATTRS_BUF[nb++] = val / 16777216; // 2**24\n ATTRS_BUF[nb++] = val / 65536; // 2**16\n ATTRS_BUF[nb++] = val / 256; // 2**8\n ATTRS_BUF[nb++] = val;\n }\n if (typeof attrs.uid === 'number' && typeof attrs.gid === 'number') {\n flags |= ATTR.UIDGID;\n const uid = attrs.uid;\n const gid = attrs.gid;\n // Big Endian\n ATTRS_BUF[nb++] = uid >>> 24;\n ATTRS_BUF[nb++] = uid >>> 16;\n ATTRS_BUF[nb++] = uid >>> 8;\n ATTRS_BUF[nb++] = uid;\n ATTRS_BUF[nb++] = gid >>> 24;\n ATTRS_BUF[nb++] = gid >>> 16;\n ATTRS_BUF[nb++] = gid >>> 8;\n ATTRS_BUF[nb++] = gid;\n }\n if (typeof attrs.mode === 'number' || typeof attrs.mode === 'string') {\n const mode = modeNum(attrs.mode);\n flags |= ATTR.PERMISSIONS;\n // Big Endian\n ATTRS_BUF[nb++] = mode >>> 24;\n ATTRS_BUF[nb++] = mode >>> 16;\n ATTRS_BUF[nb++] = mode >>> 8;\n ATTRS_BUF[nb++] = mode;\n }\n if ((typeof attrs.atime === 'number' || isDate(attrs.atime))\n && (typeof attrs.mtime === 'number' || isDate(attrs.mtime))) {\n const atime = toUnixTimestamp(attrs.atime);\n const mtime = toUnixTimestamp(attrs.mtime);\n\n flags |= ATTR.ACMODTIME;\n // Big Endian\n ATTRS_BUF[nb++] = atime >>> 24;\n ATTRS_BUF[nb++] = atime >>> 16;\n ATTRS_BUF[nb++] = atime >>> 8;\n ATTRS_BUF[nb++] = atime;\n ATTRS_BUF[nb++] = mtime >>> 24;\n ATTRS_BUF[nb++] = mtime >>> 16;\n ATTRS_BUF[nb++] = mtime >>> 8;\n ATTRS_BUF[nb++] = mtime;\n }\n // TODO: extended attributes\n }\n\n return { flags, nb };\n}\n\nfunction toUnixTimestamp(time) {\n // eslint-disable-next-line no-self-compare\n if (typeof time === 'number' && time === time) // Valid, non-NaN number\n return time;\n if (isDate(time))\n return parseInt(time.getTime() / 1000, 10);\n throw new Error(`Cannot parse time: ${time}`);\n}\n\nfunction modeNum(mode) {\n // eslint-disable-next-line no-self-compare\n if (typeof mode === 'number' && mode === mode) // Valid, non-NaN number\n return mode;\n if (typeof mode === 'string')\n return modeNum(parseInt(mode, 8));\n throw new Error(`Cannot parse mode: ${mode}`);\n}\n\nconst stringFlagMap = {\n 'r': OPEN_MODE.READ,\n 'r+': OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'w': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE,\n 'wx': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'xw': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'w+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'wx+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'xw+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'a': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE,\n 'ax': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'xa': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'a+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'ax+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'xa+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL\n};\n\nfunction stringToFlags(str) {\n const flags = stringFlagMap[str];\n return (flags !== undefined ? flags : null);\n}\n\nconst flagsToString = (() => {\n const stringFlagMapKeys = Object.keys(stringFlagMap);\n return (flags) => {\n for (let i = 0; i < stringFlagMapKeys.length; ++i) {\n const key = stringFlagMapKeys[i];\n if (stringFlagMap[key] === flags)\n return key;\n }\n return null;\n };\n})();\n\nfunction readAttrs(biOpt) {\n /*\n uint32 flags\n uint64 size present only if flag SSH_FILEXFER_ATTR_SIZE\n uint32 uid present only if flag SSH_FILEXFER_ATTR_UIDGID\n uint32 gid present only if flag SSH_FILEXFER_ATTR_UIDGID\n uint32 permissions present only if flag SSH_FILEXFER_ATTR_PERMISSIONS\n uint32 atime present only if flag SSH_FILEXFER_ACMODTIME\n uint32 mtime present only if flag SSH_FILEXFER_ACMODTIME\n uint32 extended_count present only if flag SSH_FILEXFER_ATTR_EXTENDED\n string extended_type\n string extended_data\n ... more extended data (extended_type - extended_data pairs),\n so that number of pairs equals extended_count\n */\n const flags = bufferParser.readUInt32BE();\n if (flags === undefined)\n return;\n\n const attrs = new Stats();\n if (flags & ATTR.SIZE) {\n const size = bufferParser.readUInt64BE(biOpt);\n if (size === undefined)\n return;\n attrs.size = size;\n }\n\n if (flags & ATTR.UIDGID) {\n const uid = bufferParser.readUInt32BE();\n const gid = bufferParser.readUInt32BE();\n if (gid === undefined)\n return;\n attrs.uid = uid;\n attrs.gid = gid;\n }\n\n if (flags & ATTR.PERMISSIONS) {\n const mode = bufferParser.readUInt32BE();\n if (mode === undefined)\n return;\n attrs.mode = mode;\n }\n\n if (flags & ATTR.ACMODTIME) {\n const atime = bufferParser.readUInt32BE();\n const mtime = bufferParser.readUInt32BE();\n if (mtime === undefined)\n return;\n attrs.atime = atime;\n attrs.mtime = mtime;\n }\n\n if (flags & ATTR.EXTENDED) {\n const count = bufferParser.readUInt32BE();\n if (count === undefined)\n return;\n const extended = {};\n for (let i = 0; i < count; ++i) {\n const type = bufferParser.readString(true);\n const data = bufferParser.readString();\n if (data === undefined)\n return;\n extended[type] = data;\n }\n attrs.extended = extended;\n }\n\n return attrs;\n}\n\nfunction sendOrBuffer(sftp, payload) {\n const ret = tryWritePayload(sftp, payload);\n if (ret !== undefined) {\n sftp._buffer.push(ret);\n return false;\n }\n return true;\n}\n\nfunction tryWritePayload(sftp, payload) {\n const outgoing = sftp.outgoing;\n if (outgoing.state !== 'open')\n return;\n\n if (outgoing.window === 0) {\n sftp._waitWindow = true; // XXX: Unnecessary?\n return payload;\n }\n\n let ret;\n const len = payload.length;\n let p = 0;\n\n while (len - p > 0 && outgoing.window > 0) {\n const actualLen = Math.min(len - p, outgoing.window, outgoing.packetSize);\n outgoing.window -= actualLen;\n if (outgoing.window === 0) {\n sftp._waitWindow = true;\n sftp._chunkcb = drainBuffer;\n }\n\n if (p === 0 && actualLen === len) {\n sftp._protocol.channelData(sftp.outgoing.id, payload);\n } else {\n sftp._protocol.channelData(sftp.outgoing.id,\n bufferSlice(payload, p, p + actualLen));\n }\n\n p += actualLen;\n }\n\n if (len - p > 0) {\n if (p > 0)\n ret = bufferSlice(payload, p, len);\n else\n ret = payload; // XXX: should never get here?\n }\n\n return ret;\n}\n\nfunction drainBuffer() {\n this._chunkcb = undefined;\n const buffer = this._buffer;\n let i = 0;\n while (i < buffer.length) {\n const payload = buffer[i];\n const ret = tryWritePayload(this, payload);\n if (ret !== undefined) {\n if (ret !== payload)\n buffer[i] = ret;\n if (i > 0)\n this._buffer = buffer.slice(i);\n return;\n }\n ++i;\n }\n if (i > 0)\n this._buffer = [];\n}\n\nfunction doFatalSFTPError(sftp, msg, noDebug) {\n const err = new Error(msg);\n err.level = 'sftp-protocol';\n if (!noDebug && sftp._debug)\n sftp._debug(`SFTP: Inbound: ${msg}`);\n sftp.emit('error', err);\n sftp.destroy();\n cleanupRequests(sftp);\n return false;\n}\n\nfunction cleanupRequests(sftp) {\n const keys = Object.keys(sftp._requests);\n if (keys.length === 0)\n return;\n\n const reqs = sftp._requests;\n sftp._requests = {};\n const err = new Error('No response from server');\n for (let i = 0; i < keys.length; ++i) {\n const req = reqs[keys[i]];\n if (typeof req.cb === 'function')\n req.cb(err);\n }\n}\n\nfunction requestLimits(sftp, cb) {\n /*\n uint32 id\n string \"limits@openssh.com\"\n */\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 18);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = sftp._writeReqid = (sftp._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 18, p);\n buf.utf8Write('limits@openssh.com', p += 4, 18);\n\n sftp._requests[reqid] = { extended: 'limits@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(sftp, buf);\n if (sftp._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n sftp._debug(`SFTP: Outbound: ${which} limits@openssh.com`);\n }\n}\n\nconst CLIENT_HANDLERS = {\n [RESPONSE.VERSION]: (sftp, payload) => {\n if (sftp._version !== -1)\n return doFatalSFTPError(sftp, 'Duplicate VERSION packet');\n\n const extensions = {};\n\n /*\n uint32 version\n \n */\n bufferParser.init(payload, 1);\n let version = bufferParser.readUInt32BE();\n while (bufferParser.avail()) {\n const extName = bufferParser.readString(true);\n const extData = bufferParser.readString(true);\n if (extData === undefined) {\n version = undefined;\n break;\n }\n extensions[extName] = extData;\n }\n bufferParser.clear();\n\n if (version === undefined)\n return doFatalSFTPError(sftp, 'Malformed VERSION packet');\n\n if (sftp._debug) {\n const names = Object.keys(extensions);\n if (names.length) {\n sftp._debug(\n `SFTP: Inbound: Received VERSION (v${version}, exts:${names})`\n );\n } else {\n sftp._debug(`SFTP: Inbound: Received VERSION (v${version})`);\n }\n }\n\n sftp._version = version;\n sftp._extensions = extensions;\n\n if (extensions['limits@openssh.com'] === '1') {\n return requestLimits(sftp, (err, limits) => {\n if (!err) {\n if (limits.maxPktLen > 0)\n sftp._maxOutPktLen = limits.maxPktLen;\n if (limits.maxReadLen > 0)\n sftp._maxReadLen = limits.maxReadLen;\n if (limits.maxWriteLen > 0)\n sftp._maxWriteLen = limits.maxWriteLen;\n sftp.maxOpenHandles = (\n limits.maxOpenHandles > 0 ? limits.maxOpenHandles : Infinity\n );\n }\n sftp.emit('ready');\n });\n }\n\n sftp.emit('ready');\n },\n [RESPONSE.STATUS]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n uint32 error/status code\n string error message (ISO-10646 UTF-8)\n string language tag\n */\n const errorCode = bufferParser.readUInt32BE();\n const errorMsg = bufferParser.readString(true);\n bufferParser.clear();\n\n // Note: we avoid checking that the error message and language tag are in\n // the packet because there are some broken implementations that incorrectly\n // omit them. The language tag in general was never really used amongst ssh\n // implementations, so in the case of a missing error message we just\n // default to something sensible.\n\n if (sftp._debug) {\n const jsonMsg = JSON.stringify(errorMsg);\n sftp._debug(\n `SFTP: Inbound: Received STATUS (id:${reqID}, ${errorCode}, ${jsonMsg})`\n );\n }\n const req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n if (req && typeof req.cb === 'function') {\n if (errorCode === STATUS_CODE.OK) {\n req.cb();\n return;\n }\n const err = new Error(errorMsg\n || STATUS_CODE_STR[errorCode]\n || 'Unknown status');\n err.code = errorCode;\n req.cb(err);\n }\n },\n [RESPONSE.HANDLE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined) {\n if (reqID !== undefined)\n delete sftp._requests[reqID];\n return doFatalSFTPError(sftp, 'Malformed HANDLE packet');\n }\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received HANDLE (id:${reqID})`);\n\n const req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n if (req && typeof req.cb === 'function')\n req.cb(undefined, handle);\n },\n [RESPONSE.DATA]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n string data\n */\n if (req && typeof req.cb === 'function') {\n if (req.buffer) {\n // We have already pre-allocated space to store the data\n\n const nb = bufferParser.readString(req.buffer);\n bufferParser.clear();\n\n if (nb !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`\n );\n req.cb(undefined, req.buffer, nb);\n return;\n }\n } else {\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${data.length})`\n );\n req.cb(undefined, data);\n return;\n }\n }\n } else {\n const nb = bufferParser.skipString();\n bufferParser.clear();\n if (nb !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`\n );\n return;\n }\n }\n\n return doFatalSFTPError(sftp, 'Malformed DATA packet');\n },\n [RESPONSE.NAME]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n uint32 count\n repeats count times:\n string filename\n string longname\n ATTRS attrs\n */\n const count = bufferParser.readUInt32BE();\n if (count !== undefined) {\n let names = [];\n for (let i = 0; i < count; ++i) {\n // We are going to assume UTF-8 for filenames despite the SFTPv3\n // spec not specifying an encoding because the specs for newer\n // versions of the protocol all explicitly specify UTF-8 for\n // filenames\n const filename = bufferParser.readString(true);\n\n // `longname` only exists in SFTPv3 and since it typically will\n // contain the filename, we assume it is also UTF-8\n const longname = bufferParser.readString(true);\n\n const attrs = readAttrs(sftp._biOpt);\n if (attrs === undefined) {\n names = undefined;\n break;\n }\n names.push({ filename, longname, attrs });\n }\n if (names !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received NAME (id:${reqID}, ${names.length})`\n );\n bufferParser.clear();\n if (req && typeof req.cb === 'function')\n req.cb(undefined, names);\n return;\n }\n }\n\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed NAME packet');\n },\n [RESPONSE.ATTRS]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n ATTRS attrs\n */\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n if (attrs !== undefined) {\n sftp._debug && sftp._debug(`SFTP: Inbound: Received ATTRS (id:${reqID})`);\n if (req && typeof req.cb === 'function')\n req.cb(undefined, attrs);\n return;\n }\n\n return doFatalSFTPError(sftp, 'Malformed ATTRS packet');\n },\n [RESPONSE.EXTENDED]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n if (reqID !== undefined) {\n const req = sftp._requests[reqID];\n if (req) {\n delete sftp._requests[reqID];\n switch (req.extended) {\n case 'statvfs@openssh.com':\n case 'fstatvfs@openssh.com': {\n /*\n uint64 f_bsize // file system block size\n uint64 f_frsize // fundamental fs block size\n uint64 f_blocks // number of blocks (unit f_frsize)\n uint64 f_bfree // free blocks in file system\n uint64 f_bavail // free blocks for non-root\n uint64 f_files // total file inodes\n uint64 f_ffree // free file inodes\n uint64 f_favail // free file inodes for to non-root\n uint64 f_fsid // file system id\n uint64 f_flag // bit mask of f_flag values\n uint64 f_namemax // maximum filename length\n */\n const biOpt = sftp._biOpt;\n const stats = {\n f_bsize: bufferParser.readUInt64BE(biOpt),\n f_frsize: bufferParser.readUInt64BE(biOpt),\n f_blocks: bufferParser.readUInt64BE(biOpt),\n f_bfree: bufferParser.readUInt64BE(biOpt),\n f_bavail: bufferParser.readUInt64BE(biOpt),\n f_files: bufferParser.readUInt64BE(biOpt),\n f_ffree: bufferParser.readUInt64BE(biOpt),\n f_favail: bufferParser.readUInt64BE(biOpt),\n f_sid: bufferParser.readUInt64BE(biOpt),\n f_flag: bufferParser.readUInt64BE(biOpt),\n f_namemax: bufferParser.readUInt64BE(biOpt),\n };\n if (stats.f_namemax === undefined)\n break;\n if (sftp._debug) {\n sftp._debug(\n 'SFTP: Inbound: Received EXTENDED_REPLY '\n + `(id:${reqID}, ${req.extended})`\n );\n }\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb(undefined, stats);\n return;\n }\n case 'limits@openssh.com': {\n /*\n uint64 max-packet-length\n uint64 max-read-length\n uint64 max-write-length\n uint64 max-open-handles\n */\n const limits = {\n maxPktLen: bufferParser.readUInt64BE(),\n maxReadLen: bufferParser.readUInt64BE(),\n maxWriteLen: bufferParser.readUInt64BE(),\n maxOpenHandles: bufferParser.readUInt64BE(),\n };\n if (limits.maxOpenHandles === undefined)\n break;\n if (sftp._debug) {\n sftp._debug(\n 'SFTP: Inbound: Received EXTENDED_REPLY '\n + `(id:${reqID}, ${req.extended})`\n );\n }\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb(undefined, limits);\n return;\n }\n default:\n // Unknown extended request\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`\n );\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb();\n return;\n }\n } else {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`\n );\n bufferParser.clear();\n return;\n }\n }\n\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed EXTENDED_REPLY packet');\n },\n};\nconst SERVER_HANDLERS = {\n [REQUEST.INIT]: (sftp, payload) => {\n if (sftp._version !== -1)\n return doFatalSFTPError(sftp, 'Duplicate INIT packet');\n\n const extensions = {};\n\n /*\n uint32 version\n \n */\n bufferParser.init(payload, 1);\n let version = bufferParser.readUInt32BE();\n while (bufferParser.avail()) {\n const extName = bufferParser.readString(true);\n const extData = bufferParser.readString(true);\n if (extData === undefined) {\n version = undefined;\n break;\n }\n extensions[extName] = extData;\n }\n bufferParser.clear();\n\n if (version === undefined)\n return doFatalSFTPError(sftp, 'Malformed INIT packet');\n\n if (sftp._debug) {\n const names = Object.keys(extensions);\n if (names.length) {\n sftp._debug(\n `SFTP: Inbound: Received INIT (v${version}, exts:${names})`\n );\n } else {\n sftp._debug(`SFTP: Inbound: Received INIT (v${version})`);\n }\n }\n\n sendOrBuffer(sftp, SERVER_VERSION_BUFFER);\n\n sftp._version = version;\n sftp._extensions = extensions;\n sftp.emit('ready');\n },\n [REQUEST.OPEN]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string filename\n uint32 pflags\n ATTRS attrs\n */\n const filename = bufferParser.readString(true);\n const pflags = bufferParser.readUInt32BE();\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed OPEN packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received OPEN (id:${reqID})`);\n\n if (!sftp.emit('OPEN', reqID, filename, pflags, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.CLOSE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed CLOSE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received CLOSE (id:${reqID})`);\n\n if (!sftp.emit('CLOSE', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READ]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n uint64 offset\n uint32 len\n */\n const handle = bufferParser.readString();\n const offset = bufferParser.readUInt64BE(sftp._biOpt);\n const len = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (len === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed READ packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received READ (id:${reqID})`);\n\n if (!sftp.emit('READ', reqID, handle, offset, len)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.WRITE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n uint64 offset\n string data\n */\n const handle = bufferParser.readString();\n const offset = bufferParser.readUInt64BE(sftp._biOpt);\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed WRITE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received WRITE (id:${reqID})`);\n\n if (!sftp.emit('WRITE', reqID, handle, offset, data)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.LSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed LSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received LSTAT (id:${reqID})`);\n\n if (!sftp.emit('LSTAT', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.FSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed FSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received FSTAT (id:${reqID})`);\n\n if (!sftp.emit('FSTAT', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.SETSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n ATTRS attrs\n */\n const path = bufferParser.readString(true);\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed SETSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received SETSTAT (id:${reqID})`);\n\n if (!sftp.emit('SETSTAT', reqID, path, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.FSETSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n ATTRS attrs\n */\n const handle = bufferParser.readString();\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed FSETSTAT packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received FSETSTAT (id:${reqID})`\n );\n\n if (!sftp.emit('FSETSTAT', reqID, handle, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.OPENDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed OPENDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received OPENDIR (id:${reqID})`);\n\n if (!sftp.emit('OPENDIR', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed READDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received READDIR (id:${reqID})`);\n\n if (!sftp.emit('READDIR', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.REMOVE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed REMOVE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received REMOVE (id:${reqID})`);\n\n if (!sftp.emit('REMOVE', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.MKDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n ATTRS attrs\n */\n const path = bufferParser.readString(true);\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed MKDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received MKDIR (id:${reqID})`);\n\n if (!sftp.emit('MKDIR', reqID, path, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.RMDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed RMDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received RMDIR (id:${reqID})`);\n\n if (!sftp.emit('RMDIR', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.REALPATH]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed REALPATH packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received REALPATH (id:${reqID})`\n );\n\n if (!sftp.emit('REALPATH', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.STAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed STAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received STAT (id:${reqID})`);\n\n if (!sftp.emit('STAT', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.RENAME]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string oldpath\n string newpath\n */\n const oldPath = bufferParser.readString(true);\n const newPath = bufferParser.readString(true);\n bufferParser.clear();\n\n if (newPath === undefined)\n return doFatalSFTPError(sftp, 'Malformed RENAME packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received RENAME (id:${reqID})`);\n\n if (!sftp.emit('RENAME', reqID, oldPath, newPath)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READLINK]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed READLINK packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received READLINK (id:${reqID})`\n );\n\n if (!sftp.emit('READLINK', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.SYMLINK]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string linkpath\n string targetpath\n */\n const linkPath = bufferParser.readString(true);\n const targetPath = bufferParser.readString(true);\n bufferParser.clear();\n\n if (targetPath === undefined)\n return doFatalSFTPError(sftp, 'Malformed SYMLINK packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received SYMLINK (id:${reqID})`);\n\n let handled;\n if (sftp._isOpenSSH) {\n // OpenSSH has linkpath and targetpath positions switched\n handled = sftp.emit('SYMLINK', reqID, targetPath, linkPath);\n } else {\n handled = sftp.emit('SYMLINK', reqID, linkPath, targetPath);\n }\n if (!handled) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.EXTENDED]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string extended-request\n ... any request-specific data ...\n */\n const extName = bufferParser.readString(true);\n if (extName === undefined) {\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed EXTENDED packet');\n }\n\n let extData;\n if (bufferParser.avail())\n extData = bufferParser.readRaw();\n bufferParser.clear();\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED (id:${reqID})`\n );\n\n if (!sftp.emit('EXTENDED', reqID, extName, extData)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n};\n\n// =============================================================================\n// ReadStream/WriteStream-related ==============================================\n// =============================================================================\nconst {\n ERR_INVALID_ARG_TYPE,\n ERR_OUT_OF_RANGE,\n validateNumber\n} = require('./node-fs-compat');\n\nconst kMinPoolSpace = 128;\n\nlet pool;\n// It can happen that we expect to read a large chunk of data, and reserve\n// a large chunk of the pool accordingly, but the read() call only filled\n// a portion of it. If a concurrently executing read() then uses the same pool,\n// the \"reserved\" portion cannot be used, so we allow it to be re-used as a\n// new pool later.\nconst poolFragments = [];\n\nfunction allocNewPool(poolSize) {\n if (poolFragments.length > 0)\n pool = poolFragments.pop();\n else\n pool = Buffer.allocUnsafe(poolSize);\n pool.used = 0;\n}\n\n// Check the `this.start` and `this.end` of stream.\nfunction checkPosition(pos, name) {\n if (!Number.isSafeInteger(pos)) {\n validateNumber(pos, name);\n if (!Number.isInteger(pos))\n throw new ERR_OUT_OF_RANGE(name, 'an integer', pos);\n throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);\n }\n if (pos < 0)\n throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);\n}\n\nfunction roundUpToMultipleOf8(n) {\n return (n + 7) & ~7; // Align to 8 byte boundary.\n}\n\nfunction ReadStream(sftp, path, options) {\n if (options === undefined)\n options = {};\n else if (typeof options === 'string')\n options = { encoding: options };\n else if (options === null || typeof options !== 'object')\n throw new TypeError('\"options\" argument must be a string or an object');\n else\n options = Object.create(options);\n\n // A little bit bigger buffer and water marks by default\n if (options.highWaterMark === undefined)\n options.highWaterMark = 64 * 1024;\n\n // For backwards compat do not emit close on destroy.\n options.emitClose = false;\n options.autoDestroy = false; // Node 14 major change.\n\n ReadableStream.call(this, options);\n\n this.path = path;\n this.flags = options.flags === undefined ? 'r' : options.flags;\n this.mode = options.mode === undefined ? 0o666 : options.mode;\n\n this.start = options.start;\n this.end = options.end;\n this.autoClose = options.autoClose === undefined ? true : options.autoClose;\n this.pos = 0;\n this.bytesRead = 0;\n this.closed = false;\n\n this.handle = options.handle === undefined ? null : options.handle;\n this.sftp = sftp;\n this._opening = false;\n\n if (this.start !== undefined) {\n checkPosition(this.start, 'start');\n\n this.pos = this.start;\n }\n\n if (this.end === undefined) {\n this.end = Infinity;\n } else if (this.end !== Infinity) {\n checkPosition(this.end, 'end');\n\n if (this.start !== undefined && this.start > this.end) {\n throw new ERR_OUT_OF_RANGE(\n 'start',\n `<= \"end\" (here: ${this.end})`,\n this.start\n );\n }\n }\n\n this.on('end', function() {\n if (this.autoClose)\n this.destroy();\n });\n\n if (!Buffer.isBuffer(this.handle))\n this.open();\n}\ninherits(ReadStream, ReadableStream);\n\nReadStream.prototype.open = function() {\n if (this._opening)\n return;\n\n this._opening = true;\n\n this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {\n this._opening = false;\n\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n\n this.handle = handle;\n this.emit('open', handle);\n this.emit('ready');\n // Start the flow of data.\n this.read();\n });\n};\n\nReadStream.prototype._read = function(n) {\n if (!Buffer.isBuffer(this.handle))\n return this.once('open', () => this._read(n));\n\n // XXX: safe to remove this?\n if (this.destroyed)\n return;\n\n if (!pool || pool.length - pool.used < kMinPoolSpace) {\n // Discard the old pool.\n allocNewPool(this.readableHighWaterMark\n || this._readableState.highWaterMark);\n }\n\n // Grab another reference to the pool in the case that while we're\n // in the thread pool another read() finishes up the pool, and\n // allocates a new one.\n const thisPool = pool;\n let toRead = Math.min(pool.length - pool.used, n);\n const start = pool.used;\n\n if (this.end !== undefined)\n toRead = Math.min(this.end - this.pos + 1, toRead);\n\n // Already read everything we were supposed to read!\n // treat as EOF.\n if (toRead <= 0)\n return this.push(null);\n\n // the actual read.\n this.sftp.read(this.handle,\n pool,\n pool.used,\n toRead,\n this.pos,\n (er, bytesRead) => {\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n let b = null;\n\n // Now that we know how much data we have actually read, re-wind the\n // 'used' field if we can, and otherwise allow the remainder of our\n // reservation to be used as a new pool later.\n if (start + toRead === thisPool.used && thisPool === pool) {\n thisPool.used = roundUpToMultipleOf8(thisPool.used + bytesRead - toRead);\n } else {\n // Round down to the next lowest multiple of 8 to ensure the new pool\n // fragment start and end positions are aligned to an 8 byte boundary.\n const alignedEnd = (start + toRead) & ~7;\n const alignedStart = roundUpToMultipleOf8(start + bytesRead);\n if (alignedEnd - alignedStart >= kMinPoolSpace)\n poolFragments.push(thisPool.slice(alignedStart, alignedEnd));\n }\n\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n b = thisPool.slice(start, start + bytesRead);\n }\n\n // Move the pool positions, and internal position for reading.\n this.pos += bytesRead;\n\n this.push(b);\n });\n\n pool.used = roundUpToMultipleOf8(pool.used + toRead);\n};\n\nReadStream.prototype._destroy = function(err, cb) {\n if (this._opening && !Buffer.isBuffer(this.handle)) {\n this.once('open', closeStream.bind(null, this, cb, err));\n return;\n }\n\n closeStream(this, cb, err);\n this.handle = null;\n this._opening = false;\n};\n\nfunction closeStream(stream, cb, err) {\n if (!stream.handle)\n return onclose();\n\n stream.sftp.close(stream.handle, onclose);\n\n function onclose(er) {\n er = er || err;\n cb(er);\n stream.closed = true;\n if (!er)\n stream.emit('close');\n }\n}\n\nReadStream.prototype.close = function(cb) {\n this.destroy(null, cb);\n};\n\nObject.defineProperty(ReadStream.prototype, 'pending', {\n get() {\n return this.handle === null;\n },\n configurable: true\n});\n\n// TODO: add `concurrency` setting to allow more than one in-flight WRITE\n// request to server to improve throughput\nfunction WriteStream(sftp, path, options) {\n if (options === undefined)\n options = {};\n else if (typeof options === 'string')\n options = { encoding: options };\n else if (options === null || typeof options !== 'object')\n throw new TypeError('\"options\" argument must be a string or an object');\n else\n options = Object.create(options);\n\n // For backwards compat do not emit close on destroy.\n options.emitClose = false;\n options.autoDestroy = false; // Node 14 major change.\n\n WritableStream.call(this, options);\n\n this.path = path;\n this.flags = options.flags === undefined ? 'w' : options.flags;\n this.mode = options.mode === undefined ? 0o666 : options.mode;\n\n this.start = options.start;\n this.autoClose = options.autoClose === undefined ? true : options.autoClose;\n this.pos = 0;\n this.bytesWritten = 0;\n this.closed = false;\n\n this.handle = options.handle === undefined ? null : options.handle;\n this.sftp = sftp;\n this._opening = false;\n\n if (this.start !== undefined) {\n checkPosition(this.start, 'start');\n\n this.pos = this.start;\n }\n\n if (options.encoding)\n this.setDefaultEncoding(options.encoding);\n\n // Node v6.x only\n this.on('finish', function() {\n if (this._writableState.finalCalled)\n return;\n if (this.autoClose)\n this.destroy();\n });\n\n if (!Buffer.isBuffer(this.handle))\n this.open();\n}\ninherits(WriteStream, WritableStream);\n\nWriteStream.prototype._final = function(cb) {\n if (this.autoClose)\n this.destroy();\n cb();\n};\n\nWriteStream.prototype.open = function() {\n if (this._opening)\n return;\n\n this._opening = true;\n\n this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {\n this._opening = false;\n\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n\n this.handle = handle;\n\n const tryAgain = (err) => {\n if (err) {\n // Try chmod() for sftp servers that may not support fchmod() for\n // whatever reason\n this.sftp.chmod(this.path, this.mode, (err_) => tryAgain());\n return;\n }\n\n // SFTPv3 requires absolute offsets, no matter the open flag used\n if (this.flags[0] === 'a') {\n const tryStat = (err, st) => {\n if (err) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.sftp.stat(this.path, (err_, st_) => {\n if (err_) {\n this.destroy();\n this.emit('error', err);\n return;\n }\n tryStat(null, st_);\n });\n return;\n }\n\n this.pos = st.size;\n this.emit('open', handle);\n this.emit('ready');\n };\n\n this.sftp.fstat(handle, tryStat);\n return;\n }\n\n this.emit('open', handle);\n this.emit('ready');\n };\n\n this.sftp.fchmod(handle, this.mode, tryAgain);\n });\n};\n\nWriteStream.prototype._write = function(data, encoding, cb) {\n if (!Buffer.isBuffer(data)) {\n const err = new ERR_INVALID_ARG_TYPE('data', 'Buffer', data);\n return this.emit('error', err);\n }\n\n if (!Buffer.isBuffer(this.handle)) {\n return this.once('open', function() {\n this._write(data, encoding, cb);\n });\n }\n\n this.sftp.write(this.handle,\n data,\n 0,\n data.length,\n this.pos,\n (er, bytes) => {\n if (er) {\n if (this.autoClose)\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n cb();\n });\n\n this.pos += data.length;\n};\n\nWriteStream.prototype._writev = function(data, cb) {\n if (!Buffer.isBuffer(this.handle)) {\n return this.once('open', function() {\n this._writev(data, cb);\n });\n }\n\n const sftp = this.sftp;\n const handle = this.handle;\n let writesLeft = data.length;\n\n const onwrite = (er, bytes) => {\n if (er) {\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n if (--writesLeft === 0)\n cb();\n };\n\n // TODO: try to combine chunks to reduce number of requests to the server?\n for (let i = 0; i < data.length; ++i) {\n const chunk = data[i].chunk;\n\n sftp.write(handle, chunk, 0, chunk.length, this.pos, onwrite);\n this.pos += chunk.length;\n }\n};\n\nif (typeof WritableStream.prototype.destroy !== 'function')\n WriteStream.prototype.destroy = ReadStream.prototype.destroy;\n\nWriteStream.prototype._destroy = ReadStream.prototype._destroy;\nWriteStream.prototype.close = function(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on('close', cb);\n }\n\n // If we are not autoClosing, we should call\n // destroy on 'finish'.\n if (!this.autoClose)\n this.on('finish', this.destroy.bind(this));\n\n this.end();\n};\n\n// There is no shutdown() for files.\nWriteStream.prototype.destroySoon = WriteStream.prototype.end;\n\nObject.defineProperty(WriteStream.prototype, 'pending', {\n get() {\n return this.handle === null;\n },\n configurable: true\n});\n// =============================================================================\n\nmodule.exports = {\n flagsToString,\n OPEN_MODE,\n SFTP,\n Stats,\n STATUS_CODE,\n stringToFlags,\n};\n","'use strict';\n\nconst crypto = require('crypto');\n\nlet cpuInfo;\ntry {\n cpuInfo = require('cpu-features')();\n} catch {}\n\nconst { bindingAvailable } = require('./crypto.js');\n\nconst eddsaSupported = (() => {\n if (typeof crypto.sign === 'function'\n && typeof crypto.verify === 'function') {\n const key =\n '-----BEGIN PRIVATE KEY-----\\r\\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD'\n + '/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\\r\\n-----END PRIVATE KEY-----';\n const data = Buffer.from('a');\n let sig;\n let verified;\n try {\n sig = crypto.sign(null, data, key);\n verified = crypto.verify(null, data, key, sig);\n } catch {}\n return (Buffer.isBuffer(sig) && sig.length === 64 && verified === true);\n }\n\n return false;\n})();\n\nconst curve25519Supported = (typeof crypto.diffieHellman === 'function'\n && typeof crypto.generateKeyPairSync === 'function'\n && typeof crypto.createPublicKey === 'function');\n\nconst DEFAULT_KEX = [\n // https://tools.ietf.org/html/rfc5656#section-10.1\n 'ecdh-sha2-nistp256',\n 'ecdh-sha2-nistp384',\n 'ecdh-sha2-nistp521',\n\n // https://tools.ietf.org/html/rfc4419#section-4\n 'diffie-hellman-group-exchange-sha256',\n\n // https://tools.ietf.org/html/rfc8268\n 'diffie-hellman-group14-sha256',\n 'diffie-hellman-group15-sha512',\n 'diffie-hellman-group16-sha512',\n 'diffie-hellman-group17-sha512',\n 'diffie-hellman-group18-sha512',\n];\nif (curve25519Supported) {\n DEFAULT_KEX.unshift('curve25519-sha256');\n DEFAULT_KEX.unshift('curve25519-sha256@libssh.org');\n}\nconst SUPPORTED_KEX = DEFAULT_KEX.concat([\n // https://tools.ietf.org/html/rfc4419#section-4\n 'diffie-hellman-group-exchange-sha1',\n\n 'diffie-hellman-group14-sha1', // REQUIRED\n 'diffie-hellman-group1-sha1', // REQUIRED\n]);\n\n\nconst DEFAULT_SERVER_HOST_KEY = [\n 'ecdsa-sha2-nistp256',\n 'ecdsa-sha2-nistp384',\n 'ecdsa-sha2-nistp521',\n 'rsa-sha2-512', // RFC 8332\n 'rsa-sha2-256', // RFC 8332\n 'ssh-rsa',\n];\nif (eddsaSupported)\n DEFAULT_SERVER_HOST_KEY.unshift('ssh-ed25519');\nconst SUPPORTED_SERVER_HOST_KEY = DEFAULT_SERVER_HOST_KEY.concat([\n 'ssh-dss',\n]);\n\n\nconst DEFAULT_CIPHER = [\n // http://tools.ietf.org/html/rfc5647\n 'aes128-gcm@openssh.com',\n 'aes256-gcm@openssh.com',\n\n // http://tools.ietf.org/html/rfc4344#section-4\n 'aes128-ctr',\n 'aes192-ctr',\n 'aes256-ctr',\n];\nif (cpuInfo && cpuInfo.flags && !cpuInfo.flags.aes) {\n // We know for sure the CPU does not support AES acceleration\n if (bindingAvailable)\n DEFAULT_CIPHER.unshift('chacha20-poly1305@openssh.com');\n else\n DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');\n} else if (bindingAvailable && cpuInfo && cpuInfo.arch === 'x86') {\n // Places chacha20-poly1305 immediately after GCM ciphers since GCM ciphers\n // seem to outperform it on x86, but it seems to be faster than CTR ciphers\n DEFAULT_CIPHER.splice(4, 0, 'chacha20-poly1305@openssh.com');\n} else {\n DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');\n}\nconst SUPPORTED_CIPHER = DEFAULT_CIPHER.concat([\n 'aes256-cbc',\n 'aes192-cbc',\n 'aes128-cbc',\n 'blowfish-cbc',\n '3des-cbc',\n 'aes128-gcm',\n 'aes256-gcm',\n\n // http://tools.ietf.org/html/rfc4345#section-4:\n 'arcfour256',\n 'arcfour128',\n\n 'cast128-cbc',\n 'arcfour',\n]);\n\n\nconst DEFAULT_MAC = [\n 'hmac-sha2-256-etm@openssh.com',\n 'hmac-sha2-512-etm@openssh.com',\n 'hmac-sha1-etm@openssh.com',\n 'hmac-sha2-256',\n 'hmac-sha2-512',\n 'hmac-sha1',\n];\nconst SUPPORTED_MAC = DEFAULT_MAC.concat([\n 'hmac-md5',\n 'hmac-sha2-256-96', // first 96 bits of HMAC-SHA256\n 'hmac-sha2-512-96', // first 96 bits of HMAC-SHA512\n 'hmac-ripemd160',\n 'hmac-sha1-96', // first 96 bits of HMAC-SHA1\n 'hmac-md5-96', // first 96 bits of HMAC-MD5\n]);\n\nconst DEFAULT_COMPRESSION = [\n 'none',\n 'zlib@openssh.com', // ZLIB (LZ77) compression, except\n // compression/decompression does not start until after\n // successful user authentication\n 'zlib', // ZLIB (LZ77) compression\n];\nconst SUPPORTED_COMPRESSION = DEFAULT_COMPRESSION.concat([\n]);\n\n\nconst COMPAT = {\n BAD_DHGEX: 1 << 0,\n OLD_EXIT: 1 << 1,\n DYN_RPORT_BUG: 1 << 2,\n BUG_DHGEX_LARGE: 1 << 3,\n};\n\nmodule.exports = {\n MESSAGE: {\n // Transport layer protocol -- generic (1-19)\n DISCONNECT: 1,\n IGNORE: 2,\n UNIMPLEMENTED: 3,\n DEBUG: 4,\n SERVICE_REQUEST: 5,\n SERVICE_ACCEPT: 6,\n\n // Transport layer protocol -- algorithm negotiation (20-29)\n KEXINIT: 20,\n NEWKEYS: 21,\n\n // Transport layer protocol -- key exchange method-specific (30-49)\n KEXDH_INIT: 30,\n KEXDH_REPLY: 31,\n\n KEXDH_GEX_GROUP: 31,\n KEXDH_GEX_INIT: 32,\n KEXDH_GEX_REPLY: 33,\n KEXDH_GEX_REQUEST: 34,\n\n KEXECDH_INIT: 30,\n KEXECDH_REPLY: 31,\n\n // User auth protocol -- generic (50-59)\n USERAUTH_REQUEST: 50,\n USERAUTH_FAILURE: 51,\n USERAUTH_SUCCESS: 52,\n USERAUTH_BANNER: 53,\n\n // User auth protocol -- user auth method-specific (60-79)\n USERAUTH_PASSWD_CHANGEREQ: 60,\n\n USERAUTH_PK_OK: 60,\n\n USERAUTH_INFO_REQUEST: 60,\n USERAUTH_INFO_RESPONSE: 61,\n\n // Connection protocol -- generic (80-89)\n GLOBAL_REQUEST: 80,\n REQUEST_SUCCESS: 81,\n REQUEST_FAILURE: 82,\n\n // Connection protocol -- channel-related (90-127)\n CHANNEL_OPEN: 90,\n CHANNEL_OPEN_CONFIRMATION: 91,\n CHANNEL_OPEN_FAILURE: 92,\n CHANNEL_WINDOW_ADJUST: 93,\n CHANNEL_DATA: 94,\n CHANNEL_EXTENDED_DATA: 95,\n CHANNEL_EOF: 96,\n CHANNEL_CLOSE: 97,\n CHANNEL_REQUEST: 98,\n CHANNEL_SUCCESS: 99,\n CHANNEL_FAILURE: 100\n\n // Reserved for client protocols (128-191)\n\n // Local extensions (192-155)\n },\n DISCONNECT_REASON: {\n HOST_NOT_ALLOWED_TO_CONNECT: 1,\n PROTOCOL_ERROR: 2,\n KEY_EXCHANGE_FAILED: 3,\n RESERVED: 4,\n MAC_ERROR: 5,\n COMPRESSION_ERROR: 6,\n SERVICE_NOT_AVAILABLE: 7,\n PROTOCOL_VERSION_NOT_SUPPORTED: 8,\n HOST_KEY_NOT_VERIFIABLE: 9,\n CONNECTION_LOST: 10,\n BY_APPLICATION: 11,\n TOO_MANY_CONNECTIONS: 12,\n AUTH_CANCELED_BY_USER: 13,\n NO_MORE_AUTH_METHODS_AVAILABLE: 14,\n ILLEGAL_USER_NAME: 15,\n },\n DISCONNECT_REASON_STR: undefined,\n CHANNEL_OPEN_FAILURE: {\n ADMINISTRATIVELY_PROHIBITED: 1,\n CONNECT_FAILED: 2,\n UNKNOWN_CHANNEL_TYPE: 3,\n RESOURCE_SHORTAGE: 4\n },\n TERMINAL_MODE: {\n TTY_OP_END: 0, // Indicates end of options.\n VINTR: 1, // Interrupt character; 255 if none. Similarly for the\n // other characters. Not all of these characters are\n // supported on all systems.\n VQUIT: 2, // The quit character (sends SIGQUIT signal on POSIX\n // systems).\n VERASE: 3, // Erase the character to left of the cursor.\n VKILL: 4, // Kill the current input line.\n VEOF: 5, // End-of-file character (sends EOF from the\n // terminal).\n VEOL: 6, // End-of-line character in addition to carriage\n // return and/or linefeed.\n VEOL2: 7, // Additional end-of-line character.\n VSTART: 8, // Continues paused output (normally control-Q).\n VSTOP: 9, // Pauses output (normally control-S).\n VSUSP: 10, // Suspends the current program.\n VDSUSP: 11, // Another suspend character.\n VREPRINT: 12, // Reprints the current input line.\n VWERASE: 13, // Erases a word left of cursor.\n VLNEXT: 14, // Enter the next character typed literally, even if\n // it is a special character\n VFLUSH: 15, // Character to flush output.\n VSWTCH: 16, // Switch to a different shell layer.\n VSTATUS: 17, // Prints system status line (load, command, pid,\n // etc).\n VDISCARD: 18, // Toggles the flushing of terminal output.\n IGNPAR: 30, // The ignore parity flag. The parameter SHOULD be 0\n // if this flag is FALSE, and 1 if it is TRUE.\n PARMRK: 31, // Mark parity and framing errors.\n INPCK: 32, // Enable checking of parity errors.\n ISTRIP: 33, // Strip 8th bit off characters.\n INLCR: 34, // Map NL into CR on input.\n IGNCR: 35, // Ignore CR on input.\n ICRNL: 36, // Map CR to NL on input.\n IUCLC: 37, // Translate uppercase characters to lowercase.\n IXON: 38, // Enable output flow control.\n IXANY: 39, // Any char will restart after stop.\n IXOFF: 40, // Enable input flow control.\n IMAXBEL: 41, // Ring bell on input queue full.\n ISIG: 50, // Enable signals INTR, QUIT, [D]SUSP.\n ICANON: 51, // Canonicalize input lines.\n XCASE: 52, // Enable input and output of uppercase characters by\n // preceding their lowercase equivalents with \"\\\".\n ECHO: 53, // Enable echoing.\n ECHOE: 54, // Visually erase chars.\n ECHOK: 55, // Kill character discards current line.\n ECHONL: 56, // Echo NL even if ECHO is off.\n NOFLSH: 57, // Don't flush after interrupt.\n TOSTOP: 58, // Stop background jobs from output.\n IEXTEN: 59, // Enable extensions.\n ECHOCTL: 60, // Echo control characters as ^(Char).\n ECHOKE: 61, // Visual erase for line kill.\n PENDIN: 62, // Retype pending input.\n OPOST: 70, // Enable output processing.\n OLCUC: 71, // Convert lowercase to uppercase.\n ONLCR: 72, // Map NL to CR-NL.\n OCRNL: 73, // Translate carriage return to newline (output).\n ONOCR: 74, // Translate newline to carriage return-newline\n // (output).\n ONLRET: 75, // Newline performs a carriage return (output).\n CS7: 90, // 7 bit mode.\n CS8: 91, // 8 bit mode.\n PARENB: 92, // Parity enable.\n PARODD: 93, // Odd parity, else even.\n TTY_OP_ISPEED: 128, // Specifies the input baud rate in bits per second.\n TTY_OP_OSPEED: 129, // Specifies the output baud rate in bits per second.\n },\n CHANNEL_EXTENDED_DATATYPE: {\n STDERR: 1,\n },\n\n SIGNALS: [\n 'ABRT', 'ALRM', 'FPE', 'HUP', 'ILL', 'INT', 'QUIT', 'SEGV', 'TERM', 'USR1',\n 'USR2', 'KILL', 'PIPE'\n ].reduce((cur, val) => ({ ...cur, [val]: 1 }), {}),\n\n COMPAT,\n COMPAT_CHECKS: [\n [ 'Cisco-1.25', COMPAT.BAD_DHGEX ],\n [ /^Cisco-1\\./, COMPAT.BUG_DHGEX_LARGE ],\n [ /^[0-9.]+$/, COMPAT.OLD_EXIT ], // old SSH.com implementations\n [ /^OpenSSH_5\\.\\d+/, COMPAT.DYN_RPORT_BUG ],\n ],\n\n // KEX proposal-related\n DEFAULT_KEX,\n SUPPORTED_KEX,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER,\n DEFAULT_MAC,\n SUPPORTED_MAC,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION,\n\n curve25519Supported,\n eddsaSupported,\n};\n\nmodule.exports.DISCONNECT_REASON_BY_VALUE =\n Array.from(Object.entries(module.exports.DISCONNECT_REASON))\n .reduce((obj, [key, value]) => ({ ...obj, [value]: key }), {});\n","// TODO:\n// * make max packet size configurable\n// * if decompression is enabled, use `._packet` in decipher instances as\n// input to (sync) zlib inflater with appropriate offset and length to\n// avoid an additional copy of payload data before inflation\n// * factor decompression status into packet length checks\n'use strict';\n\nconst {\n createCipheriv, createDecipheriv, createHmac, randomFillSync, timingSafeEqual\n} = require('crypto');\n\nconst { readUInt32BE, writeUInt32BE } = require('./utils.js');\n\nconst FastBuffer = Buffer[Symbol.species];\nconst MAX_SEQNO = 2 ** 32 - 1;\nconst EMPTY_BUFFER = Buffer.alloc(0);\nconst BUF_INT = Buffer.alloc(4);\nconst DISCARD_CACHE = new Map();\nconst MAX_PACKET_SIZE = 35000;\n\nlet binding;\nlet AESGCMCipher;\nlet ChaChaPolyCipher;\nlet GenericCipher;\nlet AESGCMDecipher;\nlet ChaChaPolyDecipher;\nlet GenericDecipher;\ntry {\n binding = require('./crypto/build/Release/sshcrypto.node');\n ({ AESGCMCipher, ChaChaPolyCipher, GenericCipher,\n AESGCMDecipher, ChaChaPolyDecipher, GenericDecipher } = binding);\n} catch {}\n\nconst CIPHER_STREAM = 1 << 0;\nconst CIPHER_INFO = (() => {\n function info(sslName, blockLen, keyLen, ivLen, authLen, discardLen, flags) {\n return {\n sslName,\n blockLen,\n keyLen,\n ivLen: (ivLen !== 0 || (flags & CIPHER_STREAM)\n ? ivLen\n : blockLen),\n authLen,\n discardLen,\n stream: !!(flags & CIPHER_STREAM),\n };\n }\n\n return {\n 'chacha20-poly1305@openssh.com':\n info('chacha20', 8, 64, 0, 16, 0, CIPHER_STREAM),\n\n 'aes128-gcm': info('aes-128-gcm', 16, 16, 12, 16, 0, CIPHER_STREAM),\n 'aes256-gcm': info('aes-256-gcm', 16, 32, 12, 16, 0, CIPHER_STREAM),\n 'aes128-gcm@openssh.com':\n info('aes-128-gcm', 16, 16, 12, 16, 0, CIPHER_STREAM),\n 'aes256-gcm@openssh.com':\n info('aes-256-gcm', 16, 32, 12, 16, 0, CIPHER_STREAM),\n\n 'aes128-cbc': info('aes-128-cbc', 16, 16, 0, 0, 0, 0),\n 'aes192-cbc': info('aes-192-cbc', 16, 24, 0, 0, 0, 0),\n 'aes256-cbc': info('aes-256-cbc', 16, 32, 0, 0, 0, 0),\n 'rijndael-cbc@lysator.liu.se': info('aes-256-cbc', 16, 32, 0, 0, 0, 0),\n '3des-cbc': info('des-ede3-cbc', 8, 24, 0, 0, 0, 0),\n 'blowfish-cbc': info('bf-cbc', 8, 16, 0, 0, 0, 0),\n 'idea-cbc': info('idea-cbc', 8, 16, 0, 0, 0, 0),\n 'cast128-cbc': info('cast-cbc', 8, 16, 0, 0, 0, 0),\n\n 'aes128-ctr': info('aes-128-ctr', 16, 16, 16, 0, 0, CIPHER_STREAM),\n 'aes192-ctr': info('aes-192-ctr', 16, 24, 16, 0, 0, CIPHER_STREAM),\n 'aes256-ctr': info('aes-256-ctr', 16, 32, 16, 0, 0, CIPHER_STREAM),\n '3des-ctr': info('des-ede3', 8, 24, 8, 0, 0, CIPHER_STREAM),\n 'blowfish-ctr': info('bf-ecb', 8, 16, 8, 0, 0, CIPHER_STREAM),\n 'cast128-ctr': info('cast5-ecb', 8, 16, 8, 0, 0, CIPHER_STREAM),\n\n /* The \"arcfour128\" algorithm is the RC4 cipher, as described in\n [SCHNEIER], using a 128-bit key. The first 1536 bytes of keystream\n generated by the cipher MUST be discarded, and the first byte of the\n first encrypted packet MUST be encrypted using the 1537th byte of\n keystream.\n\n -- http://tools.ietf.org/html/rfc4345#section-4 */\n 'arcfour': info('rc4', 8, 16, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour128': info('rc4', 8, 16, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour256': info('rc4', 8, 32, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour512': info('rc4', 8, 64, 0, 0, 1536, CIPHER_STREAM),\n };\n})();\n\nconst MAC_INFO = (() => {\n function info(sslName, len, actualLen, isETM) {\n return {\n sslName,\n len,\n actualLen,\n isETM,\n };\n }\n\n return {\n 'hmac-md5': info('md5', 16, 16, false),\n 'hmac-md5-96': info('md5', 16, 12, false),\n 'hmac-ripemd160': info('ripemd160', 20, 20, false),\n 'hmac-sha1': info('sha1', 20, 20, false),\n 'hmac-sha1-etm@openssh.com': info('sha1', 20, 20, true),\n 'hmac-sha1-96': info('sha1', 20, 12, false),\n 'hmac-sha2-256': info('sha256', 32, 32, false),\n 'hmac-sha2-256-etm@openssh.com': info('sha256', 32, 32, true),\n 'hmac-sha2-256-96': info('sha256', 32, 12, false),\n 'hmac-sha2-512': info('sha512', 64, 64, false),\n 'hmac-sha2-512-etm@openssh.com': info('sha512', 64, 64, true),\n 'hmac-sha2-512-96': info('sha512', 64, 12, false),\n };\n})();\n\n\n// Should only_be used during the initial handshake\nclass NullCipher {\n constructor(seqno, onWrite) {\n this.outSeqno = seqno;\n this._onWrite = onWrite;\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - (pktLen & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nconst POLY1305_ZEROS = Buffer.alloc(32);\nconst POLY1305_OUT_COMPUTE = Buffer.alloc(16);\nlet POLY1305_WASM_MODULE;\nlet POLY1305_RESULT_MALLOC;\nlet poly1305_auth;\nclass ChaChaPolyCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encKeyMain = enc.cipherKey.slice(0, 32);\n this._encKeyPktLen = enc.cipherKey.slice(32);\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - ((pktLen - 4) & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Generate Poly1305 key\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.outSeqno, 12);\n const polyKey =\n createCipheriv('chacha20', this._encKeyMain, POLY1305_OUT_COMPUTE)\n .update(POLY1305_ZEROS);\n\n // Encrypt packet length\n const pktLenEnc =\n createCipheriv('chacha20', this._encKeyPktLen, POLY1305_OUT_COMPUTE)\n .update(packet.slice(0, 4));\n this._onWrite(pktLenEnc);\n\n // Encrypt rest of packet\n POLY1305_OUT_COMPUTE[0] = 1; // Set counter to 1 (little endian)\n const payloadEnc =\n createCipheriv('chacha20', this._encKeyMain, POLY1305_OUT_COMPUTE)\n .update(packet.slice(4));\n this._onWrite(payloadEnc);\n\n // Calculate Poly1305 MAC\n poly1305_auth(POLY1305_RESULT_MALLOC,\n pktLenEnc,\n pktLenEnc.length,\n payloadEnc,\n payloadEnc.length,\n polyKey);\n const mac = Buffer.allocUnsafe(16);\n mac.set(\n new Uint8Array(POLY1305_WASM_MODULE.HEAPU8.buffer,\n POLY1305_RESULT_MALLOC,\n 16),\n 0\n );\n this._onWrite(mac);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass ChaChaPolyCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._instance = new ChaChaPolyCipher(enc.cipherKey);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - ((pktLen - 4) & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + 16/* MAC */);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet, this.outSeqno);\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass AESGCMCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encSSLName = enc.cipherInfo.sslName;\n this._encKey = enc.cipherKey;\n this._encIV = enc.cipherIV;\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 16 - ((pktLen - 4) & (16 - 1));\n if (padLen < 4)\n padLen += 16;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n const cipher = createCipheriv(this._encSSLName, this._encKey, this._encIV);\n cipher.setAutoPadding(false);\n\n const lenData = packet.slice(0, 4);\n cipher.setAAD(lenData);\n this._onWrite(lenData);\n\n // Encrypt pad length, payload, and padding\n const encrypted = cipher.update(packet.slice(4));\n this._onWrite(encrypted);\n const final = cipher.final();\n // XXX: final.length === 0 always?\n if (final.length)\n this._onWrite(final);\n\n // Generate MAC\n const tag = cipher.getAuthTag();\n this._onWrite(tag);\n\n // Increment counter in IV by 1 for next packet\n ivIncrement(this._encIV);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass AESGCMCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._instance = new AESGCMCipher(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 16 - ((pktLen - 4) & (16 - 1));\n if (padLen < 4)\n padLen += 16;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + 16/* authTag */);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet);\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass GenericCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encBlockLen = enc.cipherInfo.blockLen;\n this._cipherInstance = createCipheriv(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV);\n this._macSSLName = enc.macInfo.sslName;\n this._macKey = enc.macKey;\n this._macActualLen = enc.macInfo.actualLen;\n this._macETM = enc.macInfo.isETM;\n this._aadLen = (this._macETM ? 4 : 0);\n this._dead = false;\n\n const discardLen = enc.cipherInfo.discardLen;\n if (discardLen) {\n let discard = DISCARD_CACHE.get(discardLen);\n if (discard === undefined) {\n discard = Buffer.alloc(discardLen);\n DISCARD_CACHE.set(discardLen, discard);\n }\n this._cipherInstance.update(discard);\n }\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n const blockLen = this._encBlockLen;\n\n let pktLen = 4 + 1 + payloadLen;\n let padLen = blockLen - ((pktLen - this._aadLen) & (blockLen - 1));\n if (padLen < 4)\n padLen += blockLen;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n let mac;\n if (this._macETM) {\n // Encrypt pad length, payload, and padding\n const lenBytes = new Uint8Array(packet.buffer, packet.byteOffset, 4);\n const encrypted = this._cipherInstance.update(\n new Uint8Array(packet.buffer,\n packet.byteOffset + 4,\n packet.length - 4)\n );\n\n this._onWrite(lenBytes);\n this._onWrite(encrypted);\n\n // TODO: look into storing seqno as 4-byte buffer and incrementing like we\n // do for AES-GCM IVs to avoid having to (re)write all 4 bytes every time\n mac = createHmac(this._macSSLName, this._macKey);\n writeUInt32BE(BUF_INT, this.outSeqno, 0);\n mac.update(BUF_INT);\n mac.update(lenBytes);\n mac.update(encrypted);\n } else {\n // Encrypt length field, pad length, payload, and padding\n const encrypted = this._cipherInstance.update(packet);\n this._onWrite(encrypted);\n\n // TODO: look into storing seqno as 4-byte buffer and incrementing like we\n // do for AES-GCM IVs to avoid having to (re)write all 4 bytes every time\n mac = createHmac(this._macSSLName, this._macKey);\n writeUInt32BE(BUF_INT, this.outSeqno, 0);\n mac.update(BUF_INT);\n mac.update(packet);\n }\n\n let digest = mac.digest();\n if (digest.length > this._macActualLen)\n digest = digest.slice(0, this._macActualLen);\n this._onWrite(digest);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass GenericCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encBlockLen = enc.cipherInfo.blockLen;\n this._macLen = enc.macInfo.len;\n this._macActualLen = enc.macInfo.actualLen;\n this._aadLen = (enc.macInfo.isETM ? 4 : 0);\n this._instance = new GenericCipher(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV,\n enc.macInfo.sslName,\n enc.macKey,\n enc.macInfo.isETM);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n const blockLen = this._encBlockLen;\n\n let pktLen = 4 + 1 + payloadLen;\n let padLen = blockLen - ((pktLen - this._aadLen) & (blockLen - 1));\n if (padLen < 4)\n padLen += blockLen;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + this._macLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet, this.outSeqno);\n\n if (this._macActualLen < this._macLen) {\n packet = new FastBuffer(packet.buffer,\n packet.byteOffset,\n (packet.length\n - (this._macLen - this._macActualLen)));\n }\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass NullDecipher {\n constructor(seqno, onPayload) {\n this.inSeqno = seqno;\n this._onPayload = onPayload;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n while (p < dataLen) {\n // Read packet length\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n\n if (this._lenBytes < 4)\n return;\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (4 + this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._packetPos < this._len) {\n const nb = Math.min(this._len - this._packetPos, dataLen - p);\n let chunk;\n if (p !== 0 || nb !== dataLen)\n chunk = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n chunk = data;\n if (nb === this._len) {\n this._packet = chunk;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(chunk, this._packetPos);\n }\n p += nb;\n this._packetPos += nb;\n if (this._packetPos < this._len)\n return;\n }\n\n const payload = (!this._packet\n ? EMPTY_BUFFER\n : new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length\n - this._packet[0] - 1));\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass ChaChaPolyDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decKeyMain = dec.decipherKey.slice(0, 32);\n this._decKeyPktLen = dec.decipherKey.slice(32);\n this._len = 0;\n this._lenBuf = Buffer.alloc(4);\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(16);\n this._calcMac = Buffer.allocUnsafe(16);\n this._macPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length\n if (this._lenPos < 4) {\n let nb = Math.min(4 - this._lenPos, dataLen - p);\n while (nb--)\n this._lenBuf[this._lenPos++] = data[p++];\n if (this._lenPos < 4)\n return;\n\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.inSeqno, 12);\n\n const decLenBytes =\n createDecipheriv('chacha20', this._decKeyPktLen, POLY1305_OUT_COMPUTE)\n .update(this._lenBuf);\n this._len = readUInt32BE(decLenBytes, 0);\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read Poly1305 MAC\n {\n const nb = Math.min(16 - this._macPos, dataLen - p);\n // TODO: avoid copying if entire MAC is in current chunk\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < 16)\n return;\n }\n\n // Generate Poly1305 key\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.inSeqno, 12);\n const polyKey =\n createCipheriv('chacha20', this._decKeyMain, POLY1305_OUT_COMPUTE)\n .update(POLY1305_ZEROS);\n\n // Calculate and compare Poly1305 MACs\n poly1305_auth(POLY1305_RESULT_MALLOC,\n this._lenBuf,\n 4,\n this._packet,\n this._packet.length,\n polyKey);\n\n this._calcMac.set(\n new Uint8Array(POLY1305_WASM_MODULE.HEAPU8.buffer,\n POLY1305_RESULT_MALLOC,\n 16),\n 0\n );\n if (!timingSafeEqual(this._calcMac, this._mac))\n throw new Error('Invalid MAC');\n\n // Decrypt packet\n POLY1305_OUT_COMPUTE[0] = 1; // Set counter to 1 (little endian)\n const packet =\n createDecipheriv('chacha20', this._decKeyMain, POLY1305_OUT_COMPUTE)\n .update(this._packet);\n\n const payload = new FastBuffer(packet.buffer,\n packet.byteOffset + 1,\n packet.length - packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass ChaChaPolyDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new ChaChaPolyDecipher(dec.decipherKey);\n this._len = 0;\n this._lenBuf = Buffer.alloc(4);\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(16);\n this._macPos = 0;\n }\n free() {\n this._instance.free();\n }\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length\n if (this._lenPos < 4) {\n let nb = Math.min(4 - this._lenPos, dataLen - p);\n while (nb--)\n this._lenBuf[this._lenPos++] = data[p++];\n if (this._lenPos < 4)\n return;\n\n this._len = this._instance.decryptLen(this._lenBuf, this.inSeqno);\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read Poly1305 MAC\n {\n const nb = Math.min(16 - this._macPos, dataLen - p);\n // TODO: avoid copying if entire MAC is in current chunk\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < 16)\n return;\n }\n\n this._instance.decrypt(this._packet, this._mac, this.inSeqno);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass AESGCMDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decipherInstance = null;\n this._decipherSSLName = dec.decipherInfo.sslName;\n this._decipherKey = dec.decipherKey;\n this._decipherIV = dec.decipherIV;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._tag = Buffer.allocUnsafe(16);\n this._tagPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length (unencrypted, but AAD)\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n if (this._lenBytes < 4)\n return;\n\n if ((this._len + 20) > MAX_PACKET_SIZE\n || this._len < 16\n || (this._len & 15) !== 0) {\n throw new Error('Bad packet length');\n }\n\n this._decipherInstance = createDecipheriv(\n this._decipherSSLName,\n this._decipherKey,\n this._decipherIV\n );\n this._decipherInstance.setAutoPadding(false);\n this._decipherInstance.setAAD(intToBytes(this._len));\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let decrypted;\n if (p !== 0 || nb !== dataLen) {\n decrypted = this._decipherInstance.update(\n new Uint8Array(data.buffer, data.byteOffset + p, nb)\n );\n } else {\n decrypted = this._decipherInstance.update(data);\n }\n if (decrypted.length) {\n if (nb === this._len) {\n this._packet = decrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(decrypted, this._packetPos);\n }\n this._packetPos += decrypted.length;\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read authentication tag\n {\n const nb = Math.min(16 - this._tagPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._tag.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._tagPos\n );\n } else {\n this._tag.set(data, this._tagPos);\n }\n p += nb;\n this._tagPos += nb;\n if (this._tagPos < 16)\n return;\n }\n\n {\n // Verify authentication tag\n this._decipherInstance.setAuthTag(this._tag);\n\n const decrypted = this._decipherInstance.final();\n\n // XXX: this should never output any data since stream ciphers always\n // return data from .update() and block ciphers must end on a multiple\n // of the block length, which would have caused an exception to be\n // thrown if the total input was not...\n if (decrypted.length) {\n if (this._packet)\n this._packet.set(decrypted, this._packetPos);\n else\n this._packet = decrypted;\n }\n }\n\n const payload = (!this._packet\n ? EMPTY_BUFFER\n : new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length\n - this._packet[0] - 1));\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n ivIncrement(this._decipherIV);\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._tagPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass AESGCMDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new AESGCMDecipher(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV);\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._pktLen = 0;\n this._tag = Buffer.allocUnsafe(16);\n this._tagPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length (unencrypted, but AAD)\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n if (this._lenBytes < 4)\n return;\n\n if ((this._len + 20) > MAX_PACKET_SIZE\n || this._len < 16\n || (this._len & 15) !== 0) {\n throw new Error(`Bad packet length: ${this._len}`);\n }\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read authentication tag\n {\n const nb = Math.min(16 - this._tagPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._tag.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._tagPos\n );\n } else {\n this._tag.set(data, this._tagPos);\n }\n p += nb;\n this._tagPos += nb;\n if (this._tagPos < 16)\n return;\n }\n\n this._instance.decrypt(this._packet, this._len, this._tag);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._pktLen = 0;\n this._tagPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\n// TODO: test incremental .update()s vs. copying to _packet and doing a single\n// .update() after entire packet read -- a single .update() would allow\n// verifying MAC before decrypting for ETM MACs\nclass GenericDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decipherInstance = createDecipheriv(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV);\n this._decipherInstance.setAutoPadding(false);\n this._block = Buffer.allocUnsafe(\n dec.macInfo.isETM ? 4 : dec.decipherInfo.blockLen\n );\n this._blockSize = dec.decipherInfo.blockLen;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(dec.macInfo.actualLen);\n this._macPos = 0;\n this._macSSLName = dec.macInfo.sslName;\n this._macKey = dec.macKey;\n this._macActualLen = dec.macInfo.actualLen;\n this._macETM = dec.macInfo.isETM;\n this._macInstance = null;\n\n const discardLen = dec.decipherInfo.discardLen;\n if (discardLen) {\n let discard = DISCARD_CACHE.get(discardLen);\n if (discard === undefined) {\n discard = Buffer.alloc(discardLen);\n DISCARD_CACHE.set(discardLen, discard);\n }\n this._decipherInstance.update(discard);\n }\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read first encrypted block\n if (this._blockPos < this._block.length) {\n const nb = Math.min(this._block.length - this._blockPos, dataLen - p);\n if (p !== 0 || nb !== dataLen || nb < data.length) {\n this._block.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._blockPos\n );\n } else {\n this._block.set(data, this._blockPos);\n }\n\n p += nb;\n this._blockPos += nb;\n if (this._blockPos < this._block.length)\n return;\n\n let decrypted;\n let need;\n if (this._macETM) {\n this._len = need = readUInt32BE(this._block, 0);\n } else {\n // Decrypt first block to get packet length\n decrypted = this._decipherInstance.update(this._block);\n this._len = readUInt32BE(decrypted, 0);\n need = 4 + this._len - this._blockSize;\n }\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 5\n || (need & (this._blockSize - 1)) !== 0) {\n throw new Error('Bad packet length');\n }\n\n // Create MAC up front to calculate in parallel with decryption\n this._macInstance = createHmac(this._macSSLName, this._macKey);\n\n writeUInt32BE(BUF_INT, this.inSeqno, 0);\n this._macInstance.update(BUF_INT);\n if (this._macETM) {\n this._macInstance.update(this._block);\n } else {\n this._macInstance.update(new Uint8Array(decrypted.buffer,\n decrypted.byteOffset,\n 4));\n this._pktLen = decrypted.length - 4;\n this._packetPos = this._pktLen;\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(\n new Uint8Array(decrypted.buffer,\n decrypted.byteOffset + 4,\n this._packetPos),\n 0\n );\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (this._macETM)\n this._macInstance.update(encrypted);\n const decrypted = this._decipherInstance.update(encrypted);\n if (decrypted.length) {\n if (nb === this._len) {\n this._packet = decrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(decrypted, this._packetPos);\n }\n this._packetPos += decrypted.length;\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read MAC\n {\n const nb = Math.min(this._macActualLen - this._macPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < this._macActualLen)\n return;\n }\n\n // Verify MAC\n if (!this._macETM)\n this._macInstance.update(this._packet);\n let calculated = this._macInstance.digest();\n if (this._macActualLen < calculated.length) {\n calculated = new Uint8Array(calculated.buffer,\n calculated.byteOffset,\n this._macActualLen);\n }\n if (!timingSafeEquals(calculated, this._mac))\n throw new Error('Invalid MAC');\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._macPos = 0;\n this._macInstance = null;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass GenericDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new GenericDecipher(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV,\n dec.macInfo.sslName,\n dec.macKey,\n dec.macInfo.isETM,\n dec.macInfo.actualLen);\n this._block = Buffer.allocUnsafe(\n dec.macInfo.isETM || dec.decipherInfo.stream\n ? 4\n : dec.decipherInfo.blockLen\n );\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(dec.macInfo.actualLen);\n this._macPos = 0;\n this._macActualLen = dec.macInfo.actualLen;\n this._macETM = dec.macInfo.isETM;\n }\n free() {\n this._instance.free();\n }\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read first encrypted block\n if (this._blockPos < this._block.length) {\n const nb = Math.min(this._block.length - this._blockPos, dataLen - p);\n if (p !== 0 || nb !== dataLen || nb < data.length) {\n this._block.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._blockPos\n );\n } else {\n this._block.set(data, this._blockPos);\n }\n\n p += nb;\n this._blockPos += nb;\n if (this._blockPos < this._block.length)\n return;\n\n let need;\n if (this._macETM) {\n this._len = need = readUInt32BE(this._block, 0);\n } else {\n // Decrypt first block to get packet length\n this._instance.decryptBlock(this._block);\n this._len = readUInt32BE(this._block, 0);\n need = 4 + this._len - this._block.length;\n }\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 5\n || (need & (this._block.length - 1)) !== 0) {\n throw new Error('Bad packet length');\n }\n\n if (!this._macETM) {\n this._pktLen = (this._block.length - 4);\n if (this._pktLen) {\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(\n new Uint8Array(this._block.buffer,\n this._block.byteOffset + 4,\n this._pktLen),\n 0\n );\n }\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read MAC\n {\n const nb = Math.min(this._macActualLen - this._macPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < this._macActualLen)\n return;\n }\n\n // Decrypt and verify MAC\n this._instance.decrypt(this._packet,\n this.inSeqno,\n this._block,\n this._mac);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n this._macInstance = null;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\n// Increments unsigned, big endian counter (last 8 bytes) of AES-GCM IV\nfunction ivIncrement(iv) {\n // eslint-disable-next-line no-unused-expressions\n ++iv[11] >>> 8\n && ++iv[10] >>> 8\n && ++iv[9] >>> 8\n && ++iv[8] >>> 8\n && ++iv[7] >>> 8\n && ++iv[6] >>> 8\n && ++iv[5] >>> 8\n && ++iv[4] >>> 8;\n}\n\nconst intToBytes = (() => {\n const ret = Buffer.alloc(4);\n return (n) => {\n ret[0] = (n >>> 24);\n ret[1] = (n >>> 16);\n ret[2] = (n >>> 8);\n ret[3] = n;\n return ret;\n };\n})();\n\nfunction timingSafeEquals(a, b) {\n if (a.length !== b.length) {\n timingSafeEqual(a, a);\n return false;\n }\n return timingSafeEqual(a, b);\n}\n\nfunction createCipher(config) {\n if (typeof config !== 'object' || config === null)\n throw new Error('Invalid config');\n\n if (typeof config.outbound !== 'object' || config.outbound === null)\n throw new Error('Invalid outbound');\n\n const outbound = config.outbound;\n\n if (typeof outbound.onWrite !== 'function')\n throw new Error('Invalid outbound.onWrite');\n\n if (typeof outbound.cipherInfo !== 'object' || outbound.cipherInfo === null)\n throw new Error('Invalid outbound.cipherInfo');\n\n if (!Buffer.isBuffer(outbound.cipherKey)\n || outbound.cipherKey.length !== outbound.cipherInfo.keyLen) {\n throw new Error('Invalid outbound.cipherKey');\n }\n\n if (outbound.cipherInfo.ivLen\n && (!Buffer.isBuffer(outbound.cipherIV)\n || outbound.cipherIV.length !== outbound.cipherInfo.ivLen)) {\n throw new Error('Invalid outbound.cipherIV');\n }\n\n if (typeof outbound.seqno !== 'number'\n || outbound.seqno < 0\n || outbound.seqno > MAX_SEQNO) {\n throw new Error('Invalid outbound.seqno');\n }\n\n const forceNative = !!outbound.forceNative;\n\n switch (outbound.cipherInfo.sslName) {\n case 'aes-128-gcm':\n case 'aes-256-gcm':\n return (AESGCMCipher && !forceNative\n ? new AESGCMCipherBinding(config)\n : new AESGCMCipherNative(config));\n case 'chacha20':\n return (ChaChaPolyCipher && !forceNative\n ? new ChaChaPolyCipherBinding(config)\n : new ChaChaPolyCipherNative(config));\n default: {\n if (typeof outbound.macInfo !== 'object' || outbound.macInfo === null)\n throw new Error('Invalid outbound.macInfo');\n if (!Buffer.isBuffer(outbound.macKey)\n || outbound.macKey.length !== outbound.macInfo.len) {\n throw new Error('Invalid outbound.macKey');\n }\n return (GenericCipher && !forceNative\n ? new GenericCipherBinding(config)\n : new GenericCipherNative(config));\n }\n }\n}\n\nfunction createDecipher(config) {\n if (typeof config !== 'object' || config === null)\n throw new Error('Invalid config');\n\n if (typeof config.inbound !== 'object' || config.inbound === null)\n throw new Error('Invalid inbound');\n\n const inbound = config.inbound;\n\n if (typeof inbound.onPayload !== 'function')\n throw new Error('Invalid inbound.onPayload');\n\n if (typeof inbound.decipherInfo !== 'object'\n || inbound.decipherInfo === null) {\n throw new Error('Invalid inbound.decipherInfo');\n }\n\n if (!Buffer.isBuffer(inbound.decipherKey)\n || inbound.decipherKey.length !== inbound.decipherInfo.keyLen) {\n throw new Error('Invalid inbound.decipherKey');\n }\n\n if (inbound.decipherInfo.ivLen\n && (!Buffer.isBuffer(inbound.decipherIV)\n || inbound.decipherIV.length !== inbound.decipherInfo.ivLen)) {\n throw new Error('Invalid inbound.decipherIV');\n }\n\n if (typeof inbound.seqno !== 'number'\n || inbound.seqno < 0\n || inbound.seqno > MAX_SEQNO) {\n throw new Error('Invalid inbound.seqno');\n }\n\n const forceNative = !!inbound.forceNative;\n\n switch (inbound.decipherInfo.sslName) {\n case 'aes-128-gcm':\n case 'aes-256-gcm':\n return (AESGCMDecipher && !forceNative\n ? new AESGCMDecipherBinding(config)\n : new AESGCMDecipherNative(config));\n case 'chacha20':\n return (ChaChaPolyDecipher && !forceNative\n ? new ChaChaPolyDecipherBinding(config)\n : new ChaChaPolyDecipherNative(config));\n default: {\n if (typeof inbound.macInfo !== 'object' || inbound.macInfo === null)\n throw new Error('Invalid inbound.macInfo');\n if (!Buffer.isBuffer(inbound.macKey)\n || inbound.macKey.length !== inbound.macInfo.len) {\n throw new Error('Invalid inbound.macKey');\n }\n return (GenericDecipher && !forceNative\n ? new GenericDecipherBinding(config)\n : new GenericDecipherNative(config));\n }\n }\n}\n\nmodule.exports = {\n CIPHER_INFO,\n MAC_INFO,\n bindingAvailable: !!binding,\n init: (() => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n try {\n POLY1305_WASM_MODULE = await require('./crypto/poly1305.js')();\n POLY1305_RESULT_MALLOC = POLY1305_WASM_MODULE._malloc(16);\n poly1305_auth = POLY1305_WASM_MODULE.cwrap(\n 'poly1305_auth',\n null,\n ['number', 'array', 'number', 'array', 'number', 'array']\n );\n } catch (ex) {\n return reject(ex);\n }\n resolve();\n });\n })(),\n\n NullCipher,\n createCipher,\n NullDecipher,\n createDecipher,\n};\n","\nvar createPoly1305 = (function() {\n var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;\n if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;\n return (\nfunction(createPoly1305) {\n createPoly1305 = createPoly1305 || {};\n\n\nvar b;b||(b=typeof createPoly1305 !== 'undefined' ? createPoly1305 : {});var q,r;b.ready=new Promise(function(a,c){q=a;r=c});var u={},w;for(w in b)b.hasOwnProperty(w)&&(u[w]=b[w]);var x=\"object\"===typeof window,y=\"function\"===typeof importScripts,z=\"object\"===typeof process&&\"object\"===typeof process.versions&&\"string\"===typeof process.versions.node,B=\"\",C,D,E,F,G;\nif(z)B=y?require(\"path\").dirname(B)+\"/\":__dirname+\"/\",C=function(a,c){var d=H(a);if(d)return c?d:d.toString();F||(F=require(\"fs\"));G||(G=require(\"path\"));a=G.normalize(a);return F.readFileSync(a,c?null:\"utf8\")},E=function(a){a=C(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},D=function(a,c,d){var e=H(a);e&&c(e);F||(F=require(\"fs\"));G||(G=require(\"path\"));a=G.normalize(a);F.readFile(a,function(f,l){f?d(f):c(l.buffer)})},1=m){var oa=g.charCodeAt(++v);m=65536+((m&1023)<<10)|oa&1023}if(127>=m){if(k>=n)break;h[k++]=m}else{if(2047>=m){if(k+1>=n)break;h[k++]=192|m>>6}else{if(65535>=m){if(k+2>=n)break;h[k++]=224|m>>12}else{if(k+3>=n)break;h[k++]=240|m>>18;h[k++]=128|m>>12&63}h[k++]=128|m>>6&63}h[k++]=128|m&63}}h[k]=\n0}}return p},array:function(g){var p=O(g.length);Q.set(g,p);return p}},l=N(a),A=[];a=0;if(e)for(var t=0;t=n);)++k;if(16h?n+=String.fromCharCode(h):(h-=65536,n+=String.fromCharCode(55296|h>>10,56320|h&1023))}}else n+=String.fromCharCode(h)}g=n}}else g=\"\";else g=\"boolean\"===c?!!g:g;return g}(d);0!==a&&fa(a);return d}var ea=\"undefined\"!==typeof TextDecoder?new TextDecoder(\"utf8\"):void 0,ha,Q,P;\nfunction ia(){var a=L.buffer;ha=a;b.HEAP8=Q=new Int8Array(a);b.HEAP16=new Int16Array(a);b.HEAP32=new Int32Array(a);b.HEAPU8=P=new Uint8Array(a);b.HEAPU16=new Uint16Array(a);b.HEAPU32=new Uint32Array(a);b.HEAPF32=new Float32Array(a);b.HEAPF64=new Float64Array(a)}var R,ja=[],ka=[],la=[];function ma(){var a=b.preRun.shift();ja.unshift(a)}var S=0,T=null,U=null;b.preloadedImages={};b.preloadedAudios={};\nfunction K(a){if(b.onAbort)b.onAbort(a);I(a);M=!0;a=new WebAssembly.RuntimeError(\"abort(\"+a+\"). Build with -s ASSERTIONS=1 for more info.\");r(a);throw a;}var V=\"data:application/octet-stream;base64,\",W;W=\"data:application/octet-stream;base64,AGFzbQEAAAABIAZgAX8Bf2ADf39/AGABfwBgAABgAAF/YAZ/f39/f38AAgcBAWEBYQAAAwsKAAEDAQAAAgQFAgQFAXABAQEFBwEBgAKAgAIGCQF/AUGAjMACCwclCQFiAgABYwADAWQACQFlAAgBZgAHAWcABgFoAAUBaQAKAWoBAAqGTQpPAQJ/QYAIKAIAIgEgAEEDakF8cSICaiEAAkAgAkEAIAAgAU0bDQAgAD8AQRB0SwRAIAAQAEUNAQtBgAggADYCACABDwtBhAhBMDYCAEF/C4wFAg5+Cn8gACgCJCEUIAAoAiAhFSAAKAIcIREgACgCGCESIAAoAhQhEyACQRBPBEAgAC0ATEVBGHQhFyAAKAIEIhZBBWytIQ8gACgCCCIYQQVsrSENIAAoAgwiGUEFbK0hCyAAKAIQIhpBBWytIQkgADUCACEIIBqtIRAgGa0hDiAYrSEMIBatIQoDQCASIAEtAAMiEiABLQAEQQh0ciABLQAFQRB0ciABLQAGIhZBGHRyQQJ2Qf///x9xaq0iAyAOfiABLwAAIAEtAAJBEHRyIBNqIBJBGHRBgICAGHFqrSIEIBB+fCARIAEtAAdBCHQgFnIgAS0ACEEQdHIgAS0ACSIRQRh0ckEEdkH///8fcWqtIgUgDH58IAEtAApBCHQgEXIgAS0AC0EQdHIgAS0ADEEYdHJBBnYgFWqtIgYgCn58IBQgF2ogAS8ADSABLQAPQRB0cmqtIgcgCH58IAMgDH4gBCAOfnwgBSAKfnwgBiAIfnwgByAJfnwgAyAKfiAEIAx+fCAFIAh+fCAGIAl+fCAHIAt+fCADIAh+IAQgCn58IAUgCX58IAYgC358IAcgDX58IAMgCX4gBCAIfnwgBSALfnwgBiANfnwgByAPfnwiA0IaiEL/////D4N8IgRCGohC/////w+DfCIFQhqIQv////8Pg3wiBkIaiEL/////D4N8IgdCGoinQQVsIAOnQf///x9xaiITQRp2IASnQf///x9xaiESIAWnQf///x9xIREgBqdB////H3EhFSAHp0H///8fcSEUIBNB////H3EhEyABQRBqIQEgAkEQayICQQ9LDQALCyAAIBQ2AiQgACAVNgIgIAAgETYCHCAAIBI2AhggACATNgIUCwMAAQu2BAEGfwJAIAAoAjgiBARAIABBPGohBQJAIAJBECAEayIDIAIgA0kbIgZFDQAgBkEDcSEHAkAgBkEBa0EDSQRAQQAhAwwBCyAGQXxxIQhBACEDA0AgBSADIARqaiABIANqLQAAOgAAIAUgA0EBciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0ECciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0EDciIEIAAoAjhqaiABIARqLQAAOgAAIANBBGohAyAAKAI4IQQgCEEEayIIDQALCyAHRQ0AA0AgBSADIARqaiABIANqLQAAOgAAIANBAWohAyAAKAI4IQQgB0EBayIHDQALCyAAIAQgBmoiAzYCOCADQRBJDQEgACAFQRAQAiAAQQA2AjggAiAGayECIAEgBmohAQsgAkEQTwRAIAAgASACQXBxIgMQAiACQQ9xIQIgASADaiEBCyACRQ0AIAJBA3EhBCAAQTxqIQVBACEDIAJBAWtBA08EQCACQXxxIQcDQCAFIAAoAjggA2pqIAEgA2otAAA6AAAgBSADQQFyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQJyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQNyIgYgACgCOGpqIAEgBmotAAA6AAAgA0EEaiEDIAdBBGsiBw0ACwsgBARAA0AgBSAAKAI4IANqaiABIANqLQAAOgAAIANBAWohAyAEQQFrIgQNAAsLIAAgACgCOCACajYCOAsLoS0BDH8jAEEQayIMJAACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAEH0AU0EQEGICCgCACIFQRAgAEELakF4cSAAQQtJGyIIQQN2IgJ2IgFBA3EEQCABQX9zQQFxIAJqIgNBA3QiAUG4CGooAgAiBEEIaiEAAkAgBCgCCCICIAFBsAhqIgFGBEBBiAggBUF+IAN3cTYCAAwBCyACIAE2AgwgASACNgIICyAEIANBA3QiAUEDcjYCBCABIARqIgEgASgCBEEBcjYCBAwNCyAIQZAIKAIAIgpNDQEgAQRAAkBBAiACdCIAQQAgAGtyIAEgAnRxIgBBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2aiIDQQN0IgBBuAhqKAIAIgQoAggiASAAQbAIaiIARgRAQYgIIAVBfiADd3EiBTYCAAwBCyABIAA2AgwgACABNgIICyAEQQhqIQAgBCAIQQNyNgIEIAQgCGoiAiADQQN0IgEgCGsiA0EBcjYCBCABIARqIAM2AgAgCgRAIApBA3YiAUEDdEGwCGohB0GcCCgCACEEAn8gBUEBIAF0IgFxRQRAQYgIIAEgBXI2AgAgBwwBCyAHKAIICyEBIAcgBDYCCCABIAQ2AgwgBCAHNgIMIAQgATYCCAtBnAggAjYCAEGQCCADNgIADA0LQYwIKAIAIgZFDQEgBkEAIAZrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QbgKaigCACIBKAIEQXhxIAhrIQMgASECA0ACQCACKAIQIgBFBEAgAigCFCIARQ0BCyAAKAIEQXhxIAhrIgIgAyACIANJIgIbIQMgACABIAIbIQEgACECDAELCyABIAhqIgkgAU0NAiABKAIYIQsgASABKAIMIgRHBEAgASgCCCIAQZgIKAIASRogACAENgIMIAQgADYCCAwMCyABQRRqIgIoAgAiAEUEQCABKAIQIgBFDQQgAUEQaiECCwNAIAIhByAAIgRBFGoiAigCACIADQAgBEEQaiECIAQoAhAiAA0ACyAHQQA2AgAMCwtBfyEIIABBv39LDQAgAEELaiIAQXhxIQhBjAgoAgAiCUUNAEEAIAhrIQMCQAJAAkACf0EAIAhBgAJJDQAaQR8gCEH///8HSw0AGiAAQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgCCAAQRVqdkEBcXJBHGoLIgVBAnRBuApqKAIAIgJFBEBBACEADAELQQAhACAIQQBBGSAFQQF2ayAFQR9GG3QhAQNAAkAgAigCBEF4cSAIayIHIANPDQAgAiEEIAciAw0AQQAhAyACIQAMAwsgACACKAIUIgcgByACIAFBHXZBBHFqKAIQIgJGGyAAIAcbIQAgAUEBdCEBIAINAAsLIAAgBHJFBEBBACEEQQIgBXQiAEEAIABrciAJcSIARQ0DIABBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2akECdEG4CmooAgAhAAsgAEUNAQsDQCAAKAIEQXhxIAhrIgEgA0khAiABIAMgAhshAyAAIAQgAhshBCAAKAIQIgEEfyABBSAAKAIUCyIADQALCyAERQ0AIANBkAgoAgAgCGtPDQAgBCAIaiIGIARNDQEgBCgCGCEFIAQgBCgCDCIBRwRAIAQoAggiAEGYCCgCAEkaIAAgATYCDCABIAA2AggMCgsgBEEUaiICKAIAIgBFBEAgBCgCECIARQ0EIARBEGohAgsDQCACIQcgACIBQRRqIgIoAgAiAA0AIAFBEGohAiABKAIQIgANAAsgB0EANgIADAkLIAhBkAgoAgAiAk0EQEGcCCgCACEDAkAgAiAIayIBQRBPBEBBkAggATYCAEGcCCADIAhqIgA2AgAgACABQQFyNgIEIAIgA2ogATYCACADIAhBA3I2AgQMAQtBnAhBADYCAEGQCEEANgIAIAMgAkEDcjYCBCACIANqIgAgACgCBEEBcjYCBAsgA0EIaiEADAsLIAhBlAgoAgAiBkkEQEGUCCAGIAhrIgE2AgBBoAhBoAgoAgAiAiAIaiIANgIAIAAgAUEBcjYCBCACIAhBA3I2AgQgAkEIaiEADAsLQQAhACAIQS9qIgkCf0HgCygCAARAQegLKAIADAELQewLQn83AgBB5AtCgKCAgICABDcCAEHgCyAMQQxqQXBxQdiq1aoFczYCAEH0C0EANgIAQcQLQQA2AgBBgCALIgFqIgVBACABayIHcSICIAhNDQpBwAsoAgAiBARAQbgLKAIAIgMgAmoiASADTQ0LIAEgBEsNCwtBxAstAABBBHENBQJAAkBBoAgoAgAiAwRAQcgLIQADQCADIAAoAgAiAU8EQCABIAAoAgRqIANLDQMLIAAoAggiAA0ACwtBABABIgFBf0YNBiACIQVB5AsoAgAiA0EBayIAIAFxBEAgAiABayAAIAFqQQAgA2txaiEFCyAFIAhNDQYgBUH+////B0sNBkHACygCACIEBEBBuAsoAgAiAyAFaiIAIANNDQcgACAESw0HCyAFEAEiACABRw0BDAgLIAUgBmsgB3EiBUH+////B0sNBSAFEAEiASAAKAIAIAAoAgRqRg0EIAEhAAsCQCAAQX9GDQAgCEEwaiAFTQ0AQegLKAIAIgEgCSAFa2pBACABa3EiAUH+////B0sEQCAAIQEMCAsgARABQX9HBEAgASAFaiEFIAAhAQwIC0EAIAVrEAEaDAULIAAiAUF/Rw0GDAQLAAtBACEEDAcLQQAhAQwFCyABQX9HDQILQcQLQcQLKAIAQQRyNgIACyACQf7///8HSw0BIAIQASEBQQAQASEAIAFBf0YNASAAQX9GDQEgACABTQ0BIAAgAWsiBSAIQShqTQ0BC0G4C0G4CygCACAFaiIANgIAQbwLKAIAIABJBEBBvAsgADYCAAsCQAJAAkBBoAgoAgAiBwRAQcgLIQADQCABIAAoAgAiAyAAKAIEIgJqRg0CIAAoAggiAA0ACwwCC0GYCCgCACIAQQAgACABTRtFBEBBmAggATYCAAtBACEAQcwLIAU2AgBByAsgATYCAEGoCEF/NgIAQawIQeALKAIANgIAQdQLQQA2AgADQCAAQQN0IgNBuAhqIANBsAhqIgI2AgAgA0G8CGogAjYCACAAQQFqIgBBIEcNAAtBlAggBUEoayIDQXggAWtBB3FBACABQQhqQQdxGyIAayICNgIAQaAIIAAgAWoiADYCACAAIAJBAXI2AgQgASADakEoNgIEQaQIQfALKAIANgIADAILIAAtAAxBCHENACADIAdLDQAgASAHTQ0AIAAgAiAFajYCBEGgCCAHQXggB2tBB3FBACAHQQhqQQdxGyIAaiICNgIAQZQIQZQIKAIAIAVqIgEgAGsiADYCACACIABBAXI2AgQgASAHakEoNgIEQaQIQfALKAIANgIADAELQZgIKAIAIAFLBEBBmAggATYCAAsgASAFaiECQcgLIQACQAJAAkACQAJAAkADQCACIAAoAgBHBEAgACgCCCIADQEMAgsLIAAtAAxBCHFFDQELQcgLIQADQCAHIAAoAgAiAk8EQCACIAAoAgRqIgQgB0sNAwsgACgCCCEADAALAAsgACABNgIAIAAgACgCBCAFajYCBCABQXggAWtBB3FBACABQQhqQQdxG2oiCSAIQQNyNgIEIAJBeCACa0EHcUEAIAJBCGpBB3EbaiIFIAggCWoiBmshAiAFIAdGBEBBoAggBjYCAEGUCEGUCCgCACACaiIANgIAIAYgAEEBcjYCBAwDCyAFQZwIKAIARgRAQZwIIAY2AgBBkAhBkAgoAgAgAmoiADYCACAGIABBAXI2AgQgACAGaiAANgIADAMLIAUoAgQiAEEDcUEBRgRAIABBeHEhBwJAIABB/wFNBEAgBSgCCCIDIABBA3YiAEEDdEGwCGpGGiADIAUoAgwiAUYEQEGICEGICCgCAEF+IAB3cTYCAAwCCyADIAE2AgwgASADNgIIDAELIAUoAhghCAJAIAUgBSgCDCIBRwRAIAUoAggiACABNgIMIAEgADYCCAwBCwJAIAVBFGoiACgCACIDDQAgBUEQaiIAKAIAIgMNAEEAIQEMAQsDQCAAIQQgAyIBQRRqIgAoAgAiAw0AIAFBEGohACABKAIQIgMNAAsgBEEANgIACyAIRQ0AAkAgBSAFKAIcIgNBAnRBuApqIgAoAgBGBEAgACABNgIAIAENAUGMCEGMCCgCAEF+IAN3cTYCAAwCCyAIQRBBFCAIKAIQIAVGG2ogATYCACABRQ0BCyABIAg2AhggBSgCECIABEAgASAANgIQIAAgATYCGAsgBSgCFCIARQ0AIAEgADYCFCAAIAE2AhgLIAUgB2ohBSACIAdqIQILIAUgBSgCBEF+cTYCBCAGIAJBAXI2AgQgAiAGaiACNgIAIAJB/wFNBEAgAkEDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwDC0EfIQAgAkH///8HTQRAIAJBCHYiACAAQYD+P2pBEHZBCHEiA3QiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASADciAAcmsiAEEBdCACIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQQCQEGMCCgCACIDQQEgAHQiAXFFBEBBjAggASADcjYCACAEIAY2AgAgBiAENgIYDAELIAJBAEEZIABBAXZrIABBH0YbdCEAIAQoAgAhAQNAIAEiAygCBEF4cSACRg0DIABBHXYhASAAQQF0IQAgAyABQQRxaiIEKAIQIgENAAsgBCAGNgIQIAYgAzYCGAsgBiAGNgIMIAYgBjYCCAwCC0GUCCAFQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBBoAggACABaiIANgIAIAAgAkEBcjYCBCABIANqQSg2AgRBpAhB8AsoAgA2AgAgByAEQScgBGtBB3FBACAEQSdrQQdxG2pBL2siACAAIAdBEGpJGyICQRs2AgQgAkHQCykCADcCECACQcgLKQIANwIIQdALIAJBCGo2AgBBzAsgBTYCAEHICyABNgIAQdQLQQA2AgAgAkEYaiEAA0AgAEEHNgIEIABBCGohASAAQQRqIQAgASAESQ0ACyACIAdGDQMgAiACKAIEQX5xNgIEIAcgAiAHayIEQQFyNgIEIAIgBDYCACAEQf8BTQRAIARBA3YiAEEDdEGwCGohAgJ/QYgIKAIAIgFBASAAdCIAcUUEQEGICCAAIAFyNgIAIAIMAQsgAigCCAshACACIAc2AgggACAHNgIMIAcgAjYCDCAHIAA2AggMBAtBHyEAIAdCADcCECAEQf///wdNBEAgBEEIdiIAIABBgP4/akEQdkEIcSICdCIAIABBgOAfakEQdkEEcSIBdCIAIABBgIAPakEQdkECcSIAdEEPdiABIAJyIAByayIAQQF0IAQgAEEVanZBAXFyQRxqIQALIAcgADYCHCAAQQJ0QbgKaiEDAkBBjAgoAgAiAkEBIAB0IgFxRQRAQYwIIAEgAnI2AgAgAyAHNgIAIAcgAzYCGAwBCyAEQQBBGSAAQQF2ayAAQR9GG3QhACADKAIAIQEDQCABIgIoAgRBeHEgBEYNBCAAQR12IQEgAEEBdCEAIAIgAUEEcWoiAygCECIBDQALIAMgBzYCECAHIAI2AhgLIAcgBzYCDCAHIAc2AggMAwsgAygCCCIAIAY2AgwgAyAGNgIIIAZBADYCGCAGIAM2AgwgBiAANgIICyAJQQhqIQAMBQsgAigCCCIAIAc2AgwgAiAHNgIIIAdBADYCGCAHIAI2AgwgByAANgIIC0GUCCgCACIAIAhNDQBBlAggACAIayIBNgIAQaAIQaAIKAIAIgIgCGoiADYCACAAIAFBAXI2AgQgAiAIQQNyNgIEIAJBCGohAAwDC0GECEEwNgIAQQAhAAwCCwJAIAVFDQACQCAEKAIcIgJBAnRBuApqIgAoAgAgBEYEQCAAIAE2AgAgAQ0BQYwIIAlBfiACd3EiCTYCAAwCCyAFQRBBFCAFKAIQIARGG2ogATYCACABRQ0BCyABIAU2AhggBCgCECIABEAgASAANgIQIAAgATYCGAsgBCgCFCIARQ0AIAEgADYCFCAAIAE2AhgLAkAgA0EPTQRAIAQgAyAIaiIAQQNyNgIEIAAgBGoiACAAKAIEQQFyNgIEDAELIAQgCEEDcjYCBCAGIANBAXI2AgQgAyAGaiADNgIAIANB/wFNBEAgA0EDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwBC0EfIQAgA0H///8HTQRAIANBCHYiACAAQYD+P2pBEHZBCHEiAnQiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASACciAAcmsiAEEBdCADIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQICQAJAIAlBASAAdCIBcUUEQEGMCCABIAlyNgIAIAIgBjYCACAGIAI2AhgMAQsgA0EAQRkgAEEBdmsgAEEfRht0IQAgAigCACEIA0AgCCIBKAIEQXhxIANGDQIgAEEddiECIABBAXQhACABIAJBBHFqIgIoAhAiCA0ACyACIAY2AhAgBiABNgIYCyAGIAY2AgwgBiAGNgIIDAELIAEoAggiACAGNgIMIAEgBjYCCCAGQQA2AhggBiABNgIMIAYgADYCCAsgBEEIaiEADAELAkAgC0UNAAJAIAEoAhwiAkECdEG4CmoiACgCACABRgRAIAAgBDYCACAEDQFBjAggBkF+IAJ3cTYCAAwCCyALQRBBFCALKAIQIAFGG2ogBDYCACAERQ0BCyAEIAs2AhggASgCECIABEAgBCAANgIQIAAgBDYCGAsgASgCFCIARQ0AIAQgADYCFCAAIAQ2AhgLAkAgA0EPTQRAIAEgAyAIaiIAQQNyNgIEIAAgAWoiACAAKAIEQQFyNgIEDAELIAEgCEEDcjYCBCAJIANBAXI2AgQgAyAJaiADNgIAIAoEQCAKQQN2IgBBA3RBsAhqIQRBnAgoAgAhAgJ/QQEgAHQiACAFcUUEQEGICCAAIAVyNgIAIAQMAQsgBCgCCAshACAEIAI2AgggACACNgIMIAIgBDYCDCACIAA2AggLQZwIIAk2AgBBkAggAzYCAAsgAUEIaiEACyAMQRBqJAAgAAsQACMAIABrQXBxIgAkACAACwYAIAAkAAsEACMAC4AJAgh/BH4jAEGQAWsiBiQAIAYgBS0AA0EYdEGAgIAYcSAFLwAAIAUtAAJBEHRycjYCACAGIAUoAANBAnZBg/7/H3E2AgQgBiAFKAAGQQR2Qf+B/x9xNgIIIAYgBSgACUEGdkH//8AfcTYCDCAFLwANIQggBS0ADyEJIAZCADcCFCAGQgA3AhwgBkEANgIkIAYgCCAJQRB0QYCAPHFyNgIQIAYgBSgAEDYCKCAGIAUoABQ2AiwgBiAFKAAYNgIwIAUoABwhBSAGQQA6AEwgBkEANgI4IAYgBTYCNCAGIAEgAhAEIAQEQCAGIAMgBBAECyAGKAI4IgEEQCAGQTxqIgIgAWpBAToAACABQQFqQQ9NBEAgASAGakE9aiEEAkBBDyABayIDRQ0AIAMgBGoiAUEBa0EAOgAAIARBADoAACADQQNJDQAgAUECa0EAOgAAIARBADoAASABQQNrQQA6AAAgBEEAOgACIANBB0kNACABQQRrQQA6AAAgBEEAOgADIANBCUkNACAEQQAgBGtBA3EiAWoiBEEANgIAIAQgAyABa0F8cSIBaiIDQQRrQQA2AgAgAUEJSQ0AIARBADYCCCAEQQA2AgQgA0EIa0EANgIAIANBDGtBADYCACABQRlJDQAgBEEANgIYIARBADYCFCAEQQA2AhAgBEEANgIMIANBEGtBADYCACADQRRrQQA2AgAgA0EYa0EANgIAIANBHGtBADYCACABIARBBHFBGHIiAWsiA0EgSQ0AIAEgBGohAQNAIAFCADcDGCABQgA3AxAgAUIANwMIIAFCADcDACABQSBqIQEgA0EgayIDQR9LDQALCwsgBkEBOgBMIAYgAkEQEAILIAY1AjQhECAGNQIwIREgBjUCLCEOIAAgBjUCKCAGKAIkIAYoAiAgBigCHCAGKAIYIgNBGnZqIgJBGnZqIgFBGnZqIgtBgICAYHIgAUH///8fcSINIAJB////H3EiCCAGKAIUIAtBGnZBBWxqIgFB////H3EiCUEFaiIFQRp2IANB////H3EgAUEadmoiA2oiAUEadmoiAkEadmoiBEEadmoiDEEfdSIHIANxIAEgDEEfdkEBayIDQf///x9xIgpxciIBQRp0IAUgCnEgByAJcXJyrXwiDzwAACAAIA9CGIg8AAMgACAPQhCIPAACIAAgD0IIiDwAASAAIA4gByAIcSACIApxciICQRR0IAFBBnZyrXwgD0IgiHwiDjwABCAAIA5CGIg8AAcgACAOQhCIPAAGIAAgDkIIiDwABSAAIBEgByANcSAEIApxciIBQQ50IAJBDHZyrXwgDkIgiHwiDjwACCAAIA5CGIg8AAsgACAOQhCIPAAKIAAgDkIIiDwACSAAIBAgAyAMcSAHIAtxckEIdCABQRJ2cq18IA5CIIh8Ig48AAwgACAOQhiIPAAPIAAgDkIQiDwADiAAIA5CCIg8AA0gBkIANwIwIAZCADcCKCAGQgA3AiAgBkIANwIYIAZCADcCECAGQgA3AgggBkIANwIAIAZBkAFqJAALpwwBB38CQCAARQ0AIABBCGsiAyAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQNxRQ0BIAMgAygCACIBayIDQZgIKAIASQ0BIAAgAWohACADQZwIKAIARwRAIAFB/wFNBEAgAygCCCICIAFBA3YiBEEDdEGwCGpGGiACIAMoAgwiAUYEQEGICEGICCgCAEF+IAR3cTYCAAwDCyACIAE2AgwgASACNgIIDAILIAMoAhghBgJAIAMgAygCDCIBRwRAIAMoAggiAiABNgIMIAEgAjYCCAwBCwJAIANBFGoiAigCACIEDQAgA0EQaiICKAIAIgQNAEEAIQEMAQsDQCACIQcgBCIBQRRqIgIoAgAiBA0AIAFBEGohAiABKAIQIgQNAAsgB0EANgIACyAGRQ0BAkAgAyADKAIcIgJBAnRBuApqIgQoAgBGBEAgBCABNgIAIAENAUGMCEGMCCgCAEF+IAJ3cTYCAAwDCyAGQRBBFCAGKAIQIANGG2ogATYCACABRQ0CCyABIAY2AhggAygCECICBEAgASACNgIQIAIgATYCGAsgAygCFCICRQ0BIAEgAjYCFCACIAE2AhgMAQsgBSgCBCIBQQNxQQNHDQBBkAggADYCACAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAA8LIAMgBU8NACAFKAIEIgFBAXFFDQACQCABQQJxRQRAIAVBoAgoAgBGBEBBoAggAzYCAEGUCEGUCCgCACAAaiIANgIAIAMgAEEBcjYCBCADQZwIKAIARw0DQZAIQQA2AgBBnAhBADYCAA8LIAVBnAgoAgBGBEBBnAggAzYCAEGQCEGQCCgCACAAaiIANgIAIAMgAEEBcjYCBCAAIANqIAA2AgAPCyABQXhxIABqIQACQCABQf8BTQRAIAUoAggiAiABQQN2IgRBA3RBsAhqRhogAiAFKAIMIgFGBEBBiAhBiAgoAgBBfiAEd3E2AgAMAgsgAiABNgIMIAEgAjYCCAwBCyAFKAIYIQYCQCAFIAUoAgwiAUcEQCAFKAIIIgJBmAgoAgBJGiACIAE2AgwgASACNgIIDAELAkAgBUEUaiICKAIAIgQNACAFQRBqIgIoAgAiBA0AQQAhAQwBCwNAIAIhByAEIgFBFGoiAigCACIEDQAgAUEQaiECIAEoAhAiBA0ACyAHQQA2AgALIAZFDQACQCAFIAUoAhwiAkECdEG4CmoiBCgCAEYEQCAEIAE2AgAgAQ0BQYwIQYwIKAIAQX4gAndxNgIADAILIAZBEEEUIAYoAhAgBUYbaiABNgIAIAFFDQELIAEgBjYCGCAFKAIQIgIEQCABIAI2AhAgAiABNgIYCyAFKAIUIgJFDQAgASACNgIUIAIgATYCGAsgAyAAQQFyNgIEIAAgA2ogADYCACADQZwIKAIARw0BQZAIIAA2AgAPCyAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAAsgAEH/AU0EQCAAQQN2IgFBA3RBsAhqIQACf0GICCgCACICQQEgAXQiAXFFBEBBiAggASACcjYCACAADAELIAAoAggLIQIgACADNgIIIAIgAzYCDCADIAA2AgwgAyACNgIIDwtBHyECIANCADcCECAAQf///wdNBEAgAEEIdiIBIAFBgP4/akEQdkEIcSIBdCICIAJBgOAfakEQdkEEcSICdCIEIARBgIAPakEQdkECcSIEdEEPdiABIAJyIARyayIBQQF0IAAgAUEVanZBAXFyQRxqIQILIAMgAjYCHCACQQJ0QbgKaiEBAkACQAJAQYwIKAIAIgRBASACdCIHcUUEQEGMCCAEIAdyNgIAIAEgAzYCACADIAE2AhgMAQsgAEEAQRkgAkEBdmsgAkEfRht0IQIgASgCACEBA0AgASIEKAIEQXhxIABGDQIgAkEddiEBIAJBAXQhAiAEIAFBBHFqIgdBEGooAgAiAQ0ACyAHIAM2AhAgAyAENgIYCyADIAM2AgwgAyADNgIIDAELIAQoAggiACADNgIMIAQgAzYCCCADQQA2AhggAyAENgIMIAMgADYCCAtBqAhBqAgoAgBBAWsiAEF/IAAbNgIACwsLCQEAQYEICwIGUA==\";if(!W.startsWith(V)){var na=W;W=b.locateFile?b.locateFile(na,B):B+na}function pa(){var a=W;try{if(a==W&&J)return new Uint8Array(J);var c=H(a);if(c)return c;if(E)return E(a);throw\"both async and sync fetching of the wasm failed\";}catch(d){K(d)}}\nfunction qa(){if(!J&&(x||y)){if(\"function\"===typeof fetch&&!W.startsWith(\"file://\"))return fetch(W,{credentials:\"same-origin\"}).then(function(a){if(!a.ok)throw\"failed to load wasm binary file at '\"+W+\"'\";return a.arrayBuffer()}).catch(function(){return pa()});if(D)return new Promise(function(a,c){D(W,function(d){a(new Uint8Array(d))},c)})}return Promise.resolve().then(function(){return pa()})}\nfunction X(a){for(;0>4;f=(f&15)<<4|l>>2;var t=(l&3)<<6|A;c+=String.fromCharCode(e);64!==l&&(c+=String.fromCharCode(f));64!==A&&(c+=String.fromCharCode(t))}while(d>>=0;if(2147483648=d;d*=2){var e=c*(1+.2/d);e=Math.min(e,a+100663296);e=Math.max(a,e);0>>16);ia();var f=1;break a}catch(l){}f=void 0}if(f)return!0}return!1}};\n(function(){function a(f){b.asm=f.exports;L=b.asm.b;ia();R=b.asm.j;ka.unshift(b.asm.c);S--;b.monitorRunDependencies&&b.monitorRunDependencies(S);0==S&&(null!==T&&(clearInterval(T),T=null),U&&(f=U,U=null,f()))}function c(f){a(f.instance)}function d(f){return qa().then(function(l){return WebAssembly.instantiate(l,e)}).then(f,function(l){I(\"failed to asynchronously prepare wasm: \"+l);K(l)})}var e={a:sa};S++;b.monitorRunDependencies&&b.monitorRunDependencies(S);if(b.instantiateWasm)try{return b.instantiateWasm(e,\na)}catch(f){return I(\"Module.instantiateWasm callback failed with error: \"+f),!1}(function(){return J||\"function\"!==typeof WebAssembly.instantiateStreaming||W.startsWith(V)||W.startsWith(\"file://\")||\"function\"!==typeof fetch?d(c):fetch(W,{credentials:\"same-origin\"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(c,function(l){I(\"wasm streaming compile failed: \"+l);I(\"falling back to ArrayBuffer instantiation\");return d(c)})})})().catch(r);return{}})();\nb.___wasm_call_ctors=function(){return(b.___wasm_call_ctors=b.asm.c).apply(null,arguments)};b._poly1305_auth=function(){return(b._poly1305_auth=b.asm.d).apply(null,arguments)};var da=b.stackSave=function(){return(da=b.stackSave=b.asm.e).apply(null,arguments)},fa=b.stackRestore=function(){return(fa=b.stackRestore=b.asm.f).apply(null,arguments)},O=b.stackAlloc=function(){return(O=b.stackAlloc=b.asm.g).apply(null,arguments)};b._malloc=function(){return(b._malloc=b.asm.h).apply(null,arguments)};\nb._free=function(){return(b._free=b.asm.i).apply(null,arguments)};b.cwrap=function(a,c,d,e){d=d||[];var f=d.every(function(l){return\"number\"===l});return\"string\"!==c&&f&&!e?N(a):function(){return ca(a,c,d,arguments)}};var Y;U=function ta(){Y||Z();Y||(U=ta)};\nfunction Z(){function a(){if(!Y&&(Y=!0,b.calledRun=!0,!M)){X(ka);q(b);if(b.onRuntimeInitialized)b.onRuntimeInitialized();if(b.postRun)for(\"function\"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var c=b.postRun.shift();la.unshift(c)}X(la)}}if(!(0 {\n // eslint-disable-next-line prefer-const\n for (let [type, handler] of Object.entries(handlers)) {\n type = +type;\n if (isFinite(type) && type >= 0 && type < MESSAGE_HANDLERS.length)\n MESSAGE_HANDLERS[type] = handler;\n }\n});\n\nmodule.exports = MESSAGE_HANDLERS;\n","'use strict';\n\nconst {\n bufferSlice,\n bufferParser,\n doFatalError,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst {\n CHANNEL_OPEN_FAILURE,\n COMPAT,\n MESSAGE,\n TERMINAL_MODE,\n} = require('./constants.js');\n\nconst {\n parseKey,\n} = require('./keyParser.js');\n\nconst TERMINAL_MODE_BY_VALUE =\n Array.from(Object.entries(TERMINAL_MODE))\n .reduce((obj, [key, value]) => ({ ...obj, [key]: value }), {});\n\nmodule.exports = {\n // Transport layer protocol ==================================================\n [MESSAGE.DISCONNECT]: (self, payload) => {\n /*\n byte SSH_MSG_DISCONNECT\n uint32 reason code\n string description in ISO-10646 UTF-8 encoding\n string language tag\n */\n bufferParser.init(payload, 1);\n const reason = bufferParser.readUInt32BE();\n const desc = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed DISCONNECT packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: Received DISCONNECT (${reason}, \"${desc}\")`\n );\n\n const handler = self._handlers.DISCONNECT;\n handler && handler(self, reason, desc);\n },\n [MESSAGE.IGNORE]: (self, payload) => {\n /*\n byte SSH_MSG_IGNORE\n string data\n */\n self._debug && self._debug('Inbound: Received IGNORE');\n },\n [MESSAGE.UNIMPLEMENTED]: (self, payload) => {\n /*\n byte SSH_MSG_UNIMPLEMENTED\n uint32 packet sequence number of rejected message\n */\n bufferParser.init(payload, 1);\n const seqno = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (seqno === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed UNIMPLEMENTED packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: Received UNIMPLEMENTED (seqno ${seqno})`);\n },\n [MESSAGE.DEBUG]: (self, payload) => {\n /*\n byte SSH_MSG_DEBUG\n boolean always_display\n string message in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const display = bufferParser.readBool();\n const msg = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed DEBUG packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received DEBUG');\n\n const handler = self._handlers.DEBUG;\n handler && handler(self, display, msg);\n },\n [MESSAGE.SERVICE_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_SERVICE_REQUEST\n string service name\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n bufferParser.clear();\n\n if (name === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed SERVICE_REQUEST packet'\n );\n }\n\n self._debug && self._debug(`Inbound: Received SERVICE_REQUEST (${name})`);\n\n const handler = self._handlers.SERVICE_REQUEST;\n handler && handler(self, name);\n },\n [MESSAGE.SERVICE_ACCEPT]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_SERVICE_ACCEPT\n string service name\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n bufferParser.clear();\n\n if (name === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed SERVICE_ACCEPT packet'\n );\n }\n\n self._debug && self._debug(`Inbound: Received SERVICE_ACCEPT (${name})`);\n\n const handler = self._handlers.SERVICE_ACCEPT;\n handler && handler(self, name);\n },\n\n // User auth protocol -- generic =============================================\n [MESSAGE.USERAUTH_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_USERAUTH_REQUEST\n string user name in ISO-10646 UTF-8 encoding [RFC3629]\n string service name in US-ASCII\n string method name in US-ASCII\n .... method specific fields\n */\n bufferParser.init(payload, 1);\n const user = bufferParser.readString(true);\n const service = bufferParser.readString(true);\n const method = bufferParser.readString(true);\n let methodData;\n let methodDesc;\n switch (method) {\n case 'none':\n methodData = null;\n break;\n case 'password': {\n /*\n boolean \n string plaintext password in ISO-10646 UTF-8 encoding [RFC3629]\n [string new password]\n */\n const isChange = bufferParser.readBool();\n if (isChange !== undefined) {\n methodData = bufferParser.readString(true);\n if (methodData !== undefined && isChange) {\n const newPassword = bufferParser.readString(true);\n if (newPassword !== undefined)\n methodData = { oldPassword: methodData, newPassword };\n else\n methodData = undefined;\n }\n }\n break;\n }\n case 'publickey': {\n /*\n boolean \n string public key algorithm name\n string public key blob\n [string signature]\n */\n const hasSig = bufferParser.readBool();\n if (hasSig !== undefined) {\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n if (hasSig) {\n const blobEnd = bufferParser.pos();\n let signature = bufferParser.readString();\n if (signature !== undefined) {\n if (signature.length > (4 + keyAlgo.length + 4)\n && signature.utf8Slice(4, 4 + keyAlgo.length) === keyAlgo) {\n // Skip algoLen + algo + sigLen\n signature = bufferSlice(signature, 4 + keyAlgo.length + 4);\n }\n\n signature = sigSSHToASN1(signature, keyAlgo);\n if (signature) {\n const sessionID = self._kex.sessionID;\n const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);\n writeUInt32BE(blob, sessionID.length, 0);\n blob.set(sessionID, 4);\n blob.set(\n new Uint8Array(payload.buffer, payload.byteOffset, blobEnd),\n 4 + sessionID.length\n );\n methodData = {\n keyAlgo,\n key,\n signature,\n blob,\n };\n }\n }\n } else {\n methodData = { keyAlgo, key };\n methodDesc = 'publickey -- check';\n }\n }\n break;\n }\n case 'hostbased': {\n /*\n string public key algorithm for host key\n string public host key and certificates for client host\n string client host name expressed as the FQDN in US-ASCII\n string user name on the client host in ISO-10646 UTF-8 encoding\n [RFC3629]\n string signature\n */\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n const localHostname = bufferParser.readString(true);\n const localUsername = bufferParser.readString(true);\n\n const blobEnd = bufferParser.pos();\n let signature = bufferParser.readString();\n if (signature !== undefined) {\n if (signature.length > (4 + keyAlgo.length + 4)\n && signature.utf8Slice(4, 4 + keyAlgo.length) === keyAlgo) {\n // Skip algoLen + algo + sigLen\n signature = bufferSlice(signature, 4 + keyAlgo.length + 4);\n }\n\n signature = sigSSHToASN1(signature, keyAlgo);\n if (signature !== undefined) {\n const sessionID = self._kex.sessionID;\n const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);\n writeUInt32BE(blob, sessionID.length, 0);\n blob.set(sessionID, 4);\n blob.set(\n new Uint8Array(payload.buffer, payload.byteOffset, blobEnd),\n 4 + sessionID.length\n );\n methodData = {\n keyAlgo,\n key,\n signature,\n blob,\n localHostname,\n localUsername,\n };\n }\n }\n break;\n }\n case 'keyboard-interactive':\n /*\n string language tag (as defined in [RFC-3066])\n string submethods (ISO-10646 UTF-8)\n */\n // Skip/ignore language field -- it's deprecated in RFC 4256\n bufferParser.skipString();\n\n methodData = bufferParser.readList();\n break;\n default:\n if (method !== undefined)\n methodData = bufferParser.readRaw();\n }\n bufferParser.clear();\n\n if (methodData === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_REQUEST packet'\n );\n }\n\n if (methodDesc === undefined)\n methodDesc = method;\n\n self._authsQueue.push(method);\n\n self._debug\n && self._debug(`Inbound: Received USERAUTH_REQUEST (${methodDesc})`);\n\n const handler = self._handlers.USERAUTH_REQUEST;\n handler && handler(self, user, service, method, methodData);\n },\n [MESSAGE.USERAUTH_FAILURE]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_FAILURE\n name-list authentications that can continue\n boolean partial success\n */\n bufferParser.init(payload, 1);\n const authMethods = bufferParser.readList();\n const partialSuccess = bufferParser.readBool();\n bufferParser.clear();\n\n if (partialSuccess === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_FAILURE packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: Received USERAUTH_FAILURE (${authMethods})`);\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_FAILURE;\n handler && handler(self, authMethods, partialSuccess);\n },\n [MESSAGE.USERAUTH_SUCCESS]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_SUCCESS\n */\n self._debug && self._debug('Inbound: Received USERAUTH_SUCCESS');\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_SUCCESS;\n handler && handler(self);\n },\n [MESSAGE.USERAUTH_BANNER]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_BANNER\n string message in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const msg = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_BANNER packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_BANNER');\n\n const handler = self._handlers.USERAUTH_BANNER;\n handler && handler(self, msg);\n },\n\n // User auth protocol -- method-specific =====================================\n 60: (self, payload) => {\n if (!self._authsQueue.length) {\n self._debug\n && self._debug('Inbound: Received payload type 60 without auth');\n return;\n }\n\n switch (self._authsQueue[0]) {\n case 'password': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_PASSWD_CHANGEREQ\n string prompt in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const prompt = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet'\n );\n }\n\n self._debug\n && self._debug('Inbound: Received USERAUTH_PASSWD_CHANGEREQ');\n\n const handler = self._handlers.USERAUTH_PASSWD_CHANGEREQ;\n handler && handler(self, prompt);\n break;\n }\n case 'publickey': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_PK_OK\n string public key algorithm name from the request\n string public key blob from the request\n */\n bufferParser.init(payload, 1);\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n bufferParser.clear();\n\n if (key === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_PK_OK packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_PK_OK');\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_PK_OK;\n handler && handler(self, keyAlgo, key);\n break;\n }\n case 'keyboard-interactive': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_INFO_REQUEST\n string name (ISO-10646 UTF-8)\n string instruction (ISO-10646 UTF-8)\n string language tag (as defined in [RFC-3066])\n int num-prompts\n string prompt[1] (ISO-10646 UTF-8)\n boolean echo[1]\n ...\n string prompt[num-prompts] (ISO-10646 UTF-8)\n boolean echo[num-prompts]\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n const instructions = bufferParser.readString(true);\n bufferParser.readString(); // skip lang\n const numPrompts = bufferParser.readUInt32BE();\n let prompts;\n if (numPrompts !== undefined) {\n prompts = new Array(numPrompts);\n let i;\n for (i = 0; i < numPrompts; ++i) {\n const prompt = bufferParser.readString(true);\n const echo = bufferParser.readBool();\n if (echo === undefined)\n break;\n prompts[i] = { prompt, echo };\n }\n if (i !== numPrompts)\n prompts = undefined;\n }\n bufferParser.clear();\n\n if (prompts === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_INFO_REQUEST packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_INFO_REQUEST');\n\n const handler = self._handlers.USERAUTH_INFO_REQUEST;\n handler && handler(self, name, instructions, prompts);\n break;\n }\n default:\n self._debug\n && self._debug('Inbound: Received unexpected payload type 60');\n }\n },\n 61: (self, payload) => {\n if (!self._authsQueue.length) {\n self._debug\n && self._debug('Inbound: Received payload type 61 without auth');\n return;\n }\n /*\n byte SSH_MSG_USERAUTH_INFO_RESPONSE\n int num-responses\n string response[1] (ISO-10646 UTF-8)\n ...\n string response[num-responses] (ISO-10646 UTF-8)\n */\n if (self._authsQueue[0] !== 'keyboard-interactive') {\n return doFatalError(\n self,\n 'Inbound: Received unexpected payload type 61'\n );\n }\n bufferParser.init(payload, 1);\n const numResponses = bufferParser.readUInt32BE();\n let responses;\n if (numResponses !== undefined) {\n responses = new Array(numResponses);\n let i;\n for (i = 0; i < numResponses; ++i) {\n const response = bufferParser.readString(true);\n if (response === undefined)\n break;\n responses[i] = response;\n }\n if (i !== numResponses)\n responses = undefined;\n }\n bufferParser.clear();\n\n if (responses === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_INFO_RESPONSE packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_INFO_RESPONSE');\n\n const handler = self._handlers.USERAUTH_INFO_RESPONSE;\n handler && handler(self, responses);\n },\n\n // Connection protocol -- generic ============================================\n [MESSAGE.GLOBAL_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_GLOBAL_REQUEST\n string request name in US-ASCII only\n boolean want reply\n .... request-specific data follows\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n const wantReply = bufferParser.readBool();\n let data;\n if (wantReply !== undefined) {\n switch (name) {\n case 'tcpip-forward':\n case 'cancel-tcpip-forward': {\n /*\n string address to bind (e.g., \"0.0.0.0\")\n uint32 port number to bind\n */\n const bindAddr = bufferParser.readString(true);\n const bindPort = bufferParser.readUInt32BE();\n if (bindPort !== undefined)\n data = { bindAddr, bindPort };\n break;\n }\n case 'streamlocal-forward@openssh.com':\n case 'cancel-streamlocal-forward@openssh.com': {\n /*\n string socket path\n */\n const socketPath = bufferParser.readString(true);\n if (socketPath !== undefined)\n data = { socketPath };\n break;\n }\n case 'no-more-sessions@openssh.com':\n data = null;\n break;\n case 'hostkeys-00@openssh.com': {\n data = [];\n while (bufferParser.avail() > 0) {\n const keyRaw = bufferParser.readString();\n if (keyRaw === undefined) {\n data = undefined;\n break;\n }\n const key = parseKey(keyRaw);\n if (!(key instanceof Error))\n data.push(key);\n }\n break;\n }\n default:\n data = bufferParser.readRaw();\n }\n }\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed GLOBAL_REQUEST packet'\n );\n }\n\n self._debug && self._debug(`Inbound: GLOBAL_REQUEST (${name})`);\n\n const handler = self._handlers.GLOBAL_REQUEST;\n if (handler)\n handler(self, name, wantReply, data);\n else\n self.requestFailure(); // Auto reject\n },\n [MESSAGE.REQUEST_SUCCESS]: (self, payload) => {\n /*\n byte SSH_MSG_REQUEST_SUCCESS\n .... response specific data\n */\n const data = (payload.length > 1 ? bufferSlice(payload, 1) : null);\n\n self._debug && self._debug('Inbound: REQUEST_SUCCESS');\n\n const handler = self._handlers.REQUEST_SUCCESS;\n handler && handler(self, data);\n },\n [MESSAGE.REQUEST_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_REQUEST_FAILURE\n */\n self._debug && self._debug('Inbound: Received REQUEST_FAILURE');\n\n const handler = self._handlers.REQUEST_FAILURE;\n handler && handler(self);\n },\n\n // Connection protocol -- channel-related ====================================\n [MESSAGE.CHANNEL_OPEN]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN\n string channel type in US-ASCII only\n uint32 sender channel\n uint32 initial window size\n uint32 maximum packet size\n .... channel type specific data follows\n */\n bufferParser.init(payload, 1);\n const type = bufferParser.readString(true);\n const sender = bufferParser.readUInt32BE();\n const window = bufferParser.readUInt32BE();\n const packetSize = bufferParser.readUInt32BE();\n let channelInfo;\n\n switch (type) {\n case 'forwarded-tcpip': // S->C\n case 'direct-tcpip': { // C->S\n /*\n string address that was connected / host to connect\n uint32 port that was connected / port to connect\n string originator IP address\n uint32 originator port\n */\n const destIP = bufferParser.readString(true);\n const destPort = bufferParser.readUInt32BE();\n const srcIP = bufferParser.readString(true);\n const srcPort = bufferParser.readUInt32BE();\n if (srcPort !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { destIP, destPort, srcIP, srcPort }\n };\n }\n break;\n }\n case 'forwarded-streamlocal@openssh.com': // S->C\n case 'direct-streamlocal@openssh.com': { // C->S\n /*\n string socket path\n string reserved for future use\n\n (direct-streamlocal@openssh.com additionally has:)\n uint32 reserved\n */\n const socketPath = bufferParser.readString(true);\n if (socketPath !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { socketPath }\n };\n }\n break;\n }\n case 'x11': { // S->C\n /*\n string originator address (e.g., \"192.168.7.38\")\n uint32 originator port\n */\n const srcIP = bufferParser.readString(true);\n const srcPort = bufferParser.readUInt32BE();\n if (srcPort !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { srcIP, srcPort }\n };\n }\n break;\n }\n default:\n // Includes:\n // 'session' (C->S)\n // 'auth-agent@openssh.com' (S->C)\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: {}\n };\n }\n bufferParser.clear();\n\n if (channelInfo === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_OPEN (s:${sender}, ${type})`);\n\n const handler = self._handlers.CHANNEL_OPEN;\n if (handler) {\n handler(self, channelInfo);\n } else {\n self.channelOpenFail(\n channelInfo.sender,\n CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED,\n '',\n ''\n );\n }\n },\n [MESSAGE.CHANNEL_OPEN_CONFIRMATION]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN_CONFIRMATION\n uint32 recipient channel\n uint32 sender channel\n uint32 initial window size\n uint32 maximum packet size\n .... channel type specific data follows\n */\n // \"The 'recipient channel' is the channel number given in the\n // original open request, and 'sender channel' is the channel number\n // allocated by the other side.\"\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const sender = bufferParser.readUInt32BE();\n const window = bufferParser.readUInt32BE();\n const packetSize = bufferParser.readUInt32BE();\n const data = (bufferParser.avail() ? bufferParser.readRaw() : undefined);\n bufferParser.clear();\n\n if (packetSize === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_OPEN_CONFIRMATION (r:${recipient}, s:${sender})`\n );\n\n const handler = self._handlers.CHANNEL_OPEN_CONFIRMATION;\n if (handler)\n handler(self, { recipient, sender, window, packetSize, data });\n },\n [MESSAGE.CHANNEL_OPEN_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN_FAILURE\n uint32 recipient channel\n uint32 reason code\n string description in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const reason = bufferParser.readUInt32BE();\n const description = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN_FAILURE packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_OPEN_FAILURE;\n handler && handler(self, recipient, reason, description);\n },\n [MESSAGE.CHANNEL_WINDOW_ADJUST]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_WINDOW_ADJUST\n uint32 recipient channel\n uint32 bytes to add\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const bytesToAdd = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (bytesToAdd === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_WINDOW_ADJUST packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_WINDOW_ADJUST (r:${recipient}, ${bytesToAdd})`\n );\n\n const handler = self._handlers.CHANNEL_WINDOW_ADJUST;\n handler && handler(self, recipient, bytesToAdd);\n },\n [MESSAGE.CHANNEL_DATA]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_DATA\n uint32 recipient channel\n string data\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_DATA packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: CHANNEL_DATA (r:${recipient}, ${data.length})`);\n\n const handler = self._handlers.CHANNEL_DATA;\n handler && handler(self, recipient, data);\n },\n [MESSAGE.CHANNEL_EXTENDED_DATA]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_EXTENDED_DATA\n uint32 recipient channel\n uint32 data_type_code\n string data\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const type = bufferParser.readUInt32BE();\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_EXTENDED_DATA packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_EXTENDED_DATA (r:${recipient}, ${data.length})`\n );\n\n const handler = self._handlers.CHANNEL_EXTENDED_DATA;\n handler && handler(self, recipient, data, type);\n },\n [MESSAGE.CHANNEL_EOF]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_EOF\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_EOF packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_EOF (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_EOF;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_CLOSE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_CLOSE\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_CLOSE packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_CLOSE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_CLOSE;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_REQUEST\n uint32 recipient channel\n string request type in US-ASCII characters only\n boolean want reply\n .... type-specific data follows\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const type = bufferParser.readString(true);\n const wantReply = bufferParser.readBool();\n let data;\n if (wantReply !== undefined) {\n switch (type) {\n case 'exit-status': // S->C\n /*\n uint32 exit_status\n */\n data = bufferParser.readUInt32BE();\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'exit-signal': { // S->C\n /*\n string signal name (without the \"SIG\" prefix)\n boolean core dumped\n string error message in ISO-10646 UTF-8 encoding\n string language tag\n */\n let signal;\n let coreDumped;\n if (self._compatFlags & COMPAT.OLD_EXIT) {\n /*\n Instead of `signal name` and `core dumped`, we have just:\n uint32 signal number\n */\n const num = bufferParser.readUInt32BE();\n switch (num) {\n case 1:\n signal = 'HUP';\n break;\n case 2:\n signal = 'INT';\n break;\n case 3:\n signal = 'QUIT';\n break;\n case 6:\n signal = 'ABRT';\n break;\n case 9:\n signal = 'KILL';\n break;\n case 14:\n signal = 'ALRM';\n break;\n case 15:\n signal = 'TERM';\n break;\n default:\n if (num !== undefined) {\n // Unknown or OS-specific\n signal = `UNKNOWN (${num})`;\n }\n }\n coreDumped = false;\n } else {\n signal = bufferParser.readString(true);\n coreDumped = bufferParser.readBool();\n if (coreDumped === undefined)\n signal = undefined;\n }\n const errorMessage = bufferParser.readString(true);\n if (bufferParser.skipString() !== undefined)\n data = { signal, coreDumped, errorMessage };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${signal})`\n );\n break;\n }\n case 'pty-req': { // C->S\n /*\n string TERM environment variable value (e.g., vt100)\n uint32 terminal width, characters (e.g., 80)\n uint32 terminal height, rows (e.g., 24)\n uint32 terminal width, pixels (e.g., 640)\n uint32 terminal height, pixels (e.g., 480)\n string encoded terminal modes\n */\n const term = bufferParser.readString(true);\n const cols = bufferParser.readUInt32BE();\n const rows = bufferParser.readUInt32BE();\n const width = bufferParser.readUInt32BE();\n const height = bufferParser.readUInt32BE();\n const modesBinary = bufferParser.readString();\n if (modesBinary !== undefined) {\n bufferParser.init(modesBinary, 1);\n let modes = {};\n while (bufferParser.avail()) {\n const opcode = bufferParser.readByte();\n if (opcode === TERMINAL_MODE.TTY_OP_END)\n break;\n const name = TERMINAL_MODE_BY_VALUE[opcode];\n const value = bufferParser.readUInt32BE();\n if (opcode === undefined\n || name === undefined\n || value === undefined) {\n modes = undefined;\n break;\n }\n modes[name] = value;\n }\n if (modes !== undefined)\n data = { term, cols, rows, width, height, modes };\n }\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'window-change': { // C->S\n /*\n uint32 terminal width, columns\n uint32 terminal height, rows\n uint32 terminal width, pixels\n uint32 terminal height, pixels\n */\n const cols = bufferParser.readUInt32BE();\n const rows = bufferParser.readUInt32BE();\n const width = bufferParser.readUInt32BE();\n const height = bufferParser.readUInt32BE();\n if (height !== undefined)\n data = { cols, rows, width, height };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'x11-req': { // C->S\n /*\n boolean single connection\n string x11 authentication protocol\n string x11 authentication cookie\n uint32 x11 screen number\n */\n const single = bufferParser.readBool();\n const protocol = bufferParser.readString(true);\n const cookie = bufferParser.readString();\n const screen = bufferParser.readUInt32BE();\n if (screen !== undefined)\n data = { single, protocol, cookie, screen };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'env': { // C->S\n /*\n string variable name\n string variable value\n */\n const name = bufferParser.readString(true);\n const value = bufferParser.readString(true);\n if (value !== undefined)\n data = { name, value };\n if (self._debug) {\n self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: `\n + `${name}=${value})`\n );\n }\n break;\n }\n case 'shell': // C->S\n data = null; // No extra data\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n case 'exec': // C->S\n /*\n string command\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'subsystem': // C->S\n /*\n string subsystem name\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'signal': // C->S\n /*\n string signal name (without the \"SIG\" prefix)\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'xon-xoff': // C->S\n /*\n boolean client can do\n */\n data = bufferParser.readBool();\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'auth-agent-req@openssh.com': // C-S\n data = null; // No extra data\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n default:\n data = (bufferParser.avail() ? bufferParser.readRaw() : null);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n }\n }\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_REQUEST packet'\n );\n }\n\n const handler = self._handlers.CHANNEL_REQUEST;\n handler && handler(self, recipient, type, wantReply, data);\n },\n [MESSAGE.CHANNEL_SUCCESS]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_SUCCESS\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_SUCCESS packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_SUCCESS (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_SUCCESS;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_FAILURE\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_FAILURE packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_FAILURE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_FAILURE;\n handler && handler(self, recipient);\n },\n};\n","'use strict';\n\nconst {\n createDiffieHellman,\n createDiffieHellmanGroup,\n createECDH,\n createHash,\n createPublicKey,\n diffieHellman,\n generateKeyPairSync,\n randomFillSync,\n} = require('crypto');\n\nconst { Ber } = require('asn1');\n\nconst {\n COMPAT,\n curve25519Supported,\n DEFAULT_KEX,\n DEFAULT_SERVER_HOST_KEY,\n DEFAULT_CIPHER,\n DEFAULT_MAC,\n DEFAULT_COMPRESSION,\n DISCONNECT_REASON,\n MESSAGE,\n} = require('./constants.js');\nconst {\n CIPHER_INFO,\n createCipher,\n createDecipher,\n MAC_INFO,\n} = require('./crypto.js');\nconst { parseDERKey } = require('./keyParser.js');\nconst {\n bufferFill,\n bufferParser,\n convertSignature,\n doFatalError,\n FastBuffer,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./utils.js');\nconst {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n} = require('./zlib.js');\n\nlet MESSAGE_HANDLERS;\n\nconst GEX_MIN_BITS = 2048; // RFC 8270\nconst GEX_MAX_BITS = 8192; // RFC 8270\n\nconst EMPTY_BUFFER = Buffer.alloc(0);\n\n// Client/Server\nfunction kexinit(self) {\n /*\n byte SSH_MSG_KEXINIT\n byte[16] cookie (random bytes)\n name-list kex_algorithms\n name-list server_host_key_algorithms\n name-list encryption_algorithms_client_to_server\n name-list encryption_algorithms_server_to_client\n name-list mac_algorithms_client_to_server\n name-list mac_algorithms_server_to_client\n name-list compression_algorithms_client_to_server\n name-list compression_algorithms_server_to_client\n name-list languages_client_to_server\n name-list languages_server_to_client\n boolean first_kex_packet_follows\n uint32 0 (reserved for future extension)\n */\n\n let payload;\n if (self._compatFlags & COMPAT.BAD_DHGEX) {\n const entry = self._offer.lists.kex;\n let kex = entry.array;\n let found = false;\n for (let i = 0; i < kex.length; ++i) {\n if (kex[i].includes('group-exchange')) {\n if (!found) {\n found = true;\n // Copy array lazily\n kex = kex.slice();\n }\n kex.splice(i--, 1);\n }\n }\n if (found) {\n let len = 1 + 16 + self._offer.totalSize + 1 + 4;\n const newKexBuf = Buffer.from(kex.join(','));\n len -= (entry.buffer.length - newKexBuf.length);\n\n const all = self._offer.lists.all;\n const rest = new Uint8Array(\n all.buffer,\n all.byteOffset + 4 + entry.buffer.length,\n all.length - (4 + entry.buffer.length)\n );\n\n payload = Buffer.allocUnsafe(len);\n writeUInt32BE(payload, newKexBuf.length, 17);\n payload.set(newKexBuf, 17 + 4);\n payload.set(rest, 17 + 4 + newKexBuf.length);\n }\n }\n\n if (payload === undefined) {\n payload = Buffer.allocUnsafe(1 + 16 + self._offer.totalSize + 1 + 4);\n self._offer.copyAllTo(payload, 17);\n }\n\n self._debug && self._debug('Outbound: Sending KEXINIT');\n\n payload[0] = MESSAGE.KEXINIT;\n randomFillSync(payload, 1, 16);\n\n // Zero-fill first_kex_packet_follows and reserved bytes\n bufferFill(payload, 0, payload.length - 5);\n\n self._kexinit = payload;\n\n // Needed to correct the starting position in allocated \"packets\" when packets\n // will be buffered due to active key exchange\n self._packetRW.write.allocStart = 0;\n\n // TODO: only create single buffer and set _kexinit as slice of packet instead\n {\n const p = self._packetRW.write.allocStartKEX;\n const packet = self._packetRW.write.alloc(payload.length, true);\n packet.set(payload, p);\n self._cipher.encrypt(self._packetRW.write.finalize(packet, true));\n }\n}\n\nfunction handleKexInit(self, payload) {\n /*\n byte SSH_MSG_KEXINIT\n byte[16] cookie (random bytes)\n name-list kex_algorithms\n name-list server_host_key_algorithms\n name-list encryption_algorithms_client_to_server\n name-list encryption_algorithms_server_to_client\n name-list mac_algorithms_client_to_server\n name-list mac_algorithms_server_to_client\n name-list compression_algorithms_client_to_server\n name-list compression_algorithms_server_to_client\n name-list languages_client_to_server\n name-list languages_server_to_client\n boolean first_kex_packet_follows\n uint32 0 (reserved for future extension)\n */\n const init = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n sc: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n };\n\n bufferParser.init(payload, 17);\n\n if ((init.kex = bufferParser.readList()) === undefined\n || (init.serverHostKey = bufferParser.readList()) === undefined\n || (init.cs.cipher = bufferParser.readList()) === undefined\n || (init.sc.cipher = bufferParser.readList()) === undefined\n || (init.cs.mac = bufferParser.readList()) === undefined\n || (init.sc.mac = bufferParser.readList()) === undefined\n || (init.cs.compress = bufferParser.readList()) === undefined\n || (init.sc.compress = bufferParser.readList()) === undefined\n || (init.cs.lang = bufferParser.readList()) === undefined\n || (init.sc.lang = bufferParser.readList()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n self,\n 'Received malformed KEXINIT',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n const pos = bufferParser.pos();\n const firstFollows = (pos < payload.length && payload[pos] === 1);\n bufferParser.clear();\n\n const local = self._offer;\n const remote = init;\n\n let localKex = local.lists.kex.array;\n if (self._compatFlags & COMPAT.BAD_DHGEX) {\n let found = false;\n for (let i = 0; i < localKex.length; ++i) {\n if (localKex[i].indexOf('group-exchange') !== -1) {\n if (!found) {\n found = true;\n // Copy array lazily\n localKex = localKex.slice();\n }\n localKex.splice(i--, 1);\n }\n }\n }\n\n let clientList;\n let serverList;\n let i;\n const debug = self._debug;\n\n debug && debug('Inbound: Handshake in progress');\n\n // Key exchange method =======================================================\n debug && debug(`Handshake: (local) KEX method: ${localKex}`);\n debug && debug(`Handshake: (remote) KEX method: ${remote.kex}`);\n if (self._server) {\n serverList = localKex;\n clientList = remote.kex;\n } else {\n serverList = remote.kex;\n clientList = localKex;\n }\n // Check for agreeable key exchange algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching key exchange algorithm');\n return doFatalError(\n self,\n 'Handshake failed: no matching key exchange algorithm',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.kex = clientList[i];\n debug && debug(`Handshake: KEX algorithm: ${clientList[i]}`);\n if (firstFollows && (!remote.kex.length || clientList[i] !== remote.kex[0])) {\n // Ignore next inbound packet, it was a wrong first guess at KEX algorithm\n self._skipNextInboundPacket = true;\n }\n\n\n // Server host key format ====================================================\n const localSrvHostKey = local.lists.serverHostKey.array;\n debug && debug(`Handshake: (local) Host key format: ${localSrvHostKey}`);\n debug && debug(\n `Handshake: (remote) Host key format: ${remote.serverHostKey}`\n );\n if (self._server) {\n serverList = localSrvHostKey;\n clientList = remote.serverHostKey;\n } else {\n serverList = remote.serverHostKey;\n clientList = localSrvHostKey;\n }\n // Check for agreeable server host key format\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching host key format');\n return doFatalError(\n self,\n 'Handshake failed: no matching host key format',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.serverHostKey = clientList[i];\n debug && debug(`Handshake: Host key format: ${clientList[i]}`);\n\n\n // Client->Server cipher =====================================================\n const localCSCipher = local.lists.cs.cipher.array;\n debug && debug(`Handshake: (local) C->S cipher: ${localCSCipher}`);\n debug && debug(`Handshake: (remote) C->S cipher: ${remote.cs.cipher}`);\n if (self._server) {\n serverList = localCSCipher;\n clientList = remote.cs.cipher;\n } else {\n serverList = remote.cs.cipher;\n clientList = localCSCipher;\n }\n // Check for agreeable client->server cipher\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S cipher');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S cipher',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.cipher = clientList[i];\n debug && debug(`Handshake: C->S Cipher: ${clientList[i]}`);\n\n\n // Server->Client cipher =====================================================\n const localSCCipher = local.lists.sc.cipher.array;\n debug && debug(`Handshake: (local) S->C cipher: ${localSCCipher}`);\n debug && debug(`Handshake: (remote) S->C cipher: ${remote.sc.cipher}`);\n if (self._server) {\n serverList = localSCCipher;\n clientList = remote.sc.cipher;\n } else {\n serverList = remote.sc.cipher;\n clientList = localSCCipher;\n }\n // Check for agreeable server->client cipher\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C cipher');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C cipher',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.cipher = clientList[i];\n debug && debug(`Handshake: S->C cipher: ${clientList[i]}`);\n\n\n // Client->Server MAC ========================================================\n const localCSMAC = local.lists.cs.mac.array;\n debug && debug(`Handshake: (local) C->S MAC: ${localCSMAC}`);\n debug && debug(`Handshake: (remote) C->S MAC: ${remote.cs.mac}`);\n if (CIPHER_INFO[init.cs.cipher].authLen > 0) {\n init.cs.mac = '';\n debug && debug('Handshake: C->S MAC: ');\n } else {\n if (self._server) {\n serverList = localCSMAC;\n clientList = remote.cs.mac;\n } else {\n serverList = remote.cs.mac;\n clientList = localCSMAC;\n }\n // Check for agreeable client->server hmac algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S MAC');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S MAC',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.mac = clientList[i];\n debug && debug(`Handshake: C->S MAC: ${clientList[i]}`);\n }\n\n\n // Server->Client MAC ========================================================\n const localSCMAC = local.lists.sc.mac.array;\n debug && debug(`Handshake: (local) S->C MAC: ${localSCMAC}`);\n debug && debug(`Handshake: (remote) S->C MAC: ${remote.sc.mac}`);\n if (CIPHER_INFO[init.sc.cipher].authLen > 0) {\n init.sc.mac = '';\n debug && debug('Handshake: S->C MAC: ');\n } else {\n if (self._server) {\n serverList = localSCMAC;\n clientList = remote.sc.mac;\n } else {\n serverList = remote.sc.mac;\n clientList = localSCMAC;\n }\n // Check for agreeable server->client hmac algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C MAC');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C MAC',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.mac = clientList[i];\n debug && debug(`Handshake: S->C MAC: ${clientList[i]}`);\n }\n\n\n // Client->Server compression ================================================\n const localCSCompress = local.lists.cs.compress.array;\n debug && debug(`Handshake: (local) C->S compression: ${localCSCompress}`);\n debug && debug(`Handshake: (remote) C->S compression: ${remote.cs.compress}`);\n if (self._server) {\n serverList = localCSCompress;\n clientList = remote.cs.compress;\n } else {\n serverList = remote.cs.compress;\n clientList = localCSCompress;\n }\n // Check for agreeable client->server compression algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S compression');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S compression',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.compress = clientList[i];\n debug && debug(`Handshake: C->S compression: ${clientList[i]}`);\n\n\n // Server->Client compression ================================================\n const localSCCompress = local.lists.sc.compress.array;\n debug && debug(`Handshake: (local) S->C compression: ${localSCCompress}`);\n debug && debug(`Handshake: (remote) S->C compression: ${remote.sc.compress}`);\n if (self._server) {\n serverList = localSCCompress;\n clientList = remote.sc.compress;\n } else {\n serverList = remote.sc.compress;\n clientList = localSCCompress;\n }\n // Check for agreeable server->client compression algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C compression');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C compression',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.compress = clientList[i];\n debug && debug(`Handshake: S->C compression: ${clientList[i]}`);\n\n init.cs.lang = '';\n init.sc.lang = '';\n\n // XXX: hack -- find a better way to do this\n if (self._kex) {\n if (!self._kexinit) {\n // We received a rekey request, but we haven't sent a KEXINIT in response\n // yet\n kexinit(self);\n }\n self._decipher._onPayload = onKEXPayload.bind(self, { firstPacket: false });\n }\n\n self._kex = createKeyExchange(init, self, payload);\n self._kex.start();\n}\n\nconst createKeyExchange = (() => {\n function convertToMpint(buf) {\n let idx = 0;\n let length = buf.length;\n while (buf[idx] === 0x00) {\n ++idx;\n --length;\n }\n let newBuf;\n if (buf[idx] & 0x80) {\n newBuf = Buffer.allocUnsafe(1 + length);\n newBuf[0] = 0;\n buf.copy(newBuf, 1, idx);\n buf = newBuf;\n } else if (length !== buf.length) {\n newBuf = Buffer.allocUnsafe(length);\n buf.copy(newBuf, 0, idx);\n buf = newBuf;\n }\n return buf;\n }\n\n class KeyExchange {\n constructor(negotiated, protocol, remoteKexinit) {\n this._protocol = protocol;\n\n this.sessionID = (protocol._kex ? protocol._kex.sessionID : undefined);\n this.negotiated = negotiated;\n this._step = 1;\n this._public = null;\n this._dh = null;\n this._sentNEWKEYS = false;\n this._receivedNEWKEYS = false;\n this._finished = false;\n this._hostVerified = false;\n\n // Data needed for initializing cipher/decipher/etc.\n this._kexinit = protocol._kexinit;\n this._remoteKexinit = remoteKexinit;\n this._identRaw = protocol._identRaw;\n this._remoteIdentRaw = protocol._remoteIdentRaw;\n this._hostKey = undefined;\n this._dhData = undefined;\n this._sig = undefined;\n }\n finish() {\n if (this._finished)\n return false;\n this._finished = true;\n\n const isServer = this._protocol._server;\n const negotiated = this.negotiated;\n\n const pubKey = this.convertPublicKey(this._dhData);\n let secret = this.computeSecret(this._dhData);\n if (secret instanceof Error) {\n secret.message =\n `Error while computing DH secret (${this.type}): ${secret.message}`;\n secret.level = 'handshake';\n return doFatalError(\n this._protocol,\n secret,\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n const hash = createHash(this.hashName);\n // V_C\n hashString(hash, (isServer ? this._remoteIdentRaw : this._identRaw));\n // \"V_S\"\n hashString(hash, (isServer ? this._identRaw : this._remoteIdentRaw));\n // \"I_C\"\n hashString(hash, (isServer ? this._remoteKexinit : this._kexinit));\n // \"I_S\"\n hashString(hash, (isServer ? this._kexinit : this._remoteKexinit));\n // \"K_S\"\n const serverPublicHostKey = (isServer\n ? this._hostKey.getPublicSSH()\n : this._hostKey);\n hashString(hash, serverPublicHostKey);\n\n if (this.type === 'groupex') {\n // Group exchange-specific\n const params = this.getDHParams();\n const num = Buffer.allocUnsafe(4);\n // min (uint32)\n writeUInt32BE(num, this._minBits, 0);\n hash.update(num);\n // preferred (uint32)\n writeUInt32BE(num, this._prefBits, 0);\n hash.update(num);\n // max (uint32)\n writeUInt32BE(num, this._maxBits, 0);\n hash.update(num);\n // prime\n hashString(hash, params.prime);\n // generator\n hashString(hash, params.generator);\n }\n\n // method-specific data sent by client\n hashString(hash, (isServer ? pubKey : this.getPublicKey()));\n // method-specific data sent by server\n const serverPublicKey = (isServer ? this.getPublicKey() : pubKey);\n hashString(hash, serverPublicKey);\n // shared secret (\"K\")\n hashString(hash, secret);\n\n // \"H\"\n const exchangeHash = hash.digest();\n\n if (!isServer) {\n bufferParser.init(this._sig, 0);\n const sigType = bufferParser.readString(true);\n\n if (!sigType) {\n return doFatalError(\n this._protocol,\n 'Malformed packet while reading signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (sigType !== negotiated.serverHostKey) {\n return doFatalError(\n this._protocol,\n `Wrong signature type: ${sigType}, `\n + `expected: ${negotiated.serverHostKey}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // \"s\"\n let sigValue = bufferParser.readString();\n\n bufferParser.clear();\n\n if (sigValue === undefined) {\n return doFatalError(\n this._protocol,\n 'Malformed packet while reading signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (!(sigValue = sigSSHToASN1(sigValue, sigType))) {\n return doFatalError(\n this._protocol,\n 'Malformed signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n let parsedHostKey;\n {\n bufferParser.init(this._hostKey, 0);\n const name = bufferParser.readString(true);\n const hostKey = this._hostKey.slice(bufferParser.pos());\n bufferParser.clear();\n parsedHostKey = parseDERKey(hostKey, name);\n if (parsedHostKey instanceof Error) {\n parsedHostKey.level = 'handshake';\n return doFatalError(\n this._protocol,\n parsedHostKey,\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n let hashAlgo;\n // Check if we need to override the default hash algorithm\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256': hashAlgo = 'sha256'; break;\n case 'rsa-sha2-512': hashAlgo = 'sha512'; break;\n }\n\n this._protocol._debug\n && this._protocol._debug('Verifying signature ...');\n\n const verified = parsedHostKey.verify(exchangeHash, sigValue, hashAlgo);\n if (verified !== true) {\n if (verified instanceof Error) {\n this._protocol._debug && this._protocol._debug(\n `Signature verification failed: ${verified.stack}`\n );\n } else {\n this._protocol._debug && this._protocol._debug(\n 'Signature verification failed'\n );\n }\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature verification failed',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug('Verified signature');\n } else {\n // Server\n\n let hashAlgo;\n // Check if we need to override the default hash algorithm\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256': hashAlgo = 'sha256'; break;\n case 'rsa-sha2-512': hashAlgo = 'sha512'; break;\n }\n\n this._protocol._debug && this._protocol._debug(\n 'Generating signature ...'\n );\n\n let signature = this._hostKey.sign(exchangeHash, hashAlgo);\n if (signature instanceof Error) {\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature generation failed for '\n + `${this._hostKey.type} host key: ${signature.message}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n signature = convertSignature(signature, this._hostKey.type);\n if (signature === false) {\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature conversion failed for '\n + `${this._hostKey.type} host key`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // Send KEX reply\n /*\n byte SSH_MSG_KEXDH_REPLY\n / SSH_MSG_KEX_DH_GEX_REPLY\n / SSH_MSG_KEX_ECDH_REPLY\n string server public host key and certificates (K_S)\n string \n string signature of H\n */\n const sigType = this.negotiated.serverHostKey;\n const sigTypeLen = Buffer.byteLength(sigType);\n const sigLen = 4 + sigTypeLen + 4 + signature.length;\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1\n + 4 + serverPublicHostKey.length\n + 4 + serverPublicKey.length\n + 4 + sigLen,\n true\n );\n\n packet[p] = MESSAGE.KEXDH_REPLY;\n\n writeUInt32BE(packet, serverPublicHostKey.length, ++p);\n packet.set(serverPublicHostKey, p += 4);\n\n writeUInt32BE(packet,\n serverPublicKey.length,\n p += serverPublicHostKey.length);\n packet.set(serverPublicKey, p += 4);\n\n writeUInt32BE(packet, sigLen, p += serverPublicKey.length);\n\n writeUInt32BE(packet, sigTypeLen, p += 4);\n packet.utf8Write(sigType, p += 4, sigTypeLen);\n\n writeUInt32BE(packet, signature.length, p += sigTypeLen);\n packet.set(signature, p += 4);\n\n if (this._protocol._debug) {\n let type;\n switch (this.type) {\n case 'group':\n type = 'KEXDH_REPLY';\n break;\n case 'groupex':\n type = 'KEXDH_GEX_REPLY';\n break;\n default:\n type = 'KEXECDH_REPLY';\n }\n this._protocol._debug(`Outbound: Sending ${type}`);\n }\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n trySendNEWKEYS(this);\n\n const completeHandshake = () => {\n if (!this.sessionID)\n this.sessionID = exchangeHash;\n\n {\n const newSecret = Buffer.allocUnsafe(4 + secret.length);\n writeUInt32BE(newSecret, secret.length, 0);\n newSecret.set(secret, 4);\n secret = newSecret;\n }\n\n // Initialize new ciphers, deciphers, etc.\n\n const csCipherInfo = CIPHER_INFO[negotiated.cs.cipher];\n const scCipherInfo = CIPHER_INFO[negotiated.sc.cipher];\n\n const csIV = generateKEXVal(csCipherInfo.ivLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'A');\n const scIV = generateKEXVal(scCipherInfo.ivLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'B');\n const csKey = generateKEXVal(csCipherInfo.keyLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'C');\n const scKey = generateKEXVal(scCipherInfo.keyLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'D');\n let csMacInfo;\n let csMacKey;\n if (!csCipherInfo.authLen) {\n csMacInfo = MAC_INFO[negotiated.cs.mac];\n csMacKey = generateKEXVal(csMacInfo.len,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'E');\n }\n let scMacInfo;\n let scMacKey;\n if (!scCipherInfo.authLen) {\n scMacInfo = MAC_INFO[negotiated.sc.mac];\n scMacKey = generateKEXVal(scMacInfo.len,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'F');\n }\n\n const config = {\n inbound: {\n onPayload: this._protocol._onPayload,\n seqno: this._protocol._decipher.inSeqno,\n decipherInfo: (!isServer ? scCipherInfo : csCipherInfo),\n decipherIV: (!isServer ? scIV : csIV),\n decipherKey: (!isServer ? scKey : csKey),\n macInfo: (!isServer ? scMacInfo : csMacInfo),\n macKey: (!isServer ? scMacKey : csMacKey),\n },\n outbound: {\n onWrite: this._protocol._onWrite,\n seqno: this._protocol._cipher.outSeqno,\n cipherInfo: (isServer ? scCipherInfo : csCipherInfo),\n cipherIV: (isServer ? scIV : csIV),\n cipherKey: (isServer ? scKey : csKey),\n macInfo: (isServer ? scMacInfo : csMacInfo),\n macKey: (isServer ? scMacKey : csMacKey),\n },\n };\n this._protocol._cipher && this._protocol._cipher.free();\n this._protocol._decipher && this._protocol._decipher.free();\n this._protocol._cipher = createCipher(config);\n this._protocol._decipher = createDecipher(config);\n\n const rw = {\n read: undefined,\n write: undefined,\n };\n switch (negotiated.cs.compress) {\n case 'zlib': // starts immediately\n if (isServer)\n rw.read = new ZlibPacketReader();\n else\n rw.write = new ZlibPacketWriter(this._protocol);\n break;\n case 'zlib@openssh.com':\n // Starts after successful user authentication\n\n if (this._protocol._authenticated) {\n // If a rekey happens and this compression method is selected and\n // we already authenticated successfully, we need to start\n // immediately instead\n if (isServer)\n rw.read = new ZlibPacketReader();\n else\n rw.write = new ZlibPacketWriter(this._protocol);\n break;\n }\n // FALLTHROUGH\n default:\n // none -- never any compression/decompression\n\n if (isServer)\n rw.read = new PacketReader();\n else\n rw.write = new PacketWriter(this._protocol);\n }\n switch (negotiated.sc.compress) {\n case 'zlib': // starts immediately\n if (isServer)\n rw.write = new ZlibPacketWriter(this._protocol);\n else\n rw.read = new ZlibPacketReader();\n break;\n case 'zlib@openssh.com':\n // Starts after successful user authentication\n\n if (this._protocol._authenticated) {\n // If a rekey happens and this compression method is selected and\n // we already authenticated successfully, we need to start\n // immediately instead\n if (isServer)\n rw.write = new ZlibPacketWriter(this._protocol);\n else\n rw.read = new ZlibPacketReader();\n break;\n }\n // FALLTHROUGH\n default:\n // none -- never any compression/decompression\n\n if (isServer)\n rw.write = new PacketWriter(this._protocol);\n else\n rw.read = new PacketReader();\n }\n this._protocol._packetRW.read.cleanup();\n this._protocol._packetRW.write.cleanup();\n this._protocol._packetRW = rw;\n\n // Cleanup/reset various state\n this._public = null;\n this._dh = null;\n this._kexinit = this._protocol._kexinit = undefined;\n this._remoteKexinit = undefined;\n this._identRaw = undefined;\n this._remoteIdentRaw = undefined;\n this._hostKey = undefined;\n this._dhData = undefined;\n this._sig = undefined;\n\n this._protocol._onHandshakeComplete(negotiated);\n\n return false;\n };\n if (!isServer)\n return completeHandshake();\n this.finish = completeHandshake;\n }\n\n start() {\n if (!this._protocol._server) {\n if (this._protocol._debug) {\n let type;\n switch (this.type) {\n case 'group':\n type = 'KEXDH_INIT';\n break;\n default:\n type = 'KEXECDH_INIT';\n }\n this._protocol._debug(`Outbound: Sending ${type}`);\n }\n\n const pubKey = this.getPublicKey();\n\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1 + 4 + pubKey.length,\n true\n );\n packet[p] = MESSAGE.KEXDH_INIT;\n writeUInt32BE(packet, pubKey.length, ++p);\n packet.set(pubKey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n }\n getPublicKey() {\n this.generateKeys();\n\n const key = this._public;\n\n if (key)\n return this.convertPublicKey(key);\n }\n convertPublicKey(key) {\n let newKey;\n let idx = 0;\n let len = key.length;\n while (key[idx] === 0x00) {\n ++idx;\n --len;\n }\n\n if (key[idx] & 0x80) {\n newKey = Buffer.allocUnsafe(1 + len);\n newKey[0] = 0;\n key.copy(newKey, 1, idx);\n return newKey;\n }\n\n if (len !== key.length) {\n newKey = Buffer.allocUnsafe(len);\n key.copy(newKey, 0, idx);\n key = newKey;\n }\n return key;\n }\n computeSecret(otherPublicKey) {\n this.generateKeys();\n\n try {\n return convertToMpint(this._dh.computeSecret(otherPublicKey));\n } catch (ex) {\n return ex;\n }\n }\n parse(payload) {\n const type = payload[0];\n switch (this._step) {\n case 1:\n if (this._protocol._server) {\n // Server\n if (type !== MESSAGE.KEXDH_INIT) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_INIT}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH Init'\n );\n /*\n byte SSH_MSG_KEXDH_INIT\n / SSH_MSG_KEX_ECDH_INIT\n string \n */\n bufferParser.init(payload, 1);\n const dhData = bufferParser.readString();\n bufferParser.clear();\n if (dhData === undefined) {\n return doFatalError(\n this._protocol,\n 'Received malformed KEX*_INIT',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // Client public key\n this._dhData = dhData;\n\n let hostKey =\n this._protocol._hostKeys[this.negotiated.serverHostKey];\n if (Array.isArray(hostKey))\n hostKey = hostKey[0];\n this._hostKey = hostKey;\n\n this.finish();\n } else {\n // Client\n if (type !== MESSAGE.KEXDH_REPLY) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_REPLY}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH Reply'\n );\n /*\n byte SSH_MSG_KEXDH_REPLY\n / SSH_MSG_KEX_DH_GEX_REPLY\n / SSH_MSG_KEX_ECDH_REPLY\n string server public host key and certificates (K_S)\n string \n string signature of H\n */\n bufferParser.init(payload, 1);\n let hostPubKey;\n let dhData;\n let sig;\n if ((hostPubKey = bufferParser.readString()) === undefined\n || (dhData = bufferParser.readString()) === undefined\n || (sig = bufferParser.readString()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n this._protocol,\n 'Received malformed KEX*_REPLY',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n bufferParser.clear();\n\n // Check that the host public key type matches what was negotiated\n // during KEXINIT swap\n bufferParser.init(hostPubKey, 0);\n const hostPubKeyType = bufferParser.readString(true);\n bufferParser.clear();\n if (hostPubKeyType === undefined) {\n return doFatalError(\n this._protocol,\n 'Received malformed host public key',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n if (hostPubKeyType !== this.negotiated.serverHostKey) {\n // Check if we need to make an exception\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256':\n case 'rsa-sha2-512':\n if (hostPubKeyType === 'ssh-rsa')\n break;\n // FALLTHROUGH\n default:\n return doFatalError(\n this._protocol,\n 'Host key does not match negotiated type',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n this._hostKey = hostPubKey;\n this._dhData = dhData;\n this._sig = sig;\n\n let checked = false;\n let ret;\n if (this._protocol._hostVerifier === undefined) {\n ret = true;\n this._protocol._debug && this._protocol._debug(\n 'Host accepted by default (no verification)'\n );\n } else {\n ret = this._protocol._hostVerifier(hostPubKey, (permitted) => {\n if (checked)\n return;\n checked = true;\n if (permitted === false) {\n this._protocol._debug && this._protocol._debug(\n 'Host denied (verification failed)'\n );\n return doFatalError(\n this._protocol,\n 'Host denied (verification failed)',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Host accepted (verified)'\n );\n this._hostVerified = true;\n if (this._receivedNEWKEYS)\n this.finish();\n else\n trySendNEWKEYS(this);\n });\n }\n if (ret === undefined) {\n // Async host verification\n ++this._step;\n return;\n }\n checked = true;\n if (ret === false) {\n this._protocol._debug && this._protocol._debug(\n 'Host denied (verification failed)'\n );\n return doFatalError(\n this._protocol,\n 'Host denied (verification failed)',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Host accepted (verified)'\n );\n this._hostVerified = true;\n trySendNEWKEYS(this);\n }\n ++this._step;\n break;\n case 2:\n if (type !== MESSAGE.NEWKEYS) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.NEWKEYS}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Inbound: NEWKEYS'\n );\n this._receivedNEWKEYS = true;\n ++this._step;\n if (this._protocol._server || this._hostVerified)\n return this.finish();\n\n // Signal to current decipher that we need to change to a new decipher\n // for the next packet\n return false;\n default:\n return doFatalError(\n this._protocol,\n `Received unexpected packet ${type} after NEWKEYS`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n }\n\n class Curve25519Exchange extends KeyExchange {\n constructor(hashName, ...args) {\n super(...args);\n\n this.type = '25519';\n this.hashName = hashName;\n this._keys = null;\n }\n generateKeys() {\n if (!this._keys)\n this._keys = generateKeyPairSync('x25519');\n }\n getPublicKey() {\n this.generateKeys();\n\n const key = this._keys.publicKey.export({ type: 'spki', format: 'der' });\n return key.slice(-32); // HACK: avoids parsing DER/BER header\n }\n convertPublicKey(key) {\n let newKey;\n let idx = 0;\n let len = key.length;\n while (key[idx] === 0x00) {\n ++idx;\n --len;\n }\n\n if (key.length === 32)\n return key;\n\n if (len !== key.length) {\n newKey = Buffer.allocUnsafe(len);\n key.copy(newKey, 0, idx);\n key = newKey;\n }\n return key;\n }\n computeSecret(otherPublicKey) {\n this.generateKeys();\n\n try {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.110'); // id-X25519\n asnWriter.endSequence();\n\n // PublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(otherPublicKey.length);\n otherPublicKey.copy(asnWriter._buf,\n asnWriter._offset,\n 0,\n otherPublicKey.length);\n asnWriter._offset += otherPublicKey.length;\n asnWriter.endSequence();\n asnWriter.endSequence();\n\n return convertToMpint(diffieHellman({\n privateKey: this._keys.privateKey,\n publicKey: createPublicKey({\n key: asnWriter.buffer,\n type: 'spki',\n format: 'der',\n }),\n }));\n } catch (ex) {\n return ex;\n }\n }\n }\n\n class ECDHExchange extends KeyExchange {\n constructor(curveName, hashName, ...args) {\n super(...args);\n\n this.type = 'ecdh';\n this.curveName = curveName;\n this.hashName = hashName;\n }\n generateKeys() {\n if (!this._dh) {\n this._dh = createECDH(this.curveName);\n this._public = this._dh.generateKeys();\n }\n }\n }\n\n class DHGroupExchange extends KeyExchange {\n constructor(hashName, ...args) {\n super(...args);\n\n this.type = 'groupex';\n this.hashName = hashName;\n this._prime = null;\n this._generator = null;\n this._minBits = GEX_MIN_BITS;\n this._prefBits = dhEstimate(this.negotiated);\n if (this._protocol._compatFlags & COMPAT.BUG_DHGEX_LARGE)\n this._prefBits = Math.min(this._prefBits, 4096);\n this._maxBits = GEX_MAX_BITS;\n }\n start() {\n if (this._protocol._server)\n return;\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_GEX_REQUEST'\n );\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1 + 4 + 4 + 4,\n true\n );\n packet[p] = MESSAGE.KEXDH_GEX_REQUEST;\n writeUInt32BE(packet, this._minBits, ++p);\n writeUInt32BE(packet, this._prefBits, p += 4);\n writeUInt32BE(packet, this._maxBits, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n generateKeys() {\n if (!this._dh && this._prime && this._generator) {\n this._dh = createDiffieHellman(this._prime, this._generator);\n this._public = this._dh.generateKeys();\n }\n }\n setDHParams(prime, generator) {\n if (!Buffer.isBuffer(prime))\n throw new Error('Invalid prime value');\n if (!Buffer.isBuffer(generator))\n throw new Error('Invalid generator value');\n this._prime = prime;\n this._generator = generator;\n }\n getDHParams() {\n if (this._dh) {\n return {\n prime: convertToMpint(this._dh.getPrime()),\n generator: convertToMpint(this._dh.getGenerator()),\n };\n }\n }\n parse(payload) {\n const type = payload[0];\n switch (this._step) {\n case 1:\n if (this._protocol._server) {\n if (type !== MESSAGE.KEXDH_GEX_REQUEST) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of `\n + MESSAGE.KEXDH_GEX_REQUEST,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n // TODO: allow user implementation to provide safe prime and\n // generator on demand to support group exchange on server side\n return doFatalError(\n this._protocol,\n 'Group exchange not implemented for server',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (type !== MESSAGE.KEXDH_GEX_GROUP) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_GROUP}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Group'\n );\n\n /*\n byte SSH_MSG_KEX_DH_GEX_GROUP\n mpint p, safe prime\n mpint g, generator for subgroup in GF(p)\n */\n bufferParser.init(payload, 1);\n let prime;\n let gen;\n if ((prime = bufferParser.readString()) === undefined\n || (gen = bufferParser.readString()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n this._protocol,\n 'Received malformed KEXDH_GEX_GROUP',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n bufferParser.clear();\n\n // TODO: validate prime\n this.setDHParams(prime, gen);\n this.generateKeys();\n const pubkey = this.getPublicKey();\n\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_GEX_INIT'\n );\n\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet =\n this._protocol._packetRW.write.alloc(1 + 4 + pubkey.length, true);\n packet[p] = MESSAGE.KEXDH_GEX_INIT;\n writeUInt32BE(packet, pubkey.length, ++p);\n packet.set(pubkey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n\n ++this._step;\n break;\n case 2:\n if (this._protocol._server) {\n if (type !== MESSAGE.KEXDH_GEX_INIT) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_INIT}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Init'\n );\n return doFatalError(\n this._protocol,\n 'Group exchange not implemented for server',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n } else if (type !== MESSAGE.KEXDH_GEX_REPLY) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_REPLY}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Reply'\n );\n this._step = 1;\n payload[0] = MESSAGE.KEXDH_REPLY;\n this.parse = KeyExchange.prototype.parse;\n this.parse(payload);\n }\n }\n }\n\n class DHExchange extends KeyExchange {\n constructor(groupName, hashName, ...args) {\n super(...args);\n\n this.type = 'group';\n this.groupName = groupName;\n this.hashName = hashName;\n }\n start() {\n if (!this._protocol._server) {\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_INIT'\n );\n const pubKey = this.getPublicKey();\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet =\n this._protocol._packetRW.write.alloc(1 + 4 + pubKey.length, true);\n packet[p] = MESSAGE.KEXDH_INIT;\n writeUInt32BE(packet, pubKey.length, ++p);\n packet.set(pubKey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n }\n generateKeys() {\n if (!this._dh) {\n this._dh = createDiffieHellmanGroup(this.groupName);\n this._public = this._dh.generateKeys();\n }\n }\n getDHParams() {\n if (this._dh) {\n return {\n prime: convertToMpint(this._dh.getPrime()),\n generator: convertToMpint(this._dh.getGenerator()),\n };\n }\n }\n }\n\n return (negotiated, ...args) => {\n if (typeof negotiated !== 'object' || negotiated === null)\n throw new Error('Invalid negotiated argument');\n const kexType = negotiated.kex;\n if (typeof kexType === 'string') {\n args = [negotiated, ...args];\n switch (kexType) {\n case 'curve25519-sha256':\n case 'curve25519-sha256@libssh.org':\n if (!curve25519Supported)\n break;\n return new Curve25519Exchange('sha256', ...args);\n\n case 'ecdh-sha2-nistp256':\n return new ECDHExchange('prime256v1', 'sha256', ...args);\n case 'ecdh-sha2-nistp384':\n return new ECDHExchange('secp384r1', 'sha384', ...args);\n case 'ecdh-sha2-nistp521':\n return new ECDHExchange('secp521r1', 'sha512', ...args);\n\n case 'diffie-hellman-group1-sha1':\n return new DHExchange('modp2', 'sha1', ...args);\n case 'diffie-hellman-group14-sha1':\n return new DHExchange('modp14', 'sha1', ...args);\n case 'diffie-hellman-group14-sha256':\n return new DHExchange('modp14', 'sha256', ...args);\n case 'diffie-hellman-group15-sha512':\n return new DHExchange('modp15', 'sha512', ...args);\n case 'diffie-hellman-group16-sha512':\n return new DHExchange('modp16', 'sha512', ...args);\n case 'diffie-hellman-group17-sha512':\n return new DHExchange('modp17', 'sha512', ...args);\n case 'diffie-hellman-group18-sha512':\n return new DHExchange('modp18', 'sha512', ...args);\n\n case 'diffie-hellman-group-exchange-sha1':\n return new DHGroupExchange('sha1', ...args);\n case 'diffie-hellman-group-exchange-sha256':\n return new DHGroupExchange('sha256', ...args);\n }\n throw new Error(`Unsupported key exchange algorithm: ${kexType}`);\n }\n throw new Error(`Invalid key exchange type: ${kexType}`);\n };\n})();\n\nconst KexInit = (() => {\n const KEX_PROPERTY_NAMES = [\n 'kex',\n 'serverHostKey',\n ['cs', 'cipher' ],\n ['sc', 'cipher' ],\n ['cs', 'mac' ],\n ['sc', 'mac' ],\n ['cs', 'compress' ],\n ['sc', 'compress' ],\n ['cs', 'lang' ],\n ['sc', 'lang' ],\n ];\n return class KexInit {\n constructor(obj) {\n if (typeof obj !== 'object' || obj === null)\n throw new TypeError('Argument must be an object');\n\n const lists = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n sc: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n\n all: undefined,\n };\n let totalSize = 0;\n for (const prop of KEX_PROPERTY_NAMES) {\n let base;\n let val;\n let desc;\n let key;\n if (typeof prop === 'string') {\n base = lists;\n val = obj[prop];\n desc = key = prop;\n } else {\n const parent = prop[0];\n base = lists[parent];\n key = prop[1];\n val = obj[parent][key];\n desc = `${parent}.${key}`;\n }\n const entry = { array: undefined, buffer: undefined };\n if (Buffer.isBuffer(val)) {\n entry.array = ('' + val).split(',');\n entry.buffer = val;\n totalSize += 4 + val.length;\n } else {\n if (typeof val === 'string')\n val = val.split(',');\n if (Array.isArray(val)) {\n entry.array = val;\n entry.buffer = Buffer.from(val.join(','));\n } else {\n throw new TypeError(`Invalid \\`${desc}\\` type: ${typeof val}`);\n }\n totalSize += 4 + entry.buffer.length;\n }\n base[key] = entry;\n }\n\n const all = Buffer.allocUnsafe(totalSize);\n lists.all = all;\n\n let allPos = 0;\n for (const prop of KEX_PROPERTY_NAMES) {\n let data;\n if (typeof prop === 'string')\n data = lists[prop].buffer;\n else\n data = lists[prop[0]][prop[1]].buffer;\n allPos = writeUInt32BE(all, data.length, allPos);\n all.set(data, allPos);\n allPos += data.length;\n }\n\n this.totalSize = totalSize;\n this.lists = lists;\n }\n copyAllTo(buf, offset) {\n const src = this.lists.all;\n if (typeof offset !== 'number')\n throw new TypeError(`Invalid offset value: ${typeof offset}`);\n if (buf.length - offset < src.length)\n throw new Error('Insufficient space to copy list');\n buf.set(src, offset);\n return src.length;\n }\n };\n})();\n\nconst hashString = (() => {\n const LEN = Buffer.allocUnsafe(4);\n return (hash, buf) => {\n writeUInt32BE(LEN, buf.length, 0);\n hash.update(LEN);\n hash.update(buf);\n };\n})();\n\nfunction generateKEXVal(len, hashName, secret, exchangeHash, sessionID, char) {\n let ret;\n if (len) {\n let digest = createHash(hashName)\n .update(secret)\n .update(exchangeHash)\n .update(char)\n .update(sessionID)\n .digest();\n while (digest.length < len) {\n const chunk = createHash(hashName)\n .update(secret)\n .update(exchangeHash)\n .update(digest)\n .digest();\n const extended = Buffer.allocUnsafe(digest.length + chunk.length);\n extended.set(digest, 0);\n extended.set(chunk, digest.length);\n digest = extended;\n }\n if (digest.length === len)\n ret = digest;\n else\n ret = new FastBuffer(digest.buffer, digest.byteOffset, len);\n } else {\n ret = EMPTY_BUFFER;\n }\n return ret;\n}\n\nfunction onKEXPayload(state, payload) {\n // XXX: move this to the Decipher implementations?\n if (payload.length === 0) {\n this._debug && this._debug('Inbound: Skipping empty packet payload');\n return;\n }\n\n if (this._skipNextInboundPacket) {\n this._skipNextInboundPacket = false;\n return;\n }\n\n payload = this._packetRW.read.read(payload);\n\n const type = payload[0];\n switch (type) {\n case MESSAGE.DISCONNECT:\n case MESSAGE.IGNORE:\n case MESSAGE.UNIMPLEMENTED:\n case MESSAGE.DEBUG:\n if (!MESSAGE_HANDLERS)\n MESSAGE_HANDLERS = require('./handlers.js');\n return MESSAGE_HANDLERS[type](this, payload);\n case MESSAGE.KEXINIT:\n if (!state.firstPacket) {\n return doFatalError(\n this,\n 'Received extra KEXINIT during handshake',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n state.firstPacket = false;\n return handleKexInit(this, payload);\n default:\n if (type < 20 || type > 49) {\n return doFatalError(\n this,\n `Received unexpected packet type ${type}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n return this._kex.parse(payload);\n}\n\nfunction dhEstimate(neg) {\n const csCipher = CIPHER_INFO[neg.cs.cipher];\n const scCipher = CIPHER_INFO[neg.sc.cipher];\n // XXX: if OpenSSH's `umac-*` MACs are ever supported, their key lengths will\n // also need to be considered when calculating `bits`\n const bits = Math.max(\n 0,\n (csCipher.sslName === 'des-ede3-cbc' ? 14 : csCipher.keyLen),\n csCipher.blockLen,\n csCipher.ivLen,\n (scCipher.sslName === 'des-ede3-cbc' ? 14 : scCipher.keyLen),\n scCipher.blockLen,\n scCipher.ivLen\n ) * 8;\n if (bits <= 112)\n return 2048;\n if (bits <= 128)\n return 3072;\n if (bits <= 192)\n return 7680;\n return 8192;\n}\n\nfunction trySendNEWKEYS(kex) {\n if (!kex._sentNEWKEYS) {\n kex._protocol._debug && kex._protocol._debug(\n 'Outbound: Sending NEWKEYS'\n );\n const p = kex._protocol._packetRW.write.allocStartKEX;\n const packet = kex._protocol._packetRW.write.alloc(1, true);\n packet[p] = MESSAGE.NEWKEYS;\n kex._protocol._cipher.encrypt(\n kex._protocol._packetRW.write.finalize(packet, true)\n );\n kex._sentNEWKEYS = true;\n }\n}\n\nmodule.exports = {\n KexInit,\n kexinit,\n onKEXPayload,\n DEFAULT_KEXINIT: new KexInit({\n kex: DEFAULT_KEX,\n serverHostKey: DEFAULT_SERVER_HOST_KEY,\n cs: {\n cipher: DEFAULT_CIPHER,\n mac: DEFAULT_MAC,\n compress: DEFAULT_COMPRESSION,\n lang: [],\n },\n sc: {\n cipher: DEFAULT_CIPHER,\n mac: DEFAULT_MAC,\n compress: DEFAULT_COMPRESSION,\n lang: [],\n },\n }),\n HANDLERS: {\n [MESSAGE.KEXINIT]: handleKexInit,\n },\n};\n","// TODO:\n// * utilize `crypto.create(Private|Public)Key()` and `keyObject.export()`\n// * handle multi-line header values (OpenSSH)?\n// * more thorough validation?\n'use strict';\n\nconst {\n createDecipheriv,\n createECDH,\n createHash,\n createHmac,\n createSign,\n createVerify,\n getCiphers,\n sign: sign_,\n verify: verify_,\n} = require('crypto');\nconst supportedOpenSSLCiphers = getCiphers();\n\nconst { Ber } = require('asn1');\nconst bcrypt_pbkdf = require('bcrypt-pbkdf').pbkdf;\n\nconst { CIPHER_INFO } = require('./crypto.js');\nconst { eddsaSupported, SUPPORTED_CIPHER } = require('./constants.js');\nconst {\n bufferSlice,\n makeBufferParser,\n readString,\n readUInt32BE,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst SYM_HASH_ALGO = Symbol('Hash Algorithm');\nconst SYM_PRIV_PEM = Symbol('Private key PEM');\nconst SYM_PUB_PEM = Symbol('Public key PEM');\nconst SYM_PUB_SSH = Symbol('Public key SSH');\nconst SYM_DECRYPTED = Symbol('Decrypted Key');\n\n// Create OpenSSL cipher name -> SSH cipher name conversion table\nconst CIPHER_INFO_OPENSSL = Object.create(null);\n{\n const keys = Object.keys(CIPHER_INFO);\n for (let i = 0; i < keys.length; ++i) {\n const cipherName = CIPHER_INFO[keys[i]].sslName;\n if (!cipherName || CIPHER_INFO_OPENSSL[cipherName])\n continue;\n CIPHER_INFO_OPENSSL[cipherName] = CIPHER_INFO[keys[i]];\n }\n}\n\nconst binaryKeyParser = makeBufferParser();\n\nfunction makePEM(type, data) {\n data = data.base64Slice(0, data.length);\n let formatted = data.replace(/.{64}/g, '$&\\n');\n if (data.length & 63)\n formatted += '\\n';\n return `-----BEGIN ${type} KEY-----\\n${formatted}-----END ${type} KEY-----`;\n}\n\nfunction combineBuffers(buf1, buf2) {\n const result = Buffer.allocUnsafe(buf1.length + buf2.length);\n result.set(buf1, 0);\n result.set(buf2, buf1.length);\n return result;\n}\n\nfunction skipFields(buf, nfields) {\n const bufLen = buf.length;\n let pos = (buf._pos || 0);\n for (let i = 0; i < nfields; ++i) {\n const left = (bufLen - pos);\n if (pos >= bufLen || left < 4)\n return false;\n const len = readUInt32BE(buf, pos);\n if (left < 4 + len)\n return false;\n pos += 4 + len;\n }\n buf._pos = pos;\n return true;\n}\n\nfunction genOpenSSLRSAPub(n, e) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.113549.1.1.1'); // rsaEncryption\n // algorithm parameters (RSA has none)\n asnWriter.writeNull();\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n asnWriter.startSequence();\n asnWriter.writeBuffer(n, Ber.Integer);\n asnWriter.writeBuffer(e, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHRSAPub(n, e) {\n const publicKey = Buffer.allocUnsafe(4 + 7 + 4 + e.length + 4 + n.length);\n\n writeUInt32BE(publicKey, 7, 0);\n publicKey.utf8Write('ssh-rsa', 4, 7);\n\n let i = 4 + 7;\n writeUInt32BE(publicKey, e.length, i);\n publicKey.set(e, i += 4);\n\n writeUInt32BE(publicKey, n.length, i += e.length);\n publicKey.set(n, i + 4);\n\n return publicKey;\n}\n\nconst genOpenSSLRSAPriv = (() => {\n function genRSAASN1Buf(n, e, d, p, q, dmp1, dmq1, iqmp) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeInt(0x00, Ber.Integer);\n asnWriter.writeBuffer(n, Ber.Integer);\n asnWriter.writeBuffer(e, Ber.Integer);\n asnWriter.writeBuffer(d, Ber.Integer);\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(dmp1, Ber.Integer);\n asnWriter.writeBuffer(dmq1, Ber.Integer);\n asnWriter.writeBuffer(iqmp, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n\n function bigIntFromBuffer(buf) {\n return BigInt(`0x${buf.hexSlice(0, buf.length)}`);\n }\n\n function bigIntToBuffer(bn) {\n let hex = bn.toString(16);\n if ((hex.length & 1) !== 0) {\n hex = `0${hex}`;\n } else {\n const sigbit = hex.charCodeAt(0);\n // BER/DER integers require leading zero byte to denote a positive value\n // when first byte >= 0x80\n if (sigbit === 56/* '8' */\n || sigbit === 57/* '9' */\n || (sigbit >= 97/* 'a' */ && sigbit <= 102/* 'f' */)) {\n hex = `00${hex}`;\n }\n }\n return Buffer.from(hex, 'hex');\n }\n\n return function genOpenSSLRSAPriv(n, e, d, iqmp, p, q) {\n const bn_d = bigIntFromBuffer(d);\n const dmp1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(p) - 1n));\n const dmq1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(q) - 1n));\n return makePEM('RSA PRIVATE',\n genRSAASN1Buf(n, e, d, p, q, dmp1, dmq1, iqmp));\n };\n})();\n\nfunction genOpenSSLDSAPub(p, q, g, y) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.10040.4.1'); // id-dsa\n // algorithm parameters\n asnWriter.startSequence();\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(g, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n asnWriter.writeBuffer(y, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHDSAPub(p, q, g, y) {\n const publicKey = Buffer.allocUnsafe(\n 4 + 7 + 4 + p.length + 4 + q.length + 4 + g.length + 4 + y.length\n );\n\n writeUInt32BE(publicKey, 7, 0);\n publicKey.utf8Write('ssh-dss', 4, 7);\n\n let i = 4 + 7;\n writeUInt32BE(publicKey, p.length, i);\n publicKey.set(p, i += 4);\n\n writeUInt32BE(publicKey, q.length, i += p.length);\n publicKey.set(q, i += 4);\n\n writeUInt32BE(publicKey, g.length, i += q.length);\n publicKey.set(g, i += 4);\n\n writeUInt32BE(publicKey, y.length, i += g.length);\n publicKey.set(y, i + 4);\n\n return publicKey;\n}\n\nfunction genOpenSSLDSAPriv(p, q, g, y, x) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeInt(0x00, Ber.Integer);\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(g, Ber.Integer);\n asnWriter.writeBuffer(y, Ber.Integer);\n asnWriter.writeBuffer(x, Ber.Integer);\n asnWriter.endSequence();\n return makePEM('DSA PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLEdPub(pub) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.112'); // id-Ed25519\n asnWriter.endSequence();\n\n // PublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(pub.length);\n asnWriter._buf.set(pub, asnWriter._offset);\n asnWriter._offset += pub.length;\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHEdPub(pub) {\n const publicKey = Buffer.allocUnsafe(4 + 11 + 4 + pub.length);\n\n writeUInt32BE(publicKey, 11, 0);\n publicKey.utf8Write('ssh-ed25519', 4, 11);\n\n writeUInt32BE(publicKey, pub.length, 15);\n publicKey.set(pub, 19);\n\n return publicKey;\n}\n\nfunction genOpenSSLEdPriv(priv) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // version\n asnWriter.writeInt(0x00, Ber.Integer);\n\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.112'); // id-Ed25519\n asnWriter.endSequence();\n\n // PrivateKey\n asnWriter.startSequence(Ber.OctetString);\n asnWriter.writeBuffer(priv, Ber.OctetString);\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLECDSAPub(oid, Q) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.10045.2.1'); // id-ecPublicKey\n // algorithm parameters (namedCurve)\n asnWriter.writeOID(oid);\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(Q.length);\n asnWriter._buf.set(Q, asnWriter._offset);\n asnWriter._offset += Q.length;\n // end hack\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHECDSAPub(oid, Q) {\n let curveName;\n switch (oid) {\n case '1.2.840.10045.3.1.7':\n // prime256v1/secp256r1\n curveName = 'nistp256';\n break;\n case '1.3.132.0.34':\n // secp384r1\n curveName = 'nistp384';\n break;\n case '1.3.132.0.35':\n // secp521r1\n curveName = 'nistp521';\n break;\n default:\n return;\n }\n\n const publicKey = Buffer.allocUnsafe(4 + 19 + 4 + 8 + 4 + Q.length);\n\n writeUInt32BE(publicKey, 19, 0);\n publicKey.utf8Write(`ecdsa-sha2-${curveName}`, 4, 19);\n\n writeUInt32BE(publicKey, 8, 23);\n publicKey.utf8Write(curveName, 27, 8);\n\n writeUInt32BE(publicKey, Q.length, 35);\n publicKey.set(Q, 39);\n\n return publicKey;\n}\n\nfunction genOpenSSLECDSAPriv(oid, pub, priv) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // version\n asnWriter.writeInt(0x01, Ber.Integer);\n // privateKey\n asnWriter.writeBuffer(priv, Ber.OctetString);\n // parameters (optional)\n asnWriter.startSequence(0xA0);\n asnWriter.writeOID(oid);\n asnWriter.endSequence();\n // publicKey (optional)\n asnWriter.startSequence(0xA1);\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(pub.length);\n asnWriter._buf.set(pub, asnWriter._offset);\n asnWriter._offset += pub.length;\n // end hack\n asnWriter.endSequence();\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('EC PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLECDSAPubFromPriv(curveName, priv) {\n const tempECDH = createECDH(curveName);\n tempECDH.setPrivateKey(priv);\n return tempECDH.getPublicKey();\n}\n\nconst BaseKey = {\n sign: (() => {\n if (typeof sign_ === 'function') {\n return function sign(data, algo) {\n const pem = this[SYM_PRIV_PEM];\n if (pem === null)\n return new Error('No private key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n try {\n return sign_(algo, data, pem);\n } catch (ex) {\n return ex;\n }\n };\n }\n return function sign(data, algo) {\n const pem = this[SYM_PRIV_PEM];\n if (pem === null)\n return new Error('No private key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n const signature = createSign(algo);\n signature.update(data);\n try {\n return signature.sign(pem);\n } catch (ex) {\n return ex;\n }\n };\n })(),\n verify: (() => {\n if (typeof verify_ === 'function') {\n return function verify(data, signature, algo) {\n const pem = this[SYM_PUB_PEM];\n if (pem === null)\n return new Error('No public key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n try {\n return verify_(algo, data, pem, signature);\n } catch (ex) {\n return ex;\n }\n };\n }\n return function verify(data, signature, algo) {\n const pem = this[SYM_PUB_PEM];\n if (pem === null)\n return new Error('No public key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n const verifier = createVerify(algo);\n verifier.update(data);\n try {\n return verifier.verify(pem, signature);\n } catch (ex) {\n return ex;\n }\n };\n })(),\n isPrivateKey: function isPrivateKey() {\n return (this[SYM_PRIV_PEM] !== null);\n },\n getPrivatePEM: function getPrivatePEM() {\n return this[SYM_PRIV_PEM];\n },\n getPublicPEM: function getPublicPEM() {\n return this[SYM_PUB_PEM];\n },\n getPublicSSH: function getPublicSSH() {\n return this[SYM_PUB_SSH];\n },\n equals: function equals(key) {\n const parsed = parseKey(key);\n if (parsed instanceof Error)\n return false;\n return (\n this.type === parsed.type\n && this[SYM_PRIV_PEM] === parsed[SYM_PRIV_PEM]\n && this[SYM_PUB_PEM] === parsed[SYM_PUB_PEM]\n && this[SYM_PUB_SSH] === parsed[SYM_PUB_SSH]\n );\n },\n};\n\n\nfunction OpenSSH_Private(type, comment, privPEM, pubPEM, pubSSH, algo,\n decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nOpenSSH_Private.prototype = BaseKey;\n{\n const regexp = /^-----BEGIN OPENSSH PRIVATE KEY-----(?:\\r\\n|\\n)([\\s\\S]+)(?:\\r\\n|\\n)-----END OPENSSH PRIVATE KEY-----$/;\n OpenSSH_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n let ret;\n const data = Buffer.from(m[1], 'base64');\n if (data.length < 31) // magic (+ magic null term.) + minimum field lengths\n return new Error('Malformed OpenSSH private key');\n const magic = data.utf8Slice(0, 15);\n if (magic !== 'openssh-key-v1\\0')\n return new Error(`Unsupported OpenSSH key magic: ${magic}`);\n\n const cipherName = readString(data, 15, true);\n if (cipherName === undefined)\n return new Error('Malformed OpenSSH private key');\n if (cipherName !== 'none' && SUPPORTED_CIPHER.indexOf(cipherName) === -1)\n return new Error(`Unsupported cipher for OpenSSH key: ${cipherName}`);\n\n const kdfName = readString(data, data._pos, true);\n if (kdfName === undefined)\n return new Error('Malformed OpenSSH private key');\n if (kdfName !== 'none') {\n if (cipherName === 'none')\n return new Error('Malformed OpenSSH private key');\n if (kdfName !== 'bcrypt')\n return new Error(`Unsupported kdf name for OpenSSH key: ${kdfName}`);\n if (!passphrase) {\n return new Error(\n 'Encrypted private OpenSSH key detected, but no passphrase given'\n );\n }\n } else if (cipherName !== 'none') {\n return new Error('Malformed OpenSSH private key');\n }\n\n let encInfo;\n let cipherKey;\n let cipherIV;\n if (cipherName !== 'none')\n encInfo = CIPHER_INFO[cipherName];\n const kdfOptions = readString(data, data._pos);\n if (kdfOptions === undefined)\n return new Error('Malformed OpenSSH private key');\n if (kdfOptions.length) {\n switch (kdfName) {\n case 'none':\n return new Error('Malformed OpenSSH private key');\n case 'bcrypt':\n /*\n string salt\n uint32 rounds\n */\n const salt = readString(kdfOptions, 0);\n if (salt === undefined || kdfOptions._pos + 4 > kdfOptions.length)\n return new Error('Malformed OpenSSH private key');\n const rounds = readUInt32BE(kdfOptions, kdfOptions._pos);\n const gen = Buffer.allocUnsafe(encInfo.keyLen + encInfo.ivLen);\n const r = bcrypt_pbkdf(passphrase,\n passphrase.length,\n salt,\n salt.length,\n gen,\n gen.length,\n rounds);\n if (r !== 0)\n return new Error('Failed to generate information to decrypt key');\n cipherKey = bufferSlice(gen, 0, encInfo.keyLen);\n cipherIV = bufferSlice(gen, encInfo.keyLen, gen.length);\n break;\n }\n } else if (kdfName !== 'none') {\n return new Error('Malformed OpenSSH private key');\n }\n\n if (data._pos + 3 >= data.length)\n return new Error('Malformed OpenSSH private key');\n const keyCount = readUInt32BE(data, data._pos);\n data._pos += 4;\n\n if (keyCount > 0) {\n // TODO: place sensible limit on max `keyCount`\n\n // Read public keys first\n for (let i = 0; i < keyCount; ++i) {\n const pubData = readString(data, data._pos);\n if (pubData === undefined)\n return new Error('Malformed OpenSSH private key');\n const type = readString(pubData, 0, true);\n if (type === undefined)\n return new Error('Malformed OpenSSH private key');\n }\n\n let privBlob = readString(data, data._pos);\n if (privBlob === undefined)\n return new Error('Malformed OpenSSH private key');\n\n if (cipherKey !== undefined) {\n // Encrypted private key(s)\n if (privBlob.length < encInfo.blockLen\n || (privBlob.length % encInfo.blockLen) !== 0) {\n return new Error('Malformed OpenSSH private key');\n }\n try {\n const options = { authTagLength: encInfo.authLen };\n const decipher = createDecipheriv(encInfo.sslName,\n cipherKey,\n cipherIV,\n options);\n if (encInfo.authLen > 0) {\n if (data.length - data._pos < encInfo.authLen)\n return new Error('Malformed OpenSSH private key');\n decipher.setAuthTag(\n bufferSlice(data, data._pos, data._pos += encInfo.authLen)\n );\n }\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n } catch (ex) {\n return ex;\n }\n }\n // Nothing should we follow the private key(s), except a possible\n // authentication tag for relevant ciphers\n if (data._pos !== data.length)\n return new Error('Malformed OpenSSH private key');\n\n ret = parseOpenSSHPrivKeys(privBlob, keyCount, cipherKey !== undefined);\n } else {\n ret = [];\n }\n if (ret instanceof Error)\n return ret;\n // This will need to change if/when OpenSSH ever starts storing multiple\n // keys in their key files\n return ret[0];\n };\n\n function parseOpenSSHPrivKeys(data, nkeys, decrypted) {\n const keys = [];\n /*\n uint32 checkint\n uint32 checkint\n string privatekey1\n string comment1\n string privatekey2\n string comment2\n ...\n string privatekeyN\n string commentN\n char 1\n char 2\n char 3\n ...\n char padlen % 255\n */\n if (data.length < 8)\n return new Error('Malformed OpenSSH private key');\n const check1 = readUInt32BE(data, 0);\n const check2 = readUInt32BE(data, 4);\n if (check1 !== check2) {\n if (decrypted) {\n return new Error(\n 'OpenSSH key integrity check failed -- bad passphrase?'\n );\n }\n return new Error('OpenSSH key integrity check failed');\n }\n data._pos = 8;\n let i;\n let oid;\n for (i = 0; i < nkeys; ++i) {\n let algo;\n let privPEM;\n let pubPEM;\n let pubSSH;\n // The OpenSSH documentation for the key format actually lies, the\n // entirety of the private key content is not contained with a string\n // field, it's actually the literal contents of the private key, so to be\n // able to find the end of the key data you need to know the layout/format\n // of each key type ...\n const type = readString(data, data._pos, true);\n if (type === undefined)\n return new Error('Malformed OpenSSH private key');\n\n switch (type) {\n case 'ssh-rsa': {\n /*\n string n -- public\n string e -- public\n string d -- private\n string iqmp -- private\n string p -- private\n string q -- private\n */\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed OpenSSH private key');\n const e = readString(data, data._pos);\n if (e === undefined)\n return new Error('Malformed OpenSSH private key');\n const d = readString(data, data._pos);\n if (d === undefined)\n return new Error('Malformed OpenSSH private key');\n const iqmp = readString(data, data._pos);\n if (iqmp === undefined)\n return new Error('Malformed OpenSSH private key');\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed OpenSSH private key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n privPEM = genOpenSSLRSAPriv(n, e, d, iqmp, p, q);\n algo = 'sha1';\n break;\n }\n case 'ssh-dss': {\n /*\n string p -- public\n string q -- public\n string g -- public\n string y -- public\n string x -- private\n */\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed OpenSSH private key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH private key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed OpenSSH private key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed OpenSSH private key');\n const x = readString(data, data._pos);\n if (x === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n privPEM = genOpenSSLDSAPriv(p, q, g, y, x);\n algo = 'sha1';\n break;\n }\n case 'ssh-ed25519': {\n if (!eddsaSupported)\n return new Error(`Unsupported OpenSSH private key type: ${type}`);\n /*\n * string public key\n * string private key + public key\n */\n const edpub = readString(data, data._pos);\n if (edpub === undefined || edpub.length !== 32)\n return new Error('Malformed OpenSSH private key');\n const edpriv = readString(data, data._pos);\n if (edpriv === undefined || edpriv.length !== 64)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLEdPub(edpub);\n pubSSH = genOpenSSHEdPub(edpub);\n privPEM = genOpenSSLEdPriv(bufferSlice(edpriv, 0, 32));\n algo = null;\n break;\n }\n case 'ecdsa-sha2-nistp256':\n algo = 'sha256';\n oid = '1.2.840.10045.3.1.7';\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp384':\n if (algo === undefined) {\n algo = 'sha384';\n oid = '1.3.132.0.34';\n }\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp521': {\n if (algo === undefined) {\n algo = 'sha512';\n oid = '1.3.132.0.35';\n }\n /*\n string curve name\n string Q -- public\n string d -- private\n */\n // TODO: validate curve name against type\n if (!skipFields(data, 1)) // Skip curve name\n return new Error('Malformed OpenSSH private key');\n const ecpub = readString(data, data._pos);\n if (ecpub === undefined)\n return new Error('Malformed OpenSSH private key');\n const ecpriv = readString(data, data._pos);\n if (ecpriv === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLECDSAPub(oid, ecpub);\n pubSSH = genOpenSSHECDSAPub(oid, ecpub);\n privPEM = genOpenSSLECDSAPriv(oid, ecpub, ecpriv);\n break;\n }\n default:\n return new Error(`Unsupported OpenSSH private key type: ${type}`);\n }\n\n const privComment = readString(data, data._pos, true);\n if (privComment === undefined)\n return new Error('Malformed OpenSSH private key');\n\n keys.push(\n new OpenSSH_Private(type, privComment, privPEM, pubPEM, pubSSH, algo,\n decrypted)\n );\n }\n let cnt = 0;\n for (i = data._pos; i < data.length; ++i) {\n if (data[i] !== (++cnt % 255))\n return new Error('Malformed OpenSSH private key');\n }\n\n return keys;\n }\n}\n\n\nfunction OpenSSH_Old_Private(type, comment, privPEM, pubPEM, pubSSH, algo,\n decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nOpenSSH_Old_Private.prototype = BaseKey;\n{\n const regexp = /^-----BEGIN (RSA|DSA|EC) PRIVATE KEY-----(?:\\r\\n|\\n)((?:[^:]+:\\s*[\\S].*(?:\\r\\n|\\n))*)([\\s\\S]+)(?:\\r\\n|\\n)-----END (RSA|DSA|EC) PRIVATE KEY-----$/;\n OpenSSH_Old_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n let privBlob = Buffer.from(m[3], 'base64');\n let headers = m[2];\n let decrypted = false;\n if (headers !== undefined) {\n // encrypted key\n headers = headers.split(/\\r\\n|\\n/g);\n for (let i = 0; i < headers.length; ++i) {\n const header = headers[i];\n let sepIdx = header.indexOf(':');\n if (header.slice(0, sepIdx) === 'DEK-Info') {\n const val = header.slice(sepIdx + 2);\n sepIdx = val.indexOf(',');\n if (sepIdx === -1)\n continue;\n const cipherName = val.slice(0, sepIdx).toLowerCase();\n if (supportedOpenSSLCiphers.indexOf(cipherName) === -1) {\n return new Error(\n `Cipher (${cipherName}) not supported `\n + 'for encrypted OpenSSH private key'\n );\n }\n const encInfo = CIPHER_INFO_OPENSSL[cipherName];\n if (!encInfo) {\n return new Error(\n `Cipher (${cipherName}) not supported `\n + 'for encrypted OpenSSH private key'\n );\n }\n const cipherIV = Buffer.from(val.slice(sepIdx + 1), 'hex');\n if (cipherIV.length !== encInfo.ivLen)\n return new Error('Malformed encrypted OpenSSH private key');\n if (!passphrase) {\n return new Error(\n 'Encrypted OpenSSH private key detected, but no passphrase given'\n );\n }\n const ivSlice = bufferSlice(cipherIV, 0, 8);\n let cipherKey = createHash('md5')\n .update(passphrase)\n .update(ivSlice)\n .digest();\n while (cipherKey.length < encInfo.keyLen) {\n cipherKey = combineBuffers(\n cipherKey,\n createHash('md5')\n .update(cipherKey)\n .update(passphrase)\n .update(ivSlice)\n .digest()\n );\n }\n if (cipherKey.length > encInfo.keyLen)\n cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);\n try {\n const decipher = createDecipheriv(cipherName, cipherKey, cipherIV);\n decipher.setAutoPadding(false);\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n decrypted = true;\n } catch (ex) {\n return ex;\n }\n }\n }\n }\n\n let type;\n let privPEM;\n let pubPEM;\n let pubSSH;\n let algo;\n let reader;\n let errMsg = 'Malformed OpenSSH private key';\n if (decrypted)\n errMsg += '. Bad passphrase?';\n switch (m[1]) {\n case 'RSA':\n type = 'ssh-rsa';\n privPEM = makePEM('RSA PRIVATE', privBlob);\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n const n = reader.readString(Ber.Integer, true);\n if (n === null)\n return new Error(errMsg);\n const e = reader.readString(Ber.Integer, true);\n if (e === null)\n return new Error(errMsg);\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n } catch {\n return new Error(errMsg);\n }\n algo = 'sha1';\n break;\n case 'DSA':\n type = 'ssh-dss';\n privPEM = makePEM('DSA PRIVATE', privBlob);\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n const p = reader.readString(Ber.Integer, true);\n if (p === null)\n return new Error(errMsg);\n const q = reader.readString(Ber.Integer, true);\n if (q === null)\n return new Error(errMsg);\n const g = reader.readString(Ber.Integer, true);\n if (g === null)\n return new Error(errMsg);\n const y = reader.readString(Ber.Integer, true);\n if (y === null)\n return new Error(errMsg);\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n } catch {\n return new Error(errMsg);\n }\n algo = 'sha1';\n break;\n case 'EC':\n let ecSSLName;\n let ecPriv;\n let ecOID;\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n ecPriv = reader.readString(Ber.OctetString, true);\n reader.readByte(); // Skip \"complex\" context type byte\n const offset = reader.readLength(); // Skip context length\n if (offset !== null) {\n reader._offset = offset;\n ecOID = reader.readOID();\n if (ecOID === null)\n return new Error(errMsg);\n switch (ecOID) {\n case '1.2.840.10045.3.1.7':\n // prime256v1/secp256r1\n ecSSLName = 'prime256v1';\n type = 'ecdsa-sha2-nistp256';\n algo = 'sha256';\n break;\n case '1.3.132.0.34':\n // secp384r1\n ecSSLName = 'secp384r1';\n type = 'ecdsa-sha2-nistp384';\n algo = 'sha384';\n break;\n case '1.3.132.0.35':\n // secp521r1\n ecSSLName = 'secp521r1';\n type = 'ecdsa-sha2-nistp521';\n algo = 'sha512';\n break;\n default:\n return new Error(`Unsupported private key EC OID: ${ecOID}`);\n }\n } else {\n return new Error(errMsg);\n }\n } catch {\n return new Error(errMsg);\n }\n privPEM = makePEM('EC PRIVATE', privBlob);\n const pubBlob = genOpenSSLECDSAPubFromPriv(ecSSLName, ecPriv);\n pubPEM = genOpenSSLECDSAPub(ecOID, pubBlob);\n pubSSH = genOpenSSHECDSAPub(ecOID, pubBlob);\n break;\n }\n\n return new OpenSSH_Old_Private(type, '', privPEM, pubPEM, pubSSH, algo,\n decrypted);\n };\n}\n\n\nfunction PPK_Private(type, comment, privPEM, pubPEM, pubSSH, algo, decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nPPK_Private.prototype = BaseKey;\n{\n const EMPTY_PASSPHRASE = Buffer.alloc(0);\n const PPK_IV = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);\n const PPK_PP1 = Buffer.from([0, 0, 0, 0]);\n const PPK_PP2 = Buffer.from([0, 0, 0, 1]);\n const regexp = /^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\\r?\\nEncryption: (aes256-cbc|none)\\r?\\nComment: ([^\\r\\n]*)\\r?\\nPublic-Lines: \\d+\\r?\\n([\\s\\S]+?)\\r?\\nPrivate-Lines: \\d+\\r?\\n([\\s\\S]+?)\\r?\\nPrivate-MAC: ([^\\r\\n]+)/;\n PPK_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n // m[1] = key type\n // m[2] = encryption type\n // m[3] = comment\n // m[4] = base64-encoded public key data:\n // for \"ssh-rsa\":\n // string \"ssh-rsa\"\n // mpint e (public exponent)\n // mpint n (modulus)\n // for \"ssh-dss\":\n // string \"ssh-dss\"\n // mpint p (modulus)\n // mpint q (prime)\n // mpint g (base number)\n // mpint y (public key parameter: g^x mod p)\n // m[5] = base64-encoded private key data:\n // for \"ssh-rsa\":\n // mpint d (private exponent)\n // mpint p (prime 1)\n // mpint q (prime 2)\n // mpint iqmp ([inverse of q] mod p)\n // for \"ssh-dss\":\n // mpint x (private key parameter)\n // m[6] = SHA1 HMAC over:\n // string name of algorithm (\"ssh-dss\", \"ssh-rsa\")\n // string encryption type\n // string comment\n // string public key data\n // string private-plaintext (including the final padding)\n const cipherName = m[2];\n const encrypted = (cipherName !== 'none');\n if (encrypted && !passphrase) {\n return new Error(\n 'Encrypted PPK private key detected, but no passphrase given'\n );\n }\n\n let privBlob = Buffer.from(m[5], 'base64');\n\n if (encrypted) {\n const encInfo = CIPHER_INFO[cipherName];\n let cipherKey = combineBuffers(\n createHash('sha1').update(PPK_PP1).update(passphrase).digest(),\n createHash('sha1').update(PPK_PP2).update(passphrase).digest()\n );\n if (cipherKey.length > encInfo.keyLen)\n cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);\n try {\n const decipher = createDecipheriv(encInfo.sslName,\n cipherKey,\n PPK_IV);\n decipher.setAutoPadding(false);\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n } catch (ex) {\n return ex;\n }\n }\n\n const type = m[1];\n const comment = m[3];\n const pubBlob = Buffer.from(m[4], 'base64');\n\n const mac = m[6];\n const typeLen = type.length;\n const cipherNameLen = cipherName.length;\n const commentLen = Buffer.byteLength(comment);\n const pubLen = pubBlob.length;\n const privLen = privBlob.length;\n const macData = Buffer.allocUnsafe(4 + typeLen\n + 4 + cipherNameLen\n + 4 + commentLen\n + 4 + pubLen\n + 4 + privLen);\n let p = 0;\n\n writeUInt32BE(macData, typeLen, p);\n macData.utf8Write(type, p += 4, typeLen);\n writeUInt32BE(macData, cipherNameLen, p += typeLen);\n macData.utf8Write(cipherName, p += 4, cipherNameLen);\n writeUInt32BE(macData, commentLen, p += cipherNameLen);\n macData.utf8Write(comment, p += 4, commentLen);\n writeUInt32BE(macData, pubLen, p += commentLen);\n macData.set(pubBlob, p += 4);\n writeUInt32BE(macData, privLen, p += pubLen);\n macData.set(privBlob, p + 4);\n\n if (!passphrase)\n passphrase = EMPTY_PASSPHRASE;\n\n const calcMAC = createHmac(\n 'sha1',\n createHash('sha1')\n .update('putty-private-key-file-mac-key')\n .update(passphrase)\n .digest()\n ).update(macData).digest('hex');\n\n if (calcMAC !== mac) {\n if (encrypted) {\n return new Error(\n 'PPK private key integrity check failed -- bad passphrase?'\n );\n }\n return new Error('PPK private key integrity check failed');\n }\n\n let pubPEM;\n let pubSSH;\n let privPEM;\n pubBlob._pos = 0;\n skipFields(pubBlob, 1); // skip (duplicate) key type\n switch (type) {\n case 'ssh-rsa': {\n const e = readString(pubBlob, pubBlob._pos);\n if (e === undefined)\n return new Error('Malformed PPK public key');\n const n = readString(pubBlob, pubBlob._pos);\n if (n === undefined)\n return new Error('Malformed PPK public key');\n const d = readString(privBlob, 0);\n if (d === undefined)\n return new Error('Malformed PPK private key');\n const p = readString(privBlob, privBlob._pos);\n if (p === undefined)\n return new Error('Malformed PPK private key');\n const q = readString(privBlob, privBlob._pos);\n if (q === undefined)\n return new Error('Malformed PPK private key');\n const iqmp = readString(privBlob, privBlob._pos);\n if (iqmp === undefined)\n return new Error('Malformed PPK private key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n privPEM = genOpenSSLRSAPriv(n, e, d, iqmp, p, q);\n break;\n }\n case 'ssh-dss': {\n const p = readString(pubBlob, pubBlob._pos);\n if (p === undefined)\n return new Error('Malformed PPK public key');\n const q = readString(pubBlob, pubBlob._pos);\n if (q === undefined)\n return new Error('Malformed PPK public key');\n const g = readString(pubBlob, pubBlob._pos);\n if (g === undefined)\n return new Error('Malformed PPK public key');\n const y = readString(pubBlob, pubBlob._pos);\n if (y === undefined)\n return new Error('Malformed PPK public key');\n const x = readString(privBlob, 0);\n if (x === undefined)\n return new Error('Malformed PPK private key');\n\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n privPEM = genOpenSSLDSAPriv(p, q, g, y, x);\n break;\n }\n }\n\n return new PPK_Private(type, comment, privPEM, pubPEM, pubSSH, 'sha1',\n encrypted);\n };\n}\n\n\nfunction OpenSSH_Public(type, comment, pubPEM, pubSSH, algo) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = null;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = false;\n}\nOpenSSH_Public.prototype = BaseKey;\n{\n let regexp;\n if (eddsaSupported)\n regexp = /^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\\s+([\\S].*)?)$/;\n else\n regexp = /^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\\s+([\\S].*)?)$/;\n OpenSSH_Public.parse = (str) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n // m[1] = full type\n // m[2] = base type\n // m[3] = base64-encoded public key\n // m[4] = comment\n\n const fullType = m[1];\n const baseType = m[2];\n const data = Buffer.from(m[3], 'base64');\n const comment = (m[4] || '');\n\n const type = readString(data, data._pos, true);\n if (type === undefined || type.indexOf(baseType) !== 0)\n return new Error('Malformed OpenSSH public key');\n\n return parseDER(data, baseType, comment, fullType);\n };\n}\n\n\nfunction RFC4716_Public(type, comment, pubPEM, pubSSH, algo) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = null;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = false;\n}\nRFC4716_Public.prototype = BaseKey;\n{\n const regexp = /^---- BEGIN SSH2 PUBLIC KEY ----(?:\\r?\\n)((?:.{0,72}\\r?\\n)+)---- END SSH2 PUBLIC KEY ----$/;\n const RE_DATA = /^[A-Z0-9a-z/+=\\r\\n]+$/;\n const RE_HEADER = /^([\\x21-\\x39\\x3B-\\x7E]{1,64}): ((?:[^\\\\]*\\\\\\r?\\n)*[^\\r\\n]+)\\r?\\n/gm;\n const RE_HEADER_ENDS = /\\\\\\r?\\n/g;\n RFC4716_Public.parse = (str) => {\n let m = regexp.exec(str);\n if (m === null)\n return null;\n\n const body = m[1];\n let dataStart = 0;\n let comment = '';\n\n while (m = RE_HEADER.exec(body)) {\n const headerName = m[1];\n const headerValue = m[2].replace(RE_HEADER_ENDS, '');\n if (headerValue.length > 1024) {\n RE_HEADER.lastIndex = 0;\n return new Error('Malformed RFC4716 public key');\n }\n\n dataStart = RE_HEADER.lastIndex;\n\n if (headerName.toLowerCase() === 'comment') {\n comment = headerValue;\n if (comment.length > 1\n && comment.charCodeAt(0) === 34/* '\"' */\n && comment.charCodeAt(comment.length - 1) === 34/* '\"' */) {\n comment = comment.slice(1, -1);\n }\n }\n }\n\n let data = body.slice(dataStart);\n if (!RE_DATA.test(data))\n return new Error('Malformed RFC4716 public key');\n\n data = Buffer.from(data, 'base64');\n\n const type = readString(data, 0, true);\n if (type === undefined)\n return new Error('Malformed RFC4716 public key');\n\n let pubPEM = null;\n let pubSSH = null;\n switch (type) {\n case 'ssh-rsa': {\n const e = readString(data, data._pos);\n if (e === undefined)\n return new Error('Malformed RFC4716 public key');\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed RFC4716 public key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n break;\n }\n case 'ssh-dss': {\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed RFC4716 public key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed RFC4716 public key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed RFC4716 public key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed RFC4716 public key');\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n break;\n }\n default:\n return new Error('Malformed RFC4716 public key');\n }\n\n return new RFC4716_Public(type, comment, pubPEM, pubSSH, 'sha1');\n };\n}\n\n\nfunction parseDER(data, baseType, comment, fullType) {\n if (!isSupportedKeyType(baseType))\n return new Error(`Unsupported OpenSSH public key type: ${baseType}`);\n\n let algo;\n let oid;\n let pubPEM = null;\n let pubSSH = null;\n\n switch (baseType) {\n case 'ssh-rsa': {\n const e = readString(data, data._pos || 0);\n if (e === undefined)\n return new Error('Malformed OpenSSH public key');\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n algo = 'sha1';\n break;\n }\n case 'ssh-dss': {\n const p = readString(data, data._pos || 0);\n if (p === undefined)\n return new Error('Malformed OpenSSH public key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH public key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed OpenSSH public key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n algo = 'sha1';\n break;\n }\n case 'ssh-ed25519': {\n const edpub = readString(data, data._pos || 0);\n if (edpub === undefined || edpub.length !== 32)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLEdPub(edpub);\n pubSSH = genOpenSSHEdPub(edpub);\n algo = null;\n break;\n }\n case 'ecdsa-sha2-nistp256':\n algo = 'sha256';\n oid = '1.2.840.10045.3.1.7';\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp384':\n if (algo === undefined) {\n algo = 'sha384';\n oid = '1.3.132.0.34';\n }\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp521': {\n if (algo === undefined) {\n algo = 'sha512';\n oid = '1.3.132.0.35';\n }\n // TODO: validate curve name against type\n if (!skipFields(data, 1)) // Skip curve name\n return new Error('Malformed OpenSSH public key');\n const ecpub = readString(data, data._pos || 0);\n if (ecpub === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLECDSAPub(oid, ecpub);\n pubSSH = genOpenSSHECDSAPub(oid, ecpub);\n break;\n }\n default:\n return new Error(`Unsupported OpenSSH public key type: ${baseType}`);\n }\n\n return new OpenSSH_Public(fullType, comment, pubPEM, pubSSH, algo);\n}\n\nfunction isSupportedKeyType(type) {\n switch (type) {\n case 'ssh-rsa':\n case 'ssh-dss':\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521':\n return true;\n case 'ssh-ed25519':\n if (eddsaSupported)\n return true;\n // FALLTHROUGH\n default:\n return false;\n }\n}\n\nfunction isParsedKey(val) {\n if (!val)\n return false;\n return (typeof val[SYM_DECRYPTED] === 'boolean');\n}\n\nfunction parseKey(data, passphrase) {\n if (isParsedKey(data))\n return data;\n\n let origBuffer;\n if (Buffer.isBuffer(data)) {\n origBuffer = data;\n data = data.utf8Slice(0, data.length).trim();\n } else if (typeof data === 'string') {\n data = data.trim();\n } else {\n return new Error('Key data must be a Buffer or string');\n }\n\n // eslint-disable-next-line eqeqeq\n if (passphrase != undefined) {\n if (typeof passphrase === 'string')\n passphrase = Buffer.from(passphrase);\n else if (!Buffer.isBuffer(passphrase))\n return new Error('Passphrase must be a string or Buffer when supplied');\n }\n\n let ret;\n\n // First try as printable string format (e.g. PEM)\n\n // Private keys\n if ((ret = OpenSSH_Private.parse(data, passphrase)) !== null)\n return ret;\n if ((ret = OpenSSH_Old_Private.parse(data, passphrase)) !== null)\n return ret;\n if ((ret = PPK_Private.parse(data, passphrase)) !== null)\n return ret;\n\n // Public keys\n if ((ret = OpenSSH_Public.parse(data)) !== null)\n return ret;\n if ((ret = RFC4716_Public.parse(data)) !== null)\n return ret;\n\n // Finally try as a binary format if we were originally passed binary data\n if (origBuffer) {\n binaryKeyParser.init(origBuffer, 0);\n const type = binaryKeyParser.readString(true);\n if (type !== undefined) {\n data = binaryKeyParser.readRaw();\n if (data !== undefined) {\n ret = parseDER(data, type, '', type);\n // Ignore potentially useless errors in case the data was not actually\n // in the binary format\n if (ret instanceof Error)\n ret = null;\n }\n }\n binaryKeyParser.clear();\n }\n\n if (ret)\n return ret;\n\n return new Error('Unsupported key format');\n}\n\nmodule.exports = {\n isParsedKey,\n isSupportedKeyType,\n parseDERKey: (data, type) => parseDER(data, type, '', type),\n parseKey,\n};\n","'use strict';\n\nconst assert = require('assert');\nconst { inspect } = require('util');\n\n// Only use this for integers! Decimal numbers do not work with this function.\nfunction addNumericalSeparator(val) {\n let res = '';\n let i = val.length;\n const start = val[0] === '-' ? 1 : 0;\n for (; i >= start + 4; i -= 3)\n res = `_${val.slice(i - 3, i)}${res}`;\n return `${val.slice(0, i)}${res}`;\n}\n\nfunction oneOf(expected, thing) {\n assert(typeof thing === 'string', '`thing` has to be of type string');\n if (Array.isArray(expected)) {\n const len = expected.length;\n assert(len > 0, 'At least one expected value needs to be specified');\n expected = expected.map((i) => String(i));\n if (len > 2) {\n return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or `\n + expected[len - 1];\n } else if (len === 2) {\n return `one of ${thing} ${expected[0]} or ${expected[1]}`;\n }\n return `of ${thing} ${expected[0]}`;\n }\n return `of ${thing} ${String(expected)}`;\n}\n\n\nexports.ERR_INTERNAL_ASSERTION = class ERR_INTERNAL_ASSERTION extends Error {\n constructor(message) {\n super();\n Error.captureStackTrace(this, ERR_INTERNAL_ASSERTION);\n\n const suffix = 'This is caused by either a bug in ssh2 '\n + 'or incorrect usage of ssh2 internals.\\n'\n + 'Please open an issue with this stack trace at '\n + 'https://github.com/mscdex/ssh2/issues\\n';\n\n this.message = (message === undefined ? suffix : `${message}\\n${suffix}`);\n }\n};\n\nconst MAX_32BIT_INT = 2 ** 32;\nconst MAX_32BIT_BIGINT = (() => {\n try {\n return new Function('return 2n ** 32n')();\n } catch {}\n})();\nexports.ERR_OUT_OF_RANGE = class ERR_OUT_OF_RANGE extends RangeError {\n constructor(str, range, input, replaceDefaultBoolean) {\n super();\n Error.captureStackTrace(this, ERR_OUT_OF_RANGE);\n\n assert(range, 'Missing \"range\" argument');\n let msg = (replaceDefaultBoolean\n ? str\n : `The value of \"${str}\" is out of range.`);\n let received;\n if (Number.isInteger(input) && Math.abs(input) > MAX_32BIT_INT) {\n received = addNumericalSeparator(String(input));\n } else if (typeof input === 'bigint') {\n received = String(input);\n if (input > MAX_32BIT_BIGINT || input < -MAX_32BIT_BIGINT)\n received = addNumericalSeparator(received);\n received += 'n';\n } else {\n received = inspect(input);\n }\n msg += ` It must be ${range}. Received ${received}`;\n\n this.message = msg;\n }\n};\n\nclass ERR_INVALID_ARG_TYPE extends TypeError {\n constructor(name, expected, actual) {\n super();\n Error.captureStackTrace(this, ERR_INVALID_ARG_TYPE);\n\n assert(typeof name === 'string', `'name' must be a string`);\n\n // determiner: 'must be' or 'must not be'\n let determiner;\n if (typeof expected === 'string' && expected.startsWith('not ')) {\n determiner = 'must not be';\n expected = expected.replace(/^not /, '');\n } else {\n determiner = 'must be';\n }\n\n let msg;\n if (name.endsWith(' argument')) {\n // For cases like 'first argument'\n msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;\n } else {\n const type = (name.includes('.') ? 'property' : 'argument');\n msg = `The \"${name}\" ${type} ${determiner} ${oneOf(expected, 'type')}`;\n }\n\n msg += `. Received type ${typeof actual}`;\n\n this.message = msg;\n }\n}\nexports.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;\n\nexports.validateNumber = function validateNumber(value, name) {\n if (typeof value !== 'number')\n throw new ERR_INVALID_ARG_TYPE(name, 'number', value);\n};\n","'use strict';\n\nconst Ber = require('asn1').Ber;\n\nlet DISCONNECT_REASON;\n\nconst FastBuffer = Buffer[Symbol.species];\nconst TypedArrayFill = Object.getPrototypeOf(Uint8Array.prototype).fill;\n\nfunction readUInt32BE(buf, offset) {\n return (buf[offset++] * 16777216)\n + (buf[offset++] * 65536)\n + (buf[offset++] * 256)\n + buf[offset];\n}\n\nfunction bufferCopy(src, dest, srcStart, srcEnd, destStart) {\n if (!destStart)\n destStart = 0;\n if (srcEnd > src.length)\n srcEnd = src.length;\n let nb = srcEnd - srcStart;\n const destLeft = (dest.length - destStart);\n if (nb > destLeft)\n nb = destLeft;\n dest.set(new Uint8Array(src.buffer, src.byteOffset + srcStart, nb),\n destStart);\n return nb;\n}\n\nfunction bufferSlice(buf, start, end) {\n if (end === undefined)\n end = buf.length;\n return new FastBuffer(buf.buffer, buf.byteOffset + start, end - start);\n}\n\nfunction makeBufferParser() {\n let pos = 0;\n let buffer;\n\n const self = {\n init: (buf, start) => {\n buffer = buf;\n pos = (typeof start === 'number' ? start : 0);\n },\n pos: () => pos,\n length: () => (buffer ? buffer.length : 0),\n avail: () => (buffer && pos < buffer.length ? buffer.length - pos : 0),\n clear: () => {\n buffer = undefined;\n },\n readUInt32BE: () => {\n if (!buffer || pos + 3 >= buffer.length)\n return;\n return (buffer[pos++] * 16777216)\n + (buffer[pos++] * 65536)\n + (buffer[pos++] * 256)\n + buffer[pos++];\n },\n readUInt64BE: (behavior) => {\n if (!buffer || pos + 7 >= buffer.length)\n return;\n switch (behavior) {\n case 'always':\n return BigInt(`0x${buffer.hexSlice(pos, pos += 8)}`);\n case 'maybe':\n if (buffer[pos] > 0x1F)\n return BigInt(`0x${buffer.hexSlice(pos, pos += 8)}`);\n // FALLTHROUGH\n default:\n return (buffer[pos++] * 72057594037927940)\n + (buffer[pos++] * 281474976710656)\n + (buffer[pos++] * 1099511627776)\n + (buffer[pos++] * 4294967296)\n + (buffer[pos++] * 16777216)\n + (buffer[pos++] * 65536)\n + (buffer[pos++] * 256)\n + buffer[pos++];\n }\n },\n skip: (n) => {\n if (buffer && n > 0)\n pos += n;\n },\n skipString: () => {\n const len = self.readUInt32BE();\n if (len === undefined)\n return;\n pos += len;\n return (pos <= buffer.length ? len : undefined);\n },\n readByte: () => {\n if (buffer && pos < buffer.length)\n return buffer[pos++];\n },\n readBool: () => {\n if (buffer && pos < buffer.length)\n return !!buffer[pos++];\n },\n readList: () => {\n const list = self.readString(true);\n if (list === undefined)\n return;\n return (list ? list.split(',') : []);\n },\n readString: (dest, maxLen) => {\n if (typeof dest === 'number') {\n maxLen = dest;\n dest = undefined;\n }\n\n const len = self.readUInt32BE();\n if (len === undefined)\n return;\n\n if ((buffer.length - pos) < len\n || (typeof maxLen === 'number' && len > maxLen)) {\n return;\n }\n\n if (dest) {\n if (Buffer.isBuffer(dest))\n return bufferCopy(buffer, dest, pos, pos += len);\n return buffer.utf8Slice(pos, pos += len);\n }\n return bufferSlice(buffer, pos, pos += len);\n },\n readRaw: (len) => {\n if (!buffer)\n return;\n if (typeof len !== 'number')\n return bufferSlice(buffer, pos, pos += (buffer.length - pos));\n if ((buffer.length - pos) >= len)\n return bufferSlice(buffer, pos, pos += len);\n },\n };\n\n return self;\n}\n\nfunction makeError(msg, level, fatal) {\n const err = new Error(msg);\n if (typeof level === 'boolean') {\n fatal = level;\n err.level = 'protocol';\n } else {\n err.level = level || 'protocol';\n }\n err.fatal = !!fatal;\n return err;\n}\n\nfunction writeUInt32BE(buf, value, offset) {\n buf[offset++] = (value >>> 24);\n buf[offset++] = (value >>> 16);\n buf[offset++] = (value >>> 8);\n buf[offset++] = value;\n return offset;\n}\n\nconst utilBufferParser = makeBufferParser();\n\nmodule.exports = {\n bufferCopy,\n bufferSlice,\n FastBuffer,\n bufferFill: (buf, value, start, end) => {\n return TypedArrayFill.call(buf, value, start, end);\n },\n makeError,\n doFatalError: (protocol, msg, level, reason) => {\n let err;\n if (DISCONNECT_REASON === undefined)\n ({ DISCONNECT_REASON } = require('./utils.js'));\n if (msg instanceof Error) {\n // doFatalError(protocol, err[, reason])\n err = msg;\n if (typeof level !== 'number')\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n else\n reason = level;\n } else {\n // doFatalError(protocol, msg[, level[, reason]])\n err = makeError(msg, level, true);\n }\n if (typeof reason !== 'number')\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n protocol.disconnect(reason);\n protocol._destruct();\n protocol._onError(err);\n return Infinity;\n },\n readUInt32BE,\n writeUInt32BE,\n writeUInt32LE: (buf, value, offset) => {\n buf[offset++] = value;\n buf[offset++] = (value >>> 8);\n buf[offset++] = (value >>> 16);\n buf[offset++] = (value >>> 24);\n return offset;\n },\n makeBufferParser,\n bufferParser: makeBufferParser(),\n readString: (buffer, start, dest, maxLen) => {\n if (typeof dest === 'number') {\n maxLen = dest;\n dest = undefined;\n }\n\n if (start === undefined)\n start = 0;\n\n const left = (buffer.length - start);\n if (start < 0 || start >= buffer.length || left < 4)\n return;\n\n const len = readUInt32BE(buffer, start);\n if (left < (4 + len) || (typeof maxLen === 'number' && len > maxLen))\n return;\n\n start += 4;\n const end = start + len;\n buffer._pos = end;\n\n if (dest) {\n if (Buffer.isBuffer(dest))\n return bufferCopy(buffer, dest, start, end);\n return buffer.utf8Slice(start, end);\n }\n return bufferSlice(buffer, start, end);\n },\n sigSSHToASN1: (sig, type) => {\n switch (type) {\n case 'ssh-dss': {\n if (sig.length > 40)\n return sig;\n // Change bare signature r and s values to ASN.1 BER values for OpenSSL\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n let r = sig.slice(0, 20);\n let s = sig.slice(20);\n if (r[0] & 0x80) {\n const rNew = Buffer.allocUnsafe(21);\n rNew[0] = 0x00;\n r.copy(rNew, 1);\n r = rNew;\n } else if (r[0] === 0x00 && !(r[1] & 0x80)) {\n r = r.slice(1);\n }\n if (s[0] & 0x80) {\n const sNew = Buffer.allocUnsafe(21);\n sNew[0] = 0x00;\n s.copy(sNew, 1);\n s = sNew;\n } else if (s[0] === 0x00 && !(s[1] & 0x80)) {\n s = s.slice(1);\n }\n asnWriter.writeBuffer(r, Ber.Integer);\n asnWriter.writeBuffer(s, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521': {\n utilBufferParser.init(sig, 0);\n const r = utilBufferParser.readString();\n const s = utilBufferParser.readString();\n utilBufferParser.clear();\n if (r === undefined || s === undefined)\n return;\n\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeBuffer(r, Ber.Integer);\n asnWriter.writeBuffer(s, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n default:\n return sig;\n }\n },\n convertSignature: (signature, keyType) => {\n switch (keyType) {\n case 'ssh-dss': {\n if (signature.length <= 40)\n return signature;\n // This is a quick and dirty way to get from BER encoded r and s that\n // OpenSSL gives us, to just the bare values back to back (40 bytes\n // total) like OpenSSH (and possibly others) are expecting\n const asnReader = new Ber.Reader(signature);\n asnReader.readSequence();\n let r = asnReader.readString(Ber.Integer, true);\n let s = asnReader.readString(Ber.Integer, true);\n let rOffset = 0;\n let sOffset = 0;\n if (r.length < 20) {\n const rNew = Buffer.allocUnsafe(20);\n rNew.set(r, 1);\n r = rNew;\n r[0] = 0;\n }\n if (s.length < 20) {\n const sNew = Buffer.allocUnsafe(20);\n sNew.set(s, 1);\n s = sNew;\n s[0] = 0;\n }\n if (r.length > 20 && r[0] === 0)\n rOffset = 1;\n if (s.length > 20 && s[0] === 0)\n sOffset = 1;\n const newSig =\n Buffer.allocUnsafe((r.length - rOffset) + (s.length - sOffset));\n bufferCopy(r, newSig, rOffset, r.length, 0);\n bufferCopy(s, newSig, sOffset, s.length, r.length - rOffset);\n return newSig;\n }\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521': {\n if (signature[0] === 0)\n return signature;\n // Convert SSH signature parameters to ASN.1 BER values for OpenSSL\n const asnReader = new Ber.Reader(signature);\n asnReader.readSequence();\n const r = asnReader.readString(Ber.Integer, true);\n const s = asnReader.readString(Ber.Integer, true);\n if (r === null || s === null)\n return;\n const newSig = Buffer.allocUnsafe(4 + r.length + 4 + s.length);\n writeUInt32BE(newSig, r.length, 0);\n newSig.set(r, 4);\n writeUInt32BE(newSig, s.length, 4 + r.length);\n newSig.set(s, 4 + 4 + r.length);\n return newSig;\n }\n }\n\n return signature;\n },\n sendPacket: (proto, packet, bypass) => {\n if (!bypass && proto._kexinit !== undefined) {\n // We're currently in the middle of a handshake\n\n if (proto._queue === undefined)\n proto._queue = [];\n proto._queue.push(packet);\n proto._debug && proto._debug('Outbound: ... packet queued');\n return false;\n }\n proto._cipher.encrypt(packet);\n return true;\n },\n};\n","'use strict';\n\nconst { kMaxLength } = require('buffer');\nconst {\n createInflate,\n constants: {\n DEFLATE,\n INFLATE,\n Z_DEFAULT_CHUNK,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_MEMLEVEL,\n Z_DEFAULT_STRATEGY,\n Z_DEFAULT_WINDOWBITS,\n Z_PARTIAL_FLUSH,\n }\n} = require('zlib');\nconst ZlibHandle = createInflate()._handle.constructor;\n\nfunction processCallback() {\n throw new Error('Should not get here');\n}\n\nfunction zlibOnError(message, errno, code) {\n const self = this._owner;\n // There is no way to cleanly recover.\n // Continuing only obscures problems.\n\n const error = new Error(message);\n error.errno = errno;\n error.code = code;\n self._err = error;\n}\n\nfunction _close(engine) {\n // Caller may invoke .close after a zlib error (which will null _handle).\n if (!engine._handle)\n return;\n\n engine._handle.close();\n engine._handle = null;\n}\n\nclass Zlib {\n constructor(mode) {\n const windowBits = Z_DEFAULT_WINDOWBITS;\n const level = Z_DEFAULT_COMPRESSION;\n const memLevel = Z_DEFAULT_MEMLEVEL;\n const strategy = Z_DEFAULT_STRATEGY;\n const dictionary = undefined;\n\n this._err = undefined;\n this._writeState = new Uint32Array(2);\n this._chunkSize = Z_DEFAULT_CHUNK;\n this._maxOutputLength = kMaxLength;\n this._outBuffer = Buffer.allocUnsafe(this._chunkSize);\n this._outOffset = 0;\n\n this._handle = new ZlibHandle(mode);\n this._handle._owner = this;\n this._handle.onerror = zlibOnError;\n this._handle.init(windowBits,\n level,\n memLevel,\n strategy,\n this._writeState,\n processCallback,\n dictionary);\n }\n\n writeSync(chunk, retChunks) {\n const handle = this._handle;\n if (!handle)\n throw new Error('Invalid Zlib instance');\n\n let availInBefore = chunk.length;\n let availOutBefore = this._chunkSize - this._outOffset;\n let inOff = 0;\n let availOutAfter;\n let availInAfter;\n\n let buffers;\n let nread = 0;\n const state = this._writeState;\n let buffer = this._outBuffer;\n let offset = this._outOffset;\n const chunkSize = this._chunkSize;\n\n while (true) {\n handle.writeSync(Z_PARTIAL_FLUSH,\n chunk, // in\n inOff, // in_off\n availInBefore, // in_len\n buffer, // out\n offset, // out_off\n availOutBefore); // out_len\n if (this._err)\n throw this._err;\n\n availOutAfter = state[0];\n availInAfter = state[1];\n\n const inDelta = availInBefore - availInAfter;\n const have = availOutBefore - availOutAfter;\n\n if (have > 0) {\n const out = (offset === 0 && have === buffer.length\n ? buffer\n : buffer.slice(offset, offset + have));\n offset += have;\n if (!buffers)\n buffers = out;\n else if (buffers.push === undefined)\n buffers = [buffers, out];\n else\n buffers.push(out);\n nread += out.byteLength;\n\n if (nread > this._maxOutputLength) {\n _close(this);\n throw new Error(\n `Output length exceeded maximum of ${this._maxOutputLength}`\n );\n }\n } else if (have !== 0) {\n throw new Error('have should not go down');\n }\n\n // Exhausted the output buffer, or used all the input create a new one.\n if (availOutAfter === 0 || offset >= chunkSize) {\n availOutBefore = chunkSize;\n offset = 0;\n buffer = Buffer.allocUnsafe(chunkSize);\n }\n\n if (availOutAfter === 0) {\n // Not actually done. Need to reprocess.\n // Also, update the availInBefore to the availInAfter value,\n // so that if we have to hit it a third (fourth, etc.) time,\n // it'll have the correct byte counts.\n inOff += inDelta;\n availInBefore = availInAfter;\n } else {\n break;\n }\n }\n\n this._outBuffer = buffer;\n this._outOffset = offset;\n\n if (nread === 0)\n buffers = Buffer.alloc(0);\n\n if (retChunks) {\n buffers.totalLen = nread;\n return buffers;\n }\n\n if (buffers.push === undefined)\n return buffers;\n\n const output = Buffer.allocUnsafe(nread);\n for (let i = 0, p = 0; i < buffers.length; ++i) {\n const buf = buffers[i];\n output.set(buf, p);\n p += buf.length;\n }\n return output;\n }\n}\n\nclass ZlibPacketWriter {\n constructor(protocol) {\n this.allocStart = 0;\n this.allocStartKEX = 0;\n this._protocol = protocol;\n this._zlib = new Zlib(DEFLATE);\n }\n\n cleanup() {\n if (this._zlib)\n _close(this._zlib);\n }\n\n alloc(payloadSize, force) {\n return Buffer.allocUnsafe(payloadSize);\n }\n\n finalize(payload, force) {\n if (this._protocol._kexinit === undefined || force) {\n const output = this._zlib.writeSync(payload, true);\n const packet = this._protocol._cipher.allocPacket(output.totalLen);\n if (output.push === undefined) {\n packet.set(output, 5);\n } else {\n for (let i = 0, p = 5; i < output.length; ++i) {\n const chunk = output[i];\n packet.set(chunk, p);\n p += chunk.length;\n }\n }\n return packet;\n }\n return payload;\n }\n}\n\nclass PacketWriter {\n constructor(protocol) {\n this.allocStart = 5;\n this.allocStartKEX = 5;\n this._protocol = protocol;\n }\n\n cleanup() {}\n\n alloc(payloadSize, force) {\n if (this._protocol._kexinit === undefined || force)\n return this._protocol._cipher.allocPacket(payloadSize);\n return Buffer.allocUnsafe(payloadSize);\n }\n\n finalize(packet, force) {\n return packet;\n }\n}\n\nclass ZlibPacketReader {\n constructor() {\n this._zlib = new Zlib(INFLATE);\n }\n\n cleanup() {\n if (this._zlib)\n _close(this._zlib);\n }\n\n read(data) {\n return this._zlib.writeSync(data, false);\n }\n}\n\nclass PacketReader {\n cleanup() {}\n\n read(data) {\n return data;\n }\n}\n\nmodule.exports = {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n};\n","// TODO:\n// * convert listenerCount() usage to emit() return value checking?\n// * emit error when connection severed early (e.g. before handshake)\n// * add '.connected' or similar property to connection objects to allow\n// immediate connection status checking\n'use strict';\n\nconst { Server: netServer } = require('net');\nconst EventEmitter = require('events');\nconst { listenerCount } = EventEmitter;\n\nconst {\n CHANNEL_OPEN_FAILURE,\n DEFAULT_CIPHER,\n DEFAULT_COMPRESSION,\n DEFAULT_KEX,\n DEFAULT_MAC,\n DEFAULT_SERVER_HOST_KEY,\n DISCONNECT_REASON,\n DISCONNECT_REASON_BY_VALUE,\n SUPPORTED_CIPHER,\n SUPPORTED_COMPRESSION,\n SUPPORTED_KEX,\n SUPPORTED_MAC,\n SUPPORTED_SERVER_HOST_KEY,\n} = require('./protocol/constants.js');\nconst { init: cryptoInit } = require('./protocol/crypto.js');\nconst { KexInit } = require('./protocol/kex.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst Protocol = require('./protocol/Protocol.js');\nconst { SFTP } = require('./protocol/SFTP.js');\nconst { writeUInt32BE } = require('./protocol/utils.js');\n\nconst {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n} = require('./Channel.js');\n\nconst {\n ChannelManager,\n generateAlgorithmList,\n isWritable,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n} = require('./utils.js');\n\nconst MAX_PENDING_AUTHS = 10;\n\nclass AuthContext extends EventEmitter {\n constructor(protocol, username, service, method, cb) {\n super();\n\n this.username = this.user = username;\n this.service = service;\n this.method = method;\n this._initialResponse = false;\n this._finalResponse = false;\n this._multistep = false;\n this._cbfinal = (allowed, methodsLeft, isPartial) => {\n if (!this._finalResponse) {\n this._finalResponse = true;\n cb(this, allowed, methodsLeft, isPartial);\n }\n };\n this._protocol = protocol;\n }\n\n accept() {\n this._cleanup && this._cleanup();\n this._initialResponse = true;\n this._cbfinal(true);\n }\n reject(methodsLeft, isPartial) {\n this._cleanup && this._cleanup();\n this._initialResponse = true;\n this._cbfinal(false, methodsLeft, isPartial);\n }\n}\n\n\nclass KeyboardAuthContext extends AuthContext {\n constructor(protocol, username, service, method, submethods, cb) {\n super(protocol, username, service, method, cb);\n\n this._multistep = true;\n\n this._cb = undefined;\n this._onInfoResponse = (responses) => {\n const callback = this._cb;\n if (callback) {\n this._cb = undefined;\n callback(responses);\n }\n };\n this.submethods = submethods;\n this.on('abort', () => {\n this._cb && this._cb(new Error('Authentication request aborted'));\n });\n }\n\n prompt(prompts, title, instructions, cb) {\n if (!Array.isArray(prompts))\n prompts = [ prompts ];\n\n if (typeof title === 'function') {\n cb = title;\n title = instructions = undefined;\n } else if (typeof instructions === 'function') {\n cb = instructions;\n instructions = undefined;\n } else if (typeof cb !== 'function') {\n cb = undefined;\n }\n\n for (let i = 0; i < prompts.length; ++i) {\n if (typeof prompts[i] === 'string') {\n prompts[i] = {\n prompt: prompts[i],\n echo: true\n };\n }\n }\n\n this._cb = cb;\n this._initialResponse = true;\n\n this._protocol.authInfoReq(title, instructions, prompts);\n }\n}\n\nclass PKAuthContext extends AuthContext {\n constructor(protocol, username, service, method, pkInfo, cb) {\n super(protocol, username, service, method, cb);\n\n this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };\n this.signature = pkInfo.signature;\n this.blob = pkInfo.blob;\n }\n\n accept() {\n if (!this.signature) {\n this._initialResponse = true;\n this._protocol.authPKOK(this.key.algo, this.key.data);\n } else {\n AuthContext.prototype.accept.call(this);\n }\n }\n}\n\nclass HostbasedAuthContext extends AuthContext {\n constructor(protocol, username, service, method, pkInfo, cb) {\n super(protocol, username, service, method, cb);\n\n this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };\n this.signature = pkInfo.signature;\n this.blob = pkInfo.blob;\n this.localHostname = pkInfo.localHostname;\n this.localUsername = pkInfo.localUsername;\n }\n}\n\nclass PwdAuthContext extends AuthContext {\n constructor(protocol, username, service, method, password, cb) {\n super(protocol, username, service, method, cb);\n\n this.password = password;\n this._changeCb = undefined;\n }\n\n requestChange(prompt, cb) {\n if (this._changeCb)\n throw new Error('Change request already in progress');\n if (typeof prompt !== 'string')\n throw new Error('prompt argument must be a string');\n if (typeof cb !== 'function')\n throw new Error('Callback argument must be a function');\n this._changeCb = cb;\n this._protocol.authPasswdChg(prompt);\n }\n}\n\n\nclass Session extends EventEmitter {\n constructor(client, info, localChan) {\n super();\n\n this.type = 'session';\n this.subtype = undefined;\n this.server = true;\n this._ending = false;\n this._channel = undefined;\n this._chanInfo = {\n type: 'session',\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n }\n}\n\n\nclass Server extends EventEmitter {\n constructor(cfg, listener) {\n super();\n\n if (typeof cfg !== 'object' || cfg === null)\n throw new Error('Missing configuration object');\n\n const hostKeys = Object.create(null);\n const hostKeyAlgoOrder = [];\n\n const hostKeys_ = cfg.hostKeys;\n if (!Array.isArray(hostKeys_))\n throw new Error('hostKeys must be an array');\n\n const cfgAlgos = (\n typeof cfg.algorithms === 'object' && cfg.algorithms !== null\n ? cfg.algorithms\n : {}\n );\n\n const hostKeyAlgos = generateAlgorithmList(\n cfgAlgos.serverHostKey,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY\n );\n for (let i = 0; i < hostKeys_.length; ++i) {\n let privateKey;\n if (Buffer.isBuffer(hostKeys_[i]) || typeof hostKeys_[i] === 'string')\n privateKey = parseKey(hostKeys_[i]);\n else\n privateKey = parseKey(hostKeys_[i].key, hostKeys_[i].passphrase);\n\n if (privateKey instanceof Error)\n throw new Error(`Cannot parse privateKey: ${privateKey.message}`);\n\n if (Array.isArray(privateKey)) {\n // OpenSSH's newer format only stores 1 key for now\n privateKey = privateKey[0];\n }\n\n if (privateKey.getPrivatePEM() === null)\n throw new Error('privateKey value contains an invalid private key');\n\n // Discard key if we already found a key of the same type\n if (hostKeyAlgoOrder.includes(privateKey.type))\n continue;\n\n if (privateKey.type === 'ssh-rsa') {\n // SSH supports multiple signature hashing algorithms for RSA, so we add\n // the algorithms in the desired order\n let sha1Pos = hostKeyAlgos.indexOf('ssh-rsa');\n const sha256Pos = hostKeyAlgos.indexOf('rsa-sha2-256');\n const sha512Pos = hostKeyAlgos.indexOf('rsa-sha2-512');\n if (sha1Pos === -1) {\n // Fall back to giving SHA1 the lowest priority\n sha1Pos = Infinity;\n }\n [sha1Pos, sha256Pos, sha512Pos].sort(compareNumbers).forEach((pos) => {\n if (pos === -1)\n return;\n\n let type;\n switch (pos) {\n case sha1Pos: type = 'ssh-rsa'; break;\n case sha256Pos: type = 'rsa-sha2-256'; break;\n case sha512Pos: type = 'rsa-sha2-512'; break;\n default: return;\n }\n\n // Store same RSA key under each hash algorithm name for convenience\n hostKeys[type] = privateKey;\n\n hostKeyAlgoOrder.push(type);\n });\n } else {\n hostKeys[privateKey.type] = privateKey;\n hostKeyAlgoOrder.push(privateKey.type);\n }\n }\n\n const algorithms = {\n kex: generateAlgorithmList(cfgAlgos.kex, DEFAULT_KEX, SUPPORTED_KEX),\n serverHostKey: hostKeyAlgoOrder,\n cs: {\n cipher: generateAlgorithmList(\n cfgAlgos.cipher,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER\n ),\n mac: generateAlgorithmList(cfgAlgos.hmac, DEFAULT_MAC, SUPPORTED_MAC),\n compress: generateAlgorithmList(\n cfgAlgos.compress,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION\n ),\n lang: [],\n },\n sc: undefined,\n };\n algorithms.sc = algorithms.cs;\n\n if (typeof listener === 'function')\n this.on('connection', listener);\n\n const origDebug = (typeof cfg.debug === 'function' ? cfg.debug : undefined);\n const ident = (cfg.ident ? Buffer.from(cfg.ident) : undefined);\n const offer = new KexInit(algorithms);\n\n this._srv = new netServer((socket) => {\n if (this._connections >= this.maxConnections) {\n socket.destroy();\n return;\n }\n ++this._connections;\n socket.once('close', () => {\n --this._connections;\n });\n\n let debug;\n if (origDebug) {\n // Prepend debug output with a unique identifier in case there are\n // multiple clients connected at the same time\n const debugPrefix = `[${process.hrtime().join('.')}] `;\n debug = (msg) => {\n origDebug(`${debugPrefix}${msg}`);\n };\n }\n\n // eslint-disable-next-line no-use-before-define\n new Client(socket, hostKeys, ident, offer, debug, this, cfg);\n }).on('error', (err) => {\n this.emit('error', err);\n }).on('listening', () => {\n this.emit('listening');\n }).on('close', () => {\n this.emit('close');\n });\n this._connections = 0;\n this.maxConnections = Infinity;\n }\n\n injectSocket(socket) {\n this._srv.emit('connection', socket);\n }\n\n listen(...args) {\n this._srv.listen(...args);\n return this;\n }\n\n address() {\n return this._srv.address();\n }\n\n getConnections(cb) {\n this._srv.getConnections(cb);\n return this;\n }\n\n close(cb) {\n this._srv.close(cb);\n return this;\n }\n\n ref() {\n this._srv.ref();\n return this;\n }\n\n unref() {\n this._srv.unref();\n return this;\n }\n}\nServer.KEEPALIVE_CLIENT_INTERVAL = 15000;\nServer.KEEPALIVE_CLIENT_COUNT_MAX = 3;\n\n\nclass Client extends EventEmitter {\n constructor(socket, hostKeys, ident, offer, debug, server, srvCfg) {\n super();\n\n let exchanges = 0;\n let acceptedAuthSvc = false;\n let pendingAuths = [];\n let authCtx;\n let kaTimer;\n let onPacket;\n const unsentGlobalRequestsReplies = [];\n this._sock = socket;\n this._chanMgr = new ChannelManager(this);\n this._debug = debug;\n this.noMoreSessions = false;\n this.authenticated = false;\n\n // Silence pre-header errors\n function onClientPreHeaderError(err) {}\n this.on('error', onClientPreHeaderError);\n\n const DEBUG_HANDLER = (!debug ? undefined : (p, display, msg) => {\n debug(`Debug output from client: ${JSON.stringify(msg)}`);\n });\n\n const kaIntvl = (\n typeof srvCfg.keepaliveInterval === 'number'\n && isFinite(srvCfg.keepaliveInterval)\n && srvCfg.keepaliveInterval > 0\n ? srvCfg.keepaliveInterval\n : (\n typeof Server.KEEPALIVE_CLIENT_INTERVAL === 'number'\n && isFinite(Server.KEEPALIVE_CLIENT_INTERVAL)\n && Server.KEEPALIVE_CLIENT_INTERVAL > 0\n ? Server.KEEPALIVE_CLIENT_INTERVAL\n : -1\n )\n );\n const kaCountMax = (\n typeof srvCfg.keepaliveCountMax === 'number'\n && isFinite(srvCfg.keepaliveCountMax)\n && srvCfg.keepaliveCountMax >= 0\n ? srvCfg.keepaliveCountMax\n : (\n typeof Server.KEEPALIVE_CLIENT_COUNT_MAX === 'number'\n && isFinite(Server.KEEPALIVE_CLIENT_COUNT_MAX)\n && Server.KEEPALIVE_CLIENT_COUNT_MAX >= 0\n ? Server.KEEPALIVE_CLIENT_COUNT_MAX\n : -1\n )\n );\n let kaCurCount = 0;\n if (kaIntvl !== -1 && kaCountMax !== -1) {\n this.once('ready', () => {\n const onClose = () => {\n clearInterval(kaTimer);\n };\n this.on('close', onClose).on('end', onClose);\n kaTimer = setInterval(() => {\n if (++kaCurCount > kaCountMax) {\n clearInterval(kaTimer);\n const err = new Error('Keepalive timeout');\n err.level = 'client-timeout';\n this.emit('error', err);\n this.end();\n } else {\n // XXX: if the server ever starts sending real global requests to\n // the client, we will need to add a dummy callback here to\n // keep the correct reply order\n proto.ping();\n }\n }, kaIntvl);\n });\n // TODO: re-verify keepalive behavior with OpenSSH\n onPacket = () => {\n kaTimer && kaTimer.refresh();\n kaCurCount = 0;\n };\n }\n\n const proto = this._protocol = new Protocol({\n server: true,\n hostKeys,\n ident,\n offer,\n onPacket,\n greeting: srvCfg.greeting,\n banner: srvCfg.banner,\n onWrite: (data) => {\n if (isWritable(socket))\n socket.write(data);\n },\n onError: (err) => {\n if (!proto._destruct)\n socket.removeAllListeners('data');\n this.emit('error', err);\n try {\n socket.end();\n } catch {}\n },\n onHeader: (header) => {\n this.removeListener('error', onClientPreHeaderError);\n\n const info = {\n ip: socket.remoteAddress,\n family: socket.remoteFamily,\n port: socket.remotePort,\n header,\n };\n if (!server.emit('connection', this, info)) {\n // auto reject\n proto.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n socket.end();\n return;\n }\n\n if (header.greeting)\n this.emit('greeting', header.greeting);\n },\n onHandshakeComplete: (negotiated) => {\n if (++exchanges > 1)\n this.emit('rekey');\n this.emit('handshake', negotiated);\n },\n debug,\n messageHandlers: {\n DEBUG: DEBUG_HANDLER,\n DISCONNECT: (p, reason, desc) => {\n if (reason !== DISCONNECT_REASON.BY_APPLICATION) {\n if (!desc) {\n desc = DISCONNECT_REASON_BY_VALUE[reason];\n if (desc === undefined)\n desc = `Unexpected disconnection reason: ${reason}`;\n }\n const err = new Error(desc);\n err.code = reason;\n this.emit('error', err);\n }\n socket.end();\n },\n CHANNEL_OPEN: (p, info) => {\n // Handle incoming requests from client\n\n // Do early reject in some cases to prevent wasteful channel\n // allocation\n if ((info.type === 'session' && this.noMoreSessions)\n || !this.authenticated) {\n const reasonCode = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n return proto.channelOpenFail(info.sender, reasonCode);\n }\n\n let localChan = -1;\n let reason;\n let replied = false;\n\n let accept;\n const reject = () => {\n if (replied)\n return;\n replied = true;\n\n if (reason === undefined) {\n if (localChan === -1)\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n else\n reason = CHANNEL_OPEN_FAILURE.CONNECT_FAILED;\n }\n\n if (localChan !== -1)\n this._chanMgr.remove(localChan);\n proto.channelOpenFail(info.sender, reason, '');\n };\n const reserveChannel = () => {\n localChan = this._chanMgr.add();\n\n if (localChan === -1) {\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n if (debug) {\n debug('Automatic rejection of incoming channel open: '\n + 'no channels available');\n }\n }\n\n return (localChan !== -1);\n };\n\n const data = info.data;\n switch (info.type) {\n case 'session':\n if (listenerCount(this, 'session') && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const instance = new Session(this, info, localChan);\n this._chanMgr.update(localChan, instance);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return instance;\n };\n\n this.emit('session', accept, reject);\n return;\n }\n break;\n case 'direct-tcpip':\n if (listenerCount(this, 'tcpip') && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const chanInfo = {\n type: undefined,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const stream = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(localChan, stream);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return stream;\n };\n\n this.emit('tcpip', accept, reject, data);\n return;\n }\n break;\n case 'direct-streamlocal@openssh.com':\n if (listenerCount(this, 'openssh.streamlocal')\n && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const chanInfo = {\n type: undefined,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const stream = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(localChan, stream);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return stream;\n };\n\n this.emit('openssh.streamlocal', accept, reject, data);\n return;\n }\n break;\n default:\n // Automatically reject any unsupported channel open requests\n reason = CHANNEL_OPEN_FAILURE.UNKNOWN_CHANNEL_TYPE;\n if (debug) {\n debug('Automatic rejection of unsupported incoming channel open'\n + ` type: ${info.type}`);\n }\n }\n\n if (reason === undefined) {\n reason = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n if (debug) {\n debug('Automatic rejection of unexpected incoming channel open'\n + ` for: ${info.type}`);\n }\n }\n\n reject();\n },\n CHANNEL_OPEN_CONFIRMATION: (p, info) => {\n const channel = this._chanMgr.get(info.recipient);\n if (typeof channel !== 'function')\n return;\n\n const chanInfo = {\n type: channel.type,\n incoming: {\n id: info.recipient,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const instance = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(info.recipient, instance);\n channel(undefined, instance);\n },\n CHANNEL_OPEN_FAILURE: (p, recipient, reason, description) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'function')\n return;\n\n const info = { reason, description };\n onChannelOpenFailure(this, recipient, info, channel);\n },\n CHANNEL_DATA: (p, recipient, data) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (channel.push(data) === false) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_EXTENDED_DATA: (p, recipient, data, type) => {\n // NOOP -- should not be sent by client\n },\n CHANNEL_WINDOW_ADJUST: (p, recipient, amount) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n // The other side is allowing us to send `amount` more bytes of data\n channel.outgoing.window += amount;\n\n if (channel._waitWindow) {\n channel._waitWindow = false;\n\n if (channel._chunk) {\n channel._write(channel._chunk, null, channel._chunkcb);\n } else if (channel._chunkcb) {\n channel._chunkcb();\n } else if (channel._chunkErr) {\n channel.stderr._write(channel._chunkErr,\n null,\n channel._chunkcbErr);\n } else if (channel._chunkcbErr) {\n channel._chunkcbErr();\n }\n }\n },\n CHANNEL_SUCCESS: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(false);\n },\n CHANNEL_FAILURE: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(true);\n },\n CHANNEL_REQUEST: (p, recipient, type, wantReply, data) => {\n const session = this._chanMgr.get(recipient);\n if (typeof session !== 'object' || session === null)\n return;\n\n let replied = false;\n let accept;\n let reject;\n\n if (session.constructor !== Session) {\n // normal Channel instance\n if (wantReply)\n proto.channelFailure(session.outgoing.id);\n return;\n }\n\n if (wantReply) {\n // \"real session\" requests will have custom accept behaviors\n if (type !== 'shell'\n && type !== 'exec'\n && type !== 'subsystem') {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n proto.channelSuccess(session._chanInfo.outgoing.id);\n };\n }\n\n reject = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n proto.channelFailure(session._chanInfo.outgoing.id);\n };\n }\n\n if (session._ending) {\n reject && reject();\n return;\n }\n\n switch (type) {\n // \"pre-real session start\" requests\n case 'env':\n if (listenerCount(session, 'env')) {\n session.emit('env', accept, reject, {\n key: data.name,\n val: data.value\n });\n return;\n }\n break;\n case 'pty-req':\n if (listenerCount(session, 'pty')) {\n session.emit('pty', accept, reject, data);\n return;\n }\n break;\n case 'window-change':\n if (listenerCount(session, 'window-change'))\n session.emit('window-change', accept, reject, data);\n else\n reject && reject();\n break;\n case 'x11-req':\n if (listenerCount(session, 'x11')) {\n session.emit('x11', accept, reject, data);\n return;\n }\n break;\n // \"post-real session start\" requests\n case 'signal':\n if (listenerCount(session, 'signal')) {\n session.emit('signal', accept, reject, {\n name: data\n });\n return;\n }\n break;\n // XXX: is `auth-agent-req@openssh.com` really \"post-real session\n // start\"?\n case 'auth-agent-req@openssh.com':\n if (listenerCount(session, 'auth-agent')) {\n session.emit('auth-agent', accept, reject);\n return;\n }\n break;\n // \"real session start\" requests\n case 'shell':\n if (listenerCount(session, 'shell')) {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n const channel = new Channel(\n this, session._chanInfo, { server: true }\n );\n\n channel.subtype = session.subtype = type;\n session._channel = channel;\n\n return channel;\n };\n\n session.emit('shell', accept, reject);\n return;\n }\n break;\n case 'exec':\n if (listenerCount(session, 'exec')) {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n const channel = new Channel(\n this, session._chanInfo, { server: true }\n );\n\n channel.subtype = session.subtype = type;\n session._channel = channel;\n\n return channel;\n };\n\n session.emit('exec', accept, reject, {\n command: data\n });\n return;\n }\n break;\n case 'subsystem': {\n let useSFTP = (data === 'sftp');\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n let instance;\n if (useSFTP) {\n instance = new SFTP(this, session._chanInfo, {\n server: true,\n debug,\n });\n } else {\n instance = new Channel(\n this, session._chanInfo, { server: true }\n );\n instance.subtype =\n session.subtype = `${type}:${data}`;\n }\n session._channel = instance;\n\n return instance;\n };\n\n if (data === 'sftp') {\n if (listenerCount(session, 'sftp')) {\n session.emit('sftp', accept, reject);\n return;\n }\n useSFTP = false;\n }\n if (listenerCount(session, 'subsystem')) {\n session.emit('subsystem', accept, reject, {\n name: data\n });\n return;\n }\n break;\n }\n }\n debug && debug(\n `Automatic rejection of incoming channel request: ${type}`\n );\n reject && reject();\n },\n CHANNEL_EOF: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n if (!channel._ending) {\n channel._ending = true;\n channel.emit('eof');\n channel.emit('end');\n }\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel.incoming.state !== 'open')\n return;\n channel.incoming.state = 'eof';\n\n if (channel.readable)\n channel.push(null);\n },\n CHANNEL_CLOSE: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel._ending = true;\n channel.emit('close');\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n onCHANNEL_CLOSE(this, recipient, channel);\n },\n // Begin service/auth-related ==========================================\n SERVICE_REQUEST: (p, service) => {\n if (exchanges === 0\n || acceptedAuthSvc\n || this.authenticated\n || service !== 'ssh-userauth') {\n proto.disconnect(DISCONNECT_REASON.SERVICE_NOT_AVAILABLE);\n socket.end();\n return;\n }\n\n acceptedAuthSvc = true;\n proto.serviceAccept(service);\n },\n USERAUTH_REQUEST: (p, username, service, method, methodData) => {\n if (exchanges === 0\n || this.authenticated\n || (authCtx\n && (authCtx.username !== username\n || authCtx.service !== service))\n // TODO: support hostbased auth\n || (method !== 'password'\n && method !== 'publickey'\n && method !== 'hostbased'\n && method !== 'keyboard-interactive'\n && method !== 'none')\n || pendingAuths.length === MAX_PENDING_AUTHS) {\n proto.disconnect(DISCONNECT_REASON.PROTOCOL_ERROR);\n socket.end();\n return;\n } else if (service !== 'ssh-connection') {\n proto.disconnect(DISCONNECT_REASON.SERVICE_NOT_AVAILABLE);\n socket.end();\n return;\n }\n\n let ctx;\n switch (method) {\n case 'keyboard-interactive':\n ctx = new KeyboardAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'publickey':\n ctx = new PKAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'hostbased':\n ctx = new HostbasedAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'password':\n if (authCtx\n && authCtx instanceof PwdAuthContext\n && authCtx._changeCb) {\n const cb = authCtx._changeCb;\n authCtx._changeCb = undefined;\n cb(methodData.newPassword);\n return;\n }\n ctx = new PwdAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'none':\n ctx = new AuthContext(proto, username, service, method,\n onAuthDecide);\n break;\n }\n\n if (authCtx) {\n if (!authCtx._initialResponse) {\n return pendingAuths.push(ctx);\n } else if (authCtx._multistep && !authCtx._finalResponse) {\n // RFC 4252 says to silently abort the current auth request if a\n // new auth request comes in before the final response from an\n // auth method that requires additional request/response exchanges\n // -- this means keyboard-interactive for now ...\n authCtx._cleanup && authCtx._cleanup();\n authCtx.emit('abort');\n }\n }\n\n authCtx = ctx;\n\n if (listenerCount(this, 'authentication'))\n this.emit('authentication', authCtx);\n else\n authCtx.reject();\n },\n USERAUTH_INFO_RESPONSE: (p, responses) => {\n if (authCtx && authCtx instanceof KeyboardAuthContext)\n authCtx._onInfoResponse(responses);\n },\n // End service/auth-related ============================================\n GLOBAL_REQUEST: (p, name, wantReply, data) => {\n const reply = {\n type: null,\n buf: null\n };\n\n function setReply(type, buf) {\n reply.type = type;\n reply.buf = buf;\n sendReplies();\n }\n\n if (wantReply)\n unsentGlobalRequestsReplies.push(reply);\n\n if ((name === 'tcpip-forward'\n || name === 'cancel-tcpip-forward'\n || name === 'no-more-sessions@openssh.com'\n || name === 'streamlocal-forward@openssh.com'\n || name === 'cancel-streamlocal-forward@openssh.com')\n && listenerCount(this, 'request')\n && this.authenticated) {\n let accept;\n let reject;\n\n if (wantReply) {\n let replied = false;\n accept = (chosenPort) => {\n if (replied)\n return;\n replied = true;\n let bufPort;\n if (name === 'tcpip-forward'\n && data.bindPort === 0\n && typeof chosenPort === 'number') {\n bufPort = Buffer.allocUnsafe(4);\n writeUInt32BE(bufPort, chosenPort, 0);\n }\n setReply('SUCCESS', bufPort);\n };\n reject = () => {\n if (replied)\n return;\n replied = true;\n setReply('FAILURE');\n };\n }\n\n if (name === 'no-more-sessions@openssh.com') {\n this.noMoreSessions = true;\n accept && accept();\n return;\n }\n\n this.emit('request', accept, reject, name, data);\n } else if (wantReply) {\n setReply('FAILURE');\n }\n },\n },\n });\n\n socket.pause();\n cryptoInit.then(() => {\n proto.start();\n socket.on('data', (data) => {\n try {\n proto.parse(data, 0, data.length);\n } catch (ex) {\n this.emit('error', ex);\n try {\n if (isWritable(socket))\n socket.end();\n } catch {}\n }\n });\n socket.resume();\n }).catch((err) => {\n this.emit('error', err);\n try {\n if (isWritable(socket))\n socket.end();\n } catch {}\n });\n socket.on('error', (err) => {\n err.level = 'socket';\n this.emit('error', err);\n }).once('end', () => {\n debug && debug('Socket ended');\n proto.cleanup();\n this.emit('end');\n }).once('close', () => {\n debug && debug('Socket closed');\n proto.cleanup();\n this.emit('close');\n\n const err = new Error('No response from server');\n\n // Simulate error for pending channels and close any open channels\n this._chanMgr.cleanup(err);\n });\n\n const onAuthDecide = (ctx, allowed, methodsLeft, isPartial) => {\n if (authCtx === ctx && !this.authenticated) {\n if (allowed) {\n authCtx = undefined;\n this.authenticated = true;\n proto.authSuccess();\n pendingAuths = [];\n this.emit('ready');\n } else {\n proto.authFailure(methodsLeft, isPartial);\n if (pendingAuths.length) {\n authCtx = pendingAuths.pop();\n if (listenerCount(this, 'authentication'))\n this.emit('authentication', authCtx);\n else\n authCtx.reject();\n }\n }\n }\n };\n\n function sendReplies() {\n while (unsentGlobalRequestsReplies.length > 0\n && unsentGlobalRequestsReplies[0].type) {\n const reply = unsentGlobalRequestsReplies.shift();\n if (reply.type === 'SUCCESS')\n proto.requestSuccess(reply.buf);\n if (reply.type === 'FAILURE')\n proto.requestFailure();\n }\n }\n }\n\n end() {\n if (this._sock && isWritable(this._sock)) {\n this._protocol.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n this._sock.end();\n }\n return this;\n }\n\n x11(originAddr, originPort, cb) {\n const opts = { originAddr, originPort };\n openChannel(this, 'x11', opts, cb);\n return this;\n }\n\n forwardOut(boundAddr, boundPort, remoteAddr, remotePort, cb) {\n const opts = { boundAddr, boundPort, remoteAddr, remotePort };\n openChannel(this, 'forwarded-tcpip', opts, cb);\n return this;\n }\n\n openssh_forwardOutStreamLocal(socketPath, cb) {\n const opts = { socketPath };\n openChannel(this, 'forwarded-streamlocal@openssh.com', opts, cb);\n return this;\n }\n\n rekey(cb) {\n let error;\n\n try {\n this._protocol.rekey();\n } catch (ex) {\n error = ex;\n }\n\n // TODO: re-throw error if no callback?\n\n if (typeof cb === 'function') {\n if (error)\n process.nextTick(cb, error);\n else\n this.once('rekey', cb);\n }\n }\n}\n\n\nfunction openChannel(self, type, opts, cb) {\n // Ask the client to open a channel for some purpose (e.g. a forwarded TCP\n // connection)\n const initWindow = MAX_WINDOW;\n const maxPacket = PACKET_SIZE;\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const wrapper = (err, stream) => {\n cb(err, stream);\n };\n wrapper.type = type;\n\n const localChan = self._chanMgr.add(wrapper);\n\n if (localChan === -1) {\n cb(new Error('No free channels available'));\n return;\n }\n\n switch (type) {\n case 'forwarded-tcpip':\n self._protocol.forwardedTcpip(localChan, initWindow, maxPacket, opts);\n break;\n case 'x11':\n self._protocol.x11(localChan, initWindow, maxPacket, opts);\n break;\n case 'forwarded-streamlocal@openssh.com':\n self._protocol.openssh_forwardedStreamLocal(\n localChan, initWindow, maxPacket, opts\n );\n break;\n default:\n throw new Error(`Unsupported channel type: ${type}`);\n }\n}\n\nfunction compareNumbers(a, b) {\n return a - b;\n}\n\nmodule.exports = Server;\nmodule.exports.IncomingClient = Client;\n","'use strict';\n\nconst { SFTP } = require('./protocol/SFTP.js');\n\nconst MAX_CHANNEL = 2 ** 32 - 1;\n\nfunction onChannelOpenFailure(self, recipient, info, cb) {\n self._chanMgr.remove(recipient);\n if (typeof cb !== 'function')\n return;\n\n let err;\n if (info instanceof Error) {\n err = info;\n } else if (typeof info === 'object' && info !== null) {\n err = new Error(`(SSH) Channel open failure: ${info.description}`);\n err.reason = info.reason;\n } else {\n err = new Error(\n '(SSH) Channel open failure: server closed channel unexpectedly'\n );\n err.reason = '';\n }\n\n cb(err);\n}\n\nfunction onCHANNEL_CLOSE(self, recipient, channel, err, dead) {\n if (typeof channel === 'function') {\n // We got CHANNEL_CLOSE instead of CHANNEL_OPEN_FAILURE when\n // requesting to open a channel\n onChannelOpenFailure(self, recipient, err, channel);\n return;\n }\n\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.incoming && channel.incoming.state === 'closed')\n return;\n\n self._chanMgr.remove(recipient);\n\n if (channel.server && channel.constructor.name === 'Session')\n return;\n\n channel.incoming.state = 'closed';\n\n if (channel.readable)\n channel.push(null);\n if (channel.server) {\n if (channel.stderr.writable)\n channel.stderr.end();\n } else if (channel.stderr.readable) {\n channel.stderr.push(null);\n }\n\n if (channel.constructor !== SFTP\n && (channel.outgoing.state === 'open'\n || channel.outgoing.state === 'eof')\n && !dead) {\n channel.close();\n }\n if (channel.outgoing.state === 'closing')\n channel.outgoing.state = 'closed';\n\n const readState = channel._readableState;\n const writeState = channel._writableState;\n if (writeState && !writeState.ending && !writeState.finished && !dead)\n channel.end();\n\n // Take care of any outstanding channel requests\n const chanCallbacks = channel._callbacks;\n channel._callbacks = [];\n for (let i = 0; i < chanCallbacks.length; ++i)\n chanCallbacks[i](true);\n\n if (channel.server) {\n if (!channel.readable\n || channel.destroyed\n || (readState && readState.endEmitted)) {\n channel.emit('close');\n } else {\n channel.once('end', () => channel.emit('close'));\n }\n } else {\n let doClose;\n switch (channel.type) {\n case 'direct-streamlocal@openssh.com':\n case 'direct-tcpip':\n doClose = () => channel.emit('close');\n break;\n default: {\n // Align more with node child processes, where the close event gets\n // the same arguments as the exit event\n const exit = channel._exit;\n doClose = () => {\n if (exit.code === null)\n channel.emit('close', exit.code, exit.signal, exit.dump, exit.desc);\n else\n channel.emit('close', exit.code);\n };\n }\n }\n if (!channel.readable\n || channel.destroyed\n || (readState && readState.endEmitted)) {\n doClose();\n } else {\n channel.once('end', doClose);\n }\n\n const errReadState = channel.stderr._readableState;\n if (!channel.stderr.readable\n || channel.stderr.destroyed\n || (errReadState && errReadState.endEmitted)) {\n channel.stderr.emit('close');\n } else {\n channel.stderr.once('end', () => channel.stderr.emit('close'));\n }\n }\n}\n\nclass ChannelManager {\n constructor(client) {\n this._client = client;\n this._channels = {};\n this._cur = -1;\n this._count = 0;\n }\n add(val) {\n // Attempt to reserve an id\n\n let id;\n // Optimized paths\n if (this._cur < MAX_CHANNEL) {\n id = ++this._cur;\n } else if (this._count === 0) {\n // Revert and reset back to fast path once we no longer have any channels\n // open\n this._cur = 0;\n id = 0;\n } else {\n // Slower lookup path\n\n // This path is triggered we have opened at least MAX_CHANNEL channels\n // while having at least one channel open at any given time, so we have\n // to search for a free id.\n const channels = this._channels;\n for (let i = 0; i < MAX_CHANNEL; ++i) {\n if (channels[i] === undefined) {\n id = i;\n break;\n }\n }\n }\n\n if (id === undefined)\n return -1;\n\n this._channels[id] = (val || true);\n ++this._count;\n\n return id;\n }\n update(id, val) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n if (val && this._channels[id])\n this._channels[id] = val;\n }\n get(id) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n return this._channels[id];\n }\n remove(id) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n if (this._channels[id]) {\n delete this._channels[id];\n if (this._count)\n --this._count;\n }\n }\n cleanup(err) {\n const channels = this._channels;\n this._channels = {};\n this._cur = -1;\n this._count = 0;\n\n const chanIDs = Object.keys(channels);\n const client = this._client;\n for (let i = 0; i < chanIDs.length; ++i) {\n const id = +chanIDs[i];\n const channel = channels[id];\n onCHANNEL_CLOSE(client, id, channel._channel || channel, err, true);\n }\n }\n}\n\nconst isRegExp = (() => {\n const toString = Object.prototype.toString;\n return (val) => toString.call(val) === '[object RegExp]';\n})();\n\nfunction generateAlgorithmList(algoList, defaultList, supportedList) {\n if (Array.isArray(algoList) && algoList.length > 0) {\n // Exact list\n for (let i = 0; i < algoList.length; ++i) {\n if (supportedList.indexOf(algoList[i]) === -1)\n throw new Error(`Unsupported algorithm: ${algoList[i]}`);\n }\n return algoList;\n }\n\n if (typeof algoList === 'object' && algoList !== null) {\n // Operations based on the default list\n const keys = Object.keys(algoList);\n let list = defaultList;\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n let val = algoList[key];\n switch (key) {\n case 'append':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = 0; j < val.length; ++j) {\n const append = val[j];\n if (typeof append === 'string') {\n if (!append || list.indexOf(append) !== -1)\n continue;\n if (supportedList.indexOf(append) === -1)\n throw new Error(`Unsupported algorithm: ${append}`);\n if (list === defaultList)\n list = list.slice();\n list.push(append);\n } else if (isRegExp(append)) {\n for (let k = 0; k < supportedList.length; ++k) {\n const algo = supportedList[k];\n if (append.test(algo)) {\n if (list.indexOf(algo) !== -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.push(algo);\n }\n }\n }\n }\n }\n break;\n case 'prepend':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = val.length; j >= 0; --j) {\n const prepend = val[j];\n if (typeof prepend === 'string') {\n if (!prepend || list.indexOf(prepend) !== -1)\n continue;\n if (supportedList.indexOf(prepend) === -1)\n throw new Error(`Unsupported algorithm: ${prepend}`);\n if (list === defaultList)\n list = list.slice();\n list.unshift(prepend);\n } else if (isRegExp(prepend)) {\n for (let k = supportedList.length; k >= 0; --k) {\n const algo = supportedList[k];\n if (prepend.test(algo)) {\n if (list.indexOf(algo) !== -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.unshift(algo);\n }\n }\n }\n }\n }\n break;\n case 'remove':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = 0; j < val.length; ++j) {\n const search = val[j];\n if (typeof search === 'string') {\n if (!search)\n continue;\n const idx = list.indexOf(search);\n if (idx === -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.splice(idx, 1);\n } else if (isRegExp(search)) {\n for (let k = 0; k < list.length; ++k) {\n if (search.test(list[k])) {\n if (list === defaultList)\n list = list.slice();\n list.splice(k, 1);\n --k;\n }\n }\n }\n }\n }\n break;\n }\n }\n\n return list;\n }\n\n return defaultList;\n}\n\nmodule.exports = {\n ChannelManager,\n generateAlgorithmList,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n isWritable: (stream) => {\n // XXX: hack to workaround regression in node\n // See: https://github.com/nodejs/node/issues/36029\n return (stream\n && stream.writable\n && stream._readableState\n && stream._readableState.ended === false);\n },\n};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\n/**/\n\nvar isEncoding = Buffer.isEncoding || function (encoding) {\n encoding = '' + encoding;\n switch (encoding && encoding.toLowerCase()) {\n case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':\n return true;\n default:\n return false;\n }\n};\n\nfunction _normalizeEncoding(enc) {\n if (!enc) return 'utf8';\n var retried;\n while (true) {\n switch (enc) {\n case 'utf8':\n case 'utf-8':\n return 'utf8';\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return 'utf16le';\n case 'latin1':\n case 'binary':\n return 'latin1';\n case 'base64':\n case 'ascii':\n case 'hex':\n return enc;\n default:\n if (retried) return; // undefined\n enc = ('' + enc).toLowerCase();\n retried = true;\n }\n }\n};\n\n// Do not cache `Buffer.isEncoding` when checking encoding names as some\n// modules monkey-patch it to support additional encodings\nfunction normalizeEncoding(enc) {\n var nenc = _normalizeEncoding(enc);\n if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);\n return nenc || enc;\n}\n\n// StringDecoder provides an interface for efficiently splitting a series of\n// buffers into a series of JS strings without breaking apart multi-byte\n// characters.\nexports.StringDecoder = StringDecoder;\nfunction StringDecoder(encoding) {\n this.encoding = normalizeEncoding(encoding);\n var nb;\n switch (this.encoding) {\n case 'utf16le':\n this.text = utf16Text;\n this.end = utf16End;\n nb = 4;\n break;\n case 'utf8':\n this.fillLast = utf8FillLast;\n nb = 4;\n break;\n case 'base64':\n this.text = base64Text;\n this.end = base64End;\n nb = 3;\n break;\n default:\n this.write = simpleWrite;\n this.end = simpleEnd;\n return;\n }\n this.lastNeed = 0;\n this.lastTotal = 0;\n this.lastChar = Buffer.allocUnsafe(nb);\n}\n\nStringDecoder.prototype.write = function (buf) {\n if (buf.length === 0) return '';\n var r;\n var i;\n if (this.lastNeed) {\n r = this.fillLast(buf);\n if (r === undefined) return '';\n i = this.lastNeed;\n this.lastNeed = 0;\n } else {\n i = 0;\n }\n if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);\n return r || '';\n};\n\nStringDecoder.prototype.end = utf8End;\n\n// Returns only complete characters in a Buffer\nStringDecoder.prototype.text = utf8Text;\n\n// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer\nStringDecoder.prototype.fillLast = function (buf) {\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);\n this.lastNeed -= buf.length;\n};\n\n// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a\n// continuation byte. If an invalid byte is detected, -2 is returned.\nfunction utf8CheckByte(byte) {\n if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;\n return byte >> 6 === 0x02 ? -1 : -2;\n}\n\n// Checks at most 3 bytes at the end of a Buffer in order to detect an\n// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)\n// needed to complete the UTF-8 character (if applicable) are returned.\nfunction utf8CheckIncomplete(self, buf, i) {\n var j = buf.length - 1;\n if (j < i) return 0;\n var nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 1;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 2;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) {\n if (nb === 2) nb = 0;else self.lastNeed = nb - 3;\n }\n return nb;\n }\n return 0;\n}\n\n// Validates as many continuation bytes for a multi-byte UTF-8 character as\n// needed or are available. If we see a non-continuation byte where we expect\n// one, we \"replace\" the validated continuation bytes we've seen so far with\n// a single UTF-8 replacement character ('\\ufffd'), to match v8's UTF-8 decoding\n// behavior. The continuation byte check is included three times in the case\n// where all of the continuation bytes for a character exist in the same buffer.\n// It is also done this way as a slight performance increase instead of using a\n// loop.\nfunction utf8CheckExtraBytes(self, buf, p) {\n if ((buf[0] & 0xC0) !== 0x80) {\n self.lastNeed = 0;\n return '\\ufffd';\n }\n if (self.lastNeed > 1 && buf.length > 1) {\n if ((buf[1] & 0xC0) !== 0x80) {\n self.lastNeed = 1;\n return '\\ufffd';\n }\n if (self.lastNeed > 2 && buf.length > 2) {\n if ((buf[2] & 0xC0) !== 0x80) {\n self.lastNeed = 2;\n return '\\ufffd';\n }\n }\n }\n}\n\n// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.\nfunction utf8FillLast(buf) {\n var p = this.lastTotal - this.lastNeed;\n var r = utf8CheckExtraBytes(this, buf, p);\n if (r !== undefined) return r;\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, p, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, p, 0, buf.length);\n this.lastNeed -= buf.length;\n}\n\n// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a\n// partial character, the character's bytes are buffered until the required\n// number of bytes are available.\nfunction utf8Text(buf, i) {\n var total = utf8CheckIncomplete(this, buf, i);\n if (!this.lastNeed) return buf.toString('utf8', i);\n this.lastTotal = total;\n var end = buf.length - (total - this.lastNeed);\n buf.copy(this.lastChar, 0, end);\n return buf.toString('utf8', i, end);\n}\n\n// For UTF-8, a replacement character is added when ending on a partial\n// character.\nfunction utf8End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + '\\ufffd';\n return r;\n}\n\n// UTF-16LE typically needs two bytes per character, but even if we have an even\n// number of bytes available, we need to check if we end on a leading/high\n// surrogate. In that case, we need to wait for the next two bytes in order to\n// decode the last character properly.\nfunction utf16Text(buf, i) {\n if ((buf.length - i) % 2 === 0) {\n var r = buf.toString('utf16le', i);\n if (r) {\n var c = r.charCodeAt(r.length - 1);\n if (c >= 0xD800 && c <= 0xDBFF) {\n this.lastNeed = 2;\n this.lastTotal = 4;\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n return r.slice(0, -1);\n }\n }\n return r;\n }\n this.lastNeed = 1;\n this.lastTotal = 2;\n this.lastChar[0] = buf[buf.length - 1];\n return buf.toString('utf16le', i, buf.length - 1);\n}\n\n// For UTF-16LE we do not explicitly append special replacement characters if we\n// end on a partial character, we simply let v8 handle that.\nfunction utf16End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) {\n var end = this.lastTotal - this.lastNeed;\n return r + this.lastChar.toString('utf16le', 0, end);\n }\n return r;\n}\n\nfunction base64Text(buf, i) {\n var n = (buf.length - i) % 3;\n if (n === 0) return buf.toString('base64', i);\n this.lastNeed = 3 - n;\n this.lastTotal = 3;\n if (n === 1) {\n this.lastChar[0] = buf[buf.length - 1];\n } else {\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n }\n return buf.toString('base64', i, buf.length - n);\n}\n\nfunction base64End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);\n return r;\n}\n\n// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)\nfunction simpleWrite(buf) {\n return buf.toString(this.encoding);\n}\n\nfunction simpleEnd(buf) {\n return buf && buf.length ? this.write(buf) : '';\n}","/*! safe-buffer. MIT License. Feross Aboukhadijeh */\n/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.prototype = Object.create(Buffer.prototype)\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\nconst os = require('os');\nconst tty = require('tty');\nconst hasFlag = require('has-flag');\n\nconst {env} = process;\n\nlet forceColor;\nif (hasFlag('no-color') ||\n\thasFlag('no-colors') ||\n\thasFlag('color=false') ||\n\thasFlag('color=never')) {\n\tforceColor = 0;\n} else if (hasFlag('color') ||\n\thasFlag('colors') ||\n\thasFlag('color=true') ||\n\thasFlag('color=always')) {\n\tforceColor = 1;\n}\n\nif ('FORCE_COLOR' in env) {\n\tif (env.FORCE_COLOR === 'true') {\n\t\tforceColor = 1;\n\t} else if (env.FORCE_COLOR === 'false') {\n\t\tforceColor = 0;\n\t} else {\n\t\tforceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);\n\t}\n}\n\nfunction translateLevel(level) {\n\tif (level === 0) {\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tlevel,\n\t\thasBasic: true,\n\t\thas256: level >= 2,\n\t\thas16m: level >= 3\n\t};\n}\n\nfunction supportsColor(haveStream, streamIsTTY) {\n\tif (forceColor === 0) {\n\t\treturn 0;\n\t}\n\n\tif (hasFlag('color=16m') ||\n\t\thasFlag('color=full') ||\n\t\thasFlag('color=truecolor')) {\n\t\treturn 3;\n\t}\n\n\tif (hasFlag('color=256')) {\n\t\treturn 2;\n\t}\n\n\tif (haveStream && !streamIsTTY && forceColor === undefined) {\n\t\treturn 0;\n\t}\n\n\tconst min = forceColor || 0;\n\n\tif (env.TERM === 'dumb') {\n\t\treturn min;\n\t}\n\n\tif (process.platform === 'win32') {\n\t\t// Windows 10 build 10586 is the first Windows release that supports 256 colors.\n\t\t// Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n\t\tconst osRelease = os.release().split('.');\n\t\tif (\n\t\t\tNumber(osRelease[0]) >= 10 &&\n\t\t\tNumber(osRelease[2]) >= 10586\n\t\t) {\n\t\t\treturn Number(osRelease[2]) >= 14931 ? 3 : 2;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif ('CI' in env) {\n\t\tif (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn min;\n\t}\n\n\tif ('TEAMCITY_VERSION' in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;\n\t}\n\n\tif (env.COLORTERM === 'truecolor') {\n\t\treturn 3;\n\t}\n\n\tif ('TERM_PROGRAM' in env) {\n\t\tconst version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);\n\n\t\tswitch (env.TERM_PROGRAM) {\n\t\t\tcase 'iTerm.app':\n\t\t\t\treturn version >= 3 ? 3 : 2;\n\t\t\tcase 'Apple_Terminal':\n\t\t\t\treturn 2;\n\t\t\t// No default\n\t\t}\n\t}\n\n\tif (/-256(color)?$/i.test(env.TERM)) {\n\t\treturn 2;\n\t}\n\n\tif (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {\n\t\treturn 1;\n\t}\n\n\tif ('COLORTERM' in env) {\n\t\treturn 1;\n\t}\n\n\treturn min;\n}\n\nfunction getSupportLevel(stream) {\n\tconst level = supportsColor(stream, stream && stream.isTTY);\n\treturn translateLevel(level);\n}\n\nmodule.exports = {\n\tsupportsColor: getSupportLevel,\n\tstdout: translateLevel(supportsColor(true, tty.isatty(1))),\n\tstderr: translateLevel(supportsColor(true, tty.isatty(2)))\n};\n","var chownr = require('chownr')\nvar tar = require('tar-stream')\nvar pump = require('pump')\nvar mkdirp = require('mkdirp-classic')\nvar fs = require('fs')\nvar path = require('path')\nvar os = require('os')\n\nvar win32 = os.platform() === 'win32'\n\nvar noop = function () {}\n\nvar echo = function (name) {\n return name\n}\n\nvar normalize = !win32 ? echo : function (name) {\n return name.replace(/\\\\/g, '/').replace(/[:?<>|]/g, '_')\n}\n\nvar statAll = function (fs, stat, cwd, ignore, entries, sort) {\n var queue = entries || ['.']\n\n return function loop (callback) {\n if (!queue.length) return callback()\n var next = queue.shift()\n var nextAbs = path.join(cwd, next)\n\n stat(nextAbs, function (err, stat) {\n if (err) return callback(err)\n\n if (!stat.isDirectory()) return callback(null, next, stat)\n\n fs.readdir(nextAbs, function (err, files) {\n if (err) return callback(err)\n\n if (sort) files.sort()\n for (var i = 0; i < files.length; i++) {\n if (!ignore(path.join(cwd, next, files[i]))) queue.push(path.join(next, files[i]))\n }\n\n callback(null, next, stat)\n })\n })\n }\n}\n\nvar strip = function (map, level) {\n return function (header) {\n header.name = header.name.split('/').slice(level).join('/')\n\n var linkname = header.linkname\n if (linkname && (header.type === 'link' || path.isAbsolute(linkname))) {\n header.linkname = linkname.split('/').slice(level).join('/')\n }\n\n return map(header)\n }\n}\n\nexports.pack = function (cwd, opts) {\n if (!cwd) cwd = '.'\n if (!opts) opts = {}\n\n var xfs = opts.fs || fs\n var ignore = opts.ignore || opts.filter || noop\n var map = opts.map || noop\n var mapStream = opts.mapStream || echo\n var statNext = statAll(xfs, opts.dereference ? xfs.stat : xfs.lstat, cwd, ignore, opts.entries, opts.sort)\n var strict = opts.strict !== false\n var umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()\n var dmode = typeof opts.dmode === 'number' ? opts.dmode : 0\n var fmode = typeof opts.fmode === 'number' ? opts.fmode : 0\n var pack = opts.pack || tar.pack()\n var finish = opts.finish || noop\n\n if (opts.strip) map = strip(map, opts.strip)\n\n if (opts.readable) {\n dmode |= parseInt(555, 8)\n fmode |= parseInt(444, 8)\n }\n if (opts.writable) {\n dmode |= parseInt(333, 8)\n fmode |= parseInt(222, 8)\n }\n\n var onsymlink = function (filename, header) {\n xfs.readlink(path.join(cwd, filename), function (err, linkname) {\n if (err) return pack.destroy(err)\n header.linkname = normalize(linkname)\n pack.entry(header, onnextentry)\n })\n }\n\n var onstat = function (err, filename, stat) {\n if (err) return pack.destroy(err)\n if (!filename) {\n if (opts.finalize !== false) pack.finalize()\n return finish(pack)\n }\n\n if (stat.isSocket()) return onnextentry() // tar does not support sockets...\n\n var header = {\n name: normalize(filename),\n mode: (stat.mode | (stat.isDirectory() ? dmode : fmode)) & umask,\n mtime: stat.mtime,\n size: stat.size,\n type: 'file',\n uid: stat.uid,\n gid: stat.gid\n }\n\n if (stat.isDirectory()) {\n header.size = 0\n header.type = 'directory'\n header = map(header) || header\n return pack.entry(header, onnextentry)\n }\n\n if (stat.isSymbolicLink()) {\n header.size = 0\n header.type = 'symlink'\n header = map(header) || header\n return onsymlink(filename, header)\n }\n\n // TODO: add fifo etc...\n\n header = map(header) || header\n\n if (!stat.isFile()) {\n if (strict) return pack.destroy(new Error('unsupported type for ' + filename))\n return onnextentry()\n }\n\n var entry = pack.entry(header, onnextentry)\n if (!entry) return\n\n var rs = mapStream(xfs.createReadStream(path.join(cwd, filename)), header)\n\n rs.on('error', function (err) { // always forward errors on destroy\n entry.destroy(err)\n })\n\n pump(rs, entry)\n }\n\n var onnextentry = function (err) {\n if (err) return pack.destroy(err)\n statNext(onstat)\n }\n\n onnextentry()\n\n return pack\n}\n\nvar head = function (list) {\n return list.length ? list[list.length - 1] : null\n}\n\nvar processGetuid = function () {\n return process.getuid ? process.getuid() : -1\n}\n\nvar processUmask = function () {\n return process.umask ? process.umask() : 0\n}\n\nexports.extract = function (cwd, opts) {\n if (!cwd) cwd = '.'\n if (!opts) opts = {}\n\n var xfs = opts.fs || fs\n var ignore = opts.ignore || opts.filter || noop\n var map = opts.map || noop\n var mapStream = opts.mapStream || echo\n var own = opts.chown !== false && !win32 && processGetuid() === 0\n var extract = opts.extract || tar.extract()\n var stack = []\n var now = new Date()\n var umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()\n var dmode = typeof opts.dmode === 'number' ? opts.dmode : 0\n var fmode = typeof opts.fmode === 'number' ? opts.fmode : 0\n var strict = opts.strict !== false\n\n if (opts.strip) map = strip(map, opts.strip)\n\n if (opts.readable) {\n dmode |= parseInt(555, 8)\n fmode |= parseInt(444, 8)\n }\n if (opts.writable) {\n dmode |= parseInt(333, 8)\n fmode |= parseInt(222, 8)\n }\n\n var utimesParent = function (name, cb) { // we just set the mtime on the parent dir again everytime we write an entry\n var top\n while ((top = head(stack)) && name.slice(0, top[0].length) !== top[0]) stack.pop()\n if (!top) return cb()\n xfs.utimes(top[0], now, top[1], cb)\n }\n\n var utimes = function (name, header, cb) {\n if (opts.utimes === false) return cb()\n\n if (header.type === 'directory') return xfs.utimes(name, now, header.mtime, cb)\n if (header.type === 'symlink') return utimesParent(name, cb) // TODO: how to set mtime on link?\n\n xfs.utimes(name, now, header.mtime, function (err) {\n if (err) return cb(err)\n utimesParent(name, cb)\n })\n }\n\n var chperm = function (name, header, cb) {\n var link = header.type === 'symlink'\n\n /* eslint-disable node/no-deprecated-api */\n var chmod = link ? xfs.lchmod : xfs.chmod\n var chown = link ? xfs.lchown : xfs.chown\n /* eslint-enable node/no-deprecated-api */\n\n if (!chmod) return cb()\n\n var mode = (header.mode | (header.type === 'directory' ? dmode : fmode)) & umask\n chmod(name, mode, function (err) {\n if (err) return cb(err)\n if (!own) return cb()\n if (!chown) return cb()\n chown(name, header.uid, header.gid, cb)\n })\n }\n\n extract.on('entry', function (header, stream, next) {\n header = map(header) || header\n header.name = normalize(header.name)\n var name = path.join(cwd, path.join('/', header.name))\n\n if (ignore(name, header)) {\n stream.resume()\n return next()\n }\n\n var stat = function (err) {\n if (err) return next(err)\n utimes(name, header, function (err) {\n if (err) return next(err)\n if (win32) return next()\n chperm(name, header, next)\n })\n }\n\n var onsymlink = function () {\n if (win32) return next() // skip symlinks on win for now before it can be tested\n xfs.unlink(name, function () {\n xfs.symlink(header.linkname, name, stat)\n })\n }\n\n var onlink = function () {\n if (win32) return next() // skip links on win for now before it can be tested\n xfs.unlink(name, function () {\n var srcpath = path.join(cwd, path.join('/', header.linkname))\n\n xfs.link(srcpath, name, function (err) {\n if (err && err.code === 'EPERM' && opts.hardlinkAsFilesFallback) {\n stream = xfs.createReadStream(srcpath)\n return onfile()\n }\n\n stat(err)\n })\n })\n }\n\n var onfile = function () {\n var ws = xfs.createWriteStream(name)\n var rs = mapStream(stream, header)\n\n ws.on('error', function (err) { // always forward errors on destroy\n rs.destroy(err)\n })\n\n pump(rs, ws, function (err) {\n if (err) return next(err)\n ws.on('close', stat)\n })\n }\n\n if (header.type === 'directory') {\n stack.push([name, header.mtime])\n return mkdirfix(name, {\n fs: xfs, own: own, uid: header.uid, gid: header.gid\n }, stat)\n }\n\n var dir = path.dirname(name)\n\n validate(xfs, dir, path.join(cwd, '.'), function (err, valid) {\n if (err) return next(err)\n if (!valid) return next(new Error(dir + ' is not a valid path'))\n\n mkdirfix(dir, {\n fs: xfs, own: own, uid: header.uid, gid: header.gid\n }, function (err) {\n if (err) return next(err)\n\n switch (header.type) {\n case 'file': return onfile()\n case 'link': return onlink()\n case 'symlink': return onsymlink()\n }\n\n if (strict) return next(new Error('unsupported type for ' + name + ' (' + header.type + ')'))\n\n stream.resume()\n next()\n })\n })\n })\n\n if (opts.finish) extract.on('finish', opts.finish)\n\n return extract\n}\n\nfunction validate (fs, name, root, cb) {\n if (name === root) return cb(null, true)\n fs.lstat(name, function (err, st) {\n if (err && err.code !== 'ENOENT') return cb(err)\n if (err || st.isDirectory()) return validate(fs, path.join(name, '..'), root, cb)\n cb(null, false)\n })\n}\n\nfunction mkdirfix (name, opts, cb) {\n mkdirp(name, { fs: opts.fs }, function (err, made) {\n if (!err && made && opts.own) {\n chownr(made, opts.uid, opts.gid, cb)\n } else {\n cb(err)\n }\n })\n}\n","var util = require('util')\nvar bl = require('bl')\nvar headers = require('./headers')\n\nvar Writable = require('readable-stream').Writable\nvar PassThrough = require('readable-stream').PassThrough\n\nvar noop = function () {}\n\nvar overflow = function (size) {\n size &= 511\n return size && 512 - size\n}\n\nvar emptyStream = function (self, offset) {\n var s = new Source(self, offset)\n s.end()\n return s\n}\n\nvar mixinPax = function (header, pax) {\n if (pax.path) header.name = pax.path\n if (pax.linkpath) header.linkname = pax.linkpath\n if (pax.size) header.size = parseInt(pax.size, 10)\n header.pax = pax\n return header\n}\n\nvar Source = function (self, offset) {\n this._parent = self\n this.offset = offset\n PassThrough.call(this, { autoDestroy: false })\n}\n\nutil.inherits(Source, PassThrough)\n\nSource.prototype.destroy = function (err) {\n this._parent.destroy(err)\n}\n\nvar Extract = function (opts) {\n if (!(this instanceof Extract)) return new Extract(opts)\n Writable.call(this, opts)\n\n opts = opts || {}\n\n this._offset = 0\n this._buffer = bl()\n this._missing = 0\n this._partial = false\n this._onparse = noop\n this._header = null\n this._stream = null\n this._overflow = null\n this._cb = null\n this._locked = false\n this._destroyed = false\n this._pax = null\n this._paxGlobal = null\n this._gnuLongPath = null\n this._gnuLongLinkPath = null\n\n var self = this\n var b = self._buffer\n\n var oncontinue = function () {\n self._continue()\n }\n\n var onunlock = function (err) {\n self._locked = false\n if (err) return self.destroy(err)\n if (!self._stream) oncontinue()\n }\n\n var onstreamend = function () {\n self._stream = null\n var drain = overflow(self._header.size)\n if (drain) self._parse(drain, ondrain)\n else self._parse(512, onheader)\n if (!self._locked) oncontinue()\n }\n\n var ondrain = function () {\n self._buffer.consume(overflow(self._header.size))\n self._parse(512, onheader)\n oncontinue()\n }\n\n var onpaxglobalheader = function () {\n var size = self._header.size\n self._paxGlobal = headers.decodePax(b.slice(0, size))\n b.consume(size)\n onstreamend()\n }\n\n var onpaxheader = function () {\n var size = self._header.size\n self._pax = headers.decodePax(b.slice(0, size))\n if (self._paxGlobal) self._pax = Object.assign({}, self._paxGlobal, self._pax)\n b.consume(size)\n onstreamend()\n }\n\n var ongnulongpath = function () {\n var size = self._header.size\n this._gnuLongPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)\n b.consume(size)\n onstreamend()\n }\n\n var ongnulonglinkpath = function () {\n var size = self._header.size\n this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)\n b.consume(size)\n onstreamend()\n }\n\n var onheader = function () {\n var offset = self._offset\n var header\n try {\n header = self._header = headers.decode(b.slice(0, 512), opts.filenameEncoding, opts.allowUnknownFormat)\n } catch (err) {\n self.emit('error', err)\n }\n b.consume(512)\n\n if (!header) {\n self._parse(512, onheader)\n oncontinue()\n return\n }\n if (header.type === 'gnu-long-path') {\n self._parse(header.size, ongnulongpath)\n oncontinue()\n return\n }\n if (header.type === 'gnu-long-link-path') {\n self._parse(header.size, ongnulonglinkpath)\n oncontinue()\n return\n }\n if (header.type === 'pax-global-header') {\n self._parse(header.size, onpaxglobalheader)\n oncontinue()\n return\n }\n if (header.type === 'pax-header') {\n self._parse(header.size, onpaxheader)\n oncontinue()\n return\n }\n\n if (self._gnuLongPath) {\n header.name = self._gnuLongPath\n self._gnuLongPath = null\n }\n\n if (self._gnuLongLinkPath) {\n header.linkname = self._gnuLongLinkPath\n self._gnuLongLinkPath = null\n }\n\n if (self._pax) {\n self._header = header = mixinPax(header, self._pax)\n self._pax = null\n }\n\n self._locked = true\n\n if (!header.size || header.type === 'directory') {\n self._parse(512, onheader)\n self.emit('entry', header, emptyStream(self, offset), onunlock)\n return\n }\n\n self._stream = new Source(self, offset)\n\n self.emit('entry', header, self._stream, onunlock)\n self._parse(header.size, onstreamend)\n oncontinue()\n }\n\n this._onheader = onheader\n this._parse(512, onheader)\n}\n\nutil.inherits(Extract, Writable)\n\nExtract.prototype.destroy = function (err) {\n if (this._destroyed) return\n this._destroyed = true\n\n if (err) this.emit('error', err)\n this.emit('close')\n if (this._stream) this._stream.emit('close')\n}\n\nExtract.prototype._parse = function (size, onparse) {\n if (this._destroyed) return\n this._offset += size\n this._missing = size\n if (onparse === this._onheader) this._partial = false\n this._onparse = onparse\n}\n\nExtract.prototype._continue = function () {\n if (this._destroyed) return\n var cb = this._cb\n this._cb = noop\n if (this._overflow) this._write(this._overflow, undefined, cb)\n else cb()\n}\n\nExtract.prototype._write = function (data, enc, cb) {\n if (this._destroyed) return\n\n var s = this._stream\n var b = this._buffer\n var missing = this._missing\n if (data.length) this._partial = true\n\n // we do not reach end-of-chunk now. just forward it\n\n if (data.length < missing) {\n this._missing -= data.length\n this._overflow = null\n if (s) return s.write(data, cb)\n b.append(data)\n return cb()\n }\n\n // end-of-chunk. the parser should call cb.\n\n this._cb = cb\n this._missing = 0\n\n var overflow = null\n if (data.length > missing) {\n overflow = data.slice(missing)\n data = data.slice(0, missing)\n }\n\n if (s) s.end(data)\n else b.append(data)\n\n this._overflow = overflow\n this._onparse()\n}\n\nExtract.prototype._final = function (cb) {\n if (this._partial) return this.destroy(new Error('Unexpected end of data'))\n cb()\n}\n\nmodule.exports = Extract\n","var alloc = Buffer.alloc\n\nvar ZEROS = '0000000000000000000'\nvar SEVENS = '7777777777777777777'\nvar ZERO_OFFSET = '0'.charCodeAt(0)\nvar USTAR_MAGIC = Buffer.from('ustar\\x00', 'binary')\nvar USTAR_VER = Buffer.from('00', 'binary')\nvar GNU_MAGIC = Buffer.from('ustar\\x20', 'binary')\nvar GNU_VER = Buffer.from('\\x20\\x00', 'binary')\nvar MASK = parseInt('7777', 8)\nvar MAGIC_OFFSET = 257\nvar VERSION_OFFSET = 263\n\nvar clamp = function (index, len, defaultValue) {\n if (typeof index !== 'number') return defaultValue\n index = ~~index // Coerce to integer.\n if (index >= len) return len\n if (index >= 0) return index\n index += len\n if (index >= 0) return index\n return 0\n}\n\nvar toType = function (flag) {\n switch (flag) {\n case 0:\n return 'file'\n case 1:\n return 'link'\n case 2:\n return 'symlink'\n case 3:\n return 'character-device'\n case 4:\n return 'block-device'\n case 5:\n return 'directory'\n case 6:\n return 'fifo'\n case 7:\n return 'contiguous-file'\n case 72:\n return 'pax-header'\n case 55:\n return 'pax-global-header'\n case 27:\n return 'gnu-long-link-path'\n case 28:\n case 30:\n return 'gnu-long-path'\n }\n\n return null\n}\n\nvar toTypeflag = function (flag) {\n switch (flag) {\n case 'file':\n return 0\n case 'link':\n return 1\n case 'symlink':\n return 2\n case 'character-device':\n return 3\n case 'block-device':\n return 4\n case 'directory':\n return 5\n case 'fifo':\n return 6\n case 'contiguous-file':\n return 7\n case 'pax-header':\n return 72\n }\n\n return 0\n}\n\nvar indexOf = function (block, num, offset, end) {\n for (; offset < end; offset++) {\n if (block[offset] === num) return offset\n }\n return end\n}\n\nvar cksum = function (block) {\n var sum = 8 * 32\n for (var i = 0; i < 148; i++) sum += block[i]\n for (var j = 156; j < 512; j++) sum += block[j]\n return sum\n}\n\nvar encodeOct = function (val, n) {\n val = val.toString(8)\n if (val.length > n) return SEVENS.slice(0, n) + ' '\n else return ZEROS.slice(0, n - val.length) + val + ' '\n}\n\n/* Copied from the node-tar repo and modified to meet\n * tar-stream coding standard.\n *\n * Source: https://github.com/npm/node-tar/blob/51b6627a1f357d2eb433e7378e5f05e83b7aa6cd/lib/header.js#L349\n */\nfunction parse256 (buf) {\n // first byte MUST be either 80 or FF\n // 80 for positive, FF for 2's comp\n var positive\n if (buf[0] === 0x80) positive = true\n else if (buf[0] === 0xFF) positive = false\n else return null\n\n // build up a base-256 tuple from the least sig to the highest\n var tuple = []\n for (var i = buf.length - 1; i > 0; i--) {\n var byte = buf[i]\n if (positive) tuple.push(byte)\n else tuple.push(0xFF - byte)\n }\n\n var sum = 0\n var l = tuple.length\n for (i = 0; i < l; i++) {\n sum += tuple[i] * Math.pow(256, i)\n }\n\n return positive ? sum : -1 * sum\n}\n\nvar decodeOct = function (val, offset, length) {\n val = val.slice(offset, offset + length)\n offset = 0\n\n // If prefixed with 0x80 then parse as a base-256 integer\n if (val[offset] & 0x80) {\n return parse256(val)\n } else {\n // Older versions of tar can prefix with spaces\n while (offset < val.length && val[offset] === 32) offset++\n var end = clamp(indexOf(val, 32, offset, val.length), val.length, val.length)\n while (offset < end && val[offset] === 0) offset++\n if (end === offset) return 0\n return parseInt(val.slice(offset, end).toString(), 8)\n }\n}\n\nvar decodeStr = function (val, offset, length, encoding) {\n return val.slice(offset, indexOf(val, 0, offset, offset + length)).toString(encoding)\n}\n\nvar addLength = function (str) {\n var len = Buffer.byteLength(str)\n var digits = Math.floor(Math.log(len) / Math.log(10)) + 1\n if (len + digits >= Math.pow(10, digits)) digits++\n\n return (len + digits) + str\n}\n\nexports.decodeLongPath = function (buf, encoding) {\n return decodeStr(buf, 0, buf.length, encoding)\n}\n\nexports.encodePax = function (opts) { // TODO: encode more stuff in pax\n var result = ''\n if (opts.name) result += addLength(' path=' + opts.name + '\\n')\n if (opts.linkname) result += addLength(' linkpath=' + opts.linkname + '\\n')\n var pax = opts.pax\n if (pax) {\n for (var key in pax) {\n result += addLength(' ' + key + '=' + pax[key] + '\\n')\n }\n }\n return Buffer.from(result)\n}\n\nexports.decodePax = function (buf) {\n var result = {}\n\n while (buf.length) {\n var i = 0\n while (i < buf.length && buf[i] !== 32) i++\n var len = parseInt(buf.slice(0, i).toString(), 10)\n if (!len) return result\n\n var b = buf.slice(i + 1, len - 1).toString()\n var keyIndex = b.indexOf('=')\n if (keyIndex === -1) return result\n result[b.slice(0, keyIndex)] = b.slice(keyIndex + 1)\n\n buf = buf.slice(len)\n }\n\n return result\n}\n\nexports.encode = function (opts) {\n var buf = alloc(512)\n var name = opts.name\n var prefix = ''\n\n if (opts.typeflag === 5 && name[name.length - 1] !== '/') name += '/'\n if (Buffer.byteLength(name) !== name.length) return null // utf-8\n\n while (Buffer.byteLength(name) > 100) {\n var i = name.indexOf('/')\n if (i === -1) return null\n prefix += prefix ? '/' + name.slice(0, i) : name.slice(0, i)\n name = name.slice(i + 1)\n }\n\n if (Buffer.byteLength(name) > 100 || Buffer.byteLength(prefix) > 155) return null\n if (opts.linkname && Buffer.byteLength(opts.linkname) > 100) return null\n\n buf.write(name)\n buf.write(encodeOct(opts.mode & MASK, 6), 100)\n buf.write(encodeOct(opts.uid, 6), 108)\n buf.write(encodeOct(opts.gid, 6), 116)\n buf.write(encodeOct(opts.size, 11), 124)\n buf.write(encodeOct((opts.mtime.getTime() / 1000) | 0, 11), 136)\n\n buf[156] = ZERO_OFFSET + toTypeflag(opts.type)\n\n if (opts.linkname) buf.write(opts.linkname, 157)\n\n USTAR_MAGIC.copy(buf, MAGIC_OFFSET)\n USTAR_VER.copy(buf, VERSION_OFFSET)\n if (opts.uname) buf.write(opts.uname, 265)\n if (opts.gname) buf.write(opts.gname, 297)\n buf.write(encodeOct(opts.devmajor || 0, 6), 329)\n buf.write(encodeOct(opts.devminor || 0, 6), 337)\n\n if (prefix) buf.write(prefix, 345)\n\n buf.write(encodeOct(cksum(buf), 6), 148)\n\n return buf\n}\n\nexports.decode = function (buf, filenameEncoding, allowUnknownFormat) {\n var typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET\n\n var name = decodeStr(buf, 0, 100, filenameEncoding)\n var mode = decodeOct(buf, 100, 8)\n var uid = decodeOct(buf, 108, 8)\n var gid = decodeOct(buf, 116, 8)\n var size = decodeOct(buf, 124, 12)\n var mtime = decodeOct(buf, 136, 12)\n var type = toType(typeflag)\n var linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100, filenameEncoding)\n var uname = decodeStr(buf, 265, 32)\n var gname = decodeStr(buf, 297, 32)\n var devmajor = decodeOct(buf, 329, 8)\n var devminor = decodeOct(buf, 337, 8)\n\n var c = cksum(buf)\n\n // checksum is still initial value if header was null.\n if (c === 8 * 32) return null\n\n // valid checksum\n if (c !== decodeOct(buf, 148, 8)) throw new Error('Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?')\n\n if (USTAR_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0) {\n // ustar (posix) format.\n // prepend prefix, if present.\n if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + '/' + name\n } else if (GNU_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0 &&\n GNU_VER.compare(buf, VERSION_OFFSET, VERSION_OFFSET + 2) === 0) {\n // 'gnu'/'oldgnu' format. Similar to ustar, but has support for incremental and\n // multi-volume tarballs.\n } else {\n if (!allowUnknownFormat) {\n throw new Error('Invalid tar header: unknown format.')\n }\n }\n\n // to support old tar versions that use trailing / to indicate dirs\n if (typeflag === 0 && name && name[name.length - 1] === '/') typeflag = 5\n\n return {\n name,\n mode,\n uid,\n gid,\n size,\n mtime: new Date(1000 * mtime),\n type,\n linkname,\n uname,\n gname,\n devmajor,\n devminor\n }\n}\n","exports.extract = require('./extract')\nexports.pack = require('./pack')\n","var constants = require('fs-constants')\nvar eos = require('end-of-stream')\nvar inherits = require('inherits')\nvar alloc = Buffer.alloc\n\nvar Readable = require('readable-stream').Readable\nvar Writable = require('readable-stream').Writable\nvar StringDecoder = require('string_decoder').StringDecoder\n\nvar headers = require('./headers')\n\nvar DMODE = parseInt('755', 8)\nvar FMODE = parseInt('644', 8)\n\nvar END_OF_TAR = alloc(1024)\n\nvar noop = function () {}\n\nvar overflow = function (self, size) {\n size &= 511\n if (size) self.push(END_OF_TAR.slice(0, 512 - size))\n}\n\nfunction modeToType (mode) {\n switch (mode & constants.S_IFMT) {\n case constants.S_IFBLK: return 'block-device'\n case constants.S_IFCHR: return 'character-device'\n case constants.S_IFDIR: return 'directory'\n case constants.S_IFIFO: return 'fifo'\n case constants.S_IFLNK: return 'symlink'\n }\n\n return 'file'\n}\n\nvar Sink = function (to) {\n Writable.call(this)\n this.written = 0\n this._to = to\n this._destroyed = false\n}\n\ninherits(Sink, Writable)\n\nSink.prototype._write = function (data, enc, cb) {\n this.written += data.length\n if (this._to.push(data)) return cb()\n this._to._drain = cb\n}\n\nSink.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar LinkSink = function () {\n Writable.call(this)\n this.linkname = ''\n this._decoder = new StringDecoder('utf-8')\n this._destroyed = false\n}\n\ninherits(LinkSink, Writable)\n\nLinkSink.prototype._write = function (data, enc, cb) {\n this.linkname += this._decoder.write(data)\n cb()\n}\n\nLinkSink.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar Void = function () {\n Writable.call(this)\n this._destroyed = false\n}\n\ninherits(Void, Writable)\n\nVoid.prototype._write = function (data, enc, cb) {\n cb(new Error('No body allowed for this entry'))\n}\n\nVoid.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar Pack = function (opts) {\n if (!(this instanceof Pack)) return new Pack(opts)\n Readable.call(this, opts)\n\n this._drain = noop\n this._finalized = false\n this._finalizing = false\n this._destroyed = false\n this._stream = null\n}\n\ninherits(Pack, Readable)\n\nPack.prototype.entry = function (header, buffer, callback) {\n if (this._stream) throw new Error('already piping an entry')\n if (this._finalized || this._destroyed) return\n\n if (typeof buffer === 'function') {\n callback = buffer\n buffer = null\n }\n\n if (!callback) callback = noop\n\n var self = this\n\n if (!header.size || header.type === 'symlink') header.size = 0\n if (!header.type) header.type = modeToType(header.mode)\n if (!header.mode) header.mode = header.type === 'directory' ? DMODE : FMODE\n if (!header.uid) header.uid = 0\n if (!header.gid) header.gid = 0\n if (!header.mtime) header.mtime = new Date()\n\n if (typeof buffer === 'string') buffer = Buffer.from(buffer)\n if (Buffer.isBuffer(buffer)) {\n header.size = buffer.length\n this._encode(header)\n var ok = this.push(buffer)\n overflow(self, header.size)\n if (ok) process.nextTick(callback)\n else this._drain = callback\n return new Void()\n }\n\n if (header.type === 'symlink' && !header.linkname) {\n var linkSink = new LinkSink()\n eos(linkSink, function (err) {\n if (err) { // stream was closed\n self.destroy()\n return callback(err)\n }\n\n header.linkname = linkSink.linkname\n self._encode(header)\n callback()\n })\n\n return linkSink\n }\n\n this._encode(header)\n\n if (header.type !== 'file' && header.type !== 'contiguous-file') {\n process.nextTick(callback)\n return new Void()\n }\n\n var sink = new Sink(this)\n\n this._stream = sink\n\n eos(sink, function (err) {\n self._stream = null\n\n if (err) { // stream was closed\n self.destroy()\n return callback(err)\n }\n\n if (sink.written !== header.size) { // corrupting tar\n self.destroy()\n return callback(new Error('size mismatch'))\n }\n\n overflow(self, header.size)\n if (self._finalizing) self.finalize()\n callback()\n })\n\n return sink\n}\n\nPack.prototype.finalize = function () {\n if (this._stream) {\n this._finalizing = true\n return\n }\n\n if (this._finalized) return\n this._finalized = true\n this.push(END_OF_TAR)\n this.push(null)\n}\n\nPack.prototype.destroy = function (err) {\n if (this._destroyed) return\n this._destroyed = true\n\n if (err) this.emit('error', err)\n this.emit('close')\n if (this._stream && this._stream.destroy) this._stream.destroy()\n}\n\nPack.prototype._encode = function (header) {\n if (!header.pax) {\n var buf = headers.encode(header)\n if (buf) {\n this.push(buf)\n return\n }\n }\n this._encodePax(header)\n}\n\nPack.prototype._encodePax = function (header) {\n var paxHeader = headers.encodePax({\n name: header.name,\n linkname: header.linkname,\n pax: header.pax\n })\n\n var newHeader = {\n name: 'PaxHeader',\n mode: header.mode,\n uid: header.uid,\n gid: header.gid,\n size: paxHeader.length,\n mtime: header.mtime,\n type: 'pax-header',\n linkname: header.linkname && 'PaxHeader',\n uname: header.uname,\n gname: header.gname,\n devmajor: header.devmajor,\n devminor: header.devminor\n }\n\n this.push(headers.encode(newHeader))\n this.push(paxHeader)\n overflow(this, paxHeader.length)\n\n newHeader.size = header.size\n newHeader.type = header.type\n this.push(headers.encode(newHeader))\n}\n\nPack.prototype._read = function (n) {\n var drain = this._drain\n this._drain = noop\n drain()\n}\n\nmodule.exports = Pack\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = (x[j] + 128) >> 8;\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i, mlen;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n mlen = -1;\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n mlen = n;\n return mlen;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n var t, i;\n for (i = 0; i < arguments.length; i++) {\n if ((t = Object.prototype.toString.call(arguments[i])) !== '[object Uint8Array]')\n throw new TypeError('unexpected type ' + t + ', use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\n// TODO: Completely remove this in v0.15.\nif (!nacl.util) {\n nacl.util = {};\n nacl.util.decodeUTF8 = nacl.util.encodeUTF8 = nacl.util.encodeBase64 = nacl.util.decodeBase64 = function() {\n throw new Error('nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js');\n };\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return false;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return false;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n if (arguments.length !== 2)\n throw new Error('nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?');\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","\n/**\n * For Node.js, simply re-export the core `util.deprecate` function.\n */\n\nmodule.exports = require('util').deprecate;\n","// Returns a wrapper function that returns a wrapped callback\n// The wrapper function should do some stuff, and return a\n// presumably different callback function.\n// This makes sure that own properties are retained, so that\n// decorations and such are not lost along the way.\nmodule.exports = wrappy\nfunction wrappy (fn, cb) {\n if (fn && cb) return wrappy(fn)(cb)\n\n if (typeof fn !== 'function')\n throw new TypeError('need wrapper function')\n\n Object.keys(fn).forEach(function (k) {\n wrapper[k] = fn[k]\n })\n\n return wrapper\n\n function wrapper() {\n var args = new Array(arguments.length)\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i]\n }\n var ret = fn.apply(this, args)\n var cb = args[args.length-1]\n if (typeof ret === 'function' && ret !== cb) {\n Object.keys(cb).forEach(function (k) {\n ret[k] = cb[k]\n })\n }\n return ret\n }\n}\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.run = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst dockerode_1 = __importDefault(require(\"dockerode\"));\nfunction run() {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n const docker = new dockerode_1.default();\n const untilFilter = JSON.stringify({ until: '24h' });\n yield docker.pruneNetworks({ filters: untilFilter });\n yield docker.pruneContainers({ filters: untilFilter });\n }\n catch (error) {\n core.debug(`Error cleaning up: ${error.message}`);\n }\n });\n}\nexports.run = run;\nrun();\n","module.exports = __non_webpack_require__(__webpack_require__.ab + \"build/Release/cpufeatures.node\")","module.exports = __non_webpack_require__(__webpack_require__.ab + \"lib/protocol/crypto/build/Release/sshcrypto.node\")","module.exports = require(\"assert\");","module.exports = require(\"buffer\");","module.exports = require(\"child_process\");","module.exports = require(\"constants\");","module.exports = require(\"crypto\");","module.exports = require(\"dns\");","module.exports = require(\"events\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","module.exports = require(\"net\");","module.exports = require(\"os\");","module.exports = require(\"path\");","module.exports = require(\"querystring\");","module.exports = require(\"stream\");","module.exports = require(\"string_decoder\");","module.exports = require(\"tls\");","module.exports = require(\"tty\");","module.exports = require(\"url\");","module.exports = require(\"util\");","module.exports = require(\"zlib\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\tvar threw = true;\n\ttry {\n\t\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\t\tthrew = false;\n\t} finally {\n\t\tif(threw) delete __webpack_module_cache__[moduleId];\n\t}\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","\nif (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = __dirname + \"/\";","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(3812);\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AChTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5TA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC3iBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC3YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtKA;AACA;AACA;;;A;;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5QA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACpQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1dA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5jCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzyDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7FA;;;A;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACnmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxrBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC9MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACjNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACvGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC/DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AChGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;AC1BA;;;A;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtSA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;ACzNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC79DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC5hEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChsHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACvVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjkDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAGA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC7rCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtyDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC18CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACt1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC/UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;ACvSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3VA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtSA;AACA;;;A;;;;;ACDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACn1EA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClDA;;A;;;;;ACAA;;A;;;;;;A;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7BA;AACA;;;;ACDA;AACA;AACA;AACA;;;;A","sourceRoot":""} \ No newline at end of file diff --git a/dist/main/index.js b/dist/main/index.js index 0ba677c77..2f7696c03 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -9879,15 +9879,19 @@ Config.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return /** * Inspect + * + * @param {Object} opts Options (optional) * @param {Function} callback Callback, if specified Docker will be queried. * @return {Object} Name only if callback isn't specified. */ -Config.prototype.inspect = function(callback) { +Config.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/configs/' + this.id, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'config not found', @@ -9896,7 +9900,7 @@ Config.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -9907,7 +9911,7 @@ Config.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -9920,23 +9924,22 @@ Config.prototype.inspect = function(callback) { */ Config.prototype.update = function(opts, callback) { var self = this; - if (!callback && typeof opts === 'function') { - callback = opts; - } + var args = util.processArgs(opts, callback); var optsf = { path: '/configs/' + this.id + '/update?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'config not found', 500: 'server error', 503: 'node is not part of a swarm' }, - options: opts + options: args.opts }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -9947,7 +9950,7 @@ Config.prototype.update = function(opts, callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -9965,6 +9968,7 @@ Config.prototype.remove = function(opts, callback) { var optsf = { path: '/configs/' + this.id, method: 'DELETE', + abortSignal: opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -10055,6 +10059,7 @@ Container.prototype.inspect = function(opts, callback) { path: '/containers/' + this.id + '/json?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such container', @@ -10090,6 +10095,7 @@ Container.prototype.rename = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/rename?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -10127,6 +10133,7 @@ Container.prototype.update = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/update', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -10165,6 +10172,7 @@ Container.prototype.top = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/top?', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such container', @@ -10191,13 +10199,17 @@ Container.prototype.top = function(opts, callback) { /** * Containers changes + * @param {Object} Options * @param {Function} callback Callback */ -Container.prototype.changes = function(callback) { +Container.prototype.changes = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/containers/' + this.id + '/changes', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such container', @@ -10205,7 +10217,7 @@ Container.prototype.changes = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -10216,7 +10228,7 @@ Container.prototype.changes = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -10233,6 +10245,7 @@ Container.prototype.listCheckpoint = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/checkpoints?', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such container', @@ -10270,6 +10283,7 @@ Container.prototype.deleteCheckpoint = function(checkpoint, opts, callback) { var optsf = { path: '/containers/' + this.id + '/checkpoints/' + checkpoint + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -10307,6 +10321,7 @@ Container.prototype.createCheckpoint = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/checkpoints', method: 'POST', + abortSignal: args.opts.abortSignal, allowEmpty: true, statusCodes: { 200: true, //unofficial, but proxies may return it @@ -10336,13 +10351,17 @@ Container.prototype.createCheckpoint = function(opts, callback) { /** * Export + * @param {Object} opts Options (optional) * @param {Function} callback Callback with the octet-stream. */ -Container.prototype.export = function(callback) { +Container.prototype.export = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/containers/' + this.id + '/export', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -10351,7 +10370,7 @@ Container.prototype.export = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -10362,7 +10381,7 @@ Container.prototype.export = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -10379,6 +10398,7 @@ Container.prototype.start = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/start?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -10417,6 +10437,7 @@ Container.prototype.pause = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/pause', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -10453,6 +10474,7 @@ Container.prototype.unpause = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/unpause', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -10491,6 +10513,7 @@ Container.prototype.exec = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/exec', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -10533,6 +10556,7 @@ Container.prototype.commit = function(opts, callback) { var optsf = { path: '/commit?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -10570,6 +10594,7 @@ Container.prototype.stop = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/stop?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -10608,6 +10633,7 @@ Container.prototype.restart = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/restart?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -10645,6 +10671,7 @@ Container.prototype.kill = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/kill?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -10682,6 +10709,7 @@ Container.prototype.resize = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/resize?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -10719,6 +10747,7 @@ Container.prototype.attach = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/attach?', method: 'POST', + abortSignal: args.opts.abortSignal, isStream: true, hijack: args.opts.hijack, openStdin: args.opts.stdin, @@ -10758,6 +10787,7 @@ Container.prototype.wait = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/wait?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -10795,6 +10825,7 @@ Container.prototype.remove = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -10834,6 +10865,7 @@ Container.prototype.copy = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/copy', method: 'POST', + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -10871,6 +10903,7 @@ Container.prototype.getArchive = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/archive?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -10909,6 +10942,7 @@ Container.prototype.infoArchive = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/archive?', method: 'HEAD', + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -10948,6 +10982,7 @@ Container.prototype.putArchive = function(file, opts, callback) { path: '/containers/' + this.id + '/archive?', method: 'PUT', file: file, + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -10987,6 +11022,7 @@ Container.prototype.logs = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/logs?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: args.opts.follow || false, statusCodes: { 200: true, @@ -11027,6 +11063,7 @@ Container.prototype.stats = function(opts, callback) { var optsf = { path: '/containers/' + this.id + '/stats?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: isStream, statusCodes: { 200: true, @@ -11107,6 +11144,7 @@ Docker.prototype.createContainer = function(opts, callback) { method: 'POST', options: opts, authconfig: opts.authconfig, + abortSignal: opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -11157,6 +11195,7 @@ Docker.prototype.createImage = function(auth, opts, callback) { method: 'POST', options: opts, authconfig: auth, + abortSignal: opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -11198,6 +11237,7 @@ Docker.prototype.loadImage = function(file, opts, callback) { method: 'POST', options: opts, file: file, + abortSignal: opts && opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -11233,7 +11273,7 @@ Docker.prototype.importImage = function(file, opts, callback) { callback = opts; opts = undefined; } - + if (!opts) opts = {}; @@ -11244,6 +11284,7 @@ Docker.prototype.importImage = function(file, opts, callback) { method: 'POST', options: opts, file: file, + abortSignal: opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -11278,6 +11319,7 @@ Docker.prototype.checkAuth = function(opts, callback) { path: '/auth', method: 'POST', options: opts, + abortSignal: opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -11309,7 +11351,6 @@ Docker.prototype.checkAuth = function(opts, callback) { */ Docker.prototype.buildImage = function(file, opts, callback) { var self = this; - var content; if (!callback && typeof opts === 'function') { callback = opts; @@ -11322,6 +11363,7 @@ Docker.prototype.buildImage = function(file, opts, callback) { method: 'POST', file: file, options: opts, + abortSignal: opts && opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -11469,6 +11511,7 @@ Docker.prototype.listContainers = function(opts, callback) { path: '/containers/json?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -11505,6 +11548,7 @@ Docker.prototype.listImages = function(opts, callback) { path: '/images/json?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -11541,6 +11585,7 @@ Docker.prototype.getImages = function(opts, callback) { path: '/images/get?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -11578,6 +11623,7 @@ Docker.prototype.listServices = function(opts, callback) { path: '/services?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -11613,6 +11659,7 @@ Docker.prototype.listNodes = function(opts, callback) { path: '/nodes?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -11651,6 +11698,7 @@ Docker.prototype.listTasks = function(opts, callback) { path: '/tasks?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -11685,6 +11733,7 @@ Docker.prototype.createSecret = function(opts, callback) { path: '/secrets/create?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -11725,6 +11774,7 @@ Docker.prototype.createConfig = function(opts, callback) { path: '/configs/create?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -11766,6 +11816,7 @@ Docker.prototype.listSecrets = function(opts, callback) { path: '/secrets?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -11801,6 +11852,7 @@ Docker.prototype.listConfigs = function(opts, callback) { path: '/configs?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -11835,6 +11887,7 @@ Docker.prototype.createPlugin = function(opts, callback) { path: '/plugins/create?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 204: true, @@ -11874,6 +11927,7 @@ Docker.prototype.listPlugins = function(opts, callback) { path: '/plugins?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -11909,6 +11963,7 @@ Docker.prototype.pruneImages = function(opts, callback) { path: '/images/prune?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -11933,21 +11988,24 @@ Docker.prototype.pruneImages = function(opts, callback) { /** * Prune builder + * @param {Object} opts Options (optional) * @param {Function} callback Callback */ -Docker.prototype.pruneBuilder = function(callback) { +Docker.prototype.pruneBuilder = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/build/prune', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -11958,7 +12016,7 @@ Docker.prototype.pruneBuilder = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -11976,6 +12034,7 @@ Docker.prototype.pruneContainers = function(opts, callback) { path: '/containers/prune?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -12011,6 +12070,7 @@ Docker.prototype.pruneVolumes = function(opts, callback) { path: '/volumes/prune?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -12046,6 +12106,7 @@ Docker.prototype.pruneNetworks = function(opts, callback) { path: '/networks/prune?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -12082,6 +12143,7 @@ Docker.prototype.createVolume = function(opts, callback) { method: 'POST', allowEmpty: true, options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -12129,6 +12191,7 @@ Docker.prototype.createService = function(auth, opts, callback) { method: 'POST', options: opts, authconfig: auth, + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 201: true, @@ -12167,6 +12230,7 @@ Docker.prototype.listVolumes = function(opts, callback) { path: '/volumes?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -12202,6 +12266,7 @@ Docker.prototype.createNetwork = function(opts, callback) { path: '/networks/create?', method: 'POST', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -12241,6 +12306,7 @@ Docker.prototype.listNetworks = function(opts, callback) { path: '/networks?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -12276,6 +12342,7 @@ Docker.prototype.searchImages = function(opts, callback) { method: 'GET', options: opts, authconfig: opts.authconfig, + abortSignal: opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -12300,13 +12367,17 @@ Docker.prototype.searchImages = function(opts, callback) { /** * Info - * @param {Function} callback Callback with info + * @param {Object} opts Options (optional) + * @param {Function} callback Callback with info */ -Docker.prototype.info = function(callback) { +Docker.prototype.info = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var opts = { path: '/info', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -12314,7 +12385,7 @@ Docker.prototype.info = function(callback) { }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(opts, function(err, data) { if (err) { @@ -12325,27 +12396,31 @@ Docker.prototype.info = function(callback) { }); } else { this.modem.dial(opts, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; /** * Version - * @param {Function} callback Callback + * @param {Object} opts Options (optional) + * @param {Function} callback Callback */ -Docker.prototype.version = function(callback) { +Docker.prototype.version = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var opts = { path: '/version', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(opts, function(err, data) { if (err) { @@ -12356,27 +12431,31 @@ Docker.prototype.version = function(callback) { }); } else { this.modem.dial(opts, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; /** * Ping - * @param {Function} callback Callback + * @param {Object} opts Options (optional) + * @param {Function} callback Callback */ -Docker.prototype.ping = function(callback) { +Docker.prototype.ping = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/_ping', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -12387,7 +12466,7 @@ Docker.prototype.ping = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -12395,20 +12474,24 @@ Docker.prototype.ping = function(callback) { /** * SystemDf equivalent to system/df API Engine * get usage data information - * @param {Function} callback Callback + * @param {Object} opts Options (optional) + * @param {Function} callback Callback */ -Docker.prototype.df = function(callback) { +Docker.prototype.df = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/system/df', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -12419,7 +12502,7 @@ Docker.prototype.df = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -12437,6 +12520,7 @@ Docker.prototype.getEvents = function(opts, callback) { path: '/events?', method: 'GET', options: args.opts, + abortSignal: args.opts.abortSignal, isStream: true, statusCodes: { 200: true, @@ -12658,6 +12742,7 @@ Docker.prototype.swarmInit = function(opts, callback) { var optsf = { path: '/swarm/init', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -12695,6 +12780,7 @@ Docker.prototype.swarmJoin = function(opts, callback) { var optsf = { path: '/swarm/join', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -12732,6 +12818,7 @@ Docker.prototype.swarmLeave = function(opts, callback) { var optsf = { path: '/swarm/leave?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 406: 'node is not part of a Swarm' @@ -12768,6 +12855,7 @@ Docker.prototype.swarmUpdate = function(opts, callback) { var optsf = { path: '/swarm/update?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 400: 'bad parameter', @@ -12797,13 +12885,17 @@ Docker.prototype.swarmUpdate = function(opts, callback) { * Inspect a Swarm. * Warning: This method is not documented in the API * - * @param {Function} callback Callback + * @param {Object} opts Options (optional) + * @param {Function} callback Callback */ -Docker.prototype.swarmInspect = function(callback) { +Docker.prototype.swarmInspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/swarm', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 406: 'This node is not a swarm manager', @@ -12811,7 +12903,7 @@ Docker.prototype.swarmInspect = function(callback) { } }; - if (callback === undefined) { + if (args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -12822,7 +12914,7 @@ Docker.prototype.swarmInspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -12873,6 +12965,7 @@ Exec.prototype.start = function(opts, callback) { var optsf = { path: '/exec/' + this.id + '/start', method: 'POST', + abortSignal: args.opts.abortSignal, isStream: true, allowEmpty: true, hijack: args.opts.hijack, @@ -12918,6 +13011,7 @@ Exec.prototype.resize = function(opts, callback) { var optsf = { path: '/exec/' + this.id + '/resize?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such exec', @@ -12946,14 +13040,17 @@ Exec.prototype.resize = function(opts, callback) { /** * Get low-level information about the exec call. * + * @param {Object} opts Options (optional) * @param {function} callback */ -Exec.prototype.inspect = function(callback) { +Exec.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/exec/' + this.id + '/json', method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such exec', @@ -12961,7 +13058,7 @@ Exec.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -12973,7 +13070,7 @@ Exec.prototype.inspect = function(callback) { } else { this.modem.dial(optsf, function(err, data) { if (err) return callback(err, data); - callback(err, data); + args.callback(err, data); }); } }; @@ -13158,6 +13255,7 @@ Image.prototype.push = function(opts, callback, auth) { method: 'POST', options: args.opts, authconfig: args.opts.authconfig || auth, + abortSignal: args.opts.abortSignal, isStream: isStream, statusCodes: { 200: true, @@ -13195,6 +13293,7 @@ Image.prototype.tag = function(opts, callback) { path: '/images/' + this.name + '/tag?', method: 'POST', options: opts, + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, // unofficial, but proxies may return it 201: true, @@ -13230,10 +13329,10 @@ Image.prototype.remove = function(opts, callback) { var self = this; var args = util.processArgs(opts, callback); - var optsf = { path: '/images/' + this.name + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such image', @@ -13330,6 +13429,7 @@ Network.prototype.remove = function(opts, callback) { var optsf = { path: '/networks/' + this.id, method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -13369,6 +13469,7 @@ Network.prototype.connect = function(opts, callback) { var optsf = { path: '/networks/' + this.id + '/connect', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 201: true, @@ -13407,6 +13508,7 @@ Network.prototype.disconnect = function(opts, callback) { var optsf = { path: '/networks/' + this.id + '/disconnect', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 201: true, @@ -13460,14 +13562,17 @@ Node.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return t /** * Query Docker for Node details. * + * @param {Object} opts Options (optional) * @param {function} callback */ -Node.prototype.inspect = function(callback) { +Node.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/nodes/' + this.id, method: 'GET', + abortSignal: args.abortSignal, statusCodes: { 200: true, 404: 'no such node', @@ -13475,7 +13580,7 @@ Node.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -13486,7 +13591,7 @@ Node.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -13507,6 +13612,7 @@ Node.prototype.update = function(opts, callback) { var optsf = { path: '/nodes/' + this.id + '/update?', method: 'POST', + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 404: 'no such node', @@ -13547,6 +13653,7 @@ Node.prototype.remove = function(opts, callback) { var optsf = { path: '/nodes/' + this.id + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such node', @@ -13597,15 +13704,19 @@ Plugin.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return /** * Inspect + * + * @param {Object} opts Options (optional) * @param {Function} callback Callback, if specified Docker will be queried. * @return {Object} Name only if callback isn't specified. */ -Plugin.prototype.inspect = function(callback) { +Plugin.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/plugins/' + this.name, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'plugin is not installed', @@ -13613,7 +13724,7 @@ Plugin.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -13624,7 +13735,7 @@ Plugin.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -13641,6 +13752,7 @@ Plugin.prototype.remove = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '?', method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'plugin is not installed', @@ -13668,24 +13780,28 @@ Plugin.prototype.remove = function(opts, callback) { /** * get privileges + * @param {Object} opts Options (optional) * @param {Function} callback Callback * @return {Object} Name only if callback isn't specified. */ -Plugin.prototype.privileges = function(callback) { +Plugin.prototype.privileges = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); + var optsf = { path: '/plugins/privileges?', method: 'GET', options: { 'remote': this.remote }, + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -13696,7 +13812,7 @@ Plugin.prototype.privileges = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -13721,6 +13837,7 @@ Plugin.prototype.pull = function(opts, callback) { var optsf = { path: '/plugins/pull?', method: 'POST', + abortSignal: args.opts.abortSignal, isStream: true, options: args.opts, statusCodes: { @@ -13759,6 +13876,7 @@ Plugin.prototype.enable = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '/enable?', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -13794,6 +13912,7 @@ Plugin.prototype.disable = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '/disable', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 500: 'server error' @@ -13829,6 +13948,7 @@ Plugin.prototype.push = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '/push', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'plugin not installed', @@ -13865,6 +13985,7 @@ Plugin.prototype.configure = function(opts, callback) { var optsf = { path: '/plugins/' + this.name + '/set', method: 'POST', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'plugin not installed', @@ -13908,6 +14029,7 @@ Plugin.prototype.upgrade = function(auth, opts, callback) { var optsf = { path: '/plugins/' + this.name + '/upgrade?', method: 'POST', + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -13959,15 +14081,18 @@ Secret.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return /** * Inspect + * @param {Object} opts Options (optional) * @param {Function} callback Callback, if specified Docker will be queried. * @return {Object} Name only if callback isn't specified. */ -Secret.prototype.inspect = function(callback) { +Secret.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/secrets/' + this.id, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'secret not found', @@ -13976,7 +14101,7 @@ Secret.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -13987,7 +14112,7 @@ Secret.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -14007,6 +14132,7 @@ Secret.prototype.update = function(opts, callback) { var optsf = { path: '/secrets/' + this.id + '/update?', method: 'POST', + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 404: 'secret not found', @@ -14044,6 +14170,7 @@ Secret.prototype.remove = function(opts, callback) { var optsf = { path: '/secrets/' + this.id, method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -14096,14 +14223,17 @@ Service.prototype[__nccwpck_require__(1669).inspect.custom] = function() { retur /** * Query Docker for service details. * + * @param {Object} opts Options (optional) * @param {function} callback */ -Service.prototype.inspect = function(callback) { +Service.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/services/' + this.id, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such service', @@ -14111,7 +14241,7 @@ Service.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -14122,7 +14252,7 @@ Service.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -14130,14 +14260,17 @@ Service.prototype.inspect = function(callback) { /** * Delete Service * + * @param {Object} opts Options (optional) * @param {function} callback */ -Service.prototype.remove = function(callback) { +Service.prototype.remove = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/services/' + this.id, method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 204: true, @@ -14146,7 +14279,7 @@ Service.prototype.remove = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -14157,7 +14290,7 @@ Service.prototype.remove = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -14186,6 +14319,7 @@ Service.prototype.update = function(auth, opts, callback) { var optsf = { path: '/services/' + this.id + '/update?', method: 'POST', + abortSignal: opts && opts.abortSignal, statusCodes: { 200: true, 404: 'no such service', @@ -14225,6 +14359,7 @@ Service.prototype.logs = function(opts, callback) { var optsf = { path: '/services/' + this.id + '/logs?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: args.opts.follow || false, statusCodes: { 200: true, @@ -14282,14 +14417,17 @@ Task.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return t /** * Query Docker for Task details. * + * @param {Object} opts Options (optional) * @param {function} callback */ -Task.prototype.inspect = function(callback) { +Task.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/tasks/' + this.id, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'unknown task', @@ -14297,7 +14435,7 @@ Task.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -14308,7 +14446,7 @@ Task.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -14325,6 +14463,7 @@ Task.prototype.logs = function(opts, callback) { var optsf = { path: '/tasks/' + this.id + '/logs?', method: 'GET', + abortSignal: args.opts.abortSignal, isStream: args.opts.follow || false, statusCodes: { 101: true, @@ -14454,15 +14593,18 @@ Volume.prototype[__nccwpck_require__(1669).inspect.custom] = function() { return /** * Inspect + * @param {Object} opts Options (optional) * @param {Function} callback Callback, if specified Docker will be queried. * @return {Object} Name only if callback isn't specified. */ -Volume.prototype.inspect = function(callback) { +Volume.prototype.inspect = function(opts, callback) { var self = this; + var args = util.processArgs(opts, callback); var optsf = { path: '/volumes/' + this.name, method: 'GET', + abortSignal: args.opts.abortSignal, statusCodes: { 200: true, 404: 'no such volume', @@ -14470,7 +14612,7 @@ Volume.prototype.inspect = function(callback) { } }; - if(callback === undefined) { + if(args.callback === undefined) { return new this.modem.Promise(function(resolve, reject) { self.modem.dial(optsf, function(err, data) { if (err) { @@ -14481,7 +14623,7 @@ Volume.prototype.inspect = function(callback) { }); } else { this.modem.dial(optsf, function(err, data) { - callback(err, data); + args.callback(err, data); }); } }; @@ -14498,6 +14640,7 @@ Volume.prototype.remove = function(opts, callback) { var optsf = { path: '/volumes/' + this.name, method: 'DELETE', + abortSignal: args.opts.abortSignal, statusCodes: { 204: true, 404: 'no such volume', @@ -50401,6 +50544,7 @@ class Channel extends DuplexStream { destroy() { this.end(); this.close(); + return this; } // Session type-specific methods ============================================= @@ -58463,14 +58607,13 @@ const CLIENT_HANDLERS = { */ const errorCode = bufferParser.readUInt32BE(); const errorMsg = bufferParser.readString(true); - const lang = bufferParser.skipString(); bufferParser.clear(); - if (lang === undefined) { - if (reqID !== undefined) - delete sftp._requests[reqID]; - return doFatalSFTPError(sftp, 'Malformed STATUS packet'); - } + // Note: we avoid checking that the error message and language tag are in + // the packet because there are some broken implementations that incorrectly + // omit them. The language tag in general was never really used amongst ssh + // implementations, so in the case of a missing error message we just + // default to something sensible. if (sftp._debug) { const jsonMsg = JSON.stringify(errorMsg); @@ -59761,6 +59904,8 @@ const SUPPORTED_CIPHER = DEFAULT_CIPHER.concat([ 'aes128-cbc', 'blowfish-cbc', '3des-cbc', + 'aes128-gcm', + 'aes256-gcm', // http://tools.ietf.org/html/rfc4345#section-4: 'arcfour256', @@ -65343,6 +65488,8 @@ OpenSSH_Private.prototype = BaseKey; } else { ret = []; } + if (ret instanceof Error) + return ret; // This will need to change if/when OpenSSH ever starts storing multiple // keys in their key files return ret[0]; @@ -74240,7 +74387,7 @@ module.exports = eval("require")("encoding"); /***/ ((module) => { "use strict"; -module.exports = {"i8":"1.5.0"}; +module.exports = {"i8":"1.6.0"}; /***/ }), diff --git a/dist/main/index.js.map b/dist/main/index.js.map index fcdb20c7f..6bd0a2b8d 100644 --- a/dist/main/index.js.map +++ b/dist/main/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/command.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/core.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/file-command.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/@actions/github/lib/context.js","../webpack://dependabot-updater-action/./node_modules/@actions/github/lib/github.js","../webpack://dependabot-updater-action/./node_modules/@actions/github/lib/internal/utils.js","../webpack://dependabot-updater-action/./node_modules/@actions/github/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/@actions/http-client/index.js","../webpack://dependabot-updater-action/./node_modules/@actions/http-client/proxy.js","../webpack://dependabot-updater-action/./node_modules/@octokit/auth-token/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/core/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/endpoint/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/graphql/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/plugin-paginate-rest/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/request-error/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/request/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/errors.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/index.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/reader.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/types.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/writer.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/index.js","../webpack://dependabot-updater-action/./node_modules/axios/index.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/adapters/http.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/adapters/xhr.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/axios.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/cancel/Cancel.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/cancel/CancelToken.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/cancel/isCancel.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/Axios.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/InterceptorManager.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/buildFullPath.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/createError.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/dispatchRequest.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/enhanceError.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/mergeConfig.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/settle.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/transformData.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/defaults.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/env/data.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/bind.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/buildURL.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/combineURLs.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/cookies.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/isAbsoluteURL.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/isAxiosError.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/isURLSameOrigin.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/normalizeHeaderName.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/parseHeaders.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/spread.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/validator.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/bcrypt-pbkdf/index.js","../webpack://dependabot-updater-action/./node_modules/before-after-hook/index.js","../webpack://dependabot-updater-action/./node_modules/before-after-hook/lib/add.js","../webpack://dependabot-updater-action/./node_modules/before-after-hook/lib/register.js","../webpack://dependabot-updater-action/./node_modules/before-after-hook/lib/remove.js","../webpack://dependabot-updater-action/./node_modules/bl/BufferList.js","../webpack://dependabot-updater-action/./node_modules/bl/bl.js","../webpack://dependabot-updater-action/./node_modules/chownr/chownr.js","../webpack://dependabot-updater-action/./node_modules/cpu-features/lib/index.js","../webpack://dependabot-updater-action/./node_modules/debug/src/browser.js","../webpack://dependabot-updater-action/./node_modules/debug/src/common.js","../webpack://dependabot-updater-action/./node_modules/debug/src/index.js","../webpack://dependabot-updater-action/./node_modules/debug/src/node.js","../webpack://dependabot-updater-action/./node_modules/deprecation/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/http.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/http_duplex.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/modem.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/ssh.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/config.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/container.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/docker.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/exec.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/image.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/network.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/node.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/plugin.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/secret.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/service.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/task.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/util.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/volume.js","../webpack://dependabot-updater-action/./node_modules/end-of-stream/index.js","../webpack://dependabot-updater-action/./node_modules/follow-redirects/debug.js","../webpack://dependabot-updater-action/./node_modules/follow-redirects/index.js","../webpack://dependabot-updater-action/./node_modules/fs-constants/index.js","../webpack://dependabot-updater-action/./node_modules/has-flag/index.js","../webpack://dependabot-updater-action/./node_modules/inherits/inherits.js","../webpack://dependabot-updater-action/./node_modules/inherits/inherits_browser.js","../webpack://dependabot-updater-action/./node_modules/is-plain-object/dist/is-plain-object.js","../webpack://dependabot-updater-action/./node_modules/mkdirp-classic/index.js","../webpack://dependabot-updater-action/./node_modules/ms/index.js","../webpack://dependabot-updater-action/./node_modules/node-fetch/lib/index.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/aes.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/aesCipherSuites.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/asn1-validator.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/asn1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/baseN.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/cipher.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/cipherModes.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/debug.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/des.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/ed25519.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/forge.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/hmac.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/index.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/jsbn.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/kem.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/log.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/md.all.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/md.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/md5.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/mgf.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/mgf1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/oids.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pbe.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pbkdf2.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pem.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pkcs1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pkcs12.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pkcs7.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pkcs7asn1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pki.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/prime.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/prng.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pss.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/random.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/rc2.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/rsa.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/sha1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/sha256.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/sha512.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/ssh.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/task.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/tls.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/util.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/x509.js","../webpack://dependabot-updater-action/./node_modules/once/once.js","../webpack://dependabot-updater-action/./node_modules/pump/index.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/errors.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_duplex.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_passthrough.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_readable.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_transform.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_writable.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/async_iterator.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/buffer_list.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/destroy.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/end-of-stream.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/from.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/pipeline.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/state.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/stream.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/readable.js","../webpack://dependabot-updater-action/./node_modules/safer-buffer/safer.js","../webpack://dependabot-updater-action/./node_modules/split-ca/index.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/Channel.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/agent.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/client.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/http-agents.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/index.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/Protocol.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/SFTP.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/constants.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto/poly1305.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/handlers.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/handlers.misc.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/kex.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/keyParser.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/node-fs-compat.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/utils.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/zlib.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/server.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/string_decoder/lib/string_decoder.js","../webpack://dependabot-updater-action/./node_modules/string_decoder/node_modules/safe-buffer/index.js","../webpack://dependabot-updater-action/./node_modules/supports-color/index.js","../webpack://dependabot-updater-action/./node_modules/tar-fs/index.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/extract.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/headers.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/index.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/pack.js","../webpack://dependabot-updater-action/./node_modules/tunnel/index.js","../webpack://dependabot-updater-action/./node_modules/tunnel/lib/tunnel.js","../webpack://dependabot-updater-action/./node_modules/tweetnacl/nacl-fast.js","../webpack://dependabot-updater-action/./node_modules/universal-user-agent/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/util-deprecate/node.js","../webpack://dependabot-updater-action/./node_modules/wrappy/wrappy.js","../webpack://dependabot-updater-action/./src/api-client.ts","../webpack://dependabot-updater-action/./src/container-service.ts","../webpack://dependabot-updater-action/./src/image-service.ts","../webpack://dependabot-updater-action/./src/inputs.ts","../webpack://dependabot-updater-action/./src/main.ts","../webpack://dependabot-updater-action/./src/proxy.ts","../webpack://dependabot-updater-action/./src/updater-builder.ts","../webpack://dependabot-updater-action/./src/updater.ts","../webpack://dependabot-updater-action/./src/utils.ts","../webpack://dependabot-updater-action/./node_modules/cpu-features/build/Release/cpufeatures.node","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node","../webpack://dependabot-updater-action/./node_modules/@vercel/ncc/dist/ncc/@@notfound.js","../webpack://dependabot-updater-action/external \"assert\"","../webpack://dependabot-updater-action/external \"buffer\"","../webpack://dependabot-updater-action/external \"child_process\"","../webpack://dependabot-updater-action/external \"constants\"","../webpack://dependabot-updater-action/external \"crypto\"","../webpack://dependabot-updater-action/external \"dns\"","../webpack://dependabot-updater-action/external \"events\"","../webpack://dependabot-updater-action/external \"fs\"","../webpack://dependabot-updater-action/external \"http\"","../webpack://dependabot-updater-action/external \"https\"","../webpack://dependabot-updater-action/external \"net\"","../webpack://dependabot-updater-action/external \"os\"","../webpack://dependabot-updater-action/external \"path\"","../webpack://dependabot-updater-action/external \"querystring\"","../webpack://dependabot-updater-action/external \"stream\"","../webpack://dependabot-updater-action/external \"string_decoder\"","../webpack://dependabot-updater-action/external \"tls\"","../webpack://dependabot-updater-action/external \"tty\"","../webpack://dependabot-updater-action/external \"url\"","../webpack://dependabot-updater-action/external \"util\"","../webpack://dependabot-updater-action/external \"zlib\"","../webpack://dependabot-updater-action/webpack/bootstrap","../webpack://dependabot-updater-action/webpack/runtime/compat","../webpack://dependabot-updater-action/webpack/startup"],"sourcesContent":["\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.issue = exports.issueCommand = void 0;\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\n/**\n * Commands\n *\n * Command Format:\n * ::name key=value,key=value::message\n *\n * Examples:\n * ::warning::This is the message\n * ::set-env name=MY_VAR::some value\n */\nfunction issueCommand(command, properties, message) {\n const cmd = new Command(command, properties, message);\n process.stdout.write(cmd.toString() + os.EOL);\n}\nexports.issueCommand = issueCommand;\nfunction issue(name, message = '') {\n issueCommand(name, {}, message);\n}\nexports.issue = issue;\nconst CMD_STRING = '::';\nclass Command {\n constructor(command, properties, message) {\n if (!command) {\n command = 'missing.command';\n }\n this.command = command;\n this.properties = properties;\n this.message = message;\n }\n toString() {\n let cmdStr = CMD_STRING + this.command;\n if (this.properties && Object.keys(this.properties).length > 0) {\n cmdStr += ' ';\n let first = true;\n for (const key in this.properties) {\n if (this.properties.hasOwnProperty(key)) {\n const val = this.properties[key];\n if (val) {\n if (first) {\n first = false;\n }\n else {\n cmdStr += ',';\n }\n cmdStr += `${key}=${escapeProperty(val)}`;\n }\n }\n }\n }\n cmdStr += `${CMD_STRING}${escapeData(this.message)}`;\n return cmdStr;\n }\n}\nfunction escapeData(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A');\n}\nfunction escapeProperty(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A')\n .replace(/:/g, '%3A')\n .replace(/,/g, '%2C');\n}\n//# sourceMappingURL=command.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;\nconst command_1 = require(\"./command\");\nconst file_command_1 = require(\"./file-command\");\nconst utils_1 = require(\"./utils\");\nconst os = __importStar(require(\"os\"));\nconst path = __importStar(require(\"path\"));\n/**\n * The code to exit an action\n */\nvar ExitCode;\n(function (ExitCode) {\n /**\n * A code indicating that the action was successful\n */\n ExitCode[ExitCode[\"Success\"] = 0] = \"Success\";\n /**\n * A code indicating that the action was a failure\n */\n ExitCode[ExitCode[\"Failure\"] = 1] = \"Failure\";\n})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));\n//-----------------------------------------------------------------------\n// Variables\n//-----------------------------------------------------------------------\n/**\n * Sets env variable for this action and future actions in the job\n * @param name the name of the variable to set\n * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction exportVariable(name, val) {\n const convertedVal = utils_1.toCommandValue(val);\n process.env[name] = convertedVal;\n const filePath = process.env['GITHUB_ENV'] || '';\n if (filePath) {\n const delimiter = '_GitHubActionsFileCommandDelimeter_';\n const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;\n file_command_1.issueCommand('ENV', commandValue);\n }\n else {\n command_1.issueCommand('set-env', { name }, convertedVal);\n }\n}\nexports.exportVariable = exportVariable;\n/**\n * Registers a secret which will get masked from logs\n * @param secret value of the secret\n */\nfunction setSecret(secret) {\n command_1.issueCommand('add-mask', {}, secret);\n}\nexports.setSecret = setSecret;\n/**\n * Prepends inputPath to the PATH (for this action and future actions)\n * @param inputPath\n */\nfunction addPath(inputPath) {\n const filePath = process.env['GITHUB_PATH'] || '';\n if (filePath) {\n file_command_1.issueCommand('PATH', inputPath);\n }\n else {\n command_1.issueCommand('add-path', {}, inputPath);\n }\n process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;\n}\nexports.addPath = addPath;\n/**\n * Gets the value of an input.\n * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.\n * Returns an empty string if the value is not defined.\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns string\n */\nfunction getInput(name, options) {\n const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';\n if (options && options.required && !val) {\n throw new Error(`Input required and not supplied: ${name}`);\n }\n if (options && options.trimWhitespace === false) {\n return val;\n }\n return val.trim();\n}\nexports.getInput = getInput;\n/**\n * Gets the values of an multiline input. Each value is also trimmed.\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns string[]\n *\n */\nfunction getMultilineInput(name, options) {\n const inputs = getInput(name, options)\n .split('\\n')\n .filter(x => x !== '');\n return inputs;\n}\nexports.getMultilineInput = getMultilineInput;\n/**\n * Gets the input value of the boolean type in the YAML 1.2 \"core schema\" specification.\n * Support boolean input list: `true | True | TRUE | false | False | FALSE` .\n * The return value is also in boolean type.\n * ref: https://yaml.org/spec/1.2/spec.html#id2804923\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns boolean\n */\nfunction getBooleanInput(name, options) {\n const trueValue = ['true', 'True', 'TRUE'];\n const falseValue = ['false', 'False', 'FALSE'];\n const val = getInput(name, options);\n if (trueValue.includes(val))\n return true;\n if (falseValue.includes(val))\n return false;\n throw new TypeError(`Input does not meet YAML 1.2 \"Core Schema\" specification: ${name}\\n` +\n `Support boolean input list: \\`true | True | TRUE | false | False | FALSE\\``);\n}\nexports.getBooleanInput = getBooleanInput;\n/**\n * Sets the value of an output.\n *\n * @param name name of the output to set\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction setOutput(name, value) {\n process.stdout.write(os.EOL);\n command_1.issueCommand('set-output', { name }, value);\n}\nexports.setOutput = setOutput;\n/**\n * Enables or disables the echoing of commands into stdout for the rest of the step.\n * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.\n *\n */\nfunction setCommandEcho(enabled) {\n command_1.issue('echo', enabled ? 'on' : 'off');\n}\nexports.setCommandEcho = setCommandEcho;\n//-----------------------------------------------------------------------\n// Results\n//-----------------------------------------------------------------------\n/**\n * Sets the action status to failed.\n * When the action exits it will be with an exit code of 1\n * @param message add error issue message\n */\nfunction setFailed(message) {\n process.exitCode = ExitCode.Failure;\n error(message);\n}\nexports.setFailed = setFailed;\n//-----------------------------------------------------------------------\n// Logging Commands\n//-----------------------------------------------------------------------\n/**\n * Gets whether Actions Step Debug is on or not\n */\nfunction isDebug() {\n return process.env['RUNNER_DEBUG'] === '1';\n}\nexports.isDebug = isDebug;\n/**\n * Writes debug message to user log\n * @param message debug message\n */\nfunction debug(message) {\n command_1.issueCommand('debug', {}, message);\n}\nexports.debug = debug;\n/**\n * Adds an error issue\n * @param message error issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction error(message, properties = {}) {\n command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.error = error;\n/**\n * Adds a warning issue\n * @param message warning issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction warning(message, properties = {}) {\n command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.warning = warning;\n/**\n * Adds a notice issue\n * @param message notice issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction notice(message, properties = {}) {\n command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.notice = notice;\n/**\n * Writes info to log with console.log.\n * @param message info message\n */\nfunction info(message) {\n process.stdout.write(message + os.EOL);\n}\nexports.info = info;\n/**\n * Begin an output group.\n *\n * Output until the next `groupEnd` will be foldable in this group\n *\n * @param name The name of the output group\n */\nfunction startGroup(name) {\n command_1.issue('group', name);\n}\nexports.startGroup = startGroup;\n/**\n * End an output group.\n */\nfunction endGroup() {\n command_1.issue('endgroup');\n}\nexports.endGroup = endGroup;\n/**\n * Wrap an asynchronous function call in a group.\n *\n * Returns the same type as the function itself.\n *\n * @param name The name of the group\n * @param fn The function to wrap in the group\n */\nfunction group(name, fn) {\n return __awaiter(this, void 0, void 0, function* () {\n startGroup(name);\n let result;\n try {\n result = yield fn();\n }\n finally {\n endGroup();\n }\n return result;\n });\n}\nexports.group = group;\n//-----------------------------------------------------------------------\n// Wrapper action state\n//-----------------------------------------------------------------------\n/**\n * Saves state for current action, the state can only be retrieved by this action's post job execution.\n *\n * @param name name of the state to store\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction saveState(name, value) {\n command_1.issueCommand('save-state', { name }, value);\n}\nexports.saveState = saveState;\n/**\n * Gets the value of an state set by this action's main execution.\n *\n * @param name name of the state to get\n * @returns string\n */\nfunction getState(name) {\n return process.env[`STATE_${name}`] || '';\n}\nexports.getState = getState;\n//# sourceMappingURL=core.js.map","\"use strict\";\n// For internal use, subject to change.\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.issueCommand = void 0;\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst fs = __importStar(require(\"fs\"));\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\nfunction issueCommand(command, message) {\n const filePath = process.env[`GITHUB_${command}`];\n if (!filePath) {\n throw new Error(`Unable to find environment variable for file command ${command}`);\n }\n if (!fs.existsSync(filePath)) {\n throw new Error(`Missing file at path: ${filePath}`);\n }\n fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {\n encoding: 'utf8'\n });\n}\nexports.issueCommand = issueCommand;\n//# sourceMappingURL=file-command.js.map","\"use strict\";\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.toCommandProperties = exports.toCommandValue = void 0;\n/**\n * Sanitizes an input into a string so it can be passed into issueCommand safely\n * @param input input to sanitize into a string\n */\nfunction toCommandValue(input) {\n if (input === null || input === undefined) {\n return '';\n }\n else if (typeof input === 'string' || input instanceof String) {\n return input;\n }\n return JSON.stringify(input);\n}\nexports.toCommandValue = toCommandValue;\n/**\n *\n * @param annotationProperties\n * @returns The command properties to send with the actual annotation command\n * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646\n */\nfunction toCommandProperties(annotationProperties) {\n if (!Object.keys(annotationProperties).length) {\n return {};\n }\n return {\n title: annotationProperties.title,\n line: annotationProperties.startLine,\n endLine: annotationProperties.endLine,\n col: annotationProperties.startColumn,\n endColumn: annotationProperties.endColumn\n };\n}\nexports.toCommandProperties = toCommandProperties;\n//# sourceMappingURL=utils.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Context = void 0;\nconst fs_1 = require(\"fs\");\nconst os_1 = require(\"os\");\nclass Context {\n /**\n * Hydrate the context from the environment\n */\n constructor() {\n var _a, _b, _c;\n this.payload = {};\n if (process.env.GITHUB_EVENT_PATH) {\n if (fs_1.existsSync(process.env.GITHUB_EVENT_PATH)) {\n this.payload = JSON.parse(fs_1.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' }));\n }\n else {\n const path = process.env.GITHUB_EVENT_PATH;\n process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${os_1.EOL}`);\n }\n }\n this.eventName = process.env.GITHUB_EVENT_NAME;\n this.sha = process.env.GITHUB_SHA;\n this.ref = process.env.GITHUB_REF;\n this.workflow = process.env.GITHUB_WORKFLOW;\n this.action = process.env.GITHUB_ACTION;\n this.actor = process.env.GITHUB_ACTOR;\n this.job = process.env.GITHUB_JOB;\n this.runNumber = parseInt(process.env.GITHUB_RUN_NUMBER, 10);\n this.runId = parseInt(process.env.GITHUB_RUN_ID, 10);\n this.apiUrl = (_a = process.env.GITHUB_API_URL) !== null && _a !== void 0 ? _a : `https://api.github.com`;\n this.serverUrl = (_b = process.env.GITHUB_SERVER_URL) !== null && _b !== void 0 ? _b : `https://github.com`;\n this.graphqlUrl = (_c = process.env.GITHUB_GRAPHQL_URL) !== null && _c !== void 0 ? _c : `https://api.github.com/graphql`;\n }\n get issue() {\n const payload = this.payload;\n return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pull_request || payload).number });\n }\n get repo() {\n if (process.env.GITHUB_REPOSITORY) {\n const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');\n return { owner, repo };\n }\n if (this.payload.repository) {\n return {\n owner: this.payload.repository.owner.login,\n repo: this.payload.repository.name\n };\n }\n throw new Error(\"context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'\");\n }\n}\nexports.Context = Context;\n//# sourceMappingURL=context.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getOctokit = exports.context = void 0;\nconst Context = __importStar(require(\"./context\"));\nconst utils_1 = require(\"./utils\");\nexports.context = new Context.Context();\n/**\n * Returns a hydrated octokit ready to use for GitHub Actions\n *\n * @param token the repo PAT or GITHUB_TOKEN\n * @param options other options to set\n */\nfunction getOctokit(token, options) {\n return new utils_1.GitHub(utils_1.getOctokitOptions(token, options));\n}\nexports.getOctokit = getOctokit;\n//# sourceMappingURL=github.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getApiBaseUrl = exports.getProxyAgent = exports.getAuthString = void 0;\nconst httpClient = __importStar(require(\"@actions/http-client\"));\nfunction getAuthString(token, options) {\n if (!token && !options.auth) {\n throw new Error('Parameter token or opts.auth is required');\n }\n else if (token && options.auth) {\n throw new Error('Parameters token and opts.auth may not both be specified');\n }\n return typeof options.auth === 'string' ? options.auth : `token ${token}`;\n}\nexports.getAuthString = getAuthString;\nfunction getProxyAgent(destinationUrl) {\n const hc = new httpClient.HttpClient();\n return hc.getAgent(destinationUrl);\n}\nexports.getProxyAgent = getProxyAgent;\nfunction getApiBaseUrl() {\n return process.env['GITHUB_API_URL'] || 'https://api.github.com';\n}\nexports.getApiBaseUrl = getApiBaseUrl;\n//# sourceMappingURL=utils.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getOctokitOptions = exports.GitHub = exports.context = void 0;\nconst Context = __importStar(require(\"./context\"));\nconst Utils = __importStar(require(\"./internal/utils\"));\n// octokit + plugins\nconst core_1 = require(\"@octokit/core\");\nconst plugin_rest_endpoint_methods_1 = require(\"@octokit/plugin-rest-endpoint-methods\");\nconst plugin_paginate_rest_1 = require(\"@octokit/plugin-paginate-rest\");\nexports.context = new Context.Context();\nconst baseUrl = Utils.getApiBaseUrl();\nconst defaults = {\n baseUrl,\n request: {\n agent: Utils.getProxyAgent(baseUrl)\n }\n};\nexports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults);\n/**\n * Convience function to correctly format Octokit Options to pass into the constructor.\n *\n * @param token the repo PAT or GITHUB_TOKEN\n * @param options other options to set\n */\nfunction getOctokitOptions(token, options) {\n const opts = Object.assign({}, options || {}); // Shallow clone - don't mutate the object provided by the caller\n // Auth\n const auth = Utils.getAuthString(token, opts);\n if (auth) {\n opts.auth = auth;\n }\n return opts;\n}\nexports.getOctokitOptions = getOctokitOptions;\n//# sourceMappingURL=utils.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst http = require(\"http\");\nconst https = require(\"https\");\nconst pm = require(\"./proxy\");\nlet tunnel;\nvar HttpCodes;\n(function (HttpCodes) {\n HttpCodes[HttpCodes[\"OK\"] = 200] = \"OK\";\n HttpCodes[HttpCodes[\"MultipleChoices\"] = 300] = \"MultipleChoices\";\n HttpCodes[HttpCodes[\"MovedPermanently\"] = 301] = \"MovedPermanently\";\n HttpCodes[HttpCodes[\"ResourceMoved\"] = 302] = \"ResourceMoved\";\n HttpCodes[HttpCodes[\"SeeOther\"] = 303] = \"SeeOther\";\n HttpCodes[HttpCodes[\"NotModified\"] = 304] = \"NotModified\";\n HttpCodes[HttpCodes[\"UseProxy\"] = 305] = \"UseProxy\";\n HttpCodes[HttpCodes[\"SwitchProxy\"] = 306] = \"SwitchProxy\";\n HttpCodes[HttpCodes[\"TemporaryRedirect\"] = 307] = \"TemporaryRedirect\";\n HttpCodes[HttpCodes[\"PermanentRedirect\"] = 308] = \"PermanentRedirect\";\n HttpCodes[HttpCodes[\"BadRequest\"] = 400] = \"BadRequest\";\n HttpCodes[HttpCodes[\"Unauthorized\"] = 401] = \"Unauthorized\";\n HttpCodes[HttpCodes[\"PaymentRequired\"] = 402] = \"PaymentRequired\";\n HttpCodes[HttpCodes[\"Forbidden\"] = 403] = \"Forbidden\";\n HttpCodes[HttpCodes[\"NotFound\"] = 404] = \"NotFound\";\n HttpCodes[HttpCodes[\"MethodNotAllowed\"] = 405] = \"MethodNotAllowed\";\n HttpCodes[HttpCodes[\"NotAcceptable\"] = 406] = \"NotAcceptable\";\n HttpCodes[HttpCodes[\"ProxyAuthenticationRequired\"] = 407] = \"ProxyAuthenticationRequired\";\n HttpCodes[HttpCodes[\"RequestTimeout\"] = 408] = \"RequestTimeout\";\n HttpCodes[HttpCodes[\"Conflict\"] = 409] = \"Conflict\";\n HttpCodes[HttpCodes[\"Gone\"] = 410] = \"Gone\";\n HttpCodes[HttpCodes[\"TooManyRequests\"] = 429] = \"TooManyRequests\";\n HttpCodes[HttpCodes[\"InternalServerError\"] = 500] = \"InternalServerError\";\n HttpCodes[HttpCodes[\"NotImplemented\"] = 501] = \"NotImplemented\";\n HttpCodes[HttpCodes[\"BadGateway\"] = 502] = \"BadGateway\";\n HttpCodes[HttpCodes[\"ServiceUnavailable\"] = 503] = \"ServiceUnavailable\";\n HttpCodes[HttpCodes[\"GatewayTimeout\"] = 504] = \"GatewayTimeout\";\n})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));\nvar Headers;\n(function (Headers) {\n Headers[\"Accept\"] = \"accept\";\n Headers[\"ContentType\"] = \"content-type\";\n})(Headers = exports.Headers || (exports.Headers = {}));\nvar MediaTypes;\n(function (MediaTypes) {\n MediaTypes[\"ApplicationJson\"] = \"application/json\";\n})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));\n/**\n * Returns the proxy URL, depending upon the supplied url and proxy environment variables.\n * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com\n */\nfunction getProxyUrl(serverUrl) {\n let proxyUrl = pm.getProxyUrl(new URL(serverUrl));\n return proxyUrl ? proxyUrl.href : '';\n}\nexports.getProxyUrl = getProxyUrl;\nconst HttpRedirectCodes = [\n HttpCodes.MovedPermanently,\n HttpCodes.ResourceMoved,\n HttpCodes.SeeOther,\n HttpCodes.TemporaryRedirect,\n HttpCodes.PermanentRedirect\n];\nconst HttpResponseRetryCodes = [\n HttpCodes.BadGateway,\n HttpCodes.ServiceUnavailable,\n HttpCodes.GatewayTimeout\n];\nconst RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];\nconst ExponentialBackoffCeiling = 10;\nconst ExponentialBackoffTimeSlice = 5;\nclass HttpClientError extends Error {\n constructor(message, statusCode) {\n super(message);\n this.name = 'HttpClientError';\n this.statusCode = statusCode;\n Object.setPrototypeOf(this, HttpClientError.prototype);\n }\n}\nexports.HttpClientError = HttpClientError;\nclass HttpClientResponse {\n constructor(message) {\n this.message = message;\n }\n readBody() {\n return new Promise(async (resolve, reject) => {\n let output = Buffer.alloc(0);\n this.message.on('data', (chunk) => {\n output = Buffer.concat([output, chunk]);\n });\n this.message.on('end', () => {\n resolve(output.toString());\n });\n });\n }\n}\nexports.HttpClientResponse = HttpClientResponse;\nfunction isHttps(requestUrl) {\n let parsedUrl = new URL(requestUrl);\n return parsedUrl.protocol === 'https:';\n}\nexports.isHttps = isHttps;\nclass HttpClient {\n constructor(userAgent, handlers, requestOptions) {\n this._ignoreSslError = false;\n this._allowRedirects = true;\n this._allowRedirectDowngrade = false;\n this._maxRedirects = 50;\n this._allowRetries = false;\n this._maxRetries = 1;\n this._keepAlive = false;\n this._disposed = false;\n this.userAgent = userAgent;\n this.handlers = handlers || [];\n this.requestOptions = requestOptions;\n if (requestOptions) {\n if (requestOptions.ignoreSslError != null) {\n this._ignoreSslError = requestOptions.ignoreSslError;\n }\n this._socketTimeout = requestOptions.socketTimeout;\n if (requestOptions.allowRedirects != null) {\n this._allowRedirects = requestOptions.allowRedirects;\n }\n if (requestOptions.allowRedirectDowngrade != null) {\n this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;\n }\n if (requestOptions.maxRedirects != null) {\n this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);\n }\n if (requestOptions.keepAlive != null) {\n this._keepAlive = requestOptions.keepAlive;\n }\n if (requestOptions.allowRetries != null) {\n this._allowRetries = requestOptions.allowRetries;\n }\n if (requestOptions.maxRetries != null) {\n this._maxRetries = requestOptions.maxRetries;\n }\n }\n }\n options(requestUrl, additionalHeaders) {\n return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});\n }\n get(requestUrl, additionalHeaders) {\n return this.request('GET', requestUrl, null, additionalHeaders || {});\n }\n del(requestUrl, additionalHeaders) {\n return this.request('DELETE', requestUrl, null, additionalHeaders || {});\n }\n post(requestUrl, data, additionalHeaders) {\n return this.request('POST', requestUrl, data, additionalHeaders || {});\n }\n patch(requestUrl, data, additionalHeaders) {\n return this.request('PATCH', requestUrl, data, additionalHeaders || {});\n }\n put(requestUrl, data, additionalHeaders) {\n return this.request('PUT', requestUrl, data, additionalHeaders || {});\n }\n head(requestUrl, additionalHeaders) {\n return this.request('HEAD', requestUrl, null, additionalHeaders || {});\n }\n sendStream(verb, requestUrl, stream, additionalHeaders) {\n return this.request(verb, requestUrl, stream, additionalHeaders);\n }\n /**\n * Gets a typed object from an endpoint\n * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise\n */\n async getJson(requestUrl, additionalHeaders = {}) {\n additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);\n let res = await this.get(requestUrl, additionalHeaders);\n return this._processResponse(res, this.requestOptions);\n }\n async postJson(requestUrl, obj, additionalHeaders = {}) {\n let data = JSON.stringify(obj, null, 2);\n additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);\n additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);\n let res = await this.post(requestUrl, data, additionalHeaders);\n return this._processResponse(res, this.requestOptions);\n }\n async putJson(requestUrl, obj, additionalHeaders = {}) {\n let data = JSON.stringify(obj, null, 2);\n additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);\n additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);\n let res = await this.put(requestUrl, data, additionalHeaders);\n return this._processResponse(res, this.requestOptions);\n }\n async patchJson(requestUrl, obj, additionalHeaders = {}) {\n let data = JSON.stringify(obj, null, 2);\n additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);\n additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);\n let res = await this.patch(requestUrl, data, additionalHeaders);\n return this._processResponse(res, this.requestOptions);\n }\n /**\n * Makes a raw http request.\n * All other methods such as get, post, patch, and request ultimately call this.\n * Prefer get, del, post and patch\n */\n async request(verb, requestUrl, data, headers) {\n if (this._disposed) {\n throw new Error('Client has already been disposed.');\n }\n let parsedUrl = new URL(requestUrl);\n let info = this._prepareRequest(verb, parsedUrl, headers);\n // Only perform retries on reads since writes may not be idempotent.\n let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1\n ? this._maxRetries + 1\n : 1;\n let numTries = 0;\n let response;\n while (numTries < maxTries) {\n response = await this.requestRaw(info, data);\n // Check if it's an authentication challenge\n if (response &&\n response.message &&\n response.message.statusCode === HttpCodes.Unauthorized) {\n let authenticationHandler;\n for (let i = 0; i < this.handlers.length; i++) {\n if (this.handlers[i].canHandleAuthentication(response)) {\n authenticationHandler = this.handlers[i];\n break;\n }\n }\n if (authenticationHandler) {\n return authenticationHandler.handleAuthentication(this, info, data);\n }\n else {\n // We have received an unauthorized response but have no handlers to handle it.\n // Let the response return to the caller.\n return response;\n }\n }\n let redirectsRemaining = this._maxRedirects;\n while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&\n this._allowRedirects &&\n redirectsRemaining > 0) {\n const redirectUrl = response.message.headers['location'];\n if (!redirectUrl) {\n // if there's no location to redirect to, we won't\n break;\n }\n let parsedRedirectUrl = new URL(redirectUrl);\n if (parsedUrl.protocol == 'https:' &&\n parsedUrl.protocol != parsedRedirectUrl.protocol &&\n !this._allowRedirectDowngrade) {\n throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');\n }\n // we need to finish reading the response before reassigning response\n // which will leak the open socket.\n await response.readBody();\n // strip authorization header if redirected to a different hostname\n if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {\n for (let header in headers) {\n // header names are case insensitive\n if (header.toLowerCase() === 'authorization') {\n delete headers[header];\n }\n }\n }\n // let's make the request with the new redirectUrl\n info = this._prepareRequest(verb, parsedRedirectUrl, headers);\n response = await this.requestRaw(info, data);\n redirectsRemaining--;\n }\n if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) {\n // If not a retry code, return immediately instead of retrying\n return response;\n }\n numTries += 1;\n if (numTries < maxTries) {\n await response.readBody();\n await this._performExponentialBackoff(numTries);\n }\n }\n return response;\n }\n /**\n * Needs to be called if keepAlive is set to true in request options.\n */\n dispose() {\n if (this._agent) {\n this._agent.destroy();\n }\n this._disposed = true;\n }\n /**\n * Raw request.\n * @param info\n * @param data\n */\n requestRaw(info, data) {\n return new Promise((resolve, reject) => {\n let callbackForResult = function (err, res) {\n if (err) {\n reject(err);\n }\n resolve(res);\n };\n this.requestRawWithCallback(info, data, callbackForResult);\n });\n }\n /**\n * Raw request with callback.\n * @param info\n * @param data\n * @param onResult\n */\n requestRawWithCallback(info, data, onResult) {\n let socket;\n if (typeof data === 'string') {\n info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');\n }\n let callbackCalled = false;\n let handleResult = (err, res) => {\n if (!callbackCalled) {\n callbackCalled = true;\n onResult(err, res);\n }\n };\n let req = info.httpModule.request(info.options, (msg) => {\n let res = new HttpClientResponse(msg);\n handleResult(null, res);\n });\n req.on('socket', sock => {\n socket = sock;\n });\n // If we ever get disconnected, we want the socket to timeout eventually\n req.setTimeout(this._socketTimeout || 3 * 60000, () => {\n if (socket) {\n socket.end();\n }\n handleResult(new Error('Request timeout: ' + info.options.path), null);\n });\n req.on('error', function (err) {\n // err has statusCode property\n // res should have headers\n handleResult(err, null);\n });\n if (data && typeof data === 'string') {\n req.write(data, 'utf8');\n }\n if (data && typeof data !== 'string') {\n data.on('close', function () {\n req.end();\n });\n data.pipe(req);\n }\n else {\n req.end();\n }\n }\n /**\n * Gets an http agent. This function is useful when you need an http agent that handles\n * routing through a proxy server - depending upon the url and proxy environment variables.\n * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com\n */\n getAgent(serverUrl) {\n let parsedUrl = new URL(serverUrl);\n return this._getAgent(parsedUrl);\n }\n _prepareRequest(method, requestUrl, headers) {\n const info = {};\n info.parsedUrl = requestUrl;\n const usingSsl = info.parsedUrl.protocol === 'https:';\n info.httpModule = usingSsl ? https : http;\n const defaultPort = usingSsl ? 443 : 80;\n info.options = {};\n info.options.host = info.parsedUrl.hostname;\n info.options.port = info.parsedUrl.port\n ? parseInt(info.parsedUrl.port)\n : defaultPort;\n info.options.path =\n (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');\n info.options.method = method;\n info.options.headers = this._mergeHeaders(headers);\n if (this.userAgent != null) {\n info.options.headers['user-agent'] = this.userAgent;\n }\n info.options.agent = this._getAgent(info.parsedUrl);\n // gives handlers an opportunity to participate\n if (this.handlers) {\n this.handlers.forEach(handler => {\n handler.prepareRequest(info.options);\n });\n }\n return info;\n }\n _mergeHeaders(headers) {\n const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});\n if (this.requestOptions && this.requestOptions.headers) {\n return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));\n }\n return lowercaseKeys(headers || {});\n }\n _getExistingOrDefaultHeader(additionalHeaders, header, _default) {\n const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});\n let clientHeader;\n if (this.requestOptions && this.requestOptions.headers) {\n clientHeader = lowercaseKeys(this.requestOptions.headers)[header];\n }\n return additionalHeaders[header] || clientHeader || _default;\n }\n _getAgent(parsedUrl) {\n let agent;\n let proxyUrl = pm.getProxyUrl(parsedUrl);\n let useProxy = proxyUrl && proxyUrl.hostname;\n if (this._keepAlive && useProxy) {\n agent = this._proxyAgent;\n }\n if (this._keepAlive && !useProxy) {\n agent = this._agent;\n }\n // if agent is already assigned use that agent.\n if (!!agent) {\n return agent;\n }\n const usingSsl = parsedUrl.protocol === 'https:';\n let maxSockets = 100;\n if (!!this.requestOptions) {\n maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;\n }\n if (useProxy) {\n // If using proxy, need tunnel\n if (!tunnel) {\n tunnel = require('tunnel');\n }\n const agentOptions = {\n maxSockets: maxSockets,\n keepAlive: this._keepAlive,\n proxy: {\n ...((proxyUrl.username || proxyUrl.password) && {\n proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`\n }),\n host: proxyUrl.hostname,\n port: proxyUrl.port\n }\n };\n let tunnelAgent;\n const overHttps = proxyUrl.protocol === 'https:';\n if (usingSsl) {\n tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;\n }\n else {\n tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;\n }\n agent = tunnelAgent(agentOptions);\n this._proxyAgent = agent;\n }\n // if reusing agent across request and tunneling agent isn't assigned create a new agent\n if (this._keepAlive && !agent) {\n const options = { keepAlive: this._keepAlive, maxSockets: maxSockets };\n agent = usingSsl ? new https.Agent(options) : new http.Agent(options);\n this._agent = agent;\n }\n // if not using private agent and tunnel agent isn't setup then use global agent\n if (!agent) {\n agent = usingSsl ? https.globalAgent : http.globalAgent;\n }\n if (usingSsl && this._ignoreSslError) {\n // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process\n // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options\n // we have to cast it to any and change it directly\n agent.options = Object.assign(agent.options || {}, {\n rejectUnauthorized: false\n });\n }\n return agent;\n }\n _performExponentialBackoff(retryNumber) {\n retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);\n const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);\n return new Promise(resolve => setTimeout(() => resolve(), ms));\n }\n static dateTimeDeserializer(key, value) {\n if (typeof value === 'string') {\n let a = new Date(value);\n if (!isNaN(a.valueOf())) {\n return a;\n }\n }\n return value;\n }\n async _processResponse(res, options) {\n return new Promise(async (resolve, reject) => {\n const statusCode = res.message.statusCode;\n const response = {\n statusCode: statusCode,\n result: null,\n headers: {}\n };\n // not found leads to null obj returned\n if (statusCode == HttpCodes.NotFound) {\n resolve(response);\n }\n let obj;\n let contents;\n // get the result from the body\n try {\n contents = await res.readBody();\n if (contents && contents.length > 0) {\n if (options && options.deserializeDates) {\n obj = JSON.parse(contents, HttpClient.dateTimeDeserializer);\n }\n else {\n obj = JSON.parse(contents);\n }\n response.result = obj;\n }\n response.headers = res.message.headers;\n }\n catch (err) {\n // Invalid resource (contents not json); leaving result obj null\n }\n // note that 3xx redirects are handled by the http layer.\n if (statusCode > 299) {\n let msg;\n // if exception/error in body, attempt to get better error\n if (obj && obj.message) {\n msg = obj.message;\n }\n else if (contents && contents.length > 0) {\n // it may be the case that the exception is in the body message as string\n msg = contents;\n }\n else {\n msg = 'Failed request: (' + statusCode + ')';\n }\n let err = new HttpClientError(msg, statusCode);\n err.result = response.result;\n reject(err);\n }\n else {\n resolve(response);\n }\n });\n }\n}\nexports.HttpClient = HttpClient;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction getProxyUrl(reqUrl) {\n let usingSsl = reqUrl.protocol === 'https:';\n let proxyUrl;\n if (checkBypass(reqUrl)) {\n return proxyUrl;\n }\n let proxyVar;\n if (usingSsl) {\n proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];\n }\n else {\n proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];\n }\n if (proxyVar) {\n proxyUrl = new URL(proxyVar);\n }\n return proxyUrl;\n}\nexports.getProxyUrl = getProxyUrl;\nfunction checkBypass(reqUrl) {\n if (!reqUrl.hostname) {\n return false;\n }\n let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';\n if (!noProxy) {\n return false;\n }\n // Determine the request port\n let reqPort;\n if (reqUrl.port) {\n reqPort = Number(reqUrl.port);\n }\n else if (reqUrl.protocol === 'http:') {\n reqPort = 80;\n }\n else if (reqUrl.protocol === 'https:') {\n reqPort = 443;\n }\n // Format the request hostname and hostname with port\n let upperReqHosts = [reqUrl.hostname.toUpperCase()];\n if (typeof reqPort === 'number') {\n upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);\n }\n // Compare request host against noproxy\n for (let upperNoProxyItem of noProxy\n .split(',')\n .map(x => x.trim().toUpperCase())\n .filter(x => x)) {\n if (upperReqHosts.some(x => x === upperNoProxyItem)) {\n return true;\n }\n }\n return false;\n}\nexports.checkBypass = checkBypass;\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nasync function auth(token) {\n const tokenType = token.split(/\\./).length === 3 ? \"app\" : /^v\\d+\\./.test(token) ? \"installation\" : \"oauth\";\n return {\n type: \"token\",\n token: token,\n tokenType\n };\n}\n\n/**\n * Prefix token for usage in the Authorization header\n *\n * @param token OAuth token or JSON Web Token\n */\nfunction withAuthorizationPrefix(token) {\n if (token.split(/\\./).length === 3) {\n return `bearer ${token}`;\n }\n\n return `token ${token}`;\n}\n\nasync function hook(token, request, route, parameters) {\n const endpoint = request.endpoint.merge(route, parameters);\n endpoint.headers.authorization = withAuthorizationPrefix(token);\n return request(endpoint);\n}\n\nconst createTokenAuth = function createTokenAuth(token) {\n if (!token) {\n throw new Error(\"[@octokit/auth-token] No token passed to createTokenAuth\");\n }\n\n if (typeof token !== \"string\") {\n throw new Error(\"[@octokit/auth-token] Token passed to createTokenAuth is not a string\");\n }\n\n token = token.replace(/^(token|bearer) +/i, \"\");\n return Object.assign(auth.bind(null, token), {\n hook: hook.bind(null, token)\n });\n};\n\nexports.createTokenAuth = createTokenAuth;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar universalUserAgent = require('universal-user-agent');\nvar beforeAfterHook = require('before-after-hook');\nvar request = require('@octokit/request');\nvar graphql = require('@octokit/graphql');\nvar authToken = require('@octokit/auth-token');\n\nfunction _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n\n return target;\n}\n\nfunction _objectWithoutProperties(source, excluded) {\n if (source == null) return {};\n\n var target = _objectWithoutPropertiesLoose(source, excluded);\n\n var key, i;\n\n if (Object.getOwnPropertySymbols) {\n var sourceSymbolKeys = Object.getOwnPropertySymbols(source);\n\n for (i = 0; i < sourceSymbolKeys.length; i++) {\n key = sourceSymbolKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;\n target[key] = source[key];\n }\n }\n\n return target;\n}\n\nconst VERSION = \"3.4.0\";\n\nclass Octokit {\n constructor(options = {}) {\n const hook = new beforeAfterHook.Collection();\n const requestDefaults = {\n baseUrl: request.request.endpoint.DEFAULTS.baseUrl,\n headers: {},\n request: Object.assign({}, options.request, {\n // @ts-ignore internal usage only, no need to type\n hook: hook.bind(null, \"request\")\n }),\n mediaType: {\n previews: [],\n format: \"\"\n }\n }; // prepend default user agent with `options.userAgent` if set\n\n requestDefaults.headers[\"user-agent\"] = [options.userAgent, `octokit-core.js/${VERSION} ${universalUserAgent.getUserAgent()}`].filter(Boolean).join(\" \");\n\n if (options.baseUrl) {\n requestDefaults.baseUrl = options.baseUrl;\n }\n\n if (options.previews) {\n requestDefaults.mediaType.previews = options.previews;\n }\n\n if (options.timeZone) {\n requestDefaults.headers[\"time-zone\"] = options.timeZone;\n }\n\n this.request = request.request.defaults(requestDefaults);\n this.graphql = graphql.withCustomRequest(this.request).defaults(requestDefaults);\n this.log = Object.assign({\n debug: () => {},\n info: () => {},\n warn: console.warn.bind(console),\n error: console.error.bind(console)\n }, options.log);\n this.hook = hook; // (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance\n // is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered.\n // (2) If only `options.auth` is set, use the default token authentication strategy.\n // (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance.\n // TODO: type `options.auth` based on `options.authStrategy`.\n\n if (!options.authStrategy) {\n if (!options.auth) {\n // (1)\n this.auth = async () => ({\n type: \"unauthenticated\"\n });\n } else {\n // (2)\n const auth = authToken.createTokenAuth(options.auth); // @ts-ignore ¯\\_(ツ)_/¯\n\n hook.wrap(\"request\", auth.hook);\n this.auth = auth;\n }\n } else {\n const {\n authStrategy\n } = options,\n otherOptions = _objectWithoutProperties(options, [\"authStrategy\"]);\n\n const auth = authStrategy(Object.assign({\n request: this.request,\n log: this.log,\n // we pass the current octokit instance as well as its constructor options\n // to allow for authentication strategies that return a new octokit instance\n // that shares the same internal state as the current one. The original\n // requirement for this was the \"event-octokit\" authentication strategy\n // of https://github.com/probot/octokit-auth-probot.\n octokit: this,\n octokitOptions: otherOptions\n }, options.auth)); // @ts-ignore ¯\\_(ツ)_/¯\n\n hook.wrap(\"request\", auth.hook);\n this.auth = auth;\n } // apply plugins\n // https://stackoverflow.com/a/16345172\n\n\n const classConstructor = this.constructor;\n classConstructor.plugins.forEach(plugin => {\n Object.assign(this, plugin(this, options));\n });\n }\n\n static defaults(defaults) {\n const OctokitWithDefaults = class extends this {\n constructor(...args) {\n const options = args[0] || {};\n\n if (typeof defaults === \"function\") {\n super(defaults(options));\n return;\n }\n\n super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent ? {\n userAgent: `${options.userAgent} ${defaults.userAgent}`\n } : null));\n }\n\n };\n return OctokitWithDefaults;\n }\n /**\n * Attach a plugin (or many) to your Octokit instance.\n *\n * @example\n * const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)\n */\n\n\n static plugin(...newPlugins) {\n var _a;\n\n const currentPlugins = this.plugins;\n const NewOctokit = (_a = class extends this {}, _a.plugins = currentPlugins.concat(newPlugins.filter(plugin => !currentPlugins.includes(plugin))), _a);\n return NewOctokit;\n }\n\n}\nOctokit.VERSION = VERSION;\nOctokit.plugins = [];\n\nexports.Octokit = Octokit;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar isPlainObject = require('is-plain-object');\nvar universalUserAgent = require('universal-user-agent');\n\nfunction lowercaseKeys(object) {\n if (!object) {\n return {};\n }\n\n return Object.keys(object).reduce((newObj, key) => {\n newObj[key.toLowerCase()] = object[key];\n return newObj;\n }, {});\n}\n\nfunction mergeDeep(defaults, options) {\n const result = Object.assign({}, defaults);\n Object.keys(options).forEach(key => {\n if (isPlainObject.isPlainObject(options[key])) {\n if (!(key in defaults)) Object.assign(result, {\n [key]: options[key]\n });else result[key] = mergeDeep(defaults[key], options[key]);\n } else {\n Object.assign(result, {\n [key]: options[key]\n });\n }\n });\n return result;\n}\n\nfunction removeUndefinedProperties(obj) {\n for (const key in obj) {\n if (obj[key] === undefined) {\n delete obj[key];\n }\n }\n\n return obj;\n}\n\nfunction merge(defaults, route, options) {\n if (typeof route === \"string\") {\n let [method, url] = route.split(\" \");\n options = Object.assign(url ? {\n method,\n url\n } : {\n url: method\n }, options);\n } else {\n options = Object.assign({}, route);\n } // lowercase header names before merging with defaults to avoid duplicates\n\n\n options.headers = lowercaseKeys(options.headers); // remove properties with undefined values before merging\n\n removeUndefinedProperties(options);\n removeUndefinedProperties(options.headers);\n const mergedOptions = mergeDeep(defaults || {}, options); // mediaType.previews arrays are merged, instead of overwritten\n\n if (defaults && defaults.mediaType.previews.length) {\n mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(preview => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews);\n }\n\n mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map(preview => preview.replace(/-preview/, \"\"));\n return mergedOptions;\n}\n\nfunction addQueryParameters(url, parameters) {\n const separator = /\\?/.test(url) ? \"&\" : \"?\";\n const names = Object.keys(parameters);\n\n if (names.length === 0) {\n return url;\n }\n\n return url + separator + names.map(name => {\n if (name === \"q\") {\n return \"q=\" + parameters.q.split(\"+\").map(encodeURIComponent).join(\"+\");\n }\n\n return `${name}=${encodeURIComponent(parameters[name])}`;\n }).join(\"&\");\n}\n\nconst urlVariableRegex = /\\{[^}]+\\}/g;\n\nfunction removeNonChars(variableName) {\n return variableName.replace(/^\\W+|\\W+$/g, \"\").split(/,/);\n}\n\nfunction extractUrlVariableNames(url) {\n const matches = url.match(urlVariableRegex);\n\n if (!matches) {\n return [];\n }\n\n return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);\n}\n\nfunction omit(object, keysToOmit) {\n return Object.keys(object).filter(option => !keysToOmit.includes(option)).reduce((obj, key) => {\n obj[key] = object[key];\n return obj;\n }, {});\n}\n\n// Based on https://github.com/bramstein/url-template, licensed under BSD\n// TODO: create separate package.\n//\n// Copyright (c) 2012-2014, Bram Stein\n// All rights reserved.\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions\n// are met:\n// 1. Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n// 3. The name of the author may not be used to endorse or promote products\n// derived from this software without specific prior written permission.\n// THIS SOFTWARE IS PROVIDED BY THE AUTHOR \"AS IS\" AND ANY EXPRESS OR IMPLIED\n// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n/* istanbul ignore file */\nfunction encodeReserved(str) {\n return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) {\n if (!/%[0-9A-Fa-f]/.test(part)) {\n part = encodeURI(part).replace(/%5B/g, \"[\").replace(/%5D/g, \"]\");\n }\n\n return part;\n }).join(\"\");\n}\n\nfunction encodeUnreserved(str) {\n return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {\n return \"%\" + c.charCodeAt(0).toString(16).toUpperCase();\n });\n}\n\nfunction encodeValue(operator, value, key) {\n value = operator === \"+\" || operator === \"#\" ? encodeReserved(value) : encodeUnreserved(value);\n\n if (key) {\n return encodeUnreserved(key) + \"=\" + value;\n } else {\n return value;\n }\n}\n\nfunction isDefined(value) {\n return value !== undefined && value !== null;\n}\n\nfunction isKeyOperator(operator) {\n return operator === \";\" || operator === \"&\" || operator === \"?\";\n}\n\nfunction getValues(context, operator, key, modifier) {\n var value = context[key],\n result = [];\n\n if (isDefined(value) && value !== \"\") {\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n value = value.toString();\n\n if (modifier && modifier !== \"*\") {\n value = value.substring(0, parseInt(modifier, 10));\n }\n\n result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : \"\"));\n } else {\n if (modifier === \"*\") {\n if (Array.isArray(value)) {\n value.filter(isDefined).forEach(function (value) {\n result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : \"\"));\n });\n } else {\n Object.keys(value).forEach(function (k) {\n if (isDefined(value[k])) {\n result.push(encodeValue(operator, value[k], k));\n }\n });\n }\n } else {\n const tmp = [];\n\n if (Array.isArray(value)) {\n value.filter(isDefined).forEach(function (value) {\n tmp.push(encodeValue(operator, value));\n });\n } else {\n Object.keys(value).forEach(function (k) {\n if (isDefined(value[k])) {\n tmp.push(encodeUnreserved(k));\n tmp.push(encodeValue(operator, value[k].toString()));\n }\n });\n }\n\n if (isKeyOperator(operator)) {\n result.push(encodeUnreserved(key) + \"=\" + tmp.join(\",\"));\n } else if (tmp.length !== 0) {\n result.push(tmp.join(\",\"));\n }\n }\n }\n } else {\n if (operator === \";\") {\n if (isDefined(value)) {\n result.push(encodeUnreserved(key));\n }\n } else if (value === \"\" && (operator === \"&\" || operator === \"?\")) {\n result.push(encodeUnreserved(key) + \"=\");\n } else if (value === \"\") {\n result.push(\"\");\n }\n }\n\n return result;\n}\n\nfunction parseUrl(template) {\n return {\n expand: expand.bind(null, template)\n };\n}\n\nfunction expand(template, context) {\n var operators = [\"+\", \"#\", \".\", \"/\", \";\", \"?\", \"&\"];\n return template.replace(/\\{([^\\{\\}]+)\\}|([^\\{\\}]+)/g, function (_, expression, literal) {\n if (expression) {\n let operator = \"\";\n const values = [];\n\n if (operators.indexOf(expression.charAt(0)) !== -1) {\n operator = expression.charAt(0);\n expression = expression.substr(1);\n }\n\n expression.split(/,/g).forEach(function (variable) {\n var tmp = /([^:\\*]*)(?::(\\d+)|(\\*))?/.exec(variable);\n values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));\n });\n\n if (operator && operator !== \"+\") {\n var separator = \",\";\n\n if (operator === \"?\") {\n separator = \"&\";\n } else if (operator !== \"#\") {\n separator = operator;\n }\n\n return (values.length !== 0 ? operator : \"\") + values.join(separator);\n } else {\n return values.join(\",\");\n }\n } else {\n return encodeReserved(literal);\n }\n });\n}\n\nfunction parse(options) {\n // https://fetch.spec.whatwg.org/#methods\n let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible\n\n let url = (options.url || \"/\").replace(/:([a-z]\\w+)/g, \"{$1}\");\n let headers = Object.assign({}, options.headers);\n let body;\n let parameters = omit(options, [\"method\", \"baseUrl\", \"url\", \"headers\", \"request\", \"mediaType\"]); // extract variable names from URL to calculate remaining variables later\n\n const urlVariableNames = extractUrlVariableNames(url);\n url = parseUrl(url).expand(parameters);\n\n if (!/^http/.test(url)) {\n url = options.baseUrl + url;\n }\n\n const omittedParameters = Object.keys(options).filter(option => urlVariableNames.includes(option)).concat(\"baseUrl\");\n const remainingParameters = omit(parameters, omittedParameters);\n const isBinaryRequest = /application\\/octet-stream/i.test(headers.accept);\n\n if (!isBinaryRequest) {\n if (options.mediaType.format) {\n // e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw\n headers.accept = headers.accept.split(/,/).map(preview => preview.replace(/application\\/vnd(\\.\\w+)(\\.v3)?(\\.\\w+)?(\\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)).join(\",\");\n }\n\n if (options.mediaType.previews.length) {\n const previewsFromAcceptHeader = headers.accept.match(/[\\w-]+(?=-preview)/g) || [];\n headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map(preview => {\n const format = options.mediaType.format ? `.${options.mediaType.format}` : \"+json\";\n return `application/vnd.github.${preview}-preview${format}`;\n }).join(\",\");\n }\n } // for GET/HEAD requests, set URL query parameters from remaining parameters\n // for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters\n\n\n if ([\"GET\", \"HEAD\"].includes(method)) {\n url = addQueryParameters(url, remainingParameters);\n } else {\n if (\"data\" in remainingParameters) {\n body = remainingParameters.data;\n } else {\n if (Object.keys(remainingParameters).length) {\n body = remainingParameters;\n } else {\n headers[\"content-length\"] = 0;\n }\n }\n } // default content-type for JSON if body is set\n\n\n if (!headers[\"content-type\"] && typeof body !== \"undefined\") {\n headers[\"content-type\"] = \"application/json; charset=utf-8\";\n } // GitHub expects 'content-length: 0' header for PUT/PATCH requests without body.\n // fetch does not allow to set `content-length` header, but we can set body to an empty string\n\n\n if ([\"PATCH\", \"PUT\"].includes(method) && typeof body === \"undefined\") {\n body = \"\";\n } // Only return body/request keys if present\n\n\n return Object.assign({\n method,\n url,\n headers\n }, typeof body !== \"undefined\" ? {\n body\n } : null, options.request ? {\n request: options.request\n } : null);\n}\n\nfunction endpointWithDefaults(defaults, route, options) {\n return parse(merge(defaults, route, options));\n}\n\nfunction withDefaults(oldDefaults, newDefaults) {\n const DEFAULTS = merge(oldDefaults, newDefaults);\n const endpoint = endpointWithDefaults.bind(null, DEFAULTS);\n return Object.assign(endpoint, {\n DEFAULTS,\n defaults: withDefaults.bind(null, DEFAULTS),\n merge: merge.bind(null, DEFAULTS),\n parse\n });\n}\n\nconst VERSION = \"6.0.11\";\n\nconst userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}`; // DEFAULTS has all properties set that EndpointOptions has, except url.\n// So we use RequestParameters and add method as additional required property.\n\nconst DEFAULTS = {\n method: \"GET\",\n baseUrl: \"https://api.github.com\",\n headers: {\n accept: \"application/vnd.github.v3+json\",\n \"user-agent\": userAgent\n },\n mediaType: {\n format: \"\",\n previews: []\n }\n};\n\nconst endpoint = withDefaults(null, DEFAULTS);\n\nexports.endpoint = endpoint;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar request = require('@octokit/request');\nvar universalUserAgent = require('universal-user-agent');\n\nconst VERSION = \"4.6.2\";\n\nclass GraphqlError extends Error {\n constructor(request, response) {\n const message = response.data.errors[0].message;\n super(message);\n Object.assign(this, response.data);\n Object.assign(this, {\n headers: response.headers\n });\n this.name = \"GraphqlError\";\n this.request = request; // Maintains proper stack trace (only available on V8)\n\n /* istanbul ignore next */\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n\n}\n\nconst NON_VARIABLE_OPTIONS = [\"method\", \"baseUrl\", \"url\", \"headers\", \"request\", \"query\", \"mediaType\"];\nconst FORBIDDEN_VARIABLE_OPTIONS = [\"query\", \"method\", \"url\"];\nconst GHES_V3_SUFFIX_REGEX = /\\/api\\/v3\\/?$/;\nfunction graphql(request, query, options) {\n if (options) {\n if (typeof query === \"string\" && \"query\" in options) {\n return Promise.reject(new Error(`[@octokit/graphql] \"query\" cannot be used as variable name`));\n }\n\n for (const key in options) {\n if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) continue;\n return Promise.reject(new Error(`[@octokit/graphql] \"${key}\" cannot be used as variable name`));\n }\n }\n\n const parsedOptions = typeof query === \"string\" ? Object.assign({\n query\n }, options) : query;\n const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {\n if (NON_VARIABLE_OPTIONS.includes(key)) {\n result[key] = parsedOptions[key];\n return result;\n }\n\n if (!result.variables) {\n result.variables = {};\n }\n\n result.variables[key] = parsedOptions[key];\n return result;\n }, {}); // workaround for GitHub Enterprise baseUrl set with /api/v3 suffix\n // https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451\n\n const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;\n\n if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {\n requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, \"/api/graphql\");\n }\n\n return request(requestOptions).then(response => {\n if (response.data.errors) {\n const headers = {};\n\n for (const key of Object.keys(response.headers)) {\n headers[key] = response.headers[key];\n }\n\n throw new GraphqlError(requestOptions, {\n headers,\n data: response.data\n });\n }\n\n return response.data.data;\n });\n}\n\nfunction withDefaults(request$1, newDefaults) {\n const newRequest = request$1.defaults(newDefaults);\n\n const newApi = (query, options) => {\n return graphql(newRequest, query, options);\n };\n\n return Object.assign(newApi, {\n defaults: withDefaults.bind(null, newRequest),\n endpoint: request.request.endpoint\n });\n}\n\nconst graphql$1 = withDefaults(request.request, {\n headers: {\n \"user-agent\": `octokit-graphql.js/${VERSION} ${universalUserAgent.getUserAgent()}`\n },\n method: \"POST\",\n url: \"/graphql\"\n});\nfunction withCustomRequest(customRequest) {\n return withDefaults(customRequest, {\n method: \"POST\",\n url: \"/graphql\"\n });\n}\n\nexports.graphql = graphql$1;\nexports.withCustomRequest = withCustomRequest;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst VERSION = \"2.13.3\";\n\n/**\n * Some “list” response that can be paginated have a different response structure\n *\n * They have a `total_count` key in the response (search also has `incomplete_results`,\n * /installation/repositories also has `repository_selection`), as well as a key with\n * the list of the items which name varies from endpoint to endpoint.\n *\n * Octokit normalizes these responses so that paginated results are always returned following\n * the same structure. One challenge is that if the list response has only one page, no Link\n * header is provided, so this header alone is not sufficient to check wether a response is\n * paginated or not.\n *\n * We check if a \"total_count\" key is present in the response data, but also make sure that\n * a \"url\" property is not, as the \"Get the combined status for a specific ref\" endpoint would\n * otherwise match: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref\n */\nfunction normalizePaginatedListResponse(response) {\n const responseNeedsNormalization = \"total_count\" in response.data && !(\"url\" in response.data);\n if (!responseNeedsNormalization) return response; // keep the additional properties intact as there is currently no other way\n // to retrieve the same information.\n\n const incompleteResults = response.data.incomplete_results;\n const repositorySelection = response.data.repository_selection;\n const totalCount = response.data.total_count;\n delete response.data.incomplete_results;\n delete response.data.repository_selection;\n delete response.data.total_count;\n const namespaceKey = Object.keys(response.data)[0];\n const data = response.data[namespaceKey];\n response.data = data;\n\n if (typeof incompleteResults !== \"undefined\") {\n response.data.incomplete_results = incompleteResults;\n }\n\n if (typeof repositorySelection !== \"undefined\") {\n response.data.repository_selection = repositorySelection;\n }\n\n response.data.total_count = totalCount;\n return response;\n}\n\nfunction iterator(octokit, route, parameters) {\n const options = typeof route === \"function\" ? route.endpoint(parameters) : octokit.request.endpoint(route, parameters);\n const requestMethod = typeof route === \"function\" ? route : octokit.request;\n const method = options.method;\n const headers = options.headers;\n let url = options.url;\n return {\n [Symbol.asyncIterator]: () => ({\n async next() {\n if (!url) return {\n done: true\n };\n const response = await requestMethod({\n method,\n url,\n headers\n });\n const normalizedResponse = normalizePaginatedListResponse(response); // `response.headers.link` format:\n // '; rel=\"next\", ; rel=\"last\"'\n // sets `url` to undefined if \"next\" URL is not present or `link` header is not set\n\n url = ((normalizedResponse.headers.link || \"\").match(/<([^>]+)>;\\s*rel=\"next\"/) || [])[1];\n return {\n value: normalizedResponse\n };\n }\n\n })\n };\n}\n\nfunction paginate(octokit, route, parameters, mapFn) {\n if (typeof parameters === \"function\") {\n mapFn = parameters;\n parameters = undefined;\n }\n\n return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn);\n}\n\nfunction gather(octokit, results, iterator, mapFn) {\n return iterator.next().then(result => {\n if (result.done) {\n return results;\n }\n\n let earlyExit = false;\n\n function done() {\n earlyExit = true;\n }\n\n results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data);\n\n if (earlyExit) {\n return results;\n }\n\n return gather(octokit, results, iterator, mapFn);\n });\n}\n\nconst composePaginateRest = Object.assign(paginate, {\n iterator\n});\n\nconst paginatingEndpoints = [\"GET /app/installations\", \"GET /applications/grants\", \"GET /authorizations\", \"GET /enterprises/{enterprise}/actions/permissions/organizations\", \"GET /enterprises/{enterprise}/actions/runner-groups\", \"GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations\", \"GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners\", \"GET /enterprises/{enterprise}/actions/runners\", \"GET /enterprises/{enterprise}/actions/runners/downloads\", \"GET /events\", \"GET /gists\", \"GET /gists/public\", \"GET /gists/starred\", \"GET /gists/{gist_id}/comments\", \"GET /gists/{gist_id}/commits\", \"GET /gists/{gist_id}/forks\", \"GET /installation/repositories\", \"GET /issues\", \"GET /marketplace_listing/plans\", \"GET /marketplace_listing/plans/{plan_id}/accounts\", \"GET /marketplace_listing/stubbed/plans\", \"GET /marketplace_listing/stubbed/plans/{plan_id}/accounts\", \"GET /networks/{owner}/{repo}/events\", \"GET /notifications\", \"GET /organizations\", \"GET /orgs/{org}/actions/permissions/repositories\", \"GET /orgs/{org}/actions/runner-groups\", \"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories\", \"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/runners\", \"GET /orgs/{org}/actions/runners\", \"GET /orgs/{org}/actions/runners/downloads\", \"GET /orgs/{org}/actions/secrets\", \"GET /orgs/{org}/actions/secrets/{secret_name}/repositories\", \"GET /orgs/{org}/blocks\", \"GET /orgs/{org}/credential-authorizations\", \"GET /orgs/{org}/events\", \"GET /orgs/{org}/failed_invitations\", \"GET /orgs/{org}/hooks\", \"GET /orgs/{org}/installations\", \"GET /orgs/{org}/invitations\", \"GET /orgs/{org}/invitations/{invitation_id}/teams\", \"GET /orgs/{org}/issues\", \"GET /orgs/{org}/members\", \"GET /orgs/{org}/migrations\", \"GET /orgs/{org}/migrations/{migration_id}/repositories\", \"GET /orgs/{org}/outside_collaborators\", \"GET /orgs/{org}/projects\", \"GET /orgs/{org}/public_members\", \"GET /orgs/{org}/repos\", \"GET /orgs/{org}/team-sync/groups\", \"GET /orgs/{org}/teams\", \"GET /orgs/{org}/teams/{team_slug}/discussions\", \"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments\", \"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions\", \"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions\", \"GET /orgs/{org}/teams/{team_slug}/invitations\", \"GET /orgs/{org}/teams/{team_slug}/members\", \"GET /orgs/{org}/teams/{team_slug}/projects\", \"GET /orgs/{org}/teams/{team_slug}/repos\", \"GET /orgs/{org}/teams/{team_slug}/team-sync/group-mappings\", \"GET /orgs/{org}/teams/{team_slug}/teams\", \"GET /projects/columns/{column_id}/cards\", \"GET /projects/{project_id}/collaborators\", \"GET /projects/{project_id}/columns\", \"GET /repos/{owner}/{repo}/actions/artifacts\", \"GET /repos/{owner}/{repo}/actions/runners\", \"GET /repos/{owner}/{repo}/actions/runners/downloads\", \"GET /repos/{owner}/{repo}/actions/runs\", \"GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts\", \"GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs\", \"GET /repos/{owner}/{repo}/actions/secrets\", \"GET /repos/{owner}/{repo}/actions/workflows\", \"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs\", \"GET /repos/{owner}/{repo}/assignees\", \"GET /repos/{owner}/{repo}/branches\", \"GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations\", \"GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs\", \"GET /repos/{owner}/{repo}/code-scanning/alerts\", \"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances\", \"GET /repos/{owner}/{repo}/code-scanning/analyses\", \"GET /repos/{owner}/{repo}/collaborators\", \"GET /repos/{owner}/{repo}/comments\", \"GET /repos/{owner}/{repo}/comments/{comment_id}/reactions\", \"GET /repos/{owner}/{repo}/commits\", \"GET /repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head\", \"GET /repos/{owner}/{repo}/commits/{commit_sha}/comments\", \"GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls\", \"GET /repos/{owner}/{repo}/commits/{ref}/check-runs\", \"GET /repos/{owner}/{repo}/commits/{ref}/check-suites\", \"GET /repos/{owner}/{repo}/commits/{ref}/statuses\", \"GET /repos/{owner}/{repo}/contributors\", \"GET /repos/{owner}/{repo}/deployments\", \"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses\", \"GET /repos/{owner}/{repo}/events\", \"GET /repos/{owner}/{repo}/forks\", \"GET /repos/{owner}/{repo}/git/matching-refs/{ref}\", \"GET /repos/{owner}/{repo}/hooks\", \"GET /repos/{owner}/{repo}/invitations\", \"GET /repos/{owner}/{repo}/issues\", \"GET /repos/{owner}/{repo}/issues/comments\", \"GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions\", \"GET /repos/{owner}/{repo}/issues/events\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/comments\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/events\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/labels\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/reactions\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/timeline\", \"GET /repos/{owner}/{repo}/keys\", \"GET /repos/{owner}/{repo}/labels\", \"GET /repos/{owner}/{repo}/milestones\", \"GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels\", \"GET /repos/{owner}/{repo}/notifications\", \"GET /repos/{owner}/{repo}/pages/builds\", \"GET /repos/{owner}/{repo}/projects\", \"GET /repos/{owner}/{repo}/pulls\", \"GET /repos/{owner}/{repo}/pulls/comments\", \"GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/comments\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/commits\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/files\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments\", \"GET /repos/{owner}/{repo}/releases\", \"GET /repos/{owner}/{repo}/releases/{release_id}/assets\", \"GET /repos/{owner}/{repo}/secret-scanning/alerts\", \"GET /repos/{owner}/{repo}/stargazers\", \"GET /repos/{owner}/{repo}/subscribers\", \"GET /repos/{owner}/{repo}/tags\", \"GET /repos/{owner}/{repo}/teams\", \"GET /repositories\", \"GET /repositories/{repository_id}/environments/{environment_name}/secrets\", \"GET /scim/v2/enterprises/{enterprise}/Groups\", \"GET /scim/v2/enterprises/{enterprise}/Users\", \"GET /scim/v2/organizations/{org}/Users\", \"GET /search/code\", \"GET /search/commits\", \"GET /search/issues\", \"GET /search/labels\", \"GET /search/repositories\", \"GET /search/topics\", \"GET /search/users\", \"GET /teams/{team_id}/discussions\", \"GET /teams/{team_id}/discussions/{discussion_number}/comments\", \"GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions\", \"GET /teams/{team_id}/discussions/{discussion_number}/reactions\", \"GET /teams/{team_id}/invitations\", \"GET /teams/{team_id}/members\", \"GET /teams/{team_id}/projects\", \"GET /teams/{team_id}/repos\", \"GET /teams/{team_id}/team-sync/group-mappings\", \"GET /teams/{team_id}/teams\", \"GET /user/blocks\", \"GET /user/emails\", \"GET /user/followers\", \"GET /user/following\", \"GET /user/gpg_keys\", \"GET /user/installations\", \"GET /user/installations/{installation_id}/repositories\", \"GET /user/issues\", \"GET /user/keys\", \"GET /user/marketplace_purchases\", \"GET /user/marketplace_purchases/stubbed\", \"GET /user/memberships/orgs\", \"GET /user/migrations\", \"GET /user/migrations/{migration_id}/repositories\", \"GET /user/orgs\", \"GET /user/public_emails\", \"GET /user/repos\", \"GET /user/repository_invitations\", \"GET /user/starred\", \"GET /user/subscriptions\", \"GET /user/teams\", \"GET /users\", \"GET /users/{username}/events\", \"GET /users/{username}/events/orgs/{org}\", \"GET /users/{username}/events/public\", \"GET /users/{username}/followers\", \"GET /users/{username}/following\", \"GET /users/{username}/gists\", \"GET /users/{username}/gpg_keys\", \"GET /users/{username}/keys\", \"GET /users/{username}/orgs\", \"GET /users/{username}/projects\", \"GET /users/{username}/received_events\", \"GET /users/{username}/received_events/public\", \"GET /users/{username}/repos\", \"GET /users/{username}/starred\", \"GET /users/{username}/subscriptions\"];\n\nfunction isPaginatingEndpoint(arg) {\n if (typeof arg === \"string\") {\n return paginatingEndpoints.includes(arg);\n } else {\n return false;\n }\n}\n\n/**\n * @param octokit Octokit instance\n * @param options Options passed to Octokit constructor\n */\n\nfunction paginateRest(octokit) {\n return {\n paginate: Object.assign(paginate.bind(null, octokit), {\n iterator: iterator.bind(null, octokit)\n })\n };\n}\npaginateRest.VERSION = VERSION;\n\nexports.composePaginateRest = composePaginateRest;\nexports.isPaginatingEndpoint = isPaginatingEndpoint;\nexports.paginateRest = paginateRest;\nexports.paginatingEndpoints = paginatingEndpoints;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction ownKeys(object, enumerableOnly) {\n var keys = Object.keys(object);\n\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(object);\n\n if (enumerableOnly) {\n symbols = symbols.filter(function (sym) {\n return Object.getOwnPropertyDescriptor(object, sym).enumerable;\n });\n }\n\n keys.push.apply(keys, symbols);\n }\n\n return keys;\n}\n\nfunction _objectSpread2(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n\n if (i % 2) {\n ownKeys(Object(source), true).forEach(function (key) {\n _defineProperty(target, key, source[key]);\n });\n } else if (Object.getOwnPropertyDescriptors) {\n Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));\n } else {\n ownKeys(Object(source)).forEach(function (key) {\n Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));\n });\n }\n }\n\n return target;\n}\n\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nconst Endpoints = {\n actions: {\n addSelectedRepoToOrgSecret: [\"PUT /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}\"],\n approveWorkflowRun: [\"POST /repos/{owner}/{repo}/actions/runs/{run_id}/approve\"],\n cancelWorkflowRun: [\"POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel\"],\n createOrUpdateEnvironmentSecret: [\"PUT /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}\"],\n createOrUpdateOrgSecret: [\"PUT /orgs/{org}/actions/secrets/{secret_name}\"],\n createOrUpdateRepoSecret: [\"PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}\"],\n createRegistrationTokenForOrg: [\"POST /orgs/{org}/actions/runners/registration-token\"],\n createRegistrationTokenForRepo: [\"POST /repos/{owner}/{repo}/actions/runners/registration-token\"],\n createRemoveTokenForOrg: [\"POST /orgs/{org}/actions/runners/remove-token\"],\n createRemoveTokenForRepo: [\"POST /repos/{owner}/{repo}/actions/runners/remove-token\"],\n createWorkflowDispatch: [\"POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches\"],\n deleteArtifact: [\"DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id}\"],\n deleteEnvironmentSecret: [\"DELETE /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}\"],\n deleteOrgSecret: [\"DELETE /orgs/{org}/actions/secrets/{secret_name}\"],\n deleteRepoSecret: [\"DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name}\"],\n deleteSelfHostedRunnerFromOrg: [\"DELETE /orgs/{org}/actions/runners/{runner_id}\"],\n deleteSelfHostedRunnerFromRepo: [\"DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}\"],\n deleteWorkflowRun: [\"DELETE /repos/{owner}/{repo}/actions/runs/{run_id}\"],\n deleteWorkflowRunLogs: [\"DELETE /repos/{owner}/{repo}/actions/runs/{run_id}/logs\"],\n disableSelectedRepositoryGithubActionsOrganization: [\"DELETE /orgs/{org}/actions/permissions/repositories/{repository_id}\"],\n disableWorkflow: [\"PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable\"],\n downloadArtifact: [\"GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}\"],\n downloadJobLogsForWorkflowRun: [\"GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs\"],\n downloadWorkflowRunLogs: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs\"],\n enableSelectedRepositoryGithubActionsOrganization: [\"PUT /orgs/{org}/actions/permissions/repositories/{repository_id}\"],\n enableWorkflow: [\"PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable\"],\n getAllowedActionsOrganization: [\"GET /orgs/{org}/actions/permissions/selected-actions\"],\n getAllowedActionsRepository: [\"GET /repos/{owner}/{repo}/actions/permissions/selected-actions\"],\n getArtifact: [\"GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}\"],\n getEnvironmentPublicKey: [\"GET /repositories/{repository_id}/environments/{environment_name}/secrets/public-key\"],\n getEnvironmentSecret: [\"GET /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}\"],\n getGithubActionsPermissionsOrganization: [\"GET /orgs/{org}/actions/permissions\"],\n getGithubActionsPermissionsRepository: [\"GET /repos/{owner}/{repo}/actions/permissions\"],\n getJobForWorkflowRun: [\"GET /repos/{owner}/{repo}/actions/jobs/{job_id}\"],\n getOrgPublicKey: [\"GET /orgs/{org}/actions/secrets/public-key\"],\n getOrgSecret: [\"GET /orgs/{org}/actions/secrets/{secret_name}\"],\n getPendingDeploymentsForRun: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments\"],\n getRepoPermissions: [\"GET /repos/{owner}/{repo}/actions/permissions\", {}, {\n renamed: [\"actions\", \"getGithubActionsPermissionsRepository\"]\n }],\n getRepoPublicKey: [\"GET /repos/{owner}/{repo}/actions/secrets/public-key\"],\n getRepoSecret: [\"GET /repos/{owner}/{repo}/actions/secrets/{secret_name}\"],\n getReviewsForRun: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/approvals\"],\n getSelfHostedRunnerForOrg: [\"GET /orgs/{org}/actions/runners/{runner_id}\"],\n getSelfHostedRunnerForRepo: [\"GET /repos/{owner}/{repo}/actions/runners/{runner_id}\"],\n getWorkflow: [\"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}\"],\n getWorkflowRun: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}\"],\n getWorkflowRunUsage: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing\"],\n getWorkflowUsage: [\"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing\"],\n listArtifactsForRepo: [\"GET /repos/{owner}/{repo}/actions/artifacts\"],\n listEnvironmentSecrets: [\"GET /repositories/{repository_id}/environments/{environment_name}/secrets\"],\n listJobsForWorkflowRun: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs\"],\n listOrgSecrets: [\"GET /orgs/{org}/actions/secrets\"],\n listRepoSecrets: [\"GET /repos/{owner}/{repo}/actions/secrets\"],\n listRepoWorkflows: [\"GET /repos/{owner}/{repo}/actions/workflows\"],\n listRunnerApplicationsForOrg: [\"GET /orgs/{org}/actions/runners/downloads\"],\n listRunnerApplicationsForRepo: [\"GET /repos/{owner}/{repo}/actions/runners/downloads\"],\n listSelectedReposForOrgSecret: [\"GET /orgs/{org}/actions/secrets/{secret_name}/repositories\"],\n listSelectedRepositoriesEnabledGithubActionsOrganization: [\"GET /orgs/{org}/actions/permissions/repositories\"],\n listSelfHostedRunnersForOrg: [\"GET /orgs/{org}/actions/runners\"],\n listSelfHostedRunnersForRepo: [\"GET /repos/{owner}/{repo}/actions/runners\"],\n listWorkflowRunArtifacts: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts\"],\n listWorkflowRuns: [\"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs\"],\n listWorkflowRunsForRepo: [\"GET /repos/{owner}/{repo}/actions/runs\"],\n reRunWorkflow: [\"POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun\"],\n removeSelectedRepoFromOrgSecret: [\"DELETE /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}\"],\n reviewPendingDeploymentsForRun: [\"POST /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments\"],\n setAllowedActionsOrganization: [\"PUT /orgs/{org}/actions/permissions/selected-actions\"],\n setAllowedActionsRepository: [\"PUT /repos/{owner}/{repo}/actions/permissions/selected-actions\"],\n setGithubActionsPermissionsOrganization: [\"PUT /orgs/{org}/actions/permissions\"],\n setGithubActionsPermissionsRepository: [\"PUT /repos/{owner}/{repo}/actions/permissions\"],\n setSelectedReposForOrgSecret: [\"PUT /orgs/{org}/actions/secrets/{secret_name}/repositories\"],\n setSelectedRepositoriesEnabledGithubActionsOrganization: [\"PUT /orgs/{org}/actions/permissions/repositories\"]\n },\n activity: {\n checkRepoIsStarredByAuthenticatedUser: [\"GET /user/starred/{owner}/{repo}\"],\n deleteRepoSubscription: [\"DELETE /repos/{owner}/{repo}/subscription\"],\n deleteThreadSubscription: [\"DELETE /notifications/threads/{thread_id}/subscription\"],\n getFeeds: [\"GET /feeds\"],\n getRepoSubscription: [\"GET /repos/{owner}/{repo}/subscription\"],\n getThread: [\"GET /notifications/threads/{thread_id}\"],\n getThreadSubscriptionForAuthenticatedUser: [\"GET /notifications/threads/{thread_id}/subscription\"],\n listEventsForAuthenticatedUser: [\"GET /users/{username}/events\"],\n listNotificationsForAuthenticatedUser: [\"GET /notifications\"],\n listOrgEventsForAuthenticatedUser: [\"GET /users/{username}/events/orgs/{org}\"],\n listPublicEvents: [\"GET /events\"],\n listPublicEventsForRepoNetwork: [\"GET /networks/{owner}/{repo}/events\"],\n listPublicEventsForUser: [\"GET /users/{username}/events/public\"],\n listPublicOrgEvents: [\"GET /orgs/{org}/events\"],\n listReceivedEventsForUser: [\"GET /users/{username}/received_events\"],\n listReceivedPublicEventsForUser: [\"GET /users/{username}/received_events/public\"],\n listRepoEvents: [\"GET /repos/{owner}/{repo}/events\"],\n listRepoNotificationsForAuthenticatedUser: [\"GET /repos/{owner}/{repo}/notifications\"],\n listReposStarredByAuthenticatedUser: [\"GET /user/starred\"],\n listReposStarredByUser: [\"GET /users/{username}/starred\"],\n listReposWatchedByUser: [\"GET /users/{username}/subscriptions\"],\n listStargazersForRepo: [\"GET /repos/{owner}/{repo}/stargazers\"],\n listWatchedReposForAuthenticatedUser: [\"GET /user/subscriptions\"],\n listWatchersForRepo: [\"GET /repos/{owner}/{repo}/subscribers\"],\n markNotificationsAsRead: [\"PUT /notifications\"],\n markRepoNotificationsAsRead: [\"PUT /repos/{owner}/{repo}/notifications\"],\n markThreadAsRead: [\"PATCH /notifications/threads/{thread_id}\"],\n setRepoSubscription: [\"PUT /repos/{owner}/{repo}/subscription\"],\n setThreadSubscription: [\"PUT /notifications/threads/{thread_id}/subscription\"],\n starRepoForAuthenticatedUser: [\"PUT /user/starred/{owner}/{repo}\"],\n unstarRepoForAuthenticatedUser: [\"DELETE /user/starred/{owner}/{repo}\"]\n },\n apps: {\n addRepoToInstallation: [\"PUT /user/installations/{installation_id}/repositories/{repository_id}\"],\n checkToken: [\"POST /applications/{client_id}/token\"],\n createContentAttachment: [\"POST /content_references/{content_reference_id}/attachments\", {\n mediaType: {\n previews: [\"corsair\"]\n }\n }],\n createContentAttachmentForRepo: [\"POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments\", {\n mediaType: {\n previews: [\"corsair\"]\n }\n }],\n createFromManifest: [\"POST /app-manifests/{code}/conversions\"],\n createInstallationAccessToken: [\"POST /app/installations/{installation_id}/access_tokens\"],\n deleteAuthorization: [\"DELETE /applications/{client_id}/grant\"],\n deleteInstallation: [\"DELETE /app/installations/{installation_id}\"],\n deleteToken: [\"DELETE /applications/{client_id}/token\"],\n getAuthenticated: [\"GET /app\"],\n getBySlug: [\"GET /apps/{app_slug}\"],\n getInstallation: [\"GET /app/installations/{installation_id}\"],\n getOrgInstallation: [\"GET /orgs/{org}/installation\"],\n getRepoInstallation: [\"GET /repos/{owner}/{repo}/installation\"],\n getSubscriptionPlanForAccount: [\"GET /marketplace_listing/accounts/{account_id}\"],\n getSubscriptionPlanForAccountStubbed: [\"GET /marketplace_listing/stubbed/accounts/{account_id}\"],\n getUserInstallation: [\"GET /users/{username}/installation\"],\n getWebhookConfigForApp: [\"GET /app/hook/config\"],\n listAccountsForPlan: [\"GET /marketplace_listing/plans/{plan_id}/accounts\"],\n listAccountsForPlanStubbed: [\"GET /marketplace_listing/stubbed/plans/{plan_id}/accounts\"],\n listInstallationReposForAuthenticatedUser: [\"GET /user/installations/{installation_id}/repositories\"],\n listInstallations: [\"GET /app/installations\"],\n listInstallationsForAuthenticatedUser: [\"GET /user/installations\"],\n listPlans: [\"GET /marketplace_listing/plans\"],\n listPlansStubbed: [\"GET /marketplace_listing/stubbed/plans\"],\n listReposAccessibleToInstallation: [\"GET /installation/repositories\"],\n listSubscriptionsForAuthenticatedUser: [\"GET /user/marketplace_purchases\"],\n listSubscriptionsForAuthenticatedUserStubbed: [\"GET /user/marketplace_purchases/stubbed\"],\n removeRepoFromInstallation: [\"DELETE /user/installations/{installation_id}/repositories/{repository_id}\"],\n resetToken: [\"PATCH /applications/{client_id}/token\"],\n revokeInstallationAccessToken: [\"DELETE /installation/token\"],\n scopeToken: [\"POST /applications/{client_id}/token/scoped\"],\n suspendInstallation: [\"PUT /app/installations/{installation_id}/suspended\"],\n unsuspendInstallation: [\"DELETE /app/installations/{installation_id}/suspended\"],\n updateWebhookConfigForApp: [\"PATCH /app/hook/config\"]\n },\n billing: {\n getGithubActionsBillingOrg: [\"GET /orgs/{org}/settings/billing/actions\"],\n getGithubActionsBillingUser: [\"GET /users/{username}/settings/billing/actions\"],\n getGithubPackagesBillingOrg: [\"GET /orgs/{org}/settings/billing/packages\"],\n getGithubPackagesBillingUser: [\"GET /users/{username}/settings/billing/packages\"],\n getSharedStorageBillingOrg: [\"GET /orgs/{org}/settings/billing/shared-storage\"],\n getSharedStorageBillingUser: [\"GET /users/{username}/settings/billing/shared-storage\"]\n },\n checks: {\n create: [\"POST /repos/{owner}/{repo}/check-runs\"],\n createSuite: [\"POST /repos/{owner}/{repo}/check-suites\"],\n get: [\"GET /repos/{owner}/{repo}/check-runs/{check_run_id}\"],\n getSuite: [\"GET /repos/{owner}/{repo}/check-suites/{check_suite_id}\"],\n listAnnotations: [\"GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations\"],\n listForRef: [\"GET /repos/{owner}/{repo}/commits/{ref}/check-runs\"],\n listForSuite: [\"GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs\"],\n listSuitesForRef: [\"GET /repos/{owner}/{repo}/commits/{ref}/check-suites\"],\n rerequestSuite: [\"POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest\"],\n setSuitesPreferences: [\"PATCH /repos/{owner}/{repo}/check-suites/preferences\"],\n update: [\"PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}\"]\n },\n codeScanning: {\n deleteAnalysis: [\"DELETE /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}{?confirm_delete}\"],\n getAlert: [\"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}\", {}, {\n renamedParameters: {\n alert_id: \"alert_number\"\n }\n }],\n getAnalysis: [\"GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}\"],\n getSarif: [\"GET /repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}\"],\n listAlertInstances: [\"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances\"],\n listAlertsForRepo: [\"GET /repos/{owner}/{repo}/code-scanning/alerts\"],\n listAlertsInstances: [\"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances\", {}, {\n renamed: [\"codeScanning\", \"listAlertInstances\"]\n }],\n listRecentAnalyses: [\"GET /repos/{owner}/{repo}/code-scanning/analyses\"],\n updateAlert: [\"PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}\"],\n uploadSarif: [\"POST /repos/{owner}/{repo}/code-scanning/sarifs\"]\n },\n codesOfConduct: {\n getAllCodesOfConduct: [\"GET /codes_of_conduct\", {\n mediaType: {\n previews: [\"scarlet-witch\"]\n }\n }],\n getConductCode: [\"GET /codes_of_conduct/{key}\", {\n mediaType: {\n previews: [\"scarlet-witch\"]\n }\n }],\n getForRepo: [\"GET /repos/{owner}/{repo}/community/code_of_conduct\", {\n mediaType: {\n previews: [\"scarlet-witch\"]\n }\n }]\n },\n emojis: {\n get: [\"GET /emojis\"]\n },\n enterpriseAdmin: {\n disableSelectedOrganizationGithubActionsEnterprise: [\"DELETE /enterprises/{enterprise}/actions/permissions/organizations/{org_id}\"],\n enableSelectedOrganizationGithubActionsEnterprise: [\"PUT /enterprises/{enterprise}/actions/permissions/organizations/{org_id}\"],\n getAllowedActionsEnterprise: [\"GET /enterprises/{enterprise}/actions/permissions/selected-actions\"],\n getGithubActionsPermissionsEnterprise: [\"GET /enterprises/{enterprise}/actions/permissions\"],\n listSelectedOrganizationsEnabledGithubActionsEnterprise: [\"GET /enterprises/{enterprise}/actions/permissions/organizations\"],\n setAllowedActionsEnterprise: [\"PUT /enterprises/{enterprise}/actions/permissions/selected-actions\"],\n setGithubActionsPermissionsEnterprise: [\"PUT /enterprises/{enterprise}/actions/permissions\"],\n setSelectedOrganizationsEnabledGithubActionsEnterprise: [\"PUT /enterprises/{enterprise}/actions/permissions/organizations\"]\n },\n gists: {\n checkIsStarred: [\"GET /gists/{gist_id}/star\"],\n create: [\"POST /gists\"],\n createComment: [\"POST /gists/{gist_id}/comments\"],\n delete: [\"DELETE /gists/{gist_id}\"],\n deleteComment: [\"DELETE /gists/{gist_id}/comments/{comment_id}\"],\n fork: [\"POST /gists/{gist_id}/forks\"],\n get: [\"GET /gists/{gist_id}\"],\n getComment: [\"GET /gists/{gist_id}/comments/{comment_id}\"],\n getRevision: [\"GET /gists/{gist_id}/{sha}\"],\n list: [\"GET /gists\"],\n listComments: [\"GET /gists/{gist_id}/comments\"],\n listCommits: [\"GET /gists/{gist_id}/commits\"],\n listForUser: [\"GET /users/{username}/gists\"],\n listForks: [\"GET /gists/{gist_id}/forks\"],\n listPublic: [\"GET /gists/public\"],\n listStarred: [\"GET /gists/starred\"],\n star: [\"PUT /gists/{gist_id}/star\"],\n unstar: [\"DELETE /gists/{gist_id}/star\"],\n update: [\"PATCH /gists/{gist_id}\"],\n updateComment: [\"PATCH /gists/{gist_id}/comments/{comment_id}\"]\n },\n git: {\n createBlob: [\"POST /repos/{owner}/{repo}/git/blobs\"],\n createCommit: [\"POST /repos/{owner}/{repo}/git/commits\"],\n createRef: [\"POST /repos/{owner}/{repo}/git/refs\"],\n createTag: [\"POST /repos/{owner}/{repo}/git/tags\"],\n createTree: [\"POST /repos/{owner}/{repo}/git/trees\"],\n deleteRef: [\"DELETE /repos/{owner}/{repo}/git/refs/{ref}\"],\n getBlob: [\"GET /repos/{owner}/{repo}/git/blobs/{file_sha}\"],\n getCommit: [\"GET /repos/{owner}/{repo}/git/commits/{commit_sha}\"],\n getRef: [\"GET /repos/{owner}/{repo}/git/ref/{ref}\"],\n getTag: [\"GET /repos/{owner}/{repo}/git/tags/{tag_sha}\"],\n getTree: [\"GET /repos/{owner}/{repo}/git/trees/{tree_sha}\"],\n listMatchingRefs: [\"GET /repos/{owner}/{repo}/git/matching-refs/{ref}\"],\n updateRef: [\"PATCH /repos/{owner}/{repo}/git/refs/{ref}\"]\n },\n gitignore: {\n getAllTemplates: [\"GET /gitignore/templates\"],\n getTemplate: [\"GET /gitignore/templates/{name}\"]\n },\n interactions: {\n getRestrictionsForAuthenticatedUser: [\"GET /user/interaction-limits\"],\n getRestrictionsForOrg: [\"GET /orgs/{org}/interaction-limits\"],\n getRestrictionsForRepo: [\"GET /repos/{owner}/{repo}/interaction-limits\"],\n getRestrictionsForYourPublicRepos: [\"GET /user/interaction-limits\", {}, {\n renamed: [\"interactions\", \"getRestrictionsForAuthenticatedUser\"]\n }],\n removeRestrictionsForAuthenticatedUser: [\"DELETE /user/interaction-limits\"],\n removeRestrictionsForOrg: [\"DELETE /orgs/{org}/interaction-limits\"],\n removeRestrictionsForRepo: [\"DELETE /repos/{owner}/{repo}/interaction-limits\"],\n removeRestrictionsForYourPublicRepos: [\"DELETE /user/interaction-limits\", {}, {\n renamed: [\"interactions\", \"removeRestrictionsForAuthenticatedUser\"]\n }],\n setRestrictionsForAuthenticatedUser: [\"PUT /user/interaction-limits\"],\n setRestrictionsForOrg: [\"PUT /orgs/{org}/interaction-limits\"],\n setRestrictionsForRepo: [\"PUT /repos/{owner}/{repo}/interaction-limits\"],\n setRestrictionsForYourPublicRepos: [\"PUT /user/interaction-limits\", {}, {\n renamed: [\"interactions\", \"setRestrictionsForAuthenticatedUser\"]\n }]\n },\n issues: {\n addAssignees: [\"POST /repos/{owner}/{repo}/issues/{issue_number}/assignees\"],\n addLabels: [\"POST /repos/{owner}/{repo}/issues/{issue_number}/labels\"],\n checkUserCanBeAssigned: [\"GET /repos/{owner}/{repo}/assignees/{assignee}\"],\n create: [\"POST /repos/{owner}/{repo}/issues\"],\n createComment: [\"POST /repos/{owner}/{repo}/issues/{issue_number}/comments\"],\n createLabel: [\"POST /repos/{owner}/{repo}/labels\"],\n createMilestone: [\"POST /repos/{owner}/{repo}/milestones\"],\n deleteComment: [\"DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}\"],\n deleteLabel: [\"DELETE /repos/{owner}/{repo}/labels/{name}\"],\n deleteMilestone: [\"DELETE /repos/{owner}/{repo}/milestones/{milestone_number}\"],\n get: [\"GET /repos/{owner}/{repo}/issues/{issue_number}\"],\n getComment: [\"GET /repos/{owner}/{repo}/issues/comments/{comment_id}\"],\n getEvent: [\"GET /repos/{owner}/{repo}/issues/events/{event_id}\"],\n getLabel: [\"GET /repos/{owner}/{repo}/labels/{name}\"],\n getMilestone: [\"GET /repos/{owner}/{repo}/milestones/{milestone_number}\"],\n list: [\"GET /issues\"],\n listAssignees: [\"GET /repos/{owner}/{repo}/assignees\"],\n listComments: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/comments\"],\n listCommentsForRepo: [\"GET /repos/{owner}/{repo}/issues/comments\"],\n listEvents: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/events\"],\n listEventsForRepo: [\"GET /repos/{owner}/{repo}/issues/events\"],\n listEventsForTimeline: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/timeline\", {\n mediaType: {\n previews: [\"mockingbird\"]\n }\n }],\n listForAuthenticatedUser: [\"GET /user/issues\"],\n listForOrg: [\"GET /orgs/{org}/issues\"],\n listForRepo: [\"GET /repos/{owner}/{repo}/issues\"],\n listLabelsForMilestone: [\"GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels\"],\n listLabelsForRepo: [\"GET /repos/{owner}/{repo}/labels\"],\n listLabelsOnIssue: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/labels\"],\n listMilestones: [\"GET /repos/{owner}/{repo}/milestones\"],\n lock: [\"PUT /repos/{owner}/{repo}/issues/{issue_number}/lock\"],\n removeAllLabels: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels\"],\n removeAssignees: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/assignees\"],\n removeLabel: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}\"],\n setLabels: [\"PUT /repos/{owner}/{repo}/issues/{issue_number}/labels\"],\n unlock: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock\"],\n update: [\"PATCH /repos/{owner}/{repo}/issues/{issue_number}\"],\n updateComment: [\"PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}\"],\n updateLabel: [\"PATCH /repos/{owner}/{repo}/labels/{name}\"],\n updateMilestone: [\"PATCH /repos/{owner}/{repo}/milestones/{milestone_number}\"]\n },\n licenses: {\n get: [\"GET /licenses/{license}\"],\n getAllCommonlyUsed: [\"GET /licenses\"],\n getForRepo: [\"GET /repos/{owner}/{repo}/license\"]\n },\n markdown: {\n render: [\"POST /markdown\"],\n renderRaw: [\"POST /markdown/raw\", {\n headers: {\n \"content-type\": \"text/plain; charset=utf-8\"\n }\n }]\n },\n meta: {\n get: [\"GET /meta\"],\n getOctocat: [\"GET /octocat\"],\n getZen: [\"GET /zen\"],\n root: [\"GET /\"]\n },\n migrations: {\n cancelImport: [\"DELETE /repos/{owner}/{repo}/import\"],\n deleteArchiveForAuthenticatedUser: [\"DELETE /user/migrations/{migration_id}/archive\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n deleteArchiveForOrg: [\"DELETE /orgs/{org}/migrations/{migration_id}/archive\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n downloadArchiveForOrg: [\"GET /orgs/{org}/migrations/{migration_id}/archive\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n getArchiveForAuthenticatedUser: [\"GET /user/migrations/{migration_id}/archive\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n getCommitAuthors: [\"GET /repos/{owner}/{repo}/import/authors\"],\n getImportStatus: [\"GET /repos/{owner}/{repo}/import\"],\n getLargeFiles: [\"GET /repos/{owner}/{repo}/import/large_files\"],\n getStatusForAuthenticatedUser: [\"GET /user/migrations/{migration_id}\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n getStatusForOrg: [\"GET /orgs/{org}/migrations/{migration_id}\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n listForAuthenticatedUser: [\"GET /user/migrations\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n listForOrg: [\"GET /orgs/{org}/migrations\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n listReposForOrg: [\"GET /orgs/{org}/migrations/{migration_id}/repositories\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n listReposForUser: [\"GET /user/migrations/{migration_id}/repositories\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n mapCommitAuthor: [\"PATCH /repos/{owner}/{repo}/import/authors/{author_id}\"],\n setLfsPreference: [\"PATCH /repos/{owner}/{repo}/import/lfs\"],\n startForAuthenticatedUser: [\"POST /user/migrations\"],\n startForOrg: [\"POST /orgs/{org}/migrations\"],\n startImport: [\"PUT /repos/{owner}/{repo}/import\"],\n unlockRepoForAuthenticatedUser: [\"DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n unlockRepoForOrg: [\"DELETE /orgs/{org}/migrations/{migration_id}/repos/{repo_name}/lock\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n updateImport: [\"PATCH /repos/{owner}/{repo}/import\"]\n },\n orgs: {\n blockUser: [\"PUT /orgs/{org}/blocks/{username}\"],\n cancelInvitation: [\"DELETE /orgs/{org}/invitations/{invitation_id}\"],\n checkBlockedUser: [\"GET /orgs/{org}/blocks/{username}\"],\n checkMembershipForUser: [\"GET /orgs/{org}/members/{username}\"],\n checkPublicMembershipForUser: [\"GET /orgs/{org}/public_members/{username}\"],\n convertMemberToOutsideCollaborator: [\"PUT /orgs/{org}/outside_collaborators/{username}\"],\n createInvitation: [\"POST /orgs/{org}/invitations\"],\n createWebhook: [\"POST /orgs/{org}/hooks\"],\n deleteWebhook: [\"DELETE /orgs/{org}/hooks/{hook_id}\"],\n get: [\"GET /orgs/{org}\"],\n getMembershipForAuthenticatedUser: [\"GET /user/memberships/orgs/{org}\"],\n getMembershipForUser: [\"GET /orgs/{org}/memberships/{username}\"],\n getWebhook: [\"GET /orgs/{org}/hooks/{hook_id}\"],\n getWebhookConfigForOrg: [\"GET /orgs/{org}/hooks/{hook_id}/config\"],\n list: [\"GET /organizations\"],\n listAppInstallations: [\"GET /orgs/{org}/installations\"],\n listBlockedUsers: [\"GET /orgs/{org}/blocks\"],\n listFailedInvitations: [\"GET /orgs/{org}/failed_invitations\"],\n listForAuthenticatedUser: [\"GET /user/orgs\"],\n listForUser: [\"GET /users/{username}/orgs\"],\n listInvitationTeams: [\"GET /orgs/{org}/invitations/{invitation_id}/teams\"],\n listMembers: [\"GET /orgs/{org}/members\"],\n listMembershipsForAuthenticatedUser: [\"GET /user/memberships/orgs\"],\n listOutsideCollaborators: [\"GET /orgs/{org}/outside_collaborators\"],\n listPendingInvitations: [\"GET /orgs/{org}/invitations\"],\n listPublicMembers: [\"GET /orgs/{org}/public_members\"],\n listWebhooks: [\"GET /orgs/{org}/hooks\"],\n pingWebhook: [\"POST /orgs/{org}/hooks/{hook_id}/pings\"],\n removeMember: [\"DELETE /orgs/{org}/members/{username}\"],\n removeMembershipForUser: [\"DELETE /orgs/{org}/memberships/{username}\"],\n removeOutsideCollaborator: [\"DELETE /orgs/{org}/outside_collaborators/{username}\"],\n removePublicMembershipForAuthenticatedUser: [\"DELETE /orgs/{org}/public_members/{username}\"],\n setMembershipForUser: [\"PUT /orgs/{org}/memberships/{username}\"],\n setPublicMembershipForAuthenticatedUser: [\"PUT /orgs/{org}/public_members/{username}\"],\n unblockUser: [\"DELETE /orgs/{org}/blocks/{username}\"],\n update: [\"PATCH /orgs/{org}\"],\n updateMembershipForAuthenticatedUser: [\"PATCH /user/memberships/orgs/{org}\"],\n updateWebhook: [\"PATCH /orgs/{org}/hooks/{hook_id}\"],\n updateWebhookConfigForOrg: [\"PATCH /orgs/{org}/hooks/{hook_id}/config\"]\n },\n packages: {\n deletePackageForAuthenticatedUser: [\"DELETE /user/packages/{package_type}/{package_name}\"],\n deletePackageForOrg: [\"DELETE /orgs/{org}/packages/{package_type}/{package_name}\"],\n deletePackageVersionForAuthenticatedUser: [\"DELETE /user/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n deletePackageVersionForOrg: [\"DELETE /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n getAllPackageVersionsForAPackageOwnedByAnOrg: [\"GET /orgs/{org}/packages/{package_type}/{package_name}/versions\", {}, {\n renamed: [\"packages\", \"getAllPackageVersionsForPackageOwnedByOrg\"]\n }],\n getAllPackageVersionsForAPackageOwnedByTheAuthenticatedUser: [\"GET /user/packages/{package_type}/{package_name}/versions\", {}, {\n renamed: [\"packages\", \"getAllPackageVersionsForPackageOwnedByAuthenticatedUser\"]\n }],\n getAllPackageVersionsForPackageOwnedByAuthenticatedUser: [\"GET /user/packages/{package_type}/{package_name}/versions\"],\n getAllPackageVersionsForPackageOwnedByOrg: [\"GET /orgs/{org}/packages/{package_type}/{package_name}/versions\"],\n getAllPackageVersionsForPackageOwnedByUser: [\"GET /users/{username}/packages/{package_type}/{package_name}/versions\"],\n getPackageForAuthenticatedUser: [\"GET /user/packages/{package_type}/{package_name}\"],\n getPackageForOrganization: [\"GET /orgs/{org}/packages/{package_type}/{package_name}\"],\n getPackageForUser: [\"GET /users/{username}/packages/{package_type}/{package_name}\"],\n getPackageVersionForAuthenticatedUser: [\"GET /user/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n getPackageVersionForOrganization: [\"GET /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n getPackageVersionForUser: [\"GET /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n restorePackageForAuthenticatedUser: [\"POST /user/packages/{package_type}/{package_name}/restore{?token}\"],\n restorePackageForOrg: [\"POST /orgs/{org}/packages/{package_type}/{package_name}/restore{?token}\"],\n restorePackageVersionForAuthenticatedUser: [\"POST /user/packages/{package_type}/{package_name}/versions/{package_version_id}/restore\"],\n restorePackageVersionForOrg: [\"POST /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore\"]\n },\n projects: {\n addCollaborator: [\"PUT /projects/{project_id}/collaborators/{username}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createCard: [\"POST /projects/columns/{column_id}/cards\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createColumn: [\"POST /projects/{project_id}/columns\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createForAuthenticatedUser: [\"POST /user/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createForOrg: [\"POST /orgs/{org}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createForRepo: [\"POST /repos/{owner}/{repo}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n delete: [\"DELETE /projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n deleteCard: [\"DELETE /projects/columns/cards/{card_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n deleteColumn: [\"DELETE /projects/columns/{column_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n get: [\"GET /projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n getCard: [\"GET /projects/columns/cards/{card_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n getColumn: [\"GET /projects/columns/{column_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n getPermissionForUser: [\"GET /projects/{project_id}/collaborators/{username}/permission\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listCards: [\"GET /projects/columns/{column_id}/cards\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listCollaborators: [\"GET /projects/{project_id}/collaborators\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listColumns: [\"GET /projects/{project_id}/columns\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listForOrg: [\"GET /orgs/{org}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listForRepo: [\"GET /repos/{owner}/{repo}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listForUser: [\"GET /users/{username}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n moveCard: [\"POST /projects/columns/cards/{card_id}/moves\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n moveColumn: [\"POST /projects/columns/{column_id}/moves\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n removeCollaborator: [\"DELETE /projects/{project_id}/collaborators/{username}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n update: [\"PATCH /projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n updateCard: [\"PATCH /projects/columns/cards/{card_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n updateColumn: [\"PATCH /projects/columns/{column_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }]\n },\n pulls: {\n checkIfMerged: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/merge\"],\n create: [\"POST /repos/{owner}/{repo}/pulls\"],\n createReplyForReviewComment: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies\"],\n createReview: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews\"],\n createReviewComment: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/comments\"],\n deletePendingReview: [\"DELETE /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}\"],\n deleteReviewComment: [\"DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}\"],\n dismissReview: [\"PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals\"],\n get: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}\"],\n getReview: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}\"],\n getReviewComment: [\"GET /repos/{owner}/{repo}/pulls/comments/{comment_id}\"],\n list: [\"GET /repos/{owner}/{repo}/pulls\"],\n listCommentsForReview: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments\"],\n listCommits: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/commits\"],\n listFiles: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/files\"],\n listRequestedReviewers: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers\"],\n listReviewComments: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/comments\"],\n listReviewCommentsForRepo: [\"GET /repos/{owner}/{repo}/pulls/comments\"],\n listReviews: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews\"],\n merge: [\"PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge\"],\n removeRequestedReviewers: [\"DELETE /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers\"],\n requestReviewers: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers\"],\n submitReview: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events\"],\n update: [\"PATCH /repos/{owner}/{repo}/pulls/{pull_number}\"],\n updateBranch: [\"PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch\", {\n mediaType: {\n previews: [\"lydian\"]\n }\n }],\n updateReview: [\"PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}\"],\n updateReviewComment: [\"PATCH /repos/{owner}/{repo}/pulls/comments/{comment_id}\"]\n },\n rateLimit: {\n get: [\"GET /rate_limit\"]\n },\n reactions: {\n createForCommitComment: [\"POST /repos/{owner}/{repo}/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForIssue: [\"POST /repos/{owner}/{repo}/issues/{issue_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForIssueComment: [\"POST /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForPullRequestReviewComment: [\"POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForRelease: [\"POST /repos/{owner}/{repo}/releases/{release_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForTeamDiscussionCommentInOrg: [\"POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForTeamDiscussionInOrg: [\"POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForCommitComment: [\"DELETE /repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForIssue: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForIssueComment: [\"DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForPullRequestComment: [\"DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForTeamDiscussion: [\"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForTeamDiscussionComment: [\"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteLegacy: [\"DELETE /reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }, {\n deprecated: \"octokit.rest.reactions.deleteLegacy() is deprecated, see https://docs.github.com/rest/reference/reactions/#delete-a-reaction-legacy\"\n }],\n listForCommitComment: [\"GET /repos/{owner}/{repo}/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForIssue: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForIssueComment: [\"GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForPullRequestReviewComment: [\"GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForTeamDiscussionCommentInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForTeamDiscussionInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }]\n },\n repos: {\n acceptInvitation: [\"PATCH /user/repository_invitations/{invitation_id}\"],\n addAppAccessRestrictions: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps\", {}, {\n mapToData: \"apps\"\n }],\n addCollaborator: [\"PUT /repos/{owner}/{repo}/collaborators/{username}\"],\n addStatusCheckContexts: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts\", {}, {\n mapToData: \"contexts\"\n }],\n addTeamAccessRestrictions: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams\", {}, {\n mapToData: \"teams\"\n }],\n addUserAccessRestrictions: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users\", {}, {\n mapToData: \"users\"\n }],\n checkCollaborator: [\"GET /repos/{owner}/{repo}/collaborators/{username}\"],\n checkVulnerabilityAlerts: [\"GET /repos/{owner}/{repo}/vulnerability-alerts\", {\n mediaType: {\n previews: [\"dorian\"]\n }\n }],\n compareCommits: [\"GET /repos/{owner}/{repo}/compare/{base}...{head}\"],\n compareCommitsWithBasehead: [\"GET /repos/{owner}/{repo}/compare/{basehead}\"],\n createCommitComment: [\"POST /repos/{owner}/{repo}/commits/{commit_sha}/comments\"],\n createCommitSignatureProtection: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures\", {\n mediaType: {\n previews: [\"zzzax\"]\n }\n }],\n createCommitStatus: [\"POST /repos/{owner}/{repo}/statuses/{sha}\"],\n createDeployKey: [\"POST /repos/{owner}/{repo}/keys\"],\n createDeployment: [\"POST /repos/{owner}/{repo}/deployments\"],\n createDeploymentStatus: [\"POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses\"],\n createDispatchEvent: [\"POST /repos/{owner}/{repo}/dispatches\"],\n createForAuthenticatedUser: [\"POST /user/repos\"],\n createFork: [\"POST /repos/{owner}/{repo}/forks\"],\n createInOrg: [\"POST /orgs/{org}/repos\"],\n createOrUpdateEnvironment: [\"PUT /repos/{owner}/{repo}/environments/{environment_name}\"],\n createOrUpdateFileContents: [\"PUT /repos/{owner}/{repo}/contents/{path}\"],\n createPagesSite: [\"POST /repos/{owner}/{repo}/pages\", {\n mediaType: {\n previews: [\"switcheroo\"]\n }\n }],\n createRelease: [\"POST /repos/{owner}/{repo}/releases\"],\n createUsingTemplate: [\"POST /repos/{template_owner}/{template_repo}/generate\", {\n mediaType: {\n previews: [\"baptiste\"]\n }\n }],\n createWebhook: [\"POST /repos/{owner}/{repo}/hooks\"],\n declineInvitation: [\"DELETE /user/repository_invitations/{invitation_id}\"],\n delete: [\"DELETE /repos/{owner}/{repo}\"],\n deleteAccessRestrictions: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions\"],\n deleteAdminBranchProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins\"],\n deleteAnEnvironment: [\"DELETE /repos/{owner}/{repo}/environments/{environment_name}\"],\n deleteBranchProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection\"],\n deleteCommitComment: [\"DELETE /repos/{owner}/{repo}/comments/{comment_id}\"],\n deleteCommitSignatureProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures\", {\n mediaType: {\n previews: [\"zzzax\"]\n }\n }],\n deleteDeployKey: [\"DELETE /repos/{owner}/{repo}/keys/{key_id}\"],\n deleteDeployment: [\"DELETE /repos/{owner}/{repo}/deployments/{deployment_id}\"],\n deleteFile: [\"DELETE /repos/{owner}/{repo}/contents/{path}\"],\n deleteInvitation: [\"DELETE /repos/{owner}/{repo}/invitations/{invitation_id}\"],\n deletePagesSite: [\"DELETE /repos/{owner}/{repo}/pages\", {\n mediaType: {\n previews: [\"switcheroo\"]\n }\n }],\n deletePullRequestReviewProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews\"],\n deleteRelease: [\"DELETE /repos/{owner}/{repo}/releases/{release_id}\"],\n deleteReleaseAsset: [\"DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}\"],\n deleteWebhook: [\"DELETE /repos/{owner}/{repo}/hooks/{hook_id}\"],\n disableAutomatedSecurityFixes: [\"DELETE /repos/{owner}/{repo}/automated-security-fixes\", {\n mediaType: {\n previews: [\"london\"]\n }\n }],\n disableVulnerabilityAlerts: [\"DELETE /repos/{owner}/{repo}/vulnerability-alerts\", {\n mediaType: {\n previews: [\"dorian\"]\n }\n }],\n downloadArchive: [\"GET /repos/{owner}/{repo}/zipball/{ref}\", {}, {\n renamed: [\"repos\", \"downloadZipballArchive\"]\n }],\n downloadTarballArchive: [\"GET /repos/{owner}/{repo}/tarball/{ref}\"],\n downloadZipballArchive: [\"GET /repos/{owner}/{repo}/zipball/{ref}\"],\n enableAutomatedSecurityFixes: [\"PUT /repos/{owner}/{repo}/automated-security-fixes\", {\n mediaType: {\n previews: [\"london\"]\n }\n }],\n enableVulnerabilityAlerts: [\"PUT /repos/{owner}/{repo}/vulnerability-alerts\", {\n mediaType: {\n previews: [\"dorian\"]\n }\n }],\n get: [\"GET /repos/{owner}/{repo}\"],\n getAccessRestrictions: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions\"],\n getAdminBranchProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins\"],\n getAllEnvironments: [\"GET /repos/{owner}/{repo}/environments\"],\n getAllStatusCheckContexts: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts\"],\n getAllTopics: [\"GET /repos/{owner}/{repo}/topics\", {\n mediaType: {\n previews: [\"mercy\"]\n }\n }],\n getAppsWithAccessToProtectedBranch: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps\"],\n getBranch: [\"GET /repos/{owner}/{repo}/branches/{branch}\"],\n getBranchProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection\"],\n getClones: [\"GET /repos/{owner}/{repo}/traffic/clones\"],\n getCodeFrequencyStats: [\"GET /repos/{owner}/{repo}/stats/code_frequency\"],\n getCollaboratorPermissionLevel: [\"GET /repos/{owner}/{repo}/collaborators/{username}/permission\"],\n getCombinedStatusForRef: [\"GET /repos/{owner}/{repo}/commits/{ref}/status\"],\n getCommit: [\"GET /repos/{owner}/{repo}/commits/{ref}\"],\n getCommitActivityStats: [\"GET /repos/{owner}/{repo}/stats/commit_activity\"],\n getCommitComment: [\"GET /repos/{owner}/{repo}/comments/{comment_id}\"],\n getCommitSignatureProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures\", {\n mediaType: {\n previews: [\"zzzax\"]\n }\n }],\n getCommunityProfileMetrics: [\"GET /repos/{owner}/{repo}/community/profile\"],\n getContent: [\"GET /repos/{owner}/{repo}/contents/{path}\"],\n getContributorsStats: [\"GET /repos/{owner}/{repo}/stats/contributors\"],\n getDeployKey: [\"GET /repos/{owner}/{repo}/keys/{key_id}\"],\n getDeployment: [\"GET /repos/{owner}/{repo}/deployments/{deployment_id}\"],\n getDeploymentStatus: [\"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}\"],\n getEnvironment: [\"GET /repos/{owner}/{repo}/environments/{environment_name}\"],\n getLatestPagesBuild: [\"GET /repos/{owner}/{repo}/pages/builds/latest\"],\n getLatestRelease: [\"GET /repos/{owner}/{repo}/releases/latest\"],\n getPages: [\"GET /repos/{owner}/{repo}/pages\"],\n getPagesBuild: [\"GET /repos/{owner}/{repo}/pages/builds/{build_id}\"],\n getPagesHealthCheck: [\"GET /repos/{owner}/{repo}/pages/health\"],\n getParticipationStats: [\"GET /repos/{owner}/{repo}/stats/participation\"],\n getPullRequestReviewProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews\"],\n getPunchCardStats: [\"GET /repos/{owner}/{repo}/stats/punch_card\"],\n getReadme: [\"GET /repos/{owner}/{repo}/readme\"],\n getReadmeInDirectory: [\"GET /repos/{owner}/{repo}/readme/{dir}\"],\n getRelease: [\"GET /repos/{owner}/{repo}/releases/{release_id}\"],\n getReleaseAsset: [\"GET /repos/{owner}/{repo}/releases/assets/{asset_id}\"],\n getReleaseByTag: [\"GET /repos/{owner}/{repo}/releases/tags/{tag}\"],\n getStatusChecksProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks\"],\n getTeamsWithAccessToProtectedBranch: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams\"],\n getTopPaths: [\"GET /repos/{owner}/{repo}/traffic/popular/paths\"],\n getTopReferrers: [\"GET /repos/{owner}/{repo}/traffic/popular/referrers\"],\n getUsersWithAccessToProtectedBranch: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users\"],\n getViews: [\"GET /repos/{owner}/{repo}/traffic/views\"],\n getWebhook: [\"GET /repos/{owner}/{repo}/hooks/{hook_id}\"],\n getWebhookConfigForRepo: [\"GET /repos/{owner}/{repo}/hooks/{hook_id}/config\"],\n listBranches: [\"GET /repos/{owner}/{repo}/branches\"],\n listBranchesForHeadCommit: [\"GET /repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head\", {\n mediaType: {\n previews: [\"groot\"]\n }\n }],\n listCollaborators: [\"GET /repos/{owner}/{repo}/collaborators\"],\n listCommentsForCommit: [\"GET /repos/{owner}/{repo}/commits/{commit_sha}/comments\"],\n listCommitCommentsForRepo: [\"GET /repos/{owner}/{repo}/comments\"],\n listCommitStatusesForRef: [\"GET /repos/{owner}/{repo}/commits/{ref}/statuses\"],\n listCommits: [\"GET /repos/{owner}/{repo}/commits\"],\n listContributors: [\"GET /repos/{owner}/{repo}/contributors\"],\n listDeployKeys: [\"GET /repos/{owner}/{repo}/keys\"],\n listDeploymentStatuses: [\"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses\"],\n listDeployments: [\"GET /repos/{owner}/{repo}/deployments\"],\n listForAuthenticatedUser: [\"GET /user/repos\"],\n listForOrg: [\"GET /orgs/{org}/repos\"],\n listForUser: [\"GET /users/{username}/repos\"],\n listForks: [\"GET /repos/{owner}/{repo}/forks\"],\n listInvitations: [\"GET /repos/{owner}/{repo}/invitations\"],\n listInvitationsForAuthenticatedUser: [\"GET /user/repository_invitations\"],\n listLanguages: [\"GET /repos/{owner}/{repo}/languages\"],\n listPagesBuilds: [\"GET /repos/{owner}/{repo}/pages/builds\"],\n listPublic: [\"GET /repositories\"],\n listPullRequestsAssociatedWithCommit: [\"GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls\", {\n mediaType: {\n previews: [\"groot\"]\n }\n }],\n listReleaseAssets: [\"GET /repos/{owner}/{repo}/releases/{release_id}/assets\"],\n listReleases: [\"GET /repos/{owner}/{repo}/releases\"],\n listTags: [\"GET /repos/{owner}/{repo}/tags\"],\n listTeams: [\"GET /repos/{owner}/{repo}/teams\"],\n listWebhooks: [\"GET /repos/{owner}/{repo}/hooks\"],\n merge: [\"POST /repos/{owner}/{repo}/merges\"],\n pingWebhook: [\"POST /repos/{owner}/{repo}/hooks/{hook_id}/pings\"],\n removeAppAccessRestrictions: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps\", {}, {\n mapToData: \"apps\"\n }],\n removeCollaborator: [\"DELETE /repos/{owner}/{repo}/collaborators/{username}\"],\n removeStatusCheckContexts: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts\", {}, {\n mapToData: \"contexts\"\n }],\n removeStatusCheckProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks\"],\n removeTeamAccessRestrictions: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams\", {}, {\n mapToData: \"teams\"\n }],\n removeUserAccessRestrictions: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users\", {}, {\n mapToData: \"users\"\n }],\n renameBranch: [\"POST /repos/{owner}/{repo}/branches/{branch}/rename\"],\n replaceAllTopics: [\"PUT /repos/{owner}/{repo}/topics\", {\n mediaType: {\n previews: [\"mercy\"]\n }\n }],\n requestPagesBuild: [\"POST /repos/{owner}/{repo}/pages/builds\"],\n setAdminBranchProtection: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins\"],\n setAppAccessRestrictions: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps\", {}, {\n mapToData: \"apps\"\n }],\n setStatusCheckContexts: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts\", {}, {\n mapToData: \"contexts\"\n }],\n setTeamAccessRestrictions: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams\", {}, {\n mapToData: \"teams\"\n }],\n setUserAccessRestrictions: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users\", {}, {\n mapToData: \"users\"\n }],\n testPushWebhook: [\"POST /repos/{owner}/{repo}/hooks/{hook_id}/tests\"],\n transfer: [\"POST /repos/{owner}/{repo}/transfer\"],\n update: [\"PATCH /repos/{owner}/{repo}\"],\n updateBranchProtection: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection\"],\n updateCommitComment: [\"PATCH /repos/{owner}/{repo}/comments/{comment_id}\"],\n updateInformationAboutPagesSite: [\"PUT /repos/{owner}/{repo}/pages\"],\n updateInvitation: [\"PATCH /repos/{owner}/{repo}/invitations/{invitation_id}\"],\n updatePullRequestReviewProtection: [\"PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews\"],\n updateRelease: [\"PATCH /repos/{owner}/{repo}/releases/{release_id}\"],\n updateReleaseAsset: [\"PATCH /repos/{owner}/{repo}/releases/assets/{asset_id}\"],\n updateStatusCheckPotection: [\"PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks\", {}, {\n renamed: [\"repos\", \"updateStatusCheckProtection\"]\n }],\n updateStatusCheckProtection: [\"PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks\"],\n updateWebhook: [\"PATCH /repos/{owner}/{repo}/hooks/{hook_id}\"],\n updateWebhookConfigForRepo: [\"PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config\"],\n uploadReleaseAsset: [\"POST /repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}\", {\n baseUrl: \"https://uploads.github.com\"\n }]\n },\n search: {\n code: [\"GET /search/code\"],\n commits: [\"GET /search/commits\", {\n mediaType: {\n previews: [\"cloak\"]\n }\n }],\n issuesAndPullRequests: [\"GET /search/issues\"],\n labels: [\"GET /search/labels\"],\n repos: [\"GET /search/repositories\"],\n topics: [\"GET /search/topics\", {\n mediaType: {\n previews: [\"mercy\"]\n }\n }],\n users: [\"GET /search/users\"]\n },\n secretScanning: {\n getAlert: [\"GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}\"],\n listAlertsForRepo: [\"GET /repos/{owner}/{repo}/secret-scanning/alerts\"],\n updateAlert: [\"PATCH /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}\"]\n },\n teams: {\n addOrUpdateMembershipForUserInOrg: [\"PUT /orgs/{org}/teams/{team_slug}/memberships/{username}\"],\n addOrUpdateProjectPermissionsInOrg: [\"PUT /orgs/{org}/teams/{team_slug}/projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n addOrUpdateRepoPermissionsInOrg: [\"PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}\"],\n checkPermissionsForProjectInOrg: [\"GET /orgs/{org}/teams/{team_slug}/projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n checkPermissionsForRepoInOrg: [\"GET /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}\"],\n create: [\"POST /orgs/{org}/teams\"],\n createDiscussionCommentInOrg: [\"POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments\"],\n createDiscussionInOrg: [\"POST /orgs/{org}/teams/{team_slug}/discussions\"],\n deleteDiscussionCommentInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}\"],\n deleteDiscussionInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}\"],\n deleteInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}\"],\n getByName: [\"GET /orgs/{org}/teams/{team_slug}\"],\n getDiscussionCommentInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}\"],\n getDiscussionInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}\"],\n getMembershipForUserInOrg: [\"GET /orgs/{org}/teams/{team_slug}/memberships/{username}\"],\n list: [\"GET /orgs/{org}/teams\"],\n listChildInOrg: [\"GET /orgs/{org}/teams/{team_slug}/teams\"],\n listDiscussionCommentsInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments\"],\n listDiscussionsInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions\"],\n listForAuthenticatedUser: [\"GET /user/teams\"],\n listMembersInOrg: [\"GET /orgs/{org}/teams/{team_slug}/members\"],\n listPendingInvitationsInOrg: [\"GET /orgs/{org}/teams/{team_slug}/invitations\"],\n listProjectsInOrg: [\"GET /orgs/{org}/teams/{team_slug}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listReposInOrg: [\"GET /orgs/{org}/teams/{team_slug}/repos\"],\n removeMembershipForUserInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/memberships/{username}\"],\n removeProjectInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/projects/{project_id}\"],\n removeRepoInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}\"],\n updateDiscussionCommentInOrg: [\"PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}\"],\n updateDiscussionInOrg: [\"PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}\"],\n updateInOrg: [\"PATCH /orgs/{org}/teams/{team_slug}\"]\n },\n users: {\n addEmailForAuthenticated: [\"POST /user/emails\"],\n block: [\"PUT /user/blocks/{username}\"],\n checkBlocked: [\"GET /user/blocks/{username}\"],\n checkFollowingForUser: [\"GET /users/{username}/following/{target_user}\"],\n checkPersonIsFollowedByAuthenticated: [\"GET /user/following/{username}\"],\n createGpgKeyForAuthenticated: [\"POST /user/gpg_keys\"],\n createPublicSshKeyForAuthenticated: [\"POST /user/keys\"],\n deleteEmailForAuthenticated: [\"DELETE /user/emails\"],\n deleteGpgKeyForAuthenticated: [\"DELETE /user/gpg_keys/{gpg_key_id}\"],\n deletePublicSshKeyForAuthenticated: [\"DELETE /user/keys/{key_id}\"],\n follow: [\"PUT /user/following/{username}\"],\n getAuthenticated: [\"GET /user\"],\n getByUsername: [\"GET /users/{username}\"],\n getContextForUser: [\"GET /users/{username}/hovercard\"],\n getGpgKeyForAuthenticated: [\"GET /user/gpg_keys/{gpg_key_id}\"],\n getPublicSshKeyForAuthenticated: [\"GET /user/keys/{key_id}\"],\n list: [\"GET /users\"],\n listBlockedByAuthenticated: [\"GET /user/blocks\"],\n listEmailsForAuthenticated: [\"GET /user/emails\"],\n listFollowedByAuthenticated: [\"GET /user/following\"],\n listFollowersForAuthenticatedUser: [\"GET /user/followers\"],\n listFollowersForUser: [\"GET /users/{username}/followers\"],\n listFollowingForUser: [\"GET /users/{username}/following\"],\n listGpgKeysForAuthenticated: [\"GET /user/gpg_keys\"],\n listGpgKeysForUser: [\"GET /users/{username}/gpg_keys\"],\n listPublicEmailsForAuthenticated: [\"GET /user/public_emails\"],\n listPublicKeysForUser: [\"GET /users/{username}/keys\"],\n listPublicSshKeysForAuthenticated: [\"GET /user/keys\"],\n setPrimaryEmailVisibilityForAuthenticated: [\"PATCH /user/email/visibility\"],\n unblock: [\"DELETE /user/blocks/{username}\"],\n unfollow: [\"DELETE /user/following/{username}\"],\n updateAuthenticated: [\"PATCH /user\"]\n }\n};\n\nconst VERSION = \"5.3.1\";\n\nfunction endpointsToMethods(octokit, endpointsMap) {\n const newMethods = {};\n\n for (const [scope, endpoints] of Object.entries(endpointsMap)) {\n for (const [methodName, endpoint] of Object.entries(endpoints)) {\n const [route, defaults, decorations] = endpoint;\n const [method, url] = route.split(/ /);\n const endpointDefaults = Object.assign({\n method,\n url\n }, defaults);\n\n if (!newMethods[scope]) {\n newMethods[scope] = {};\n }\n\n const scopeMethods = newMethods[scope];\n\n if (decorations) {\n scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations);\n continue;\n }\n\n scopeMethods[methodName] = octokit.request.defaults(endpointDefaults);\n }\n }\n\n return newMethods;\n}\n\nfunction decorate(octokit, scope, methodName, defaults, decorations) {\n const requestWithDefaults = octokit.request.defaults(defaults);\n /* istanbul ignore next */\n\n function withDecorations(...args) {\n // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488\n let options = requestWithDefaults.endpoint.merge(...args); // There are currently no other decorations than `.mapToData`\n\n if (decorations.mapToData) {\n options = Object.assign({}, options, {\n data: options[decorations.mapToData],\n [decorations.mapToData]: undefined\n });\n return requestWithDefaults(options);\n }\n\n if (decorations.renamed) {\n const [newScope, newMethodName] = decorations.renamed;\n octokit.log.warn(`octokit.${scope}.${methodName}() has been renamed to octokit.${newScope}.${newMethodName}()`);\n }\n\n if (decorations.deprecated) {\n octokit.log.warn(decorations.deprecated);\n }\n\n if (decorations.renamedParameters) {\n // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488\n const options = requestWithDefaults.endpoint.merge(...args);\n\n for (const [name, alias] of Object.entries(decorations.renamedParameters)) {\n if (name in options) {\n octokit.log.warn(`\"${name}\" parameter is deprecated for \"octokit.${scope}.${methodName}()\". Use \"${alias}\" instead`);\n\n if (!(alias in options)) {\n options[alias] = options[name];\n }\n\n delete options[name];\n }\n }\n\n return requestWithDefaults(options);\n } // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488\n\n\n return requestWithDefaults(...args);\n }\n\n return Object.assign(withDecorations, requestWithDefaults);\n}\n\nfunction restEndpointMethods(octokit) {\n const api = endpointsToMethods(octokit, Endpoints);\n return {\n rest: api\n };\n}\nrestEndpointMethods.VERSION = VERSION;\nfunction legacyRestEndpointMethods(octokit) {\n const api = endpointsToMethods(octokit, Endpoints);\n return _objectSpread2(_objectSpread2({}, api), {}, {\n rest: api\n });\n}\nlegacyRestEndpointMethods.VERSION = VERSION;\n\nexports.legacyRestEndpointMethods = legacyRestEndpointMethods;\nexports.restEndpointMethods = restEndpointMethods;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar deprecation = require('deprecation');\nvar once = _interopDefault(require('once'));\n\nconst logOnce = once(deprecation => console.warn(deprecation));\n/**\n * Error with extra properties to help with debugging\n */\n\nclass RequestError extends Error {\n constructor(message, statusCode, options) {\n super(message); // Maintains proper stack trace (only available on V8)\n\n /* istanbul ignore next */\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n\n this.name = \"HttpError\";\n this.status = statusCode;\n Object.defineProperty(this, \"code\", {\n get() {\n logOnce(new deprecation.Deprecation(\"[@octokit/request-error] `error.code` is deprecated, use `error.status`.\"));\n return statusCode;\n }\n\n });\n this.headers = options.headers || {}; // redact request credentials without mutating original request options\n\n const requestCopy = Object.assign({}, options.request);\n\n if (options.request.headers.authorization) {\n requestCopy.headers = Object.assign({}, options.request.headers, {\n authorization: options.request.headers.authorization.replace(/ .*$/, \" [REDACTED]\")\n });\n }\n\n requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit\n // see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications\n .replace(/\\bclient_secret=\\w+/g, \"client_secret=[REDACTED]\") // OAuth tokens can be passed as URL query parameters, although it is not recommended\n // see https://developer.github.com/v3/#oauth2-token-sent-in-a-header\n .replace(/\\baccess_token=\\w+/g, \"access_token=[REDACTED]\");\n this.request = requestCopy;\n }\n\n}\n\nexports.RequestError = RequestError;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar endpoint = require('@octokit/endpoint');\nvar universalUserAgent = require('universal-user-agent');\nvar isPlainObject = require('is-plain-object');\nvar nodeFetch = _interopDefault(require('node-fetch'));\nvar requestError = require('@octokit/request-error');\n\nconst VERSION = \"5.4.15\";\n\nfunction getBufferResponse(response) {\n return response.arrayBuffer();\n}\n\nfunction fetchWrapper(requestOptions) {\n if (isPlainObject.isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {\n requestOptions.body = JSON.stringify(requestOptions.body);\n }\n\n let headers = {};\n let status;\n let url;\n const fetch = requestOptions.request && requestOptions.request.fetch || nodeFetch;\n return fetch(requestOptions.url, Object.assign({\n method: requestOptions.method,\n body: requestOptions.body,\n headers: requestOptions.headers,\n redirect: requestOptions.redirect\n }, // `requestOptions.request.agent` type is incompatible\n // see https://github.com/octokit/types.ts/pull/264\n requestOptions.request)).then(response => {\n url = response.url;\n status = response.status;\n\n for (const keyAndValue of response.headers) {\n headers[keyAndValue[0]] = keyAndValue[1];\n }\n\n if (status === 204 || status === 205) {\n return;\n } // GitHub API returns 200 for HEAD requests\n\n\n if (requestOptions.method === \"HEAD\") {\n if (status < 400) {\n return;\n }\n\n throw new requestError.RequestError(response.statusText, status, {\n headers,\n request: requestOptions\n });\n }\n\n if (status === 304) {\n throw new requestError.RequestError(\"Not modified\", status, {\n headers,\n request: requestOptions\n });\n }\n\n if (status >= 400) {\n return response.text().then(message => {\n const error = new requestError.RequestError(message, status, {\n headers,\n request: requestOptions\n });\n\n try {\n let responseBody = JSON.parse(error.message);\n Object.assign(error, responseBody);\n let errors = responseBody.errors; // Assumption `errors` would always be in Array format\n\n error.message = error.message + \": \" + errors.map(JSON.stringify).join(\", \");\n } catch (e) {// ignore, see octokit/rest.js#684\n }\n\n throw error;\n });\n }\n\n const contentType = response.headers.get(\"content-type\");\n\n if (/application\\/json/.test(contentType)) {\n return response.json();\n }\n\n if (!contentType || /^text\\/|charset=utf-8$/.test(contentType)) {\n return response.text();\n }\n\n return getBufferResponse(response);\n }).then(data => {\n return {\n status,\n url,\n headers,\n data\n };\n }).catch(error => {\n if (error instanceof requestError.RequestError) {\n throw error;\n }\n\n throw new requestError.RequestError(error.message, 500, {\n headers,\n request: requestOptions\n });\n });\n}\n\nfunction withDefaults(oldEndpoint, newDefaults) {\n const endpoint = oldEndpoint.defaults(newDefaults);\n\n const newApi = function (route, parameters) {\n const endpointOptions = endpoint.merge(route, parameters);\n\n if (!endpointOptions.request || !endpointOptions.request.hook) {\n return fetchWrapper(endpoint.parse(endpointOptions));\n }\n\n const request = (route, parameters) => {\n return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters)));\n };\n\n Object.assign(request, {\n endpoint,\n defaults: withDefaults.bind(null, endpoint)\n });\n return endpointOptions.request.hook(request, endpointOptions);\n };\n\n return Object.assign(newApi, {\n endpoint,\n defaults: withDefaults.bind(null, endpoint)\n });\n}\n\nconst request = withDefaults(endpoint.endpoint, {\n headers: {\n \"user-agent\": `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}`\n }\n});\n\nexports.request = request;\n//# sourceMappingURL=index.js.map\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n\nmodule.exports = {\n\n newInvalidAsn1Error: function (msg) {\n var e = new Error();\n e.name = 'InvalidAsn1Error';\n e.message = msg || '';\n return e;\n }\n\n};\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar errors = require('./errors');\nvar types = require('./types');\n\nvar Reader = require('./reader');\nvar Writer = require('./writer');\n\n\n// --- Exports\n\nmodule.exports = {\n\n Reader: Reader,\n\n Writer: Writer\n\n};\n\nfor (var t in types) {\n if (types.hasOwnProperty(t))\n module.exports[t] = types[t];\n}\nfor (var e in errors) {\n if (errors.hasOwnProperty(e))\n module.exports[e] = errors[e];\n}\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar assert = require('assert');\nvar Buffer = require('safer-buffer').Buffer;\n\nvar ASN1 = require('./types');\nvar errors = require('./errors');\n\n\n// --- Globals\n\nvar newInvalidAsn1Error = errors.newInvalidAsn1Error;\n\n\n\n// --- API\n\nfunction Reader(data) {\n if (!data || !Buffer.isBuffer(data))\n throw new TypeError('data must be a node Buffer');\n\n this._buf = data;\n this._size = data.length;\n\n // These hold the \"current\" state\n this._len = 0;\n this._offset = 0;\n}\n\nObject.defineProperty(Reader.prototype, 'length', {\n enumerable: true,\n get: function () { return (this._len); }\n});\n\nObject.defineProperty(Reader.prototype, 'offset', {\n enumerable: true,\n get: function () { return (this._offset); }\n});\n\nObject.defineProperty(Reader.prototype, 'remain', {\n get: function () { return (this._size - this._offset); }\n});\n\nObject.defineProperty(Reader.prototype, 'buffer', {\n get: function () { return (this._buf.slice(this._offset)); }\n});\n\n\n/**\n * Reads a single byte and advances offset; you can pass in `true` to make this\n * a \"peek\" operation (i.e., get the byte, but don't advance the offset).\n *\n * @param {Boolean} peek true means don't move offset.\n * @return {Number} the next byte, null if not enough data.\n */\nReader.prototype.readByte = function (peek) {\n if (this._size - this._offset < 1)\n return null;\n\n var b = this._buf[this._offset] & 0xff;\n\n if (!peek)\n this._offset += 1;\n\n return b;\n};\n\n\nReader.prototype.peek = function () {\n return this.readByte(true);\n};\n\n\n/**\n * Reads a (potentially) variable length off the BER buffer. This call is\n * not really meant to be called directly, as callers have to manipulate\n * the internal buffer afterwards.\n *\n * As a result of this call, you can call `Reader.length`, until the\n * next thing called that does a readLength.\n *\n * @return {Number} the amount of offset to advance the buffer.\n * @throws {InvalidAsn1Error} on bad ASN.1\n */\nReader.prototype.readLength = function (offset) {\n if (offset === undefined)\n offset = this._offset;\n\n if (offset >= this._size)\n return null;\n\n var lenB = this._buf[offset++] & 0xff;\n if (lenB === null)\n return null;\n\n if ((lenB & 0x80) === 0x80) {\n lenB &= 0x7f;\n\n if (lenB === 0)\n throw newInvalidAsn1Error('Indefinite length not supported');\n\n if (lenB > 4)\n throw newInvalidAsn1Error('encoding too long');\n\n if (this._size - offset < lenB)\n return null;\n\n this._len = 0;\n for (var i = 0; i < lenB; i++)\n this._len = (this._len << 8) + (this._buf[offset++] & 0xff);\n\n } else {\n // Wasn't a variable length\n this._len = lenB;\n }\n\n return offset;\n};\n\n\n/**\n * Parses the next sequence in this BER buffer.\n *\n * To get the length of the sequence, call `Reader.length`.\n *\n * @return {Number} the sequence's tag.\n */\nReader.prototype.readSequence = function (tag) {\n var seq = this.peek();\n if (seq === null)\n return null;\n if (tag !== undefined && tag !== seq)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + seq.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n if (o === null)\n return null;\n\n this._offset = o;\n return seq;\n};\n\n\nReader.prototype.readInt = function () {\n return this._readTag(ASN1.Integer);\n};\n\n\nReader.prototype.readBoolean = function () {\n return (this._readTag(ASN1.Boolean) === 0 ? false : true);\n};\n\n\nReader.prototype.readEnumeration = function () {\n return this._readTag(ASN1.Enumeration);\n};\n\n\nReader.prototype.readString = function (tag, retbuf) {\n if (!tag)\n tag = ASN1.OctetString;\n\n var b = this.peek();\n if (b === null)\n return null;\n\n if (b !== tag)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + b.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n\n if (o === null)\n return null;\n\n if (this.length > this._size - o)\n return null;\n\n this._offset = o;\n\n if (this.length === 0)\n return retbuf ? Buffer.alloc(0) : '';\n\n var str = this._buf.slice(this._offset, this._offset + this.length);\n this._offset += this.length;\n\n return retbuf ? str : str.toString('utf8');\n};\n\nReader.prototype.readOID = function (tag) {\n if (!tag)\n tag = ASN1.OID;\n\n var b = this.readString(tag, true);\n if (b === null)\n return null;\n\n var values = [];\n var value = 0;\n\n for (var i = 0; i < b.length; i++) {\n var byte = b[i] & 0xff;\n\n value <<= 7;\n value += byte & 0x7f;\n if ((byte & 0x80) === 0) {\n values.push(value);\n value = 0;\n }\n }\n\n value = values.shift();\n values.unshift(value % 40);\n values.unshift((value / 40) >> 0);\n\n return values.join('.');\n};\n\n\nReader.prototype._readTag = function (tag) {\n assert.ok(tag !== undefined);\n\n var b = this.peek();\n\n if (b === null)\n return null;\n\n if (b !== tag)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + b.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n if (o === null)\n return null;\n\n if (this.length > 4)\n throw newInvalidAsn1Error('Integer too long: ' + this.length);\n\n if (this.length > this._size - o)\n return null;\n this._offset = o;\n\n var fb = this._buf[this._offset];\n var value = 0;\n\n for (var i = 0; i < this.length; i++) {\n value <<= 8;\n value |= (this._buf[this._offset++] & 0xff);\n }\n\n if ((fb & 0x80) === 0x80 && i !== 4)\n value -= (1 << (i * 8));\n\n return value >> 0;\n};\n\n\n\n// --- Exported API\n\nmodule.exports = Reader;\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n\nmodule.exports = {\n EOC: 0,\n Boolean: 1,\n Integer: 2,\n BitString: 3,\n OctetString: 4,\n Null: 5,\n OID: 6,\n ObjectDescriptor: 7,\n External: 8,\n Real: 9, // float\n Enumeration: 10,\n PDV: 11,\n Utf8String: 12,\n RelativeOID: 13,\n Sequence: 16,\n Set: 17,\n NumericString: 18,\n PrintableString: 19,\n T61String: 20,\n VideotexString: 21,\n IA5String: 22,\n UTCTime: 23,\n GeneralizedTime: 24,\n GraphicString: 25,\n VisibleString: 26,\n GeneralString: 28,\n UniversalString: 29,\n CharacterString: 30,\n BMPString: 31,\n Constructor: 32,\n Context: 128\n};\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar assert = require('assert');\nvar Buffer = require('safer-buffer').Buffer;\nvar ASN1 = require('./types');\nvar errors = require('./errors');\n\n\n// --- Globals\n\nvar newInvalidAsn1Error = errors.newInvalidAsn1Error;\n\nvar DEFAULT_OPTS = {\n size: 1024,\n growthFactor: 8\n};\n\n\n// --- Helpers\n\nfunction merge(from, to) {\n assert.ok(from);\n assert.equal(typeof (from), 'object');\n assert.ok(to);\n assert.equal(typeof (to), 'object');\n\n var keys = Object.getOwnPropertyNames(from);\n keys.forEach(function (key) {\n if (to[key])\n return;\n\n var value = Object.getOwnPropertyDescriptor(from, key);\n Object.defineProperty(to, key, value);\n });\n\n return to;\n}\n\n\n\n// --- API\n\nfunction Writer(options) {\n options = merge(DEFAULT_OPTS, options || {});\n\n this._buf = Buffer.alloc(options.size || 1024);\n this._size = this._buf.length;\n this._offset = 0;\n this._options = options;\n\n // A list of offsets in the buffer where we need to insert\n // sequence tag/len pairs.\n this._seq = [];\n}\n\nObject.defineProperty(Writer.prototype, 'buffer', {\n get: function () {\n if (this._seq.length)\n throw newInvalidAsn1Error(this._seq.length + ' unended sequence(s)');\n\n return (this._buf.slice(0, this._offset));\n }\n});\n\nWriter.prototype.writeByte = function (b) {\n if (typeof (b) !== 'number')\n throw new TypeError('argument must be a Number');\n\n this._ensure(1);\n this._buf[this._offset++] = b;\n};\n\n\nWriter.prototype.writeInt = function (i, tag) {\n if (typeof (i) !== 'number')\n throw new TypeError('argument must be a Number');\n if (typeof (tag) !== 'number')\n tag = ASN1.Integer;\n\n var sz = 4;\n\n while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&\n (sz > 1)) {\n sz--;\n i <<= 8;\n }\n\n if (sz > 4)\n throw newInvalidAsn1Error('BER ints cannot be > 0xffffffff');\n\n this._ensure(2 + sz);\n this._buf[this._offset++] = tag;\n this._buf[this._offset++] = sz;\n\n while (sz-- > 0) {\n this._buf[this._offset++] = ((i & 0xff000000) >>> 24);\n i <<= 8;\n }\n\n};\n\n\nWriter.prototype.writeNull = function () {\n this.writeByte(ASN1.Null);\n this.writeByte(0x00);\n};\n\n\nWriter.prototype.writeEnumeration = function (i, tag) {\n if (typeof (i) !== 'number')\n throw new TypeError('argument must be a Number');\n if (typeof (tag) !== 'number')\n tag = ASN1.Enumeration;\n\n return this.writeInt(i, tag);\n};\n\n\nWriter.prototype.writeBoolean = function (b, tag) {\n if (typeof (b) !== 'boolean')\n throw new TypeError('argument must be a Boolean');\n if (typeof (tag) !== 'number')\n tag = ASN1.Boolean;\n\n this._ensure(3);\n this._buf[this._offset++] = tag;\n this._buf[this._offset++] = 0x01;\n this._buf[this._offset++] = b ? 0xff : 0x00;\n};\n\n\nWriter.prototype.writeString = function (s, tag) {\n if (typeof (s) !== 'string')\n throw new TypeError('argument must be a string (was: ' + typeof (s) + ')');\n if (typeof (tag) !== 'number')\n tag = ASN1.OctetString;\n\n var len = Buffer.byteLength(s);\n this.writeByte(tag);\n this.writeLength(len);\n if (len) {\n this._ensure(len);\n this._buf.write(s, this._offset);\n this._offset += len;\n }\n};\n\n\nWriter.prototype.writeBuffer = function (buf, tag) {\n if (typeof (tag) !== 'number')\n throw new TypeError('tag must be a number');\n if (!Buffer.isBuffer(buf))\n throw new TypeError('argument must be a buffer');\n\n this.writeByte(tag);\n this.writeLength(buf.length);\n this._ensure(buf.length);\n buf.copy(this._buf, this._offset, 0, buf.length);\n this._offset += buf.length;\n};\n\n\nWriter.prototype.writeStringArray = function (strings) {\n if ((!strings instanceof Array))\n throw new TypeError('argument must be an Array[String]');\n\n var self = this;\n strings.forEach(function (s) {\n self.writeString(s);\n });\n};\n\n// This is really to solve DER cases, but whatever for now\nWriter.prototype.writeOID = function (s, tag) {\n if (typeof (s) !== 'string')\n throw new TypeError('argument must be a string');\n if (typeof (tag) !== 'number')\n tag = ASN1.OID;\n\n if (!/^([0-9]+\\.){3,}[0-9]+$/.test(s))\n throw new Error('argument is not a valid OID string');\n\n function encodeOctet(bytes, octet) {\n if (octet < 128) {\n bytes.push(octet);\n } else if (octet < 16384) {\n bytes.push((octet >>> 7) | 0x80);\n bytes.push(octet & 0x7F);\n } else if (octet < 2097152) {\n bytes.push((octet >>> 14) | 0x80);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n } else if (octet < 268435456) {\n bytes.push((octet >>> 21) | 0x80);\n bytes.push(((octet >>> 14) | 0x80) & 0xFF);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n } else {\n bytes.push(((octet >>> 28) | 0x80) & 0xFF);\n bytes.push(((octet >>> 21) | 0x80) & 0xFF);\n bytes.push(((octet >>> 14) | 0x80) & 0xFF);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n }\n }\n\n var tmp = s.split('.');\n var bytes = [];\n bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));\n tmp.slice(2).forEach(function (b) {\n encodeOctet(bytes, parseInt(b, 10));\n });\n\n var self = this;\n this._ensure(2 + bytes.length);\n this.writeByte(tag);\n this.writeLength(bytes.length);\n bytes.forEach(function (b) {\n self.writeByte(b);\n });\n};\n\n\nWriter.prototype.writeLength = function (len) {\n if (typeof (len) !== 'number')\n throw new TypeError('argument must be a Number');\n\n this._ensure(4);\n\n if (len <= 0x7f) {\n this._buf[this._offset++] = len;\n } else if (len <= 0xff) {\n this._buf[this._offset++] = 0x81;\n this._buf[this._offset++] = len;\n } else if (len <= 0xffff) {\n this._buf[this._offset++] = 0x82;\n this._buf[this._offset++] = len >> 8;\n this._buf[this._offset++] = len;\n } else if (len <= 0xffffff) {\n this._buf[this._offset++] = 0x83;\n this._buf[this._offset++] = len >> 16;\n this._buf[this._offset++] = len >> 8;\n this._buf[this._offset++] = len;\n } else {\n throw newInvalidAsn1Error('Length too long (> 4 bytes)');\n }\n};\n\nWriter.prototype.startSequence = function (tag) {\n if (typeof (tag) !== 'number')\n tag = ASN1.Sequence | ASN1.Constructor;\n\n this.writeByte(tag);\n this._seq.push(this._offset);\n this._ensure(3);\n this._offset += 3;\n};\n\n\nWriter.prototype.endSequence = function () {\n var seq = this._seq.pop();\n var start = seq + 3;\n var len = this._offset - start;\n\n if (len <= 0x7f) {\n this._shift(start, len, -2);\n this._buf[seq] = len;\n } else if (len <= 0xff) {\n this._shift(start, len, -1);\n this._buf[seq] = 0x81;\n this._buf[seq + 1] = len;\n } else if (len <= 0xffff) {\n this._buf[seq] = 0x82;\n this._buf[seq + 1] = len >> 8;\n this._buf[seq + 2] = len;\n } else if (len <= 0xffffff) {\n this._shift(start, len, 1);\n this._buf[seq] = 0x83;\n this._buf[seq + 1] = len >> 16;\n this._buf[seq + 2] = len >> 8;\n this._buf[seq + 3] = len;\n } else {\n throw newInvalidAsn1Error('Sequence too long');\n }\n};\n\n\nWriter.prototype._shift = function (start, len, shift) {\n assert.ok(start !== undefined);\n assert.ok(len !== undefined);\n assert.ok(shift);\n\n this._buf.copy(this._buf, start + shift, start, start + len);\n this._offset += shift;\n};\n\nWriter.prototype._ensure = function (len) {\n assert.ok(len);\n\n if (this._size - this._offset < len) {\n var sz = this._size * this._options.growthFactor;\n if (sz - this._offset < len)\n sz += len;\n\n var buf = Buffer.alloc(sz);\n\n this._buf.copy(buf, 0, 0, this._offset);\n this._buf = buf;\n this._size = sz;\n }\n};\n\n\n\n// --- Exported API\n\nmodule.exports = Writer;\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n// If you have no idea what ASN.1 or BER is, see this:\n// ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc\n\nvar Ber = require('./ber/index');\n\n\n\n// --- Exported API\n\nmodule.exports = {\n\n Ber: Ber,\n\n BerReader: Ber.Reader,\n\n BerWriter: Ber.Writer\n\n};\n","module.exports = require('./lib/axios');","'use strict';\n\nvar utils = require('./../utils');\nvar settle = require('./../core/settle');\nvar buildFullPath = require('../core/buildFullPath');\nvar buildURL = require('./../helpers/buildURL');\nvar http = require('http');\nvar https = require('https');\nvar httpFollow = require('follow-redirects').http;\nvar httpsFollow = require('follow-redirects').https;\nvar url = require('url');\nvar zlib = require('zlib');\nvar VERSION = require('./../env/data').version;\nvar createError = require('../core/createError');\nvar enhanceError = require('../core/enhanceError');\nvar defaults = require('../defaults');\nvar Cancel = require('../cancel/Cancel');\n\nvar isHttps = /https:?/;\n\n/**\n *\n * @param {http.ClientRequestArgs} options\n * @param {AxiosProxyConfig} proxy\n * @param {string} location\n */\nfunction setProxy(options, proxy, location) {\n options.hostname = proxy.host;\n options.host = proxy.host;\n options.port = proxy.port;\n options.path = location;\n\n // Basic proxy authorization\n if (proxy.auth) {\n var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');\n options.headers['Proxy-Authorization'] = 'Basic ' + base64;\n }\n\n // If a proxy is used, any redirects must also pass through the proxy\n options.beforeRedirect = function beforeRedirect(redirection) {\n redirection.headers.host = redirection.host;\n setProxy(redirection, proxy, redirection.href);\n };\n}\n\n/*eslint consistent-return:0*/\nmodule.exports = function httpAdapter(config) {\n return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {\n var onCanceled;\n function done() {\n if (config.cancelToken) {\n config.cancelToken.unsubscribe(onCanceled);\n }\n\n if (config.signal) {\n config.signal.removeEventListener('abort', onCanceled);\n }\n }\n var resolve = function resolve(value) {\n done();\n resolvePromise(value);\n };\n var reject = function reject(value) {\n done();\n rejectPromise(value);\n };\n var data = config.data;\n var headers = config.headers;\n var headerNames = {};\n\n Object.keys(headers).forEach(function storeLowerName(name) {\n headerNames[name.toLowerCase()] = name;\n });\n\n // Set User-Agent (required by some servers)\n // See https://github.com/axios/axios/issues/69\n if ('user-agent' in headerNames) {\n // User-Agent is specified; handle case where no UA header is desired\n if (!headers[headerNames['user-agent']]) {\n delete headers[headerNames['user-agent']];\n }\n // Otherwise, use specified value\n } else {\n // Only set header if it hasn't been set in config\n headers['User-Agent'] = 'axios/' + VERSION;\n }\n\n if (data && !utils.isStream(data)) {\n if (Buffer.isBuffer(data)) {\n // Nothing to do...\n } else if (utils.isArrayBuffer(data)) {\n data = Buffer.from(new Uint8Array(data));\n } else if (utils.isString(data)) {\n data = Buffer.from(data, 'utf-8');\n } else {\n return reject(createError(\n 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',\n config\n ));\n }\n\n // Add Content-Length header if data exists\n if (!headerNames['content-length']) {\n headers['Content-Length'] = data.length;\n }\n }\n\n // HTTP basic authentication\n var auth = undefined;\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password || '';\n auth = username + ':' + password;\n }\n\n // Parse url\n var fullPath = buildFullPath(config.baseURL, config.url);\n var parsed = url.parse(fullPath);\n var protocol = parsed.protocol || 'http:';\n\n if (!auth && parsed.auth) {\n var urlAuth = parsed.auth.split(':');\n var urlUsername = urlAuth[0] || '';\n var urlPassword = urlAuth[1] || '';\n auth = urlUsername + ':' + urlPassword;\n }\n\n if (auth && headerNames.authorization) {\n delete headers[headerNames.authorization];\n }\n\n var isHttpsRequest = isHttps.test(protocol);\n var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;\n\n var options = {\n path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\\?/, ''),\n method: config.method.toUpperCase(),\n headers: headers,\n agent: agent,\n agents: { http: config.httpAgent, https: config.httpsAgent },\n auth: auth\n };\n\n if (config.socketPath) {\n options.socketPath = config.socketPath;\n } else {\n options.hostname = parsed.hostname;\n options.port = parsed.port;\n }\n\n var proxy = config.proxy;\n if (!proxy && proxy !== false) {\n var proxyEnv = protocol.slice(0, -1) + '_proxy';\n var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];\n if (proxyUrl) {\n var parsedProxyUrl = url.parse(proxyUrl);\n var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;\n var shouldProxy = true;\n\n if (noProxyEnv) {\n var noProxy = noProxyEnv.split(',').map(function trim(s) {\n return s.trim();\n });\n\n shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {\n if (!proxyElement) {\n return false;\n }\n if (proxyElement === '*') {\n return true;\n }\n if (proxyElement[0] === '.' &&\n parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {\n return true;\n }\n\n return parsed.hostname === proxyElement;\n });\n }\n\n if (shouldProxy) {\n proxy = {\n host: parsedProxyUrl.hostname,\n port: parsedProxyUrl.port,\n protocol: parsedProxyUrl.protocol\n };\n\n if (parsedProxyUrl.auth) {\n var proxyUrlAuth = parsedProxyUrl.auth.split(':');\n proxy.auth = {\n username: proxyUrlAuth[0],\n password: proxyUrlAuth[1]\n };\n }\n }\n }\n }\n\n if (proxy) {\n options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');\n setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);\n }\n\n var transport;\n var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);\n if (config.transport) {\n transport = config.transport;\n } else if (config.maxRedirects === 0) {\n transport = isHttpsProxy ? https : http;\n } else {\n if (config.maxRedirects) {\n options.maxRedirects = config.maxRedirects;\n }\n transport = isHttpsProxy ? httpsFollow : httpFollow;\n }\n\n if (config.maxBodyLength > -1) {\n options.maxBodyLength = config.maxBodyLength;\n }\n\n if (config.insecureHTTPParser) {\n options.insecureHTTPParser = config.insecureHTTPParser;\n }\n\n // Create the request\n var req = transport.request(options, function handleResponse(res) {\n if (req.aborted) return;\n\n // uncompress the response body transparently if required\n var stream = res;\n\n // return the last request in case of redirects\n var lastRequest = res.req || req;\n\n\n // if no content, is HEAD request or decompress disabled we should not decompress\n if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {\n switch (res.headers['content-encoding']) {\n /*eslint default-case:0*/\n case 'gzip':\n case 'compress':\n case 'deflate':\n // add the unzipper to the body stream processing pipeline\n stream = stream.pipe(zlib.createUnzip());\n\n // remove the content-encoding in order to not confuse downstream operations\n delete res.headers['content-encoding'];\n break;\n }\n }\n\n var response = {\n status: res.statusCode,\n statusText: res.statusMessage,\n headers: res.headers,\n config: config,\n request: lastRequest\n };\n\n if (config.responseType === 'stream') {\n response.data = stream;\n settle(resolve, reject, response);\n } else {\n var responseBuffer = [];\n var totalResponseBytes = 0;\n stream.on('data', function handleStreamData(chunk) {\n responseBuffer.push(chunk);\n totalResponseBytes += chunk.length;\n\n // make sure the content length is not over the maxContentLength if specified\n if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {\n stream.destroy();\n reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',\n config, null, lastRequest));\n }\n });\n\n stream.on('error', function handleStreamError(err) {\n if (req.aborted) return;\n reject(enhanceError(err, config, null, lastRequest));\n });\n\n stream.on('end', function handleStreamEnd() {\n var responseData = Buffer.concat(responseBuffer);\n if (config.responseType !== 'arraybuffer') {\n responseData = responseData.toString(config.responseEncoding);\n if (!config.responseEncoding || config.responseEncoding === 'utf8') {\n responseData = utils.stripBOM(responseData);\n }\n }\n\n response.data = responseData;\n settle(resolve, reject, response);\n });\n }\n });\n\n // Handle errors\n req.on('error', function handleRequestError(err) {\n if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;\n reject(enhanceError(err, config, null, req));\n });\n\n // Handle request timeout\n if (config.timeout) {\n // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.\n var timeout = parseInt(config.timeout, 10);\n\n if (isNaN(timeout)) {\n reject(createError(\n 'error trying to parse `config.timeout` to int',\n config,\n 'ERR_PARSE_TIMEOUT',\n req\n ));\n\n return;\n }\n\n // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.\n // And timer callback will be fired, and abort() will be invoked before connection, then get \"socket hang up\" and code ECONNRESET.\n // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.\n // And then these socket which be hang up will devoring CPU little by little.\n // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.\n req.setTimeout(timeout, function handleRequestTimeout() {\n req.abort();\n var transitional = config.transitional || defaults.transitional;\n reject(createError(\n 'timeout of ' + timeout + 'ms exceeded',\n config,\n transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',\n req\n ));\n });\n }\n\n if (config.cancelToken || config.signal) {\n // Handle cancellation\n // eslint-disable-next-line func-names\n onCanceled = function(cancel) {\n if (req.aborted) return;\n\n req.abort();\n reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);\n };\n\n config.cancelToken && config.cancelToken.subscribe(onCanceled);\n if (config.signal) {\n config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);\n }\n }\n\n\n // Send the request\n if (utils.isStream(data)) {\n data.on('error', function handleStreamError(err) {\n reject(enhanceError(err, config, null, req));\n }).pipe(req);\n } else {\n req.end(data);\n }\n });\n};\n","'use strict';\n\nvar utils = require('./../utils');\nvar settle = require('./../core/settle');\nvar cookies = require('./../helpers/cookies');\nvar buildURL = require('./../helpers/buildURL');\nvar buildFullPath = require('../core/buildFullPath');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar createError = require('../core/createError');\nvar defaults = require('../defaults');\nvar Cancel = require('../cancel/Cancel');\n\nmodule.exports = function xhrAdapter(config) {\n return new Promise(function dispatchXhrRequest(resolve, reject) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n var responseType = config.responseType;\n var onCanceled;\n function done() {\n if (config.cancelToken) {\n config.cancelToken.unsubscribe(onCanceled);\n }\n\n if (config.signal) {\n config.signal.removeEventListener('abort', onCanceled);\n }\n }\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n var fullPath = buildFullPath(config.baseURL, config.url);\n request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n function onloadend() {\n if (!request) {\n return;\n }\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = !responseType || responseType === 'text' || responseType === 'json' ?\n request.responseText : request.response;\n var response = {\n data: responseData,\n status: request.status,\n statusText: request.statusText,\n headers: responseHeaders,\n config: config,\n request: request\n };\n\n settle(function _resolve(value) {\n resolve(value);\n done();\n }, function _reject(err) {\n reject(err);\n done();\n }, response);\n\n // Clean up request\n request = null;\n }\n\n if ('onloadend' in request) {\n // Use onloadend if available\n request.onloadend = onloadend;\n } else {\n // Listen for ready state to emulate onloadend\n request.onreadystatechange = function handleLoad() {\n if (!request || request.readyState !== 4) {\n return;\n }\n\n // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n // With one exception: request that using file: protocol, most browsers\n // will return status as 0 even though it's a successful request\n if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n return;\n }\n // readystate handler is calling before onerror or ontimeout handlers,\n // so we should call onloadend on the next 'tick'\n setTimeout(onloadend);\n };\n }\n\n // Handle browser request cancellation (as opposed to a manual cancellation)\n request.onabort = function handleAbort() {\n if (!request) {\n return;\n }\n\n reject(createError('Request aborted', config, 'ECONNABORTED', request));\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(createError('Network Error', config, null, request));\n\n // Clean up request\n request = null;\n };\n\n // Handle timeout\n request.ontimeout = function handleTimeout() {\n var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';\n var transitional = config.transitional || defaults.transitional;\n if (config.timeoutErrorMessage) {\n timeoutErrorMessage = config.timeoutErrorMessage;\n }\n reject(createError(\n timeoutErrorMessage,\n config,\n transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',\n request));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n // Add xsrf header\n var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (!utils.isUndefined(config.withCredentials)) {\n request.withCredentials = !!config.withCredentials;\n }\n\n // Add responseType to request if needed\n if (responseType && responseType !== 'json') {\n request.responseType = config.responseType;\n }\n\n // Handle progress if needed\n if (typeof config.onDownloadProgress === 'function') {\n request.addEventListener('progress', config.onDownloadProgress);\n }\n\n // Not all browsers support upload events\n if (typeof config.onUploadProgress === 'function' && request.upload) {\n request.upload.addEventListener('progress', config.onUploadProgress);\n }\n\n if (config.cancelToken || config.signal) {\n // Handle cancellation\n // eslint-disable-next-line func-names\n onCanceled = function(cancel) {\n if (!request) {\n return;\n }\n reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);\n request.abort();\n request = null;\n };\n\n config.cancelToken && config.cancelToken.subscribe(onCanceled);\n if (config.signal) {\n config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);\n }\n }\n\n if (!requestData) {\n requestData = null;\n }\n\n // Send the request\n request.send(requestData);\n });\n};\n","'use strict';\n\nvar utils = require('./utils');\nvar bind = require('./helpers/bind');\nvar Axios = require('./core/Axios');\nvar mergeConfig = require('./core/mergeConfig');\nvar defaults = require('./defaults');\n\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n * @return {Axios} A new instance of Axios\n */\nfunction createInstance(defaultConfig) {\n var context = new Axios(defaultConfig);\n var instance = bind(Axios.prototype.request, context);\n\n // Copy axios.prototype to instance\n utils.extend(instance, Axios.prototype, context);\n\n // Copy context to instance\n utils.extend(instance, context);\n\n // Factory for creating new instances\n instance.create = function create(instanceConfig) {\n return createInstance(mergeConfig(defaultConfig, instanceConfig));\n };\n\n return instance;\n}\n\n// Create the default instance to be exported\nvar axios = createInstance(defaults);\n\n// Expose Axios class to allow class inheritance\naxios.Axios = Axios;\n\n// Expose Cancel & CancelToken\naxios.Cancel = require('./cancel/Cancel');\naxios.CancelToken = require('./cancel/CancelToken');\naxios.isCancel = require('./cancel/isCancel');\naxios.VERSION = require('./env/data').version;\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\n// Expose isAxiosError\naxios.isAxiosError = require('./helpers/isAxiosError');\n\nmodule.exports = axios;\n\n// Allow use of default import syntax in TypeScript\nmodule.exports.default = axios;\n","'use strict';\n\n/**\n * A `Cancel` is an object that is thrown when an operation is canceled.\n *\n * @class\n * @param {string=} message The message.\n */\nfunction Cancel(message) {\n this.message = message;\n}\n\nCancel.prototype.toString = function toString() {\n return 'Cancel' + (this.message ? ': ' + this.message : '');\n};\n\nCancel.prototype.__CANCEL__ = true;\n\nmodule.exports = Cancel;\n","'use strict';\n\nvar Cancel = require('./Cancel');\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @class\n * @param {Function} executor The executor function.\n */\nfunction CancelToken(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n var resolvePromise;\n\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n\n var token = this;\n\n // eslint-disable-next-line func-names\n this.promise.then(function(cancel) {\n if (!token._listeners) return;\n\n var i;\n var l = token._listeners.length;\n\n for (i = 0; i < l; i++) {\n token._listeners[i](cancel);\n }\n token._listeners = null;\n });\n\n // eslint-disable-next-line func-names\n this.promise.then = function(onfulfilled) {\n var _resolve;\n // eslint-disable-next-line func-names\n var promise = new Promise(function(resolve) {\n token.subscribe(resolve);\n _resolve = resolve;\n }).then(onfulfilled);\n\n promise.cancel = function reject() {\n token.unsubscribe(_resolve);\n };\n\n return promise;\n };\n\n executor(function cancel(message) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new Cancel(message);\n resolvePromise(token.reason);\n });\n}\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n};\n\n/**\n * Subscribe to the cancel signal\n */\n\nCancelToken.prototype.subscribe = function subscribe(listener) {\n if (this.reason) {\n listener(this.reason);\n return;\n }\n\n if (this._listeners) {\n this._listeners.push(listener);\n } else {\n this._listeners = [listener];\n }\n};\n\n/**\n * Unsubscribe from the cancel signal\n */\n\nCancelToken.prototype.unsubscribe = function unsubscribe(listener) {\n if (!this._listeners) {\n return;\n }\n var index = this._listeners.indexOf(listener);\n if (index !== -1) {\n this._listeners.splice(index, 1);\n }\n};\n\n/**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\nCancelToken.source = function source() {\n var cancel;\n var token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token: token,\n cancel: cancel\n };\n};\n\nmodule.exports = CancelToken;\n","'use strict';\n\nmodule.exports = function isCancel(value) {\n return !!(value && value.__CANCEL__);\n};\n","'use strict';\n\nvar utils = require('./../utils');\nvar buildURL = require('../helpers/buildURL');\nvar InterceptorManager = require('./InterceptorManager');\nvar dispatchRequest = require('./dispatchRequest');\nvar mergeConfig = require('./mergeConfig');\nvar validator = require('../helpers/validator');\n\nvar validators = validator.validators;\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n */\nfunction Axios(instanceConfig) {\n this.defaults = instanceConfig;\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\n/**\n * Dispatch a request\n *\n * @param {Object} config The config specific for this request (merged with this.defaults)\n */\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = arguments[1] || {};\n config.url = arguments[0];\n } else {\n config = config || {};\n }\n\n config = mergeConfig(this.defaults, config);\n\n // Set config.method\n if (config.method) {\n config.method = config.method.toLowerCase();\n } else if (this.defaults.method) {\n config.method = this.defaults.method.toLowerCase();\n } else {\n config.method = 'get';\n }\n\n var transitional = config.transitional;\n\n if (transitional !== undefined) {\n validator.assertOptions(transitional, {\n silentJSONParsing: validators.transitional(validators.boolean),\n forcedJSONParsing: validators.transitional(validators.boolean),\n clarifyTimeoutError: validators.transitional(validators.boolean)\n }, false);\n }\n\n // filter out skipped interceptors\n var requestInterceptorChain = [];\n var synchronousRequestInterceptors = true;\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {\n return;\n }\n\n synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;\n\n requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n var responseInterceptorChain = [];\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n var promise;\n\n if (!synchronousRequestInterceptors) {\n var chain = [dispatchRequest, undefined];\n\n Array.prototype.unshift.apply(chain, requestInterceptorChain);\n chain = chain.concat(responseInterceptorChain);\n\n promise = Promise.resolve(config);\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n }\n\n\n var newConfig = config;\n while (requestInterceptorChain.length) {\n var onFulfilled = requestInterceptorChain.shift();\n var onRejected = requestInterceptorChain.shift();\n try {\n newConfig = onFulfilled(newConfig);\n } catch (error) {\n onRejected(error);\n break;\n }\n }\n\n try {\n promise = dispatchRequest(newConfig);\n } catch (error) {\n return Promise.reject(error);\n }\n\n while (responseInterceptorChain.length) {\n promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());\n }\n\n return promise;\n};\n\nAxios.prototype.getUri = function getUri(config) {\n config = mergeConfig(this.defaults, config);\n return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\\?/, '');\n};\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: (config || {}).data\n }));\n };\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n});\n\nmodule.exports = Axios;\n","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected, options) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected,\n synchronous: options ? options.synchronous : false,\n runWhen: options ? options.runWhen : null\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n","'use strict';\n\nvar isAbsoluteURL = require('../helpers/isAbsoluteURL');\nvar combineURLs = require('../helpers/combineURLs');\n\n/**\n * Creates a new URL by combining the baseURL with the requestedURL,\n * only when the requestedURL is not already an absolute URL.\n * If the requestURL is absolute, this function returns the requestedURL untouched.\n *\n * @param {string} baseURL The base URL\n * @param {string} requestedURL Absolute or relative URL to combine\n * @returns {string} The combined full path\n */\nmodule.exports = function buildFullPath(baseURL, requestedURL) {\n if (baseURL && !isAbsoluteURL(requestedURL)) {\n return combineURLs(baseURL, requestedURL);\n }\n return requestedURL;\n};\n","'use strict';\n\nvar enhanceError = require('./enhanceError');\n\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The created error.\n */\nmodule.exports = function createError(message, config, code, request, response) {\n var error = new Error(message);\n return enhanceError(error, config, code, request, response);\n};\n","'use strict';\n\nvar utils = require('./../utils');\nvar transformData = require('./transformData');\nvar isCancel = require('../cancel/isCancel');\nvar defaults = require('../defaults');\nvar Cancel = require('../cancel/Cancel');\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nfunction throwIfCancellationRequested(config) {\n if (config.cancelToken) {\n config.cancelToken.throwIfRequested();\n }\n\n if (config.signal && config.signal.aborted) {\n throw new Cancel('canceled');\n }\n}\n\n/**\n * Dispatch a request to the server using the configured adapter.\n *\n * @param {object} config The config that is to be used for the request\n * @returns {Promise} The Promise to be fulfilled\n */\nmodule.exports = function dispatchRequest(config) {\n throwIfCancellationRequested(config);\n\n // Ensure headers exist\n config.headers = config.headers || {};\n\n // Transform request data\n config.data = transformData.call(\n config,\n config.data,\n config.headers,\n config.transformRequest\n );\n\n // Flatten headers\n config.headers = utils.merge(\n config.headers.common || {},\n config.headers[config.method] || {},\n config.headers\n );\n\n utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n function cleanHeaderConfig(method) {\n delete config.headers[method];\n }\n );\n\n var adapter = config.adapter || defaults.adapter;\n\n return adapter(config).then(function onAdapterResolution(response) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n response.data = transformData.call(\n config,\n response.data,\n response.headers,\n config.transformResponse\n );\n\n return response;\n }, function onAdapterRejection(reason) {\n if (!isCancel(reason)) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n if (reason && reason.response) {\n reason.response.data = transformData.call(\n config,\n reason.response.data,\n reason.response.headers,\n config.transformResponse\n );\n }\n }\n\n return Promise.reject(reason);\n });\n};\n","'use strict';\n\n/**\n * Update an Error with the specified config, error code, and response.\n *\n * @param {Error} error The error to update.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The error.\n */\nmodule.exports = function enhanceError(error, config, code, request, response) {\n error.config = config;\n if (code) {\n error.code = code;\n }\n\n error.request = request;\n error.response = response;\n error.isAxiosError = true;\n\n error.toJSON = function toJSON() {\n return {\n // Standard\n message: this.message,\n name: this.name,\n // Microsoft\n description: this.description,\n number: this.number,\n // Mozilla\n fileName: this.fileName,\n lineNumber: this.lineNumber,\n columnNumber: this.columnNumber,\n stack: this.stack,\n // Axios\n config: this.config,\n code: this.code,\n status: this.response && this.response.status ? this.response.status : null\n };\n };\n return error;\n};\n","'use strict';\n\nvar utils = require('../utils');\n\n/**\n * Config-specific merge-function which creates a new config-object\n * by merging two configuration objects together.\n *\n * @param {Object} config1\n * @param {Object} config2\n * @returns {Object} New object resulting from merging config2 to config1\n */\nmodule.exports = function mergeConfig(config1, config2) {\n // eslint-disable-next-line no-param-reassign\n config2 = config2 || {};\n var config = {};\n\n function getMergedValue(target, source) {\n if (utils.isPlainObject(target) && utils.isPlainObject(source)) {\n return utils.merge(target, source);\n } else if (utils.isPlainObject(source)) {\n return utils.merge({}, source);\n } else if (utils.isArray(source)) {\n return source.slice();\n }\n return source;\n }\n\n // eslint-disable-next-line consistent-return\n function mergeDeepProperties(prop) {\n if (!utils.isUndefined(config2[prop])) {\n return getMergedValue(config1[prop], config2[prop]);\n } else if (!utils.isUndefined(config1[prop])) {\n return getMergedValue(undefined, config1[prop]);\n }\n }\n\n // eslint-disable-next-line consistent-return\n function valueFromConfig2(prop) {\n if (!utils.isUndefined(config2[prop])) {\n return getMergedValue(undefined, config2[prop]);\n }\n }\n\n // eslint-disable-next-line consistent-return\n function defaultToConfig2(prop) {\n if (!utils.isUndefined(config2[prop])) {\n return getMergedValue(undefined, config2[prop]);\n } else if (!utils.isUndefined(config1[prop])) {\n return getMergedValue(undefined, config1[prop]);\n }\n }\n\n // eslint-disable-next-line consistent-return\n function mergeDirectKeys(prop) {\n if (prop in config2) {\n return getMergedValue(config1[prop], config2[prop]);\n } else if (prop in config1) {\n return getMergedValue(undefined, config1[prop]);\n }\n }\n\n var mergeMap = {\n 'url': valueFromConfig2,\n 'method': valueFromConfig2,\n 'data': valueFromConfig2,\n 'baseURL': defaultToConfig2,\n 'transformRequest': defaultToConfig2,\n 'transformResponse': defaultToConfig2,\n 'paramsSerializer': defaultToConfig2,\n 'timeout': defaultToConfig2,\n 'timeoutMessage': defaultToConfig2,\n 'withCredentials': defaultToConfig2,\n 'adapter': defaultToConfig2,\n 'responseType': defaultToConfig2,\n 'xsrfCookieName': defaultToConfig2,\n 'xsrfHeaderName': defaultToConfig2,\n 'onUploadProgress': defaultToConfig2,\n 'onDownloadProgress': defaultToConfig2,\n 'decompress': defaultToConfig2,\n 'maxContentLength': defaultToConfig2,\n 'maxBodyLength': defaultToConfig2,\n 'transport': defaultToConfig2,\n 'httpAgent': defaultToConfig2,\n 'httpsAgent': defaultToConfig2,\n 'cancelToken': defaultToConfig2,\n 'socketPath': defaultToConfig2,\n 'responseEncoding': defaultToConfig2,\n 'validateStatus': mergeDirectKeys\n };\n\n utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {\n var merge = mergeMap[prop] || mergeDeepProperties;\n var configValue = merge(prop);\n (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);\n });\n\n return config;\n};\n","'use strict';\n\nvar createError = require('./createError');\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n */\nmodule.exports = function settle(resolve, reject, response) {\n var validateStatus = response.config.validateStatus;\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(createError(\n 'Request failed with status code ' + response.status,\n response.config,\n null,\n response.request,\n response\n ));\n }\n};\n","'use strict';\n\nvar utils = require('./../utils');\nvar defaults = require('./../defaults');\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Object|String} data The data to be transformed\n * @param {Array} headers The headers for the request or response\n * @param {Array|Function} fns A single function or Array of functions\n * @returns {*} The resulting transformed data\n */\nmodule.exports = function transformData(data, headers, fns) {\n var context = this || defaults;\n /*eslint no-param-reassign:0*/\n utils.forEach(fns, function transform(fn) {\n data = fn.call(context, data, headers);\n });\n\n return data;\n};\n","'use strict';\n\nvar utils = require('./utils');\nvar normalizeHeaderName = require('./helpers/normalizeHeaderName');\nvar enhanceError = require('./core/enhanceError');\n\nvar DEFAULT_CONTENT_TYPE = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nfunction setContentTypeIfUnset(headers, value) {\n if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n headers['Content-Type'] = value;\n }\n}\n\nfunction getDefaultAdapter() {\n var adapter;\n if (typeof XMLHttpRequest !== 'undefined') {\n // For browsers use XHR adapter\n adapter = require('./adapters/xhr');\n } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {\n // For node use HTTP adapter\n adapter = require('./adapters/http');\n }\n return adapter;\n}\n\nfunction stringifySafely(rawValue, parser, encoder) {\n if (utils.isString(rawValue)) {\n try {\n (parser || JSON.parse)(rawValue);\n return utils.trim(rawValue);\n } catch (e) {\n if (e.name !== 'SyntaxError') {\n throw e;\n }\n }\n }\n\n return (encoder || JSON.stringify)(rawValue);\n}\n\nvar defaults = {\n\n transitional: {\n silentJSONParsing: true,\n forcedJSONParsing: true,\n clarifyTimeoutError: false\n },\n\n adapter: getDefaultAdapter(),\n\n transformRequest: [function transformRequest(data, headers) {\n normalizeHeaderName(headers, 'Accept');\n normalizeHeaderName(headers, 'Content-Type');\n\n if (utils.isFormData(data) ||\n utils.isArrayBuffer(data) ||\n utils.isBuffer(data) ||\n utils.isStream(data) ||\n utils.isFile(data) ||\n utils.isBlob(data)\n ) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isURLSearchParams(data)) {\n setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n return data.toString();\n }\n if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {\n setContentTypeIfUnset(headers, 'application/json');\n return stringifySafely(data);\n }\n return data;\n }],\n\n transformResponse: [function transformResponse(data) {\n var transitional = this.transitional || defaults.transitional;\n var silentJSONParsing = transitional && transitional.silentJSONParsing;\n var forcedJSONParsing = transitional && transitional.forcedJSONParsing;\n var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';\n\n if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {\n try {\n return JSON.parse(data);\n } catch (e) {\n if (strictJSONParsing) {\n if (e.name === 'SyntaxError') {\n throw enhanceError(e, this, 'E_JSON_PARSE');\n }\n throw e;\n }\n }\n }\n\n return data;\n }],\n\n /**\n * A timeout in milliseconds to abort a request. If set to 0 (default) a\n * timeout is not created.\n */\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n\n maxContentLength: -1,\n maxBodyLength: -1,\n\n validateStatus: function validateStatus(status) {\n return status >= 200 && status < 300;\n },\n\n headers: {\n common: {\n 'Accept': 'application/json, text/plain, */*'\n }\n }\n};\n\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n defaults.headers[method] = {};\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n});\n\nmodule.exports = defaults;\n","module.exports = {\n \"version\": \"0.23.0\"\n};","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n","'use strict';\n\nvar utils = require('./../utils');\n\nfunction encode(val) {\n return encodeURIComponent(val).\n replace(/%3A/gi, ':').\n replace(/%24/g, '$').\n replace(/%2C/gi, ',').\n replace(/%20/g, '+').\n replace(/%5B/gi, '[').\n replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @returns {string} The formatted url\n */\nmodule.exports = function buildURL(url, params, paramsSerializer) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n\n var serializedParams;\n if (paramsSerializer) {\n serializedParams = paramsSerializer(params);\n } else if (utils.isURLSearchParams(params)) {\n serializedParams = params.toString();\n } else {\n var parts = [];\n\n utils.forEach(params, function serialize(val, key) {\n if (val === null || typeof val === 'undefined') {\n return;\n }\n\n if (utils.isArray(val)) {\n key = key + '[]';\n } else {\n val = [val];\n }\n\n utils.forEach(val, function parseValue(v) {\n if (utils.isDate(v)) {\n v = v.toISOString();\n } else if (utils.isObject(v)) {\n v = JSON.stringify(v);\n }\n parts.push(encode(key) + '=' + encode(v));\n });\n });\n\n serializedParams = parts.join('&');\n }\n\n if (serializedParams) {\n var hashmarkIndex = url.indexOf('#');\n if (hashmarkIndex !== -1) {\n url = url.slice(0, hashmarkIndex);\n }\n\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n};\n","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n * @returns {string} The combined URL\n */\nmodule.exports = function combineURLs(baseURL, relativeURL) {\n return relativeURL\n ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n : baseURL;\n};\n","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs support document.cookie\n (function standardBrowserEnv() {\n return {\n write: function write(name, value, expires, path, domain, secure) {\n var cookie = [];\n cookie.push(name + '=' + encodeURIComponent(value));\n\n if (utils.isNumber(expires)) {\n cookie.push('expires=' + new Date(expires).toGMTString());\n }\n\n if (utils.isString(path)) {\n cookie.push('path=' + path);\n }\n\n if (utils.isString(domain)) {\n cookie.push('domain=' + domain);\n }\n\n if (secure === true) {\n cookie.push('secure');\n }\n\n document.cookie = cookie.join('; ');\n },\n\n read: function read(name) {\n var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove: function remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n };\n })() :\n\n // Non standard browser env (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return {\n write: function write() {},\n read: function read() { return null; },\n remove: function remove() {}\n };\n })()\n);\n","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nmodule.exports = function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n};\n","'use strict';\n\n/**\n * Determines whether the payload is an error thrown by Axios\n *\n * @param {*} payload The value to test\n * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false\n */\nmodule.exports = function isAxiosError(payload) {\n return (typeof payload === 'object') && (payload.isAxiosError === true);\n};\n","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n","'use strict';\n\nvar utils = require('../utils');\n\nmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n utils.forEach(headers, function processHeader(value, name) {\n if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n headers[normalizedName] = value;\n delete headers[name];\n }\n });\n};\n","'use strict';\n\nvar utils = require('./../utils');\n\n// Headers whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\nvar ignoreDuplicateOf = [\n 'age', 'authorization', 'content-length', 'content-type', 'etag',\n 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n 'referer', 'retry-after', 'user-agent'\n];\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n return;\n }\n if (key === 'set-cookie') {\n parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n } else {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n }\n });\n\n return parsed;\n};\n","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n * @returns {Function}\n */\nmodule.exports = function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n};\n","'use strict';\n\nvar VERSION = require('../env/data').version;\n\nvar validators = {};\n\n// eslint-disable-next-line func-names\n['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {\n validators[type] = function validator(thing) {\n return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;\n };\n});\n\nvar deprecatedWarnings = {};\n\n/**\n * Transitional option validator\n * @param {function|boolean?} validator - set to false if the transitional option has been removed\n * @param {string?} version - deprecated version / removed since version\n * @param {string?} message - some message with additional info\n * @returns {function}\n */\nvalidators.transitional = function transitional(validator, version, message) {\n function formatMessage(opt, desc) {\n return '[Axios v' + VERSION + '] Transitional option \\'' + opt + '\\'' + desc + (message ? '. ' + message : '');\n }\n\n // eslint-disable-next-line func-names\n return function(value, opt, opts) {\n if (validator === false) {\n throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));\n }\n\n if (version && !deprecatedWarnings[opt]) {\n deprecatedWarnings[opt] = true;\n // eslint-disable-next-line no-console\n console.warn(\n formatMessage(\n opt,\n ' has been deprecated since v' + version + ' and will be removed in the near future'\n )\n );\n }\n\n return validator ? validator(value, opt, opts) : true;\n };\n};\n\n/**\n * Assert object's properties type\n * @param {object} options\n * @param {object} schema\n * @param {boolean?} allowUnknown\n */\n\nfunction assertOptions(options, schema, allowUnknown) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n var keys = Object.keys(options);\n var i = keys.length;\n while (i-- > 0) {\n var opt = keys[i];\n var validator = schema[opt];\n if (validator) {\n var value = options[opt];\n var result = value === undefined || validator(value, opt, options);\n if (result !== true) {\n throw new TypeError('option ' + opt + ' must be ' + result);\n }\n continue;\n }\n if (allowUnknown !== true) {\n throw Error('Unknown option ' + opt);\n }\n }\n}\n\nmodule.exports = {\n assertOptions: assertOptions,\n validators: validators\n};\n","'use strict';\n\nvar bind = require('./helpers/bind');\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is a Buffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Buffer, otherwise false\n */\nfunction isBuffer(val) {\n return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)\n && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return (typeof FormData !== 'undefined') && (val instanceof FormData);\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a plain Object\n *\n * @param {Object} val The value to test\n * @return {boolean} True if value is a plain Object, otherwise false\n */\nfunction isPlainObject(val) {\n if (toString.call(val) !== '[object Object]') {\n return false;\n }\n\n var prototype = Object.getPrototypeOf(val);\n return prototype === null || prototype === Object.prototype;\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Determine if a value is a Function\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\nfunction isFunction(val) {\n return toString.call(val) === '[object Function]';\n}\n\n/**\n * Determine if a value is a Stream\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Stream, otherwise false\n */\nfunction isStream(val) {\n return isObject(val) && isFunction(val.pipe);\n}\n\n/**\n * Determine if a value is a URLSearchParams object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n */\nfunction isURLSearchParams(val) {\n return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.trim ? str.trim() : str.replace(/^\\s+|\\s+$/g, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * navigator.product -> 'ReactNative'\n * nativescript\n * navigator.product -> 'NativeScript' or 'NS'\n */\nfunction isStandardBrowserEnv() {\n if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||\n navigator.product === 'NativeScript' ||\n navigator.product === 'NS')) {\n return false;\n }\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object') {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (isPlainObject(result[key]) && isPlainObject(val)) {\n result[key] = merge(result[key], val);\n } else if (isPlainObject(val)) {\n result[key] = merge({}, val);\n } else if (isArray(val)) {\n result[key] = val.slice();\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\n/**\n * Extends object a by mutably adding to it the properties of object b.\n *\n * @param {Object} a The object to be extended\n * @param {Object} b The object to copy properties from\n * @param {Object} thisArg The object to bind function to\n * @return {Object} The resulting value of object a\n */\nfunction extend(a, b, thisArg) {\n forEach(b, function assignValue(val, key) {\n if (thisArg && typeof val === 'function') {\n a[key] = bind(val, thisArg);\n } else {\n a[key] = val;\n }\n });\n return a;\n}\n\n/**\n * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)\n *\n * @param {string} content with BOM\n * @return {string} content value without BOM\n */\nfunction stripBOM(content) {\n if (content.charCodeAt(0) === 0xFEFF) {\n content = content.slice(1);\n }\n return content;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isBuffer: isBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isPlainObject: isPlainObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isFunction: isFunction,\n isStream: isStream,\n isURLSearchParams: isURLSearchParams,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n extend: extend,\n trim: trim,\n stripBOM: stripBOM\n};\n","'use strict';\n\nvar crypto_hash_sha512 = require('tweetnacl').lowlevel.crypto_hash;\n\n/*\n * This file is a 1:1 port from the OpenBSD blowfish.c and bcrypt_pbkdf.c. As a\n * result, it retains the original copyright and license. The two files are\n * under slightly different (but compatible) licenses, and are here combined in\n * one file.\n *\n * Credit for the actual porting work goes to:\n * Devi Mandiri \n */\n\n/*\n * The Blowfish portions are under the following license:\n *\n * Blowfish block cipher for OpenBSD\n * Copyright 1997 Niels Provos \n * All rights reserved.\n *\n * Implementation advice by David Mazieres .\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. The name of the author may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*\n * The bcrypt_pbkdf portions are under the following license:\n *\n * Copyright (c) 2013 Ted Unangst \n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n/*\n * Performance improvements (Javascript-specific):\n *\n * Copyright 2016, Joyent Inc\n * Author: Alex Wilson \n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n// Ported from OpenBSD bcrypt_pbkdf.c v1.9\n\nvar BLF_J = 0;\n\nvar Blowfish = function() {\n this.S = [\n new Uint32Array([\n 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,\n 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,\n 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,\n 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,\n 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,\n 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,\n 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,\n 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,\n 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,\n 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,\n 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,\n 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,\n 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,\n 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,\n 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,\n 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,\n 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,\n 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,\n 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,\n 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,\n 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,\n 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,\n 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,\n 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,\n 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,\n 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,\n 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,\n 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,\n 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,\n 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,\n 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,\n 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,\n 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,\n 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,\n 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,\n 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,\n 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,\n 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,\n 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,\n 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,\n 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,\n 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,\n 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,\n 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,\n 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,\n 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,\n 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,\n 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,\n 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,\n 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,\n 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,\n 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,\n 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,\n 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,\n 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,\n 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,\n 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,\n 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,\n 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,\n 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,\n 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,\n 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,\n 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,\n 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a]),\n new Uint32Array([\n 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,\n 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,\n 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,\n 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,\n 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,\n 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,\n 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,\n 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,\n 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,\n 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,\n 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,\n 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,\n 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,\n 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,\n 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,\n 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,\n 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,\n 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,\n 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,\n 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,\n 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,\n 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,\n 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,\n 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,\n 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,\n 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,\n 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,\n 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,\n 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,\n 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,\n 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,\n 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,\n 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,\n 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,\n 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,\n 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,\n 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,\n 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,\n 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,\n 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,\n 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,\n 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,\n 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,\n 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,\n 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,\n 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,\n 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,\n 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,\n 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,\n 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,\n 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,\n 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,\n 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,\n 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,\n 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,\n 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,\n 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,\n 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,\n 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,\n 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,\n 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,\n 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,\n 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,\n 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7]),\n new Uint32Array([\n 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,\n 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,\n 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,\n 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,\n 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,\n 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,\n 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,\n 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,\n 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,\n 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,\n 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,\n 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,\n 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,\n 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,\n 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,\n 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,\n 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,\n 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,\n 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,\n 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,\n 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,\n 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,\n 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,\n 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,\n 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,\n 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,\n 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,\n 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,\n 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,\n 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,\n 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,\n 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,\n 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,\n 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,\n 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,\n 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,\n 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,\n 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,\n 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,\n 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,\n 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,\n 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,\n 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,\n 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,\n 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,\n 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,\n 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,\n 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,\n 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,\n 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,\n 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,\n 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,\n 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,\n 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,\n 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,\n 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,\n 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,\n 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,\n 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,\n 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,\n 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,\n 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,\n 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,\n 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0]),\n new Uint32Array([\n 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,\n 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,\n 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,\n 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,\n 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,\n 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,\n 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,\n 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,\n 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,\n 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,\n 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,\n 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,\n 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,\n 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,\n 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,\n 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,\n 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,\n 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,\n 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,\n 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,\n 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,\n 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,\n 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,\n 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,\n 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,\n 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,\n 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,\n 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,\n 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,\n 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,\n 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,\n 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,\n 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,\n 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,\n 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,\n 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,\n 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,\n 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,\n 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,\n 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,\n 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,\n 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,\n 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,\n 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,\n 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,\n 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,\n 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,\n 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,\n 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,\n 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,\n 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,\n 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,\n 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,\n 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,\n 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,\n 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,\n 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,\n 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,\n 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,\n 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,\n 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,\n 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,\n 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,\n 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6])\n ];\n this.P = new Uint32Array([\n 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,\n 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,\n 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,\n 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,\n 0x9216d5d9, 0x8979fb1b]);\n};\n\nfunction F(S, x8, i) {\n return (((S[0][x8[i+3]] +\n S[1][x8[i+2]]) ^\n S[2][x8[i+1]]) +\n S[3][x8[i]]);\n};\n\nBlowfish.prototype.encipher = function(x, x8) {\n if (x8 === undefined) {\n x8 = new Uint8Array(x.buffer);\n if (x.byteOffset !== 0)\n x8 = x8.subarray(x.byteOffset);\n }\n x[0] ^= this.P[0];\n for (var i = 1; i < 16; i += 2) {\n x[1] ^= F(this.S, x8, 0) ^ this.P[i];\n x[0] ^= F(this.S, x8, 4) ^ this.P[i+1];\n }\n var t = x[0];\n x[0] = x[1] ^ this.P[17];\n x[1] = t;\n};\n\nBlowfish.prototype.decipher = function(x) {\n var x8 = new Uint8Array(x.buffer);\n if (x.byteOffset !== 0)\n x8 = x8.subarray(x.byteOffset);\n x[0] ^= this.P[17];\n for (var i = 16; i > 0; i -= 2) {\n x[1] ^= F(this.S, x8, 0) ^ this.P[i];\n x[0] ^= F(this.S, x8, 4) ^ this.P[i-1];\n }\n var t = x[0];\n x[0] = x[1] ^ this.P[0];\n x[1] = t;\n};\n\nfunction stream2word(data, databytes){\n var i, temp = 0;\n for (i = 0; i < 4; i++, BLF_J++) {\n if (BLF_J >= databytes) BLF_J = 0;\n temp = (temp << 8) | data[BLF_J];\n }\n return temp;\n};\n\nBlowfish.prototype.expand0state = function(key, keybytes) {\n var d = new Uint32Array(2), i, k;\n var d8 = new Uint8Array(d.buffer);\n\n for (i = 0, BLF_J = 0; i < 18; i++) {\n this.P[i] ^= stream2word(key, keybytes);\n }\n BLF_J = 0;\n\n for (i = 0; i < 18; i += 2) {\n this.encipher(d, d8);\n this.P[i] = d[0];\n this.P[i+1] = d[1];\n }\n\n for (i = 0; i < 4; i++) {\n for (k = 0; k < 256; k += 2) {\n this.encipher(d, d8);\n this.S[i][k] = d[0];\n this.S[i][k+1] = d[1];\n }\n }\n};\n\nBlowfish.prototype.expandstate = function(data, databytes, key, keybytes) {\n var d = new Uint32Array(2), i, k;\n\n for (i = 0, BLF_J = 0; i < 18; i++) {\n this.P[i] ^= stream2word(key, keybytes);\n }\n\n for (i = 0, BLF_J = 0; i < 18; i += 2) {\n d[0] ^= stream2word(data, databytes);\n d[1] ^= stream2word(data, databytes);\n this.encipher(d);\n this.P[i] = d[0];\n this.P[i+1] = d[1];\n }\n\n for (i = 0; i < 4; i++) {\n for (k = 0; k < 256; k += 2) {\n d[0] ^= stream2word(data, databytes);\n d[1] ^= stream2word(data, databytes);\n this.encipher(d);\n this.S[i][k] = d[0];\n this.S[i][k+1] = d[1];\n }\n }\n BLF_J = 0;\n};\n\nBlowfish.prototype.enc = function(data, blocks) {\n for (var i = 0; i < blocks; i++) {\n this.encipher(data.subarray(i*2));\n }\n};\n\nBlowfish.prototype.dec = function(data, blocks) {\n for (var i = 0; i < blocks; i++) {\n this.decipher(data.subarray(i*2));\n }\n};\n\nvar BCRYPT_BLOCKS = 8,\n BCRYPT_HASHSIZE = 32;\n\nfunction bcrypt_hash(sha2pass, sha2salt, out) {\n var state = new Blowfish(),\n cdata = new Uint32Array(BCRYPT_BLOCKS), i,\n ciphertext = new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,\n 99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,\n 105,116,101]); //\"OxychromaticBlowfishSwatDynamite\"\n\n state.expandstate(sha2salt, 64, sha2pass, 64);\n for (i = 0; i < 64; i++) {\n state.expand0state(sha2salt, 64);\n state.expand0state(sha2pass, 64);\n }\n\n for (i = 0; i < BCRYPT_BLOCKS; i++)\n cdata[i] = stream2word(ciphertext, ciphertext.byteLength);\n for (i = 0; i < 64; i++)\n state.enc(cdata, cdata.byteLength / 8);\n\n for (i = 0; i < BCRYPT_BLOCKS; i++) {\n out[4*i+3] = cdata[i] >>> 24;\n out[4*i+2] = cdata[i] >>> 16;\n out[4*i+1] = cdata[i] >>> 8;\n out[4*i+0] = cdata[i];\n }\n};\n\nfunction bcrypt_pbkdf(pass, passlen, salt, saltlen, key, keylen, rounds) {\n var sha2pass = new Uint8Array(64),\n sha2salt = new Uint8Array(64),\n out = new Uint8Array(BCRYPT_HASHSIZE),\n tmpout = new Uint8Array(BCRYPT_HASHSIZE),\n countsalt = new Uint8Array(saltlen+4),\n i, j, amt, stride, dest, count,\n origkeylen = keylen;\n\n if (rounds < 1)\n return -1;\n if (passlen === 0 || saltlen === 0 || keylen === 0 ||\n keylen > (out.byteLength * out.byteLength) || saltlen > (1<<20))\n return -1;\n\n stride = Math.floor((keylen + out.byteLength - 1) / out.byteLength);\n amt = Math.floor((keylen + stride - 1) / stride);\n\n for (i = 0; i < saltlen; i++)\n countsalt[i] = salt[i];\n\n crypto_hash_sha512(sha2pass, pass, passlen);\n\n for (count = 1; keylen > 0; count++) {\n countsalt[saltlen+0] = count >>> 24;\n countsalt[saltlen+1] = count >>> 16;\n countsalt[saltlen+2] = count >>> 8;\n countsalt[saltlen+3] = count;\n\n crypto_hash_sha512(sha2salt, countsalt, saltlen + 4);\n bcrypt_hash(sha2pass, sha2salt, tmpout);\n for (i = out.byteLength; i--;)\n out[i] = tmpout[i];\n\n for (i = 1; i < rounds; i++) {\n crypto_hash_sha512(sha2salt, tmpout, tmpout.byteLength);\n bcrypt_hash(sha2pass, sha2salt, tmpout);\n for (j = 0; j < out.byteLength; j++)\n out[j] ^= tmpout[j];\n }\n\n amt = Math.min(amt, keylen);\n for (i = 0; i < amt; i++) {\n dest = i * stride + (count - 1);\n if (dest >= origkeylen)\n break;\n key[dest] = out[i];\n }\n keylen -= i;\n }\n\n return 0;\n};\n\nmodule.exports = {\n BLOCKS: BCRYPT_BLOCKS,\n HASHSIZE: BCRYPT_HASHSIZE,\n hash: bcrypt_hash,\n pbkdf: bcrypt_pbkdf\n};\n","var register = require('./lib/register')\nvar addHook = require('./lib/add')\nvar removeHook = require('./lib/remove')\n\n// bind with array of arguments: https://stackoverflow.com/a/21792913\nvar bind = Function.bind\nvar bindable = bind.bind(bind)\n\nfunction bindApi (hook, state, name) {\n var removeHookRef = bindable(removeHook, null).apply(null, name ? [state, name] : [state])\n hook.api = { remove: removeHookRef }\n hook.remove = removeHookRef\n\n ;['before', 'error', 'after', 'wrap'].forEach(function (kind) {\n var args = name ? [state, kind, name] : [state, kind]\n hook[kind] = hook.api[kind] = bindable(addHook, null).apply(null, args)\n })\n}\n\nfunction HookSingular () {\n var singularHookName = 'h'\n var singularHookState = {\n registry: {}\n }\n var singularHook = register.bind(null, singularHookState, singularHookName)\n bindApi(singularHook, singularHookState, singularHookName)\n return singularHook\n}\n\nfunction HookCollection () {\n var state = {\n registry: {}\n }\n\n var hook = register.bind(null, state)\n bindApi(hook, state)\n\n return hook\n}\n\nvar collectionHookDeprecationMessageDisplayed = false\nfunction Hook () {\n if (!collectionHookDeprecationMessageDisplayed) {\n console.warn('[before-after-hook]: \"Hook()\" repurposing warning, use \"Hook.Collection()\". Read more: https://git.io/upgrade-before-after-hook-to-1.4')\n collectionHookDeprecationMessageDisplayed = true\n }\n return HookCollection()\n}\n\nHook.Singular = HookSingular.bind()\nHook.Collection = HookCollection.bind()\n\nmodule.exports = Hook\n// expose constructors as a named property for TypeScript\nmodule.exports.Hook = Hook\nmodule.exports.Singular = Hook.Singular\nmodule.exports.Collection = Hook.Collection\n","module.exports = addHook;\n\nfunction addHook(state, kind, name, hook) {\n var orig = hook;\n if (!state.registry[name]) {\n state.registry[name] = [];\n }\n\n if (kind === \"before\") {\n hook = function (method, options) {\n return Promise.resolve()\n .then(orig.bind(null, options))\n .then(method.bind(null, options));\n };\n }\n\n if (kind === \"after\") {\n hook = function (method, options) {\n var result;\n return Promise.resolve()\n .then(method.bind(null, options))\n .then(function (result_) {\n result = result_;\n return orig(result, options);\n })\n .then(function () {\n return result;\n });\n };\n }\n\n if (kind === \"error\") {\n hook = function (method, options) {\n return Promise.resolve()\n .then(method.bind(null, options))\n .catch(function (error) {\n return orig(error, options);\n });\n };\n }\n\n state.registry[name].push({\n hook: hook,\n orig: orig,\n });\n}\n","module.exports = register;\n\nfunction register(state, name, method, options) {\n if (typeof method !== \"function\") {\n throw new Error(\"method for before hook must be a function\");\n }\n\n if (!options) {\n options = {};\n }\n\n if (Array.isArray(name)) {\n return name.reverse().reduce(function (callback, name) {\n return register.bind(null, state, name, callback, options);\n }, method)();\n }\n\n return Promise.resolve().then(function () {\n if (!state.registry[name]) {\n return method(options);\n }\n\n return state.registry[name].reduce(function (method, registered) {\n return registered.hook.bind(null, method, options);\n }, method)();\n });\n}\n","module.exports = removeHook;\n\nfunction removeHook(state, name, method) {\n if (!state.registry[name]) {\n return;\n }\n\n var index = state.registry[name]\n .map(function (registered) {\n return registered.orig;\n })\n .indexOf(method);\n\n if (index === -1) {\n return;\n }\n\n state.registry[name].splice(index, 1);\n}\n","'use strict'\n\nconst { Buffer } = require('buffer')\nconst symbol = Symbol.for('BufferList')\n\nfunction BufferList (buf) {\n if (!(this instanceof BufferList)) {\n return new BufferList(buf)\n }\n\n BufferList._init.call(this, buf)\n}\n\nBufferList._init = function _init (buf) {\n Object.defineProperty(this, symbol, { value: true })\n\n this._bufs = []\n this.length = 0\n\n if (buf) {\n this.append(buf)\n }\n}\n\nBufferList.prototype._new = function _new (buf) {\n return new BufferList(buf)\n}\n\nBufferList.prototype._offset = function _offset (offset) {\n if (offset === 0) {\n return [0, 0]\n }\n\n let tot = 0\n\n for (let i = 0; i < this._bufs.length; i++) {\n const _t = tot + this._bufs[i].length\n if (offset < _t || i === this._bufs.length - 1) {\n return [i, offset - tot]\n }\n tot = _t\n }\n}\n\nBufferList.prototype._reverseOffset = function (blOffset) {\n const bufferId = blOffset[0]\n let offset = blOffset[1]\n\n for (let i = 0; i < bufferId; i++) {\n offset += this._bufs[i].length\n }\n\n return offset\n}\n\nBufferList.prototype.get = function get (index) {\n if (index > this.length || index < 0) {\n return undefined\n }\n\n const offset = this._offset(index)\n\n return this._bufs[offset[0]][offset[1]]\n}\n\nBufferList.prototype.slice = function slice (start, end) {\n if (typeof start === 'number' && start < 0) {\n start += this.length\n }\n\n if (typeof end === 'number' && end < 0) {\n end += this.length\n }\n\n return this.copy(null, 0, start, end)\n}\n\nBufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {\n if (typeof srcStart !== 'number' || srcStart < 0) {\n srcStart = 0\n }\n\n if (typeof srcEnd !== 'number' || srcEnd > this.length) {\n srcEnd = this.length\n }\n\n if (srcStart >= this.length) {\n return dst || Buffer.alloc(0)\n }\n\n if (srcEnd <= 0) {\n return dst || Buffer.alloc(0)\n }\n\n const copy = !!dst\n const off = this._offset(srcStart)\n const len = srcEnd - srcStart\n let bytes = len\n let bufoff = (copy && dstStart) || 0\n let start = off[1]\n\n // copy/slice everything\n if (srcStart === 0 && srcEnd === this.length) {\n if (!copy) {\n // slice, but full concat if multiple buffers\n return this._bufs.length === 1\n ? this._bufs[0]\n : Buffer.concat(this._bufs, this.length)\n }\n\n // copy, need to copy individual buffers\n for (let i = 0; i < this._bufs.length; i++) {\n this._bufs[i].copy(dst, bufoff)\n bufoff += this._bufs[i].length\n }\n\n return dst\n }\n\n // easy, cheap case where it's a subset of one of the buffers\n if (bytes <= this._bufs[off[0]].length - start) {\n return copy\n ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)\n : this._bufs[off[0]].slice(start, start + bytes)\n }\n\n if (!copy) {\n // a slice, we need something to copy in to\n dst = Buffer.allocUnsafe(len)\n }\n\n for (let i = off[0]; i < this._bufs.length; i++) {\n const l = this._bufs[i].length - start\n\n if (bytes > l) {\n this._bufs[i].copy(dst, bufoff, start)\n bufoff += l\n } else {\n this._bufs[i].copy(dst, bufoff, start, start + bytes)\n bufoff += l\n break\n }\n\n bytes -= l\n\n if (start) {\n start = 0\n }\n }\n\n // safeguard so that we don't return uninitialized memory\n if (dst.length > bufoff) return dst.slice(0, bufoff)\n\n return dst\n}\n\nBufferList.prototype.shallowSlice = function shallowSlice (start, end) {\n start = start || 0\n end = typeof end !== 'number' ? this.length : end\n\n if (start < 0) {\n start += this.length\n }\n\n if (end < 0) {\n end += this.length\n }\n\n if (start === end) {\n return this._new()\n }\n\n const startOffset = this._offset(start)\n const endOffset = this._offset(end)\n const buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)\n\n if (endOffset[1] === 0) {\n buffers.pop()\n } else {\n buffers[buffers.length - 1] = buffers[buffers.length - 1].slice(0, endOffset[1])\n }\n\n if (startOffset[1] !== 0) {\n buffers[0] = buffers[0].slice(startOffset[1])\n }\n\n return this._new(buffers)\n}\n\nBufferList.prototype.toString = function toString (encoding, start, end) {\n return this.slice(start, end).toString(encoding)\n}\n\nBufferList.prototype.consume = function consume (bytes) {\n // first, normalize the argument, in accordance with how Buffer does it\n bytes = Math.trunc(bytes)\n // do nothing if not a positive number\n if (Number.isNaN(bytes) || bytes <= 0) return this\n\n while (this._bufs.length) {\n if (bytes >= this._bufs[0].length) {\n bytes -= this._bufs[0].length\n this.length -= this._bufs[0].length\n this._bufs.shift()\n } else {\n this._bufs[0] = this._bufs[0].slice(bytes)\n this.length -= bytes\n break\n }\n }\n\n return this\n}\n\nBufferList.prototype.duplicate = function duplicate () {\n const copy = this._new()\n\n for (let i = 0; i < this._bufs.length; i++) {\n copy.append(this._bufs[i])\n }\n\n return copy\n}\n\nBufferList.prototype.append = function append (buf) {\n if (buf == null) {\n return this\n }\n\n if (buf.buffer) {\n // append a view of the underlying ArrayBuffer\n this._appendBuffer(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength))\n } else if (Array.isArray(buf)) {\n for (let i = 0; i < buf.length; i++) {\n this.append(buf[i])\n }\n } else if (this._isBufferList(buf)) {\n // unwrap argument into individual BufferLists\n for (let i = 0; i < buf._bufs.length; i++) {\n this.append(buf._bufs[i])\n }\n } else {\n // coerce number arguments to strings, since Buffer(number) does\n // uninitialized memory allocation\n if (typeof buf === 'number') {\n buf = buf.toString()\n }\n\n this._appendBuffer(Buffer.from(buf))\n }\n\n return this\n}\n\nBufferList.prototype._appendBuffer = function appendBuffer (buf) {\n this._bufs.push(buf)\n this.length += buf.length\n}\n\nBufferList.prototype.indexOf = function (search, offset, encoding) {\n if (encoding === undefined && typeof offset === 'string') {\n encoding = offset\n offset = undefined\n }\n\n if (typeof search === 'function' || Array.isArray(search)) {\n throw new TypeError('The \"value\" argument must be one of type string, Buffer, BufferList, or Uint8Array.')\n } else if (typeof search === 'number') {\n search = Buffer.from([search])\n } else if (typeof search === 'string') {\n search = Buffer.from(search, encoding)\n } else if (this._isBufferList(search)) {\n search = search.slice()\n } else if (Array.isArray(search.buffer)) {\n search = Buffer.from(search.buffer, search.byteOffset, search.byteLength)\n } else if (!Buffer.isBuffer(search)) {\n search = Buffer.from(search)\n }\n\n offset = Number(offset || 0)\n\n if (isNaN(offset)) {\n offset = 0\n }\n\n if (offset < 0) {\n offset = this.length + offset\n }\n\n if (offset < 0) {\n offset = 0\n }\n\n if (search.length === 0) {\n return offset > this.length ? this.length : offset\n }\n\n const blOffset = this._offset(offset)\n let blIndex = blOffset[0] // index of which internal buffer we're working on\n let buffOffset = blOffset[1] // offset of the internal buffer we're working on\n\n // scan over each buffer\n for (; blIndex < this._bufs.length; blIndex++) {\n const buff = this._bufs[blIndex]\n\n while (buffOffset < buff.length) {\n const availableWindow = buff.length - buffOffset\n\n if (availableWindow >= search.length) {\n const nativeSearchResult = buff.indexOf(search, buffOffset)\n\n if (nativeSearchResult !== -1) {\n return this._reverseOffset([blIndex, nativeSearchResult])\n }\n\n buffOffset = buff.length - search.length + 1 // end of native search window\n } else {\n const revOffset = this._reverseOffset([blIndex, buffOffset])\n\n if (this._match(revOffset, search)) {\n return revOffset\n }\n\n buffOffset++\n }\n }\n\n buffOffset = 0\n }\n\n return -1\n}\n\nBufferList.prototype._match = function (offset, search) {\n if (this.length - offset < search.length) {\n return false\n }\n\n for (let searchOffset = 0; searchOffset < search.length; searchOffset++) {\n if (this.get(offset + searchOffset) !== search[searchOffset]) {\n return false\n }\n }\n return true\n}\n\n;(function () {\n const methods = {\n readDoubleBE: 8,\n readDoubleLE: 8,\n readFloatBE: 4,\n readFloatLE: 4,\n readInt32BE: 4,\n readInt32LE: 4,\n readUInt32BE: 4,\n readUInt32LE: 4,\n readInt16BE: 2,\n readInt16LE: 2,\n readUInt16BE: 2,\n readUInt16LE: 2,\n readInt8: 1,\n readUInt8: 1,\n readIntBE: null,\n readIntLE: null,\n readUIntBE: null,\n readUIntLE: null\n }\n\n for (const m in methods) {\n (function (m) {\n if (methods[m] === null) {\n BufferList.prototype[m] = function (offset, byteLength) {\n return this.slice(offset, offset + byteLength)[m](0, byteLength)\n }\n } else {\n BufferList.prototype[m] = function (offset = 0) {\n return this.slice(offset, offset + methods[m])[m](0)\n }\n }\n }(m))\n }\n}())\n\n// Used internally by the class and also as an indicator of this object being\n// a `BufferList`. It's not possible to use `instanceof BufferList` in a browser\n// environment because there could be multiple different copies of the\n// BufferList class and some `BufferList`s might be `BufferList`s.\nBufferList.prototype._isBufferList = function _isBufferList (b) {\n return b instanceof BufferList || BufferList.isBufferList(b)\n}\n\nBufferList.isBufferList = function isBufferList (b) {\n return b != null && b[symbol]\n}\n\nmodule.exports = BufferList\n","'use strict'\n\nconst DuplexStream = require('readable-stream').Duplex\nconst inherits = require('inherits')\nconst BufferList = require('./BufferList')\n\nfunction BufferListStream (callback) {\n if (!(this instanceof BufferListStream)) {\n return new BufferListStream(callback)\n }\n\n if (typeof callback === 'function') {\n this._callback = callback\n\n const piper = function piper (err) {\n if (this._callback) {\n this._callback(err)\n this._callback = null\n }\n }.bind(this)\n\n this.on('pipe', function onPipe (src) {\n src.on('error', piper)\n })\n this.on('unpipe', function onUnpipe (src) {\n src.removeListener('error', piper)\n })\n\n callback = null\n }\n\n BufferList._init.call(this, callback)\n DuplexStream.call(this)\n}\n\ninherits(BufferListStream, DuplexStream)\nObject.assign(BufferListStream.prototype, BufferList.prototype)\n\nBufferListStream.prototype._new = function _new (callback) {\n return new BufferListStream(callback)\n}\n\nBufferListStream.prototype._write = function _write (buf, encoding, callback) {\n this._appendBuffer(buf)\n\n if (typeof callback === 'function') {\n callback()\n }\n}\n\nBufferListStream.prototype._read = function _read (size) {\n if (!this.length) {\n return this.push(null)\n }\n\n size = Math.min(size, this.length)\n this.push(this.slice(0, size))\n this.consume(size)\n}\n\nBufferListStream.prototype.end = function end (chunk) {\n DuplexStream.prototype.end.call(this, chunk)\n\n if (this._callback) {\n this._callback(null, this.slice())\n this._callback = null\n }\n}\n\nBufferListStream.prototype._destroy = function _destroy (err, cb) {\n this._bufs.length = 0\n this.length = 0\n cb(err)\n}\n\nBufferListStream.prototype._isBufferList = function _isBufferList (b) {\n return b instanceof BufferListStream || b instanceof BufferList || BufferListStream.isBufferList(b)\n}\n\nBufferListStream.isBufferList = BufferList.isBufferList\n\nmodule.exports = BufferListStream\nmodule.exports.BufferListStream = BufferListStream\nmodule.exports.BufferList = BufferList\n","'use strict'\nconst fs = require('fs')\nconst path = require('path')\n\n/* istanbul ignore next */\nconst LCHOWN = fs.lchown ? 'lchown' : 'chown'\n/* istanbul ignore next */\nconst LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'\n\n/* istanbul ignore next */\nconst needEISDIRHandled = fs.lchown &&\n !process.version.match(/v1[1-9]+\\./) &&\n !process.version.match(/v10\\.[6-9]/)\n\nconst lchownSync = (path, uid, gid) => {\n try {\n return fs[LCHOWNSYNC](path, uid, gid)\n } catch (er) {\n if (er.code !== 'ENOENT')\n throw er\n }\n}\n\n/* istanbul ignore next */\nconst chownSync = (path, uid, gid) => {\n try {\n return fs.chownSync(path, uid, gid)\n } catch (er) {\n if (er.code !== 'ENOENT')\n throw er\n }\n}\n\n/* istanbul ignore next */\nconst handleEISDIR =\n needEISDIRHandled ? (path, uid, gid, cb) => er => {\n // Node prior to v10 had a very questionable implementation of\n // fs.lchown, which would always try to call fs.open on a directory\n // Fall back to fs.chown in those cases.\n if (!er || er.code !== 'EISDIR')\n cb(er)\n else\n fs.chown(path, uid, gid, cb)\n }\n : (_, __, ___, cb) => cb\n\n/* istanbul ignore next */\nconst handleEISDirSync =\n needEISDIRHandled ? (path, uid, gid) => {\n try {\n return lchownSync(path, uid, gid)\n } catch (er) {\n if (er.code !== 'EISDIR')\n throw er\n chownSync(path, uid, gid)\n }\n }\n : (path, uid, gid) => lchownSync(path, uid, gid)\n\n// fs.readdir could only accept an options object as of node v6\nconst nodeVersion = process.version\nlet readdir = (path, options, cb) => fs.readdir(path, options, cb)\nlet readdirSync = (path, options) => fs.readdirSync(path, options)\n/* istanbul ignore next */\nif (/^v4\\./.test(nodeVersion))\n readdir = (path, options, cb) => fs.readdir(path, cb)\n\nconst chown = (cpath, uid, gid, cb) => {\n fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, er => {\n // Skip ENOENT error\n cb(er && er.code !== 'ENOENT' ? er : null)\n }))\n}\n\nconst chownrKid = (p, child, uid, gid, cb) => {\n if (typeof child === 'string')\n return fs.lstat(path.resolve(p, child), (er, stats) => {\n // Skip ENOENT error\n if (er)\n return cb(er.code !== 'ENOENT' ? er : null)\n stats.name = child\n chownrKid(p, stats, uid, gid, cb)\n })\n\n if (child.isDirectory()) {\n chownr(path.resolve(p, child.name), uid, gid, er => {\n if (er)\n return cb(er)\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n })\n } else {\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n }\n}\n\n\nconst chownr = (p, uid, gid, cb) => {\n readdir(p, { withFileTypes: true }, (er, children) => {\n // any error other than ENOTDIR or ENOTSUP means it's not readable,\n // or doesn't exist. give up.\n if (er) {\n if (er.code === 'ENOENT')\n return cb()\n else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')\n return cb(er)\n }\n if (er || !children.length)\n return chown(p, uid, gid, cb)\n\n let len = children.length\n let errState = null\n const then = er => {\n if (errState)\n return\n if (er)\n return cb(errState = er)\n if (-- len === 0)\n return chown(p, uid, gid, cb)\n }\n\n children.forEach(child => chownrKid(p, child, uid, gid, then))\n })\n}\n\nconst chownrKidSync = (p, child, uid, gid) => {\n if (typeof child === 'string') {\n try {\n const stats = fs.lstatSync(path.resolve(p, child))\n stats.name = child\n child = stats\n } catch (er) {\n if (er.code === 'ENOENT')\n return\n else\n throw er\n }\n }\n\n if (child.isDirectory())\n chownrSync(path.resolve(p, child.name), uid, gid)\n\n handleEISDirSync(path.resolve(p, child.name), uid, gid)\n}\n\nconst chownrSync = (p, uid, gid) => {\n let children\n try {\n children = readdirSync(p, { withFileTypes: true })\n } catch (er) {\n if (er.code === 'ENOENT')\n return\n else if (er.code === 'ENOTDIR' || er.code === 'ENOTSUP')\n return handleEISDirSync(p, uid, gid)\n else\n throw er\n }\n\n if (children && children.length)\n children.forEach(child => chownrKidSync(p, child, uid, gid))\n\n return handleEISDirSync(p, uid, gid)\n}\n\nmodule.exports = chownr\nchownr.sync = chownrSync\n","const binding = require('../build/Release/cpufeatures.node');\n\nmodule.exports = binding.getCPUInfo;\n","/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug');\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tlet i;\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n\t\tconst len = split.length;\n\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tif (!split[i]) {\n\t\t\t\t// ignore empty strings\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tnamespaces = split[i].replace(/\\*/g, '.*?');\n\n\t\t\tif (namespaces[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(new RegExp('^' + namespaces + '$'));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names.map(toNamespace),\n\t\t\t...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tif (name[name.length - 1] === '*') {\n\t\t\treturn true;\n\t\t}\n\n\t\tlet i;\n\t\tlet len;\n\n\t\tfor (i = 0, len = createDebug.skips.length; i < len; i++) {\n\t\t\tif (createDebug.skips[i].test(name)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0, len = createDebug.names.length; i < len; i++) {\n\t\t\tif (createDebug.names[i].test(name)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Convert regexp to namespace\n\t*\n\t* @param {RegExp} regxep\n\t* @return {String} namespace\n\t* @api private\n\t*/\n\tfunction toNamespace(regexp) {\n\t\treturn regexp.toString()\n\t\t\t.substring(2, regexp.toString().length - 2)\n\t\t\t.replace(/\\.\\*\\?$/, '*');\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n","/**\n * Detect Electron renderer / nwjs process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {\n\tmodule.exports = require('./browser.js');\n} else {\n\tmodule.exports = require('./node.js');\n}\n","/**\n * Module dependencies.\n */\n\nconst tty = require('tty');\nconst util = require('util');\n\n/**\n * This is the Node.js implementation of `debug()`.\n */\n\nexports.init = init;\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.destroy = util.deprecate(\n\t() => {},\n\t'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'\n);\n\n/**\n * Colors.\n */\n\nexports.colors = [6, 2, 3, 4, 5, 1];\n\ntry {\n\t// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)\n\t// eslint-disable-next-line import/no-extraneous-dependencies\n\tconst supportsColor = require('supports-color');\n\n\tif (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {\n\t\texports.colors = [\n\t\t\t20,\n\t\t\t21,\n\t\t\t26,\n\t\t\t27,\n\t\t\t32,\n\t\t\t33,\n\t\t\t38,\n\t\t\t39,\n\t\t\t40,\n\t\t\t41,\n\t\t\t42,\n\t\t\t43,\n\t\t\t44,\n\t\t\t45,\n\t\t\t56,\n\t\t\t57,\n\t\t\t62,\n\t\t\t63,\n\t\t\t68,\n\t\t\t69,\n\t\t\t74,\n\t\t\t75,\n\t\t\t76,\n\t\t\t77,\n\t\t\t78,\n\t\t\t79,\n\t\t\t80,\n\t\t\t81,\n\t\t\t92,\n\t\t\t93,\n\t\t\t98,\n\t\t\t99,\n\t\t\t112,\n\t\t\t113,\n\t\t\t128,\n\t\t\t129,\n\t\t\t134,\n\t\t\t135,\n\t\t\t148,\n\t\t\t149,\n\t\t\t160,\n\t\t\t161,\n\t\t\t162,\n\t\t\t163,\n\t\t\t164,\n\t\t\t165,\n\t\t\t166,\n\t\t\t167,\n\t\t\t168,\n\t\t\t169,\n\t\t\t170,\n\t\t\t171,\n\t\t\t172,\n\t\t\t173,\n\t\t\t178,\n\t\t\t179,\n\t\t\t184,\n\t\t\t185,\n\t\t\t196,\n\t\t\t197,\n\t\t\t198,\n\t\t\t199,\n\t\t\t200,\n\t\t\t201,\n\t\t\t202,\n\t\t\t203,\n\t\t\t204,\n\t\t\t205,\n\t\t\t206,\n\t\t\t207,\n\t\t\t208,\n\t\t\t209,\n\t\t\t214,\n\t\t\t215,\n\t\t\t220,\n\t\t\t221\n\t\t];\n\t}\n} catch (error) {\n\t// Swallow - we only care if `supports-color` is available; it doesn't have to be.\n}\n\n/**\n * Build up the default `inspectOpts` object from the environment variables.\n *\n * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js\n */\n\nexports.inspectOpts = Object.keys(process.env).filter(key => {\n\treturn /^debug_/i.test(key);\n}).reduce((obj, key) => {\n\t// Camel-case\n\tconst prop = key\n\t\t.substring(6)\n\t\t.toLowerCase()\n\t\t.replace(/_([a-z])/g, (_, k) => {\n\t\t\treturn k.toUpperCase();\n\t\t});\n\n\t// Coerce string value into JS value\n\tlet val = process.env[key];\n\tif (/^(yes|on|true|enabled)$/i.test(val)) {\n\t\tval = true;\n\t} else if (/^(no|off|false|disabled)$/i.test(val)) {\n\t\tval = false;\n\t} else if (val === 'null') {\n\t\tval = null;\n\t} else {\n\t\tval = Number(val);\n\t}\n\n\tobj[prop] = val;\n\treturn obj;\n}, {});\n\n/**\n * Is stdout a TTY? Colored output is enabled when `true`.\n */\n\nfunction useColors() {\n\treturn 'colors' in exports.inspectOpts ?\n\t\tBoolean(exports.inspectOpts.colors) :\n\t\ttty.isatty(process.stderr.fd);\n}\n\n/**\n * Adds ANSI color escape codes if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\tconst {namespace: name, useColors} = this;\n\n\tif (useColors) {\n\t\tconst c = this.color;\n\t\tconst colorCode = '\\u001B[3' + (c < 8 ? c : '8;5;' + c);\n\t\tconst prefix = ` ${colorCode};1m${name} \\u001B[0m`;\n\n\t\targs[0] = prefix + args[0].split('\\n').join('\\n' + prefix);\n\t\targs.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\\u001B[0m');\n\t} else {\n\t\targs[0] = getDate() + name + ' ' + args[0];\n\t}\n}\n\nfunction getDate() {\n\tif (exports.inspectOpts.hideDate) {\n\t\treturn '';\n\t}\n\treturn new Date().toISOString() + ' ';\n}\n\n/**\n * Invokes `util.format()` with the specified arguments and writes to stderr.\n */\n\nfunction log(...args) {\n\treturn process.stderr.write(util.format(...args) + '\\n');\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\tif (namespaces) {\n\t\tprocess.env.DEBUG = namespaces;\n\t} else {\n\t\t// If you set a process.env field to null or undefined, it gets cast to the\n\t\t// string 'null' or 'undefined'. Just delete instead.\n\t\tdelete process.env.DEBUG;\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n\treturn process.env.DEBUG;\n}\n\n/**\n * Init logic for `debug` instances.\n *\n * Create a new `inspectOpts` object in case `useColors` is set\n * differently for a particular `debug` instance.\n */\n\nfunction init(debug) {\n\tdebug.inspectOpts = {};\n\n\tconst keys = Object.keys(exports.inspectOpts);\n\tfor (let i = 0; i < keys.length; i++) {\n\t\tdebug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %o to `util.inspect()`, all on a single line.\n */\n\nformatters.o = function (v) {\n\tthis.inspectOpts.colors = this.useColors;\n\treturn util.inspect(v, this.inspectOpts)\n\t\t.split('\\n')\n\t\t.map(str => str.trim())\n\t\t.join(' ');\n};\n\n/**\n * Map %O to `util.inspect()`, allowing multiple lines if needed.\n */\n\nformatters.O = function (v) {\n\tthis.inspectOpts.colors = this.useColors;\n\treturn util.inspect(v, this.inspectOpts);\n};\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nclass Deprecation extends Error {\n constructor(message) {\n super(message); // Maintains proper stack trace (only available on V8)\n\n /* istanbul ignore next */\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n\n this.name = 'Deprecation';\n }\n\n}\n\nexports.Deprecation = Deprecation;\n","//Based on follow-redirects v0.0.x\n\nvar nativeHttps = require('https'),\n nativeHttp = require('http'),\n url = require('url'),\n utils = require('./utils');\n\nvar maxRedirects = module.exports.maxRedirects = 5;\n\nvar protocols = {\n https: nativeHttps,\n http: nativeHttp\n};\n\nfor (var protocol in protocols) {\n var h = function() {};\n h.prototype = protocols[protocol];\n h = new h();\n\n h.request = function(h) {\n return function(options, callback, redirectOptions) {\n\n redirectOptions = redirectOptions || {};\n\n var max = (typeof options === 'object' && 'maxRedirects' in options) ? options.maxRedirects : exports.maxRedirects;\n\n var redirect = utils.extend({\n count: 0,\n max: max,\n clientRequest: null,\n userCallback: callback\n }, redirectOptions);\n\n if (redirect.count > redirect.max) {\n var err = new Error('Max redirects exceeded. To allow more redirects, pass options.maxRedirects property.');\n redirect.clientRequest.emit('error', err);\n return redirect.clientRequest;\n }\n\n redirect.count++;\n\n var reqUrl;\n if (typeof options === 'string') {\n reqUrl = options;\n } else {\n reqUrl = url.format(utils.extend({\n protocol: protocol\n }, options));\n }\n\n var clientRequest = Object.getPrototypeOf(h).request(options, redirectCallback(reqUrl, redirect));\n\n if (!redirect.clientRequest) redirect.clientRequest = clientRequest;\n\n function redirectCallback(reqUrl, redirect) {\n return function(res) {\n if (res.statusCode < 300 || res.statusCode > 399) {\n return redirect.userCallback(res);\n }\n\n if (!('location' in res.headers)) {\n return redirect.userCallback(res);\n }\n\n var redirectUrl = url.resolve(reqUrl, res.headers.location);\n\n var proto = url.parse(redirectUrl).protocol;\n proto = proto.substr(0, proto.length - 1);\n return module.exports[proto].get(redirectUrl, redirectCallback(reqUrl, redirect), redirect);\n };\n }\n\n return clientRequest;\n };\n }(h);\n\n // see https://github.com/joyent/node/blob/master/lib/http.js#L1623\n h.get = function(h) {\n return function(options, cb, redirectOptions) {\n var req = h.request(options, cb, redirectOptions);\n req.end();\n return req;\n };\n }(h);\n\n module.exports[protocol] = h;\n}\n","module.exports = HttpDuplex;\n\nvar util = require('util'),\n stream = require('readable-stream');\n\nutil.inherits(HttpDuplex, stream.Duplex);\n\nfunction HttpDuplex(req, res, options) {\n var self = this;\n\n if (!(self instanceof HttpDuplex)) return new HttpDuplex(req, res, options);\n\n stream.Duplex.call(self, options);\n self._output = null;\n\n self.connect(req, res);\n}\n\nHttpDuplex.prototype.connect = function(req, res) {\n var self = this;\n self.req = req;\n self._output = res;\n self.emit('response', res);\n\n res.on('data', function(c) {\n if (!self.push(c)) self._output.pause();\n });\n res.on('end', function() {\n self.push(null);\n });\n};\n\nHttpDuplex.prototype._read = function(n) {\n if (this._output) this._output.resume();\n};\n\nHttpDuplex.prototype._write = function(chunk, encoding, cb) {\n this.req.write(chunk, encoding);\n cb();\n};\n\nHttpDuplex.prototype.end = function(chunk, encoding, cb) {\n this._output.socket.destroy();\n return this.req.end(chunk, encoding, cb);\n};\n\nHttpDuplex.prototype.destroy = function() {\n this.req.destroy();\n this._output.socket.destroy();\n};\n","var querystring = require('querystring'),\n http = require('./http'),\n fs = require('fs'),\n path = require('path'),\n url = require('url'),\n ssh = require('./ssh'),\n HttpDuplex = require('./http_duplex'),\n debug = require('debug')('modem'),\n utils = require('./utils'),\n util = require('util'),\n url = require('url'),\n splitca = require('split-ca'),\n isWin = require('os').type() === 'Windows_NT';\n\nvar defaultOpts = function () {\n var host;\n var opts = {};\n\n if (!process.env.DOCKER_HOST) {\n // Windows socket path: //./pipe/docker_engine ( Windows 10 )\n // Linux & Darwin socket path: /var/run/docker.sock\n opts.socketPath = isWin ? '//./pipe/docker_engine' : '/var/run/docker.sock';\n } else if (process.env.DOCKER_HOST.indexOf('unix://') === 0) {\n // Strip off unix://, fall back to default of /var/run/docker.sock if\n // unix:// was passed without a path\n opts.socketPath = process.env.DOCKER_HOST.substring(7) || '/var/run/docker.sock';\n } else if (process.env.DOCKER_HOST.indexOf('npipe://') === 0) {\n // Strip off npipe://, fall back to default of //./pipe/docker_engine if\n // npipe:// was passed without a path\n opts.socketPath = process.env.DOCKER_HOST.substring(8) || '//./pipe/docker_engine';\n } else {\n var hostStr = process.env.DOCKER_HOST;\n if (hostStr.indexOf('\\/\\/') < 0) {\n hostStr = 'tcp://' + hostStr;\n }\n try {\n host = new url.URL(hostStr);\n } catch (err) {\n throw new Error('DOCKER_HOST env variable should be something like tcp://localhost:1234');\n }\n\n opts.port = host.port;\n\n if (process.env.DOCKER_TLS_VERIFY === '1' || opts.port === '2376') {\n opts.protocol = 'https';\n } else if (host.protocol === 'ssh:') {\n opts.protocol = 'ssh';\n opts.username = host.username;\n opts.sshOptions = {\n agent: process.env.SSH_AUTH_SOCK,\n }\n } else {\n opts.protocol = 'http';\n }\n\n opts.host = host.hostname;\n\n if (process.env.DOCKER_CERT_PATH) {\n opts.ca = splitca(path.join(process.env.DOCKER_CERT_PATH, 'ca.pem'));\n opts.cert = fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'cert.pem'));\n opts.key = fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'key.pem'));\n }\n\n if (process.env.DOCKER_CLIENT_TIMEOUT) {\n opts.timeout = parseInt(process.env.DOCKER_CLIENT_TIMEOUT, 10);\n }\n }\n\n return opts;\n};\n\n\nvar Modem = function (options) {\n var optDefaults = defaultOpts();\n var opts = Object.assign({}, optDefaults, options);\n\n this.host = opts.host;\n\n if(!this.host) {\n this.socketPath = opts.socketPath;\n }\n\n this.port = opts.port;\n this.username = opts.username;\n this.password = opts.password;\n this.version = opts.version;\n this.key = opts.key;\n this.cert = opts.cert;\n this.ca = opts.ca;\n this.timeout = opts.timeout;\n this.connectionTimeout = opts.connectionTimeout;\n this.checkServerIdentity = opts.checkServerIdentity;\n this.agent = opts.agent;\n this.headers = opts.headers || {};\n this.sshOptions = Object.assign({}, options ? options.sshOptions : {}, optDefaults.sshOptions);\n //retrocompabitlity\n if(this.sshOptions.agentForward === undefined) {\n this.sshOptions.agentForward = opts.agentForward;\n }\n\n if (this.key && this.cert && this.ca) {\n this.protocol = 'https';\n }\n this.protocol = opts.protocol || this.protocol || 'http';\n};\n\nModem.prototype.dial = function (options, callback) {\n var opts, address, data;\n var self = this;\n\n if (options.options) {\n opts = options.options;\n }\n\n // Prevent credentials from showing up in URL\n if (opts && opts.authconfig) {\n delete opts.authconfig;\n }\n\n // Prevent abortsignal from showing up in the URL\n if (opts && opts.abortSignal) {\n delete opts.abortSignal;\n }\n\n if (this.version) {\n options.path = '/' + this.version + options.path;\n }\n\n if (this.host) {\n var parsed = url.parse(self.host);\n address = url.format({\n 'protocol': parsed.protocol || self.protocol,\n 'hostname': parsed.hostname || self.host,\n 'port': self.port\n });\n address = url.resolve(address, options.path);\n } else {\n address = options.path;\n }\n\n if (options.path.indexOf('?') !== -1) {\n if (opts && Object.keys(opts).length > 0) {\n address += this.buildQuerystring(opts._query || opts);\n } else {\n address = address.substring(0, address.length - 1);\n }\n }\n\n var optionsf = {\n path: address,\n method: options.method,\n headers: options.headers || Object.assign({}, self.headers),\n key: self.key,\n cert: self.cert,\n ca: self.ca\n };\n\n if (this.checkServerIdentity) {\n optionsf.checkServerIdentity = this.checkServerIdentity;\n }\n\n if (this.agent) {\n optionsf.agent = this.agent;\n }\n\n if (options.authconfig) {\n optionsf.headers['X-Registry-Auth'] = options.authconfig.key || options.authconfig.base64 ||\n Buffer.from(JSON.stringify(options.authconfig)).toString('base64');\n }\n\n if (options.registryconfig) {\n optionsf.headers['X-Registry-Config'] = options.registryconfig.base64 ||\n Buffer.from(JSON.stringify(options.registryconfig)).toString('base64');\n }\n\n if (options.abortSignal) {\n optionsf.signal = options.abortSignal;\n }\n\n if (options.file) {\n if (typeof options.file === 'string') {\n data = fs.createReadStream(path.resolve(options.file));\n } else {\n data = options.file;\n }\n optionsf.headers['Content-Type'] = 'application/tar';\n } else if (opts && options.method === 'POST') {\n data = JSON.stringify(opts._body || opts);\n if (options.allowEmpty) {\n optionsf.headers['Content-Type'] = 'application/json';\n } else {\n if (data !== '{}' && data !== '\"\"') {\n optionsf.headers['Content-Type'] = 'application/json';\n } else {\n data = undefined;\n }\n }\n }\n\n if (typeof data === 'string') {\n optionsf.headers['Content-Length'] = Buffer.byteLength(data);\n } else if (Buffer.isBuffer(data) === true) {\n optionsf.headers['Content-Length'] = data.length;\n } else if (optionsf.method === 'PUT' || options.hijack || options.openStdin) {\n optionsf.headers['Transfer-Encoding'] = 'chunked';\n }\n\n if (options.hijack) {\n optionsf.headers.Connection = 'Upgrade';\n optionsf.headers.Upgrade = 'tcp';\n }\n\n if (this.socketPath) {\n optionsf.socketPath = this.socketPath;\n } else {\n var urlp = url.parse(address);\n optionsf.hostname = urlp.hostname;\n optionsf.port = urlp.port;\n optionsf.path = urlp.path;\n }\n\n this.buildRequest(optionsf, options, data, callback);\n};\n\nModem.prototype.buildRequest = function (options, context, data, callback) {\n var self = this;\n var connectionTimeoutTimer;\n\n var opts = self.protocol === 'ssh' ? Object.assign(options, {\n agent: ssh(Object.assign({}, self.sshOptions, {\n 'host': self.host,\n 'port': self.port,\n 'username': self.username,\n 'password': self.password,\n })),\n protocol: 'http:',\n }) : options;\n\n var req = http[self.protocol === 'ssh' ? 'http' : self.protocol].request(opts, function () { });\n\n debug('Sending: %s', util.inspect(options, {\n showHidden: true,\n depth: null\n }));\n\n if (self.connectionTimeout) {\n connectionTimeoutTimer = setTimeout(function () {\n debug('Connection Timeout of %s ms exceeded', self.connectionTimeout);\n req.abort();\n }, self.connectionTimeout);\n }\n\n if (self.timeout) {\n req.on('socket', function (socket) {\n socket.setTimeout(self.timeout);\n socket.on('timeout', function () {\n debug('Timeout of %s ms exceeded', self.timeout);\n req.abort();\n });\n });\n }\n\n if (context.hijack === true) {\n clearTimeout(connectionTimeoutTimer);\n req.on('upgrade', function (res, sock, head) {\n return callback(null, sock);\n });\n }\n\n req.on('connect', function () {\n clearTimeout(connectionTimeoutTimer);\n });\n\n req.on('disconnect', function () {\n clearTimeout(connectionTimeoutTimer);\n });\n\n req.on('response', function (res) {\n clearTimeout(connectionTimeoutTimer);\n if (context.isStream === true) {\n self.buildPayload(null, context.isStream, context.statusCodes, context.openStdin, req, res, null, callback);\n } else {\n var chunks = [];\n res.on('data', function (chunk) {\n chunks.push(chunk);\n });\n\n res.on('end', function () {\n var buffer = Buffer.concat(chunks);\n var result = buffer.toString();\n\n debug('Received: %s', result);\n\n var json = utils.parseJSON(result) || buffer;\n self.buildPayload(null, context.isStream, context.statusCodes, false, req, res, json, callback);\n });\n }\n });\n\n req.on('error', function (error) {\n clearTimeout(connectionTimeoutTimer);\n self.buildPayload(error, context.isStream, context.statusCodes, false, {}, {}, null, callback);\n });\n\n if (typeof data === 'string' || Buffer.isBuffer(data)) {\n req.write(data);\n } else if (data) {\n data.on('error', function (error) {\n req.destroy(error);\n });\n data.pipe(req);\n }\n\n if (!context.hijack && !context.openStdin && (typeof data === 'string' || data === undefined || Buffer.isBuffer(data))) {\n req.end();\n }\n};\n\nModem.prototype.buildPayload = function (err, isStream, statusCodes, openStdin, req, res, json, cb) {\n if (err) return cb(err, null);\n\n if (statusCodes[res.statusCode] !== true) {\n getCause(isStream, res, json, function (err, cause) {\n var msg = new Error(\n '(HTTP code ' + res.statusCode + ') ' +\n (statusCodes[res.statusCode] || 'unexpected') + ' - ' +\n (cause.message || cause) + ' '\n );\n msg.reason = statusCodes[res.statusCode];\n msg.statusCode = res.statusCode;\n msg.json = json;\n cb(msg, null);\n });\n } else {\n if (openStdin) {\n cb(null, new HttpDuplex(req, res));\n } else if (isStream) {\n cb(null, res);\n } else {\n cb(null, json);\n }\n }\n\n function getCause(isStream, res, json, callback) {\n var chunks = '';\n if (isStream) {\n res.on('data', function (chunk) {\n chunks += chunk;\n });\n res.on('end', function () {\n callback(null, utils.parseJSON(chunks) || chunks);\n });\n } else {\n callback(null, json);\n }\n }\n};\n\nModem.prototype.demuxStream = function (stream, stdout, stderr) {\n var nextDataType = null;\n var nextDataLength = null;\n var buffer = Buffer.from('');\n function processData(data) {\n if (data) {\n buffer = Buffer.concat([buffer, data]);\n }\n if (!nextDataType) {\n if (buffer.length >= 8) {\n var header = bufferSlice(8);\n nextDataType = header.readUInt8(0);\n nextDataLength = header.readUInt32BE(4);\n // It's possible we got a \"data\" that contains multiple messages\n // Process the next one\n processData();\n }\n } else {\n if (buffer.length >= nextDataLength) {\n var content = bufferSlice(nextDataLength);\n if (nextDataType === 1) {\n stdout.write(content);\n } else {\n stderr.write(content);\n }\n nextDataType = null;\n // It's possible we got a \"data\" that contains multiple messages\n // Process the next one\n processData();\n }\n }\n }\n\n function bufferSlice(end) {\n var out = buffer.slice(0, end);\n buffer = Buffer.from(buffer.slice(end, buffer.length));\n return out;\n }\n\n stream.on('data', processData);\n};\n\nModem.prototype.followProgress = function (stream, onFinished, onProgress) {\n var buf = '';\n var output = [];\n var finished = false;\n\n stream.on('data', onStreamEvent);\n stream.on('error', onStreamError);\n stream.on('end', onStreamEnd);\n stream.on('close', onStreamEnd);\n\n function onStreamEvent(data) {\n buf += data.toString();\n pump();\n\n function pump() {\n var pos;\n while ((pos = buf.indexOf('\\n')) >= 0) {\n if (pos == 0) {\n buf = buf.slice(1);\n continue;\n }\n processLine(buf.slice(0, pos));\n buf = buf.slice(pos + 1);\n }\n }\n\n function processLine(line) {\n if (line[line.length - 1] == '\\r') line = line.substr(0, line.length - 1);\n if (line.length > 0) {\n var obj = JSON.parse(line);\n output.push(obj);\n if (onProgress) {\n onProgress(obj);\n }\n }\n }\n };\n\n function onStreamError(err) {\n finished = true;\n stream.removeListener('data', onStreamEvent);\n stream.removeListener('error', onStreamError);\n stream.removeListener('end', onStreamEnd);\n stream.removeListener('close', onStreamEnd);\n onFinished(err, output);\n }\n\n function onStreamEnd() {\n if(!finished) onFinished(null, output);\n finished = true;\n }\n};\n\nModem.prototype.buildQuerystring = function (opts) {\n var clone = {};\n\n // serialize map values as JSON strings, else querystring truncates.\n Object.keys(opts).map(function (key, i) {\n if (opts[key]\n && typeof opts[key] === 'object'\n && !Array.isArray(opts[key])\n // Ref: https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild\n // > cachefrom (string) JSON array of images used for build cache resolution.\n || key === 'cachefrom'\n ) {\n clone[key] = JSON.stringify(opts[key]);\n } else {\n clone[key] = opts[key];\n }\n });\n\n return querystring.stringify(clone);\n};\n\nmodule.exports = Modem;\n","var Client = require('ssh2').Client,\n http = require('http');\n\nmodule.exports = function(opt) {\n var conn = new Client();\n var agent = new http.Agent();\n\n agent.createConnection = function(options, fn) {\n conn.once('ready', function() {\n conn.exec('docker system dial-stdio', function(err, stream) {\n if (err) {\n conn.end();\n agent.destroy();\n return;\n }\n\n fn(null, stream);\n\n stream.once('close', () => {\n conn.end();\n agent.destroy();\n });\n });\n }).connect(opt);\n\n conn.once('end', () => agent.destroy());\n };\n\n return agent;\n};\n","// https://github.com/HenrikJoreteg/extend-object/blob/v0.1.0/extend-object.js\n\nvar arr = [];\nvar each = arr.forEach;\nvar slice = arr.slice;\n\nmodule.exports.extend = function(obj) {\n each.call(slice.call(arguments, 1), function(source) {\n if (source) {\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n });\n return obj;\n};\n\nmodule.exports.parseJSON = function(s) {\n try {\n return JSON.parse(s);\n } catch (e) {\n return null;\n }\n};\n","var util = require('./util');\n\n/**\n * Represents a config\n * @param {Object} modem docker-modem\n * @param {String} id Config's id\n */\nvar Config = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nConfig.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nConfig.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/configs/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Update a config.\n *\n * @param {object} opts\n * @param {function} callback\n */\nConfig.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/configs/' + this.id + '/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Removes the config\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nConfig.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs/' + this.id,\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Config;\n","var extend = require('./util').extend,\n Exec = require('./exec'),\n util = require('./util');\n\n/**\n * Represents a Container\n * @param {Object} modem docker-modem\n * @param {String} id Container's ID\n */\nvar Container = function(modem, id) {\n this.modem = modem;\n this.id = id;\n\n this.defaultOptions = {\n top: {},\n start: {},\n commit: {},\n stop: {},\n pause: {},\n unpause: {},\n restart: {},\n resize: {},\n attach: {},\n remove: {},\n copy: {},\n kill: {},\n exec: {},\n rename: {},\n log: {},\n stats: {},\n getArchive: {},\n infoArchive: {},\n putArchive: {},\n update: {},\n wait: {}\n };\n};\n\nContainer.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if supplied will query Docker.\n * @return {Object} ID only and only if callback isn't supplied.\n */\nContainer.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/json?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Rename\n * @param {Object} opts Rename options\n * @param {Function} callback Callback\n */\nContainer.prototype.rename = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.rename);\n\n var optsf = {\n path: '/containers/' + this.id + '/rename?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update\n * @param {Object} opts Update options\n * @param {Function} callback Callback\n */\nContainer.prototype.update = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.update);\n\n var optsf = {\n path: '/containers/' + this.id + '/update',\n method: 'POST',\n statusCodes: {\n 200: true,\n 204: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Top\n * @param {Object} opts like 'ps_args' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.top = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.top);\n\n var optsf = {\n path: '/containers/' + this.id + '/top?',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Containers changes\n * @param {Function} callback Callback\n */\nContainer.prototype.changes = function(callback) {\n var self = this;\n var optsf = {\n path: '/containers/' + this.id + '/changes',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Checkpoints list\n * @param {Object} opts List checkpoints options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.listCheckpoint = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints?',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Delete checkpoint\n * @param {Object} opts Delete checkpoint options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.deleteCheckpoint = function(checkpoint, opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints/' + checkpoint + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Create checkpoint\n * @param {Object} opts Create checkpoint options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.createCheckpoint = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints',\n method: 'POST',\n allowEmpty: true,\n statusCodes: {\n 200: true, //unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Export\n * @param {Function} callback Callback with the octet-stream.\n */\nContainer.prototype.export = function(callback) {\n var self = this;\n var optsf = {\n path: '/containers/' + this.id + '/export',\n method: 'GET',\n isStream: true,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Start\n * @param {Object} opts Container start options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.start = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.start);\n\n var optsf = {\n path: '/containers/' + this.id + '/start?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 304: 'container already started',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Pause\n * @param {Object} opts Pause options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.pause = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.pause);\n\n var optsf = {\n path: '/containers/' + this.id + '/pause',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Unpause\n * @param {Object} opts Unpause options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.unpause = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.unpause);\n\n var optsf = {\n path: '/containers/' + this.id + '/unpause',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Setup an exec call to a running container\n *\n * @param {object} opts\n * @param {function} callback\n */\nContainer.prototype.exec = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.exec);\n\n var optsf = {\n path: '/containers/' + this.id + '/exec',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 409: 'container stopped/paused',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(new Exec(self.modem, data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, new Exec(self.modem, data.Id));\n });\n }\n};\n\n/**\n * Commit\n * @param {Object} opts Commit options like 'Hostname' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.commit = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.commit);\n\n args.opts.container = this.id;\n\n var optsf = {\n path: '/commit?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Stop\n * @param {Object} opts Container stop options, like 't' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.stop = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.stop);\n\n var optsf = {\n path: '/containers/' + this.id + '/stop?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 304: 'container already stopped',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Restart\n * @param {Object} opts Container restart options, like 't' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.restart = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.restart);\n\n var optsf = {\n path: '/containers/' + this.id + '/restart?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Kill\n * @param {Object} opts Container kill options, like 'signal' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.kill = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.kill);\n\n var optsf = {\n path: '/containers/' + this.id + '/kill?',\n method: 'POST',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container resize\n * @param {[type]} opts Resize options. (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.resize = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.resize);\n\n var optsf = {\n path: '/containers/' + this.id + '/resize?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Attach\n * @param {Object} opts Attach options, like 'logs' (optional)\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.attach = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.attach);\n\n var optsf = {\n path: '/containers/' + this.id + '/attach?',\n method: 'POST',\n isStream: true,\n hijack: args.opts.hijack,\n openStdin: args.opts.stdin,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, stream) {\n if (err) {\n return reject(err);\n }\n resolve(stream);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, stream) {\n args.callback(err, stream);\n });\n }\n};\n\n/**\n * Waits for a container to end.\n * @param {[type]} opts Container wait options, like condition. (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.wait = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.wait);\n\n var optsf = {\n path: '/containers/' + this.id + '/wait?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes a container\n * @param {Object} opts Remove options, like 'force' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.remove);\n\n var optsf = {\n path: '/containers/' + this.id + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Copy (WARNING: DEPRECATED since RAPI v1.20)\n * @param {Object} opts Copy options, like 'Resource' (optional)\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.copy = function(opts, callback) {\n var self = this;\n console.log('container.copy is deprecated since Docker v1.8.x');\n var args = util.processArgs(opts, callback, this.defaultOptions.copy);\n\n var optsf = {\n path: '/containers/' + this.id + '/copy',\n method: 'POST',\n isStream: true,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * getArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.getArchive = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.getArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'GET',\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * infoArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.infoArchive = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.infoArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'HEAD',\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * putArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.putArchive = function(file, opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.putArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'PUT',\n file: file,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 403: 'client error, permission denied',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nContainer.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.log);\n\n var optsf = {\n path: '/containers/' + this.id + '/logs?',\n method: 'GET',\n isStream: args.opts.follow || false,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container stats\n * @param {Object} opts Stats options. (optional)\n * @param {Function} callback Callback with data\n */\nContainer.prototype.stats = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.stats);\n var isStream = true;\n if (args.opts.stream === false) {\n isStream = false;\n }\n var optsf = {\n path: '/containers/' + this.id + '/stats?',\n method: 'GET',\n isStream: isStream,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Container;\n","var EventEmitter = require('events').EventEmitter,\n Modem = require('docker-modem'),\n tar = require('tar-fs'),\n zlib = require('zlib'),\n Container = require('./container'),\n Image = require('./image'),\n Volume = require('./volume'),\n Network = require('./network'),\n Service = require('./service'),\n Plugin = require('./plugin'),\n Secret = require('./secret'),\n Config = require('./config'),\n Task = require('./task'),\n Node = require('./node'),\n Exec = require('./exec'),\n util = require('./util'),\n extend = util.extend;\n\nvar Docker = function(opts) {\n if (!(this instanceof Docker)) return new Docker(opts);\n\n var plibrary = global.Promise;\n\n if (opts && opts.Promise) {\n plibrary = opts.Promise;\n\n if (Object.keys(opts).length === 1) {\n opts = undefined;\n }\n }\n\n this.modem = new Modem(opts);\n this.modem.Promise = plibrary;\n};\n\n/**\n * Creates a new container\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createContainer = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/containers/create?',\n method: 'POST',\n options: opts,\n authconfig: opts.authconfig,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 406: 'impossible to attach',\n 500: 'server error'\n }\n };\n\n delete opts.authconfig;\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getContainer(data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, self.getContainer(data.Id));\n });\n }\n};\n\n/**\n * Creates a new image\n * @param {Object} auth Authentication (optional)\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createImage = function(auth, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (!callback && !opts) {\n opts = auth;\n auth = opts.authconfig;\n }\n\n var optsf = {\n path: '/images/create?',\n method: 'POST',\n options: opts,\n authconfig: auth,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Load image\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.loadImage = function(file, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n\n var optsf = {\n path: '/images/load?',\n method: 'POST',\n options: opts,\n file: file,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Import image from a tar archive\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.importImage = function(file, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = undefined;\n }\n \n if (!opts)\n opts = {};\n\n opts.fromSrc = '-';\n\n var optsf = {\n path: '/images/create?',\n method: 'POST',\n options: opts,\n file: file,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Verifies auth\n * @param {Object} opts Options\n * @param {Function} callback Callback\n */\nDocker.prototype.checkAuth = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/auth',\n method: 'POST',\n options: opts,\n statusCodes: {\n 200: true,\n 204: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Builds an image\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.buildImage = function(file, opts, callback) {\n var self = this;\n var content;\n\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n\n function build(file) {\n var optsf = {\n path: '/build?',\n method: 'POST',\n file: file,\n options: opts,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (opts) {\n if (opts.registryconfig) {\n optsf.registryconfig = optsf.options.registryconfig;\n delete optsf.options.registryconfig;\n }\n\n //undocumented?\n if (opts.authconfig) {\n optsf.authconfig = optsf.options.authconfig;\n delete optsf.options.authconfig;\n }\n }\n\n if (callback === undefined) {\n return new self.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n self.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n }\n\n if (file && file.context) {\n var pack = tar.pack(file.context, {\n entries: file.src\n });\n return build(pack.pipe(zlib.createGzip()));\n } else {\n return build(file);\n }\n};\n\n/**\n * Fetches a Container by ID\n * @param {String} id Container's ID\n */\nDocker.prototype.getContainer = function(id) {\n return new Container(this.modem, id);\n};\n\n/**\n * Fetches an Image by name\n * @param {String} name Image's name\n */\nDocker.prototype.getImage = function(name) {\n return new Image(this.modem, name);\n};\n\n/**\n * Fetches a Volume by name\n * @param {String} name Volume's name\n */\nDocker.prototype.getVolume = function(name) {\n return new Volume(this.modem, name);\n};\n\n/**\n * Fetches a Plugin by name\n * @param {String} name Volume's name\n */\nDocker.prototype.getPlugin = function(name, remote) {\n return new Plugin(this.modem, name, remote);\n};\n\n/**\n * Fetches a Service by id\n * @param {String} id Services's id\n */\nDocker.prototype.getService = function(id) {\n return new Service(this.modem, id);\n};\n\n/**\n * Fetches a Task by id\n * @param {String} id Task's id\n */\nDocker.prototype.getTask = function(id) {\n return new Task(this.modem, id);\n};\n\n/**\n * Fetches Node by id\n * @param {String} id Node's id\n */\nDocker.prototype.getNode = function(id) {\n return new Node(this.modem, id);\n};\n\n/**\n * Fetches a Network by id\n * @param {String} id network's id\n */\nDocker.prototype.getNetwork = function(id) {\n return new Network(this.modem, id);\n};\n\n/**\n * Fetches a Secret by id\n * @param {String} id network's id\n */\nDocker.prototype.getSecret = function(id) {\n return new Secret(this.modem, id);\n};\n\n/**\n * Fetches a Config by id\n * @param {String} id network's id\n */\nDocker.prototype.getConfig = function(id) {\n return new Config(this.modem, id);\n};\n\n/**\n * Fetches an Exec instance by ID\n * @param {String} id Exec instance's ID\n */\nDocker.prototype.getExec = function(id) {\n return new Exec(this.modem, id);\n};\n\n/**\n * Lists containers\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listContainers = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/json?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/json?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Get images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.getImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/get?',\n method: 'GET',\n options: args.opts,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Services\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listServices = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/services?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Nodes\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listNodes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such node',\n 500: 'server error',\n 503: 'node is not part of a swarm',\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Tasks\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listTasks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/tasks?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new secret\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createSecret = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n var optsf = {\n path: '/secrets/create?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 406: 'server error or node is not part of a swarm',\n 409: 'name conflicts with an existing object',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getSecret(data.ID));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getSecret(data.ID));\n });\n }\n};\n\n\n/**\n * Creates a new config\n * @param {Object} opts Config options\n * @param {Function} callback Callback\n */\nDocker.prototype.createConfig = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n var optsf = {\n path: '/configs/create?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 406: 'server error or node is not part of a swarm',\n 409: 'name conflicts with an existing object',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getConfig(data.ID));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getConfig(data.ID));\n });\n }\n};\n\n\n/**\n * Lists secrets\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listSecrets = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists configs\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listConfigs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new plugin\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createPlugin = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/plugins/create?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getPlugin(args.opts.name));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getPlugin(args.opts.name));\n });\n }\n};\n\n\n/**\n * Lists plugins\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listPlugins = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/prune?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune builder\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneBuilder = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/build/prune',\n method: 'POST',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Prune containers\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneContainers = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/prune?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune volumes\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneVolumes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/prune?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune networks\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneNetworks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/prune?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Creates a new volume\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createVolume = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/volumes/create?',\n method: 'POST',\n allowEmpty: true,\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getVolume(data.Name));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getVolume(data.Name));\n });\n }\n};\n\n/**\n * Creates a new service\n * @param {Object} auth\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createService = function(auth, opts, callback) {\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (!opts && !callback) {\n opts = auth;\n }\n\n\n var self = this;\n var optsf = {\n path: '/services/create',\n method: 'POST',\n options: opts,\n authconfig: auth,\n statusCodes: {\n 200: true,\n 201: true,\n 500: 'server error'\n }\n };\n\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getService(data.ID || data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, self.getService(data.ID || data.Id));\n });\n }\n};\n\n/**\n * Lists volumes\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listVolumes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new network\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createNetwork = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/networks/create?',\n method: 'POST',\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'driver not found',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getNetwork(data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getNetwork(data.Id));\n });\n }\n};\n\n/**\n * Lists networks\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listNetworks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks?',\n method: 'GET',\n options: args.opts,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Search images\n * @param {Object} opts Options\n * @param {Function} callback Callback\n */\nDocker.prototype.searchImages = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/images/search?',\n method: 'GET',\n options: opts,\n authconfig: opts.authconfig,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Info\n * @param {Function} callback Callback with info\n */\nDocker.prototype.info = function(callback) {\n var self = this;\n var opts = {\n path: '/info',\n method: 'GET',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Version\n * @param {Function} callback Callback\n */\nDocker.prototype.version = function(callback) {\n var self = this;\n var opts = {\n path: '/version',\n method: 'GET',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Ping\n * @param {Function} callback Callback\n */\nDocker.prototype.ping = function(callback) {\n var self = this;\n var optsf = {\n path: '/_ping',\n method: 'GET',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * SystemDf \tequivalent to system/df API Engine\n *\t\tget usage data information\n * @param {Function} callback Callback\n */\nDocker.prototype.df = function(callback) {\n var self = this;\n var optsf = {\n path: '/system/df',\n method: 'GET',\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Events\n * @param {Object} opts Events options, like 'since' (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.getEvents = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/events?',\n method: 'GET',\n options: args.opts,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Pull is a wrapper around createImage, parsing image's tags.\n * @param {String} repoTag Repository tag\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n * @param {Object} auth Authentication (optional)\n * @return {Object} Image\n */\nDocker.prototype.pull = function(repoTag, opts, callback, auth) {\n var args = util.processArgs(opts, callback);\n\n var imageSrc = util.parseRepositoryTag(repoTag);\n args.opts.fromImage = imageSrc.repository;\n args.opts.tag = imageSrc.tag || 'latest';\n\n var argsf = [args.opts, args.callback];\n if (auth) {\n argsf = [auth, args.opts, args.callback];\n }\n return this.createImage.apply(this, argsf);\n};\n\n/**\n * Like run command from Docker's CLI\n * @param {String} image Image name to be used.\n * @param {Array} cmd Command to run in array format.\n * @param {Object} streamo Output stream\n * @param {Object} createOptions Container create options (optional)\n * @param {Object} startOptions Container start options (optional)\n * @param {Function} callback Callback\n * @return {Object} EventEmitter\n */\nDocker.prototype.run = function(image, cmd, streamo, createOptions, startOptions, callback) {\n if (typeof arguments[arguments.length - 1] === 'function') {\n return this.runCallback(image, cmd, streamo, createOptions, startOptions, callback);\n } else {\n return this.runPromise(image, cmd, streamo, createOptions, startOptions);\n }\n};\n\n\nDocker.prototype.runCallback = function(image, cmd, streamo, createOptions, startOptions, callback) {\n if (!callback && typeof createOptions === 'function') {\n callback = createOptions;\n createOptions = {};\n startOptions = {};\n } else if (!callback && typeof startOptions === 'function') {\n callback = startOptions;\n startOptions = {};\n }\n\n var hub = new EventEmitter();\n\n function handler(err, container) {\n if (err) return callback(err, null, container);\n\n hub.emit('container', container);\n\n container.attach({\n stream: true,\n stdout: true,\n stderr: true\n }, function handler(err, stream) {\n if (err) return callback(err, null, container);\n\n hub.emit('stream', stream);\n\n if (streamo) {\n if (streamo instanceof Array) {\n stream.on('end', function() {\n try {\n streamo[0].end();\n } catch (e) {}\n try {\n streamo[1].end();\n } catch (e) {}\n });\n container.modem.demuxStream(stream, streamo[0], streamo[1]);\n } else {\n stream.setEncoding('utf8');\n stream.pipe(streamo, {\n end: true\n });\n }\n }\n\n container.start(startOptions, function(err, data) {\n if (err) return callback(err, data, container);\n hub.emit('start', container);\n\n container.wait(function(err, data) {\n hub.emit('data', data);\n callback(err, data, container);\n });\n });\n });\n }\n\n var optsc = {\n 'Hostname': '',\n 'User': '',\n 'AttachStdin': false,\n 'AttachStdout': true,\n 'AttachStderr': true,\n 'Tty': true,\n 'OpenStdin': false,\n 'StdinOnce': false,\n 'Env': null,\n 'Cmd': cmd,\n 'Image': image,\n 'Volumes': {},\n 'VolumesFrom': []\n };\n\n extend(optsc, createOptions);\n\n this.createContainer(optsc, handler);\n\n return hub;\n};\n\nDocker.prototype.runPromise = function(image, cmd, streamo, createOptions, startOptions) {\n var self = this;\n\n createOptions = createOptions || {};\n startOptions = startOptions || {};\n\n var optsc = {\n 'Hostname': '',\n 'User': '',\n 'AttachStdin': false,\n 'AttachStdout': true,\n 'AttachStderr': true,\n 'Tty': true,\n 'OpenStdin': false,\n 'StdinOnce': false,\n 'Env': null,\n 'Cmd': cmd,\n 'Image': image,\n 'Volumes': {},\n 'VolumesFrom': []\n };\n\n extend(optsc, createOptions);\n\n var containero;\n\n return new this.modem.Promise(function(resolve, reject) {\n self.createContainer(optsc).then(function(container) {\n containero = container;\n return container.attach({\n stream: true,\n stdout: true,\n stderr: true\n });\n }).then(function(stream) {\n if (streamo) {\n if (streamo instanceof Array) {\n stream.on('end', function() {\n try {\n streamo[0].end();\n } catch (e) {}\n try {\n streamo[1].end();\n } catch (e) {}\n });\n containero.modem.demuxStream(stream, streamo[0], streamo[1]);\n } else {\n stream.setEncoding('utf8');\n stream.pipe(streamo, {\n end: true\n });\n }\n }\n return containero.start(startOptions);\n }).then(function(data) {\n return containero.wait();\n }).then(function(data) {\n resolve([data, containero]);\n }).catch(function(err) {\n reject(err);\n });\n });\n};\n\n/**\n * Init swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmInit = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/init',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Join swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmJoin = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/join',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Leave swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmLeave = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/leave?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 406: 'node is not part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmUpdate = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Inspect a Swarm.\n * Warning: This method is not documented in the API\n *\n * @param {Function} callback Callback\n */\nDocker.prototype.swarmInspect = function(callback) {\n var self = this;\n var optsf = {\n path: '/swarm',\n method: 'GET',\n statusCodes: {\n 200: true,\n 406: 'This node is not a swarm manager',\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\nDocker.Container = Container;\nDocker.Image = Image;\nDocker.Volume = Volume;\nDocker.Network = Network;\nDocker.Service = Service;\nDocker.Plugin = Plugin;\nDocker.Secret = Secret;\nDocker.Task = Task;\nDocker.Node = Node;\nDocker.Exec = Exec;\n\nmodule.exports = Docker;\n","var util = require('./util');\n\n/**\n * Represents an Exec\n * @param {Object} modem docker-modem\n * @param {String} id Exec's ID\n */\nvar Exec = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nExec.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Start the exec call that was setup.\n *\n * @param {object} opts\n * @param {function} callback\n */\nExec.prototype.start = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/start',\n method: 'POST',\n isStream: true,\n allowEmpty: true,\n hijack: args.opts.hijack,\n openStdin: args.opts.stdin,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such exec',\n 409: 'container stopped/paused',\n 500: 'container not running'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Resize the exec call that was setup.\n *\n * @param {object} opts\n * @param {function} callback\n */\nExec.prototype.resize = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/resize?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'no such exec',\n 500: 'container not running'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Get low-level information about the exec call.\n *\n * @param {function} callback\n */\nExec.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/exec/' + this.id + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such exec',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Exec;\n","var util = require('./util');\n\n/**\n * Represents an image\n * @param {Object} modem docker-modem\n * @param {String} name Image's name\n */\nvar Image = function(modem, name) {\n this.modem = modem;\n this.name = name;\n};\n\nImage.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nImage.prototype.inspect = function(callback) {\n var self = this;\n\n var opts = {\n path: '/images/' + this.name + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Distribution\n * @param {Object} opts\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nImage.prototype.distribution = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n\n var fopts = {\n path: '/distribution/' + this.name + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 401: 'no such image',\n 500: 'server error'\n },\n authconfig: (args.opts) ? args.opts.authconfig : undefined\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(fopts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(fopts, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * History\n * @param {Function} callback Callback\n */\nImage.prototype.history = function(callback) {\n var self = this;\n var opts = {\n path: '/images/' + this.name + '/history',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Get\n * @param {Function} callback Callback with data stream.\n */\nImage.prototype.get = function(callback) {\n var self = this;\n var opts = {\n path: '/images/' + this.name + '/get',\n method: 'GET',\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Push\n * @param {Object} opts Push options, like 'registry' (optional)\n * @param {Function} callback Callback with stream.\n * @param {Object} auth Registry authentication\n */\nImage.prototype.push = function(opts, callback, auth) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var isStream = true;\n if (args.opts.stream === false) {\n isStream = false;\n }\n var optsf = {\n path: '/images/' + this.name + '/push?',\n method: 'POST',\n options: args.opts,\n authconfig: args.opts.authconfig || auth,\n isStream: isStream,\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n delete optsf.options.authconfig;\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Tag\n * @param {Object} opts Tag options, like 'repo' (optional)\n * @param {Function} callback Callback\n */\nImage.prototype.tag = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/images/' + this.name + '/tag?',\n method: 'POST',\n options: opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 400: 'bad parameter',\n 404: 'no such image',\n 409: 'conflict',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Removes the image\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nImage.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n\n var optsf = {\n path: '/images/' + this.name + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Image;\n","var util = require('./util');\n\n/**\n * Represents an network\n * @param {Object} modem docker-modem\n * @param {String} id Network's id\n */\nvar Network = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nNetwork.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Id only if callback isn't specified.\n */\nNetwork.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var opts = {\n path: '/networks/' + this.id + '?',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such network',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes the network\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id,\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such network',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Connects a container to a network\n * @param {[Object]} opts Connect options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.connect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id + '/connect',\n method: 'POST',\n statusCodes: {\n 200: true,\n 201: true,\n 404: 'network or container is not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Disconnects a container from a network\n * @param {[Object]} opts Disconnect options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.disconnect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id + '/disconnect',\n method: 'POST',\n statusCodes: {\n 200: true,\n 201: true,\n 404: 'network or container is not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\n\nmodule.exports = Network;\n","var util = require('./util');\n\n/**\n * Represents an Node\n * @param {Object} modem docker-modem\n * @param {String} id Node's ID\n */\nvar Node = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nNode.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for Node details.\n *\n * @param {function} callback\n */\nNode.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/nodes/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Update a node.\n *\n * @param {object} opts\n * @param {function} callback\n */\nNode.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/nodes/' + this.id + '/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 406: 'node is not part of a swarm',\n 500: 'server error'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Remove a Node.\n * Warning: This method is not documented in the API.\n *\n * @param {object} opts\n * @param {function} callback\n */\nNode.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes/' + this.id + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Node;\n","var util = require('./util');\n\n/**\n * Represents a plugin\n * @param {Object} modem docker-modem\n * @param {String} name Plugin's name\n */\nvar Plugin = function(modem, name, remote) {\n this.modem = modem;\n this.name = name;\n this.remote = remote || name;\n};\n\nPlugin.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nPlugin.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/plugins/' + this.name,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'plugin is not installed',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Removes the plugin\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '?',\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 404: 'plugin is not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * get privileges\n * @param {Function} callback Callback\n * @return {Object} Name only if callback isn't specified.\n */\nPlugin.prototype.privileges = function(callback) {\n var self = this;\n var optsf = {\n path: '/plugins/privileges?',\n method: 'GET',\n options: {\n 'remote': this.remote\n },\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Installs a new plugin\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nPlugin.prototype.pull = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n if(args.opts._query && !args.opts._query.name) {\n args.opts._query.name = this.name;\n }\n if(args.opts._query && !args.opts._query.remote) {\n args.opts._query.remote = this.remote;\n }\n\n var optsf = {\n path: '/plugins/pull?',\n method: 'POST',\n isStream: true,\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Enable\n * @param {Object} opts Plugin enable options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.enable = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/enable?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Disable\n * @param {Object} opts Plugin disable options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.disable = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/disable',\n method: 'POST',\n statusCodes: {\n 200: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Push\n * @param {Object} opts Plugin push options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.push = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/push',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * COnfigure\n * @param {Object} opts Plugin configure options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.configure = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/set',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Upgrade plugin\n *\n * @param {object} auth\n * @param {object} opts\n * @param {function} callback\n */\nPlugin.prototype.upgrade = function(auth, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n }\n\n var optsf = {\n path: '/plugins/' + this.name + '/upgrade?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n authconfig: auth,\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Plugin;\n","var util = require('./util');\n\n/**\n * Represents a secret\n * @param {Object} modem docker-modem\n * @param {String} id Secret's id\n */\nvar Secret = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nSecret.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nSecret.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/secrets/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'secret not found',\n 406: 'node is not part of a swarm',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Update a secret.\n *\n * @param {object} opts\n * @param {function} callback\n */\nSecret.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/secrets/' + this.id + '/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'secret not found',\n 500: 'server error'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Removes the secret\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nSecret.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets/' + this.id,\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'secret not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Secret;\n","var util = require('./util');\n\n/**\n * Represents an Service\n * @param {Object} modem docker-modem\n * @param {String} id Service's ID\n */\nvar Service = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nService.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for service details.\n *\n * @param {function} callback\n */\nService.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/services/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Delete Service\n *\n * @param {function} callback\n */\nService.prototype.remove = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/services/' + this.id,\n method: 'DELETE',\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such service',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Update service\n *\n * @param {object} auth\n * @param {object} opts\n * @param {function} callback\n */\nService.prototype.update = function(auth, opts, callback) {\n var self = this;\n if (!callback) {\n var t = typeof opts;\n if(t === 'function'){\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (t === 'undefined'){\n opts = auth;\n auth = opts.authconfig || undefined;\n }\n }\n\n var optsf = {\n path: '/services/' + this.id + '/update?',\n method: 'POST',\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error'\n },\n authconfig: auth,\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n\n/**\n * Service logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nService.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, {});\n\n var optsf = {\n path: '/services/' + this.id + '/logs?',\n method: 'GET',\n isStream: args.opts.follow || false,\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Service;\n","var util = require('./util');\n\n/**\n * Represents an Task\n * @param {Object} modem docker-modem\n * @param {String} id Task's ID\n */\nvar Task = function(modem, id) {\n this.modem = modem;\n this.id = id;\n\n this.defaultOptions = {\n log: {}\n };\n};\n\nTask.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for Task details.\n *\n * @param {function} callback\n */\nTask.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/tasks/' + this.id,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'unknown task',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Task logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nTask.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.log);\n\n var optsf = {\n path: '/tasks/' + this.id + '/logs?',\n method: 'GET',\n isStream: args.opts.follow || false,\n statusCodes: {\n 101: true,\n 200: true,\n 404: 'no such container',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Task;\n","// https://github.com/HenrikJoreteg/extend-object/blob/v0.1.0/extend-object.js\n\nvar arr = [];\nvar each = arr.forEach;\nvar slice = arr.slice;\n\nmodule.exports.extend = function(obj) {\n each.call(slice.call(arguments, 1), function(source) {\n if (source) {\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n });\n return obj;\n};\n\nmodule.exports.processArgs = function(opts, callback, defaultOpts) {\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n return {\n callback: callback,\n opts: module.exports.extend({}, defaultOpts, opts)\n };\n};\n\n\n/**\n * Parse the given repo tag name (as a string) and break it out into repo/tag pair.\n * // if given the input http://localhost:8080/woot:latest\n * {\n * repository: 'http://localhost:8080/woot',\n * tag: 'latest'\n * }\n * @param {String} input Input e.g: 'repo/foo', 'ubuntu', 'ubuntu:latest'\n * @return {Object} input parsed into the repo and tag.\n */\nmodule.exports.parseRepositoryTag = function(input) {\n var separatorPos;\n var digestPos = input.indexOf('@');\n var colonPos = input.lastIndexOf(':');\n // @ symbol is more important\n if (digestPos >= 0) {\n separatorPos = digestPos;\n } else if (colonPos >= 0) {\n separatorPos = colonPos;\n } else {\n // no colon nor @\n return {\n repository: input\n };\n }\n\n // last colon is either the tag (or part of a port designation)\n var tag = input.slice(separatorPos + 1);\n\n // if it contains a / its not a tag and is part of the url\n if (tag.indexOf('/') === -1) {\n return {\n repository: input.slice(0, separatorPos),\n tag: tag\n };\n }\n\n return {\n repository: input\n };\n};\n","var util = require('./util');\n\n/**\n * Represents a volume\n * @param {Object} modem docker-modem\n * @param {String} name Volume's name\n */\nvar Volume = function(modem, name) {\n this.modem = modem;\n this.name = name;\n};\n\nVolume.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nVolume.prototype.inspect = function(callback) {\n var self = this;\n\n var optsf = {\n path: '/volumes/' + this.name,\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such volume',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Removes the volume\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nVolume.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/' + this.name,\n method: 'DELETE',\n statusCodes: {\n 204: true,\n 404: 'no such volume',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Volume;\n","var once = require('once');\n\nvar noop = function() {};\n\nvar isRequest = function(stream) {\n\treturn stream.setHeader && typeof stream.abort === 'function';\n};\n\nvar isChildProcess = function(stream) {\n\treturn stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3\n};\n\nvar eos = function(stream, opts, callback) {\n\tif (typeof opts === 'function') return eos(stream, null, opts);\n\tif (!opts) opts = {};\n\n\tcallback = once(callback || noop);\n\n\tvar ws = stream._writableState;\n\tvar rs = stream._readableState;\n\tvar readable = opts.readable || (opts.readable !== false && stream.readable);\n\tvar writable = opts.writable || (opts.writable !== false && stream.writable);\n\tvar cancelled = false;\n\n\tvar onlegacyfinish = function() {\n\t\tif (!stream.writable) onfinish();\n\t};\n\n\tvar onfinish = function() {\n\t\twritable = false;\n\t\tif (!readable) callback.call(stream);\n\t};\n\n\tvar onend = function() {\n\t\treadable = false;\n\t\tif (!writable) callback.call(stream);\n\t};\n\n\tvar onexit = function(exitCode) {\n\t\tcallback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);\n\t};\n\n\tvar onerror = function(err) {\n\t\tcallback.call(stream, err);\n\t};\n\n\tvar onclose = function() {\n\t\tprocess.nextTick(onclosenexttick);\n\t};\n\n\tvar onclosenexttick = function() {\n\t\tif (cancelled) return;\n\t\tif (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close'));\n\t\tif (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close'));\n\t};\n\n\tvar onrequest = function() {\n\t\tstream.req.on('finish', onfinish);\n\t};\n\n\tif (isRequest(stream)) {\n\t\tstream.on('complete', onfinish);\n\t\tstream.on('abort', onclose);\n\t\tif (stream.req) onrequest();\n\t\telse stream.on('request', onrequest);\n\t} else if (writable && !ws) { // legacy streams\n\t\tstream.on('end', onlegacyfinish);\n\t\tstream.on('close', onlegacyfinish);\n\t}\n\n\tif (isChildProcess(stream)) stream.on('exit', onexit);\n\n\tstream.on('end', onend);\n\tstream.on('finish', onfinish);\n\tif (opts.error !== false) stream.on('error', onerror);\n\tstream.on('close', onclose);\n\n\treturn function() {\n\t\tcancelled = true;\n\t\tstream.removeListener('complete', onfinish);\n\t\tstream.removeListener('abort', onclose);\n\t\tstream.removeListener('request', onrequest);\n\t\tif (stream.req) stream.req.removeListener('finish', onfinish);\n\t\tstream.removeListener('end', onlegacyfinish);\n\t\tstream.removeListener('close', onlegacyfinish);\n\t\tstream.removeListener('finish', onfinish);\n\t\tstream.removeListener('exit', onexit);\n\t\tstream.removeListener('end', onend);\n\t\tstream.removeListener('error', onerror);\n\t\tstream.removeListener('close', onclose);\n\t};\n};\n\nmodule.exports = eos;\n","var debug;\n\nmodule.exports = function () {\n if (!debug) {\n try {\n /* eslint global-require: off */\n debug = require(\"debug\")(\"follow-redirects\");\n }\n catch (error) { /* */ }\n if (typeof debug !== \"function\") {\n debug = function () { /* */ };\n }\n }\n debug.apply(null, arguments);\n};\n","var url = require(\"url\");\nvar URL = url.URL;\nvar http = require(\"http\");\nvar https = require(\"https\");\nvar Writable = require(\"stream\").Writable;\nvar assert = require(\"assert\");\nvar debug = require(\"./debug\");\n\n// Create handlers that pass events from native requests\nvar events = [\"abort\", \"aborted\", \"connect\", \"error\", \"socket\", \"timeout\"];\nvar eventHandlers = Object.create(null);\nevents.forEach(function (event) {\n eventHandlers[event] = function (arg1, arg2, arg3) {\n this._redirectable.emit(event, arg1, arg2, arg3);\n };\n});\n\n// Error types with codes\nvar RedirectionError = createErrorType(\n \"ERR_FR_REDIRECTION_FAILURE\",\n \"\"\n);\nvar TooManyRedirectsError = createErrorType(\n \"ERR_FR_TOO_MANY_REDIRECTS\",\n \"Maximum number of redirects exceeded\"\n);\nvar MaxBodyLengthExceededError = createErrorType(\n \"ERR_FR_MAX_BODY_LENGTH_EXCEEDED\",\n \"Request body larger than maxBodyLength limit\"\n);\nvar WriteAfterEndError = createErrorType(\n \"ERR_STREAM_WRITE_AFTER_END\",\n \"write after end\"\n);\n\n// An HTTP(S) request that can be redirected\nfunction RedirectableRequest(options, responseCallback) {\n // Initialize the request\n Writable.call(this);\n this._sanitizeOptions(options);\n this._options = options;\n this._ended = false;\n this._ending = false;\n this._redirectCount = 0;\n this._redirects = [];\n this._requestBodyLength = 0;\n this._requestBodyBuffers = [];\n\n // Attach a callback if passed\n if (responseCallback) {\n this.on(\"response\", responseCallback);\n }\n\n // React to responses of native requests\n var self = this;\n this._onNativeResponse = function (response) {\n self._processResponse(response);\n };\n\n // Perform the first request\n this._performRequest();\n}\nRedirectableRequest.prototype = Object.create(Writable.prototype);\n\nRedirectableRequest.prototype.abort = function () {\n abortRequest(this._currentRequest);\n this.emit(\"abort\");\n};\n\n// Writes buffered data to the current native request\nRedirectableRequest.prototype.write = function (data, encoding, callback) {\n // Writing is not allowed if end has been called\n if (this._ending) {\n throw new WriteAfterEndError();\n }\n\n // Validate input and shift parameters if necessary\n if (!(typeof data === \"string\" || typeof data === \"object\" && (\"length\" in data))) {\n throw new TypeError(\"data should be a string, Buffer or Uint8Array\");\n }\n if (typeof encoding === \"function\") {\n callback = encoding;\n encoding = null;\n }\n\n // Ignore empty buffers, since writing them doesn't invoke the callback\n // https://github.com/nodejs/node/issues/22066\n if (data.length === 0) {\n if (callback) {\n callback();\n }\n return;\n }\n // Only write when we don't exceed the maximum body length\n if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {\n this._requestBodyLength += data.length;\n this._requestBodyBuffers.push({ data: data, encoding: encoding });\n this._currentRequest.write(data, encoding, callback);\n }\n // Error when we exceed the maximum body length\n else {\n this.emit(\"error\", new MaxBodyLengthExceededError());\n this.abort();\n }\n};\n\n// Ends the current native request\nRedirectableRequest.prototype.end = function (data, encoding, callback) {\n // Shift parameters if necessary\n if (typeof data === \"function\") {\n callback = data;\n data = encoding = null;\n }\n else if (typeof encoding === \"function\") {\n callback = encoding;\n encoding = null;\n }\n\n // Write data if needed and end\n if (!data) {\n this._ended = this._ending = true;\n this._currentRequest.end(null, null, callback);\n }\n else {\n var self = this;\n var currentRequest = this._currentRequest;\n this.write(data, encoding, function () {\n self._ended = true;\n currentRequest.end(null, null, callback);\n });\n this._ending = true;\n }\n};\n\n// Sets a header value on the current native request\nRedirectableRequest.prototype.setHeader = function (name, value) {\n this._options.headers[name] = value;\n this._currentRequest.setHeader(name, value);\n};\n\n// Clears a header value on the current native request\nRedirectableRequest.prototype.removeHeader = function (name) {\n delete this._options.headers[name];\n this._currentRequest.removeHeader(name);\n};\n\n// Global timeout for all underlying requests\nRedirectableRequest.prototype.setTimeout = function (msecs, callback) {\n var self = this;\n\n // Destroys the socket on timeout\n function destroyOnTimeout(socket) {\n socket.setTimeout(msecs);\n socket.removeListener(\"timeout\", socket.destroy);\n socket.addListener(\"timeout\", socket.destroy);\n }\n\n // Sets up a timer to trigger a timeout event\n function startTimer(socket) {\n if (self._timeout) {\n clearTimeout(self._timeout);\n }\n self._timeout = setTimeout(function () {\n self.emit(\"timeout\");\n clearTimer();\n }, msecs);\n destroyOnTimeout(socket);\n }\n\n // Stops a timeout from triggering\n function clearTimer() {\n if (self._timeout) {\n clearTimeout(self._timeout);\n self._timeout = null;\n }\n if (callback) {\n self.removeListener(\"timeout\", callback);\n }\n if (!self.socket) {\n self._currentRequest.removeListener(\"socket\", startTimer);\n }\n }\n\n // Attach callback if passed\n if (callback) {\n this.on(\"timeout\", callback);\n }\n\n // Start the timer if or when the socket is opened\n if (this.socket) {\n startTimer(this.socket);\n }\n else {\n this._currentRequest.once(\"socket\", startTimer);\n }\n\n // Clean up on events\n this.on(\"socket\", destroyOnTimeout);\n this.once(\"response\", clearTimer);\n this.once(\"error\", clearTimer);\n\n return this;\n};\n\n// Proxy all other public ClientRequest methods\n[\n \"flushHeaders\", \"getHeader\",\n \"setNoDelay\", \"setSocketKeepAlive\",\n].forEach(function (method) {\n RedirectableRequest.prototype[method] = function (a, b) {\n return this._currentRequest[method](a, b);\n };\n});\n\n// Proxy all public ClientRequest properties\n[\"aborted\", \"connection\", \"socket\"].forEach(function (property) {\n Object.defineProperty(RedirectableRequest.prototype, property, {\n get: function () { return this._currentRequest[property]; },\n });\n});\n\nRedirectableRequest.prototype._sanitizeOptions = function (options) {\n // Ensure headers are always present\n if (!options.headers) {\n options.headers = {};\n }\n\n // Since http.request treats host as an alias of hostname,\n // but the url module interprets host as hostname plus port,\n // eliminate the host property to avoid confusion.\n if (options.host) {\n // Use hostname if set, because it has precedence\n if (!options.hostname) {\n options.hostname = options.host;\n }\n delete options.host;\n }\n\n // Complete the URL object when necessary\n if (!options.pathname && options.path) {\n var searchPos = options.path.indexOf(\"?\");\n if (searchPos < 0) {\n options.pathname = options.path;\n }\n else {\n options.pathname = options.path.substring(0, searchPos);\n options.search = options.path.substring(searchPos);\n }\n }\n};\n\n\n// Executes the next native request (initial or redirect)\nRedirectableRequest.prototype._performRequest = function () {\n // Load the native protocol\n var protocol = this._options.protocol;\n var nativeProtocol = this._options.nativeProtocols[protocol];\n if (!nativeProtocol) {\n this.emit(\"error\", new TypeError(\"Unsupported protocol \" + protocol));\n return;\n }\n\n // If specified, use the agent corresponding to the protocol\n // (HTTP and HTTPS use different types of agents)\n if (this._options.agents) {\n var scheme = protocol.substr(0, protocol.length - 1);\n this._options.agent = this._options.agents[scheme];\n }\n\n // Create the native request\n var request = this._currentRequest =\n nativeProtocol.request(this._options, this._onNativeResponse);\n this._currentUrl = url.format(this._options);\n\n // Set up event handlers\n request._redirectable = this;\n for (var e = 0; e < events.length; e++) {\n request.on(events[e], eventHandlers[events[e]]);\n }\n\n // End a redirected request\n // (The first request must be ended explicitly with RedirectableRequest#end)\n if (this._isRedirect) {\n // Write the request entity and end.\n var i = 0;\n var self = this;\n var buffers = this._requestBodyBuffers;\n (function writeNext(error) {\n // Only write if this request has not been redirected yet\n /* istanbul ignore else */\n if (request === self._currentRequest) {\n // Report any write errors\n /* istanbul ignore if */\n if (error) {\n self.emit(\"error\", error);\n }\n // Write the next buffer if there are still left\n else if (i < buffers.length) {\n var buffer = buffers[i++];\n /* istanbul ignore else */\n if (!request.finished) {\n request.write(buffer.data, buffer.encoding, writeNext);\n }\n }\n // End the request if `end` has been called on us\n else if (self._ended) {\n request.end();\n }\n }\n }());\n }\n};\n\n// Processes a response from the current native request\nRedirectableRequest.prototype._processResponse = function (response) {\n // Store the redirected response\n var statusCode = response.statusCode;\n if (this._options.trackRedirects) {\n this._redirects.push({\n url: this._currentUrl,\n headers: response.headers,\n statusCode: statusCode,\n });\n }\n\n // RFC7231§6.4: The 3xx (Redirection) class of status code indicates\n // that further action needs to be taken by the user agent in order to\n // fulfill the request. If a Location header field is provided,\n // the user agent MAY automatically redirect its request to the URI\n // referenced by the Location field value,\n // even if the specific status code is not understood.\n var location = response.headers.location;\n if (location && this._options.followRedirects !== false &&\n statusCode >= 300 && statusCode < 400) {\n // Abort the current request\n abortRequest(this._currentRequest);\n // Discard the remainder of the response to avoid waiting for data\n response.destroy();\n\n // RFC7231§6.4: A client SHOULD detect and intervene\n // in cyclical redirections (i.e., \"infinite\" redirection loops).\n if (++this._redirectCount > this._options.maxRedirects) {\n this.emit(\"error\", new TooManyRedirectsError());\n return;\n }\n\n // RFC7231§6.4: Automatic redirection needs to done with\n // care for methods not known to be safe, […]\n // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change\n // the request method from POST to GET for the subsequent request.\n if ((statusCode === 301 || statusCode === 302) && this._options.method === \"POST\" ||\n // RFC7231§6.4.4: The 303 (See Other) status code indicates that\n // the server is redirecting the user agent to a different resource […]\n // A user agent can perform a retrieval request targeting that URI\n // (a GET or HEAD request if using HTTP) […]\n (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {\n this._options.method = \"GET\";\n // Drop a possible entity and headers related to it\n this._requestBodyBuffers = [];\n removeMatchingHeaders(/^content-/i, this._options.headers);\n }\n\n // Drop the Host header, as the redirect might lead to a different host\n var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) ||\n url.parse(this._currentUrl).hostname;\n\n // Create the redirected request\n var redirectUrl = url.resolve(this._currentUrl, location);\n debug(\"redirecting to\", redirectUrl);\n this._isRedirect = true;\n var redirectUrlParts = url.parse(redirectUrl);\n Object.assign(this._options, redirectUrlParts);\n\n // Drop the Authorization header if redirecting to another host\n if (redirectUrlParts.hostname !== previousHostName) {\n removeMatchingHeaders(/^authorization$/i, this._options.headers);\n }\n\n // Evaluate the beforeRedirect callback\n if (typeof this._options.beforeRedirect === \"function\") {\n var responseDetails = { headers: response.headers };\n try {\n this._options.beforeRedirect.call(null, this._options, responseDetails);\n }\n catch (err) {\n this.emit(\"error\", err);\n return;\n }\n this._sanitizeOptions(this._options);\n }\n\n // Perform the redirected request\n try {\n this._performRequest();\n }\n catch (cause) {\n var error = new RedirectionError(\"Redirected request failed: \" + cause.message);\n error.cause = cause;\n this.emit(\"error\", error);\n }\n }\n else {\n // The response is not a redirect; return it as-is\n response.responseUrl = this._currentUrl;\n response.redirects = this._redirects;\n this.emit(\"response\", response);\n\n // Clean up\n this._requestBodyBuffers = [];\n }\n};\n\n// Wraps the key/value object of protocols with redirect functionality\nfunction wrap(protocols) {\n // Default settings\n var exports = {\n maxRedirects: 21,\n maxBodyLength: 10 * 1024 * 1024,\n };\n\n // Wrap each protocol\n var nativeProtocols = {};\n Object.keys(protocols).forEach(function (scheme) {\n var protocol = scheme + \":\";\n var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];\n var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);\n\n // Executes a request, following redirects\n function request(input, options, callback) {\n // Parse parameters\n if (typeof input === \"string\") {\n var urlStr = input;\n try {\n input = urlToOptions(new URL(urlStr));\n }\n catch (err) {\n /* istanbul ignore next */\n input = url.parse(urlStr);\n }\n }\n else if (URL && (input instanceof URL)) {\n input = urlToOptions(input);\n }\n else {\n callback = options;\n options = input;\n input = { protocol: protocol };\n }\n if (typeof options === \"function\") {\n callback = options;\n options = null;\n }\n\n // Set defaults\n options = Object.assign({\n maxRedirects: exports.maxRedirects,\n maxBodyLength: exports.maxBodyLength,\n }, input, options);\n options.nativeProtocols = nativeProtocols;\n\n assert.equal(options.protocol, protocol, \"protocol mismatch\");\n debug(\"options\", options);\n return new RedirectableRequest(options, callback);\n }\n\n // Executes a GET request, following redirects\n function get(input, options, callback) {\n var wrappedRequest = wrappedProtocol.request(input, options, callback);\n wrappedRequest.end();\n return wrappedRequest;\n }\n\n // Expose the properties on the wrapped protocol\n Object.defineProperties(wrappedProtocol, {\n request: { value: request, configurable: true, enumerable: true, writable: true },\n get: { value: get, configurable: true, enumerable: true, writable: true },\n });\n });\n return exports;\n}\n\n/* istanbul ignore next */\nfunction noop() { /* empty */ }\n\n// from https://github.com/nodejs/node/blob/master/lib/internal/url.js\nfunction urlToOptions(urlObject) {\n var options = {\n protocol: urlObject.protocol,\n hostname: urlObject.hostname.startsWith(\"[\") ?\n /* istanbul ignore next */\n urlObject.hostname.slice(1, -1) :\n urlObject.hostname,\n hash: urlObject.hash,\n search: urlObject.search,\n pathname: urlObject.pathname,\n path: urlObject.pathname + urlObject.search,\n href: urlObject.href,\n };\n if (urlObject.port !== \"\") {\n options.port = Number(urlObject.port);\n }\n return options;\n}\n\nfunction removeMatchingHeaders(regex, headers) {\n var lastValue;\n for (var header in headers) {\n if (regex.test(header)) {\n lastValue = headers[header];\n delete headers[header];\n }\n }\n return lastValue;\n}\n\nfunction createErrorType(code, defaultMessage) {\n function CustomError(message) {\n Error.captureStackTrace(this, this.constructor);\n this.message = message || defaultMessage;\n }\n CustomError.prototype = new Error();\n CustomError.prototype.constructor = CustomError;\n CustomError.prototype.name = \"Error [\" + code + \"]\";\n CustomError.prototype.code = code;\n return CustomError;\n}\n\nfunction abortRequest(request) {\n for (var e = 0; e < events.length; e++) {\n request.removeListener(events[e], eventHandlers[events[e]]);\n }\n request.on(\"error\", noop);\n request.abort();\n}\n\n// Exports\nmodule.exports = wrap({ http: http, https: https });\nmodule.exports.wrap = wrap;\n","module.exports = require('fs').constants || require('constants')\n","'use strict';\n\nmodule.exports = (flag, argv = process.argv) => {\n\tconst prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');\n\tconst position = argv.indexOf(prefix + flag);\n\tconst terminatorPosition = argv.indexOf('--');\n\treturn position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n};\n","try {\n var util = require('util');\n /* istanbul ignore next */\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n /* istanbul ignore next */\n module.exports = require('./inherits_browser.js');\n}\n","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n }\n}\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\n/*!\n * is-plain-object \n *\n * Copyright (c) 2014-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\n\nfunction isObject(o) {\n return Object.prototype.toString.call(o) === '[object Object]';\n}\n\nfunction isPlainObject(o) {\n var ctor,prot;\n\n if (isObject(o) === false) return false;\n\n // If has modified constructor\n ctor = o.constructor;\n if (ctor === undefined) return true;\n\n // If has modified prototype\n prot = ctor.prototype;\n if (isObject(prot) === false) return false;\n\n // If constructor does not have an Object-specific method\n if (prot.hasOwnProperty('isPrototypeOf') === false) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n\nexports.isPlainObject = isPlainObject;\n","var path = require('path');\nvar fs = require('fs');\nvar _0777 = parseInt('0777', 8);\n\nmodule.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;\n\nfunction mkdirP (p, opts, f, made) {\n if (typeof opts === 'function') {\n f = opts;\n opts = {};\n }\n else if (!opts || typeof opts !== 'object') {\n opts = { mode: opts };\n }\n \n var mode = opts.mode;\n var xfs = opts.fs || fs;\n \n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n \n var cb = f || function () {};\n p = path.resolve(p);\n \n xfs.mkdir(p, mode, function (er) {\n if (!er) {\n made = made || p;\n return cb(null, made);\n }\n switch (er.code) {\n case 'ENOENT':\n mkdirP(path.dirname(p), opts, function (er, made) {\n if (er) cb(er, made);\n else mkdirP(p, opts, cb, made);\n });\n break;\n\n // In the case of any other error, just see if there's a dir\n // there already. If so, then hooray! If not, then something\n // is borked.\n default:\n xfs.stat(p, function (er2, stat) {\n // if the stat fails, then that's super weird.\n // let the original error be the failure reason.\n if (er2 || !stat.isDirectory()) cb(er, made)\n else cb(null, made);\n });\n break;\n }\n });\n}\n\nmkdirP.sync = function sync (p, opts, made) {\n if (!opts || typeof opts !== 'object') {\n opts = { mode: opts };\n }\n \n var mode = opts.mode;\n var xfs = opts.fs || fs;\n \n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n\n p = path.resolve(p);\n\n try {\n xfs.mkdirSync(p, mode);\n made = made || p;\n }\n catch (err0) {\n switch (err0.code) {\n case 'ENOENT' :\n made = sync(path.dirname(p), opts, made);\n sync(p, opts, made);\n break;\n\n // In the case of any other error, just see if there's a dir\n // there already. If so, then hooray! If not, then something\n // is borked.\n default:\n var stat;\n try {\n stat = xfs.statSync(p);\n }\n catch (err1) {\n throw err0;\n }\n if (!stat.isDirectory()) throw err0;\n break;\n }\n }\n\n return made;\n};\n","/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar Stream = _interopDefault(require('stream'));\nvar http = _interopDefault(require('http'));\nvar Url = _interopDefault(require('url'));\nvar https = _interopDefault(require('https'));\nvar zlib = _interopDefault(require('zlib'));\n\n// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js\n\n// fix for \"Readable\" isn't a named export issue\nconst Readable = Stream.Readable;\n\nconst BUFFER = Symbol('buffer');\nconst TYPE = Symbol('type');\n\nclass Blob {\n\tconstructor() {\n\t\tthis[TYPE] = '';\n\n\t\tconst blobParts = arguments[0];\n\t\tconst options = arguments[1];\n\n\t\tconst buffers = [];\n\t\tlet size = 0;\n\n\t\tif (blobParts) {\n\t\t\tconst a = blobParts;\n\t\t\tconst length = Number(a.length);\n\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\tconst element = a[i];\n\t\t\t\tlet buffer;\n\t\t\t\tif (element instanceof Buffer) {\n\t\t\t\t\tbuffer = element;\n\t\t\t\t} else if (ArrayBuffer.isView(element)) {\n\t\t\t\t\tbuffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength);\n\t\t\t\t} else if (element instanceof ArrayBuffer) {\n\t\t\t\t\tbuffer = Buffer.from(element);\n\t\t\t\t} else if (element instanceof Blob) {\n\t\t\t\t\tbuffer = element[BUFFER];\n\t\t\t\t} else {\n\t\t\t\t\tbuffer = Buffer.from(typeof element === 'string' ? element : String(element));\n\t\t\t\t}\n\t\t\t\tsize += buffer.length;\n\t\t\t\tbuffers.push(buffer);\n\t\t\t}\n\t\t}\n\n\t\tthis[BUFFER] = Buffer.concat(buffers);\n\n\t\tlet type = options && options.type !== undefined && String(options.type).toLowerCase();\n\t\tif (type && !/[^\\u0020-\\u007E]/.test(type)) {\n\t\t\tthis[TYPE] = type;\n\t\t}\n\t}\n\tget size() {\n\t\treturn this[BUFFER].length;\n\t}\n\tget type() {\n\t\treturn this[TYPE];\n\t}\n\ttext() {\n\t\treturn Promise.resolve(this[BUFFER].toString());\n\t}\n\tarrayBuffer() {\n\t\tconst buf = this[BUFFER];\n\t\tconst ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n\t\treturn Promise.resolve(ab);\n\t}\n\tstream() {\n\t\tconst readable = new Readable();\n\t\treadable._read = function () {};\n\t\treadable.push(this[BUFFER]);\n\t\treadable.push(null);\n\t\treturn readable;\n\t}\n\ttoString() {\n\t\treturn '[object Blob]';\n\t}\n\tslice() {\n\t\tconst size = this.size;\n\n\t\tconst start = arguments[0];\n\t\tconst end = arguments[1];\n\t\tlet relativeStart, relativeEnd;\n\t\tif (start === undefined) {\n\t\t\trelativeStart = 0;\n\t\t} else if (start < 0) {\n\t\t\trelativeStart = Math.max(size + start, 0);\n\t\t} else {\n\t\t\trelativeStart = Math.min(start, size);\n\t\t}\n\t\tif (end === undefined) {\n\t\t\trelativeEnd = size;\n\t\t} else if (end < 0) {\n\t\t\trelativeEnd = Math.max(size + end, 0);\n\t\t} else {\n\t\t\trelativeEnd = Math.min(end, size);\n\t\t}\n\t\tconst span = Math.max(relativeEnd - relativeStart, 0);\n\n\t\tconst buffer = this[BUFFER];\n\t\tconst slicedBuffer = buffer.slice(relativeStart, relativeStart + span);\n\t\tconst blob = new Blob([], { type: arguments[2] });\n\t\tblob[BUFFER] = slicedBuffer;\n\t\treturn blob;\n\t}\n}\n\nObject.defineProperties(Blob.prototype, {\n\tsize: { enumerable: true },\n\ttype: { enumerable: true },\n\tslice: { enumerable: true }\n});\n\nObject.defineProperty(Blob.prototype, Symbol.toStringTag, {\n\tvalue: 'Blob',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\n/**\n * fetch-error.js\n *\n * FetchError interface for operational errors\n */\n\n/**\n * Create FetchError instance\n *\n * @param String message Error message for human\n * @param String type Error type for machine\n * @param String systemError For Node.js system error\n * @return FetchError\n */\nfunction FetchError(message, type, systemError) {\n Error.call(this, message);\n\n this.message = message;\n this.type = type;\n\n // when err.type is `system`, err.code contains system error code\n if (systemError) {\n this.code = this.errno = systemError.code;\n }\n\n // hide custom error implementation details from end-users\n Error.captureStackTrace(this, this.constructor);\n}\n\nFetchError.prototype = Object.create(Error.prototype);\nFetchError.prototype.constructor = FetchError;\nFetchError.prototype.name = 'FetchError';\n\nlet convert;\ntry {\n\tconvert = require('encoding').convert;\n} catch (e) {}\n\nconst INTERNALS = Symbol('Body internals');\n\n// fix an issue where \"PassThrough\" isn't a named export for node <10\nconst PassThrough = Stream.PassThrough;\n\n/**\n * Body mixin\n *\n * Ref: https://fetch.spec.whatwg.org/#body\n *\n * @param Stream body Readable stream\n * @param Object opts Response options\n * @return Void\n */\nfunction Body(body) {\n\tvar _this = this;\n\n\tvar _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n\t _ref$size = _ref.size;\n\n\tlet size = _ref$size === undefined ? 0 : _ref$size;\n\tvar _ref$timeout = _ref.timeout;\n\tlet timeout = _ref$timeout === undefined ? 0 : _ref$timeout;\n\n\tif (body == null) {\n\t\t// body is undefined or null\n\t\tbody = null;\n\t} else if (isURLSearchParams(body)) {\n\t\t// body is a URLSearchParams\n\t\tbody = Buffer.from(body.toString());\n\t} else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {\n\t\t// body is ArrayBuffer\n\t\tbody = Buffer.from(body);\n\t} else if (ArrayBuffer.isView(body)) {\n\t\t// body is ArrayBufferView\n\t\tbody = Buffer.from(body.buffer, body.byteOffset, body.byteLength);\n\t} else if (body instanceof Stream) ; else {\n\t\t// none of the above\n\t\t// coerce to string then buffer\n\t\tbody = Buffer.from(String(body));\n\t}\n\tthis[INTERNALS] = {\n\t\tbody,\n\t\tdisturbed: false,\n\t\terror: null\n\t};\n\tthis.size = size;\n\tthis.timeout = timeout;\n\n\tif (body instanceof Stream) {\n\t\tbody.on('error', function (err) {\n\t\t\tconst error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err);\n\t\t\t_this[INTERNALS].error = error;\n\t\t});\n\t}\n}\n\nBody.prototype = {\n\tget body() {\n\t\treturn this[INTERNALS].body;\n\t},\n\n\tget bodyUsed() {\n\t\treturn this[INTERNALS].disturbed;\n\t},\n\n\t/**\n * Decode response as ArrayBuffer\n *\n * @return Promise\n */\n\tarrayBuffer() {\n\t\treturn consumeBody.call(this).then(function (buf) {\n\t\t\treturn buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n\t\t});\n\t},\n\n\t/**\n * Return raw response as Blob\n *\n * @return Promise\n */\n\tblob() {\n\t\tlet ct = this.headers && this.headers.get('content-type') || '';\n\t\treturn consumeBody.call(this).then(function (buf) {\n\t\t\treturn Object.assign(\n\t\t\t// Prevent copying\n\t\t\tnew Blob([], {\n\t\t\t\ttype: ct.toLowerCase()\n\t\t\t}), {\n\t\t\t\t[BUFFER]: buf\n\t\t\t});\n\t\t});\n\t},\n\n\t/**\n * Decode response as json\n *\n * @return Promise\n */\n\tjson() {\n\t\tvar _this2 = this;\n\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(buffer.toString());\n\t\t\t} catch (err) {\n\t\t\t\treturn Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));\n\t\t\t}\n\t\t});\n\t},\n\n\t/**\n * Decode response as text\n *\n * @return Promise\n */\n\ttext() {\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\treturn buffer.toString();\n\t\t});\n\t},\n\n\t/**\n * Decode response as buffer (non-spec api)\n *\n * @return Promise\n */\n\tbuffer() {\n\t\treturn consumeBody.call(this);\n\t},\n\n\t/**\n * Decode response as text, while automatically detecting the encoding and\n * trying to decode to UTF-8 (non-spec api)\n *\n * @return Promise\n */\n\ttextConverted() {\n\t\tvar _this3 = this;\n\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\treturn convertBody(buffer, _this3.headers);\n\t\t});\n\t}\n};\n\n// In browsers, all properties are enumerable.\nObject.defineProperties(Body.prototype, {\n\tbody: { enumerable: true },\n\tbodyUsed: { enumerable: true },\n\tarrayBuffer: { enumerable: true },\n\tblob: { enumerable: true },\n\tjson: { enumerable: true },\n\ttext: { enumerable: true }\n});\n\nBody.mixIn = function (proto) {\n\tfor (const name of Object.getOwnPropertyNames(Body.prototype)) {\n\t\t// istanbul ignore else: future proof\n\t\tif (!(name in proto)) {\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(Body.prototype, name);\n\t\t\tObject.defineProperty(proto, name, desc);\n\t\t}\n\t}\n};\n\n/**\n * Consume and convert an entire Body to a Buffer.\n *\n * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body\n *\n * @return Promise\n */\nfunction consumeBody() {\n\tvar _this4 = this;\n\n\tif (this[INTERNALS].disturbed) {\n\t\treturn Body.Promise.reject(new TypeError(`body used already for: ${this.url}`));\n\t}\n\n\tthis[INTERNALS].disturbed = true;\n\n\tif (this[INTERNALS].error) {\n\t\treturn Body.Promise.reject(this[INTERNALS].error);\n\t}\n\n\tlet body = this.body;\n\n\t// body is null\n\tif (body === null) {\n\t\treturn Body.Promise.resolve(Buffer.alloc(0));\n\t}\n\n\t// body is blob\n\tif (isBlob(body)) {\n\t\tbody = body.stream();\n\t}\n\n\t// body is buffer\n\tif (Buffer.isBuffer(body)) {\n\t\treturn Body.Promise.resolve(body);\n\t}\n\n\t// istanbul ignore if: should never happen\n\tif (!(body instanceof Stream)) {\n\t\treturn Body.Promise.resolve(Buffer.alloc(0));\n\t}\n\n\t// body is stream\n\t// get ready to actually consume the body\n\tlet accum = [];\n\tlet accumBytes = 0;\n\tlet abort = false;\n\n\treturn new Body.Promise(function (resolve, reject) {\n\t\tlet resTimeout;\n\n\t\t// allow timeout on slow response body\n\t\tif (_this4.timeout) {\n\t\t\tresTimeout = setTimeout(function () {\n\t\t\t\tabort = true;\n\t\t\t\treject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout'));\n\t\t\t}, _this4.timeout);\n\t\t}\n\n\t\t// handle stream errors\n\t\tbody.on('error', function (err) {\n\t\t\tif (err.name === 'AbortError') {\n\t\t\t\t// if the request was aborted, reject with this Error\n\t\t\t\tabort = true;\n\t\t\t\treject(err);\n\t\t\t} else {\n\t\t\t\t// other errors, such as incorrect content-encoding\n\t\t\t\treject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));\n\t\t\t}\n\t\t});\n\n\t\tbody.on('data', function (chunk) {\n\t\t\tif (abort || chunk === null) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (_this4.size && accumBytes + chunk.length > _this4.size) {\n\t\t\t\tabort = true;\n\t\t\t\treject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size'));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\taccumBytes += chunk.length;\n\t\t\taccum.push(chunk);\n\t\t});\n\n\t\tbody.on('end', function () {\n\t\t\tif (abort) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tclearTimeout(resTimeout);\n\n\t\t\ttry {\n\t\t\t\tresolve(Buffer.concat(accum, accumBytes));\n\t\t\t} catch (err) {\n\t\t\t\t// handle streams that have accumulated too much data (issue #414)\n\t\t\t\treject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err));\n\t\t\t}\n\t\t});\n\t});\n}\n\n/**\n * Detect buffer encoding and convert to target encoding\n * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding\n *\n * @param Buffer buffer Incoming buffer\n * @param String encoding Target encoding\n * @return String\n */\nfunction convertBody(buffer, headers) {\n\tif (typeof convert !== 'function') {\n\t\tthrow new Error('The package `encoding` must be installed to use the textConverted() function');\n\t}\n\n\tconst ct = headers.get('content-type');\n\tlet charset = 'utf-8';\n\tlet res, str;\n\n\t// header\n\tif (ct) {\n\t\tres = /charset=([^;]*)/i.exec(ct);\n\t}\n\n\t// no charset in content type, peek at response body for at most 1024 bytes\n\tstr = buffer.slice(0, 1024).toString();\n\n\t// html5\n\tif (!res && str) {\n\t\tres = / 0 && arguments[0] !== undefined ? arguments[0] : undefined;\n\n\t\tthis[MAP] = Object.create(null);\n\n\t\tif (init instanceof Headers) {\n\t\t\tconst rawHeaders = init.raw();\n\t\t\tconst headerNames = Object.keys(rawHeaders);\n\n\t\t\tfor (const headerName of headerNames) {\n\t\t\t\tfor (const value of rawHeaders[headerName]) {\n\t\t\t\t\tthis.append(headerName, value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't worry about converting prop to ByteString here as append()\n\t\t// will handle it.\n\t\tif (init == null) ; else if (typeof init === 'object') {\n\t\t\tconst method = init[Symbol.iterator];\n\t\t\tif (method != null) {\n\t\t\t\tif (typeof method !== 'function') {\n\t\t\t\t\tthrow new TypeError('Header pairs must be iterable');\n\t\t\t\t}\n\n\t\t\t\t// sequence>\n\t\t\t\t// Note: per spec we have to first exhaust the lists then process them\n\t\t\t\tconst pairs = [];\n\t\t\t\tfor (const pair of init) {\n\t\t\t\t\tif (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') {\n\t\t\t\t\t\tthrow new TypeError('Each header pair must be iterable');\n\t\t\t\t\t}\n\t\t\t\t\tpairs.push(Array.from(pair));\n\t\t\t\t}\n\n\t\t\t\tfor (const pair of pairs) {\n\t\t\t\t\tif (pair.length !== 2) {\n\t\t\t\t\t\tthrow new TypeError('Each header pair must be a name/value tuple');\n\t\t\t\t\t}\n\t\t\t\t\tthis.append(pair[0], pair[1]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// record\n\t\t\t\tfor (const key of Object.keys(init)) {\n\t\t\t\t\tconst value = init[key];\n\t\t\t\t\tthis.append(key, value);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Provided initializer must be an object');\n\t\t}\n\t}\n\n\t/**\n * Return combined header value given name\n *\n * @param String name Header name\n * @return Mixed\n */\n\tget(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key === undefined) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this[MAP][key].join(', ');\n\t}\n\n\t/**\n * Iterate over all headers\n *\n * @param Function callback Executed for each item with parameters (value, name, thisArg)\n * @param Boolean thisArg `this` context for callback function\n * @return Void\n */\n\tforEach(callback) {\n\t\tlet thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;\n\n\t\tlet pairs = getHeaders(this);\n\t\tlet i = 0;\n\t\twhile (i < pairs.length) {\n\t\t\tvar _pairs$i = pairs[i];\n\t\t\tconst name = _pairs$i[0],\n\t\t\t value = _pairs$i[1];\n\n\t\t\tcallback.call(thisArg, value, name, this);\n\t\t\tpairs = getHeaders(this);\n\t\t\ti++;\n\t\t}\n\t}\n\n\t/**\n * Overwrite header values given name\n *\n * @param String name Header name\n * @param String value Header value\n * @return Void\n */\n\tset(name, value) {\n\t\tname = `${name}`;\n\t\tvalue = `${value}`;\n\t\tvalidateName(name);\n\t\tvalidateValue(value);\n\t\tconst key = find(this[MAP], name);\n\t\tthis[MAP][key !== undefined ? key : name] = [value];\n\t}\n\n\t/**\n * Append a value onto existing header\n *\n * @param String name Header name\n * @param String value Header value\n * @return Void\n */\n\tappend(name, value) {\n\t\tname = `${name}`;\n\t\tvalue = `${value}`;\n\t\tvalidateName(name);\n\t\tvalidateValue(value);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tthis[MAP][key].push(value);\n\t\t} else {\n\t\t\tthis[MAP][name] = [value];\n\t\t}\n\t}\n\n\t/**\n * Check for header name existence\n *\n * @param String name Header name\n * @return Boolean\n */\n\thas(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\treturn find(this[MAP], name) !== undefined;\n\t}\n\n\t/**\n * Delete all header values given name\n *\n * @param String name Header name\n * @return Void\n */\n\tdelete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}\n\n\t/**\n * Return raw headers (non-spec api)\n *\n * @return Object\n */\n\traw() {\n\t\treturn this[MAP];\n\t}\n\n\t/**\n * Get an iterator on keys.\n *\n * @return Iterator\n */\n\tkeys() {\n\t\treturn createHeadersIterator(this, 'key');\n\t}\n\n\t/**\n * Get an iterator on values.\n *\n * @return Iterator\n */\n\tvalues() {\n\t\treturn createHeadersIterator(this, 'value');\n\t}\n\n\t/**\n * Get an iterator on entries.\n *\n * This is the default iterator of the Headers object.\n *\n * @return Iterator\n */\n\t[Symbol.iterator]() {\n\t\treturn createHeadersIterator(this, 'key+value');\n\t}\n}\nHeaders.prototype.entries = Headers.prototype[Symbol.iterator];\n\nObject.defineProperty(Headers.prototype, Symbol.toStringTag, {\n\tvalue: 'Headers',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nObject.defineProperties(Headers.prototype, {\n\tget: { enumerable: true },\n\tforEach: { enumerable: true },\n\tset: { enumerable: true },\n\tappend: { enumerable: true },\n\thas: { enumerable: true },\n\tdelete: { enumerable: true },\n\tkeys: { enumerable: true },\n\tvalues: { enumerable: true },\n\tentries: { enumerable: true }\n});\n\nfunction getHeaders(headers) {\n\tlet kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value';\n\n\tconst keys = Object.keys(headers[MAP]).sort();\n\treturn keys.map(kind === 'key' ? function (k) {\n\t\treturn k.toLowerCase();\n\t} : kind === 'value' ? function (k) {\n\t\treturn headers[MAP][k].join(', ');\n\t} : function (k) {\n\t\treturn [k.toLowerCase(), headers[MAP][k].join(', ')];\n\t});\n}\n\nconst INTERNAL = Symbol('internal');\n\nfunction createHeadersIterator(target, kind) {\n\tconst iterator = Object.create(HeadersIteratorPrototype);\n\titerator[INTERNAL] = {\n\t\ttarget,\n\t\tkind,\n\t\tindex: 0\n\t};\n\treturn iterator;\n}\n\nconst HeadersIteratorPrototype = Object.setPrototypeOf({\n\tnext() {\n\t\t// istanbul ignore if\n\t\tif (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) {\n\t\t\tthrow new TypeError('Value of `this` is not a HeadersIterator');\n\t\t}\n\n\t\tvar _INTERNAL = this[INTERNAL];\n\t\tconst target = _INTERNAL.target,\n\t\t kind = _INTERNAL.kind,\n\t\t index = _INTERNAL.index;\n\n\t\tconst values = getHeaders(target, kind);\n\t\tconst len = values.length;\n\t\tif (index >= len) {\n\t\t\treturn {\n\t\t\t\tvalue: undefined,\n\t\t\t\tdone: true\n\t\t\t};\n\t\t}\n\n\t\tthis[INTERNAL].index = index + 1;\n\n\t\treturn {\n\t\t\tvalue: values[index],\n\t\t\tdone: false\n\t\t};\n\t}\n}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));\n\nObject.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, {\n\tvalue: 'HeadersIterator',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\n/**\n * Export the Headers object in a form that Node.js can consume.\n *\n * @param Headers headers\n * @return Object\n */\nfunction exportNodeCompatibleHeaders(headers) {\n\tconst obj = Object.assign({ __proto__: null }, headers[MAP]);\n\n\t// http.request() only supports string as Host header. This hack makes\n\t// specifying custom Host header possible.\n\tconst hostHeaderKey = find(headers[MAP], 'Host');\n\tif (hostHeaderKey !== undefined) {\n\t\tobj[hostHeaderKey] = obj[hostHeaderKey][0];\n\t}\n\n\treturn obj;\n}\n\n/**\n * Create a Headers object from an object of headers, ignoring those that do\n * not conform to HTTP grammar productions.\n *\n * @param Object obj Object of headers\n * @return Headers\n */\nfunction createHeadersLenient(obj) {\n\tconst headers = new Headers();\n\tfor (const name of Object.keys(obj)) {\n\t\tif (invalidTokenRegex.test(name)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (Array.isArray(obj[name])) {\n\t\t\tfor (const val of obj[name]) {\n\t\t\t\tif (invalidHeaderCharRegex.test(val)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (headers[MAP][name] === undefined) {\n\t\t\t\t\theaders[MAP][name] = [val];\n\t\t\t\t} else {\n\t\t\t\t\theaders[MAP][name].push(val);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!invalidHeaderCharRegex.test(obj[name])) {\n\t\t\theaders[MAP][name] = [obj[name]];\n\t\t}\n\t}\n\treturn headers;\n}\n\nconst INTERNALS$1 = Symbol('Response internals');\n\n// fix an issue where \"STATUS_CODES\" aren't a named export for node <10\nconst STATUS_CODES = http.STATUS_CODES;\n\n/**\n * Response class\n *\n * @param Stream body Readable stream\n * @param Object opts Response options\n * @return Void\n */\nclass Response {\n\tconstructor() {\n\t\tlet body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\t\tlet opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\t\tBody.call(this, body, opts);\n\n\t\tconst status = opts.status || 200;\n\t\tconst headers = new Headers(opts.headers);\n\n\t\tif (body != null && !headers.has('Content-Type')) {\n\t\t\tconst contentType = extractContentType(body);\n\t\t\tif (contentType) {\n\t\t\t\theaders.append('Content-Type', contentType);\n\t\t\t}\n\t\t}\n\n\t\tthis[INTERNALS$1] = {\n\t\t\turl: opts.url,\n\t\t\tstatus,\n\t\t\tstatusText: opts.statusText || STATUS_CODES[status],\n\t\t\theaders,\n\t\t\tcounter: opts.counter\n\t\t};\n\t}\n\n\tget url() {\n\t\treturn this[INTERNALS$1].url || '';\n\t}\n\n\tget status() {\n\t\treturn this[INTERNALS$1].status;\n\t}\n\n\t/**\n * Convenience property representing if the request ended normally\n */\n\tget ok() {\n\t\treturn this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;\n\t}\n\n\tget redirected() {\n\t\treturn this[INTERNALS$1].counter > 0;\n\t}\n\n\tget statusText() {\n\t\treturn this[INTERNALS$1].statusText;\n\t}\n\n\tget headers() {\n\t\treturn this[INTERNALS$1].headers;\n\t}\n\n\t/**\n * Clone this response\n *\n * @return Response\n */\n\tclone() {\n\t\treturn new Response(clone(this), {\n\t\t\turl: this.url,\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t\theaders: this.headers,\n\t\t\tok: this.ok,\n\t\t\tredirected: this.redirected\n\t\t});\n\t}\n}\n\nBody.mixIn(Response.prototype);\n\nObject.defineProperties(Response.prototype, {\n\turl: { enumerable: true },\n\tstatus: { enumerable: true },\n\tok: { enumerable: true },\n\tredirected: { enumerable: true },\n\tstatusText: { enumerable: true },\n\theaders: { enumerable: true },\n\tclone: { enumerable: true }\n});\n\nObject.defineProperty(Response.prototype, Symbol.toStringTag, {\n\tvalue: 'Response',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nconst INTERNALS$2 = Symbol('Request internals');\n\n// fix an issue where \"format\", \"parse\" aren't a named export for node <10\nconst parse_url = Url.parse;\nconst format_url = Url.format;\n\nconst streamDestructionSupported = 'destroy' in Stream.Readable.prototype;\n\n/**\n * Check if a value is an instance of Request.\n *\n * @param Mixed input\n * @return Boolean\n */\nfunction isRequest(input) {\n\treturn typeof input === 'object' && typeof input[INTERNALS$2] === 'object';\n}\n\nfunction isAbortSignal(signal) {\n\tconst proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal);\n\treturn !!(proto && proto.constructor.name === 'AbortSignal');\n}\n\n/**\n * Request class\n *\n * @param Mixed input Url or Request instance\n * @param Object init Custom options\n * @return Void\n */\nclass Request {\n\tconstructor(input) {\n\t\tlet init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\t\tlet parsedURL;\n\n\t\t// normalize input\n\t\tif (!isRequest(input)) {\n\t\t\tif (input && input.href) {\n\t\t\t\t// in order to support Node.js' Url objects; though WHATWG's URL objects\n\t\t\t\t// will fall into this branch also (since their `toString()` will return\n\t\t\t\t// `href` property anyway)\n\t\t\t\tparsedURL = parse_url(input.href);\n\t\t\t} else {\n\t\t\t\t// coerce input to a string before attempting to parse\n\t\t\t\tparsedURL = parse_url(`${input}`);\n\t\t\t}\n\t\t\tinput = {};\n\t\t} else {\n\t\t\tparsedURL = parse_url(input.url);\n\t\t}\n\n\t\tlet method = init.method || input.method || 'GET';\n\t\tmethod = method.toUpperCase();\n\n\t\tif ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) {\n\t\t\tthrow new TypeError('Request with GET/HEAD method cannot have body');\n\t\t}\n\n\t\tlet inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;\n\n\t\tBody.call(this, inputBody, {\n\t\t\ttimeout: init.timeout || input.timeout || 0,\n\t\t\tsize: init.size || input.size || 0\n\t\t});\n\n\t\tconst headers = new Headers(init.headers || input.headers || {});\n\n\t\tif (inputBody != null && !headers.has('Content-Type')) {\n\t\t\tconst contentType = extractContentType(inputBody);\n\t\t\tif (contentType) {\n\t\t\t\theaders.append('Content-Type', contentType);\n\t\t\t}\n\t\t}\n\n\t\tlet signal = isRequest(input) ? input.signal : null;\n\t\tif ('signal' in init) signal = init.signal;\n\n\t\tif (signal != null && !isAbortSignal(signal)) {\n\t\t\tthrow new TypeError('Expected signal to be an instanceof AbortSignal');\n\t\t}\n\n\t\tthis[INTERNALS$2] = {\n\t\t\tmethod,\n\t\t\tredirect: init.redirect || input.redirect || 'follow',\n\t\t\theaders,\n\t\t\tparsedURL,\n\t\t\tsignal\n\t\t};\n\n\t\t// node-fetch-only options\n\t\tthis.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20;\n\t\tthis.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true;\n\t\tthis.counter = init.counter || input.counter || 0;\n\t\tthis.agent = init.agent || input.agent;\n\t}\n\n\tget method() {\n\t\treturn this[INTERNALS$2].method;\n\t}\n\n\tget url() {\n\t\treturn format_url(this[INTERNALS$2].parsedURL);\n\t}\n\n\tget headers() {\n\t\treturn this[INTERNALS$2].headers;\n\t}\n\n\tget redirect() {\n\t\treturn this[INTERNALS$2].redirect;\n\t}\n\n\tget signal() {\n\t\treturn this[INTERNALS$2].signal;\n\t}\n\n\t/**\n * Clone this request\n *\n * @return Request\n */\n\tclone() {\n\t\treturn new Request(this);\n\t}\n}\n\nBody.mixIn(Request.prototype);\n\nObject.defineProperty(Request.prototype, Symbol.toStringTag, {\n\tvalue: 'Request',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nObject.defineProperties(Request.prototype, {\n\tmethod: { enumerable: true },\n\turl: { enumerable: true },\n\theaders: { enumerable: true },\n\tredirect: { enumerable: true },\n\tclone: { enumerable: true },\n\tsignal: { enumerable: true }\n});\n\n/**\n * Convert a Request to Node.js http request options.\n *\n * @param Request A Request instance\n * @return Object The options object to be passed to http.request\n */\nfunction getNodeRequestOptions(request) {\n\tconst parsedURL = request[INTERNALS$2].parsedURL;\n\tconst headers = new Headers(request[INTERNALS$2].headers);\n\n\t// fetch step 1.3\n\tif (!headers.has('Accept')) {\n\t\theaders.set('Accept', '*/*');\n\t}\n\n\t// Basic fetch\n\tif (!parsedURL.protocol || !parsedURL.hostname) {\n\t\tthrow new TypeError('Only absolute URLs are supported');\n\t}\n\n\tif (!/^https?:$/.test(parsedURL.protocol)) {\n\t\tthrow new TypeError('Only HTTP(S) protocols are supported');\n\t}\n\n\tif (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) {\n\t\tthrow new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8');\n\t}\n\n\t// HTTP-network-or-cache fetch steps 2.4-2.7\n\tlet contentLengthValue = null;\n\tif (request.body == null && /^(POST|PUT)$/i.test(request.method)) {\n\t\tcontentLengthValue = '0';\n\t}\n\tif (request.body != null) {\n\t\tconst totalBytes = getTotalBytes(request);\n\t\tif (typeof totalBytes === 'number') {\n\t\t\tcontentLengthValue = String(totalBytes);\n\t\t}\n\t}\n\tif (contentLengthValue) {\n\t\theaders.set('Content-Length', contentLengthValue);\n\t}\n\n\t// HTTP-network-or-cache fetch step 2.11\n\tif (!headers.has('User-Agent')) {\n\t\theaders.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)');\n\t}\n\n\t// HTTP-network-or-cache fetch step 2.15\n\tif (request.compress && !headers.has('Accept-Encoding')) {\n\t\theaders.set('Accept-Encoding', 'gzip,deflate');\n\t}\n\n\tlet agent = request.agent;\n\tif (typeof agent === 'function') {\n\t\tagent = agent(parsedURL);\n\t}\n\n\tif (!headers.has('Connection') && !agent) {\n\t\theaders.set('Connection', 'close');\n\t}\n\n\t// HTTP-network fetch step 4.2\n\t// chunked encoding is handled by Node.js\n\n\treturn Object.assign({}, parsedURL, {\n\t\tmethod: request.method,\n\t\theaders: exportNodeCompatibleHeaders(headers),\n\t\tagent\n\t});\n}\n\n/**\n * abort-error.js\n *\n * AbortError interface for cancelled requests\n */\n\n/**\n * Create AbortError instance\n *\n * @param String message Error message for human\n * @return AbortError\n */\nfunction AbortError(message) {\n Error.call(this, message);\n\n this.type = 'aborted';\n this.message = message;\n\n // hide custom error implementation details from end-users\n Error.captureStackTrace(this, this.constructor);\n}\n\nAbortError.prototype = Object.create(Error.prototype);\nAbortError.prototype.constructor = AbortError;\nAbortError.prototype.name = 'AbortError';\n\n// fix an issue where \"PassThrough\", \"resolve\" aren't a named export for node <10\nconst PassThrough$1 = Stream.PassThrough;\nconst resolve_url = Url.resolve;\n\n/**\n * Fetch function\n *\n * @param Mixed url Absolute url or Request instance\n * @param Object opts Fetch options\n * @return Promise\n */\nfunction fetch(url, opts) {\n\n\t// allow custom promise\n\tif (!fetch.Promise) {\n\t\tthrow new Error('native promise missing, set fetch.Promise to your favorite alternative');\n\t}\n\n\tBody.Promise = fetch.Promise;\n\n\t// wrap http.request into fetch\n\treturn new fetch.Promise(function (resolve, reject) {\n\t\t// build request object\n\t\tconst request = new Request(url, opts);\n\t\tconst options = getNodeRequestOptions(request);\n\n\t\tconst send = (options.protocol === 'https:' ? https : http).request;\n\t\tconst signal = request.signal;\n\n\t\tlet response = null;\n\n\t\tconst abort = function abort() {\n\t\t\tlet error = new AbortError('The user aborted a request.');\n\t\t\treject(error);\n\t\t\tif (request.body && request.body instanceof Stream.Readable) {\n\t\t\t\trequest.body.destroy(error);\n\t\t\t}\n\t\t\tif (!response || !response.body) return;\n\t\t\tresponse.body.emit('error', error);\n\t\t};\n\n\t\tif (signal && signal.aborted) {\n\t\t\tabort();\n\t\t\treturn;\n\t\t}\n\n\t\tconst abortAndFinalize = function abortAndFinalize() {\n\t\t\tabort();\n\t\t\tfinalize();\n\t\t};\n\n\t\t// send request\n\t\tconst req = send(options);\n\t\tlet reqTimeout;\n\n\t\tif (signal) {\n\t\t\tsignal.addEventListener('abort', abortAndFinalize);\n\t\t}\n\n\t\tfunction finalize() {\n\t\t\treq.abort();\n\t\t\tif (signal) signal.removeEventListener('abort', abortAndFinalize);\n\t\t\tclearTimeout(reqTimeout);\n\t\t}\n\n\t\tif (request.timeout) {\n\t\t\treq.once('socket', function (socket) {\n\t\t\t\treqTimeout = setTimeout(function () {\n\t\t\t\t\treject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout'));\n\t\t\t\t\tfinalize();\n\t\t\t\t}, request.timeout);\n\t\t\t});\n\t\t}\n\n\t\treq.on('error', function (err) {\n\t\t\treject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));\n\t\t\tfinalize();\n\t\t});\n\n\t\treq.on('response', function (res) {\n\t\t\tclearTimeout(reqTimeout);\n\n\t\t\tconst headers = createHeadersLenient(res.headers);\n\n\t\t\t// HTTP fetch step 5\n\t\t\tif (fetch.isRedirect(res.statusCode)) {\n\t\t\t\t// HTTP fetch step 5.2\n\t\t\t\tconst location = headers.get('Location');\n\n\t\t\t\t// HTTP fetch step 5.3\n\t\t\t\tconst locationURL = location === null ? null : resolve_url(request.url, location);\n\n\t\t\t\t// HTTP fetch step 5.5\n\t\t\t\tswitch (request.redirect) {\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\treject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));\n\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase 'manual':\n\t\t\t\t\t\t// node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL.\n\t\t\t\t\t\tif (locationURL !== null) {\n\t\t\t\t\t\t\t// handle corrupted header\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\theaders.set('Location', locationURL);\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\t// istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request\n\t\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'follow':\n\t\t\t\t\t\t// HTTP-redirect fetch step 2\n\t\t\t\t\t\tif (locationURL === null) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 5\n\t\t\t\t\t\tif (request.counter >= request.follow) {\n\t\t\t\t\t\t\treject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect'));\n\t\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 6 (counter increment)\n\t\t\t\t\t\t// Create a new Request object.\n\t\t\t\t\t\tconst requestOpts = {\n\t\t\t\t\t\t\theaders: new Headers(request.headers),\n\t\t\t\t\t\t\tfollow: request.follow,\n\t\t\t\t\t\t\tcounter: request.counter + 1,\n\t\t\t\t\t\t\tagent: request.agent,\n\t\t\t\t\t\t\tcompress: request.compress,\n\t\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\t\tbody: request.body,\n\t\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\t\ttimeout: request.timeout,\n\t\t\t\t\t\t\tsize: request.size\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 9\n\t\t\t\t\t\tif (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {\n\t\t\t\t\t\t\treject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));\n\t\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 11\n\t\t\t\t\t\tif (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') {\n\t\t\t\t\t\t\trequestOpts.method = 'GET';\n\t\t\t\t\t\t\trequestOpts.body = undefined;\n\t\t\t\t\t\t\trequestOpts.headers.delete('content-length');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 15\n\t\t\t\t\t\tresolve(fetch(new Request(locationURL, requestOpts)));\n\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// prepare response\n\t\t\tres.once('end', function () {\n\t\t\t\tif (signal) signal.removeEventListener('abort', abortAndFinalize);\n\t\t\t});\n\t\t\tlet body = res.pipe(new PassThrough$1());\n\n\t\t\tconst response_options = {\n\t\t\t\turl: request.url,\n\t\t\t\tstatus: res.statusCode,\n\t\t\t\tstatusText: res.statusMessage,\n\t\t\t\theaders: headers,\n\t\t\t\tsize: request.size,\n\t\t\t\ttimeout: request.timeout,\n\t\t\t\tcounter: request.counter\n\t\t\t};\n\n\t\t\t// HTTP-network fetch step 12.1.1.3\n\t\t\tconst codings = headers.get('Content-Encoding');\n\n\t\t\t// HTTP-network fetch step 12.1.1.4: handle content codings\n\n\t\t\t// in following scenarios we ignore compression support\n\t\t\t// 1. compression support is disabled\n\t\t\t// 2. HEAD request\n\t\t\t// 3. no Content-Encoding header\n\t\t\t// 4. no content response (204)\n\t\t\t// 5. content not modified response (304)\n\t\t\tif (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) {\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For Node v6+\n\t\t\t// Be less strict when decoding compressed responses, since sometimes\n\t\t\t// servers send slightly invalid responses that are still accepted\n\t\t\t// by common browsers.\n\t\t\t// Always using Z_SYNC_FLUSH is what cURL does.\n\t\t\tconst zlibOptions = {\n\t\t\t\tflush: zlib.Z_SYNC_FLUSH,\n\t\t\t\tfinishFlush: zlib.Z_SYNC_FLUSH\n\t\t\t};\n\n\t\t\t// for gzip\n\t\t\tif (codings == 'gzip' || codings == 'x-gzip') {\n\t\t\t\tbody = body.pipe(zlib.createGunzip(zlibOptions));\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// for deflate\n\t\t\tif (codings == 'deflate' || codings == 'x-deflate') {\n\t\t\t\t// handle the infamous raw deflate response from old servers\n\t\t\t\t// a hack for old IIS and Apache servers\n\t\t\t\tconst raw = res.pipe(new PassThrough$1());\n\t\t\t\traw.once('data', function (chunk) {\n\t\t\t\t\t// see http://stackoverflow.com/questions/37519828\n\t\t\t\t\tif ((chunk[0] & 0x0F) === 0x08) {\n\t\t\t\t\t\tbody = body.pipe(zlib.createInflate());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbody = body.pipe(zlib.createInflateRaw());\n\t\t\t\t\t}\n\t\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\t\tresolve(response);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// for br\n\t\t\tif (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') {\n\t\t\t\tbody = body.pipe(zlib.createBrotliDecompress());\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// otherwise, use response as-is\n\t\t\tresponse = new Response(body, response_options);\n\t\t\tresolve(response);\n\t\t});\n\n\t\twriteToStream(req, request);\n\t});\n}\n/**\n * Redirect code matching\n *\n * @param Number code Status code\n * @return Boolean\n */\nfetch.isRedirect = function (code) {\n\treturn code === 301 || code === 302 || code === 303 || code === 307 || code === 308;\n};\n\n// expose Promise\nfetch.Promise = global.Promise;\n\nmodule.exports = exports = fetch;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = exports;\nexports.Headers = Headers;\nexports.Request = Request;\nexports.Response = Response;\nexports.FetchError = FetchError;\n","/**\n * Advanced Encryption Standard (AES) implementation.\n *\n * This implementation is based on the public domain library 'jscrypto' which\n * was written by:\n *\n * Emily Stark (estark@stanford.edu)\n * Mike Hamburg (mhamburg@stanford.edu)\n * Dan Boneh (dabo@cs.stanford.edu)\n *\n * Parts of this code are based on the OpenSSL implementation of AES:\n * http://www.openssl.org\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./cipher');\nrequire('./cipherModes');\nrequire('./util');\n\n/* AES API */\nmodule.exports = forge.aes = forge.aes || {};\n\n/**\n * Deprecated. Instead, use:\n *\n * var cipher = forge.cipher.createCipher('AES-', key);\n * cipher.start({iv: iv});\n *\n * Creates an AES cipher object to encrypt data using the given symmetric key.\n * The output will be stored in the 'output' member of the returned cipher.\n *\n * The key and iv may be given as a string of bytes, an array of bytes,\n * a byte buffer, or an array of 32-bit words.\n *\n * @param key the symmetric key to use.\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.aes.startEncrypting = function(key, iv, output, mode) {\n var cipher = _createCipher({\n key: key,\n output: output,\n decrypt: false,\n mode: mode\n });\n cipher.start(iv);\n return cipher;\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var cipher = forge.cipher.createCipher('AES-', key);\n *\n * Creates an AES cipher object to encrypt data using the given symmetric key.\n *\n * The key may be given as a string of bytes, an array of bytes, a\n * byte buffer, or an array of 32-bit words.\n *\n * @param key the symmetric key to use.\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.aes.createEncryptionCipher = function(key, mode) {\n return _createCipher({\n key: key,\n output: null,\n decrypt: false,\n mode: mode\n });\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var decipher = forge.cipher.createDecipher('AES-', key);\n * decipher.start({iv: iv});\n *\n * Creates an AES cipher object to decrypt data using the given symmetric key.\n * The output will be stored in the 'output' member of the returned cipher.\n *\n * The key and iv may be given as a string of bytes, an array of bytes,\n * a byte buffer, or an array of 32-bit words.\n *\n * @param key the symmetric key to use.\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.aes.startDecrypting = function(key, iv, output, mode) {\n var cipher = _createCipher({\n key: key,\n output: output,\n decrypt: true,\n mode: mode\n });\n cipher.start(iv);\n return cipher;\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var decipher = forge.cipher.createDecipher('AES-', key);\n *\n * Creates an AES cipher object to decrypt data using the given symmetric key.\n *\n * The key may be given as a string of bytes, an array of bytes, a\n * byte buffer, or an array of 32-bit words.\n *\n * @param key the symmetric key to use.\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.aes.createDecryptionCipher = function(key, mode) {\n return _createCipher({\n key: key,\n output: null,\n decrypt: true,\n mode: mode\n });\n};\n\n/**\n * Creates a new AES cipher algorithm object.\n *\n * @param name the name of the algorithm.\n * @param mode the mode factory function.\n *\n * @return the AES algorithm object.\n */\nforge.aes.Algorithm = function(name, mode) {\n if(!init) {\n initialize();\n }\n var self = this;\n self.name = name;\n self.mode = new mode({\n blockSize: 16,\n cipher: {\n encrypt: function(inBlock, outBlock) {\n return _updateBlock(self._w, inBlock, outBlock, false);\n },\n decrypt: function(inBlock, outBlock) {\n return _updateBlock(self._w, inBlock, outBlock, true);\n }\n }\n });\n self._init = false;\n};\n\n/**\n * Initializes this AES algorithm by expanding its key.\n *\n * @param options the options to use.\n * key the key to use with this algorithm.\n * decrypt true if the algorithm should be initialized for decryption,\n * false for encryption.\n */\nforge.aes.Algorithm.prototype.initialize = function(options) {\n if(this._init) {\n return;\n }\n\n var key = options.key;\n var tmp;\n\n /* Note: The key may be a string of bytes, an array of bytes, a byte\n buffer, or an array of 32-bit integers. If the key is in bytes, then\n it must be 16, 24, or 32 bytes in length. If it is in 32-bit\n integers, it must be 4, 6, or 8 integers long. */\n\n if(typeof key === 'string' &&\n (key.length === 16 || key.length === 24 || key.length === 32)) {\n // convert key string into byte buffer\n key = forge.util.createBuffer(key);\n } else if(forge.util.isArray(key) &&\n (key.length === 16 || key.length === 24 || key.length === 32)) {\n // convert key integer array into byte buffer\n tmp = key;\n key = forge.util.createBuffer();\n for(var i = 0; i < tmp.length; ++i) {\n key.putByte(tmp[i]);\n }\n }\n\n // convert key byte buffer into 32-bit integer array\n if(!forge.util.isArray(key)) {\n tmp = key;\n key = [];\n\n // key lengths of 16, 24, 32 bytes allowed\n var len = tmp.length();\n if(len === 16 || len === 24 || len === 32) {\n len = len >>> 2;\n for(var i = 0; i < len; ++i) {\n key.push(tmp.getInt32());\n }\n }\n }\n\n // key must be an array of 32-bit integers by now\n if(!forge.util.isArray(key) ||\n !(key.length === 4 || key.length === 6 || key.length === 8)) {\n throw new Error('Invalid key parameter.');\n }\n\n // encryption operation is always used for these modes\n var mode = this.mode.name;\n var encryptOp = (['CFB', 'OFB', 'CTR', 'GCM'].indexOf(mode) !== -1);\n\n // do key expansion\n this._w = _expandKey(key, options.decrypt && !encryptOp);\n this._init = true;\n};\n\n/**\n * Expands a key. Typically only used for testing.\n *\n * @param key the symmetric key to expand, as an array of 32-bit words.\n * @param decrypt true to expand for decryption, false for encryption.\n *\n * @return the expanded key.\n */\nforge.aes._expandKey = function(key, decrypt) {\n if(!init) {\n initialize();\n }\n return _expandKey(key, decrypt);\n};\n\n/**\n * Updates a single block. Typically only used for testing.\n *\n * @param w the expanded key to use.\n * @param input an array of block-size 32-bit words.\n * @param output an array of block-size 32-bit words.\n * @param decrypt true to decrypt, false to encrypt.\n */\nforge.aes._updateBlock = _updateBlock;\n\n/** Register AES algorithms **/\n\nregisterAlgorithm('AES-ECB', forge.cipher.modes.ecb);\nregisterAlgorithm('AES-CBC', forge.cipher.modes.cbc);\nregisterAlgorithm('AES-CFB', forge.cipher.modes.cfb);\nregisterAlgorithm('AES-OFB', forge.cipher.modes.ofb);\nregisterAlgorithm('AES-CTR', forge.cipher.modes.ctr);\nregisterAlgorithm('AES-GCM', forge.cipher.modes.gcm);\n\nfunction registerAlgorithm(name, mode) {\n var factory = function() {\n return new forge.aes.Algorithm(name, mode);\n };\n forge.cipher.registerAlgorithm(name, factory);\n}\n\n/** AES implementation **/\n\nvar init = false; // not yet initialized\nvar Nb = 4; // number of words comprising the state (AES = 4)\nvar sbox; // non-linear substitution table used in key expansion\nvar isbox; // inversion of sbox\nvar rcon; // round constant word array\nvar mix; // mix-columns table\nvar imix; // inverse mix-columns table\n\n/**\n * Performs initialization, ie: precomputes tables to optimize for speed.\n *\n * One way to understand how AES works is to imagine that 'addition' and\n * 'multiplication' are interfaces that require certain mathematical\n * properties to hold true (ie: they are associative) but they might have\n * different implementations and produce different kinds of results ...\n * provided that their mathematical properties remain true. AES defines\n * its own methods of addition and multiplication but keeps some important\n * properties the same, ie: associativity and distributivity. The\n * explanation below tries to shed some light on how AES defines addition\n * and multiplication of bytes and 32-bit words in order to perform its\n * encryption and decryption algorithms.\n *\n * The basics:\n *\n * The AES algorithm views bytes as binary representations of polynomials\n * that have either 1 or 0 as the coefficients. It defines the addition\n * or subtraction of two bytes as the XOR operation. It also defines the\n * multiplication of two bytes as a finite field referred to as GF(2^8)\n * (Note: 'GF' means \"Galois Field\" which is a field that contains a finite\n * number of elements so GF(2^8) has 256 elements).\n *\n * This means that any two bytes can be represented as binary polynomials;\n * when they multiplied together and modularly reduced by an irreducible\n * polynomial of the 8th degree, the results are the field GF(2^8). The\n * specific irreducible polynomial that AES uses in hexadecimal is 0x11b.\n * This multiplication is associative with 0x01 as the identity:\n *\n * (b * 0x01 = GF(b, 0x01) = b).\n *\n * The operation GF(b, 0x02) can be performed at the byte level by left\n * shifting b once and then XOR'ing it (to perform the modular reduction)\n * with 0x11b if b is >= 128. Repeated application of the multiplication\n * of 0x02 can be used to implement the multiplication of any two bytes.\n *\n * For instance, multiplying 0x57 and 0x13, denoted as GF(0x57, 0x13), can\n * be performed by factoring 0x13 into 0x01, 0x02, and 0x10. Then these\n * factors can each be multiplied by 0x57 and then added together. To do\n * the multiplication, values for 0x57 multiplied by each of these 3 factors\n * can be precomputed and stored in a table. To add them, the values from\n * the table are XOR'd together.\n *\n * AES also defines addition and multiplication of words, that is 4-byte\n * numbers represented as polynomials of 3 degrees where the coefficients\n * are the values of the bytes.\n *\n * The word [a0, a1, a2, a3] is a polynomial a3x^3 + a2x^2 + a1x + a0.\n *\n * Addition is performed by XOR'ing like powers of x. Multiplication\n * is performed in two steps, the first is an algebriac expansion as\n * you would do normally (where addition is XOR). But the result is\n * a polynomial larger than 3 degrees and thus it cannot fit in a word. So\n * next the result is modularly reduced by an AES-specific polynomial of\n * degree 4 which will always produce a polynomial of less than 4 degrees\n * such that it will fit in a word. In AES, this polynomial is x^4 + 1.\n *\n * The modular product of two polynomials 'a' and 'b' is thus:\n *\n * d(x) = d3x^3 + d2x^2 + d1x + d0\n * with\n * d0 = GF(a0, b0) ^ GF(a3, b1) ^ GF(a2, b2) ^ GF(a1, b3)\n * d1 = GF(a1, b0) ^ GF(a0, b1) ^ GF(a3, b2) ^ GF(a2, b3)\n * d2 = GF(a2, b0) ^ GF(a1, b1) ^ GF(a0, b2) ^ GF(a3, b3)\n * d3 = GF(a3, b0) ^ GF(a2, b1) ^ GF(a1, b2) ^ GF(a0, b3)\n *\n * As a matrix:\n *\n * [d0] = [a0 a3 a2 a1][b0]\n * [d1] [a1 a0 a3 a2][b1]\n * [d2] [a2 a1 a0 a3][b2]\n * [d3] [a3 a2 a1 a0][b3]\n *\n * Special polynomials defined by AES (0x02 == {02}):\n * a(x) = {03}x^3 + {01}x^2 + {01}x + {02}\n * a^-1(x) = {0b}x^3 + {0d}x^2 + {09}x + {0e}.\n *\n * These polynomials are used in the MixColumns() and InverseMixColumns()\n * operations, respectively, to cause each element in the state to affect\n * the output (referred to as diffusing).\n *\n * RotWord() uses: a0 = a1 = a2 = {00} and a3 = {01}, which is the\n * polynomial x3.\n *\n * The ShiftRows() method modifies the last 3 rows in the state (where\n * the state is 4 words with 4 bytes per word) by shifting bytes cyclically.\n * The 1st byte in the second row is moved to the end of the row. The 1st\n * and 2nd bytes in the third row are moved to the end of the row. The 1st,\n * 2nd, and 3rd bytes are moved in the fourth row.\n *\n * More details on how AES arithmetic works:\n *\n * In the polynomial representation of binary numbers, XOR performs addition\n * and subtraction and multiplication in GF(2^8) denoted as GF(a, b)\n * corresponds with the multiplication of polynomials modulo an irreducible\n * polynomial of degree 8. In other words, for AES, GF(a, b) will multiply\n * polynomial 'a' with polynomial 'b' and then do a modular reduction by\n * an AES-specific irreducible polynomial of degree 8.\n *\n * A polynomial is irreducible if its only divisors are one and itself. For\n * the AES algorithm, this irreducible polynomial is:\n *\n * m(x) = x^8 + x^4 + x^3 + x + 1,\n *\n * or {01}{1b} in hexadecimal notation, where each coefficient is a bit:\n * 100011011 = 283 = 0x11b.\n *\n * For example, GF(0x57, 0x83) = 0xc1 because\n *\n * 0x57 = 87 = 01010111 = x^6 + x^4 + x^2 + x + 1\n * 0x85 = 131 = 10000101 = x^7 + x + 1\n *\n * (x^6 + x^4 + x^2 + x + 1) * (x^7 + x + 1)\n * = x^13 + x^11 + x^9 + x^8 + x^7 +\n * x^7 + x^5 + x^3 + x^2 + x +\n * x^6 + x^4 + x^2 + x + 1\n * = x^13 + x^11 + x^9 + x^8 + x^6 + x^5 + x^4 + x^3 + 1 = y\n * y modulo (x^8 + x^4 + x^3 + x + 1)\n * = x^7 + x^6 + 1.\n *\n * The modular reduction by m(x) guarantees the result will be a binary\n * polynomial of less than degree 8, so that it can fit in a byte.\n *\n * The operation to multiply a binary polynomial b with x (the polynomial\n * x in binary representation is 00000010) is:\n *\n * b_7x^8 + b_6x^7 + b_5x^6 + b_4x^5 + b_3x^4 + b_2x^3 + b_1x^2 + b_0x^1\n *\n * To get GF(b, x) we must reduce that by m(x). If b_7 is 0 (that is the\n * most significant bit is 0 in b) then the result is already reduced. If\n * it is 1, then we can reduce it by subtracting m(x) via an XOR.\n *\n * It follows that multiplication by x (00000010 or 0x02) can be implemented\n * by performing a left shift followed by a conditional bitwise XOR with\n * 0x1b. This operation on bytes is denoted by xtime(). Multiplication by\n * higher powers of x can be implemented by repeated application of xtime().\n *\n * By adding intermediate results, multiplication by any constant can be\n * implemented. For instance:\n *\n * GF(0x57, 0x13) = 0xfe because:\n *\n * xtime(b) = (b & 128) ? (b << 1 ^ 0x11b) : (b << 1)\n *\n * Note: We XOR with 0x11b instead of 0x1b because in javascript our\n * datatype for b can be larger than 1 byte, so a left shift will not\n * automatically eliminate bits that overflow a byte ... by XOR'ing the\n * overflow bit with 1 (the extra one from 0x11b) we zero it out.\n *\n * GF(0x57, 0x02) = xtime(0x57) = 0xae\n * GF(0x57, 0x04) = xtime(0xae) = 0x47\n * GF(0x57, 0x08) = xtime(0x47) = 0x8e\n * GF(0x57, 0x10) = xtime(0x8e) = 0x07\n *\n * GF(0x57, 0x13) = GF(0x57, (0x01 ^ 0x02 ^ 0x10))\n *\n * And by the distributive property (since XOR is addition and GF() is\n * multiplication):\n *\n * = GF(0x57, 0x01) ^ GF(0x57, 0x02) ^ GF(0x57, 0x10)\n * = 0x57 ^ 0xae ^ 0x07\n * = 0xfe.\n */\nfunction initialize() {\n init = true;\n\n /* Populate the Rcon table. These are the values given by\n [x^(i-1),{00},{00},{00}] where x^(i-1) are powers of x (and x = 0x02)\n in the field of GF(2^8), where i starts at 1.\n\n rcon[0] = [0x00, 0x00, 0x00, 0x00]\n rcon[1] = [0x01, 0x00, 0x00, 0x00] 2^(1-1) = 2^0 = 1\n rcon[2] = [0x02, 0x00, 0x00, 0x00] 2^(2-1) = 2^1 = 2\n ...\n rcon[9] = [0x1B, 0x00, 0x00, 0x00] 2^(9-1) = 2^8 = 0x1B\n rcon[10] = [0x36, 0x00, 0x00, 0x00] 2^(10-1) = 2^9 = 0x36\n\n We only store the first byte because it is the only one used.\n */\n rcon = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36];\n\n // compute xtime table which maps i onto GF(i, 0x02)\n var xtime = new Array(256);\n for(var i = 0; i < 128; ++i) {\n xtime[i] = i << 1;\n xtime[i + 128] = (i + 128) << 1 ^ 0x11B;\n }\n\n // compute all other tables\n sbox = new Array(256);\n isbox = new Array(256);\n mix = new Array(4);\n imix = new Array(4);\n for(var i = 0; i < 4; ++i) {\n mix[i] = new Array(256);\n imix[i] = new Array(256);\n }\n var e = 0, ei = 0, e2, e4, e8, sx, sx2, me, ime;\n for(var i = 0; i < 256; ++i) {\n /* We need to generate the SubBytes() sbox and isbox tables so that\n we can perform byte substitutions. This requires us to traverse\n all of the elements in GF, find their multiplicative inverses,\n and apply to each the following affine transformation:\n\n bi' = bi ^ b(i + 4) mod 8 ^ b(i + 5) mod 8 ^ b(i + 6) mod 8 ^\n b(i + 7) mod 8 ^ ci\n for 0 <= i < 8, where bi is the ith bit of the byte, and ci is the\n ith bit of a byte c with the value {63} or {01100011}.\n\n It is possible to traverse every possible value in a Galois field\n using what is referred to as a 'generator'. There are many\n generators (128 out of 256): 3,5,6,9,11,82 to name a few. To fully\n traverse GF we iterate 255 times, multiplying by our generator\n each time.\n\n On each iteration we can determine the multiplicative inverse for\n the current element.\n\n Suppose there is an element in GF 'e'. For a given generator 'g',\n e = g^x. The multiplicative inverse of e is g^(255 - x). It turns\n out that if use the inverse of a generator as another generator\n it will produce all of the corresponding multiplicative inverses\n at the same time. For this reason, we choose 5 as our inverse\n generator because it only requires 2 multiplies and 1 add and its\n inverse, 82, requires relatively few operations as well.\n\n In order to apply the affine transformation, the multiplicative\n inverse 'ei' of 'e' can be repeatedly XOR'd (4 times) with a\n bit-cycling of 'ei'. To do this 'ei' is first stored in 's' and\n 'x'. Then 's' is left shifted and the high bit of 's' is made the\n low bit. The resulting value is stored in 's'. Then 'x' is XOR'd\n with 's' and stored in 'x'. On each subsequent iteration the same\n operation is performed. When 4 iterations are complete, 'x' is\n XOR'd with 'c' (0x63) and the transformed value is stored in 'x'.\n For example:\n\n s = 01000001\n x = 01000001\n\n iteration 1: s = 10000010, x ^= s\n iteration 2: s = 00000101, x ^= s\n iteration 3: s = 00001010, x ^= s\n iteration 4: s = 00010100, x ^= s\n x ^= 0x63\n\n This can be done with a loop where s = (s << 1) | (s >> 7). However,\n it can also be done by using a single 16-bit (in this case 32-bit)\n number 'sx'. Since XOR is an associative operation, we can set 'sx'\n to 'ei' and then XOR it with 'sx' left-shifted 1,2,3, and 4 times.\n The most significant bits will flow into the high 8 bit positions\n and be correctly XOR'd with one another. All that remains will be\n to cycle the high 8 bits by XOR'ing them all with the lower 8 bits\n afterwards.\n\n At the same time we're populating sbox and isbox we can precompute\n the multiplication we'll need to do to do MixColumns() later.\n */\n\n // apply affine transformation\n sx = ei ^ (ei << 1) ^ (ei << 2) ^ (ei << 3) ^ (ei << 4);\n sx = (sx >> 8) ^ (sx & 255) ^ 0x63;\n\n // update tables\n sbox[e] = sx;\n isbox[sx] = e;\n\n /* Mixing columns is done using matrix multiplication. The columns\n that are to be mixed are each a single word in the current state.\n The state has Nb columns (4 columns). Therefore each column is a\n 4 byte word. So to mix the columns in a single column 'c' where\n its rows are r0, r1, r2, and r3, we use the following matrix\n multiplication:\n\n [2 3 1 1]*[r0,c]=[r'0,c]\n [1 2 3 1] [r1,c] [r'1,c]\n [1 1 2 3] [r2,c] [r'2,c]\n [3 1 1 2] [r3,c] [r'3,c]\n\n r0, r1, r2, and r3 are each 1 byte of one of the words in the\n state (a column). To do matrix multiplication for each mixed\n column c' we multiply the corresponding row from the left matrix\n with the corresponding column from the right matrix. In total, we\n get 4 equations:\n\n r0,c' = 2*r0,c + 3*r1,c + 1*r2,c + 1*r3,c\n r1,c' = 1*r0,c + 2*r1,c + 3*r2,c + 1*r3,c\n r2,c' = 1*r0,c + 1*r1,c + 2*r2,c + 3*r3,c\n r3,c' = 3*r0,c + 1*r1,c + 1*r2,c + 2*r3,c\n\n As usual, the multiplication is as previously defined and the\n addition is XOR. In order to optimize mixing columns we can store\n the multiplication results in tables. If you think of the whole\n column as a word (it might help to visualize by mentally rotating\n the equations above by counterclockwise 90 degrees) then you can\n see that it would be useful to map the multiplications performed on\n each byte (r0, r1, r2, r3) onto a word as well. For instance, we\n could map 2*r0,1*r0,1*r0,3*r0 onto a word by storing 2*r0 in the\n highest 8 bits and 3*r0 in the lowest 8 bits (with the other two\n respectively in the middle). This means that a table can be\n constructed that uses r0 as an index to the word. We can do the\n same with r1, r2, and r3, creating a total of 4 tables.\n\n To construct a full c', we can just look up each byte of c in\n their respective tables and XOR the results together.\n\n Also, to build each table we only have to calculate the word\n for 2,1,1,3 for every byte ... which we can do on each iteration\n of this loop since we will iterate over every byte. After we have\n calculated 2,1,1,3 we can get the results for the other tables\n by cycling the byte at the end to the beginning. For instance\n we can take the result of table 2,1,1,3 and produce table 3,2,1,1\n by moving the right most byte to the left most position just like\n how you can imagine the 3 moved out of 2,1,1,3 and to the front\n to produce 3,2,1,1.\n\n There is another optimization in that the same multiples of\n the current element we need in order to advance our generator\n to the next iteration can be reused in performing the 2,1,1,3\n calculation. We also calculate the inverse mix column tables,\n with e,9,d,b being the inverse of 2,1,1,3.\n\n When we're done, and we need to actually mix columns, the first\n byte of each state word should be put through mix[0] (2,1,1,3),\n the second through mix[1] (3,2,1,1) and so forth. Then they should\n be XOR'd together to produce the fully mixed column.\n */\n\n // calculate mix and imix table values\n sx2 = xtime[sx];\n e2 = xtime[e];\n e4 = xtime[e2];\n e8 = xtime[e4];\n me =\n (sx2 << 24) ^ // 2\n (sx << 16) ^ // 1\n (sx << 8) ^ // 1\n (sx ^ sx2); // 3\n ime =\n (e2 ^ e4 ^ e8) << 24 ^ // E (14)\n (e ^ e8) << 16 ^ // 9\n (e ^ e4 ^ e8) << 8 ^ // D (13)\n (e ^ e2 ^ e8); // B (11)\n // produce each of the mix tables by rotating the 2,1,1,3 value\n for(var n = 0; n < 4; ++n) {\n mix[n][e] = me;\n imix[n][sx] = ime;\n // cycle the right most byte to the left most position\n // ie: 2,1,1,3 becomes 3,2,1,1\n me = me << 24 | me >>> 8;\n ime = ime << 24 | ime >>> 8;\n }\n\n // get next element and inverse\n if(e === 0) {\n // 1 is the inverse of 1\n e = ei = 1;\n } else {\n // e = 2e + 2*2*2*(10e)) = multiply e by 82 (chosen generator)\n // ei = ei + 2*2*ei = multiply ei by 5 (inverse generator)\n e = e2 ^ xtime[xtime[xtime[e2 ^ e8]]];\n ei ^= xtime[xtime[ei]];\n }\n }\n}\n\n/**\n * Generates a key schedule using the AES key expansion algorithm.\n *\n * The AES algorithm takes the Cipher Key, K, and performs a Key Expansion\n * routine to generate a key schedule. The Key Expansion generates a total\n * of Nb*(Nr + 1) words: the algorithm requires an initial set of Nb words,\n * and each of the Nr rounds requires Nb words of key data. The resulting\n * key schedule consists of a linear array of 4-byte words, denoted [wi ],\n * with i in the range 0 <= i < Nb(Nr + 1).\n *\n * KeyExpansion(byte key[4*Nk], word w[Nb*(Nr+1)], Nk)\n * AES-128 (Nb=4, Nk=4, Nr=10)\n * AES-192 (Nb=4, Nk=6, Nr=12)\n * AES-256 (Nb=4, Nk=8, Nr=14)\n * Note: Nr=Nk+6.\n *\n * Nb is the number of columns (32-bit words) comprising the State (or\n * number of bytes in a block). For AES, Nb=4.\n *\n * @param key the key to schedule (as an array of 32-bit words).\n * @param decrypt true to modify the key schedule to decrypt, false not to.\n *\n * @return the generated key schedule.\n */\nfunction _expandKey(key, decrypt) {\n // copy the key's words to initialize the key schedule\n var w = key.slice(0);\n\n /* RotWord() will rotate a word, moving the first byte to the last\n byte's position (shifting the other bytes left).\n\n We will be getting the value of Rcon at i / Nk. 'i' will iterate\n from Nk to (Nb * Nr+1). Nk = 4 (4 byte key), Nb = 4 (4 words in\n a block), Nr = Nk + 6 (10). Therefore 'i' will iterate from\n 4 to 44 (exclusive). Each time we iterate 4 times, i / Nk will\n increase by 1. We use a counter iNk to keep track of this.\n */\n\n // go through the rounds expanding the key\n var temp, iNk = 1;\n var Nk = w.length;\n var Nr1 = Nk + 6 + 1;\n var end = Nb * Nr1;\n for(var i = Nk; i < end; ++i) {\n temp = w[i - 1];\n if(i % Nk === 0) {\n // temp = SubWord(RotWord(temp)) ^ Rcon[i / Nk]\n temp =\n sbox[temp >>> 16 & 255] << 24 ^\n sbox[temp >>> 8 & 255] << 16 ^\n sbox[temp & 255] << 8 ^\n sbox[temp >>> 24] ^ (rcon[iNk] << 24);\n iNk++;\n } else if(Nk > 6 && (i % Nk === 4)) {\n // temp = SubWord(temp)\n temp =\n sbox[temp >>> 24] << 24 ^\n sbox[temp >>> 16 & 255] << 16 ^\n sbox[temp >>> 8 & 255] << 8 ^\n sbox[temp & 255];\n }\n w[i] = w[i - Nk] ^ temp;\n }\n\n /* When we are updating a cipher block we always use the code path for\n encryption whether we are decrypting or not (to shorten code and\n simplify the generation of look up tables). However, because there\n are differences in the decryption algorithm, other than just swapping\n in different look up tables, we must transform our key schedule to\n account for these changes:\n\n 1. The decryption algorithm gets its key rounds in reverse order.\n 2. The decryption algorithm adds the round key before mixing columns\n instead of afterwards.\n\n We don't need to modify our key schedule to handle the first case,\n we can just traverse the key schedule in reverse order when decrypting.\n\n The second case requires a little work.\n\n The tables we built for performing rounds will take an input and then\n perform SubBytes() and MixColumns() or, for the decrypt version,\n InvSubBytes() and InvMixColumns(). But the decrypt algorithm requires\n us to AddRoundKey() before InvMixColumns(). This means we'll need to\n apply some transformations to the round key to inverse-mix its columns\n so they'll be correct for moving AddRoundKey() to after the state has\n had its columns inverse-mixed.\n\n To inverse-mix the columns of the state when we're decrypting we use a\n lookup table that will apply InvSubBytes() and InvMixColumns() at the\n same time. However, the round key's bytes are not inverse-substituted\n in the decryption algorithm. To get around this problem, we can first\n substitute the bytes in the round key so that when we apply the\n transformation via the InvSubBytes()+InvMixColumns() table, it will\n undo our substitution leaving us with the original value that we\n want -- and then inverse-mix that value.\n\n This change will correctly alter our key schedule so that we can XOR\n each round key with our already transformed decryption state. This\n allows us to use the same code path as the encryption algorithm.\n\n We make one more change to the decryption key. Since the decryption\n algorithm runs in reverse from the encryption algorithm, we reverse\n the order of the round keys to avoid having to iterate over the key\n schedule backwards when running the encryption algorithm later in\n decryption mode. In addition to reversing the order of the round keys,\n we also swap each round key's 2nd and 4th rows. See the comments\n section where rounds are performed for more details about why this is\n done. These changes are done inline with the other substitution\n described above.\n */\n if(decrypt) {\n var tmp;\n var m0 = imix[0];\n var m1 = imix[1];\n var m2 = imix[2];\n var m3 = imix[3];\n var wnew = w.slice(0);\n end = w.length;\n for(var i = 0, wi = end - Nb; i < end; i += Nb, wi -= Nb) {\n // do not sub the first or last round key (round keys are Nb\n // words) as no column mixing is performed before they are added,\n // but do change the key order\n if(i === 0 || i === (end - Nb)) {\n wnew[i] = w[wi];\n wnew[i + 1] = w[wi + 3];\n wnew[i + 2] = w[wi + 2];\n wnew[i + 3] = w[wi + 1];\n } else {\n // substitute each round key byte because the inverse-mix\n // table will inverse-substitute it (effectively cancel the\n // substitution because round key bytes aren't sub'd in\n // decryption mode) and swap indexes 3 and 1\n for(var n = 0; n < Nb; ++n) {\n tmp = w[wi + n];\n wnew[i + (3&-n)] =\n m0[sbox[tmp >>> 24]] ^\n m1[sbox[tmp >>> 16 & 255]] ^\n m2[sbox[tmp >>> 8 & 255]] ^\n m3[sbox[tmp & 255]];\n }\n }\n }\n w = wnew;\n }\n\n return w;\n}\n\n/**\n * Updates a single block (16 bytes) using AES. The update will either\n * encrypt or decrypt the block.\n *\n * @param w the key schedule.\n * @param input the input block (an array of 32-bit words).\n * @param output the updated output block.\n * @param decrypt true to decrypt the block, false to encrypt it.\n */\nfunction _updateBlock(w, input, output, decrypt) {\n /*\n Cipher(byte in[4*Nb], byte out[4*Nb], word w[Nb*(Nr+1)])\n begin\n byte state[4,Nb]\n state = in\n AddRoundKey(state, w[0, Nb-1])\n for round = 1 step 1 to Nr-1\n SubBytes(state)\n ShiftRows(state)\n MixColumns(state)\n AddRoundKey(state, w[round*Nb, (round+1)*Nb-1])\n end for\n SubBytes(state)\n ShiftRows(state)\n AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])\n out = state\n end\n\n InvCipher(byte in[4*Nb], byte out[4*Nb], word w[Nb*(Nr+1)])\n begin\n byte state[4,Nb]\n state = in\n AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])\n for round = Nr-1 step -1 downto 1\n InvShiftRows(state)\n InvSubBytes(state)\n AddRoundKey(state, w[round*Nb, (round+1)*Nb-1])\n InvMixColumns(state)\n end for\n InvShiftRows(state)\n InvSubBytes(state)\n AddRoundKey(state, w[0, Nb-1])\n out = state\n end\n */\n\n // Encrypt: AddRoundKey(state, w[0, Nb-1])\n // Decrypt: AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])\n var Nr = w.length / 4 - 1;\n var m0, m1, m2, m3, sub;\n if(decrypt) {\n m0 = imix[0];\n m1 = imix[1];\n m2 = imix[2];\n m3 = imix[3];\n sub = isbox;\n } else {\n m0 = mix[0];\n m1 = mix[1];\n m2 = mix[2];\n m3 = mix[3];\n sub = sbox;\n }\n var a, b, c, d, a2, b2, c2;\n a = input[0] ^ w[0];\n b = input[decrypt ? 3 : 1] ^ w[1];\n c = input[2] ^ w[2];\n d = input[decrypt ? 1 : 3] ^ w[3];\n var i = 3;\n\n /* In order to share code we follow the encryption algorithm when both\n encrypting and decrypting. To account for the changes required in the\n decryption algorithm, we use different lookup tables when decrypting\n and use a modified key schedule to account for the difference in the\n order of transformations applied when performing rounds. We also get\n key rounds in reverse order (relative to encryption). */\n for(var round = 1; round < Nr; ++round) {\n /* As described above, we'll be using table lookups to perform the\n column mixing. Each column is stored as a word in the state (the\n array 'input' has one column as a word at each index). In order to\n mix a column, we perform these transformations on each row in c,\n which is 1 byte in each word. The new column for c0 is c'0:\n\n m0 m1 m2 m3\n r0,c'0 = 2*r0,c0 + 3*r1,c0 + 1*r2,c0 + 1*r3,c0\n r1,c'0 = 1*r0,c0 + 2*r1,c0 + 3*r2,c0 + 1*r3,c0\n r2,c'0 = 1*r0,c0 + 1*r1,c0 + 2*r2,c0 + 3*r3,c0\n r3,c'0 = 3*r0,c0 + 1*r1,c0 + 1*r2,c0 + 2*r3,c0\n\n So using mix tables where c0 is a word with r0 being its upper\n 8 bits and r3 being its lower 8 bits:\n\n m0[c0 >> 24] will yield this word: [2*r0,1*r0,1*r0,3*r0]\n ...\n m3[c0 & 255] will yield this word: [1*r3,1*r3,3*r3,2*r3]\n\n Therefore to mix the columns in each word in the state we\n do the following (& 255 omitted for brevity):\n c'0,r0 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]\n c'0,r1 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]\n c'0,r2 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]\n c'0,r3 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]\n\n However, before mixing, the algorithm requires us to perform\n ShiftRows(). The ShiftRows() transformation cyclically shifts the\n last 3 rows of the state over different offsets. The first row\n (r = 0) is not shifted.\n\n s'_r,c = s_r,(c + shift(r, Nb) mod Nb\n for 0 < r < 4 and 0 <= c < Nb and\n shift(1, 4) = 1\n shift(2, 4) = 2\n shift(3, 4) = 3.\n\n This causes the first byte in r = 1 to be moved to the end of\n the row, the first 2 bytes in r = 2 to be moved to the end of\n the row, the first 3 bytes in r = 3 to be moved to the end of\n the row:\n\n r1: [c0 c1 c2 c3] => [c1 c2 c3 c0]\n r2: [c0 c1 c2 c3] [c2 c3 c0 c1]\n r3: [c0 c1 c2 c3] [c3 c0 c1 c2]\n\n We can make these substitutions inline with our column mixing to\n generate an updated set of equations to produce each word in the\n state (note the columns have changed positions):\n\n c0 c1 c2 c3 => c0 c1 c2 c3\n c0 c1 c2 c3 c1 c2 c3 c0 (cycled 1 byte)\n c0 c1 c2 c3 c2 c3 c0 c1 (cycled 2 bytes)\n c0 c1 c2 c3 c3 c0 c1 c2 (cycled 3 bytes)\n\n Therefore:\n\n c'0 = 2*r0,c0 + 3*r1,c1 + 1*r2,c2 + 1*r3,c3\n c'0 = 1*r0,c0 + 2*r1,c1 + 3*r2,c2 + 1*r3,c3\n c'0 = 1*r0,c0 + 1*r1,c1 + 2*r2,c2 + 3*r3,c3\n c'0 = 3*r0,c0 + 1*r1,c1 + 1*r2,c2 + 2*r3,c3\n\n c'1 = 2*r0,c1 + 3*r1,c2 + 1*r2,c3 + 1*r3,c0\n c'1 = 1*r0,c1 + 2*r1,c2 + 3*r2,c3 + 1*r3,c0\n c'1 = 1*r0,c1 + 1*r1,c2 + 2*r2,c3 + 3*r3,c0\n c'1 = 3*r0,c1 + 1*r1,c2 + 1*r2,c3 + 2*r3,c0\n\n ... and so forth for c'2 and c'3. The important distinction is\n that the columns are cycling, with c0 being used with the m0\n map when calculating c0, but c1 being used with the m0 map when\n calculating c1 ... and so forth.\n\n When performing the inverse we transform the mirror image and\n skip the bottom row, instead of the top one, and move upwards:\n\n c3 c2 c1 c0 => c0 c3 c2 c1 (cycled 3 bytes) *same as encryption\n c3 c2 c1 c0 c1 c0 c3 c2 (cycled 2 bytes)\n c3 c2 c1 c0 c2 c1 c0 c3 (cycled 1 byte) *same as encryption\n c3 c2 c1 c0 c3 c2 c1 c0\n\n If you compare the resulting matrices for ShiftRows()+MixColumns()\n and for InvShiftRows()+InvMixColumns() the 2nd and 4th columns are\n different (in encrypt mode vs. decrypt mode). So in order to use\n the same code to handle both encryption and decryption, we will\n need to do some mapping.\n\n If in encryption mode we let a=c0, b=c1, c=c2, d=c3, and r be\n a row number in the state, then the resulting matrix in encryption\n mode for applying the above transformations would be:\n\n r1: a b c d\n r2: b c d a\n r3: c d a b\n r4: d a b c\n\n If we did the same in decryption mode we would get:\n\n r1: a d c b\n r2: b a d c\n r3: c b a d\n r4: d c b a\n\n If instead we swap d and b (set b=c3 and d=c1), then we get:\n\n r1: a b c d\n r2: d a b c\n r3: c d a b\n r4: b c d a\n\n Now the 1st and 3rd rows are the same as the encryption matrix. All\n we need to do then to make the mapping exactly the same is to swap\n the 2nd and 4th rows when in decryption mode. To do this without\n having to do it on each iteration, we swapped the 2nd and 4th rows\n in the decryption key schedule. We also have to do the swap above\n when we first pull in the input and when we set the final output. */\n a2 =\n m0[a >>> 24] ^\n m1[b >>> 16 & 255] ^\n m2[c >>> 8 & 255] ^\n m3[d & 255] ^ w[++i];\n b2 =\n m0[b >>> 24] ^\n m1[c >>> 16 & 255] ^\n m2[d >>> 8 & 255] ^\n m3[a & 255] ^ w[++i];\n c2 =\n m0[c >>> 24] ^\n m1[d >>> 16 & 255] ^\n m2[a >>> 8 & 255] ^\n m3[b & 255] ^ w[++i];\n d =\n m0[d >>> 24] ^\n m1[a >>> 16 & 255] ^\n m2[b >>> 8 & 255] ^\n m3[c & 255] ^ w[++i];\n a = a2;\n b = b2;\n c = c2;\n }\n\n /*\n Encrypt:\n SubBytes(state)\n ShiftRows(state)\n AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])\n\n Decrypt:\n InvShiftRows(state)\n InvSubBytes(state)\n AddRoundKey(state, w[0, Nb-1])\n */\n // Note: rows are shifted inline\n output[0] =\n (sub[a >>> 24] << 24) ^\n (sub[b >>> 16 & 255] << 16) ^\n (sub[c >>> 8 & 255] << 8) ^\n (sub[d & 255]) ^ w[++i];\n output[decrypt ? 3 : 1] =\n (sub[b >>> 24] << 24) ^\n (sub[c >>> 16 & 255] << 16) ^\n (sub[d >>> 8 & 255] << 8) ^\n (sub[a & 255]) ^ w[++i];\n output[2] =\n (sub[c >>> 24] << 24) ^\n (sub[d >>> 16 & 255] << 16) ^\n (sub[a >>> 8 & 255] << 8) ^\n (sub[b & 255]) ^ w[++i];\n output[decrypt ? 1 : 3] =\n (sub[d >>> 24] << 24) ^\n (sub[a >>> 16 & 255] << 16) ^\n (sub[b >>> 8 & 255] << 8) ^\n (sub[c & 255]) ^ w[++i];\n}\n\n/**\n * Deprecated. Instead, use:\n *\n * forge.cipher.createCipher('AES-', key);\n * forge.cipher.createDecipher('AES-', key);\n *\n * Creates a deprecated AES cipher object. This object's mode will default to\n * CBC (cipher-block-chaining).\n *\n * The key and iv may be given as a string of bytes, an array of bytes, a\n * byte buffer, or an array of 32-bit words.\n *\n * @param options the options to use.\n * key the symmetric key to use.\n * output the buffer to write to.\n * decrypt true for decryption, false for encryption.\n * mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nfunction _createCipher(options) {\n options = options || {};\n var mode = (options.mode || 'CBC').toUpperCase();\n var algorithm = 'AES-' + mode;\n\n var cipher;\n if(options.decrypt) {\n cipher = forge.cipher.createDecipher(algorithm, options.key);\n } else {\n cipher = forge.cipher.createCipher(algorithm, options.key);\n }\n\n // backwards compatible start API\n var start = cipher.start;\n cipher.start = function(iv, options) {\n // backwards compatibility: support second arg as output buffer\n var output = null;\n if(options instanceof forge.util.ByteBuffer) {\n output = options;\n options = {};\n }\n options = options || {};\n options.output = output;\n options.iv = iv;\n start.call(cipher, options);\n };\n\n return cipher;\n}\n","/**\n * A Javascript implementation of AES Cipher Suites for TLS.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2009-2015 Digital Bazaar, Inc.\n *\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./tls');\n\nvar tls = module.exports = forge.tls;\n\n/**\n * Supported cipher suites.\n */\ntls.CipherSuites['TLS_RSA_WITH_AES_128_CBC_SHA'] = {\n id: [0x00, 0x2f],\n name: 'TLS_RSA_WITH_AES_128_CBC_SHA',\n initSecurityParameters: function(sp) {\n sp.bulk_cipher_algorithm = tls.BulkCipherAlgorithm.aes;\n sp.cipher_type = tls.CipherType.block;\n sp.enc_key_length = 16;\n sp.block_length = 16;\n sp.fixed_iv_length = 16;\n sp.record_iv_length = 16;\n sp.mac_algorithm = tls.MACAlgorithm.hmac_sha1;\n sp.mac_length = 20;\n sp.mac_key_length = 20;\n },\n initConnectionState: initConnectionState\n};\ntls.CipherSuites['TLS_RSA_WITH_AES_256_CBC_SHA'] = {\n id: [0x00, 0x35],\n name: 'TLS_RSA_WITH_AES_256_CBC_SHA',\n initSecurityParameters: function(sp) {\n sp.bulk_cipher_algorithm = tls.BulkCipherAlgorithm.aes;\n sp.cipher_type = tls.CipherType.block;\n sp.enc_key_length = 32;\n sp.block_length = 16;\n sp.fixed_iv_length = 16;\n sp.record_iv_length = 16;\n sp.mac_algorithm = tls.MACAlgorithm.hmac_sha1;\n sp.mac_length = 20;\n sp.mac_key_length = 20;\n },\n initConnectionState: initConnectionState\n};\n\nfunction initConnectionState(state, c, sp) {\n var client = (c.entity === forge.tls.ConnectionEnd.client);\n\n // cipher setup\n state.read.cipherState = {\n init: false,\n cipher: forge.cipher.createDecipher('AES-CBC', client ?\n sp.keys.server_write_key : sp.keys.client_write_key),\n iv: client ? sp.keys.server_write_IV : sp.keys.client_write_IV\n };\n state.write.cipherState = {\n init: false,\n cipher: forge.cipher.createCipher('AES-CBC', client ?\n sp.keys.client_write_key : sp.keys.server_write_key),\n iv: client ? sp.keys.client_write_IV : sp.keys.server_write_IV\n };\n state.read.cipherFunction = decrypt_aes_cbc_sha1;\n state.write.cipherFunction = encrypt_aes_cbc_sha1;\n\n // MAC setup\n state.read.macLength = state.write.macLength = sp.mac_length;\n state.read.macFunction = state.write.macFunction = tls.hmac_sha1;\n}\n\n/**\n * Encrypts the TLSCompressed record into a TLSCipherText record using AES\n * in CBC mode.\n *\n * @param record the TLSCompressed record to encrypt.\n * @param s the ConnectionState to use.\n *\n * @return true on success, false on failure.\n */\nfunction encrypt_aes_cbc_sha1(record, s) {\n var rval = false;\n\n // append MAC to fragment, update sequence number\n var mac = s.macFunction(s.macKey, s.sequenceNumber, record);\n record.fragment.putBytes(mac);\n s.updateSequenceNumber();\n\n // TLS 1.1+ use an explicit IV every time to protect against CBC attacks\n var iv;\n if(record.version.minor === tls.Versions.TLS_1_0.minor) {\n // use the pre-generated IV when initializing for TLS 1.0, otherwise use\n // the residue from the previous encryption\n iv = s.cipherState.init ? null : s.cipherState.iv;\n } else {\n iv = forge.random.getBytesSync(16);\n }\n\n s.cipherState.init = true;\n\n // start cipher\n var cipher = s.cipherState.cipher;\n cipher.start({iv: iv});\n\n // TLS 1.1+ write IV into output\n if(record.version.minor >= tls.Versions.TLS_1_1.minor) {\n cipher.output.putBytes(iv);\n }\n\n // do encryption (default padding is appropriate)\n cipher.update(record.fragment);\n if(cipher.finish(encrypt_aes_cbc_sha1_padding)) {\n // set record fragment to encrypted output\n record.fragment = cipher.output;\n record.length = record.fragment.length();\n rval = true;\n }\n\n return rval;\n}\n\n/**\n * Handles padding for aes_cbc_sha1 in encrypt mode.\n *\n * @param blockSize the block size.\n * @param input the input buffer.\n * @param decrypt true in decrypt mode, false in encrypt mode.\n *\n * @return true on success, false on failure.\n */\nfunction encrypt_aes_cbc_sha1_padding(blockSize, input, decrypt) {\n /* The encrypted data length (TLSCiphertext.length) is one more than the sum\n of SecurityParameters.block_length, TLSCompressed.length,\n SecurityParameters.mac_length, and padding_length.\n\n The padding may be any length up to 255 bytes long, as long as it results in\n the TLSCiphertext.length being an integral multiple of the block length.\n Lengths longer than necessary might be desirable to frustrate attacks on a\n protocol based on analysis of the lengths of exchanged messages. Each uint8\n in the padding data vector must be filled with the padding length value.\n\n The padding length should be such that the total size of the\n GenericBlockCipher structure is a multiple of the cipher's block length.\n Legal values range from zero to 255, inclusive. This length specifies the\n length of the padding field exclusive of the padding_length field itself.\n\n This is slightly different from PKCS#7 because the padding value is 1\n less than the actual number of padding bytes if you include the\n padding_length uint8 itself as a padding byte. */\n if(!decrypt) {\n // get the number of padding bytes required to reach the blockSize and\n // subtract 1 for the padding value (to make room for the padding_length\n // uint8)\n var padding = blockSize - (input.length() % blockSize);\n input.fillWithByte(padding - 1, padding);\n }\n return true;\n}\n\n/**\n * Handles padding for aes_cbc_sha1 in decrypt mode.\n *\n * @param blockSize the block size.\n * @param output the output buffer.\n * @param decrypt true in decrypt mode, false in encrypt mode.\n *\n * @return true on success, false on failure.\n */\nfunction decrypt_aes_cbc_sha1_padding(blockSize, output, decrypt) {\n var rval = true;\n if(decrypt) {\n /* The last byte in the output specifies the number of padding bytes not\n including itself. Each of the padding bytes has the same value as that\n last byte (known as the padding_length). Here we check all padding\n bytes to ensure they have the value of padding_length even if one of\n them is bad in order to ward-off timing attacks. */\n var len = output.length();\n var paddingLength = output.last();\n for(var i = len - 1 - paddingLength; i < len - 1; ++i) {\n rval = rval && (output.at(i) == paddingLength);\n }\n if(rval) {\n // trim off padding bytes and last padding length byte\n output.truncate(paddingLength + 1);\n }\n }\n return rval;\n}\n\n/**\n * Decrypts a TLSCipherText record into a TLSCompressed record using\n * AES in CBC mode.\n *\n * @param record the TLSCipherText record to decrypt.\n * @param s the ConnectionState to use.\n *\n * @return true on success, false on failure.\n */\nfunction decrypt_aes_cbc_sha1(record, s) {\n var rval = false;\n\n var iv;\n if(record.version.minor === tls.Versions.TLS_1_0.minor) {\n // use pre-generated IV when initializing for TLS 1.0, otherwise use the\n // residue from the previous decryption\n iv = s.cipherState.init ? null : s.cipherState.iv;\n } else {\n // TLS 1.1+ use an explicit IV every time to protect against CBC attacks\n // that is appended to the record fragment\n iv = record.fragment.getBytes(16);\n }\n\n s.cipherState.init = true;\n\n // start cipher\n var cipher = s.cipherState.cipher;\n cipher.start({iv: iv});\n\n // do decryption\n cipher.update(record.fragment);\n rval = cipher.finish(decrypt_aes_cbc_sha1_padding);\n\n // even if decryption fails, keep going to minimize timing attacks\n\n // decrypted data:\n // first (len - 20) bytes = application data\n // last 20 bytes = MAC\n var macLen = s.macLength;\n\n // create a random MAC to check against should the mac length check fail\n // Note: do this regardless of the failure to keep timing consistent\n var mac = forge.random.getBytesSync(macLen);\n\n // get fragment and mac\n var len = cipher.output.length();\n if(len >= macLen) {\n record.fragment = cipher.output.getBytes(len - macLen);\n mac = cipher.output.getBytes(macLen);\n } else {\n // bad data, but get bytes anyway to try to keep timing consistent\n record.fragment = cipher.output.getBytes();\n }\n record.fragment = forge.util.createBuffer(record.fragment);\n record.length = record.fragment.length();\n\n // see if data integrity checks out, update sequence number\n var mac2 = s.macFunction(s.macKey, s.sequenceNumber, record);\n s.updateSequenceNumber();\n rval = compareMacs(s.macKey, mac, mac2) && rval;\n return rval;\n}\n\n/**\n * Safely compare two MACs. This function will compare two MACs in a way\n * that protects against timing attacks.\n *\n * TODO: Expose elsewhere as a utility API.\n *\n * See: https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2011/february/double-hmac-verification/\n *\n * @param key the MAC key to use.\n * @param mac1 as a binary-encoded string of bytes.\n * @param mac2 as a binary-encoded string of bytes.\n *\n * @return true if the MACs are the same, false if not.\n */\nfunction compareMacs(key, mac1, mac2) {\n var hmac = forge.hmac.create();\n\n hmac.start('SHA1', key);\n hmac.update(mac1);\n mac1 = hmac.digest().getBytes();\n\n hmac.start(null, null);\n hmac.update(mac2);\n mac2 = hmac.digest().getBytes();\n\n return mac1 === mac2;\n}\n","/**\n * Copyright (c) 2019 Digital Bazaar, Inc.\n */\n\nvar forge = require('./forge');\nrequire('./asn1');\nvar asn1 = forge.asn1;\n\nexports.privateKeyValidator = {\n // PrivateKeyInfo\n name: 'PrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // Version (INTEGER)\n name: 'PrivateKeyInfo.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyVersion'\n }, {\n // privateKeyAlgorithm\n name: 'PrivateKeyInfo.privateKeyAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'privateKeyOid'\n }]\n }, {\n // PrivateKey\n name: 'PrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'privateKey'\n }]\n};\n\nexports.publicKeyValidator = {\n name: 'SubjectPublicKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'subjectPublicKeyInfo',\n value: [{\n name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'publicKeyOid'\n }]\n },\n // capture group for ed25519PublicKey\n {\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n composed: true,\n captureBitStringValue: 'ed25519PublicKey'\n }\n // FIXME: this is capture group for rsaPublicKey, use it in this API or\n // discard?\n /* {\n // subjectPublicKey\n name: 'SubjectPublicKeyInfo.subjectPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n value: [{\n // RSAPublicKey\n name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n optional: true,\n captureAsn1: 'rsaPublicKey'\n }]\n } */\n ]\n};\n","/**\n * Javascript implementation of Abstract Syntax Notation Number One.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2015 Digital Bazaar, Inc.\n *\n * An API for storing data using the Abstract Syntax Notation Number One\n * format using DER (Distinguished Encoding Rules) encoding. This encoding is\n * commonly used to store data for PKI, i.e. X.509 Certificates, and this\n * implementation exists for that purpose.\n *\n * Abstract Syntax Notation Number One (ASN.1) is used to define the abstract\n * syntax of information without restricting the way the information is encoded\n * for transmission. It provides a standard that allows for open systems\n * communication. ASN.1 defines the syntax of information data and a number of\n * simple data types as well as a notation for describing them and specifying\n * values for them.\n *\n * The RSA algorithm creates public and private keys that are often stored in\n * X.509 or PKCS#X formats -- which use ASN.1 (encoded in DER format). This\n * class provides the most basic functionality required to store and load DSA\n * keys that are encoded according to ASN.1.\n *\n * The most common binary encodings for ASN.1 are BER (Basic Encoding Rules)\n * and DER (Distinguished Encoding Rules). DER is just a subset of BER that\n * has stricter requirements for how data must be encoded.\n *\n * Each ASN.1 structure has a tag (a byte identifying the ASN.1 structure type)\n * and a byte array for the value of this ASN1 structure which may be data or a\n * list of ASN.1 structures.\n *\n * Each ASN.1 structure using BER is (Tag-Length-Value):\n *\n * | byte 0 | bytes X | bytes Y |\n * |--------|---------|----------\n * | tag | length | value |\n *\n * ASN.1 allows for tags to be of \"High-tag-number form\" which allows a tag to\n * be two or more octets, but that is not supported by this class. A tag is\n * only 1 byte. Bits 1-5 give the tag number (ie the data type within a\n * particular 'class'), 6 indicates whether or not the ASN.1 value is\n * constructed from other ASN.1 values, and bits 7 and 8 give the 'class'. If\n * bits 7 and 8 are both zero, the class is UNIVERSAL. If only bit 7 is set,\n * then the class is APPLICATION. If only bit 8 is set, then the class is\n * CONTEXT_SPECIFIC. If both bits 7 and 8 are set, then the class is PRIVATE.\n * The tag numbers for the data types for the class UNIVERSAL are listed below:\n *\n * UNIVERSAL 0 Reserved for use by the encoding rules\n * UNIVERSAL 1 Boolean type\n * UNIVERSAL 2 Integer type\n * UNIVERSAL 3 Bitstring type\n * UNIVERSAL 4 Octetstring type\n * UNIVERSAL 5 Null type\n * UNIVERSAL 6 Object identifier type\n * UNIVERSAL 7 Object descriptor type\n * UNIVERSAL 8 External type and Instance-of type\n * UNIVERSAL 9 Real type\n * UNIVERSAL 10 Enumerated type\n * UNIVERSAL 11 Embedded-pdv type\n * UNIVERSAL 12 UTF8String type\n * UNIVERSAL 13 Relative object identifier type\n * UNIVERSAL 14-15 Reserved for future editions\n * UNIVERSAL 16 Sequence and Sequence-of types\n * UNIVERSAL 17 Set and Set-of types\n * UNIVERSAL 18-22, 25-30 Character string types\n * UNIVERSAL 23-24 Time types\n *\n * The length of an ASN.1 structure is specified after the tag identifier.\n * There is a definite form and an indefinite form. The indefinite form may\n * be used if the encoding is constructed and not all immediately available.\n * The indefinite form is encoded using a length byte with only the 8th bit\n * set. The end of the constructed object is marked using end-of-contents\n * octets (two zero bytes).\n *\n * The definite form looks like this:\n *\n * The length may take up 1 or more bytes, it depends on the length of the\n * value of the ASN.1 structure. DER encoding requires that if the ASN.1\n * structure has a value that has a length greater than 127, more than 1 byte\n * will be used to store its length, otherwise just one byte will be used.\n * This is strict.\n *\n * In the case that the length of the ASN.1 value is less than 127, 1 octet\n * (byte) is used to store the \"short form\" length. The 8th bit has a value of\n * 0 indicating the length is \"short form\" and not \"long form\" and bits 7-1\n * give the length of the data. (The 8th bit is the left-most, most significant\n * bit: also known as big endian or network format).\n *\n * In the case that the length of the ASN.1 value is greater than 127, 2 to\n * 127 octets (bytes) are used to store the \"long form\" length. The first\n * byte's 8th bit is set to 1 to indicate the length is \"long form.\" Bits 7-1\n * give the number of additional octets. All following octets are in base 256\n * with the most significant digit first (typical big-endian binary unsigned\n * integer storage). So, for instance, if the length of a value was 257, the\n * first byte would be set to:\n *\n * 10000010 = 130 = 0x82.\n *\n * This indicates there are 2 octets (base 256) for the length. The second and\n * third bytes (the octets just mentioned) would store the length in base 256:\n *\n * octet 2: 00000001 = 1 * 256^1 = 256\n * octet 3: 00000001 = 1 * 256^0 = 1\n * total = 257\n *\n * The algorithm for converting a js integer value of 257 to base-256 is:\n *\n * var value = 257;\n * var bytes = [];\n * bytes[0] = (value >>> 8) & 0xFF; // most significant byte first\n * bytes[1] = value & 0xFF; // least significant byte last\n *\n * On the ASN.1 UNIVERSAL Object Identifier (OID) type:\n *\n * An OID can be written like: \"value1.value2.value3...valueN\"\n *\n * The DER encoding rules:\n *\n * The first byte has the value 40 * value1 + value2.\n * The following bytes, if any, encode the remaining values. Each value is\n * encoded in base 128, most significant digit first (big endian), with as\n * few digits as possible, and the most significant bit of each byte set\n * to 1 except the last in each value's encoding. For example: Given the\n * OID \"1.2.840.113549\", its DER encoding is (remember each byte except the\n * last one in each encoding is OR'd with 0x80):\n *\n * byte 1: 40 * 1 + 2 = 42 = 0x2A.\n * bytes 2-3: 128 * 6 + 72 = 840 = 6 72 = 6 72 = 0x0648 = 0x8648\n * bytes 4-6: 16384 * 6 + 128 * 119 + 13 = 6 119 13 = 0x06770D = 0x86F70D\n *\n * The final value is: 0x2A864886F70D.\n * The full OID (including ASN.1 tag and length of 6 bytes) is:\n * 0x06062A864886F70D\n */\nvar forge = require('./forge');\nrequire('./util');\nrequire('./oids');\n\n/* ASN.1 API */\nvar asn1 = module.exports = forge.asn1 = forge.asn1 || {};\n\n/**\n * ASN.1 classes.\n */\nasn1.Class = {\n UNIVERSAL: 0x00,\n APPLICATION: 0x40,\n CONTEXT_SPECIFIC: 0x80,\n PRIVATE: 0xC0\n};\n\n/**\n * ASN.1 types. Not all types are supported by this implementation, only\n * those necessary to implement a simple PKI are implemented.\n */\nasn1.Type = {\n NONE: 0,\n BOOLEAN: 1,\n INTEGER: 2,\n BITSTRING: 3,\n OCTETSTRING: 4,\n NULL: 5,\n OID: 6,\n ODESC: 7,\n EXTERNAL: 8,\n REAL: 9,\n ENUMERATED: 10,\n EMBEDDED: 11,\n UTF8: 12,\n ROID: 13,\n SEQUENCE: 16,\n SET: 17,\n PRINTABLESTRING: 19,\n IA5STRING: 22,\n UTCTIME: 23,\n GENERALIZEDTIME: 24,\n BMPSTRING: 30\n};\n\n/**\n * Creates a new asn1 object.\n *\n * @param tagClass the tag class for the object.\n * @param type the data type (tag number) for the object.\n * @param constructed true if the asn1 object is in constructed form.\n * @param value the value for the object, if it is not constructed.\n * @param [options] the options to use:\n * [bitStringContents] the plain BIT STRING content including padding\n * byte.\n *\n * @return the asn1 object.\n */\nasn1.create = function(tagClass, type, constructed, value, options) {\n /* An asn1 object has a tagClass, a type, a constructed flag, and a\n value. The value's type depends on the constructed flag. If\n constructed, it will contain a list of other asn1 objects. If not,\n it will contain the ASN.1 value as an array of bytes formatted\n according to the ASN.1 data type. */\n\n // remove undefined values\n if(forge.util.isArray(value)) {\n var tmp = [];\n for(var i = 0; i < value.length; ++i) {\n if(value[i] !== undefined) {\n tmp.push(value[i]);\n }\n }\n value = tmp;\n }\n\n var obj = {\n tagClass: tagClass,\n type: type,\n constructed: constructed,\n composed: constructed || forge.util.isArray(value),\n value: value\n };\n if(options && 'bitStringContents' in options) {\n // TODO: copy byte buffer if it's a buffer not a string\n obj.bitStringContents = options.bitStringContents;\n // TODO: add readonly flag to avoid this overhead\n // save copy to detect changes\n obj.original = asn1.copy(obj);\n }\n return obj;\n};\n\n/**\n * Copies an asn1 object.\n *\n * @param obj the asn1 object.\n * @param [options] copy options:\n * [excludeBitStringContents] true to not copy bitStringContents\n *\n * @return the a copy of the asn1 object.\n */\nasn1.copy = function(obj, options) {\n var copy;\n\n if(forge.util.isArray(obj)) {\n copy = [];\n for(var i = 0; i < obj.length; ++i) {\n copy.push(asn1.copy(obj[i], options));\n }\n return copy;\n }\n\n if(typeof obj === 'string') {\n // TODO: copy byte buffer if it's a buffer not a string\n return obj;\n }\n\n copy = {\n tagClass: obj.tagClass,\n type: obj.type,\n constructed: obj.constructed,\n composed: obj.composed,\n value: asn1.copy(obj.value, options)\n };\n if(options && !options.excludeBitStringContents) {\n // TODO: copy byte buffer if it's a buffer not a string\n copy.bitStringContents = obj.bitStringContents;\n }\n return copy;\n};\n\n/**\n * Compares asn1 objects for equality.\n *\n * Note this function does not run in constant time.\n *\n * @param obj1 the first asn1 object.\n * @param obj2 the second asn1 object.\n * @param [options] compare options:\n * [includeBitStringContents] true to compare bitStringContents\n *\n * @return true if the asn1 objects are equal.\n */\nasn1.equals = function(obj1, obj2, options) {\n if(forge.util.isArray(obj1)) {\n if(!forge.util.isArray(obj2)) {\n return false;\n }\n if(obj1.length !== obj2.length) {\n return false;\n }\n for(var i = 0; i < obj1.length; ++i) {\n if(!asn1.equals(obj1[i], obj2[i])) {\n return false;\n }\n }\n return true;\n }\n\n if(typeof obj1 !== typeof obj2) {\n return false;\n }\n\n if(typeof obj1 === 'string') {\n return obj1 === obj2;\n }\n\n var equal = obj1.tagClass === obj2.tagClass &&\n obj1.type === obj2.type &&\n obj1.constructed === obj2.constructed &&\n obj1.composed === obj2.composed &&\n asn1.equals(obj1.value, obj2.value);\n if(options && options.includeBitStringContents) {\n equal = equal && (obj1.bitStringContents === obj2.bitStringContents);\n }\n\n return equal;\n};\n\n/**\n * Gets the length of a BER-encoded ASN.1 value.\n *\n * In case the length is not specified, undefined is returned.\n *\n * @param b the BER-encoded ASN.1 byte buffer, starting with the first\n * length byte.\n *\n * @return the length of the BER-encoded ASN.1 value or undefined.\n */\nasn1.getBerValueLength = function(b) {\n // TODO: move this function and related DER/BER functions to a der.js\n // file; better abstract ASN.1 away from der/ber.\n var b2 = b.getByte();\n if(b2 === 0x80) {\n return undefined;\n }\n\n // see if the length is \"short form\" or \"long form\" (bit 8 set)\n var length;\n var longForm = b2 & 0x80;\n if(!longForm) {\n // length is just the first byte\n length = b2;\n } else {\n // the number of bytes the length is specified in bits 7 through 1\n // and each length byte is in big-endian base-256\n length = b.getInt((b2 & 0x7F) << 3);\n }\n return length;\n};\n\n/**\n * Check if the byte buffer has enough bytes. Throws an Error if not.\n *\n * @param bytes the byte buffer to parse from.\n * @param remaining the bytes remaining in the current parsing state.\n * @param n the number of bytes the buffer must have.\n */\nfunction _checkBufferLength(bytes, remaining, n) {\n if(n > remaining) {\n var error = new Error('Too few bytes to parse DER.');\n error.available = bytes.length();\n error.remaining = remaining;\n error.requested = n;\n throw error;\n }\n}\n\n/**\n * Gets the length of a BER-encoded ASN.1 value.\n *\n * In case the length is not specified, undefined is returned.\n *\n * @param bytes the byte buffer to parse from.\n * @param remaining the bytes remaining in the current parsing state.\n *\n * @return the length of the BER-encoded ASN.1 value or undefined.\n */\nvar _getValueLength = function(bytes, remaining) {\n // TODO: move this function and related DER/BER functions to a der.js\n // file; better abstract ASN.1 away from der/ber.\n // fromDer already checked that this byte exists\n var b2 = bytes.getByte();\n remaining--;\n if(b2 === 0x80) {\n return undefined;\n }\n\n // see if the length is \"short form\" or \"long form\" (bit 8 set)\n var length;\n var longForm = b2 & 0x80;\n if(!longForm) {\n // length is just the first byte\n length = b2;\n } else {\n // the number of bytes the length is specified in bits 7 through 1\n // and each length byte is in big-endian base-256\n var longFormBytes = b2 & 0x7F;\n _checkBufferLength(bytes, remaining, longFormBytes);\n length = bytes.getInt(longFormBytes << 3);\n }\n // FIXME: this will only happen for 32 bit getInt with high bit set\n if(length < 0) {\n throw new Error('Negative length: ' + length);\n }\n return length;\n};\n\n/**\n * Parses an asn1 object from a byte buffer in DER format.\n *\n * @param bytes the byte buffer to parse from.\n * @param [strict] true to be strict when checking value lengths, false to\n * allow truncated values (default: true).\n * @param [options] object with options or boolean strict flag\n * [strict] true to be strict when checking value lengths, false to\n * allow truncated values (default: true).\n * [decodeBitStrings] true to attempt to decode the content of\n * BIT STRINGs (not OCTET STRINGs) using strict mode. Note that\n * without schema support to understand the data context this can\n * erroneously decode values that happen to be valid ASN.1. This\n * flag will be deprecated or removed as soon as schema support is\n * available. (default: true)\n *\n * @return the parsed asn1 object.\n */\nasn1.fromDer = function(bytes, options) {\n if(options === undefined) {\n options = {\n strict: true,\n decodeBitStrings: true\n };\n }\n if(typeof options === 'boolean') {\n options = {\n strict: options,\n decodeBitStrings: true\n };\n }\n if(!('strict' in options)) {\n options.strict = true;\n }\n if(!('decodeBitStrings' in options)) {\n options.decodeBitStrings = true;\n }\n\n // wrap in buffer if needed\n if(typeof bytes === 'string') {\n bytes = forge.util.createBuffer(bytes);\n }\n\n return _fromDer(bytes, bytes.length(), 0, options);\n};\n\n/**\n * Internal function to parse an asn1 object from a byte buffer in DER format.\n *\n * @param bytes the byte buffer to parse from.\n * @param remaining the number of bytes remaining for this chunk.\n * @param depth the current parsing depth.\n * @param options object with same options as fromDer().\n *\n * @return the parsed asn1 object.\n */\nfunction _fromDer(bytes, remaining, depth, options) {\n // temporary storage for consumption calculations\n var start;\n\n // minimum length for ASN.1 DER structure is 2\n _checkBufferLength(bytes, remaining, 2);\n\n // get the first byte\n var b1 = bytes.getByte();\n // consumed one byte\n remaining--;\n\n // get the tag class\n var tagClass = (b1 & 0xC0);\n\n // get the type (bits 1-5)\n var type = b1 & 0x1F;\n\n // get the variable value length and adjust remaining bytes\n start = bytes.length();\n var length = _getValueLength(bytes, remaining);\n remaining -= start - bytes.length();\n\n // ensure there are enough bytes to get the value\n if(length !== undefined && length > remaining) {\n if(options.strict) {\n var error = new Error('Too few bytes to read ASN.1 value.');\n error.available = bytes.length();\n error.remaining = remaining;\n error.requested = length;\n throw error;\n }\n // Note: be lenient with truncated values and use remaining state bytes\n length = remaining;\n }\n\n // value storage\n var value;\n // possible BIT STRING contents storage\n var bitStringContents;\n\n // constructed flag is bit 6 (32 = 0x20) of the first byte\n var constructed = ((b1 & 0x20) === 0x20);\n if(constructed) {\n // parse child asn1 objects from the value\n value = [];\n if(length === undefined) {\n // asn1 object of indefinite length, read until end tag\n for(;;) {\n _checkBufferLength(bytes, remaining, 2);\n if(bytes.bytes(2) === String.fromCharCode(0, 0)) {\n bytes.getBytes(2);\n remaining -= 2;\n break;\n }\n start = bytes.length();\n value.push(_fromDer(bytes, remaining, depth + 1, options));\n remaining -= start - bytes.length();\n }\n } else {\n // parsing asn1 object of definite length\n while(length > 0) {\n start = bytes.length();\n value.push(_fromDer(bytes, length, depth + 1, options));\n remaining -= start - bytes.length();\n length -= start - bytes.length();\n }\n }\n }\n\n // if a BIT STRING, save the contents including padding\n if(value === undefined && tagClass === asn1.Class.UNIVERSAL &&\n type === asn1.Type.BITSTRING) {\n bitStringContents = bytes.bytes(length);\n }\n\n // determine if a non-constructed value should be decoded as a composed\n // value that contains other ASN.1 objects. BIT STRINGs (and OCTET STRINGs)\n // can be used this way.\n if(value === undefined && options.decodeBitStrings &&\n tagClass === asn1.Class.UNIVERSAL &&\n // FIXME: OCTET STRINGs not yet supported here\n // .. other parts of forge expect to decode OCTET STRINGs manually\n (type === asn1.Type.BITSTRING /*|| type === asn1.Type.OCTETSTRING*/) &&\n length > 1) {\n // save read position\n var savedRead = bytes.read;\n var savedRemaining = remaining;\n var unused = 0;\n if(type === asn1.Type.BITSTRING) {\n /* The first octet gives the number of bits by which the length of the\n bit string is less than the next multiple of eight (this is called\n the \"number of unused bits\").\n\n The second and following octets give the value of the bit string\n converted to an octet string. */\n _checkBufferLength(bytes, remaining, 1);\n unused = bytes.getByte();\n remaining--;\n }\n // if all bits are used, maybe the BIT/OCTET STRING holds ASN.1 objs\n if(unused === 0) {\n try {\n // attempt to parse child asn1 object from the value\n // (stored in array to signal composed value)\n start = bytes.length();\n var subOptions = {\n // enforce strict mode to avoid parsing ASN.1 from plain data\n verbose: options.verbose,\n strict: true,\n decodeBitStrings: true\n };\n var composed = _fromDer(bytes, remaining, depth + 1, subOptions);\n var used = start - bytes.length();\n remaining -= used;\n if(type == asn1.Type.BITSTRING) {\n used++;\n }\n\n // if the data all decoded and the class indicates UNIVERSAL or\n // CONTEXT_SPECIFIC then assume we've got an encapsulated ASN.1 object\n var tc = composed.tagClass;\n if(used === length &&\n (tc === asn1.Class.UNIVERSAL || tc === asn1.Class.CONTEXT_SPECIFIC)) {\n value = [composed];\n }\n } catch(ex) {\n }\n }\n if(value === undefined) {\n // restore read position\n bytes.read = savedRead;\n remaining = savedRemaining;\n }\n }\n\n if(value === undefined) {\n // asn1 not constructed or composed, get raw value\n // TODO: do DER to OID conversion and vice-versa in .toDer?\n\n if(length === undefined) {\n if(options.strict) {\n throw new Error('Non-constructed ASN.1 object of indefinite length.');\n }\n // be lenient and use remaining state bytes\n length = remaining;\n }\n\n if(type === asn1.Type.BMPSTRING) {\n value = '';\n for(; length > 0; length -= 2) {\n _checkBufferLength(bytes, remaining, 2);\n value += String.fromCharCode(bytes.getInt16());\n remaining -= 2;\n }\n } else {\n value = bytes.getBytes(length);\n }\n }\n\n // add BIT STRING contents if available\n var asn1Options = bitStringContents === undefined ? null : {\n bitStringContents: bitStringContents\n };\n\n // create and return asn1 object\n return asn1.create(tagClass, type, constructed, value, asn1Options);\n}\n\n/**\n * Converts the given asn1 object to a buffer of bytes in DER format.\n *\n * @param asn1 the asn1 object to convert to bytes.\n *\n * @return the buffer of bytes.\n */\nasn1.toDer = function(obj) {\n var bytes = forge.util.createBuffer();\n\n // build the first byte\n var b1 = obj.tagClass | obj.type;\n\n // for storing the ASN.1 value\n var value = forge.util.createBuffer();\n\n // use BIT STRING contents if available and data not changed\n var useBitStringContents = false;\n if('bitStringContents' in obj) {\n useBitStringContents = true;\n if(obj.original) {\n useBitStringContents = asn1.equals(obj, obj.original);\n }\n }\n\n if(useBitStringContents) {\n value.putBytes(obj.bitStringContents);\n } else if(obj.composed) {\n // if composed, use each child asn1 object's DER bytes as value\n // turn on 6th bit (0x20 = 32) to indicate asn1 is constructed\n // from other asn1 objects\n if(obj.constructed) {\n b1 |= 0x20;\n } else {\n // type is a bit string, add unused bits of 0x00\n value.putByte(0x00);\n }\n\n // add all of the child DER bytes together\n for(var i = 0; i < obj.value.length; ++i) {\n if(obj.value[i] !== undefined) {\n value.putBuffer(asn1.toDer(obj.value[i]));\n }\n }\n } else {\n // use asn1.value directly\n if(obj.type === asn1.Type.BMPSTRING) {\n for(var i = 0; i < obj.value.length; ++i) {\n value.putInt16(obj.value.charCodeAt(i));\n }\n } else {\n // ensure integer is minimally-encoded\n // TODO: should all leading bytes be stripped vs just one?\n // .. ex '00 00 01' => '01'?\n if(obj.type === asn1.Type.INTEGER &&\n obj.value.length > 1 &&\n // leading 0x00 for positive integer\n ((obj.value.charCodeAt(0) === 0 &&\n (obj.value.charCodeAt(1) & 0x80) === 0) ||\n // leading 0xFF for negative integer\n (obj.value.charCodeAt(0) === 0xFF &&\n (obj.value.charCodeAt(1) & 0x80) === 0x80))) {\n value.putBytes(obj.value.substr(1));\n } else {\n value.putBytes(obj.value);\n }\n }\n }\n\n // add tag byte\n bytes.putByte(b1);\n\n // use \"short form\" encoding\n if(value.length() <= 127) {\n // one byte describes the length\n // bit 8 = 0 and bits 7-1 = length\n bytes.putByte(value.length() & 0x7F);\n } else {\n // use \"long form\" encoding\n // 2 to 127 bytes describe the length\n // first byte: bit 8 = 1 and bits 7-1 = # of additional bytes\n // other bytes: length in base 256, big-endian\n var len = value.length();\n var lenBytes = '';\n do {\n lenBytes += String.fromCharCode(len & 0xFF);\n len = len >>> 8;\n } while(len > 0);\n\n // set first byte to # bytes used to store the length and turn on\n // bit 8 to indicate long-form length is used\n bytes.putByte(lenBytes.length | 0x80);\n\n // concatenate length bytes in reverse since they were generated\n // little endian and we need big endian\n for(var i = lenBytes.length - 1; i >= 0; --i) {\n bytes.putByte(lenBytes.charCodeAt(i));\n }\n }\n\n // concatenate value bytes\n bytes.putBuffer(value);\n return bytes;\n};\n\n/**\n * Converts an OID dot-separated string to a byte buffer. The byte buffer\n * contains only the DER-encoded value, not any tag or length bytes.\n *\n * @param oid the OID dot-separated string.\n *\n * @return the byte buffer.\n */\nasn1.oidToDer = function(oid) {\n // split OID into individual values\n var values = oid.split('.');\n var bytes = forge.util.createBuffer();\n\n // first byte is 40 * value1 + value2\n bytes.putByte(40 * parseInt(values[0], 10) + parseInt(values[1], 10));\n // other bytes are each value in base 128 with 8th bit set except for\n // the last byte for each value\n var last, valueBytes, value, b;\n for(var i = 2; i < values.length; ++i) {\n // produce value bytes in reverse because we don't know how many\n // bytes it will take to store the value\n last = true;\n valueBytes = [];\n value = parseInt(values[i], 10);\n do {\n b = value & 0x7F;\n value = value >>> 7;\n // if value is not last, then turn on 8th bit\n if(!last) {\n b |= 0x80;\n }\n valueBytes.push(b);\n last = false;\n } while(value > 0);\n\n // add value bytes in reverse (needs to be in big endian)\n for(var n = valueBytes.length - 1; n >= 0; --n) {\n bytes.putByte(valueBytes[n]);\n }\n }\n\n return bytes;\n};\n\n/**\n * Converts a DER-encoded byte buffer to an OID dot-separated string. The\n * byte buffer should contain only the DER-encoded value, not any tag or\n * length bytes.\n *\n * @param bytes the byte buffer.\n *\n * @return the OID dot-separated string.\n */\nasn1.derToOid = function(bytes) {\n var oid;\n\n // wrap in buffer if needed\n if(typeof bytes === 'string') {\n bytes = forge.util.createBuffer(bytes);\n }\n\n // first byte is 40 * value1 + value2\n var b = bytes.getByte();\n oid = Math.floor(b / 40) + '.' + (b % 40);\n\n // other bytes are each value in base 128 with 8th bit set except for\n // the last byte for each value\n var value = 0;\n while(bytes.length() > 0) {\n b = bytes.getByte();\n value = value << 7;\n // not the last byte for the value\n if(b & 0x80) {\n value += b & 0x7F;\n } else {\n // last byte\n oid += '.' + (value + b);\n value = 0;\n }\n }\n\n return oid;\n};\n\n/**\n * Converts a UTCTime value to a date.\n *\n * Note: GeneralizedTime has 4 digits for the year and is used for X.509\n * dates past 2049. Parsing that structure hasn't been implemented yet.\n *\n * @param utc the UTCTime value to convert.\n *\n * @return the date.\n */\nasn1.utcTimeToDate = function(utc) {\n /* The following formats can be used:\n\n YYMMDDhhmmZ\n YYMMDDhhmm+hh'mm'\n YYMMDDhhmm-hh'mm'\n YYMMDDhhmmssZ\n YYMMDDhhmmss+hh'mm'\n YYMMDDhhmmss-hh'mm'\n\n Where:\n\n YY is the least significant two digits of the year\n MM is the month (01 to 12)\n DD is the day (01 to 31)\n hh is the hour (00 to 23)\n mm are the minutes (00 to 59)\n ss are the seconds (00 to 59)\n Z indicates that local time is GMT, + indicates that local time is\n later than GMT, and - indicates that local time is earlier than GMT\n hh' is the absolute value of the offset from GMT in hours\n mm' is the absolute value of the offset from GMT in minutes */\n var date = new Date();\n\n // if YY >= 50 use 19xx, if YY < 50 use 20xx\n var year = parseInt(utc.substr(0, 2), 10);\n year = (year >= 50) ? 1900 + year : 2000 + year;\n var MM = parseInt(utc.substr(2, 2), 10) - 1; // use 0-11 for month\n var DD = parseInt(utc.substr(4, 2), 10);\n var hh = parseInt(utc.substr(6, 2), 10);\n var mm = parseInt(utc.substr(8, 2), 10);\n var ss = 0;\n\n // not just YYMMDDhhmmZ\n if(utc.length > 11) {\n // get character after minutes\n var c = utc.charAt(10);\n var end = 10;\n\n // see if seconds are present\n if(c !== '+' && c !== '-') {\n // get seconds\n ss = parseInt(utc.substr(10, 2), 10);\n end += 2;\n }\n }\n\n // update date\n date.setUTCFullYear(year, MM, DD);\n date.setUTCHours(hh, mm, ss, 0);\n\n if(end) {\n // get +/- after end of time\n c = utc.charAt(end);\n if(c === '+' || c === '-') {\n // get hours+minutes offset\n var hhoffset = parseInt(utc.substr(end + 1, 2), 10);\n var mmoffset = parseInt(utc.substr(end + 4, 2), 10);\n\n // calculate offset in milliseconds\n var offset = hhoffset * 60 + mmoffset;\n offset *= 60000;\n\n // apply offset\n if(c === '+') {\n date.setTime(+date - offset);\n } else {\n date.setTime(+date + offset);\n }\n }\n }\n\n return date;\n};\n\n/**\n * Converts a GeneralizedTime value to a date.\n *\n * @param gentime the GeneralizedTime value to convert.\n *\n * @return the date.\n */\nasn1.generalizedTimeToDate = function(gentime) {\n /* The following formats can be used:\n\n YYYYMMDDHHMMSS\n YYYYMMDDHHMMSS.fff\n YYYYMMDDHHMMSSZ\n YYYYMMDDHHMMSS.fffZ\n YYYYMMDDHHMMSS+hh'mm'\n YYYYMMDDHHMMSS.fff+hh'mm'\n YYYYMMDDHHMMSS-hh'mm'\n YYYYMMDDHHMMSS.fff-hh'mm'\n\n Where:\n\n YYYY is the year\n MM is the month (01 to 12)\n DD is the day (01 to 31)\n hh is the hour (00 to 23)\n mm are the minutes (00 to 59)\n ss are the seconds (00 to 59)\n .fff is the second fraction, accurate to three decimal places\n Z indicates that local time is GMT, + indicates that local time is\n later than GMT, and - indicates that local time is earlier than GMT\n hh' is the absolute value of the offset from GMT in hours\n mm' is the absolute value of the offset from GMT in minutes */\n var date = new Date();\n\n var YYYY = parseInt(gentime.substr(0, 4), 10);\n var MM = parseInt(gentime.substr(4, 2), 10) - 1; // use 0-11 for month\n var DD = parseInt(gentime.substr(6, 2), 10);\n var hh = parseInt(gentime.substr(8, 2), 10);\n var mm = parseInt(gentime.substr(10, 2), 10);\n var ss = parseInt(gentime.substr(12, 2), 10);\n var fff = 0;\n var offset = 0;\n var isUTC = false;\n\n if(gentime.charAt(gentime.length - 1) === 'Z') {\n isUTC = true;\n }\n\n var end = gentime.length - 5, c = gentime.charAt(end);\n if(c === '+' || c === '-') {\n // get hours+minutes offset\n var hhoffset = parseInt(gentime.substr(end + 1, 2), 10);\n var mmoffset = parseInt(gentime.substr(end + 4, 2), 10);\n\n // calculate offset in milliseconds\n offset = hhoffset * 60 + mmoffset;\n offset *= 60000;\n\n // apply offset\n if(c === '+') {\n offset *= -1;\n }\n\n isUTC = true;\n }\n\n // check for second fraction\n if(gentime.charAt(14) === '.') {\n fff = parseFloat(gentime.substr(14), 10) * 1000;\n }\n\n if(isUTC) {\n date.setUTCFullYear(YYYY, MM, DD);\n date.setUTCHours(hh, mm, ss, fff);\n\n // apply offset\n date.setTime(+date + offset);\n } else {\n date.setFullYear(YYYY, MM, DD);\n date.setHours(hh, mm, ss, fff);\n }\n\n return date;\n};\n\n/**\n * Converts a date to a UTCTime value.\n *\n * Note: GeneralizedTime has 4 digits for the year and is used for X.509\n * dates past 2049. Converting to a GeneralizedTime hasn't been\n * implemented yet.\n *\n * @param date the date to convert.\n *\n * @return the UTCTime value.\n */\nasn1.dateToUtcTime = function(date) {\n // TODO: validate; currently assumes proper format\n if(typeof date === 'string') {\n return date;\n }\n\n var rval = '';\n\n // create format YYMMDDhhmmssZ\n var format = [];\n format.push(('' + date.getUTCFullYear()).substr(2));\n format.push('' + (date.getUTCMonth() + 1));\n format.push('' + date.getUTCDate());\n format.push('' + date.getUTCHours());\n format.push('' + date.getUTCMinutes());\n format.push('' + date.getUTCSeconds());\n\n // ensure 2 digits are used for each format entry\n for(var i = 0; i < format.length; ++i) {\n if(format[i].length < 2) {\n rval += '0';\n }\n rval += format[i];\n }\n rval += 'Z';\n\n return rval;\n};\n\n/**\n * Converts a date to a GeneralizedTime value.\n *\n * @param date the date to convert.\n *\n * @return the GeneralizedTime value as a string.\n */\nasn1.dateToGeneralizedTime = function(date) {\n // TODO: validate; currently assumes proper format\n if(typeof date === 'string') {\n return date;\n }\n\n var rval = '';\n\n // create format YYYYMMDDHHMMSSZ\n var format = [];\n format.push('' + date.getUTCFullYear());\n format.push('' + (date.getUTCMonth() + 1));\n format.push('' + date.getUTCDate());\n format.push('' + date.getUTCHours());\n format.push('' + date.getUTCMinutes());\n format.push('' + date.getUTCSeconds());\n\n // ensure 2 digits are used for each format entry\n for(var i = 0; i < format.length; ++i) {\n if(format[i].length < 2) {\n rval += '0';\n }\n rval += format[i];\n }\n rval += 'Z';\n\n return rval;\n};\n\n/**\n * Converts a javascript integer to a DER-encoded byte buffer to be used\n * as the value for an INTEGER type.\n *\n * @param x the integer.\n *\n * @return the byte buffer.\n */\nasn1.integerToDer = function(x) {\n var rval = forge.util.createBuffer();\n if(x >= -0x80 && x < 0x80) {\n return rval.putSignedInt(x, 8);\n }\n if(x >= -0x8000 && x < 0x8000) {\n return rval.putSignedInt(x, 16);\n }\n if(x >= -0x800000 && x < 0x800000) {\n return rval.putSignedInt(x, 24);\n }\n if(x >= -0x80000000 && x < 0x80000000) {\n return rval.putSignedInt(x, 32);\n }\n var error = new Error('Integer too large; max is 32-bits.');\n error.integer = x;\n throw error;\n};\n\n/**\n * Converts a DER-encoded byte buffer to a javascript integer. This is\n * typically used to decode the value of an INTEGER type.\n *\n * @param bytes the byte buffer.\n *\n * @return the integer.\n */\nasn1.derToInteger = function(bytes) {\n // wrap in buffer if needed\n if(typeof bytes === 'string') {\n bytes = forge.util.createBuffer(bytes);\n }\n\n var n = bytes.length() * 8;\n if(n > 32) {\n throw new Error('Integer too large; max is 32-bits.');\n }\n return bytes.getSignedInt(n);\n};\n\n/**\n * Validates that the given ASN.1 object is at least a super set of the\n * given ASN.1 structure. Only tag classes and types are checked. An\n * optional map may also be provided to capture ASN.1 values while the\n * structure is checked.\n *\n * To capture an ASN.1 value, set an object in the validator's 'capture'\n * parameter to the key to use in the capture map. To capture the full\n * ASN.1 object, specify 'captureAsn1'. To capture BIT STRING bytes, including\n * the leading unused bits counter byte, specify 'captureBitStringContents'.\n * To capture BIT STRING bytes, without the leading unused bits counter byte,\n * specify 'captureBitStringValue'.\n *\n * Objects in the validator may set a field 'optional' to true to indicate\n * that it isn't necessary to pass validation.\n *\n * @param obj the ASN.1 object to validate.\n * @param v the ASN.1 structure validator.\n * @param capture an optional map to capture values in.\n * @param errors an optional array for storing validation errors.\n *\n * @return true on success, false on failure.\n */\nasn1.validate = function(obj, v, capture, errors) {\n var rval = false;\n\n // ensure tag class and type are the same if specified\n if((obj.tagClass === v.tagClass || typeof(v.tagClass) === 'undefined') &&\n (obj.type === v.type || typeof(v.type) === 'undefined')) {\n // ensure constructed flag is the same if specified\n if(obj.constructed === v.constructed ||\n typeof(v.constructed) === 'undefined') {\n rval = true;\n\n // handle sub values\n if(v.value && forge.util.isArray(v.value)) {\n var j = 0;\n for(var i = 0; rval && i < v.value.length; ++i) {\n rval = v.value[i].optional || false;\n if(obj.value[j]) {\n rval = asn1.validate(obj.value[j], v.value[i], capture, errors);\n if(rval) {\n ++j;\n } else if(v.value[i].optional) {\n rval = true;\n }\n }\n if(!rval && errors) {\n errors.push(\n '[' + v.name + '] ' +\n 'Tag class \"' + v.tagClass + '\", type \"' +\n v.type + '\" expected value length \"' +\n v.value.length + '\", got \"' +\n obj.value.length + '\"');\n }\n }\n }\n\n if(rval && capture) {\n if(v.capture) {\n capture[v.capture] = obj.value;\n }\n if(v.captureAsn1) {\n capture[v.captureAsn1] = obj;\n }\n if(v.captureBitStringContents && 'bitStringContents' in obj) {\n capture[v.captureBitStringContents] = obj.bitStringContents;\n }\n if(v.captureBitStringValue && 'bitStringContents' in obj) {\n var value;\n if(obj.bitStringContents.length < 2) {\n capture[v.captureBitStringValue] = '';\n } else {\n // FIXME: support unused bits with data shifting\n var unused = obj.bitStringContents.charCodeAt(0);\n if(unused !== 0) {\n throw new Error(\n 'captureBitStringValue only supported for zero unused bits');\n }\n capture[v.captureBitStringValue] = obj.bitStringContents.slice(1);\n }\n }\n }\n } else if(errors) {\n errors.push(\n '[' + v.name + '] ' +\n 'Expected constructed \"' + v.constructed + '\", got \"' +\n obj.constructed + '\"');\n }\n } else if(errors) {\n if(obj.tagClass !== v.tagClass) {\n errors.push(\n '[' + v.name + '] ' +\n 'Expected tag class \"' + v.tagClass + '\", got \"' +\n obj.tagClass + '\"');\n }\n if(obj.type !== v.type) {\n errors.push(\n '[' + v.name + '] ' +\n 'Expected type \"' + v.type + '\", got \"' + obj.type + '\"');\n }\n }\n return rval;\n};\n\n// regex for testing for non-latin characters\nvar _nonLatinRegex = /[^\\\\u0000-\\\\u00ff]/;\n\n/**\n * Pretty prints an ASN.1 object to a string.\n *\n * @param obj the object to write out.\n * @param level the level in the tree.\n * @param indentation the indentation to use.\n *\n * @return the string.\n */\nasn1.prettyPrint = function(obj, level, indentation) {\n var rval = '';\n\n // set default level and indentation\n level = level || 0;\n indentation = indentation || 2;\n\n // start new line for deep levels\n if(level > 0) {\n rval += '\\n';\n }\n\n // create indent\n var indent = '';\n for(var i = 0; i < level * indentation; ++i) {\n indent += ' ';\n }\n\n // print class:type\n rval += indent + 'Tag: ';\n switch(obj.tagClass) {\n case asn1.Class.UNIVERSAL:\n rval += 'Universal:';\n break;\n case asn1.Class.APPLICATION:\n rval += 'Application:';\n break;\n case asn1.Class.CONTEXT_SPECIFIC:\n rval += 'Context-Specific:';\n break;\n case asn1.Class.PRIVATE:\n rval += 'Private:';\n break;\n }\n\n if(obj.tagClass === asn1.Class.UNIVERSAL) {\n rval += obj.type;\n\n // known types\n switch(obj.type) {\n case asn1.Type.NONE:\n rval += ' (None)';\n break;\n case asn1.Type.BOOLEAN:\n rval += ' (Boolean)';\n break;\n case asn1.Type.INTEGER:\n rval += ' (Integer)';\n break;\n case asn1.Type.BITSTRING:\n rval += ' (Bit string)';\n break;\n case asn1.Type.OCTETSTRING:\n rval += ' (Octet string)';\n break;\n case asn1.Type.NULL:\n rval += ' (Null)';\n break;\n case asn1.Type.OID:\n rval += ' (Object Identifier)';\n break;\n case asn1.Type.ODESC:\n rval += ' (Object Descriptor)';\n break;\n case asn1.Type.EXTERNAL:\n rval += ' (External or Instance of)';\n break;\n case asn1.Type.REAL:\n rval += ' (Real)';\n break;\n case asn1.Type.ENUMERATED:\n rval += ' (Enumerated)';\n break;\n case asn1.Type.EMBEDDED:\n rval += ' (Embedded PDV)';\n break;\n case asn1.Type.UTF8:\n rval += ' (UTF8)';\n break;\n case asn1.Type.ROID:\n rval += ' (Relative Object Identifier)';\n break;\n case asn1.Type.SEQUENCE:\n rval += ' (Sequence)';\n break;\n case asn1.Type.SET:\n rval += ' (Set)';\n break;\n case asn1.Type.PRINTABLESTRING:\n rval += ' (Printable String)';\n break;\n case asn1.Type.IA5String:\n rval += ' (IA5String (ASCII))';\n break;\n case asn1.Type.UTCTIME:\n rval += ' (UTC time)';\n break;\n case asn1.Type.GENERALIZEDTIME:\n rval += ' (Generalized time)';\n break;\n case asn1.Type.BMPSTRING:\n rval += ' (BMP String)';\n break;\n }\n } else {\n rval += obj.type;\n }\n\n rval += '\\n';\n rval += indent + 'Constructed: ' + obj.constructed + '\\n';\n\n if(obj.composed) {\n var subvalues = 0;\n var sub = '';\n for(var i = 0; i < obj.value.length; ++i) {\n if(obj.value[i] !== undefined) {\n subvalues += 1;\n sub += asn1.prettyPrint(obj.value[i], level + 1, indentation);\n if((i + 1) < obj.value.length) {\n sub += ',';\n }\n }\n }\n rval += indent + 'Sub values: ' + subvalues + sub;\n } else {\n rval += indent + 'Value: ';\n if(obj.type === asn1.Type.OID) {\n var oid = asn1.derToOid(obj.value);\n rval += oid;\n if(forge.pki && forge.pki.oids) {\n if(oid in forge.pki.oids) {\n rval += ' (' + forge.pki.oids[oid] + ') ';\n }\n }\n }\n if(obj.type === asn1.Type.INTEGER) {\n try {\n rval += asn1.derToInteger(obj.value);\n } catch(ex) {\n rval += '0x' + forge.util.bytesToHex(obj.value);\n }\n } else if(obj.type === asn1.Type.BITSTRING) {\n // TODO: shift bits as needed to display without padding\n if(obj.value.length > 1) {\n // remove unused bits field\n rval += '0x' + forge.util.bytesToHex(obj.value.slice(1));\n } else {\n rval += '(none)';\n }\n // show unused bit count\n if(obj.value.length > 0) {\n var unused = obj.value.charCodeAt(0);\n if(unused == 1) {\n rval += ' (1 unused bit shown)';\n } else if(unused > 1) {\n rval += ' (' + unused + ' unused bits shown)';\n }\n }\n } else if(obj.type === asn1.Type.OCTETSTRING) {\n if(!_nonLatinRegex.test(obj.value)) {\n rval += '(' + obj.value + ') ';\n }\n rval += '0x' + forge.util.bytesToHex(obj.value);\n } else if(obj.type === asn1.Type.UTF8) {\n rval += forge.util.decodeUtf8(obj.value);\n } else if(obj.type === asn1.Type.PRINTABLESTRING ||\n obj.type === asn1.Type.IA5String) {\n rval += obj.value;\n } else if(_nonLatinRegex.test(obj.value)) {\n rval += '0x' + forge.util.bytesToHex(obj.value);\n } else if(obj.value.length === 0) {\n rval += '[null]';\n } else {\n rval += obj.value;\n }\n }\n\n return rval;\n};\n","/**\n * Base-N/Base-X encoding/decoding functions.\n *\n * Original implementation from base-x:\n * https://github.com/cryptocoinjs/base-x\n *\n * Which is MIT licensed:\n *\n * The MIT License (MIT)\n *\n * Copyright base-x contributors (c) 2016\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nvar api = {};\nmodule.exports = api;\n\n// baseN alphabet indexes\nvar _reverseAlphabets = {};\n\n/**\n * BaseN-encodes a Uint8Array using the given alphabet.\n *\n * @param input the Uint8Array to encode.\n * @param maxline the maximum number of encoded characters per line to use,\n * defaults to none.\n *\n * @return the baseN-encoded output string.\n */\napi.encode = function(input, alphabet, maxline) {\n if(typeof alphabet !== 'string') {\n throw new TypeError('\"alphabet\" must be a string.');\n }\n if(maxline !== undefined && typeof maxline !== 'number') {\n throw new TypeError('\"maxline\" must be a number.');\n }\n\n var output = '';\n\n if(!(input instanceof Uint8Array)) {\n // assume forge byte buffer\n output = _encodeWithByteBuffer(input, alphabet);\n } else {\n var i = 0;\n var base = alphabet.length;\n var first = alphabet.charAt(0);\n var digits = [0];\n for(i = 0; i < input.length; ++i) {\n for(var j = 0, carry = input[i]; j < digits.length; ++j) {\n carry += digits[j] << 8;\n digits[j] = carry % base;\n carry = (carry / base) | 0;\n }\n\n while(carry > 0) {\n digits.push(carry % base);\n carry = (carry / base) | 0;\n }\n }\n\n // deal with leading zeros\n for(i = 0; input[i] === 0 && i < input.length - 1; ++i) {\n output += first;\n }\n // convert digits to a string\n for(i = digits.length - 1; i >= 0; --i) {\n output += alphabet[digits[i]];\n }\n }\n\n if(maxline) {\n var regex = new RegExp('.{1,' + maxline + '}', 'g');\n output = output.match(regex).join('\\r\\n');\n }\n\n return output;\n};\n\n/**\n * Decodes a baseN-encoded (using the given alphabet) string to a\n * Uint8Array.\n *\n * @param input the baseN-encoded input string.\n *\n * @return the Uint8Array.\n */\napi.decode = function(input, alphabet) {\n if(typeof input !== 'string') {\n throw new TypeError('\"input\" must be a string.');\n }\n if(typeof alphabet !== 'string') {\n throw new TypeError('\"alphabet\" must be a string.');\n }\n\n var table = _reverseAlphabets[alphabet];\n if(!table) {\n // compute reverse alphabet\n table = _reverseAlphabets[alphabet] = [];\n for(var i = 0; i < alphabet.length; ++i) {\n table[alphabet.charCodeAt(i)] = i;\n }\n }\n\n // remove whitespace characters\n input = input.replace(/\\s/g, '');\n\n var base = alphabet.length;\n var first = alphabet.charAt(0);\n var bytes = [0];\n for(var i = 0; i < input.length; i++) {\n var value = table[input.charCodeAt(i)];\n if(value === undefined) {\n return;\n }\n\n for(var j = 0, carry = value; j < bytes.length; ++j) {\n carry += bytes[j] * base;\n bytes[j] = carry & 0xff;\n carry >>= 8;\n }\n\n while(carry > 0) {\n bytes.push(carry & 0xff);\n carry >>= 8;\n }\n }\n\n // deal with leading zeros\n for(var k = 0; input[k] === first && k < input.length - 1; ++k) {\n bytes.push(0);\n }\n\n if(typeof Buffer !== 'undefined') {\n return Buffer.from(bytes.reverse());\n }\n\n return new Uint8Array(bytes.reverse());\n};\n\nfunction _encodeWithByteBuffer(input, alphabet) {\n var i = 0;\n var base = alphabet.length;\n var first = alphabet.charAt(0);\n var digits = [0];\n for(i = 0; i < input.length(); ++i) {\n for(var j = 0, carry = input.at(i); j < digits.length; ++j) {\n carry += digits[j] << 8;\n digits[j] = carry % base;\n carry = (carry / base) | 0;\n }\n\n while(carry > 0) {\n digits.push(carry % base);\n carry = (carry / base) | 0;\n }\n }\n\n var output = '';\n\n // deal with leading zeros\n for(i = 0; input.at(i) === 0 && i < input.length() - 1; ++i) {\n output += first;\n }\n // convert digits to a string\n for(i = digits.length - 1; i >= 0; --i) {\n output += alphabet[digits[i]];\n }\n\n return output;\n}\n","/**\n * Cipher base API.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\nmodule.exports = forge.cipher = forge.cipher || {};\n\n// registered algorithms\nforge.cipher.algorithms = forge.cipher.algorithms || {};\n\n/**\n * Creates a cipher object that can be used to encrypt data using the given\n * algorithm and key. The algorithm may be provided as a string value for a\n * previously registered algorithm or it may be given as a cipher algorithm\n * API object.\n *\n * @param algorithm the algorithm to use, either a string or an algorithm API\n * object.\n * @param key the key to use, as a binary-encoded string of bytes or a\n * byte buffer.\n *\n * @return the cipher.\n */\nforge.cipher.createCipher = function(algorithm, key) {\n var api = algorithm;\n if(typeof api === 'string') {\n api = forge.cipher.getAlgorithm(api);\n if(api) {\n api = api();\n }\n }\n if(!api) {\n throw new Error('Unsupported algorithm: ' + algorithm);\n }\n\n // assume block cipher\n return new forge.cipher.BlockCipher({\n algorithm: api,\n key: key,\n decrypt: false\n });\n};\n\n/**\n * Creates a decipher object that can be used to decrypt data using the given\n * algorithm and key. The algorithm may be provided as a string value for a\n * previously registered algorithm or it may be given as a cipher algorithm\n * API object.\n *\n * @param algorithm the algorithm to use, either a string or an algorithm API\n * object.\n * @param key the key to use, as a binary-encoded string of bytes or a\n * byte buffer.\n *\n * @return the cipher.\n */\nforge.cipher.createDecipher = function(algorithm, key) {\n var api = algorithm;\n if(typeof api === 'string') {\n api = forge.cipher.getAlgorithm(api);\n if(api) {\n api = api();\n }\n }\n if(!api) {\n throw new Error('Unsupported algorithm: ' + algorithm);\n }\n\n // assume block cipher\n return new forge.cipher.BlockCipher({\n algorithm: api,\n key: key,\n decrypt: true\n });\n};\n\n/**\n * Registers an algorithm by name. If the name was already registered, the\n * algorithm API object will be overwritten.\n *\n * @param name the name of the algorithm.\n * @param algorithm the algorithm API object.\n */\nforge.cipher.registerAlgorithm = function(name, algorithm) {\n name = name.toUpperCase();\n forge.cipher.algorithms[name] = algorithm;\n};\n\n/**\n * Gets a registered algorithm by name.\n *\n * @param name the name of the algorithm.\n *\n * @return the algorithm, if found, null if not.\n */\nforge.cipher.getAlgorithm = function(name) {\n name = name.toUpperCase();\n if(name in forge.cipher.algorithms) {\n return forge.cipher.algorithms[name];\n }\n return null;\n};\n\nvar BlockCipher = forge.cipher.BlockCipher = function(options) {\n this.algorithm = options.algorithm;\n this.mode = this.algorithm.mode;\n this.blockSize = this.mode.blockSize;\n this._finish = false;\n this._input = null;\n this.output = null;\n this._op = options.decrypt ? this.mode.decrypt : this.mode.encrypt;\n this._decrypt = options.decrypt;\n this.algorithm.initialize(options);\n};\n\n/**\n * Starts or restarts the encryption or decryption process, whichever\n * was previously configured.\n *\n * For non-GCM mode, the IV may be a binary-encoded string of bytes, an array\n * of bytes, a byte buffer, or an array of 32-bit integers. If the IV is in\n * bytes, then it must be Nb (16) bytes in length. If the IV is given in as\n * 32-bit integers, then it must be 4 integers long.\n *\n * Note: an IV is not required or used in ECB mode.\n *\n * For GCM-mode, the IV must be given as a binary-encoded string of bytes or\n * a byte buffer. The number of bytes should be 12 (96 bits) as recommended\n * by NIST SP-800-38D but another length may be given.\n *\n * @param options the options to use:\n * iv the initialization vector to use as a binary-encoded string of\n * bytes, null to reuse the last ciphered block from a previous\n * update() (this \"residue\" method is for legacy support only).\n * additionalData additional authentication data as a binary-encoded\n * string of bytes, for 'GCM' mode, (default: none).\n * tagLength desired length of authentication tag, in bits, for\n * 'GCM' mode (0-128, default: 128).\n * tag the authentication tag to check if decrypting, as a\n * binary-encoded string of bytes.\n * output the output the buffer to write to, null to create one.\n */\nBlockCipher.prototype.start = function(options) {\n options = options || {};\n var opts = {};\n for(var key in options) {\n opts[key] = options[key];\n }\n opts.decrypt = this._decrypt;\n this._finish = false;\n this._input = forge.util.createBuffer();\n this.output = options.output || forge.util.createBuffer();\n this.mode.start(opts);\n};\n\n/**\n * Updates the next block according to the cipher mode.\n *\n * @param input the buffer to read from.\n */\nBlockCipher.prototype.update = function(input) {\n if(input) {\n // input given, so empty it into the input buffer\n this._input.putBuffer(input);\n }\n\n // do cipher operation until it needs more input and not finished\n while(!this._op.call(this.mode, this._input, this.output, this._finish) &&\n !this._finish) {}\n\n // free consumed memory from input buffer\n this._input.compact();\n};\n\n/**\n * Finishes encrypting or decrypting.\n *\n * @param pad a padding function to use in CBC mode, null for default,\n * signature(blockSize, buffer, decrypt).\n *\n * @return true if successful, false on error.\n */\nBlockCipher.prototype.finish = function(pad) {\n // backwards-compatibility w/deprecated padding API\n // Note: will overwrite padding functions even after another start() call\n if(pad && (this.mode.name === 'ECB' || this.mode.name === 'CBC')) {\n this.mode.pad = function(input) {\n return pad(this.blockSize, input, false);\n };\n this.mode.unpad = function(output) {\n return pad(this.blockSize, output, true);\n };\n }\n\n // build options for padding and afterFinish functions\n var options = {};\n options.decrypt = this._decrypt;\n\n // get # of bytes that won't fill a block\n options.overflow = this._input.length() % this.blockSize;\n\n if(!this._decrypt && this.mode.pad) {\n if(!this.mode.pad(this._input, options)) {\n return false;\n }\n }\n\n // do final update\n this._finish = true;\n this.update();\n\n if(this._decrypt && this.mode.unpad) {\n if(!this.mode.unpad(this.output, options)) {\n return false;\n }\n }\n\n if(this.mode.afterFinish) {\n if(!this.mode.afterFinish(this.output, options)) {\n return false;\n }\n }\n\n return true;\n};\n","/**\n * Supported cipher modes.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\nforge.cipher = forge.cipher || {};\n\n// supported cipher modes\nvar modes = module.exports = forge.cipher.modes = forge.cipher.modes || {};\n\n/** Electronic codebook (ECB) (Don't use this; it's not secure) **/\n\nmodes.ecb = function(options) {\n options = options || {};\n this.name = 'ECB';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = new Array(this._ints);\n this._outBlock = new Array(this._ints);\n};\n\nmodes.ecb.prototype.start = function(options) {};\n\nmodes.ecb.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n if(input.length() < this.blockSize && !(finish && input.length() > 0)) {\n return true;\n }\n\n // get next block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32();\n }\n\n // encrypt block\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // write output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i]);\n }\n};\n\nmodes.ecb.prototype.decrypt = function(input, output, finish) {\n // not enough input to decrypt\n if(input.length() < this.blockSize && !(finish && input.length() > 0)) {\n return true;\n }\n\n // get next block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32();\n }\n\n // decrypt block\n this.cipher.decrypt(this._inBlock, this._outBlock);\n\n // write output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i]);\n }\n};\n\nmodes.ecb.prototype.pad = function(input, options) {\n // add PKCS#7 padding to block (each pad byte is the\n // value of the number of pad bytes)\n var padding = (input.length() === this.blockSize ?\n this.blockSize : (this.blockSize - input.length()));\n input.fillWithByte(padding, padding);\n return true;\n};\n\nmodes.ecb.prototype.unpad = function(output, options) {\n // check for error: input data not a multiple of blockSize\n if(options.overflow > 0) {\n return false;\n }\n\n // ensure padding byte count is valid\n var len = output.length();\n var count = output.at(len - 1);\n if(count > (this.blockSize << 2)) {\n return false;\n }\n\n // trim off padding bytes\n output.truncate(count);\n return true;\n};\n\n/** Cipher-block Chaining (CBC) **/\n\nmodes.cbc = function(options) {\n options = options || {};\n this.name = 'CBC';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = new Array(this._ints);\n this._outBlock = new Array(this._ints);\n};\n\nmodes.cbc.prototype.start = function(options) {\n // Note: legacy support for using IV residue (has security flaws)\n // if IV is null, reuse block from previous processing\n if(options.iv === null) {\n // must have a previous block\n if(!this._prev) {\n throw new Error('Invalid IV parameter.');\n }\n this._iv = this._prev.slice(0);\n } else if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n } else {\n // save IV as \"previous\" block\n this._iv = transformIV(options.iv, this.blockSize);\n this._prev = this._iv.slice(0);\n }\n};\n\nmodes.cbc.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n if(input.length() < this.blockSize && !(finish && input.length() > 0)) {\n return true;\n }\n\n // get next block\n // CBC XOR's IV (or previous block) with plaintext\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = this._prev[i] ^ input.getInt32();\n }\n\n // encrypt block\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // write output, save previous block\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i]);\n }\n this._prev = this._outBlock;\n};\n\nmodes.cbc.prototype.decrypt = function(input, output, finish) {\n // not enough input to decrypt\n if(input.length() < this.blockSize && !(finish && input.length() > 0)) {\n return true;\n }\n\n // get next block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32();\n }\n\n // decrypt block\n this.cipher.decrypt(this._inBlock, this._outBlock);\n\n // write output, save previous ciphered block\n // CBC XOR's IV (or previous block) with ciphertext\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._prev[i] ^ this._outBlock[i]);\n }\n this._prev = this._inBlock.slice(0);\n};\n\nmodes.cbc.prototype.pad = function(input, options) {\n // add PKCS#7 padding to block (each pad byte is the\n // value of the number of pad bytes)\n var padding = (input.length() === this.blockSize ?\n this.blockSize : (this.blockSize - input.length()));\n input.fillWithByte(padding, padding);\n return true;\n};\n\nmodes.cbc.prototype.unpad = function(output, options) {\n // check for error: input data not a multiple of blockSize\n if(options.overflow > 0) {\n return false;\n }\n\n // ensure padding byte count is valid\n var len = output.length();\n var count = output.at(len - 1);\n if(count > (this.blockSize << 2)) {\n return false;\n }\n\n // trim off padding bytes\n output.truncate(count);\n return true;\n};\n\n/** Cipher feedback (CFB) **/\n\nmodes.cfb = function(options) {\n options = options || {};\n this.name = 'CFB';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = null;\n this._outBlock = new Array(this._ints);\n this._partialBlock = new Array(this._ints);\n this._partialOutput = forge.util.createBuffer();\n this._partialBytes = 0;\n};\n\nmodes.cfb.prototype.start = function(options) {\n if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n }\n // use IV as first input\n this._iv = transformIV(options.iv, this.blockSize);\n this._inBlock = this._iv.slice(0);\n this._partialBytes = 0;\n};\n\nmodes.cfb.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n var inputLength = input.length();\n if(inputLength === 0) {\n return true;\n }\n\n // encrypt block\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output, write input as output\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32() ^ this._outBlock[i];\n output.putInt32(this._inBlock[i]);\n }\n return;\n }\n\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output, write input as partial output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialBlock[i] = input.getInt32() ^ this._outBlock[i];\n this._partialOutput.putInt32(this._partialBlock[i]);\n }\n\n if(partialBytes > 0) {\n // block still incomplete, restore input buffer\n input.read -= this.blockSize;\n } else {\n // block complete, update input block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = this._partialBlock[i];\n }\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n};\n\nmodes.cfb.prototype.decrypt = function(input, output, finish) {\n // not enough input to decrypt\n var inputLength = input.length();\n if(inputLength === 0) {\n return true;\n }\n\n // encrypt block (CFB always uses encryption mode)\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output, write input as output\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32();\n output.putInt32(this._inBlock[i] ^ this._outBlock[i]);\n }\n return;\n }\n\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output, write input as partial output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialBlock[i] = input.getInt32();\n this._partialOutput.putInt32(this._partialBlock[i] ^ this._outBlock[i]);\n }\n\n if(partialBytes > 0) {\n // block still incomplete, restore input buffer\n input.read -= this.blockSize;\n } else {\n // block complete, update input block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = this._partialBlock[i];\n }\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n};\n\n/** Output feedback (OFB) **/\n\nmodes.ofb = function(options) {\n options = options || {};\n this.name = 'OFB';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = null;\n this._outBlock = new Array(this._ints);\n this._partialOutput = forge.util.createBuffer();\n this._partialBytes = 0;\n};\n\nmodes.ofb.prototype.start = function(options) {\n if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n }\n // use IV as first input\n this._iv = transformIV(options.iv, this.blockSize);\n this._inBlock = this._iv.slice(0);\n this._partialBytes = 0;\n};\n\nmodes.ofb.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n var inputLength = input.length();\n if(input.length() === 0) {\n return true;\n }\n\n // encrypt block (OFB always uses encryption mode)\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output and update next input\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(input.getInt32() ^ this._outBlock[i]);\n this._inBlock[i] = this._outBlock[i];\n }\n return;\n }\n\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);\n }\n\n if(partialBytes > 0) {\n // block still incomplete, restore input buffer\n input.read -= this.blockSize;\n } else {\n // block complete, update input block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = this._outBlock[i];\n }\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n};\n\nmodes.ofb.prototype.decrypt = modes.ofb.prototype.encrypt;\n\n/** Counter (CTR) **/\n\nmodes.ctr = function(options) {\n options = options || {};\n this.name = 'CTR';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = null;\n this._outBlock = new Array(this._ints);\n this._partialOutput = forge.util.createBuffer();\n this._partialBytes = 0;\n};\n\nmodes.ctr.prototype.start = function(options) {\n if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n }\n // use IV as first input\n this._iv = transformIV(options.iv, this.blockSize);\n this._inBlock = this._iv.slice(0);\n this._partialBytes = 0;\n};\n\nmodes.ctr.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n var inputLength = input.length();\n if(inputLength === 0) {\n return true;\n }\n\n // encrypt block (CTR always uses encryption mode)\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(input.getInt32() ^ this._outBlock[i]);\n }\n } else {\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);\n }\n\n if(partialBytes > 0) {\n // block still incomplete, restore input buffer\n input.read -= this.blockSize;\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n }\n\n // block complete, increment counter (input block)\n inc32(this._inBlock);\n};\n\nmodes.ctr.prototype.decrypt = modes.ctr.prototype.encrypt;\n\n/** Galois/Counter Mode (GCM) **/\n\nmodes.gcm = function(options) {\n options = options || {};\n this.name = 'GCM';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = new Array(this._ints);\n this._outBlock = new Array(this._ints);\n this._partialOutput = forge.util.createBuffer();\n this._partialBytes = 0;\n\n // R is actually this value concatenated with 120 more zero bits, but\n // we only XOR against R so the other zeros have no effect -- we just\n // apply this value to the first integer in a block\n this._R = 0xE1000000;\n};\n\nmodes.gcm.prototype.start = function(options) {\n if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n }\n // ensure IV is a byte buffer\n var iv = forge.util.createBuffer(options.iv);\n\n // no ciphered data processed yet\n this._cipherLength = 0;\n\n // default additional data is none\n var additionalData;\n if('additionalData' in options) {\n additionalData = forge.util.createBuffer(options.additionalData);\n } else {\n additionalData = forge.util.createBuffer();\n }\n\n // default tag length is 128 bits\n if('tagLength' in options) {\n this._tagLength = options.tagLength;\n } else {\n this._tagLength = 128;\n }\n\n // if tag is given, ensure tag matches tag length\n this._tag = null;\n if(options.decrypt) {\n // save tag to check later\n this._tag = forge.util.createBuffer(options.tag).getBytes();\n if(this._tag.length !== (this._tagLength / 8)) {\n throw new Error('Authentication tag does not match tag length.');\n }\n }\n\n // create tmp storage for hash calculation\n this._hashBlock = new Array(this._ints);\n\n // no tag generated yet\n this.tag = null;\n\n // generate hash subkey\n // (apply block cipher to \"zero\" block)\n this._hashSubkey = new Array(this._ints);\n this.cipher.encrypt([0, 0, 0, 0], this._hashSubkey);\n\n // generate table M\n // use 4-bit tables (32 component decomposition of a 16 byte value)\n // 8-bit tables take more space and are known to have security\n // vulnerabilities (in native implementations)\n this.componentBits = 4;\n this._m = this.generateHashTable(this._hashSubkey, this.componentBits);\n\n // Note: support IV length different from 96 bits? (only supporting\n // 96 bits is recommended by NIST SP-800-38D)\n // generate J_0\n var ivLength = iv.length();\n if(ivLength === 12) {\n // 96-bit IV\n this._j0 = [iv.getInt32(), iv.getInt32(), iv.getInt32(), 1];\n } else {\n // IV is NOT 96-bits\n this._j0 = [0, 0, 0, 0];\n while(iv.length() > 0) {\n this._j0 = this.ghash(\n this._hashSubkey, this._j0,\n [iv.getInt32(), iv.getInt32(), iv.getInt32(), iv.getInt32()]);\n }\n this._j0 = this.ghash(\n this._hashSubkey, this._j0, [0, 0].concat(from64To32(ivLength * 8)));\n }\n\n // generate ICB (initial counter block)\n this._inBlock = this._j0.slice(0);\n inc32(this._inBlock);\n this._partialBytes = 0;\n\n // consume authentication data\n additionalData = forge.util.createBuffer(additionalData);\n // save additional data length as a BE 64-bit number\n this._aDataLength = from64To32(additionalData.length() * 8);\n // pad additional data to 128 bit (16 byte) block size\n var overflow = additionalData.length() % this.blockSize;\n if(overflow) {\n additionalData.fillWithByte(0, this.blockSize - overflow);\n }\n this._s = [0, 0, 0, 0];\n while(additionalData.length() > 0) {\n this._s = this.ghash(this._hashSubkey, this._s, [\n additionalData.getInt32(),\n additionalData.getInt32(),\n additionalData.getInt32(),\n additionalData.getInt32()\n ]);\n }\n};\n\nmodes.gcm.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n var inputLength = input.length();\n if(inputLength === 0) {\n return true;\n }\n\n // encrypt block\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i] ^= input.getInt32());\n }\n this._cipherLength += this.blockSize;\n } else {\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);\n }\n\n if(partialBytes <= 0 || finish) {\n // handle overflow prior to hashing\n if(finish) {\n // get block overflow\n var overflow = inputLength % this.blockSize;\n this._cipherLength += overflow;\n // truncate for hash function\n this._partialOutput.truncate(this.blockSize - overflow);\n } else {\n this._cipherLength += this.blockSize;\n }\n\n // get output block for hashing\n for(var i = 0; i < this._ints; ++i) {\n this._outBlock[i] = this._partialOutput.getInt32();\n }\n this._partialOutput.read -= this.blockSize;\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n // block still incomplete, restore input buffer, get partial output,\n // and return early\n input.read -= this.blockSize;\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n }\n\n // update hash block S\n this._s = this.ghash(this._hashSubkey, this._s, this._outBlock);\n\n // increment counter (input block)\n inc32(this._inBlock);\n};\n\nmodes.gcm.prototype.decrypt = function(input, output, finish) {\n // not enough input to decrypt\n var inputLength = input.length();\n if(inputLength < this.blockSize && !(finish && inputLength > 0)) {\n return true;\n }\n\n // encrypt block (GCM always uses encryption mode)\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // increment counter (input block)\n inc32(this._inBlock);\n\n // update hash block S\n this._hashBlock[0] = input.getInt32();\n this._hashBlock[1] = input.getInt32();\n this._hashBlock[2] = input.getInt32();\n this._hashBlock[3] = input.getInt32();\n this._s = this.ghash(this._hashSubkey, this._s, this._hashBlock);\n\n // XOR hash input with output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i] ^ this._hashBlock[i]);\n }\n\n // increment cipher data length\n if(inputLength < this.blockSize) {\n this._cipherLength += inputLength % this.blockSize;\n } else {\n this._cipherLength += this.blockSize;\n }\n};\n\nmodes.gcm.prototype.afterFinish = function(output, options) {\n var rval = true;\n\n // handle overflow\n if(options.decrypt && options.overflow) {\n output.truncate(this.blockSize - options.overflow);\n }\n\n // handle authentication tag\n this.tag = forge.util.createBuffer();\n\n // concatenate additional data length with cipher length\n var lengths = this._aDataLength.concat(from64To32(this._cipherLength * 8));\n\n // include lengths in hash\n this._s = this.ghash(this._hashSubkey, this._s, lengths);\n\n // do GCTR(J_0, S)\n var tag = [];\n this.cipher.encrypt(this._j0, tag);\n for(var i = 0; i < this._ints; ++i) {\n this.tag.putInt32(this._s[i] ^ tag[i]);\n }\n\n // trim tag to length\n this.tag.truncate(this.tag.length() % (this._tagLength / 8));\n\n // check authentication tag\n if(options.decrypt && this.tag.bytes() !== this._tag) {\n rval = false;\n }\n\n return rval;\n};\n\n/**\n * See NIST SP-800-38D 6.3 (Algorithm 1). This function performs Galois\n * field multiplication. The field, GF(2^128), is defined by the polynomial:\n *\n * x^128 + x^7 + x^2 + x + 1\n *\n * Which is represented in little-endian binary form as: 11100001 (0xe1). When\n * the value of a coefficient is 1, a bit is set. The value R, is the\n * concatenation of this value and 120 zero bits, yielding a 128-bit value\n * which matches the block size.\n *\n * This function will multiply two elements (vectors of bytes), X and Y, in\n * the field GF(2^128). The result is initialized to zero. For each bit of\n * X (out of 128), x_i, if x_i is set, then the result is multiplied (XOR'd)\n * by the current value of Y. For each bit, the value of Y will be raised by\n * a power of x (multiplied by the polynomial x). This can be achieved by\n * shifting Y once to the right. If the current value of Y, prior to being\n * multiplied by x, has 0 as its LSB, then it is a 127th degree polynomial.\n * Otherwise, we must divide by R after shifting to find the remainder.\n *\n * @param x the first block to multiply by the second.\n * @param y the second block to multiply by the first.\n *\n * @return the block result of the multiplication.\n */\nmodes.gcm.prototype.multiply = function(x, y) {\n var z_i = [0, 0, 0, 0];\n var v_i = y.slice(0);\n\n // calculate Z_128 (block has 128 bits)\n for(var i = 0; i < 128; ++i) {\n // if x_i is 0, Z_{i+1} = Z_i (unchanged)\n // else Z_{i+1} = Z_i ^ V_i\n // get x_i by finding 32-bit int position, then left shift 1 by remainder\n var x_i = x[(i / 32) | 0] & (1 << (31 - i % 32));\n if(x_i) {\n z_i[0] ^= v_i[0];\n z_i[1] ^= v_i[1];\n z_i[2] ^= v_i[2];\n z_i[3] ^= v_i[3];\n }\n\n // if LSB(V_i) is 1, V_i = V_i >> 1\n // else V_i = (V_i >> 1) ^ R\n this.pow(v_i, v_i);\n }\n\n return z_i;\n};\n\nmodes.gcm.prototype.pow = function(x, out) {\n // if LSB(x) is 1, x = x >>> 1\n // else x = (x >>> 1) ^ R\n var lsb = x[3] & 1;\n\n // always do x >>> 1:\n // starting with the rightmost integer, shift each integer to the right\n // one bit, pulling in the bit from the integer to the left as its top\n // most bit (do this for the last 3 integers)\n for(var i = 3; i > 0; --i) {\n out[i] = (x[i] >>> 1) | ((x[i - 1] & 1) << 31);\n }\n // shift the first integer normally\n out[0] = x[0] >>> 1;\n\n // if lsb was not set, then polynomial had a degree of 127 and doesn't\n // need to divided; otherwise, XOR with R to find the remainder; we only\n // need to XOR the first integer since R technically ends w/120 zero bits\n if(lsb) {\n out[0] ^= this._R;\n }\n};\n\nmodes.gcm.prototype.tableMultiply = function(x) {\n // assumes 4-bit tables are used\n var z = [0, 0, 0, 0];\n for(var i = 0; i < 32; ++i) {\n var idx = (i / 8) | 0;\n var x_i = (x[idx] >>> ((7 - (i % 8)) * 4)) & 0xF;\n var ah = this._m[i][x_i];\n z[0] ^= ah[0];\n z[1] ^= ah[1];\n z[2] ^= ah[2];\n z[3] ^= ah[3];\n }\n return z;\n};\n\n/**\n * A continuing version of the GHASH algorithm that operates on a single\n * block. The hash block, last hash value (Ym) and the new block to hash\n * are given.\n *\n * @param h the hash block.\n * @param y the previous value for Ym, use [0, 0, 0, 0] for a new hash.\n * @param x the block to hash.\n *\n * @return the hashed value (Ym).\n */\nmodes.gcm.prototype.ghash = function(h, y, x) {\n y[0] ^= x[0];\n y[1] ^= x[1];\n y[2] ^= x[2];\n y[3] ^= x[3];\n return this.tableMultiply(y);\n //return this.multiply(y, h);\n};\n\n/**\n * Precomputes a table for multiplying against the hash subkey. This\n * mechanism provides a substantial speed increase over multiplication\n * performed without a table. The table-based multiplication this table is\n * for solves X * H by multiplying each component of X by H and then\n * composing the results together using XOR.\n *\n * This function can be used to generate tables with different bit sizes\n * for the components, however, this implementation assumes there are\n * 32 components of X (which is a 16 byte vector), therefore each component\n * takes 4-bits (so the table is constructed with bits=4).\n *\n * @param h the hash subkey.\n * @param bits the bit size for a component.\n */\nmodes.gcm.prototype.generateHashTable = function(h, bits) {\n // TODO: There are further optimizations that would use only the\n // first table M_0 (or some variant) along with a remainder table;\n // this can be explored in the future\n var multiplier = 8 / bits;\n var perInt = 4 * multiplier;\n var size = 16 * multiplier;\n var m = new Array(size);\n for(var i = 0; i < size; ++i) {\n var tmp = [0, 0, 0, 0];\n var idx = (i / perInt) | 0;\n var shft = ((perInt - 1 - (i % perInt)) * bits);\n tmp[idx] = (1 << (bits - 1)) << shft;\n m[i] = this.generateSubHashTable(this.multiply(tmp, h), bits);\n }\n return m;\n};\n\n/**\n * Generates a table for multiplying against the hash subkey for one\n * particular component (out of all possible component values).\n *\n * @param mid the pre-multiplied value for the middle key of the table.\n * @param bits the bit size for a component.\n */\nmodes.gcm.prototype.generateSubHashTable = function(mid, bits) {\n // compute the table quickly by minimizing the number of\n // POW operations -- they only need to be performed for powers of 2,\n // all other entries can be composed from those powers using XOR\n var size = 1 << bits;\n var half = size >>> 1;\n var m = new Array(size);\n m[half] = mid.slice(0);\n var i = half >>> 1;\n while(i > 0) {\n // raise m0[2 * i] and store in m0[i]\n this.pow(m[2 * i], m[i] = []);\n i >>= 1;\n }\n i = 2;\n while(i < half) {\n for(var j = 1; j < i; ++j) {\n var m_i = m[i];\n var m_j = m[j];\n m[i + j] = [\n m_i[0] ^ m_j[0],\n m_i[1] ^ m_j[1],\n m_i[2] ^ m_j[2],\n m_i[3] ^ m_j[3]\n ];\n }\n i *= 2;\n }\n m[0] = [0, 0, 0, 0];\n /* Note: We could avoid storing these by doing composition during multiply\n calculate top half using composition by speed is preferred. */\n for(i = half + 1; i < size; ++i) {\n var c = m[i ^ half];\n m[i] = [mid[0] ^ c[0], mid[1] ^ c[1], mid[2] ^ c[2], mid[3] ^ c[3]];\n }\n return m;\n};\n\n/** Utility functions */\n\nfunction transformIV(iv, blockSize) {\n if(typeof iv === 'string') {\n // convert iv string into byte buffer\n iv = forge.util.createBuffer(iv);\n }\n\n if(forge.util.isArray(iv) && iv.length > 4) {\n // convert iv byte array into byte buffer\n var tmp = iv;\n iv = forge.util.createBuffer();\n for(var i = 0; i < tmp.length; ++i) {\n iv.putByte(tmp[i]);\n }\n }\n\n if(iv.length() < blockSize) {\n throw new Error(\n 'Invalid IV length; got ' + iv.length() +\n ' bytes and expected ' + blockSize + ' bytes.');\n }\n\n if(!forge.util.isArray(iv)) {\n // convert iv byte buffer into 32-bit integer array\n var ints = [];\n var blocks = blockSize / 4;\n for(var i = 0; i < blocks; ++i) {\n ints.push(iv.getInt32());\n }\n iv = ints;\n }\n\n return iv;\n}\n\nfunction inc32(block) {\n // increment last 32 bits of block only\n block[block.length - 1] = (block[block.length - 1] + 1) & 0xFFFFFFFF;\n}\n\nfunction from64To32(num) {\n // convert 64-bit number to two BE Int32s\n return [(num / 0x100000000) | 0, num & 0xFFFFFFFF];\n}\n","/**\n * Debugging support for web applications.\n *\n * @author David I. Lehn \n *\n * Copyright 2008-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\n\n/* DEBUG API */\nmodule.exports = forge.debug = forge.debug || {};\n\n// Private storage for debugging.\n// Useful to expose data that is otherwise unviewable behind closures.\n// NOTE: remember that this can hold references to data and cause leaks!\n// format is \"forge._debug.. = data\"\n// Example:\n// (function() {\n// var cat = 'forge.test.Test'; // debugging category\n// var sState = {...}; // local state\n// forge.debug.set(cat, 'sState', sState);\n// })();\nforge.debug.storage = {};\n\n/**\n * Gets debug data. Omit name for all cat data Omit name and cat for\n * all data.\n *\n * @param cat name of debugging category.\n * @param name name of data to get (optional).\n * @return object with requested debug data or undefined.\n */\nforge.debug.get = function(cat, name) {\n var rval;\n if(typeof(cat) === 'undefined') {\n rval = forge.debug.storage;\n } else if(cat in forge.debug.storage) {\n if(typeof(name) === 'undefined') {\n rval = forge.debug.storage[cat];\n } else {\n rval = forge.debug.storage[cat][name];\n }\n }\n return rval;\n};\n\n/**\n * Sets debug data.\n *\n * @param cat name of debugging category.\n * @param name name of data to set.\n * @param data data to set.\n */\nforge.debug.set = function(cat, name, data) {\n if(!(cat in forge.debug.storage)) {\n forge.debug.storage[cat] = {};\n }\n forge.debug.storage[cat][name] = data;\n};\n\n/**\n * Clears debug data. Omit name for all cat data. Omit name and cat for\n * all data.\n *\n * @param cat name of debugging category.\n * @param name name of data to clear or omit to clear entire category.\n */\nforge.debug.clear = function(cat, name) {\n if(typeof(cat) === 'undefined') {\n forge.debug.storage = {};\n } else if(cat in forge.debug.storage) {\n if(typeof(name) === 'undefined') {\n delete forge.debug.storage[cat];\n } else {\n delete forge.debug.storage[cat][name];\n }\n }\n};\n","/**\n * DES (Data Encryption Standard) implementation.\n *\n * This implementation supports DES as well as 3DES-EDE in ECB and CBC mode.\n * It is based on the BSD-licensed implementation by Paul Tero:\n *\n * Paul Tero, July 2001\n * http://www.tero.co.uk/des/\n *\n * Optimised for performance with large blocks by\n * Michael Hayworth, November 2001\n * http://www.netdealing.com\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * @author Stefan Siegl\n * @author Dave Longley\n *\n * Copyright (c) 2012 Stefan Siegl \n * Copyright (c) 2012-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./cipher');\nrequire('./cipherModes');\nrequire('./util');\n\n/* DES API */\nmodule.exports = forge.des = forge.des || {};\n\n/**\n * Deprecated. Instead, use:\n *\n * var cipher = forge.cipher.createCipher('DES-', key);\n * cipher.start({iv: iv});\n *\n * Creates an DES cipher object to encrypt data using the given symmetric key.\n * The output will be stored in the 'output' member of the returned cipher.\n *\n * The key and iv may be given as binary-encoded strings of bytes or\n * byte buffers.\n *\n * @param key the symmetric key to use (64 or 192 bits).\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n * @param mode the cipher mode to use (default: 'CBC' if IV is\n * given, 'ECB' if null).\n *\n * @return the cipher.\n */\nforge.des.startEncrypting = function(key, iv, output, mode) {\n var cipher = _createCipher({\n key: key,\n output: output,\n decrypt: false,\n mode: mode || (iv === null ? 'ECB' : 'CBC')\n });\n cipher.start(iv);\n return cipher;\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var cipher = forge.cipher.createCipher('DES-', key);\n *\n * Creates an DES cipher object to encrypt data using the given symmetric key.\n *\n * The key may be given as a binary-encoded string of bytes or a byte buffer.\n *\n * @param key the symmetric key to use (64 or 192 bits).\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.des.createEncryptionCipher = function(key, mode) {\n return _createCipher({\n key: key,\n output: null,\n decrypt: false,\n mode: mode\n });\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var decipher = forge.cipher.createDecipher('DES-', key);\n * decipher.start({iv: iv});\n *\n * Creates an DES cipher object to decrypt data using the given symmetric key.\n * The output will be stored in the 'output' member of the returned cipher.\n *\n * The key and iv may be given as binary-encoded strings of bytes or\n * byte buffers.\n *\n * @param key the symmetric key to use (64 or 192 bits).\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n * @param mode the cipher mode to use (default: 'CBC' if IV is\n * given, 'ECB' if null).\n *\n * @return the cipher.\n */\nforge.des.startDecrypting = function(key, iv, output, mode) {\n var cipher = _createCipher({\n key: key,\n output: output,\n decrypt: true,\n mode: mode || (iv === null ? 'ECB' : 'CBC')\n });\n cipher.start(iv);\n return cipher;\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var decipher = forge.cipher.createDecipher('DES-', key);\n *\n * Creates an DES cipher object to decrypt data using the given symmetric key.\n *\n * The key may be given as a binary-encoded string of bytes or a byte buffer.\n *\n * @param key the symmetric key to use (64 or 192 bits).\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.des.createDecryptionCipher = function(key, mode) {\n return _createCipher({\n key: key,\n output: null,\n decrypt: true,\n mode: mode\n });\n};\n\n/**\n * Creates a new DES cipher algorithm object.\n *\n * @param name the name of the algorithm.\n * @param mode the mode factory function.\n *\n * @return the DES algorithm object.\n */\nforge.des.Algorithm = function(name, mode) {\n var self = this;\n self.name = name;\n self.mode = new mode({\n blockSize: 8,\n cipher: {\n encrypt: function(inBlock, outBlock) {\n return _updateBlock(self._keys, inBlock, outBlock, false);\n },\n decrypt: function(inBlock, outBlock) {\n return _updateBlock(self._keys, inBlock, outBlock, true);\n }\n }\n });\n self._init = false;\n};\n\n/**\n * Initializes this DES algorithm by expanding its key.\n *\n * @param options the options to use.\n * key the key to use with this algorithm.\n * decrypt true if the algorithm should be initialized for decryption,\n * false for encryption.\n */\nforge.des.Algorithm.prototype.initialize = function(options) {\n if(this._init) {\n return;\n }\n\n var key = forge.util.createBuffer(options.key);\n if(this.name.indexOf('3DES') === 0) {\n if(key.length() !== 24) {\n throw new Error('Invalid Triple-DES key size: ' + key.length() * 8);\n }\n }\n\n // do key expansion to 16 or 48 subkeys (single or triple DES)\n this._keys = _createKeys(key);\n this._init = true;\n};\n\n/** Register DES algorithms **/\n\nregisterAlgorithm('DES-ECB', forge.cipher.modes.ecb);\nregisterAlgorithm('DES-CBC', forge.cipher.modes.cbc);\nregisterAlgorithm('DES-CFB', forge.cipher.modes.cfb);\nregisterAlgorithm('DES-OFB', forge.cipher.modes.ofb);\nregisterAlgorithm('DES-CTR', forge.cipher.modes.ctr);\n\nregisterAlgorithm('3DES-ECB', forge.cipher.modes.ecb);\nregisterAlgorithm('3DES-CBC', forge.cipher.modes.cbc);\nregisterAlgorithm('3DES-CFB', forge.cipher.modes.cfb);\nregisterAlgorithm('3DES-OFB', forge.cipher.modes.ofb);\nregisterAlgorithm('3DES-CTR', forge.cipher.modes.ctr);\n\nfunction registerAlgorithm(name, mode) {\n var factory = function() {\n return new forge.des.Algorithm(name, mode);\n };\n forge.cipher.registerAlgorithm(name, factory);\n}\n\n/** DES implementation **/\n\nvar spfunction1 = [0x1010400,0,0x10000,0x1010404,0x1010004,0x10404,0x4,0x10000,0x400,0x1010400,0x1010404,0x400,0x1000404,0x1010004,0x1000000,0x4,0x404,0x1000400,0x1000400,0x10400,0x10400,0x1010000,0x1010000,0x1000404,0x10004,0x1000004,0x1000004,0x10004,0,0x404,0x10404,0x1000000,0x10000,0x1010404,0x4,0x1010000,0x1010400,0x1000000,0x1000000,0x400,0x1010004,0x10000,0x10400,0x1000004,0x400,0x4,0x1000404,0x10404,0x1010404,0x10004,0x1010000,0x1000404,0x1000004,0x404,0x10404,0x1010400,0x404,0x1000400,0x1000400,0,0x10004,0x10400,0,0x1010004];\nvar spfunction2 = [-0x7fef7fe0,-0x7fff8000,0x8000,0x108020,0x100000,0x20,-0x7fefffe0,-0x7fff7fe0,-0x7fffffe0,-0x7fef7fe0,-0x7fef8000,-0x80000000,-0x7fff8000,0x100000,0x20,-0x7fefffe0,0x108000,0x100020,-0x7fff7fe0,0,-0x80000000,0x8000,0x108020,-0x7ff00000,0x100020,-0x7fffffe0,0,0x108000,0x8020,-0x7fef8000,-0x7ff00000,0x8020,0,0x108020,-0x7fefffe0,0x100000,-0x7fff7fe0,-0x7ff00000,-0x7fef8000,0x8000,-0x7ff00000,-0x7fff8000,0x20,-0x7fef7fe0,0x108020,0x20,0x8000,-0x80000000,0x8020,-0x7fef8000,0x100000,-0x7fffffe0,0x100020,-0x7fff7fe0,-0x7fffffe0,0x100020,0x108000,0,-0x7fff8000,0x8020,-0x80000000,-0x7fefffe0,-0x7fef7fe0,0x108000];\nvar spfunction3 = [0x208,0x8020200,0,0x8020008,0x8000200,0,0x20208,0x8000200,0x20008,0x8000008,0x8000008,0x20000,0x8020208,0x20008,0x8020000,0x208,0x8000000,0x8,0x8020200,0x200,0x20200,0x8020000,0x8020008,0x20208,0x8000208,0x20200,0x20000,0x8000208,0x8,0x8020208,0x200,0x8000000,0x8020200,0x8000000,0x20008,0x208,0x20000,0x8020200,0x8000200,0,0x200,0x20008,0x8020208,0x8000200,0x8000008,0x200,0,0x8020008,0x8000208,0x20000,0x8000000,0x8020208,0x8,0x20208,0x20200,0x8000008,0x8020000,0x8000208,0x208,0x8020000,0x20208,0x8,0x8020008,0x20200];\nvar spfunction4 = [0x802001,0x2081,0x2081,0x80,0x802080,0x800081,0x800001,0x2001,0,0x802000,0x802000,0x802081,0x81,0,0x800080,0x800001,0x1,0x2000,0x800000,0x802001,0x80,0x800000,0x2001,0x2080,0x800081,0x1,0x2080,0x800080,0x2000,0x802080,0x802081,0x81,0x800080,0x800001,0x802000,0x802081,0x81,0,0,0x802000,0x2080,0x800080,0x800081,0x1,0x802001,0x2081,0x2081,0x80,0x802081,0x81,0x1,0x2000,0x800001,0x2001,0x802080,0x800081,0x2001,0x2080,0x800000,0x802001,0x80,0x800000,0x2000,0x802080];\nvar spfunction5 = [0x100,0x2080100,0x2080000,0x42000100,0x80000,0x100,0x40000000,0x2080000,0x40080100,0x80000,0x2000100,0x40080100,0x42000100,0x42080000,0x80100,0x40000000,0x2000000,0x40080000,0x40080000,0,0x40000100,0x42080100,0x42080100,0x2000100,0x42080000,0x40000100,0,0x42000000,0x2080100,0x2000000,0x42000000,0x80100,0x80000,0x42000100,0x100,0x2000000,0x40000000,0x2080000,0x42000100,0x40080100,0x2000100,0x40000000,0x42080000,0x2080100,0x40080100,0x100,0x2000000,0x42080000,0x42080100,0x80100,0x42000000,0x42080100,0x2080000,0,0x40080000,0x42000000,0x80100,0x2000100,0x40000100,0x80000,0,0x40080000,0x2080100,0x40000100];\nvar spfunction6 = [0x20000010,0x20400000,0x4000,0x20404010,0x20400000,0x10,0x20404010,0x400000,0x20004000,0x404010,0x400000,0x20000010,0x400010,0x20004000,0x20000000,0x4010,0,0x400010,0x20004010,0x4000,0x404000,0x20004010,0x10,0x20400010,0x20400010,0,0x404010,0x20404000,0x4010,0x404000,0x20404000,0x20000000,0x20004000,0x10,0x20400010,0x404000,0x20404010,0x400000,0x4010,0x20000010,0x400000,0x20004000,0x20000000,0x4010,0x20000010,0x20404010,0x404000,0x20400000,0x404010,0x20404000,0,0x20400010,0x10,0x4000,0x20400000,0x404010,0x4000,0x400010,0x20004010,0,0x20404000,0x20000000,0x400010,0x20004010];\nvar spfunction7 = [0x200000,0x4200002,0x4000802,0,0x800,0x4000802,0x200802,0x4200800,0x4200802,0x200000,0,0x4000002,0x2,0x4000000,0x4200002,0x802,0x4000800,0x200802,0x200002,0x4000800,0x4000002,0x4200000,0x4200800,0x200002,0x4200000,0x800,0x802,0x4200802,0x200800,0x2,0x4000000,0x200800,0x4000000,0x200800,0x200000,0x4000802,0x4000802,0x4200002,0x4200002,0x2,0x200002,0x4000000,0x4000800,0x200000,0x4200800,0x802,0x200802,0x4200800,0x802,0x4000002,0x4200802,0x4200000,0x200800,0,0x2,0x4200802,0,0x200802,0x4200000,0x800,0x4000002,0x4000800,0x800,0x200002];\nvar spfunction8 = [0x10001040,0x1000,0x40000,0x10041040,0x10000000,0x10001040,0x40,0x10000000,0x40040,0x10040000,0x10041040,0x41000,0x10041000,0x41040,0x1000,0x40,0x10040000,0x10000040,0x10001000,0x1040,0x41000,0x40040,0x10040040,0x10041000,0x1040,0,0,0x10040040,0x10000040,0x10001000,0x41040,0x40000,0x41040,0x40000,0x10041000,0x1000,0x40,0x10040040,0x1000,0x41040,0x10001000,0x40,0x10000040,0x10040000,0x10040040,0x10000000,0x40000,0x10001040,0,0x10041040,0x40040,0x10000040,0x10040000,0x10001000,0x10001040,0,0x10041040,0x41000,0x41000,0x1040,0x1040,0x40040,0x10000000,0x10041000];\n\n/**\n * Create necessary sub keys.\n *\n * @param key the 64-bit or 192-bit key.\n *\n * @return the expanded keys.\n */\nfunction _createKeys(key) {\n var pc2bytes0 = [0,0x4,0x20000000,0x20000004,0x10000,0x10004,0x20010000,0x20010004,0x200,0x204,0x20000200,0x20000204,0x10200,0x10204,0x20010200,0x20010204],\n pc2bytes1 = [0,0x1,0x100000,0x100001,0x4000000,0x4000001,0x4100000,0x4100001,0x100,0x101,0x100100,0x100101,0x4000100,0x4000101,0x4100100,0x4100101],\n pc2bytes2 = [0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808,0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808],\n pc2bytes3 = [0,0x200000,0x8000000,0x8200000,0x2000,0x202000,0x8002000,0x8202000,0x20000,0x220000,0x8020000,0x8220000,0x22000,0x222000,0x8022000,0x8222000],\n pc2bytes4 = [0,0x40000,0x10,0x40010,0,0x40000,0x10,0x40010,0x1000,0x41000,0x1010,0x41010,0x1000,0x41000,0x1010,0x41010],\n pc2bytes5 = [0,0x400,0x20,0x420,0,0x400,0x20,0x420,0x2000000,0x2000400,0x2000020,0x2000420,0x2000000,0x2000400,0x2000020,0x2000420],\n pc2bytes6 = [0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002,0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002],\n pc2bytes7 = [0,0x10000,0x800,0x10800,0x20000000,0x20010000,0x20000800,0x20010800,0x20000,0x30000,0x20800,0x30800,0x20020000,0x20030000,0x20020800,0x20030800],\n pc2bytes8 = [0,0x40000,0,0x40000,0x2,0x40002,0x2,0x40002,0x2000000,0x2040000,0x2000000,0x2040000,0x2000002,0x2040002,0x2000002,0x2040002],\n pc2bytes9 = [0,0x10000000,0x8,0x10000008,0,0x10000000,0x8,0x10000008,0x400,0x10000400,0x408,0x10000408,0x400,0x10000400,0x408,0x10000408],\n pc2bytes10 = [0,0x20,0,0x20,0x100000,0x100020,0x100000,0x100020,0x2000,0x2020,0x2000,0x2020,0x102000,0x102020,0x102000,0x102020],\n pc2bytes11 = [0,0x1000000,0x200,0x1000200,0x200000,0x1200000,0x200200,0x1200200,0x4000000,0x5000000,0x4000200,0x5000200,0x4200000,0x5200000,0x4200200,0x5200200],\n pc2bytes12 = [0,0x1000,0x8000000,0x8001000,0x80000,0x81000,0x8080000,0x8081000,0x10,0x1010,0x8000010,0x8001010,0x80010,0x81010,0x8080010,0x8081010],\n pc2bytes13 = [0,0x4,0x100,0x104,0,0x4,0x100,0x104,0x1,0x5,0x101,0x105,0x1,0x5,0x101,0x105];\n\n // how many iterations (1 for des, 3 for triple des)\n // changed by Paul 16/6/2007 to use Triple DES for 9+ byte keys\n var iterations = key.length() > 8 ? 3 : 1;\n\n // stores the return keys\n var keys = [];\n\n // now define the left shifts which need to be done\n var shifts = [0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0];\n\n var n = 0, tmp;\n for(var j = 0; j < iterations; j++) {\n var left = key.getInt32();\n var right = key.getInt32();\n\n tmp = ((left >>> 4) ^ right) & 0x0f0f0f0f;\n right ^= tmp;\n left ^= (tmp << 4);\n\n tmp = ((right >>> -16) ^ left) & 0x0000ffff;\n left ^= tmp;\n right ^= (tmp << -16);\n\n tmp = ((left >>> 2) ^ right) & 0x33333333;\n right ^= tmp;\n left ^= (tmp << 2);\n\n tmp = ((right >>> -16) ^ left) & 0x0000ffff;\n left ^= tmp;\n right ^= (tmp << -16);\n\n tmp = ((left >>> 1) ^ right) & 0x55555555;\n right ^= tmp;\n left ^= (tmp << 1);\n\n tmp = ((right >>> 8) ^ left) & 0x00ff00ff;\n left ^= tmp;\n right ^= (tmp << 8);\n\n tmp = ((left >>> 1) ^ right) & 0x55555555;\n right ^= tmp;\n left ^= (tmp << 1);\n\n // right needs to be shifted and OR'd with last four bits of left\n tmp = (left << 8) | ((right >>> 20) & 0x000000f0);\n\n // left needs to be put upside down\n left = ((right << 24) | ((right << 8) & 0xff0000) |\n ((right >>> 8) & 0xff00) | ((right >>> 24) & 0xf0));\n right = tmp;\n\n // now go through and perform these shifts on the left and right keys\n for(var i = 0; i < shifts.length; ++i) {\n //shift the keys either one or two bits to the left\n if(shifts[i]) {\n left = (left << 2) | (left >>> 26);\n right = (right << 2) | (right >>> 26);\n } else {\n left = (left << 1) | (left >>> 27);\n right = (right << 1) | (right >>> 27);\n }\n left &= -0xf;\n right &= -0xf;\n\n // now apply PC-2, in such a way that E is easier when encrypting or\n // decrypting this conversion will look like PC-2 except only the last 6\n // bits of each byte are used rather than 48 consecutive bits and the\n // order of lines will be according to how the S selection functions will\n // be applied: S2, S4, S6, S8, S1, S3, S5, S7\n var lefttmp = (\n pc2bytes0[left >>> 28] | pc2bytes1[(left >>> 24) & 0xf] |\n pc2bytes2[(left >>> 20) & 0xf] | pc2bytes3[(left >>> 16) & 0xf] |\n pc2bytes4[(left >>> 12) & 0xf] | pc2bytes5[(left >>> 8) & 0xf] |\n pc2bytes6[(left >>> 4) & 0xf]);\n var righttmp = (\n pc2bytes7[right >>> 28] | pc2bytes8[(right >>> 24) & 0xf] |\n pc2bytes9[(right >>> 20) & 0xf] | pc2bytes10[(right >>> 16) & 0xf] |\n pc2bytes11[(right >>> 12) & 0xf] | pc2bytes12[(right >>> 8) & 0xf] |\n pc2bytes13[(right >>> 4) & 0xf]);\n tmp = ((righttmp >>> 16) ^ lefttmp) & 0x0000ffff;\n keys[n++] = lefttmp ^ tmp;\n keys[n++] = righttmp ^ (tmp << 16);\n }\n }\n\n return keys;\n}\n\n/**\n * Updates a single block (1 byte) using DES. The update will either\n * encrypt or decrypt the block.\n *\n * @param keys the expanded keys.\n * @param input the input block (an array of 32-bit words).\n * @param output the updated output block.\n * @param decrypt true to decrypt the block, false to encrypt it.\n */\nfunction _updateBlock(keys, input, output, decrypt) {\n // set up loops for single or triple DES\n var iterations = keys.length === 32 ? 3 : 9;\n var looping;\n if(iterations === 3) {\n looping = decrypt ? [30, -2, -2] : [0, 32, 2];\n } else {\n looping = (decrypt ?\n [94, 62, -2, 32, 64, 2, 30, -2, -2] :\n [0, 32, 2, 62, 30, -2, 64, 96, 2]);\n }\n\n var tmp;\n\n var left = input[0];\n var right = input[1];\n\n // first each 64 bit chunk of the message must be permuted according to IP\n tmp = ((left >>> 4) ^ right) & 0x0f0f0f0f;\n right ^= tmp;\n left ^= (tmp << 4);\n\n tmp = ((left >>> 16) ^ right) & 0x0000ffff;\n right ^= tmp;\n left ^= (tmp << 16);\n\n tmp = ((right >>> 2) ^ left) & 0x33333333;\n left ^= tmp;\n right ^= (tmp << 2);\n\n tmp = ((right >>> 8) ^ left) & 0x00ff00ff;\n left ^= tmp;\n right ^= (tmp << 8);\n\n tmp = ((left >>> 1) ^ right) & 0x55555555;\n right ^= tmp;\n left ^= (tmp << 1);\n\n // rotate left 1 bit\n left = ((left << 1) | (left >>> 31));\n right = ((right << 1) | (right >>> 31));\n\n for(var j = 0; j < iterations; j += 3) {\n var endloop = looping[j + 1];\n var loopinc = looping[j + 2];\n\n // now go through and perform the encryption or decryption\n for(var i = looping[j]; i != endloop; i += loopinc) {\n var right1 = right ^ keys[i];\n var right2 = ((right >>> 4) | (right << 28)) ^ keys[i + 1];\n\n // passing these bytes through the S selection functions\n tmp = left;\n left = right;\n right = tmp ^ (\n spfunction2[(right1 >>> 24) & 0x3f] |\n spfunction4[(right1 >>> 16) & 0x3f] |\n spfunction6[(right1 >>> 8) & 0x3f] |\n spfunction8[right1 & 0x3f] |\n spfunction1[(right2 >>> 24) & 0x3f] |\n spfunction3[(right2 >>> 16) & 0x3f] |\n spfunction5[(right2 >>> 8) & 0x3f] |\n spfunction7[right2 & 0x3f]);\n }\n // unreverse left and right\n tmp = left;\n left = right;\n right = tmp;\n }\n\n // rotate right 1 bit\n left = ((left >>> 1) | (left << 31));\n right = ((right >>> 1) | (right << 31));\n\n // now perform IP-1, which is IP in the opposite direction\n tmp = ((left >>> 1) ^ right) & 0x55555555;\n right ^= tmp;\n left ^= (tmp << 1);\n\n tmp = ((right >>> 8) ^ left) & 0x00ff00ff;\n left ^= tmp;\n right ^= (tmp << 8);\n\n tmp = ((right >>> 2) ^ left) & 0x33333333;\n left ^= tmp;\n right ^= (tmp << 2);\n\n tmp = ((left >>> 16) ^ right) & 0x0000ffff;\n right ^= tmp;\n left ^= (tmp << 16);\n\n tmp = ((left >>> 4) ^ right) & 0x0f0f0f0f;\n right ^= tmp;\n left ^= (tmp << 4);\n\n output[0] = left;\n output[1] = right;\n}\n\n/**\n * Deprecated. Instead, use:\n *\n * forge.cipher.createCipher('DES-', key);\n * forge.cipher.createDecipher('DES-', key);\n *\n * Creates a deprecated DES cipher object. This object's mode will default to\n * CBC (cipher-block-chaining).\n *\n * The key may be given as a binary-encoded string of bytes or a byte buffer.\n *\n * @param options the options to use.\n * key the symmetric key to use (64 or 192 bits).\n * output the buffer to write to.\n * decrypt true for decryption, false for encryption.\n * mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nfunction _createCipher(options) {\n options = options || {};\n var mode = (options.mode || 'CBC').toUpperCase();\n var algorithm = 'DES-' + mode;\n\n var cipher;\n if(options.decrypt) {\n cipher = forge.cipher.createDecipher(algorithm, options.key);\n } else {\n cipher = forge.cipher.createCipher(algorithm, options.key);\n }\n\n // backwards compatible start API\n var start = cipher.start;\n cipher.start = function(iv, options) {\n // backwards compatibility: support second arg as output buffer\n var output = null;\n if(options instanceof forge.util.ByteBuffer) {\n output = options;\n options = {};\n }\n options = options || {};\n options.output = output;\n options.iv = iv;\n start.call(cipher, options);\n };\n\n return cipher;\n}\n","/**\n * JavaScript implementation of Ed25519.\n *\n * Copyright (c) 2017-2019 Digital Bazaar, Inc.\n *\n * This implementation is based on the most excellent TweetNaCl which is\n * in the public domain. Many thanks to its contributors:\n *\n * https://github.com/dchest/tweetnacl-js\n */\nvar forge = require('./forge');\nrequire('./jsbn');\nrequire('./random');\nrequire('./sha512');\nrequire('./util');\nvar asn1Validator = require('./asn1-validator');\nvar publicKeyValidator = asn1Validator.publicKeyValidator;\nvar privateKeyValidator = asn1Validator.privateKeyValidator;\n\nif(typeof BigInteger === 'undefined') {\n var BigInteger = forge.jsbn.BigInteger;\n}\n\nvar ByteBuffer = forge.util.ByteBuffer;\nvar NativeBuffer = typeof Buffer === 'undefined' ? Uint8Array : Buffer;\n\n/*\n * Ed25519 algorithms, see RFC 8032:\n * https://tools.ietf.org/html/rfc8032\n */\nforge.pki = forge.pki || {};\nmodule.exports = forge.pki.ed25519 = forge.ed25519 = forge.ed25519 || {};\nvar ed25519 = forge.ed25519;\n\ned25519.constants = {};\ned25519.constants.PUBLIC_KEY_BYTE_LENGTH = 32;\ned25519.constants.PRIVATE_KEY_BYTE_LENGTH = 64;\ned25519.constants.SEED_BYTE_LENGTH = 32;\ned25519.constants.SIGN_BYTE_LENGTH = 64;\ned25519.constants.HASH_BYTE_LENGTH = 64;\n\ned25519.generateKeyPair = function(options) {\n options = options || {};\n var seed = options.seed;\n if(seed === undefined) {\n // generate seed\n seed = forge.random.getBytesSync(ed25519.constants.SEED_BYTE_LENGTH);\n } else if(typeof seed === 'string') {\n if(seed.length !== ed25519.constants.SEED_BYTE_LENGTH) {\n throw new TypeError(\n '\"seed\" must be ' + ed25519.constants.SEED_BYTE_LENGTH +\n ' bytes in length.');\n }\n } else if(!(seed instanceof Uint8Array)) {\n throw new TypeError(\n '\"seed\" must be a node.js Buffer, Uint8Array, or a binary string.');\n }\n\n seed = messageToNativeBuffer({message: seed, encoding: 'binary'});\n\n var pk = new NativeBuffer(ed25519.constants.PUBLIC_KEY_BYTE_LENGTH);\n var sk = new NativeBuffer(ed25519.constants.PRIVATE_KEY_BYTE_LENGTH);\n for(var i = 0; i < 32; ++i) {\n sk[i] = seed[i];\n }\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, privateKey: sk};\n};\n\n/**\n * Converts a private key from a RFC8410 ASN.1 encoding.\n *\n * @param obj - The asn1 representation of a private key.\n *\n * @returns {Object} keyInfo - The key information.\n * @returns {Buffer|Uint8Array} keyInfo.privateKeyBytes - 32 private key bytes.\n */\ned25519.privateKeyFromAsn1 = function(obj) {\n var capture = {};\n var errors = [];\n var valid = forge.asn1.validate(obj, privateKeyValidator, capture, errors);\n if(!valid) {\n var error = new Error('Invalid Key.');\n error.errors = errors;\n throw error;\n }\n var oid = forge.asn1.derToOid(capture.privateKeyOid);\n var ed25519Oid = forge.oids.EdDSA25519;\n if(oid !== ed25519Oid) {\n throw new Error('Invalid OID \"' + oid + '\"; OID must be \"' +\n ed25519Oid + '\".');\n }\n var privateKey = capture.privateKey;\n // manually extract the private key bytes from nested octet string, see FIXME:\n // https://github.com/digitalbazaar/forge/blob/master/lib/asn1.js#L542\n var privateKeyBytes = messageToNativeBuffer({\n message: forge.asn1.fromDer(privateKey).value,\n encoding: 'binary'\n });\n // TODO: RFC8410 specifies a format for encoding the public key bytes along\n // with the private key bytes. `publicKeyBytes` can be returned in the\n // future. https://tools.ietf.org/html/rfc8410#section-10.3\n return {privateKeyBytes: privateKeyBytes};\n};\n\n/**\n * Converts a public key from a RFC8410 ASN.1 encoding.\n *\n * @param obj - The asn1 representation of a public key.\n *\n * @return {Buffer|Uint8Array} - 32 public key bytes.\n */\ned25519.publicKeyFromAsn1 = function(obj) {\n // get SubjectPublicKeyInfo\n var capture = {};\n var errors = [];\n var valid = forge.asn1.validate(obj, publicKeyValidator, capture, errors);\n if(!valid) {\n var error = new Error('Invalid Key.');\n error.errors = errors;\n throw error;\n }\n var oid = forge.asn1.derToOid(capture.publicKeyOid);\n var ed25519Oid = forge.oids.EdDSA25519;\n if(oid !== ed25519Oid) {\n throw new Error('Invalid OID \"' + oid + '\"; OID must be \"' +\n ed25519Oid + '\".');\n }\n var publicKeyBytes = capture.ed25519PublicKey;\n if(publicKeyBytes.length !== ed25519.constants.PUBLIC_KEY_BYTE_LENGTH) {\n throw new Error('Key length is invalid.');\n }\n return messageToNativeBuffer({\n message: publicKeyBytes,\n encoding: 'binary'\n });\n};\n\ned25519.publicKeyFromPrivateKey = function(options) {\n options = options || {};\n var privateKey = messageToNativeBuffer({\n message: options.privateKey, encoding: 'binary'\n });\n if(privateKey.length !== ed25519.constants.PRIVATE_KEY_BYTE_LENGTH) {\n throw new TypeError(\n '\"options.privateKey\" must have a byte length of ' +\n ed25519.constants.PRIVATE_KEY_BYTE_LENGTH);\n }\n\n var pk = new NativeBuffer(ed25519.constants.PUBLIC_KEY_BYTE_LENGTH);\n for(var i = 0; i < pk.length; ++i) {\n pk[i] = privateKey[32 + i];\n }\n return pk;\n};\n\ned25519.sign = function(options) {\n options = options || {};\n var msg = messageToNativeBuffer(options);\n var privateKey = messageToNativeBuffer({\n message: options.privateKey,\n encoding: 'binary'\n });\n if(privateKey.length === ed25519.constants.SEED_BYTE_LENGTH) {\n var keyPair = ed25519.generateKeyPair({seed: privateKey});\n privateKey = keyPair.privateKey;\n } else if(privateKey.length !== ed25519.constants.PRIVATE_KEY_BYTE_LENGTH) {\n throw new TypeError(\n '\"options.privateKey\" must have a byte length of ' +\n ed25519.constants.SEED_BYTE_LENGTH + ' or ' +\n ed25519.constants.PRIVATE_KEY_BYTE_LENGTH);\n }\n\n var signedMsg = new NativeBuffer(\n ed25519.constants.SIGN_BYTE_LENGTH + msg.length);\n crypto_sign(signedMsg, msg, msg.length, privateKey);\n\n var sig = new NativeBuffer(ed25519.constants.SIGN_BYTE_LENGTH);\n for(var i = 0; i < sig.length; ++i) {\n sig[i] = signedMsg[i];\n }\n return sig;\n};\n\ned25519.verify = function(options) {\n options = options || {};\n var msg = messageToNativeBuffer(options);\n if(options.signature === undefined) {\n throw new TypeError(\n '\"options.signature\" must be a node.js Buffer, a Uint8Array, a forge ' +\n 'ByteBuffer, or a binary string.');\n }\n var sig = messageToNativeBuffer({\n message: options.signature,\n encoding: 'binary'\n });\n if(sig.length !== ed25519.constants.SIGN_BYTE_LENGTH) {\n throw new TypeError(\n '\"options.signature\" must have a byte length of ' +\n ed25519.constants.SIGN_BYTE_LENGTH);\n }\n var publicKey = messageToNativeBuffer({\n message: options.publicKey,\n encoding: 'binary'\n });\n if(publicKey.length !== ed25519.constants.PUBLIC_KEY_BYTE_LENGTH) {\n throw new TypeError(\n '\"options.publicKey\" must have a byte length of ' +\n ed25519.constants.PUBLIC_KEY_BYTE_LENGTH);\n }\n\n var sm = new NativeBuffer(ed25519.constants.SIGN_BYTE_LENGTH + msg.length);\n var m = new NativeBuffer(ed25519.constants.SIGN_BYTE_LENGTH + msg.length);\n var i;\n for(i = 0; i < ed25519.constants.SIGN_BYTE_LENGTH; ++i) {\n sm[i] = sig[i];\n }\n for(i = 0; i < msg.length; ++i) {\n sm[i + ed25519.constants.SIGN_BYTE_LENGTH] = msg[i];\n }\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nfunction messageToNativeBuffer(options) {\n var message = options.message;\n if(message instanceof Uint8Array || message instanceof NativeBuffer) {\n return message;\n }\n\n var encoding = options.encoding;\n if(message === undefined) {\n if(options.md) {\n // TODO: more rigorous validation that `md` is a MessageDigest\n message = options.md.digest().getBytes();\n encoding = 'binary';\n } else {\n throw new TypeError('\"options.message\" or \"options.md\" not specified.');\n }\n }\n\n if(typeof message === 'string' && !encoding) {\n throw new TypeError('\"options.encoding\" must be \"binary\" or \"utf8\".');\n }\n\n if(typeof message === 'string') {\n if(typeof Buffer !== 'undefined') {\n return Buffer.from(message, encoding);\n }\n message = new ByteBuffer(message, encoding);\n } else if(!(message instanceof ByteBuffer)) {\n throw new TypeError(\n '\"options.message\" must be a node.js Buffer, a Uint8Array, a forge ' +\n 'ByteBuffer, or a string with \"options.encoding\" specifying its ' +\n 'encoding.');\n }\n\n // convert to native buffer\n var buffer = new NativeBuffer(message.length());\n for(var i = 0; i < buffer.length; ++i) {\n buffer[i] = message.at(i);\n }\n return buffer;\n}\n\nvar gf0 = gf();\nvar gf1 = gf([1]);\nvar D = gf([\n 0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070,\n 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]);\nvar D2 = gf([\n 0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0,\n 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]);\nvar X = gf([\n 0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c,\n 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]);\nvar Y = gf([\n 0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666,\n 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]);\nvar L = new Float64Array([\n 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,\n 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\nvar I = gf([\n 0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43,\n 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\n// TODO: update forge buffer implementation to use `Buffer` or `Uint8Array`,\n// whichever is available, to improve performance\nfunction sha512(msg, msgLen) {\n // Note: `out` and `msg` are NativeBuffer\n var md = forge.md.sha512.create();\n var buffer = new ByteBuffer(msg);\n md.update(buffer.getBytes(msgLen), 'binary');\n var hash = md.digest().getBytes();\n if(typeof Buffer !== 'undefined') {\n return Buffer.from(hash, 'binary');\n }\n var out = new NativeBuffer(ed25519.constants.HASH_BYTE_LENGTH);\n for(var i = 0; i < 64; ++i) {\n out[i] = hash.charCodeAt(i);\n }\n return out;\n}\n\nfunction crypto_sign_keypair(pk, sk) {\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n var d = sha512(sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for(i = 0; i < 32; ++i) {\n sk[i + 32] = pk[i];\n }\n return 0;\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n var d = sha512(sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for(i = 0; i < n; ++i) {\n sm[64 + i] = m[i];\n }\n for(i = 0; i < 32; ++i) {\n sm[32 + i] = d[32 + i];\n }\n\n var r = sha512(sm.subarray(32), n + 32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for(i = 32; i < 64; ++i) {\n sm[i] = sk[i];\n }\n var h = sha512(sm, n + 64);\n reduce(h);\n\n for(i = 32; i < 64; ++i) {\n x[i] = 0;\n }\n for(i = 0; i < 32; ++i) {\n x[i] = r[i];\n }\n for(i = 0; i < 32; ++i) {\n for(j = 0; j < 32; j++) {\n x[i + j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i, mlen;\n var t = new NativeBuffer(32);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n mlen = -1;\n if(n < 64) {\n return -1;\n }\n\n if(unpackneg(q, pk)) {\n return -1;\n }\n\n for(i = 0; i < n; ++i) {\n m[i] = sm[i];\n }\n for(i = 0; i < 32; ++i) {\n m[i + 32] = pk[i];\n }\n var h = sha512(m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if(crypto_verify_32(sm, 0, t, 0)) {\n for(i = 0; i < n; ++i) {\n m[i] = 0;\n }\n return -1;\n }\n\n for(i = 0; i < n; ++i) {\n m[i] = sm[i + 64];\n }\n mlen = n;\n return mlen;\n}\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for(i = 63; i >= 32; --i) {\n carry = 0;\n for(j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = (x[j] + 128) >> 8;\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for(j = 0; j < 32; ++j) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for(j = 0; j < 32; ++j) {\n x[j] -= carry * L[j];\n }\n for(i = 0; i < 32; ++i) {\n x[i + 1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64);\n for(var i = 0; i < 64; ++i) {\n x[i] = r[i];\n r[i] = 0;\n }\n modL(r, x);\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n for(var i = 0; i < 4; ++i) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for(i = 0; i < 16; ++i) {\n t[i] = n[i];\n }\n car25519(t);\n car25519(t);\n car25519(t);\n for(j = 0; j < 2; ++j) {\n m[0] = t[0] - 0xffed;\n for(i = 1; i < 15; ++i) {\n m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1);\n b = (m[15] >> 16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1 - b);\n }\n for (i = 0; i < 16; i++) {\n o[2 * i] = t[i] & 0xff;\n o[2 * i + 1] = t[i] >> 8;\n }\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if(neq25519(chk, num)) {\n M(r[0], r[0], I);\n }\n\n S(chk, r[0]);\n M(chk, chk, den);\n if(neq25519(chk, num)) {\n return -1;\n }\n\n if(par25519(r[0]) === (p[31] >> 7)) {\n Z(r[0], gf0, r[0]);\n }\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for(i = 0; i < 16; ++i) {\n o[i] = n[2 * i] + (n[2 * i + 1] << 8);\n }\n o[15] &= 0x7fff;\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for(a = 0; a < 16; ++a) {\n c[a] = i[a];\n }\n for(a = 250; a >= 0; --a) {\n S(c, c);\n if(a !== 1) {\n M(c, c, i);\n }\n }\n for(a = 0; a < 16; ++a) {\n o[a] = c[a];\n }\n}\n\nfunction neq25519(a, b) {\n var c = new NativeBuffer(32);\n var d = new NativeBuffer(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x, xi, y, yi, 32);\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i, d = 0;\n for(i = 0; i < n; ++i) {\n d |= x[xi + i] ^ y[yi + i];\n }\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction par25519(a) {\n var d = new NativeBuffer(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for(i = 255; i >= 0; --i) {\n b = (s[(i / 8)|0] >> (i & 7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction set25519(r, a) {\n var i;\n for(i = 0; i < 16; i++) {\n r[i] = a[i] | 0;\n }\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for(a = 0; a < 16; ++a) {\n c[a] = i[a];\n }\n for(a = 253; a >= 0; --a) {\n S(c, c);\n if(a !== 2 && a !== 4) {\n M(c, c, i);\n }\n }\n for(a = 0; a < 16; ++a) {\n o[a] = c[a];\n }\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for(i = 0; i < 16; ++i) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c - 1 + 37 * (c - 1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b - 1);\n for(var i = 0; i < 16; ++i) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction gf(init) {\n var i, r = new Float64Array(16);\n if(init) {\n for(i = 0; i < init.length; ++i) {\n r[i] = init[i];\n }\n }\n return r;\n}\n\nfunction A(o, a, b) {\n for(var i = 0; i < 16; ++i) {\n o[i] = a[i] + b[i];\n }\n}\n\nfunction Z(o, a, b) {\n for(var i = 0; i < 16; ++i) {\n o[i] = a[i] - b[i];\n }\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n","/**\n * Node.js module for Forge.\n *\n * @author Dave Longley\n *\n * Copyright 2011-2016 Digital Bazaar, Inc.\n */\nmodule.exports = {\n // default options\n options: {\n usePureJavaScript: false\n }\n};\n","/**\n * Hash-based Message Authentication Code implementation. Requires a message\n * digest object that can be obtained, for example, from forge.md.sha1 or\n * forge.md.md5.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2012 Digital Bazaar, Inc. All rights reserved.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\n/* HMAC API */\nvar hmac = module.exports = forge.hmac = forge.hmac || {};\n\n/**\n * Creates an HMAC object that uses the given message digest object.\n *\n * @return an HMAC object.\n */\nhmac.create = function() {\n // the hmac key to use\n var _key = null;\n\n // the message digest to use\n var _md = null;\n\n // the inner padding\n var _ipadding = null;\n\n // the outer padding\n var _opadding = null;\n\n // hmac context\n var ctx = {};\n\n /**\n * Starts or restarts the HMAC with the given key and message digest.\n *\n * @param md the message digest to use, null to reuse the previous one,\n * a string to use builtin 'sha1', 'md5', 'sha256'.\n * @param key the key to use as a string, array of bytes, byte buffer,\n * or null to reuse the previous key.\n */\n ctx.start = function(md, key) {\n if(md !== null) {\n if(typeof md === 'string') {\n // create builtin message digest\n md = md.toLowerCase();\n if(md in forge.md.algorithms) {\n _md = forge.md.algorithms[md].create();\n } else {\n throw new Error('Unknown hash algorithm \"' + md + '\"');\n }\n } else {\n // store message digest\n _md = md;\n }\n }\n\n if(key === null) {\n // reuse previous key\n key = _key;\n } else {\n if(typeof key === 'string') {\n // convert string into byte buffer\n key = forge.util.createBuffer(key);\n } else if(forge.util.isArray(key)) {\n // convert byte array into byte buffer\n var tmp = key;\n key = forge.util.createBuffer();\n for(var i = 0; i < tmp.length; ++i) {\n key.putByte(tmp[i]);\n }\n }\n\n // if key is longer than blocksize, hash it\n var keylen = key.length();\n if(keylen > _md.blockLength) {\n _md.start();\n _md.update(key.bytes());\n key = _md.digest();\n }\n\n // mix key into inner and outer padding\n // ipadding = [0x36 * blocksize] ^ key\n // opadding = [0x5C * blocksize] ^ key\n _ipadding = forge.util.createBuffer();\n _opadding = forge.util.createBuffer();\n keylen = key.length();\n for(var i = 0; i < keylen; ++i) {\n var tmp = key.at(i);\n _ipadding.putByte(0x36 ^ tmp);\n _opadding.putByte(0x5C ^ tmp);\n }\n\n // if key is shorter than blocksize, add additional padding\n if(keylen < _md.blockLength) {\n var tmp = _md.blockLength - keylen;\n for(var i = 0; i < tmp; ++i) {\n _ipadding.putByte(0x36);\n _opadding.putByte(0x5C);\n }\n }\n _key = key;\n _ipadding = _ipadding.bytes();\n _opadding = _opadding.bytes();\n }\n\n // digest is done like so: hash(opadding | hash(ipadding | message))\n\n // prepare to do inner hash\n // hash(ipadding | message)\n _md.start();\n _md.update(_ipadding);\n };\n\n /**\n * Updates the HMAC with the given message bytes.\n *\n * @param bytes the bytes to update with.\n */\n ctx.update = function(bytes) {\n _md.update(bytes);\n };\n\n /**\n * Produces the Message Authentication Code (MAC).\n *\n * @return a byte buffer containing the digest value.\n */\n ctx.getMac = function() {\n // digest is done like so: hash(opadding | hash(ipadding | message))\n // here we do the outer hashing\n var inner = _md.digest().bytes();\n _md.start();\n _md.update(_opadding);\n _md.update(inner);\n return _md.digest();\n };\n // alias for getMac\n ctx.digest = ctx.getMac;\n\n return ctx;\n};\n","/**\n * Node.js module for Forge.\n *\n * @author Dave Longley\n *\n * Copyright 2011-2016 Digital Bazaar, Inc.\n */\nmodule.exports = require('./forge');\nrequire('./aes');\nrequire('./aesCipherSuites');\nrequire('./asn1');\nrequire('./cipher');\nrequire('./debug');\nrequire('./des');\nrequire('./ed25519');\nrequire('./hmac');\nrequire('./kem');\nrequire('./log');\nrequire('./md.all');\nrequire('./mgf1');\nrequire('./pbkdf2');\nrequire('./pem');\nrequire('./pkcs1');\nrequire('./pkcs12');\nrequire('./pkcs7');\nrequire('./pki');\nrequire('./prime');\nrequire('./prng');\nrequire('./pss');\nrequire('./random');\nrequire('./rc2');\nrequire('./ssh');\nrequire('./task');\nrequire('./tls');\nrequire('./util');\n","// Copyright (c) 2005 Tom Wu\n// All Rights Reserved.\n// See \"LICENSE\" for details.\n\n// Basic JavaScript BN library - subset useful for RSA encryption.\n\n/*\nLicensing (LICENSE)\n-------------------\n\nThis software is covered under the following copyright:\n*/\n/*\n * Copyright (c) 2003-2005 Tom Wu\n * All Rights Reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS-IS\" AND WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY\n * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.\n *\n * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,\n * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER\n * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF\n * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT\n * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n *\n * In addition, the following condition applies:\n *\n * All redistributions must retain an intact copy of this copyright notice\n * and disclaimer.\n */\n/*\nAddress all questions regarding this license to:\n\n Tom Wu\n tjw@cs.Stanford.EDU\n*/\nvar forge = require('./forge');\n\nmodule.exports = forge.jsbn = forge.jsbn || {};\n\n// Bits per digit\nvar dbits;\n\n// JavaScript engine analysis\nvar canary = 0xdeadbeefcafe;\nvar j_lm = ((canary&0xffffff)==0xefcafe);\n\n// (public) Constructor\nfunction BigInteger(a,b,c) {\n this.data = [];\n if(a != null)\n if(\"number\" == typeof a) this.fromNumber(a,b,c);\n else if(b == null && \"string\" != typeof a) this.fromString(a,256);\n else this.fromString(a,b);\n}\nforge.jsbn.BigInteger = BigInteger;\n\n// return new, unset BigInteger\nfunction nbi() { return new BigInteger(null); }\n\n// am: Compute w_j += (x*this_i), propagate carries,\n// c is initial carry, returns final carry.\n// c < 3*dvalue, x < 2*dvalue, this_i < dvalue\n// We need to select the fastest one that works in this environment.\n\n// am1: use a single mult and divide to get the high bits,\n// max digit bits should be 26 because\n// max internal value = 2*dvalue^2-2*dvalue (< 2^53)\nfunction am1(i,x,w,j,c,n) {\n while(--n >= 0) {\n var v = x*this.data[i++]+w.data[j]+c;\n c = Math.floor(v/0x4000000);\n w.data[j++] = v&0x3ffffff;\n }\n return c;\n}\n// am2 avoids a big mult-and-extract completely.\n// Max digit bits should be <= 30 because we do bitwise ops\n// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)\nfunction am2(i,x,w,j,c,n) {\n var xl = x&0x7fff, xh = x>>15;\n while(--n >= 0) {\n var l = this.data[i]&0x7fff;\n var h = this.data[i++]>>15;\n var m = xh*l+h*xl;\n l = xl*l+((m&0x7fff)<<15)+w.data[j]+(c&0x3fffffff);\n c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);\n w.data[j++] = l&0x3fffffff;\n }\n return c;\n}\n// Alternately, set max digit bits to 28 since some\n// browsers slow down when dealing with 32-bit numbers.\nfunction am3(i,x,w,j,c,n) {\n var xl = x&0x3fff, xh = x>>14;\n while(--n >= 0) {\n var l = this.data[i]&0x3fff;\n var h = this.data[i++]>>14;\n var m = xh*l+h*xl;\n l = xl*l+((m&0x3fff)<<14)+w.data[j]+c;\n c = (l>>28)+(m>>14)+xh*h;\n w.data[j++] = l&0xfffffff;\n }\n return c;\n}\n\n// node.js (no browser)\nif(typeof(navigator) === 'undefined')\n{\n BigInteger.prototype.am = am3;\n dbits = 28;\n} else if(j_lm && (navigator.appName == \"Microsoft Internet Explorer\")) {\n BigInteger.prototype.am = am2;\n dbits = 30;\n} else if(j_lm && (navigator.appName != \"Netscape\")) {\n BigInteger.prototype.am = am1;\n dbits = 26;\n} else { // Mozilla/Netscape seems to prefer am3\n BigInteger.prototype.am = am3;\n dbits = 28;\n}\n\nBigInteger.prototype.DB = dbits;\nBigInteger.prototype.DM = ((1<= 0; --i) r.data[i] = this.data[i];\n r.t = this.t;\n r.s = this.s;\n}\n\n// (protected) set from integer value x, -DV <= x < DV\nfunction bnpFromInt(x) {\n this.t = 1;\n this.s = (x<0)?-1:0;\n if(x > 0) this.data[0] = x;\n else if(x < -1) this.data[0] = x+this.DV;\n else this.t = 0;\n}\n\n// return bigint initialized to value\nfunction nbv(i) { var r = nbi(); r.fromInt(i); return r; }\n\n// (protected) set from string and radix\nfunction bnpFromString(s,b) {\n var k;\n if(b == 16) k = 4;\n else if(b == 8) k = 3;\n else if(b == 256) k = 8; // byte array\n else if(b == 2) k = 1;\n else if(b == 32) k = 5;\n else if(b == 4) k = 2;\n else { this.fromRadix(s,b); return; }\n this.t = 0;\n this.s = 0;\n var i = s.length, mi = false, sh = 0;\n while(--i >= 0) {\n var x = (k==8)?s[i]&0xff:intAt(s,i);\n if(x < 0) {\n if(s.charAt(i) == \"-\") mi = true;\n continue;\n }\n mi = false;\n if(sh == 0)\n this.data[this.t++] = x;\n else if(sh+k > this.DB) {\n this.data[this.t-1] |= (x&((1<<(this.DB-sh))-1))<>(this.DB-sh));\n } else\n this.data[this.t-1] |= x<= this.DB) sh -= this.DB;\n }\n if(k == 8 && (s[0]&0x80) != 0) {\n this.s = -1;\n if(sh > 0) this.data[this.t-1] |= ((1<<(this.DB-sh))-1)< 0 && this.data[this.t-1] == c) --this.t;\n}\n\n// (public) return string representation in given radix\nfunction bnToString(b) {\n if(this.s < 0) return \"-\"+this.negate().toString(b);\n var k;\n if(b == 16) k = 4;\n else if(b == 8) k = 3;\n else if(b == 2) k = 1;\n else if(b == 32) k = 5;\n else if(b == 4) k = 2;\n else return this.toRadix(b);\n var km = (1< 0) {\n if(p < this.DB && (d = this.data[i]>>p) > 0) { m = true; r = int2char(d); }\n while(i >= 0) {\n if(p < k) {\n d = (this.data[i]&((1<>(p+=this.DB-k);\n } else {\n d = (this.data[i]>>(p-=k))&km;\n if(p <= 0) { p += this.DB; --i; }\n }\n if(d > 0) m = true;\n if(m) r += int2char(d);\n }\n }\n return m?r:\"0\";\n}\n\n// (public) -this\nfunction bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }\n\n// (public) |this|\nfunction bnAbs() { return (this.s<0)?this.negate():this; }\n\n// (public) return + if this > a, - if this < a, 0 if equal\nfunction bnCompareTo(a) {\n var r = this.s-a.s;\n if(r != 0) return r;\n var i = this.t;\n r = i-a.t;\n if(r != 0) return (this.s<0)?-r:r;\n while(--i >= 0) if((r=this.data[i]-a.data[i]) != 0) return r;\n return 0;\n}\n\n// returns bit length of the integer x\nfunction nbits(x) {\n var r = 1, t;\n if((t=x>>>16) != 0) { x = t; r += 16; }\n if((t=x>>8) != 0) { x = t; r += 8; }\n if((t=x>>4) != 0) { x = t; r += 4; }\n if((t=x>>2) != 0) { x = t; r += 2; }\n if((t=x>>1) != 0) { x = t; r += 1; }\n return r;\n}\n\n// (public) return the number of bits in \"this\"\nfunction bnBitLength() {\n if(this.t <= 0) return 0;\n return this.DB*(this.t-1)+nbits(this.data[this.t-1]^(this.s&this.DM));\n}\n\n// (protected) r = this << n*DB\nfunction bnpDLShiftTo(n,r) {\n var i;\n for(i = this.t-1; i >= 0; --i) r.data[i+n] = this.data[i];\n for(i = n-1; i >= 0; --i) r.data[i] = 0;\n r.t = this.t+n;\n r.s = this.s;\n}\n\n// (protected) r = this >> n*DB\nfunction bnpDRShiftTo(n,r) {\n for(var i = n; i < this.t; ++i) r.data[i-n] = this.data[i];\n r.t = Math.max(this.t-n,0);\n r.s = this.s;\n}\n\n// (protected) r = this << n\nfunction bnpLShiftTo(n,r) {\n var bs = n%this.DB;\n var cbs = this.DB-bs;\n var bm = (1<= 0; --i) {\n r.data[i+ds+1] = (this.data[i]>>cbs)|c;\n c = (this.data[i]&bm)<= 0; --i) r.data[i] = 0;\n r.data[ds] = c;\n r.t = this.t+ds+1;\n r.s = this.s;\n r.clamp();\n}\n\n// (protected) r = this >> n\nfunction bnpRShiftTo(n,r) {\n r.s = this.s;\n var ds = Math.floor(n/this.DB);\n if(ds >= this.t) { r.t = 0; return; }\n var bs = n%this.DB;\n var cbs = this.DB-bs;\n var bm = (1<>bs;\n for(var i = ds+1; i < this.t; ++i) {\n r.data[i-ds-1] |= (this.data[i]&bm)<>bs;\n }\n if(bs > 0) r.data[this.t-ds-1] |= (this.s&bm)<>= this.DB;\n }\n if(a.t < this.t) {\n c -= a.s;\n while(i < this.t) {\n c += this.data[i];\n r.data[i++] = c&this.DM;\n c >>= this.DB;\n }\n c += this.s;\n } else {\n c += this.s;\n while(i < a.t) {\n c -= a.data[i];\n r.data[i++] = c&this.DM;\n c >>= this.DB;\n }\n c -= a.s;\n }\n r.s = (c<0)?-1:0;\n if(c < -1) r.data[i++] = this.DV+c;\n else if(c > 0) r.data[i++] = c;\n r.t = i;\n r.clamp();\n}\n\n// (protected) r = this * a, r != this,a (HAC 14.12)\n// \"this\" should be the larger one if appropriate.\nfunction bnpMultiplyTo(a,r) {\n var x = this.abs(), y = a.abs();\n var i = x.t;\n r.t = i+y.t;\n while(--i >= 0) r.data[i] = 0;\n for(i = 0; i < y.t; ++i) r.data[i+x.t] = x.am(0,y.data[i],r,i,0,x.t);\n r.s = 0;\n r.clamp();\n if(this.s != a.s) BigInteger.ZERO.subTo(r,r);\n}\n\n// (protected) r = this^2, r != this (HAC 14.16)\nfunction bnpSquareTo(r) {\n var x = this.abs();\n var i = r.t = 2*x.t;\n while(--i >= 0) r.data[i] = 0;\n for(i = 0; i < x.t-1; ++i) {\n var c = x.am(i,x.data[i],r,2*i,0,1);\n if((r.data[i+x.t]+=x.am(i+1,2*x.data[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {\n r.data[i+x.t] -= x.DV;\n r.data[i+x.t+1] = 1;\n }\n }\n if(r.t > 0) r.data[r.t-1] += x.am(i,x.data[i],r,2*i,0,1);\n r.s = 0;\n r.clamp();\n}\n\n// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)\n// r != q, this != m. q or r may be null.\nfunction bnpDivRemTo(m,q,r) {\n var pm = m.abs();\n if(pm.t <= 0) return;\n var pt = this.abs();\n if(pt.t < pm.t) {\n if(q != null) q.fromInt(0);\n if(r != null) this.copyTo(r);\n return;\n }\n if(r == null) r = nbi();\n var y = nbi(), ts = this.s, ms = m.s;\n var nsh = this.DB-nbits(pm.data[pm.t-1]);\t// normalize modulus\n if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } else { pm.copyTo(y); pt.copyTo(r); }\n var ys = y.t;\n var y0 = y.data[ys-1];\n if(y0 == 0) return;\n var yt = y0*(1<1)?y.data[ys-2]>>this.F2:0);\n var d1 = this.FV/yt, d2 = (1<= 0) {\n r.data[r.t++] = 1;\n r.subTo(t,r);\n }\n BigInteger.ONE.dlShiftTo(ys,t);\n t.subTo(y,y);\t// \"negative\" y so we can replace sub with am later\n while(y.t < ys) y.data[y.t++] = 0;\n while(--j >= 0) {\n // Estimate quotient digit\n var qd = (r.data[--i]==y0)?this.DM:Math.floor(r.data[i]*d1+(r.data[i-1]+e)*d2);\n if((r.data[i]+=y.am(0,qd,r,j,0,ys)) < qd) {\t// Try it out\n y.dlShiftTo(j,t);\n r.subTo(t,r);\n while(r.data[i] < --qd) r.subTo(t,r);\n }\n }\n if(q != null) {\n r.drShiftTo(ys,q);\n if(ts != ms) BigInteger.ZERO.subTo(q,q);\n }\n r.t = ys;\n r.clamp();\n if(nsh > 0) r.rShiftTo(nsh,r);\t// Denormalize remainder\n if(ts < 0) BigInteger.ZERO.subTo(r,r);\n}\n\n// (public) this mod a\nfunction bnMod(a) {\n var r = nbi();\n this.abs().divRemTo(a,null,r);\n if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);\n return r;\n}\n\n// Modular reduction using \"classic\" algorithm\nfunction Classic(m) { this.m = m; }\nfunction cConvert(x) {\n if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);\n else return x;\n}\nfunction cRevert(x) { return x; }\nfunction cReduce(x) { x.divRemTo(this.m,null,x); }\nfunction cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }\nfunction cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }\n\nClassic.prototype.convert = cConvert;\nClassic.prototype.revert = cRevert;\nClassic.prototype.reduce = cReduce;\nClassic.prototype.mulTo = cMulTo;\nClassic.prototype.sqrTo = cSqrTo;\n\n// (protected) return \"-1/this % 2^DB\"; useful for Mont. reduction\n// justification:\n// xy == 1 (mod m)\n// xy = 1+km\n// xy(2-xy) = (1+km)(1-km)\n// x[y(2-xy)] = 1-k^2m^2\n// x[y(2-xy)] == 1 (mod m^2)\n// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2\n// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.\n// JS multiply \"overflows\" differently from C/C++, so care is needed here.\nfunction bnpInvDigit() {\n if(this.t < 1) return 0;\n var x = this.data[0];\n if((x&1) == 0) return 0;\n var y = x&3;\t\t// y == 1/x mod 2^2\n y = (y*(2-(x&0xf)*y))&0xf;\t// y == 1/x mod 2^4\n y = (y*(2-(x&0xff)*y))&0xff;\t// y == 1/x mod 2^8\n y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff;\t// y == 1/x mod 2^16\n // last step - calculate inverse mod DV directly;\n // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints\n y = (y*(2-x*y%this.DV))%this.DV;\t\t// y == 1/x mod 2^dbits\n // we really want the negative inverse, and -DV < y < DV\n return (y>0)?this.DV-y:-y;\n}\n\n// Montgomery reduction\nfunction Montgomery(m) {\n this.m = m;\n this.mp = m.invDigit();\n this.mpl = this.mp&0x7fff;\n this.mph = this.mp>>15;\n this.um = (1<<(m.DB-15))-1;\n this.mt2 = 2*m.t;\n}\n\n// xR mod m\nfunction montConvert(x) {\n var r = nbi();\n x.abs().dlShiftTo(this.m.t,r);\n r.divRemTo(this.m,null,r);\n if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);\n return r;\n}\n\n// x/R mod m\nfunction montRevert(x) {\n var r = nbi();\n x.copyTo(r);\n this.reduce(r);\n return r;\n}\n\n// x = x/R mod m (HAC 14.32)\nfunction montReduce(x) {\n while(x.t <= this.mt2)\t// pad x so am has enough room later\n x.data[x.t++] = 0;\n for(var i = 0; i < this.m.t; ++i) {\n // faster way of calculating u0 = x.data[i]*mp mod DV\n var j = x.data[i]&0x7fff;\n var u0 = (j*this.mpl+(((j*this.mph+(x.data[i]>>15)*this.mpl)&this.um)<<15))&x.DM;\n // use am to combine the multiply-shift-add into one call\n j = i+this.m.t;\n x.data[j] += this.m.am(0,u0,x,i,0,this.m.t);\n // propagate carry\n while(x.data[j] >= x.DV) { x.data[j] -= x.DV; x.data[++j]++; }\n }\n x.clamp();\n x.drShiftTo(this.m.t,x);\n if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);\n}\n\n// r = \"x^2/R mod m\"; x != r\nfunction montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }\n\n// r = \"xy/R mod m\"; x,y != r\nfunction montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }\n\nMontgomery.prototype.convert = montConvert;\nMontgomery.prototype.revert = montRevert;\nMontgomery.prototype.reduce = montReduce;\nMontgomery.prototype.mulTo = montMulTo;\nMontgomery.prototype.sqrTo = montSqrTo;\n\n// (protected) true iff this is even\nfunction bnpIsEven() { return ((this.t>0)?(this.data[0]&1):this.s) == 0; }\n\n// (protected) this^e, e < 2^32, doing sqr and mul with \"r\" (HAC 14.79)\nfunction bnpExp(e,z) {\n if(e > 0xffffffff || e < 1) return BigInteger.ONE;\n var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;\n g.copyTo(r);\n while(--i >= 0) {\n z.sqrTo(r,r2);\n if((e&(1< 0) z.mulTo(r2,g,r);\n else { var t = r; r = r2; r2 = t; }\n }\n return z.revert(r);\n}\n\n// (public) this^e % m, 0 <= e < 2^32\nfunction bnModPowInt(e,m) {\n var z;\n if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);\n return this.exp(e,z);\n}\n\n// protected\nBigInteger.prototype.copyTo = bnpCopyTo;\nBigInteger.prototype.fromInt = bnpFromInt;\nBigInteger.prototype.fromString = bnpFromString;\nBigInteger.prototype.clamp = bnpClamp;\nBigInteger.prototype.dlShiftTo = bnpDLShiftTo;\nBigInteger.prototype.drShiftTo = bnpDRShiftTo;\nBigInteger.prototype.lShiftTo = bnpLShiftTo;\nBigInteger.prototype.rShiftTo = bnpRShiftTo;\nBigInteger.prototype.subTo = bnpSubTo;\nBigInteger.prototype.multiplyTo = bnpMultiplyTo;\nBigInteger.prototype.squareTo = bnpSquareTo;\nBigInteger.prototype.divRemTo = bnpDivRemTo;\nBigInteger.prototype.invDigit = bnpInvDigit;\nBigInteger.prototype.isEven = bnpIsEven;\nBigInteger.prototype.exp = bnpExp;\n\n// public\nBigInteger.prototype.toString = bnToString;\nBigInteger.prototype.negate = bnNegate;\nBigInteger.prototype.abs = bnAbs;\nBigInteger.prototype.compareTo = bnCompareTo;\nBigInteger.prototype.bitLength = bnBitLength;\nBigInteger.prototype.mod = bnMod;\nBigInteger.prototype.modPowInt = bnModPowInt;\n\n// \"constants\"\nBigInteger.ZERO = nbv(0);\nBigInteger.ONE = nbv(1);\n\n// jsbn2 lib\n\n//Copyright (c) 2005-2009 Tom Wu\n//All Rights Reserved.\n//See \"LICENSE\" for details (See jsbn.js for LICENSE).\n\n//Extended JavaScript BN functions, required for RSA private ops.\n\n//Version 1.1: new BigInteger(\"0\", 10) returns \"proper\" zero\n\n//(public)\nfunction bnClone() { var r = nbi(); this.copyTo(r); return r; }\n\n//(public) return value as integer\nfunction bnIntValue() {\nif(this.s < 0) {\n if(this.t == 1) return this.data[0]-this.DV;\n else if(this.t == 0) return -1;\n} else if(this.t == 1) return this.data[0];\nelse if(this.t == 0) return 0;\n// assumes 16 < DB < 32\nreturn ((this.data[1]&((1<<(32-this.DB))-1))<>24; }\n\n//(public) return value as short (assumes DB>=16)\nfunction bnShortValue() { return (this.t==0)?this.s:(this.data[0]<<16)>>16; }\n\n//(protected) return x s.t. r^x < DV\nfunction bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }\n\n//(public) 0 if this == 0, 1 if this > 0\nfunction bnSigNum() {\nif(this.s < 0) return -1;\nelse if(this.t <= 0 || (this.t == 1 && this.data[0] <= 0)) return 0;\nelse return 1;\n}\n\n//(protected) convert to radix string\nfunction bnpToRadix(b) {\nif(b == null) b = 10;\nif(this.signum() == 0 || b < 2 || b > 36) return \"0\";\nvar cs = this.chunkSize(b);\nvar a = Math.pow(b,cs);\nvar d = nbv(a), y = nbi(), z = nbi(), r = \"\";\nthis.divRemTo(d,y,z);\nwhile(y.signum() > 0) {\n r = (a+z.intValue()).toString(b).substr(1) + r;\n y.divRemTo(d,y,z);\n}\nreturn z.intValue().toString(b) + r;\n}\n\n//(protected) convert from radix string\nfunction bnpFromRadix(s,b) {\nthis.fromInt(0);\nif(b == null) b = 10;\nvar cs = this.chunkSize(b);\nvar d = Math.pow(b,cs), mi = false, j = 0, w = 0;\nfor(var i = 0; i < s.length; ++i) {\n var x = intAt(s,i);\n if(x < 0) {\n if(s.charAt(i) == \"-\" && this.signum() == 0) mi = true;\n continue;\n }\n w = b*w+x;\n if(++j >= cs) {\n this.dMultiply(d);\n this.dAddOffset(w,0);\n j = 0;\n w = 0;\n }\n}\nif(j > 0) {\n this.dMultiply(Math.pow(b,j));\n this.dAddOffset(w,0);\n}\nif(mi) BigInteger.ZERO.subTo(this,this);\n}\n\n//(protected) alternate constructor\nfunction bnpFromNumber(a,b,c) {\nif(\"number\" == typeof b) {\n // new BigInteger(int,int,RNG)\n if(a < 2) this.fromInt(1);\n else {\n this.fromNumber(a,c);\n if(!this.testBit(a-1)) // force MSB set\n this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);\n if(this.isEven()) this.dAddOffset(1,0); // force odd\n while(!this.isProbablePrime(b)) {\n this.dAddOffset(2,0);\n if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this);\n }\n }\n} else {\n // new BigInteger(int,RNG)\n var x = new Array(), t = a&7;\n x.length = (a>>3)+1;\n b.nextBytes(x);\n if(t > 0) x[0] &= ((1< 0) {\n if(p < this.DB && (d = this.data[i]>>p) != (this.s&this.DM)>>p)\n r[k++] = d|(this.s<<(this.DB-p));\n while(i >= 0) {\n if(p < 8) {\n d = (this.data[i]&((1<>(p+=this.DB-8);\n } else {\n d = (this.data[i]>>(p-=8))&0xff;\n if(p <= 0) { p += this.DB; --i; }\n }\n if((d&0x80) != 0) d |= -256;\n if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;\n if(k > 0 || d != this.s) r[k++] = d;\n }\n}\nreturn r;\n}\n\nfunction bnEquals(a) { return(this.compareTo(a)==0); }\nfunction bnMin(a) { return(this.compareTo(a)<0)?this:a; }\nfunction bnMax(a) { return(this.compareTo(a)>0)?this:a; }\n\n//(protected) r = this op a (bitwise)\nfunction bnpBitwiseTo(a,op,r) {\nvar i, f, m = Math.min(a.t,this.t);\nfor(i = 0; i < m; ++i) r.data[i] = op(this.data[i],a.data[i]);\nif(a.t < this.t) {\n f = a.s&this.DM;\n for(i = m; i < this.t; ++i) r.data[i] = op(this.data[i],f);\n r.t = this.t;\n} else {\n f = this.s&this.DM;\n for(i = m; i < a.t; ++i) r.data[i] = op(f,a.data[i]);\n r.t = a.t;\n}\nr.s = op(this.s,a.s);\nr.clamp();\n}\n\n//(public) this & a\nfunction op_and(x,y) { return x&y; }\nfunction bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }\n\n//(public) this | a\nfunction op_or(x,y) { return x|y; }\nfunction bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }\n\n//(public) this ^ a\nfunction op_xor(x,y) { return x^y; }\nfunction bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }\n\n//(public) this & ~a\nfunction op_andnot(x,y) { return x&~y; }\nfunction bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }\n\n//(public) ~this\nfunction bnNot() {\nvar r = nbi();\nfor(var i = 0; i < this.t; ++i) r.data[i] = this.DM&~this.data[i];\nr.t = this.t;\nr.s = ~this.s;\nreturn r;\n}\n\n//(public) this << n\nfunction bnShiftLeft(n) {\nvar r = nbi();\nif(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);\nreturn r;\n}\n\n//(public) this >> n\nfunction bnShiftRight(n) {\nvar r = nbi();\nif(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);\nreturn r;\n}\n\n//return index of lowest 1-bit in x, x < 2^31\nfunction lbit(x) {\nif(x == 0) return -1;\nvar r = 0;\nif((x&0xffff) == 0) { x >>= 16; r += 16; }\nif((x&0xff) == 0) { x >>= 8; r += 8; }\nif((x&0xf) == 0) { x >>= 4; r += 4; }\nif((x&3) == 0) { x >>= 2; r += 2; }\nif((x&1) == 0) ++r;\nreturn r;\n}\n\n//(public) returns index of lowest 1-bit (or -1 if none)\nfunction bnGetLowestSetBit() {\nfor(var i = 0; i < this.t; ++i)\n if(this.data[i] != 0) return i*this.DB+lbit(this.data[i]);\nif(this.s < 0) return this.t*this.DB;\nreturn -1;\n}\n\n//return number of 1 bits in x\nfunction cbit(x) {\nvar r = 0;\nwhile(x != 0) { x &= x-1; ++r; }\nreturn r;\n}\n\n//(public) return number of set bits\nfunction bnBitCount() {\nvar r = 0, x = this.s&this.DM;\nfor(var i = 0; i < this.t; ++i) r += cbit(this.data[i]^x);\nreturn r;\n}\n\n//(public) true iff nth bit is set\nfunction bnTestBit(n) {\nvar j = Math.floor(n/this.DB);\nif(j >= this.t) return(this.s!=0);\nreturn((this.data[j]&(1<<(n%this.DB)))!=0);\n}\n\n//(protected) this op (1<>= this.DB;\n}\nif(a.t < this.t) {\n c += a.s;\n while(i < this.t) {\n c += this.data[i];\n r.data[i++] = c&this.DM;\n c >>= this.DB;\n }\n c += this.s;\n} else {\n c += this.s;\n while(i < a.t) {\n c += a.data[i];\n r.data[i++] = c&this.DM;\n c >>= this.DB;\n }\n c += a.s;\n}\nr.s = (c<0)?-1:0;\nif(c > 0) r.data[i++] = c;\nelse if(c < -1) r.data[i++] = this.DV+c;\nr.t = i;\nr.clamp();\n}\n\n//(public) this + a\nfunction bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }\n\n//(public) this - a\nfunction bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }\n\n//(public) this * a\nfunction bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }\n\n//(public) this / a\nfunction bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }\n\n//(public) this % a\nfunction bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }\n\n//(public) [this/a,this%a]\nfunction bnDivideAndRemainder(a) {\nvar q = nbi(), r = nbi();\nthis.divRemTo(a,q,r);\nreturn new Array(q,r);\n}\n\n//(protected) this *= n, this >= 0, 1 < n < DV\nfunction bnpDMultiply(n) {\nthis.data[this.t] = this.am(0,n-1,this,0,0,this.t);\n++this.t;\nthis.clamp();\n}\n\n//(protected) this += n << w words, this >= 0\nfunction bnpDAddOffset(n,w) {\nif(n == 0) return;\nwhile(this.t <= w) this.data[this.t++] = 0;\nthis.data[w] += n;\nwhile(this.data[w] >= this.DV) {\n this.data[w] -= this.DV;\n if(++w >= this.t) this.data[this.t++] = 0;\n ++this.data[w];\n}\n}\n\n//A \"null\" reducer\nfunction NullExp() {}\nfunction nNop(x) { return x; }\nfunction nMulTo(x,y,r) { x.multiplyTo(y,r); }\nfunction nSqrTo(x,r) { x.squareTo(r); }\n\nNullExp.prototype.convert = nNop;\nNullExp.prototype.revert = nNop;\nNullExp.prototype.mulTo = nMulTo;\nNullExp.prototype.sqrTo = nSqrTo;\n\n//(public) this^e\nfunction bnPow(e) { return this.exp(e,new NullExp()); }\n\n//(protected) r = lower n words of \"this * a\", a.t <= n\n//\"this\" should be the larger one if appropriate.\nfunction bnpMultiplyLowerTo(a,n,r) {\nvar i = Math.min(this.t+a.t,n);\nr.s = 0; // assumes a,this >= 0\nr.t = i;\nwhile(i > 0) r.data[--i] = 0;\nvar j;\nfor(j = r.t-this.t; i < j; ++i) r.data[i+this.t] = this.am(0,a.data[i],r,i,0,this.t);\nfor(j = Math.min(a.t,n); i < j; ++i) this.am(0,a.data[i],r,i,0,n-i);\nr.clamp();\n}\n\n//(protected) r = \"this * a\" without lower n words, n > 0\n//\"this\" should be the larger one if appropriate.\nfunction bnpMultiplyUpperTo(a,n,r) {\n--n;\nvar i = r.t = this.t+a.t-n;\nr.s = 0; // assumes a,this >= 0\nwhile(--i >= 0) r.data[i] = 0;\nfor(i = Math.max(n-this.t,0); i < a.t; ++i)\n r.data[this.t+i-n] = this.am(n-i,a.data[i],r,0,0,this.t+i-n);\nr.clamp();\nr.drShiftTo(1,r);\n}\n\n//Barrett modular reduction\nfunction Barrett(m) {\n// setup Barrett\nthis.r2 = nbi();\nthis.q3 = nbi();\nBigInteger.ONE.dlShiftTo(2*m.t,this.r2);\nthis.mu = this.r2.divide(m);\nthis.m = m;\n}\n\nfunction barrettConvert(x) {\nif(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);\nelse if(x.compareTo(this.m) < 0) return x;\nelse { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }\n}\n\nfunction barrettRevert(x) { return x; }\n\n//x = x mod m (HAC 14.42)\nfunction barrettReduce(x) {\nx.drShiftTo(this.m.t-1,this.r2);\nif(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); }\nthis.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);\nthis.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);\nwhile(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1);\nx.subTo(this.r2,x);\nwhile(x.compareTo(this.m) >= 0) x.subTo(this.m,x);\n}\n\n//r = x^2 mod m; x != r\nfunction barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }\n\n//r = x*y mod m; x,y != r\nfunction barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }\n\nBarrett.prototype.convert = barrettConvert;\nBarrett.prototype.revert = barrettRevert;\nBarrett.prototype.reduce = barrettReduce;\nBarrett.prototype.mulTo = barrettMulTo;\nBarrett.prototype.sqrTo = barrettSqrTo;\n\n//(public) this^e % m (HAC 14.85)\nfunction bnModPow(e,m) {\nvar i = e.bitLength(), k, r = nbv(1), z;\nif(i <= 0) return r;\nelse if(i < 18) k = 1;\nelse if(i < 48) k = 3;\nelse if(i < 144) k = 4;\nelse if(i < 768) k = 5;\nelse k = 6;\nif(i < 8)\n z = new Classic(m);\nelse if(m.isEven())\n z = new Barrett(m);\nelse\n z = new Montgomery(m);\n\n// precomputation\nvar g = new Array(), n = 3, k1 = k-1, km = (1< 1) {\n var g2 = nbi();\n z.sqrTo(g[1],g2);\n while(n <= km) {\n g[n] = nbi();\n z.mulTo(g2,g[n-2],g[n]);\n n += 2;\n }\n}\n\nvar j = e.t-1, w, is1 = true, r2 = nbi(), t;\ni = nbits(e.data[j])-1;\nwhile(j >= 0) {\n if(i >= k1) w = (e.data[j]>>(i-k1))&km;\n else {\n w = (e.data[j]&((1<<(i+1))-1))<<(k1-i);\n if(j > 0) w |= e.data[j-1]>>(this.DB+i-k1);\n }\n\n n = k;\n while((w&1) == 0) { w >>= 1; --n; }\n if((i -= n) < 0) { i += this.DB; --j; }\n if(is1) { // ret == 1, don't bother squaring or multiplying it\n g[w].copyTo(r);\n is1 = false;\n } else {\n while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }\n if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }\n z.mulTo(r2,g[w],r);\n }\n\n while(j >= 0 && (e.data[j]&(1< 0) {\n x.rShiftTo(g,x);\n y.rShiftTo(g,y);\n}\nwhile(x.signum() > 0) {\n if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);\n if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);\n if(x.compareTo(y) >= 0) {\n x.subTo(y,x);\n x.rShiftTo(1,x);\n } else {\n y.subTo(x,y);\n y.rShiftTo(1,y);\n }\n}\nif(g > 0) y.lShiftTo(g,y);\nreturn y;\n}\n\n//(protected) this % n, n < 2^26\nfunction bnpModInt(n) {\nif(n <= 0) return 0;\nvar d = this.DV%n, r = (this.s<0)?n-1:0;\nif(this.t > 0)\n if(d == 0) r = this.data[0]%n;\n else for(var i = this.t-1; i >= 0; --i) r = (d*r+this.data[i])%n;\nreturn r;\n}\n\n//(public) 1/this % m (HAC 14.61)\nfunction bnModInverse(m) {\nvar ac = m.isEven();\nif((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;\nvar u = m.clone(), v = this.clone();\nvar a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);\nwhile(u.signum() != 0) {\n while(u.isEven()) {\n u.rShiftTo(1,u);\n if(ac) {\n if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }\n a.rShiftTo(1,a);\n } else if(!b.isEven()) b.subTo(m,b);\n b.rShiftTo(1,b);\n }\n while(v.isEven()) {\n v.rShiftTo(1,v);\n if(ac) {\n if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }\n c.rShiftTo(1,c);\n } else if(!d.isEven()) d.subTo(m,d);\n d.rShiftTo(1,d);\n }\n if(u.compareTo(v) >= 0) {\n u.subTo(v,u);\n if(ac) a.subTo(c,a);\n b.subTo(d,b);\n } else {\n v.subTo(u,v);\n if(ac) c.subTo(a,c);\n d.subTo(b,d);\n }\n}\nif(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;\nif(d.compareTo(m) >= 0) return d.subtract(m);\nif(d.signum() < 0) d.addTo(m,d); else return d;\nif(d.signum() < 0) return d.add(m); else return d;\n}\n\nvar lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509];\nvar lplim = (1<<26)/lowprimes[lowprimes.length-1];\n\n//(public) test primality with certainty >= 1-.5^t\nfunction bnIsProbablePrime(t) {\nvar i, x = this.abs();\nif(x.t == 1 && x.data[0] <= lowprimes[lowprimes.length-1]) {\n for(i = 0; i < lowprimes.length; ++i)\n if(x.data[0] == lowprimes[i]) return true;\n return false;\n}\nif(x.isEven()) return false;\ni = 1;\nwhile(i < lowprimes.length) {\n var m = lowprimes[i], j = i+1;\n while(j < lowprimes.length && m < lplim) m *= lowprimes[j++];\n m = x.modInt(m);\n while(i < j) if(m%lowprimes[i++] == 0) return false;\n}\nreturn x.millerRabin(t);\n}\n\n//(protected) true if probably prime (HAC 4.24, Miller-Rabin)\nfunction bnpMillerRabin(t) {\nvar n1 = this.subtract(BigInteger.ONE);\nvar k = n1.getLowestSetBit();\nif(k <= 0) return false;\nvar r = n1.shiftRight(k);\nvar prng = bnGetPrng();\nvar a;\nfor(var i = 0; i < t; ++i) {\n // select witness 'a' at random from between 1 and n1\n do {\n a = new BigInteger(this.bitLength(), prng);\n }\n while(a.compareTo(BigInteger.ONE) <= 0 || a.compareTo(n1) >= 0);\n var y = a.modPow(r,this);\n if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {\n var j = 1;\n while(j++ < k && y.compareTo(n1) != 0) {\n y = y.modPowInt(2,this);\n if(y.compareTo(BigInteger.ONE) == 0) return false;\n }\n if(y.compareTo(n1) != 0) return false;\n }\n}\nreturn true;\n}\n\n// get pseudo random number generator\nfunction bnGetPrng() {\n // create prng with api that matches BigInteger secure random\n return {\n // x is an array to fill with bytes\n nextBytes: function(x) {\n for(var i = 0; i < x.length; ++i) {\n x[i] = Math.floor(Math.random() * 0x0100);\n }\n }\n };\n}\n\n//protected\nBigInteger.prototype.chunkSize = bnpChunkSize;\nBigInteger.prototype.toRadix = bnpToRadix;\nBigInteger.prototype.fromRadix = bnpFromRadix;\nBigInteger.prototype.fromNumber = bnpFromNumber;\nBigInteger.prototype.bitwiseTo = bnpBitwiseTo;\nBigInteger.prototype.changeBit = bnpChangeBit;\nBigInteger.prototype.addTo = bnpAddTo;\nBigInteger.prototype.dMultiply = bnpDMultiply;\nBigInteger.prototype.dAddOffset = bnpDAddOffset;\nBigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;\nBigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;\nBigInteger.prototype.modInt = bnpModInt;\nBigInteger.prototype.millerRabin = bnpMillerRabin;\n\n//public\nBigInteger.prototype.clone = bnClone;\nBigInteger.prototype.intValue = bnIntValue;\nBigInteger.prototype.byteValue = bnByteValue;\nBigInteger.prototype.shortValue = bnShortValue;\nBigInteger.prototype.signum = bnSigNum;\nBigInteger.prototype.toByteArray = bnToByteArray;\nBigInteger.prototype.equals = bnEquals;\nBigInteger.prototype.min = bnMin;\nBigInteger.prototype.max = bnMax;\nBigInteger.prototype.and = bnAnd;\nBigInteger.prototype.or = bnOr;\nBigInteger.prototype.xor = bnXor;\nBigInteger.prototype.andNot = bnAndNot;\nBigInteger.prototype.not = bnNot;\nBigInteger.prototype.shiftLeft = bnShiftLeft;\nBigInteger.prototype.shiftRight = bnShiftRight;\nBigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;\nBigInteger.prototype.bitCount = bnBitCount;\nBigInteger.prototype.testBit = bnTestBit;\nBigInteger.prototype.setBit = bnSetBit;\nBigInteger.prototype.clearBit = bnClearBit;\nBigInteger.prototype.flipBit = bnFlipBit;\nBigInteger.prototype.add = bnAdd;\nBigInteger.prototype.subtract = bnSubtract;\nBigInteger.prototype.multiply = bnMultiply;\nBigInteger.prototype.divide = bnDivide;\nBigInteger.prototype.remainder = bnRemainder;\nBigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;\nBigInteger.prototype.modPow = bnModPow;\nBigInteger.prototype.modInverse = bnModInverse;\nBigInteger.prototype.pow = bnPow;\nBigInteger.prototype.gcd = bnGCD;\nBigInteger.prototype.isProbablePrime = bnIsProbablePrime;\n\n//BigInteger interfaces not implemented in jsbn:\n\n//BigInteger(int signum, byte[] magnitude)\n//double doubleValue()\n//float floatValue()\n//int hashCode()\n//long longValue()\n//static BigInteger valueOf(long val)\n","/**\n * Javascript implementation of RSA-KEM.\n *\n * @author Lautaro Cozzani Rodriguez\n * @author Dave Longley\n *\n * Copyright (c) 2014 Lautaro Cozzani \n * Copyright (c) 2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\nrequire('./random');\nrequire('./jsbn');\n\nmodule.exports = forge.kem = forge.kem || {};\n\nvar BigInteger = forge.jsbn.BigInteger;\n\n/**\n * The API for the RSA Key Encapsulation Mechanism (RSA-KEM) from ISO 18033-2.\n */\nforge.kem.rsa = {};\n\n/**\n * Creates an RSA KEM API object for generating a secret asymmetric key.\n *\n * The symmetric key may be generated via a call to 'encrypt', which will\n * produce a ciphertext to be transmitted to the recipient and a key to be\n * kept secret. The ciphertext is a parameter to be passed to 'decrypt' which\n * will produce the same secret key for the recipient to use to decrypt a\n * message that was encrypted with the secret key.\n *\n * @param kdf the KDF API to use (eg: new forge.kem.kdf1()).\n * @param options the options to use.\n * [prng] a custom crypto-secure pseudo-random number generator to use,\n * that must define \"getBytesSync\".\n */\nforge.kem.rsa.create = function(kdf, options) {\n options = options || {};\n var prng = options.prng || forge.random;\n\n var kem = {};\n\n /**\n * Generates a secret key and its encapsulation.\n *\n * @param publicKey the RSA public key to encrypt with.\n * @param keyLength the length, in bytes, of the secret key to generate.\n *\n * @return an object with:\n * encapsulation: the ciphertext for generating the secret key, as a\n * binary-encoded string of bytes.\n * key: the secret key to use for encrypting a message.\n */\n kem.encrypt = function(publicKey, keyLength) {\n // generate a random r where 1 < r < n\n var byteLength = Math.ceil(publicKey.n.bitLength() / 8);\n var r;\n do {\n r = new BigInteger(\n forge.util.bytesToHex(prng.getBytesSync(byteLength)),\n 16).mod(publicKey.n);\n } while(r.compareTo(BigInteger.ONE) <= 0);\n\n // prepend r with zeros\n r = forge.util.hexToBytes(r.toString(16));\n var zeros = byteLength - r.length;\n if(zeros > 0) {\n r = forge.util.fillString(String.fromCharCode(0), zeros) + r;\n }\n\n // encrypt the random\n var encapsulation = publicKey.encrypt(r, 'NONE');\n\n // generate the secret key\n var key = kdf.generate(r, keyLength);\n\n return {encapsulation: encapsulation, key: key};\n };\n\n /**\n * Decrypts an encapsulated secret key.\n *\n * @param privateKey the RSA private key to decrypt with.\n * @param encapsulation the ciphertext for generating the secret key, as\n * a binary-encoded string of bytes.\n * @param keyLength the length, in bytes, of the secret key to generate.\n *\n * @return the secret key as a binary-encoded string of bytes.\n */\n kem.decrypt = function(privateKey, encapsulation, keyLength) {\n // decrypt the encapsulation and generate the secret key\n var r = privateKey.decrypt(encapsulation, 'NONE');\n return kdf.generate(r, keyLength);\n };\n\n return kem;\n};\n\n// TODO: add forge.kem.kdf.create('KDF1', {md: ..., ...}) API?\n\n/**\n * Creates a key derivation API object that implements KDF1 per ISO 18033-2.\n *\n * @param md the hash API to use.\n * @param [digestLength] an optional digest length that must be positive and\n * less than or equal to md.digestLength.\n *\n * @return a KDF1 API object.\n */\nforge.kem.kdf1 = function(md, digestLength) {\n _createKDF(this, md, 0, digestLength || md.digestLength);\n};\n\n/**\n * Creates a key derivation API object that implements KDF2 per ISO 18033-2.\n *\n * @param md the hash API to use.\n * @param [digestLength] an optional digest length that must be positive and\n * less than or equal to md.digestLength.\n *\n * @return a KDF2 API object.\n */\nforge.kem.kdf2 = function(md, digestLength) {\n _createKDF(this, md, 1, digestLength || md.digestLength);\n};\n\n/**\n * Creates a KDF1 or KDF2 API object.\n *\n * @param md the hash API to use.\n * @param counterStart the starting index for the counter.\n * @param digestLength the digest length to use.\n *\n * @return the KDF API object.\n */\nfunction _createKDF(kdf, md, counterStart, digestLength) {\n /**\n * Generate a key of the specified length.\n *\n * @param x the binary-encoded byte string to generate a key from.\n * @param length the number of bytes to generate (the size of the key).\n *\n * @return the key as a binary-encoded string.\n */\n kdf.generate = function(x, length) {\n var key = new forge.util.ByteBuffer();\n\n // run counter from counterStart to ceil(length / Hash.len)\n var k = Math.ceil(length / digestLength) + counterStart;\n\n var c = new forge.util.ByteBuffer();\n for(var i = counterStart; i < k; ++i) {\n // I2OSP(i, 4): convert counter to an octet string of 4 octets\n c.putInt32(i);\n\n // digest 'x' and the counter and add the result to the key\n md.start();\n md.update(x + c.getBytes());\n var hash = md.digest();\n key.putBytes(hash.getBytes(digestLength));\n }\n\n // truncate to the correct key length\n key.truncate(key.length() - length);\n return key.getBytes();\n };\n}\n","/**\n * Cross-browser support for logging in a web application.\n *\n * @author David I. Lehn \n *\n * Copyright (c) 2008-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\n/* LOG API */\nmodule.exports = forge.log = forge.log || {};\n\n/**\n * Application logging system.\n *\n * Each logger level available as it's own function of the form:\n * forge.log.level(category, args...)\n * The category is an arbitrary string, and the args are the same as\n * Firebug's console.log API. By default the call will be output as:\n * 'LEVEL [category] , args[1], ...'\n * This enables proper % formatting via the first argument.\n * Each category is enabled by default but can be enabled or disabled with\n * the setCategoryEnabled() function.\n */\n// list of known levels\nforge.log.levels = [\n 'none', 'error', 'warning', 'info', 'debug', 'verbose', 'max'];\n// info on the levels indexed by name:\n// index: level index\n// name: uppercased display name\nvar sLevelInfo = {};\n// list of loggers\nvar sLoggers = [];\n/**\n * Standard console logger. If no console support is enabled this will\n * remain null. Check before using.\n */\nvar sConsoleLogger = null;\n\n// logger flags\n/**\n * Lock the level at the current value. Used in cases where user config may\n * set the level such that only critical messages are seen but more verbose\n * messages are needed for debugging or other purposes.\n */\nforge.log.LEVEL_LOCKED = (1 << 1);\n/**\n * Always call log function. By default, the logging system will check the\n * message level against logger.level before calling the log function. This\n * flag allows the function to do its own check.\n */\nforge.log.NO_LEVEL_CHECK = (1 << 2);\n/**\n * Perform message interpolation with the passed arguments. \"%\" style\n * fields in log messages will be replaced by arguments as needed. Some\n * loggers, such as Firebug, may do this automatically. The original log\n * message will be available as 'message' and the interpolated version will\n * be available as 'fullMessage'.\n */\nforge.log.INTERPOLATE = (1 << 3);\n\n// setup each log level\nfor(var i = 0; i < forge.log.levels.length; ++i) {\n var level = forge.log.levels[i];\n sLevelInfo[level] = {\n index: i,\n name: level.toUpperCase()\n };\n}\n\n/**\n * Message logger. Will dispatch a message to registered loggers as needed.\n *\n * @param message message object\n */\nforge.log.logMessage = function(message) {\n var messageLevelIndex = sLevelInfo[message.level].index;\n for(var i = 0; i < sLoggers.length; ++i) {\n var logger = sLoggers[i];\n if(logger.flags & forge.log.NO_LEVEL_CHECK) {\n logger.f(message);\n } else {\n // get logger level\n var loggerLevelIndex = sLevelInfo[logger.level].index;\n // check level\n if(messageLevelIndex <= loggerLevelIndex) {\n // message critical enough, call logger\n logger.f(logger, message);\n }\n }\n }\n};\n\n/**\n * Sets the 'standard' key on a message object to:\n * \"LEVEL [category] \" + message\n *\n * @param message a message log object\n */\nforge.log.prepareStandard = function(message) {\n if(!('standard' in message)) {\n message.standard =\n sLevelInfo[message.level].name +\n //' ' + +message.timestamp +\n ' [' + message.category + '] ' +\n message.message;\n }\n};\n\n/**\n * Sets the 'full' key on a message object to the original message\n * interpolated via % formatting with the message arguments.\n *\n * @param message a message log object.\n */\nforge.log.prepareFull = function(message) {\n if(!('full' in message)) {\n // copy args and insert message at the front\n var args = [message.message];\n args = args.concat([] || message['arguments']);\n // format the message\n message.full = forge.util.format.apply(this, args);\n }\n};\n\n/**\n * Applies both preparseStandard() and prepareFull() to a message object and\n * store result in 'standardFull'.\n *\n * @param message a message log object.\n */\nforge.log.prepareStandardFull = function(message) {\n if(!('standardFull' in message)) {\n // FIXME implement 'standardFull' logging\n forge.log.prepareStandard(message);\n message.standardFull = message.standard;\n }\n};\n\n// create log level functions\nif(true) {\n // levels for which we want functions\n var levels = ['error', 'warning', 'info', 'debug', 'verbose'];\n for(var i = 0; i < levels.length; ++i) {\n // wrap in a function to ensure proper level var is passed\n (function(level) {\n // create function for this level\n forge.log[level] = function(category, message/*, args...*/) {\n // convert arguments to real array, remove category and message\n var args = Array.prototype.slice.call(arguments).slice(2);\n // create message object\n // Note: interpolation and standard formatting is done lazily\n var msg = {\n timestamp: new Date(),\n level: level,\n category: category,\n message: message,\n 'arguments': args\n /*standard*/\n /*full*/\n /*fullMessage*/\n };\n // process this message\n forge.log.logMessage(msg);\n };\n })(levels[i]);\n }\n}\n\n/**\n * Creates a new logger with specified custom logging function.\n *\n * The logging function has a signature of:\n * function(logger, message)\n * logger: current logger\n * message: object:\n * level: level id\n * category: category\n * message: string message\n * arguments: Array of extra arguments\n * fullMessage: interpolated message and arguments if INTERPOLATE flag set\n *\n * @param logFunction a logging function which takes a log message object\n * as a parameter.\n *\n * @return a logger object.\n */\nforge.log.makeLogger = function(logFunction) {\n var logger = {\n flags: 0,\n f: logFunction\n };\n forge.log.setLevel(logger, 'none');\n return logger;\n};\n\n/**\n * Sets the current log level on a logger.\n *\n * @param logger the target logger.\n * @param level the new maximum log level as a string.\n *\n * @return true if set, false if not.\n */\nforge.log.setLevel = function(logger, level) {\n var rval = false;\n if(logger && !(logger.flags & forge.log.LEVEL_LOCKED)) {\n for(var i = 0; i < forge.log.levels.length; ++i) {\n var aValidLevel = forge.log.levels[i];\n if(level == aValidLevel) {\n // set level\n logger.level = level;\n rval = true;\n break;\n }\n }\n }\n\n return rval;\n};\n\n/**\n * Locks the log level at its current value.\n *\n * @param logger the target logger.\n * @param lock boolean lock value, default to true.\n */\nforge.log.lock = function(logger, lock) {\n if(typeof lock === 'undefined' || lock) {\n logger.flags |= forge.log.LEVEL_LOCKED;\n } else {\n logger.flags &= ~forge.log.LEVEL_LOCKED;\n }\n};\n\n/**\n * Adds a logger.\n *\n * @param logger the logger object.\n */\nforge.log.addLogger = function(logger) {\n sLoggers.push(logger);\n};\n\n// setup the console logger if possible, else create fake console.log\nif(typeof(console) !== 'undefined' && 'log' in console) {\n var logger;\n if(console.error && console.warn && console.info && console.debug) {\n // looks like Firebug-style logging is available\n // level handlers map\n var levelHandlers = {\n error: console.error,\n warning: console.warn,\n info: console.info,\n debug: console.debug,\n verbose: console.debug\n };\n var f = function(logger, message) {\n forge.log.prepareStandard(message);\n var handler = levelHandlers[message.level];\n // prepend standard message and concat args\n var args = [message.standard];\n args = args.concat(message['arguments'].slice());\n // apply to low-level console function\n handler.apply(console, args);\n };\n logger = forge.log.makeLogger(f);\n } else {\n // only appear to have basic console.log\n var f = function(logger, message) {\n forge.log.prepareStandardFull(message);\n console.log(message.standardFull);\n };\n logger = forge.log.makeLogger(f);\n }\n forge.log.setLevel(logger, 'debug');\n forge.log.addLogger(logger);\n sConsoleLogger = logger;\n} else {\n // define fake console.log to avoid potential script errors on\n // browsers that do not have console logging\n console = {\n log: function() {}\n };\n}\n\n/*\n * Check for logging control query vars.\n *\n * console.level=\n * Set's the console log level by name. Useful to override defaults and\n * allow more verbose logging before a user config is loaded.\n *\n * console.lock=\n * Lock the console log level at whatever level it is set at. This is run\n * after console.level is processed. Useful to force a level of verbosity\n * that could otherwise be limited by a user config.\n */\nif(sConsoleLogger !== null) {\n var query = forge.util.getQueryVariables();\n if('console.level' in query) {\n // set with last value\n forge.log.setLevel(\n sConsoleLogger, query['console.level'].slice(-1)[0]);\n }\n if('console.lock' in query) {\n // set with last value\n var lock = query['console.lock'].slice(-1)[0];\n if(lock == 'true') {\n forge.log.lock(sConsoleLogger);\n }\n }\n}\n\n// provide public access to console logger\nforge.log.consoleLogger = sConsoleLogger;\n","/**\n * Node.js module for all known Forge message digests.\n *\n * @author Dave Longley\n *\n * Copyright 2011-2017 Digital Bazaar, Inc.\n */\nmodule.exports = require('./md');\n\nrequire('./md5');\nrequire('./sha1');\nrequire('./sha256');\nrequire('./sha512');\n","/**\n * Node.js module for Forge message digests.\n *\n * @author Dave Longley\n *\n * Copyright 2011-2017 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\n\nmodule.exports = forge.md = forge.md || {};\nforge.md.algorithms = forge.md.algorithms || {};\n","/**\n * Message Digest Algorithm 5 with 128-bit digest (MD5) implementation.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\nvar md5 = module.exports = forge.md5 = forge.md5 || {};\nforge.md.md5 = forge.md.algorithms.md5 = md5;\n\n/**\n * Creates an MD5 message digest object.\n *\n * @return a message digest object.\n */\nmd5.create = function() {\n // do initialization as necessary\n if(!_initialized) {\n _init();\n }\n\n // MD5 state contains four 32-bit integers\n var _state = null;\n\n // input buffer\n var _input = forge.util.createBuffer();\n\n // used for word storage\n var _w = new Array(16);\n\n // message digest object\n var md = {\n algorithm: 'md5',\n blockLength: 64,\n digestLength: 16,\n // 56-bit length of message so far (does not including padding)\n messageLength: 0,\n // true message length\n fullMessageLength: null,\n // size of message length in bytes\n messageLengthSize: 8\n };\n\n /**\n * Starts the digest.\n *\n * @return this digest object.\n */\n md.start = function() {\n // up to 56-bit message length for convenience\n md.messageLength = 0;\n\n // full message length (set md.messageLength64 for backwards-compatibility)\n md.fullMessageLength = md.messageLength64 = [];\n var int32s = md.messageLengthSize / 4;\n for(var i = 0; i < int32s; ++i) {\n md.fullMessageLength.push(0);\n }\n _input = forge.util.createBuffer();\n _state = {\n h0: 0x67452301,\n h1: 0xEFCDAB89,\n h2: 0x98BADCFE,\n h3: 0x10325476\n };\n return md;\n };\n // start digest automatically for first time\n md.start();\n\n /**\n * Updates the digest with the given message input. The given input can\n * treated as raw input (no encoding will be applied) or an encoding of\n * 'utf8' maybe given to encode the input using UTF-8.\n *\n * @param msg the message input to update with.\n * @param encoding the encoding to use (default: 'raw', other: 'utf8').\n *\n * @return this digest object.\n */\n md.update = function(msg, encoding) {\n if(encoding === 'utf8') {\n msg = forge.util.encodeUtf8(msg);\n }\n\n // update message length\n var len = msg.length;\n md.messageLength += len;\n len = [(len / 0x100000000) >>> 0, len >>> 0];\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n md.fullMessageLength[i] += len[1];\n len[1] = len[0] + ((md.fullMessageLength[i] / 0x100000000) >>> 0);\n md.fullMessageLength[i] = md.fullMessageLength[i] >>> 0;\n len[0] = (len[1] / 0x100000000) >>> 0;\n }\n\n // add bytes to input buffer\n _input.putBytes(msg);\n\n // process bytes\n _update(_state, _w, _input);\n\n // compact input buffer every 2K or if empty\n if(_input.read > 2048 || _input.length() === 0) {\n _input.compact();\n }\n\n return md;\n };\n\n /**\n * Produces the digest.\n *\n * @return a byte buffer containing the digest value.\n */\n md.digest = function() {\n /* Note: Here we copy the remaining bytes in the input buffer and\n add the appropriate MD5 padding. Then we do the final update\n on a copy of the state so that if the user wants to get\n intermediate digests they can do so. */\n\n /* Determine the number of bytes that must be added to the message\n to ensure its length is congruent to 448 mod 512. In other words,\n the data to be digested must be a multiple of 512 bits (or 128 bytes).\n This data includes the message, some padding, and the length of the\n message. Since the length of the message will be encoded as 8 bytes (64\n bits), that means that the last segment of the data must have 56 bytes\n (448 bits) of message and padding. Therefore, the length of the message\n plus the padding must be congruent to 448 mod 512 because\n 512 - 128 = 448.\n\n In order to fill up the message length it must be filled with\n padding that begins with 1 bit followed by all 0 bits. Padding\n must *always* be present, so if the message length is already\n congruent to 448 mod 512, then 512 padding bits must be added. */\n\n var finalBlock = forge.util.createBuffer();\n finalBlock.putBytes(_input.bytes());\n\n // compute remaining size to be digested (include message length size)\n var remaining = (\n md.fullMessageLength[md.fullMessageLength.length - 1] +\n md.messageLengthSize);\n\n // add padding for overflow blockSize - overflow\n // _padding starts with 1 byte with first bit is set (byte value 128), then\n // there may be up to (blockSize - 1) other pad bytes\n var overflow = remaining & (md.blockLength - 1);\n finalBlock.putBytes(_padding.substr(0, md.blockLength - overflow));\n\n // serialize message length in bits in little-endian order; since length\n // is stored in bytes we multiply by 8 and add carry\n var bits, carry = 0;\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n bits = md.fullMessageLength[i] * 8 + carry;\n carry = (bits / 0x100000000) >>> 0;\n finalBlock.putInt32Le(bits >>> 0);\n }\n\n var s2 = {\n h0: _state.h0,\n h1: _state.h1,\n h2: _state.h2,\n h3: _state.h3\n };\n _update(s2, _w, finalBlock);\n var rval = forge.util.createBuffer();\n rval.putInt32Le(s2.h0);\n rval.putInt32Le(s2.h1);\n rval.putInt32Le(s2.h2);\n rval.putInt32Le(s2.h3);\n return rval;\n };\n\n return md;\n};\n\n// padding, constant tables for calculating md5\nvar _padding = null;\nvar _g = null;\nvar _r = null;\nvar _k = null;\nvar _initialized = false;\n\n/**\n * Initializes the constant tables.\n */\nfunction _init() {\n // create padding\n _padding = String.fromCharCode(128);\n _padding += forge.util.fillString(String.fromCharCode(0x00), 64);\n\n // g values\n _g = [\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12,\n 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2,\n 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9];\n\n // rounds table\n _r = [\n 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,\n 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,\n 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,\n 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21];\n\n // get the result of abs(sin(i + 1)) as a 32-bit integer\n _k = new Array(64);\n for(var i = 0; i < 64; ++i) {\n _k[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 0x100000000);\n }\n\n // now initialized\n _initialized = true;\n}\n\n/**\n * Updates an MD5 state with the given byte buffer.\n *\n * @param s the MD5 state to update.\n * @param w the array to use to store words.\n * @param bytes the byte buffer to update with.\n */\nfunction _update(s, w, bytes) {\n // consume 512 bit (64 byte) chunks\n var t, a, b, c, d, f, r, i;\n var len = bytes.length();\n while(len >= 64) {\n // initialize hash value for this chunk\n a = s.h0;\n b = s.h1;\n c = s.h2;\n d = s.h3;\n\n // round 1\n for(i = 0; i < 16; ++i) {\n w[i] = bytes.getInt32Le();\n f = d ^ (b & (c ^ d));\n t = (a + f + _k[i] + w[i]);\n r = _r[i];\n a = d;\n d = c;\n c = b;\n b += (t << r) | (t >>> (32 - r));\n }\n // round 2\n for(; i < 32; ++i) {\n f = c ^ (d & (b ^ c));\n t = (a + f + _k[i] + w[_g[i]]);\n r = _r[i];\n a = d;\n d = c;\n c = b;\n b += (t << r) | (t >>> (32 - r));\n }\n // round 3\n for(; i < 48; ++i) {\n f = b ^ c ^ d;\n t = (a + f + _k[i] + w[_g[i]]);\n r = _r[i];\n a = d;\n d = c;\n c = b;\n b += (t << r) | (t >>> (32 - r));\n }\n // round 4\n for(; i < 64; ++i) {\n f = c ^ (b | ~d);\n t = (a + f + _k[i] + w[_g[i]]);\n r = _r[i];\n a = d;\n d = c;\n c = b;\n b += (t << r) | (t >>> (32 - r));\n }\n\n // update hash state\n s.h0 = (s.h0 + a) | 0;\n s.h1 = (s.h1 + b) | 0;\n s.h2 = (s.h2 + c) | 0;\n s.h3 = (s.h3 + d) | 0;\n\n len -= 64;\n }\n}\n","/**\n * Node.js module for Forge mask generation functions.\n *\n * @author Stefan Siegl\n *\n * Copyright 2012 Stefan Siegl \n */\nvar forge = require('./forge');\nrequire('./mgf1');\n\nmodule.exports = forge.mgf = forge.mgf || {};\nforge.mgf.mgf1 = forge.mgf1;\n","/**\n * Javascript implementation of mask generation function MGF1.\n *\n * @author Stefan Siegl\n * @author Dave Longley\n *\n * Copyright (c) 2012 Stefan Siegl \n * Copyright (c) 2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\nforge.mgf = forge.mgf || {};\nvar mgf1 = module.exports = forge.mgf.mgf1 = forge.mgf1 = forge.mgf1 || {};\n\n/**\n * Creates a MGF1 mask generation function object.\n *\n * @param md the message digest API to use (eg: forge.md.sha1.create()).\n *\n * @return a mask generation function object.\n */\nmgf1.create = function(md) {\n var mgf = {\n /**\n * Generate mask of specified length.\n *\n * @param {String} seed The seed for mask generation.\n * @param maskLen Number of bytes to generate.\n * @return {String} The generated mask.\n */\n generate: function(seed, maskLen) {\n /* 2. Let T be the empty octet string. */\n var t = new forge.util.ByteBuffer();\n\n /* 3. For counter from 0 to ceil(maskLen / hLen), do the following: */\n var len = Math.ceil(maskLen / md.digestLength);\n for(var i = 0; i < len; i++) {\n /* a. Convert counter to an octet string C of length 4 octets */\n var c = new forge.util.ByteBuffer();\n c.putInt32(i);\n\n /* b. Concatenate the hash of the seed mgfSeed and C to the octet\n * string T: */\n md.start();\n md.update(seed + c.getBytes());\n t.putBuffer(md.digest());\n }\n\n /* Output the leading maskLen octets of T as the octet string mask. */\n t.truncate(t.length() - maskLen);\n return t.getBytes();\n }\n };\n\n return mgf;\n};\n","/**\n * Object IDs for ASN.1.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\n\nforge.pki = forge.pki || {};\nvar oids = module.exports = forge.pki.oids = forge.oids = forge.oids || {};\n\n// set id to name mapping and name to id mapping\nfunction _IN(id, name) {\n oids[id] = name;\n oids[name] = id;\n}\n// set id to name mapping only\nfunction _I_(id, name) {\n oids[id] = name;\n}\n\n// algorithm OIDs\n_IN('1.2.840.113549.1.1.1', 'rsaEncryption');\n// Note: md2 & md4 not implemented\n//_IN('1.2.840.113549.1.1.2', 'md2WithRSAEncryption');\n//_IN('1.2.840.113549.1.1.3', 'md4WithRSAEncryption');\n_IN('1.2.840.113549.1.1.4', 'md5WithRSAEncryption');\n_IN('1.2.840.113549.1.1.5', 'sha1WithRSAEncryption');\n_IN('1.2.840.113549.1.1.7', 'RSAES-OAEP');\n_IN('1.2.840.113549.1.1.8', 'mgf1');\n_IN('1.2.840.113549.1.1.9', 'pSpecified');\n_IN('1.2.840.113549.1.1.10', 'RSASSA-PSS');\n_IN('1.2.840.113549.1.1.11', 'sha256WithRSAEncryption');\n_IN('1.2.840.113549.1.1.12', 'sha384WithRSAEncryption');\n_IN('1.2.840.113549.1.1.13', 'sha512WithRSAEncryption');\n// Edwards-curve Digital Signature Algorithm (EdDSA) Ed25519\n_IN('1.3.101.112', 'EdDSA25519');\n\n_IN('1.2.840.10040.4.3', 'dsa-with-sha1');\n\n_IN('1.3.14.3.2.7', 'desCBC');\n\n_IN('1.3.14.3.2.26', 'sha1');\n_IN('2.16.840.1.101.3.4.2.1', 'sha256');\n_IN('2.16.840.1.101.3.4.2.2', 'sha384');\n_IN('2.16.840.1.101.3.4.2.3', 'sha512');\n_IN('1.2.840.113549.2.5', 'md5');\n\n// pkcs#7 content types\n_IN('1.2.840.113549.1.7.1', 'data');\n_IN('1.2.840.113549.1.7.2', 'signedData');\n_IN('1.2.840.113549.1.7.3', 'envelopedData');\n_IN('1.2.840.113549.1.7.4', 'signedAndEnvelopedData');\n_IN('1.2.840.113549.1.7.5', 'digestedData');\n_IN('1.2.840.113549.1.7.6', 'encryptedData');\n\n// pkcs#9 oids\n_IN('1.2.840.113549.1.9.1', 'emailAddress');\n_IN('1.2.840.113549.1.9.2', 'unstructuredName');\n_IN('1.2.840.113549.1.9.3', 'contentType');\n_IN('1.2.840.113549.1.9.4', 'messageDigest');\n_IN('1.2.840.113549.1.9.5', 'signingTime');\n_IN('1.2.840.113549.1.9.6', 'counterSignature');\n_IN('1.2.840.113549.1.9.7', 'challengePassword');\n_IN('1.2.840.113549.1.9.8', 'unstructuredAddress');\n_IN('1.2.840.113549.1.9.14', 'extensionRequest');\n\n_IN('1.2.840.113549.1.9.20', 'friendlyName');\n_IN('1.2.840.113549.1.9.21', 'localKeyId');\n_IN('1.2.840.113549.1.9.22.1', 'x509Certificate');\n\n// pkcs#12 safe bags\n_IN('1.2.840.113549.1.12.10.1.1', 'keyBag');\n_IN('1.2.840.113549.1.12.10.1.2', 'pkcs8ShroudedKeyBag');\n_IN('1.2.840.113549.1.12.10.1.3', 'certBag');\n_IN('1.2.840.113549.1.12.10.1.4', 'crlBag');\n_IN('1.2.840.113549.1.12.10.1.5', 'secretBag');\n_IN('1.2.840.113549.1.12.10.1.6', 'safeContentsBag');\n\n// password-based-encryption for pkcs#12\n_IN('1.2.840.113549.1.5.13', 'pkcs5PBES2');\n_IN('1.2.840.113549.1.5.12', 'pkcs5PBKDF2');\n\n_IN('1.2.840.113549.1.12.1.1', 'pbeWithSHAAnd128BitRC4');\n_IN('1.2.840.113549.1.12.1.2', 'pbeWithSHAAnd40BitRC4');\n_IN('1.2.840.113549.1.12.1.3', 'pbeWithSHAAnd3-KeyTripleDES-CBC');\n_IN('1.2.840.113549.1.12.1.4', 'pbeWithSHAAnd2-KeyTripleDES-CBC');\n_IN('1.2.840.113549.1.12.1.5', 'pbeWithSHAAnd128BitRC2-CBC');\n_IN('1.2.840.113549.1.12.1.6', 'pbewithSHAAnd40BitRC2-CBC');\n\n// hmac OIDs\n_IN('1.2.840.113549.2.7', 'hmacWithSHA1');\n_IN('1.2.840.113549.2.8', 'hmacWithSHA224');\n_IN('1.2.840.113549.2.9', 'hmacWithSHA256');\n_IN('1.2.840.113549.2.10', 'hmacWithSHA384');\n_IN('1.2.840.113549.2.11', 'hmacWithSHA512');\n\n// symmetric key algorithm oids\n_IN('1.2.840.113549.3.7', 'des-EDE3-CBC');\n_IN('2.16.840.1.101.3.4.1.2', 'aes128-CBC');\n_IN('2.16.840.1.101.3.4.1.22', 'aes192-CBC');\n_IN('2.16.840.1.101.3.4.1.42', 'aes256-CBC');\n\n// certificate issuer/subject OIDs\n_IN('2.5.4.3', 'commonName');\n_IN('2.5.4.5', 'serialName');\n_IN('2.5.4.6', 'countryName');\n_IN('2.5.4.7', 'localityName');\n_IN('2.5.4.8', 'stateOrProvinceName');\n_IN('2.5.4.9', 'streetAddress');\n_IN('2.5.4.10', 'organizationName');\n_IN('2.5.4.11', 'organizationalUnitName');\n_IN('2.5.4.13', 'description');\n_IN('2.5.4.15', 'businessCategory');\n_IN('2.5.4.17', 'postalCode');\n_IN('1.3.6.1.4.1.311.60.2.1.2', 'jurisdictionOfIncorporationStateOrProvinceName');\n_IN('1.3.6.1.4.1.311.60.2.1.3', 'jurisdictionOfIncorporationCountryName');\n\n// X.509 extension OIDs\n_IN('2.16.840.1.113730.1.1', 'nsCertType');\n_IN('2.16.840.1.113730.1.13', 'nsComment'); // deprecated in theory; still widely used\n_I_('2.5.29.1', 'authorityKeyIdentifier'); // deprecated, use .35\n_I_('2.5.29.2', 'keyAttributes'); // obsolete use .37 or .15\n_I_('2.5.29.3', 'certificatePolicies'); // deprecated, use .32\n_I_('2.5.29.4', 'keyUsageRestriction'); // obsolete use .37 or .15\n_I_('2.5.29.5', 'policyMapping'); // deprecated use .33\n_I_('2.5.29.6', 'subtreesConstraint'); // obsolete use .30\n_I_('2.5.29.7', 'subjectAltName'); // deprecated use .17\n_I_('2.5.29.8', 'issuerAltName'); // deprecated use .18\n_I_('2.5.29.9', 'subjectDirectoryAttributes');\n_I_('2.5.29.10', 'basicConstraints'); // deprecated use .19\n_I_('2.5.29.11', 'nameConstraints'); // deprecated use .30\n_I_('2.5.29.12', 'policyConstraints'); // deprecated use .36\n_I_('2.5.29.13', 'basicConstraints'); // deprecated use .19\n_IN('2.5.29.14', 'subjectKeyIdentifier');\n_IN('2.5.29.15', 'keyUsage');\n_I_('2.5.29.16', 'privateKeyUsagePeriod');\n_IN('2.5.29.17', 'subjectAltName');\n_IN('2.5.29.18', 'issuerAltName');\n_IN('2.5.29.19', 'basicConstraints');\n_I_('2.5.29.20', 'cRLNumber');\n_I_('2.5.29.21', 'cRLReason');\n_I_('2.5.29.22', 'expirationDate');\n_I_('2.5.29.23', 'instructionCode');\n_I_('2.5.29.24', 'invalidityDate');\n_I_('2.5.29.25', 'cRLDistributionPoints'); // deprecated use .31\n_I_('2.5.29.26', 'issuingDistributionPoint'); // deprecated use .28\n_I_('2.5.29.27', 'deltaCRLIndicator');\n_I_('2.5.29.28', 'issuingDistributionPoint');\n_I_('2.5.29.29', 'certificateIssuer');\n_I_('2.5.29.30', 'nameConstraints');\n_IN('2.5.29.31', 'cRLDistributionPoints');\n_IN('2.5.29.32', 'certificatePolicies');\n_I_('2.5.29.33', 'policyMappings');\n_I_('2.5.29.34', 'policyConstraints'); // deprecated use .36\n_IN('2.5.29.35', 'authorityKeyIdentifier');\n_I_('2.5.29.36', 'policyConstraints');\n_IN('2.5.29.37', 'extKeyUsage');\n_I_('2.5.29.46', 'freshestCRL');\n_I_('2.5.29.54', 'inhibitAnyPolicy');\n\n// extKeyUsage purposes\n_IN('1.3.6.1.4.1.11129.2.4.2', 'timestampList');\n_IN('1.3.6.1.5.5.7.1.1', 'authorityInfoAccess');\n_IN('1.3.6.1.5.5.7.3.1', 'serverAuth');\n_IN('1.3.6.1.5.5.7.3.2', 'clientAuth');\n_IN('1.3.6.1.5.5.7.3.3', 'codeSigning');\n_IN('1.3.6.1.5.5.7.3.4', 'emailProtection');\n_IN('1.3.6.1.5.5.7.3.8', 'timeStamping');\n","/**\n * Password-based encryption functions.\n *\n * @author Dave Longley\n * @author Stefan Siegl \n *\n * Copyright (c) 2010-2013 Digital Bazaar, Inc.\n * Copyright (c) 2012 Stefan Siegl \n *\n * An EncryptedPrivateKeyInfo:\n *\n * EncryptedPrivateKeyInfo ::= SEQUENCE {\n * encryptionAlgorithm EncryptionAlgorithmIdentifier,\n * encryptedData EncryptedData }\n *\n * EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier\n *\n * EncryptedData ::= OCTET STRING\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./asn1');\nrequire('./des');\nrequire('./md');\nrequire('./oids');\nrequire('./pbkdf2');\nrequire('./pem');\nrequire('./random');\nrequire('./rc2');\nrequire('./rsa');\nrequire('./util');\n\nif(typeof BigInteger === 'undefined') {\n var BigInteger = forge.jsbn.BigInteger;\n}\n\n// shortcut for asn.1 API\nvar asn1 = forge.asn1;\n\n/* Password-based encryption implementation. */\nvar pki = forge.pki = forge.pki || {};\nmodule.exports = pki.pbe = forge.pbe = forge.pbe || {};\nvar oids = pki.oids;\n\n// validator for an EncryptedPrivateKeyInfo structure\n// Note: Currently only works w/algorithm params\nvar encryptedPrivateKeyValidator = {\n name: 'EncryptedPrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EncryptedPrivateKeyInfo.encryptionAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'encryptionOid'\n }, {\n name: 'AlgorithmIdentifier.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'encryptionParams'\n }]\n }, {\n // encryptedData\n name: 'EncryptedPrivateKeyInfo.encryptedData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'encryptedData'\n }]\n};\n\n// validator for a PBES2Algorithms structure\n// Note: Currently only works w/PBKDF2 + AES encryption schemes\nvar PBES2AlgorithmsValidator = {\n name: 'PBES2Algorithms',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PBES2Algorithms.keyDerivationFunc',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PBES2Algorithms.keyDerivationFunc.oid',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'kdfOid'\n }, {\n name: 'PBES2Algorithms.params',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PBES2Algorithms.params.salt',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'kdfSalt'\n }, {\n name: 'PBES2Algorithms.params.iterationCount',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'kdfIterationCount'\n }, {\n name: 'PBES2Algorithms.params.keyLength',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n optional: true,\n capture: 'keyLength'\n }, {\n // prf\n name: 'PBES2Algorithms.params.prf',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n optional: true,\n value: [{\n name: 'PBES2Algorithms.params.prf.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'prfOid'\n }]\n }]\n }]\n }, {\n name: 'PBES2Algorithms.encryptionScheme',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PBES2Algorithms.encryptionScheme.oid',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'encOid'\n }, {\n name: 'PBES2Algorithms.encryptionScheme.iv',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'encIv'\n }]\n }]\n};\n\nvar pkcs12PbeParamsValidator = {\n name: 'pkcs-12PbeParams',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'pkcs-12PbeParams.salt',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'salt'\n }, {\n name: 'pkcs-12PbeParams.iterations',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'iterations'\n }]\n};\n\n/**\n * Encrypts a ASN.1 PrivateKeyInfo object, producing an EncryptedPrivateKeyInfo.\n *\n * PBES2Algorithms ALGORITHM-IDENTIFIER ::=\n * { {PBES2-params IDENTIFIED BY id-PBES2}, ...}\n *\n * id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13}\n *\n * PBES2-params ::= SEQUENCE {\n * keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},\n * encryptionScheme AlgorithmIdentifier {{PBES2-Encs}}\n * }\n *\n * PBES2-KDFs ALGORITHM-IDENTIFIER ::=\n * { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ... }\n *\n * PBES2-Encs ALGORITHM-IDENTIFIER ::= { ... }\n *\n * PBKDF2-params ::= SEQUENCE {\n * salt CHOICE {\n * specified OCTET STRING,\n * otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}}\n * },\n * iterationCount INTEGER (1..MAX),\n * keyLength INTEGER (1..MAX) OPTIONAL,\n * prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1\n * }\n *\n * @param obj the ASN.1 PrivateKeyInfo object.\n * @param password the password to encrypt with.\n * @param options:\n * algorithm the encryption algorithm to use\n * ('aes128', 'aes192', 'aes256', '3des'), defaults to 'aes128'.\n * count the iteration count to use.\n * saltSize the salt size to use.\n * prfAlgorithm the PRF message digest algorithm to use\n * ('sha1', 'sha224', 'sha256', 'sha384', 'sha512')\n *\n * @return the ASN.1 EncryptedPrivateKeyInfo.\n */\npki.encryptPrivateKeyInfo = function(obj, password, options) {\n // set default options\n options = options || {};\n options.saltSize = options.saltSize || 8;\n options.count = options.count || 2048;\n options.algorithm = options.algorithm || 'aes128';\n options.prfAlgorithm = options.prfAlgorithm || 'sha1';\n\n // generate PBE params\n var salt = forge.random.getBytesSync(options.saltSize);\n var count = options.count;\n var countBytes = asn1.integerToDer(count);\n var dkLen;\n var encryptionAlgorithm;\n var encryptedData;\n if(options.algorithm.indexOf('aes') === 0 || options.algorithm === 'des') {\n // do PBES2\n var ivLen, encOid, cipherFn;\n switch(options.algorithm) {\n case 'aes128':\n dkLen = 16;\n ivLen = 16;\n encOid = oids['aes128-CBC'];\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'aes192':\n dkLen = 24;\n ivLen = 16;\n encOid = oids['aes192-CBC'];\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'aes256':\n dkLen = 32;\n ivLen = 16;\n encOid = oids['aes256-CBC'];\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'des':\n dkLen = 8;\n ivLen = 8;\n encOid = oids['desCBC'];\n cipherFn = forge.des.createEncryptionCipher;\n break;\n default:\n var error = new Error('Cannot encrypt private key. Unknown encryption algorithm.');\n error.algorithm = options.algorithm;\n throw error;\n }\n\n // get PRF message digest\n var prfAlgorithm = 'hmacWith' + options.prfAlgorithm.toUpperCase();\n var md = prfAlgorithmToMessageDigest(prfAlgorithm);\n\n // encrypt private key using pbe SHA-1 and AES/DES\n var dk = forge.pkcs5.pbkdf2(password, salt, count, dkLen, md);\n var iv = forge.random.getBytesSync(ivLen);\n var cipher = cipherFn(dk);\n cipher.start(iv);\n cipher.update(asn1.toDer(obj));\n cipher.finish();\n encryptedData = cipher.output.getBytes();\n\n // get PBKDF2-params\n var params = createPbkdf2Params(salt, countBytes, dkLen, prfAlgorithm);\n\n encryptionAlgorithm = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(oids['pkcs5PBES2']).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // keyDerivationFunc\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(oids['pkcs5PBKDF2']).getBytes()),\n // PBKDF2-params\n params\n ]),\n // encryptionScheme\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(encOid).getBytes()),\n // iv\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, iv)\n ])\n ])\n ]);\n } else if(options.algorithm === '3des') {\n // Do PKCS12 PBE\n dkLen = 24;\n\n var saltBytes = new forge.util.ByteBuffer(salt);\n var dk = pki.pbe.generatePkcs12Key(password, saltBytes, 1, count, dkLen);\n var iv = pki.pbe.generatePkcs12Key(password, saltBytes, 2, count, dkLen);\n var cipher = forge.des.createEncryptionCipher(dk);\n cipher.start(iv);\n cipher.update(asn1.toDer(obj));\n cipher.finish();\n encryptedData = cipher.output.getBytes();\n\n encryptionAlgorithm = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(oids['pbeWithSHAAnd3-KeyTripleDES-CBC']).getBytes()),\n // pkcs-12PbeParams\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // salt\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, salt),\n // iteration count\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n countBytes.getBytes())\n ])\n ]);\n } else {\n var error = new Error('Cannot encrypt private key. Unknown encryption algorithm.');\n error.algorithm = options.algorithm;\n throw error;\n }\n\n // EncryptedPrivateKeyInfo\n var rval = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // encryptionAlgorithm\n encryptionAlgorithm,\n // encryptedData\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, encryptedData)\n ]);\n return rval;\n};\n\n/**\n * Decrypts a ASN.1 PrivateKeyInfo object.\n *\n * @param obj the ASN.1 EncryptedPrivateKeyInfo object.\n * @param password the password to decrypt with.\n *\n * @return the ASN.1 PrivateKeyInfo on success, null on failure.\n */\npki.decryptPrivateKeyInfo = function(obj, password) {\n var rval = null;\n\n // get PBE params\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, encryptedPrivateKeyValidator, capture, errors)) {\n var error = new Error('Cannot read encrypted private key. ' +\n 'ASN.1 object is not a supported EncryptedPrivateKeyInfo.');\n error.errors = errors;\n throw error;\n }\n\n // get cipher\n var oid = asn1.derToOid(capture.encryptionOid);\n var cipher = pki.pbe.getCipher(oid, capture.encryptionParams, password);\n\n // get encrypted data\n var encrypted = forge.util.createBuffer(capture.encryptedData);\n\n cipher.update(encrypted);\n if(cipher.finish()) {\n rval = asn1.fromDer(cipher.output);\n }\n\n return rval;\n};\n\n/**\n * Converts a EncryptedPrivateKeyInfo to PEM format.\n *\n * @param epki the EncryptedPrivateKeyInfo.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted encrypted private key.\n */\npki.encryptedPrivateKeyToPem = function(epki, maxline) {\n // convert to DER, then PEM-encode\n var msg = {\n type: 'ENCRYPTED PRIVATE KEY',\n body: asn1.toDer(epki).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Converts a PEM-encoded EncryptedPrivateKeyInfo to ASN.1 format. Decryption\n * is not performed.\n *\n * @param pem the EncryptedPrivateKeyInfo in PEM-format.\n *\n * @return the ASN.1 EncryptedPrivateKeyInfo.\n */\npki.encryptedPrivateKeyFromPem = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'ENCRYPTED PRIVATE KEY') {\n var error = new Error('Could not convert encrypted private key from PEM; ' +\n 'PEM header type is \"ENCRYPTED PRIVATE KEY\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert encrypted private key from PEM; ' +\n 'PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n return asn1.fromDer(msg.body);\n};\n\n/**\n * Encrypts an RSA private key. By default, the key will be wrapped in\n * a PrivateKeyInfo and encrypted to produce a PKCS#8 EncryptedPrivateKeyInfo.\n * This is the standard, preferred way to encrypt a private key.\n *\n * To produce a non-standard PEM-encrypted private key that uses encapsulated\n * headers to indicate the encryption algorithm (old-style non-PKCS#8 OpenSSL\n * private key encryption), set the 'legacy' option to true. Note: Using this\n * option will cause the iteration count to be forced to 1.\n *\n * Note: The 'des' algorithm is supported, but it is not considered to be\n * secure because it only uses a single 56-bit key. If possible, it is highly\n * recommended that a different algorithm be used.\n *\n * @param rsaKey the RSA key to encrypt.\n * @param password the password to use.\n * @param options:\n * algorithm: the encryption algorithm to use\n * ('aes128', 'aes192', 'aes256', '3des', 'des').\n * count: the iteration count to use.\n * saltSize: the salt size to use.\n * legacy: output an old non-PKCS#8 PEM-encrypted+encapsulated\n * headers (DEK-Info) private key.\n *\n * @return the PEM-encoded ASN.1 EncryptedPrivateKeyInfo.\n */\npki.encryptRsaPrivateKey = function(rsaKey, password, options) {\n // standard PKCS#8\n options = options || {};\n if(!options.legacy) {\n // encrypt PrivateKeyInfo\n var rval = pki.wrapRsaPrivateKey(pki.privateKeyToAsn1(rsaKey));\n rval = pki.encryptPrivateKeyInfo(rval, password, options);\n return pki.encryptedPrivateKeyToPem(rval);\n }\n\n // legacy non-PKCS#8\n var algorithm;\n var iv;\n var dkLen;\n var cipherFn;\n switch(options.algorithm) {\n case 'aes128':\n algorithm = 'AES-128-CBC';\n dkLen = 16;\n iv = forge.random.getBytesSync(16);\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'aes192':\n algorithm = 'AES-192-CBC';\n dkLen = 24;\n iv = forge.random.getBytesSync(16);\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'aes256':\n algorithm = 'AES-256-CBC';\n dkLen = 32;\n iv = forge.random.getBytesSync(16);\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case '3des':\n algorithm = 'DES-EDE3-CBC';\n dkLen = 24;\n iv = forge.random.getBytesSync(8);\n cipherFn = forge.des.createEncryptionCipher;\n break;\n case 'des':\n algorithm = 'DES-CBC';\n dkLen = 8;\n iv = forge.random.getBytesSync(8);\n cipherFn = forge.des.createEncryptionCipher;\n break;\n default:\n var error = new Error('Could not encrypt RSA private key; unsupported ' +\n 'encryption algorithm \"' + options.algorithm + '\".');\n error.algorithm = options.algorithm;\n throw error;\n }\n\n // encrypt private key using OpenSSL legacy key derivation\n var dk = forge.pbe.opensslDeriveBytes(password, iv.substr(0, 8), dkLen);\n var cipher = cipherFn(dk);\n cipher.start(iv);\n cipher.update(asn1.toDer(pki.privateKeyToAsn1(rsaKey)));\n cipher.finish();\n\n var msg = {\n type: 'RSA PRIVATE KEY',\n procType: {\n version: '4',\n type: 'ENCRYPTED'\n },\n dekInfo: {\n algorithm: algorithm,\n parameters: forge.util.bytesToHex(iv).toUpperCase()\n },\n body: cipher.output.getBytes()\n };\n return forge.pem.encode(msg);\n};\n\n/**\n * Decrypts an RSA private key.\n *\n * @param pem the PEM-formatted EncryptedPrivateKeyInfo to decrypt.\n * @param password the password to use.\n *\n * @return the RSA key on success, null on failure.\n */\npki.decryptRsaPrivateKey = function(pem, password) {\n var rval = null;\n\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'ENCRYPTED PRIVATE KEY' &&\n msg.type !== 'PRIVATE KEY' &&\n msg.type !== 'RSA PRIVATE KEY') {\n var error = new Error('Could not convert private key from PEM; PEM header type ' +\n 'is not \"ENCRYPTED PRIVATE KEY\", \"PRIVATE KEY\", or \"RSA PRIVATE KEY\".');\n error.headerType = error;\n throw error;\n }\n\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n var dkLen;\n var cipherFn;\n switch(msg.dekInfo.algorithm) {\n case 'DES-CBC':\n dkLen = 8;\n cipherFn = forge.des.createDecryptionCipher;\n break;\n case 'DES-EDE3-CBC':\n dkLen = 24;\n cipherFn = forge.des.createDecryptionCipher;\n break;\n case 'AES-128-CBC':\n dkLen = 16;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'AES-192-CBC':\n dkLen = 24;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'AES-256-CBC':\n dkLen = 32;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'RC2-40-CBC':\n dkLen = 5;\n cipherFn = function(key) {\n return forge.rc2.createDecryptionCipher(key, 40);\n };\n break;\n case 'RC2-64-CBC':\n dkLen = 8;\n cipherFn = function(key) {\n return forge.rc2.createDecryptionCipher(key, 64);\n };\n break;\n case 'RC2-128-CBC':\n dkLen = 16;\n cipherFn = function(key) {\n return forge.rc2.createDecryptionCipher(key, 128);\n };\n break;\n default:\n var error = new Error('Could not decrypt private key; unsupported ' +\n 'encryption algorithm \"' + msg.dekInfo.algorithm + '\".');\n error.algorithm = msg.dekInfo.algorithm;\n throw error;\n }\n\n // use OpenSSL legacy key derivation\n var iv = forge.util.hexToBytes(msg.dekInfo.parameters);\n var dk = forge.pbe.opensslDeriveBytes(password, iv.substr(0, 8), dkLen);\n var cipher = cipherFn(dk);\n cipher.start(iv);\n cipher.update(forge.util.createBuffer(msg.body));\n if(cipher.finish()) {\n rval = cipher.output.getBytes();\n } else {\n return rval;\n }\n } else {\n rval = msg.body;\n }\n\n if(msg.type === 'ENCRYPTED PRIVATE KEY') {\n rval = pki.decryptPrivateKeyInfo(asn1.fromDer(rval), password);\n } else {\n // decryption already performed above\n rval = asn1.fromDer(rval);\n }\n\n if(rval !== null) {\n rval = pki.privateKeyFromAsn1(rval);\n }\n\n return rval;\n};\n\n/**\n * Derives a PKCS#12 key.\n *\n * @param password the password to derive the key material from, null or\n * undefined for none.\n * @param salt the salt, as a ByteBuffer, to use.\n * @param id the PKCS#12 ID byte (1 = key material, 2 = IV, 3 = MAC).\n * @param iter the iteration count.\n * @param n the number of bytes to derive from the password.\n * @param md the message digest to use, defaults to SHA-1.\n *\n * @return a ByteBuffer with the bytes derived from the password.\n */\npki.pbe.generatePkcs12Key = function(password, salt, id, iter, n, md) {\n var j, l;\n\n if(typeof md === 'undefined' || md === null) {\n if(!('sha1' in forge.md)) {\n throw new Error('\"sha1\" hash algorithm unavailable.');\n }\n md = forge.md.sha1.create();\n }\n\n var u = md.digestLength;\n var v = md.blockLength;\n var result = new forge.util.ByteBuffer();\n\n /* Convert password to Unicode byte buffer + trailing 0-byte. */\n var passBuf = new forge.util.ByteBuffer();\n if(password !== null && password !== undefined) {\n for(l = 0; l < password.length; l++) {\n passBuf.putInt16(password.charCodeAt(l));\n }\n passBuf.putInt16(0);\n }\n\n /* Length of salt and password in BYTES. */\n var p = passBuf.length();\n var s = salt.length();\n\n /* 1. Construct a string, D (the \"diversifier\"), by concatenating\n v copies of ID. */\n var D = new forge.util.ByteBuffer();\n D.fillWithByte(id, v);\n\n /* 2. Concatenate copies of the salt together to create a string S of length\n v * ceil(s / v) bytes (the final copy of the salt may be trunacted\n to create S).\n Note that if the salt is the empty string, then so is S. */\n var Slen = v * Math.ceil(s / v);\n var S = new forge.util.ByteBuffer();\n for(l = 0; l < Slen; l++) {\n S.putByte(salt.at(l % s));\n }\n\n /* 3. Concatenate copies of the password together to create a string P of\n length v * ceil(p / v) bytes (the final copy of the password may be\n truncated to create P).\n Note that if the password is the empty string, then so is P. */\n var Plen = v * Math.ceil(p / v);\n var P = new forge.util.ByteBuffer();\n for(l = 0; l < Plen; l++) {\n P.putByte(passBuf.at(l % p));\n }\n\n /* 4. Set I=S||P to be the concatenation of S and P. */\n var I = S;\n I.putBuffer(P);\n\n /* 5. Set c=ceil(n / u). */\n var c = Math.ceil(n / u);\n\n /* 6. For i=1, 2, ..., c, do the following: */\n for(var i = 1; i <= c; i++) {\n /* a) Set Ai=H^r(D||I). (l.e. the rth hash of D||I, H(H(H(...H(D||I)))) */\n var buf = new forge.util.ByteBuffer();\n buf.putBytes(D.bytes());\n buf.putBytes(I.bytes());\n for(var round = 0; round < iter; round++) {\n md.start();\n md.update(buf.getBytes());\n buf = md.digest();\n }\n\n /* b) Concatenate copies of Ai to create a string B of length v bytes (the\n final copy of Ai may be truncated to create B). */\n var B = new forge.util.ByteBuffer();\n for(l = 0; l < v; l++) {\n B.putByte(buf.at(l % u));\n }\n\n /* c) Treating I as a concatenation I0, I1, ..., Ik-1 of v-byte blocks,\n where k=ceil(s / v) + ceil(p / v), modify I by setting\n Ij=(Ij+B+1) mod 2v for each j. */\n var k = Math.ceil(s / v) + Math.ceil(p / v);\n var Inew = new forge.util.ByteBuffer();\n for(j = 0; j < k; j++) {\n var chunk = new forge.util.ByteBuffer(I.getBytes(v));\n var x = 0x1ff;\n for(l = B.length() - 1; l >= 0; l--) {\n x = x >> 8;\n x += B.at(l) + chunk.at(l);\n chunk.setAt(l, x & 0xff);\n }\n Inew.putBuffer(chunk);\n }\n I = Inew;\n\n /* Add Ai to A. */\n result.putBuffer(buf);\n }\n\n result.truncate(result.length() - n);\n return result;\n};\n\n/**\n * Get new Forge cipher object instance.\n *\n * @param oid the OID (in string notation).\n * @param params the ASN.1 params object.\n * @param password the password to decrypt with.\n *\n * @return new cipher object instance.\n */\npki.pbe.getCipher = function(oid, params, password) {\n switch(oid) {\n case pki.oids['pkcs5PBES2']:\n return pki.pbe.getCipherForPBES2(oid, params, password);\n\n case pki.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:\n case pki.oids['pbewithSHAAnd40BitRC2-CBC']:\n return pki.pbe.getCipherForPKCS12PBE(oid, params, password);\n\n default:\n var error = new Error('Cannot read encrypted PBE data block. Unsupported OID.');\n error.oid = oid;\n error.supportedOids = [\n 'pkcs5PBES2',\n 'pbeWithSHAAnd3-KeyTripleDES-CBC',\n 'pbewithSHAAnd40BitRC2-CBC'\n ];\n throw error;\n }\n};\n\n/**\n * Get new Forge cipher object instance according to PBES2 params block.\n *\n * The returned cipher instance is already started using the IV\n * from PBES2 parameter block.\n *\n * @param oid the PKCS#5 PBKDF2 OID (in string notation).\n * @param params the ASN.1 PBES2-params object.\n * @param password the password to decrypt with.\n *\n * @return new cipher object instance.\n */\npki.pbe.getCipherForPBES2 = function(oid, params, password) {\n // get PBE params\n var capture = {};\n var errors = [];\n if(!asn1.validate(params, PBES2AlgorithmsValidator, capture, errors)) {\n var error = new Error('Cannot read password-based-encryption algorithm ' +\n 'parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.');\n error.errors = errors;\n throw error;\n }\n\n // check oids\n oid = asn1.derToOid(capture.kdfOid);\n if(oid !== pki.oids['pkcs5PBKDF2']) {\n var error = new Error('Cannot read encrypted private key. ' +\n 'Unsupported key derivation function OID.');\n error.oid = oid;\n error.supportedOids = ['pkcs5PBKDF2'];\n throw error;\n }\n oid = asn1.derToOid(capture.encOid);\n if(oid !== pki.oids['aes128-CBC'] &&\n oid !== pki.oids['aes192-CBC'] &&\n oid !== pki.oids['aes256-CBC'] &&\n oid !== pki.oids['des-EDE3-CBC'] &&\n oid !== pki.oids['desCBC']) {\n var error = new Error('Cannot read encrypted private key. ' +\n 'Unsupported encryption scheme OID.');\n error.oid = oid;\n error.supportedOids = [\n 'aes128-CBC', 'aes192-CBC', 'aes256-CBC', 'des-EDE3-CBC', 'desCBC'];\n throw error;\n }\n\n // set PBE params\n var salt = capture.kdfSalt;\n var count = forge.util.createBuffer(capture.kdfIterationCount);\n count = count.getInt(count.length() << 3);\n var dkLen;\n var cipherFn;\n switch(pki.oids[oid]) {\n case 'aes128-CBC':\n dkLen = 16;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'aes192-CBC':\n dkLen = 24;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'aes256-CBC':\n dkLen = 32;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'des-EDE3-CBC':\n dkLen = 24;\n cipherFn = forge.des.createDecryptionCipher;\n break;\n case 'desCBC':\n dkLen = 8;\n cipherFn = forge.des.createDecryptionCipher;\n break;\n }\n\n // get PRF message digest\n var md = prfOidToMessageDigest(capture.prfOid);\n\n // decrypt private key using pbe with chosen PRF and AES/DES\n var dk = forge.pkcs5.pbkdf2(password, salt, count, dkLen, md);\n var iv = capture.encIv;\n var cipher = cipherFn(dk);\n cipher.start(iv);\n\n return cipher;\n};\n\n/**\n * Get new Forge cipher object instance for PKCS#12 PBE.\n *\n * The returned cipher instance is already started using the key & IV\n * derived from the provided password and PKCS#12 PBE salt.\n *\n * @param oid The PKCS#12 PBE OID (in string notation).\n * @param params The ASN.1 PKCS#12 PBE-params object.\n * @param password The password to decrypt with.\n *\n * @return the new cipher object instance.\n */\npki.pbe.getCipherForPKCS12PBE = function(oid, params, password) {\n // get PBE params\n var capture = {};\n var errors = [];\n if(!asn1.validate(params, pkcs12PbeParamsValidator, capture, errors)) {\n var error = new Error('Cannot read password-based-encryption algorithm ' +\n 'parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.');\n error.errors = errors;\n throw error;\n }\n\n var salt = forge.util.createBuffer(capture.salt);\n var count = forge.util.createBuffer(capture.iterations);\n count = count.getInt(count.length() << 3);\n\n var dkLen, dIvLen, cipherFn;\n switch(oid) {\n case pki.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:\n dkLen = 24;\n dIvLen = 8;\n cipherFn = forge.des.startDecrypting;\n break;\n\n case pki.oids['pbewithSHAAnd40BitRC2-CBC']:\n dkLen = 5;\n dIvLen = 8;\n cipherFn = function(key, iv) {\n var cipher = forge.rc2.createDecryptionCipher(key, 40);\n cipher.start(iv, null);\n return cipher;\n };\n break;\n\n default:\n var error = new Error('Cannot read PKCS #12 PBE data block. Unsupported OID.');\n error.oid = oid;\n throw error;\n }\n\n // get PRF message digest\n var md = prfOidToMessageDigest(capture.prfOid);\n var key = pki.pbe.generatePkcs12Key(password, salt, 1, count, dkLen, md);\n md.start();\n var iv = pki.pbe.generatePkcs12Key(password, salt, 2, count, dIvLen, md);\n\n return cipherFn(key, iv);\n};\n\n/**\n * OpenSSL's legacy key derivation function.\n *\n * See: http://www.openssl.org/docs/crypto/EVP_BytesToKey.html\n *\n * @param password the password to derive the key from.\n * @param salt the salt to use, null for none.\n * @param dkLen the number of bytes needed for the derived key.\n * @param [options] the options to use:\n * [md] an optional message digest object to use.\n */\npki.pbe.opensslDeriveBytes = function(password, salt, dkLen, md) {\n if(typeof md === 'undefined' || md === null) {\n if(!('md5' in forge.md)) {\n throw new Error('\"md5\" hash algorithm unavailable.');\n }\n md = forge.md.md5.create();\n }\n if(salt === null) {\n salt = '';\n }\n var digests = [hash(md, password + salt)];\n for(var length = 16, i = 1; length < dkLen; ++i, length += 16) {\n digests.push(hash(md, digests[i - 1] + password + salt));\n }\n return digests.join('').substr(0, dkLen);\n};\n\nfunction hash(md, bytes) {\n return md.start().update(bytes).digest().getBytes();\n}\n\nfunction prfOidToMessageDigest(prfOid) {\n // get PRF algorithm, default to SHA-1\n var prfAlgorithm;\n if(!prfOid) {\n prfAlgorithm = 'hmacWithSHA1';\n } else {\n prfAlgorithm = pki.oids[asn1.derToOid(prfOid)];\n if(!prfAlgorithm) {\n var error = new Error('Unsupported PRF OID.');\n error.oid = prfOid;\n error.supported = [\n 'hmacWithSHA1', 'hmacWithSHA224', 'hmacWithSHA256', 'hmacWithSHA384',\n 'hmacWithSHA512'];\n throw error;\n }\n }\n return prfAlgorithmToMessageDigest(prfAlgorithm);\n}\n\nfunction prfAlgorithmToMessageDigest(prfAlgorithm) {\n var factory = forge.md;\n switch(prfAlgorithm) {\n case 'hmacWithSHA224':\n factory = forge.md.sha512;\n case 'hmacWithSHA1':\n case 'hmacWithSHA256':\n case 'hmacWithSHA384':\n case 'hmacWithSHA512':\n prfAlgorithm = prfAlgorithm.substr(8).toLowerCase();\n break;\n default:\n var error = new Error('Unsupported PRF algorithm.');\n error.algorithm = prfAlgorithm;\n error.supported = [\n 'hmacWithSHA1', 'hmacWithSHA224', 'hmacWithSHA256', 'hmacWithSHA384',\n 'hmacWithSHA512'];\n throw error;\n }\n if(!factory || !(prfAlgorithm in factory)) {\n throw new Error('Unknown hash algorithm: ' + prfAlgorithm);\n }\n return factory[prfAlgorithm].create();\n}\n\nfunction createPbkdf2Params(salt, countBytes, dkLen, prfAlgorithm) {\n var params = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // salt\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, salt),\n // iteration count\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n countBytes.getBytes())\n ]);\n // when PRF algorithm is not SHA-1 default, add key length and PRF algorithm\n if(prfAlgorithm !== 'hmacWithSHA1') {\n params.value.push(\n // key length\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n forge.util.hexToBytes(dkLen.toString(16))),\n // AlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids[prfAlgorithm]).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]));\n }\n return params;\n}\n","/**\n * Password-Based Key-Derivation Function #2 implementation.\n *\n * See RFC 2898 for details.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./hmac');\nrequire('./md');\nrequire('./util');\n\nvar pkcs5 = forge.pkcs5 = forge.pkcs5 || {};\n\nvar crypto;\nif(forge.util.isNodejs && !forge.options.usePureJavaScript) {\n crypto = require('crypto');\n}\n\n/**\n * Derives a key from a password.\n *\n * @param p the password as a binary-encoded string of bytes.\n * @param s the salt as a binary-encoded string of bytes.\n * @param c the iteration count, a positive integer.\n * @param dkLen the intended length, in bytes, of the derived key,\n * (max: 2^32 - 1) * hash length of the PRF.\n * @param [md] the message digest (or algorithm identifier as a string) to use\n * in the PRF, defaults to SHA-1.\n * @param [callback(err, key)] presence triggers asynchronous version, called\n * once the operation completes.\n *\n * @return the derived key, as a binary-encoded string of bytes, for the\n * synchronous version (if no callback is specified).\n */\nmodule.exports = forge.pbkdf2 = pkcs5.pbkdf2 = function(\n p, s, c, dkLen, md, callback) {\n if(typeof md === 'function') {\n callback = md;\n md = null;\n }\n\n // use native implementation if possible and not disabled, note that\n // some node versions only support SHA-1, others allow digest to be changed\n if(forge.util.isNodejs && !forge.options.usePureJavaScript &&\n crypto.pbkdf2 && (md === null || typeof md !== 'object') &&\n (crypto.pbkdf2Sync.length > 4 || (!md || md === 'sha1'))) {\n if(typeof md !== 'string') {\n // default prf to SHA-1\n md = 'sha1';\n }\n p = Buffer.from(p, 'binary');\n s = Buffer.from(s, 'binary');\n if(!callback) {\n if(crypto.pbkdf2Sync.length === 4) {\n return crypto.pbkdf2Sync(p, s, c, dkLen).toString('binary');\n }\n return crypto.pbkdf2Sync(p, s, c, dkLen, md).toString('binary');\n }\n if(crypto.pbkdf2Sync.length === 4) {\n return crypto.pbkdf2(p, s, c, dkLen, function(err, key) {\n if(err) {\n return callback(err);\n }\n callback(null, key.toString('binary'));\n });\n }\n return crypto.pbkdf2(p, s, c, dkLen, md, function(err, key) {\n if(err) {\n return callback(err);\n }\n callback(null, key.toString('binary'));\n });\n }\n\n if(typeof md === 'undefined' || md === null) {\n // default prf to SHA-1\n md = 'sha1';\n }\n if(typeof md === 'string') {\n if(!(md in forge.md.algorithms)) {\n throw new Error('Unknown hash algorithm: ' + md);\n }\n md = forge.md[md].create();\n }\n\n var hLen = md.digestLength;\n\n /* 1. If dkLen > (2^32 - 1) * hLen, output \"derived key too long\" and\n stop. */\n if(dkLen > (0xFFFFFFFF * hLen)) {\n var err = new Error('Derived key is too long.');\n if(callback) {\n return callback(err);\n }\n throw err;\n }\n\n /* 2. Let len be the number of hLen-octet blocks in the derived key,\n rounding up, and let r be the number of octets in the last\n block:\n\n len = CEIL(dkLen / hLen),\n r = dkLen - (len - 1) * hLen. */\n var len = Math.ceil(dkLen / hLen);\n var r = dkLen - (len - 1) * hLen;\n\n /* 3. For each block of the derived key apply the function F defined\n below to the password P, the salt S, the iteration count c, and\n the block index to compute the block:\n\n T_1 = F(P, S, c, 1),\n T_2 = F(P, S, c, 2),\n ...\n T_len = F(P, S, c, len),\n\n where the function F is defined as the exclusive-or sum of the\n first c iterates of the underlying pseudorandom function PRF\n applied to the password P and the concatenation of the salt S\n and the block index i:\n\n F(P, S, c, i) = u_1 XOR u_2 XOR ... XOR u_c\n\n where\n\n u_1 = PRF(P, S || INT(i)),\n u_2 = PRF(P, u_1),\n ...\n u_c = PRF(P, u_{c-1}).\n\n Here, INT(i) is a four-octet encoding of the integer i, most\n significant octet first. */\n var prf = forge.hmac.create();\n prf.start(md, p);\n var dk = '';\n var xor, u_c, u_c1;\n\n // sync version\n if(!callback) {\n for(var i = 1; i <= len; ++i) {\n // PRF(P, S || INT(i)) (first iteration)\n prf.start(null, null);\n prf.update(s);\n prf.update(forge.util.int32ToBytes(i));\n xor = u_c1 = prf.digest().getBytes();\n\n // PRF(P, u_{c-1}) (other iterations)\n for(var j = 2; j <= c; ++j) {\n prf.start(null, null);\n prf.update(u_c1);\n u_c = prf.digest().getBytes();\n // F(p, s, c, i)\n xor = forge.util.xorBytes(xor, u_c, hLen);\n u_c1 = u_c;\n }\n\n /* 4. Concatenate the blocks and extract the first dkLen octets to\n produce a derived key DK:\n\n DK = T_1 || T_2 || ... || T_len<0..r-1> */\n dk += (i < len) ? xor : xor.substr(0, r);\n }\n /* 5. Output the derived key DK. */\n return dk;\n }\n\n // async version\n var i = 1, j;\n function outer() {\n if(i > len) {\n // done\n return callback(null, dk);\n }\n\n // PRF(P, S || INT(i)) (first iteration)\n prf.start(null, null);\n prf.update(s);\n prf.update(forge.util.int32ToBytes(i));\n xor = u_c1 = prf.digest().getBytes();\n\n // PRF(P, u_{c-1}) (other iterations)\n j = 2;\n inner();\n }\n\n function inner() {\n if(j <= c) {\n prf.start(null, null);\n prf.update(u_c1);\n u_c = prf.digest().getBytes();\n // F(p, s, c, i)\n xor = forge.util.xorBytes(xor, u_c, hLen);\n u_c1 = u_c;\n ++j;\n return forge.util.setImmediate(inner);\n }\n\n /* 4. Concatenate the blocks and extract the first dkLen octets to\n produce a derived key DK:\n\n DK = T_1 || T_2 || ... || T_len<0..r-1> */\n dk += (i < len) ? xor : xor.substr(0, r);\n\n ++i;\n outer();\n }\n\n outer();\n};\n","/**\n * Javascript implementation of basic PEM (Privacy Enhanced Mail) algorithms.\n *\n * See: RFC 1421.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2013-2014 Digital Bazaar, Inc.\n *\n * A Forge PEM object has the following fields:\n *\n * type: identifies the type of message (eg: \"RSA PRIVATE KEY\").\n *\n * procType: identifies the type of processing performed on the message,\n * it has two subfields: version and type, eg: 4,ENCRYPTED.\n *\n * contentDomain: identifies the type of content in the message, typically\n * only uses the value: \"RFC822\".\n *\n * dekInfo: identifies the message encryption algorithm and mode and includes\n * any parameters for the algorithm, it has two subfields: algorithm and\n * parameters, eg: DES-CBC,F8143EDE5960C597.\n *\n * headers: contains all other PEM encapsulated headers -- where order is\n * significant (for pairing data like recipient ID + key info).\n *\n * body: the binary-encoded body.\n */\nvar forge = require('./forge');\nrequire('./util');\n\n// shortcut for pem API\nvar pem = module.exports = forge.pem = forge.pem || {};\n\n/**\n * Encodes (serializes) the given PEM object.\n *\n * @param msg the PEM message object to encode.\n * @param options the options to use:\n * maxline the maximum characters per line for the body, (default: 64).\n *\n * @return the PEM-formatted string.\n */\npem.encode = function(msg, options) {\n options = options || {};\n var rval = '-----BEGIN ' + msg.type + '-----\\r\\n';\n\n // encode special headers\n var header;\n if(msg.procType) {\n header = {\n name: 'Proc-Type',\n values: [String(msg.procType.version), msg.procType.type]\n };\n rval += foldHeader(header);\n }\n if(msg.contentDomain) {\n header = {name: 'Content-Domain', values: [msg.contentDomain]};\n rval += foldHeader(header);\n }\n if(msg.dekInfo) {\n header = {name: 'DEK-Info', values: [msg.dekInfo.algorithm]};\n if(msg.dekInfo.parameters) {\n header.values.push(msg.dekInfo.parameters);\n }\n rval += foldHeader(header);\n }\n\n if(msg.headers) {\n // encode all other headers\n for(var i = 0; i < msg.headers.length; ++i) {\n rval += foldHeader(msg.headers[i]);\n }\n }\n\n // terminate header\n if(msg.procType) {\n rval += '\\r\\n';\n }\n\n // add body\n rval += forge.util.encode64(msg.body, options.maxline || 64) + '\\r\\n';\n\n rval += '-----END ' + msg.type + '-----\\r\\n';\n return rval;\n};\n\n/**\n * Decodes (deserializes) all PEM messages found in the given string.\n *\n * @param str the PEM-formatted string to decode.\n *\n * @return the PEM message objects in an array.\n */\npem.decode = function(str) {\n var rval = [];\n\n // split string into PEM messages (be lenient w/EOF on BEGIN line)\n var rMessage = /\\s*-----BEGIN ([A-Z0-9- ]+)-----\\r?\\n?([\\x21-\\x7e\\s]+?(?:\\r?\\n\\r?\\n))?([:A-Za-z0-9+\\/=\\s]+?)-----END \\1-----/g;\n var rHeader = /([\\x21-\\x7e]+):\\s*([\\x21-\\x7e\\s^:]+)/;\n var rCRLF = /\\r?\\n/;\n var match;\n while(true) {\n match = rMessage.exec(str);\n if(!match) {\n break;\n }\n\n var msg = {\n type: match[1],\n procType: null,\n contentDomain: null,\n dekInfo: null,\n headers: [],\n body: forge.util.decode64(match[3])\n };\n rval.push(msg);\n\n // no headers\n if(!match[2]) {\n continue;\n }\n\n // parse headers\n var lines = match[2].split(rCRLF);\n var li = 0;\n while(match && li < lines.length) {\n // get line, trim any rhs whitespace\n var line = lines[li].replace(/\\s+$/, '');\n\n // RFC2822 unfold any following folded lines\n for(var nl = li + 1; nl < lines.length; ++nl) {\n var next = lines[nl];\n if(!/\\s/.test(next[0])) {\n break;\n }\n line += next;\n li = nl;\n }\n\n // parse header\n match = line.match(rHeader);\n if(match) {\n var header = {name: match[1], values: []};\n var values = match[2].split(',');\n for(var vi = 0; vi < values.length; ++vi) {\n header.values.push(ltrim(values[vi]));\n }\n\n // Proc-Type must be the first header\n if(!msg.procType) {\n if(header.name !== 'Proc-Type') {\n throw new Error('Invalid PEM formatted message. The first ' +\n 'encapsulated header must be \"Proc-Type\".');\n } else if(header.values.length !== 2) {\n throw new Error('Invalid PEM formatted message. The \"Proc-Type\" ' +\n 'header must have two subfields.');\n }\n msg.procType = {version: values[0], type: values[1]};\n } else if(!msg.contentDomain && header.name === 'Content-Domain') {\n // special-case Content-Domain\n msg.contentDomain = values[0] || '';\n } else if(!msg.dekInfo && header.name === 'DEK-Info') {\n // special-case DEK-Info\n if(header.values.length === 0) {\n throw new Error('Invalid PEM formatted message. The \"DEK-Info\" ' +\n 'header must have at least one subfield.');\n }\n msg.dekInfo = {algorithm: values[0], parameters: values[1] || null};\n } else {\n msg.headers.push(header);\n }\n }\n\n ++li;\n }\n\n if(msg.procType === 'ENCRYPTED' && !msg.dekInfo) {\n throw new Error('Invalid PEM formatted message. The \"DEK-Info\" ' +\n 'header must be present if \"Proc-Type\" is \"ENCRYPTED\".');\n }\n }\n\n if(rval.length === 0) {\n throw new Error('Invalid PEM formatted message.');\n }\n\n return rval;\n};\n\nfunction foldHeader(header) {\n var rval = header.name + ': ';\n\n // ensure values with CRLF are folded\n var values = [];\n var insertSpace = function(match, $1) {\n return ' ' + $1;\n };\n for(var i = 0; i < header.values.length; ++i) {\n values.push(header.values[i].replace(/^(\\S+\\r\\n)/, insertSpace));\n }\n rval += values.join(',') + '\\r\\n';\n\n // do folding\n var length = 0;\n var candidate = -1;\n for(var i = 0; i < rval.length; ++i, ++length) {\n if(length > 65 && candidate !== -1) {\n var insert = rval[candidate];\n if(insert === ',') {\n ++candidate;\n rval = rval.substr(0, candidate) + '\\r\\n ' + rval.substr(candidate);\n } else {\n rval = rval.substr(0, candidate) +\n '\\r\\n' + insert + rval.substr(candidate + 1);\n }\n length = (i - candidate - 1);\n candidate = -1;\n ++i;\n } else if(rval[i] === ' ' || rval[i] === '\\t' || rval[i] === ',') {\n candidate = i;\n }\n }\n\n return rval;\n}\n\nfunction ltrim(str) {\n return str.replace(/^\\s+/, '');\n}\n","/**\n * Partial implementation of PKCS#1 v2.2: RSA-OEAP\n *\n * Modified but based on the following MIT and BSD licensed code:\n *\n * https://github.com/kjur/jsjws/blob/master/rsa.js:\n *\n * The 'jsjws'(JSON Web Signature JavaScript Library) License\n *\n * Copyright (c) 2012 Kenji Urushima\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * http://webrsa.cvs.sourceforge.net/viewvc/webrsa/Client/RSAES-OAEP.js?content-type=text%2Fplain:\n *\n * RSAES-OAEP.js\n * $Id: RSAES-OAEP.js,v 1.1.1.1 2003/03/19 15:37:20 ellispritchard Exp $\n * JavaScript Implementation of PKCS #1 v2.1 RSA CRYPTOGRAPHY STANDARD (RSA Laboratories, June 14, 2002)\n * Copyright (C) Ellis Pritchard, Guardian Unlimited 2003.\n * Contact: ellis@nukinetics.com\n * Distributed under the BSD License.\n *\n * Official documentation: http://www.rsa.com/rsalabs/node.asp?id=2125\n *\n * @author Evan Jones (http://evanjones.ca/)\n * @author Dave Longley\n *\n * Copyright (c) 2013-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\nrequire('./random');\nrequire('./sha1');\n\n// shortcut for PKCS#1 API\nvar pkcs1 = module.exports = forge.pkcs1 = forge.pkcs1 || {};\n\n/**\n * Encode the given RSAES-OAEP message (M) using key, with optional label (L)\n * and seed.\n *\n * This method does not perform RSA encryption, it only encodes the message\n * using RSAES-OAEP.\n *\n * @param key the RSA key to use.\n * @param message the message to encode.\n * @param options the options to use:\n * label an optional label to use.\n * seed the seed to use.\n * md the message digest object to use, undefined for SHA-1.\n * mgf1 optional mgf1 parameters:\n * md the message digest object to use for MGF1.\n *\n * @return the encoded message bytes.\n */\npkcs1.encode_rsa_oaep = function(key, message, options) {\n // parse arguments\n var label;\n var seed;\n var md;\n var mgf1Md;\n // legacy args (label, seed, md)\n if(typeof options === 'string') {\n label = options;\n seed = arguments[3] || undefined;\n md = arguments[4] || undefined;\n } else if(options) {\n label = options.label || undefined;\n seed = options.seed || undefined;\n md = options.md || undefined;\n if(options.mgf1 && options.mgf1.md) {\n mgf1Md = options.mgf1.md;\n }\n }\n\n // default OAEP to SHA-1 message digest\n if(!md) {\n md = forge.md.sha1.create();\n } else {\n md.start();\n }\n\n // default MGF-1 to same as OAEP\n if(!mgf1Md) {\n mgf1Md = md;\n }\n\n // compute length in bytes and check output\n var keyLength = Math.ceil(key.n.bitLength() / 8);\n var maxLength = keyLength - 2 * md.digestLength - 2;\n if(message.length > maxLength) {\n var error = new Error('RSAES-OAEP input message length is too long.');\n error.length = message.length;\n error.maxLength = maxLength;\n throw error;\n }\n\n if(!label) {\n label = '';\n }\n md.update(label, 'raw');\n var lHash = md.digest();\n\n var PS = '';\n var PS_length = maxLength - message.length;\n for(var i = 0; i < PS_length; i++) {\n PS += '\\x00';\n }\n\n var DB = lHash.getBytes() + PS + '\\x01' + message;\n\n if(!seed) {\n seed = forge.random.getBytes(md.digestLength);\n } else if(seed.length !== md.digestLength) {\n var error = new Error('Invalid RSAES-OAEP seed. The seed length must ' +\n 'match the digest length.');\n error.seedLength = seed.length;\n error.digestLength = md.digestLength;\n throw error;\n }\n\n var dbMask = rsa_mgf1(seed, keyLength - md.digestLength - 1, mgf1Md);\n var maskedDB = forge.util.xorBytes(DB, dbMask, DB.length);\n\n var seedMask = rsa_mgf1(maskedDB, md.digestLength, mgf1Md);\n var maskedSeed = forge.util.xorBytes(seed, seedMask, seed.length);\n\n // return encoded message\n return '\\x00' + maskedSeed + maskedDB;\n};\n\n/**\n * Decode the given RSAES-OAEP encoded message (EM) using key, with optional\n * label (L).\n *\n * This method does not perform RSA decryption, it only decodes the message\n * using RSAES-OAEP.\n *\n * @param key the RSA key to use.\n * @param em the encoded message to decode.\n * @param options the options to use:\n * label an optional label to use.\n * md the message digest object to use for OAEP, undefined for SHA-1.\n * mgf1 optional mgf1 parameters:\n * md the message digest object to use for MGF1.\n *\n * @return the decoded message bytes.\n */\npkcs1.decode_rsa_oaep = function(key, em, options) {\n // parse args\n var label;\n var md;\n var mgf1Md;\n // legacy args\n if(typeof options === 'string') {\n label = options;\n md = arguments[3] || undefined;\n } else if(options) {\n label = options.label || undefined;\n md = options.md || undefined;\n if(options.mgf1 && options.mgf1.md) {\n mgf1Md = options.mgf1.md;\n }\n }\n\n // compute length in bytes\n var keyLength = Math.ceil(key.n.bitLength() / 8);\n\n if(em.length !== keyLength) {\n var error = new Error('RSAES-OAEP encoded message length is invalid.');\n error.length = em.length;\n error.expectedLength = keyLength;\n throw error;\n }\n\n // default OAEP to SHA-1 message digest\n if(md === undefined) {\n md = forge.md.sha1.create();\n } else {\n md.start();\n }\n\n // default MGF-1 to same as OAEP\n if(!mgf1Md) {\n mgf1Md = md;\n }\n\n if(keyLength < 2 * md.digestLength + 2) {\n throw new Error('RSAES-OAEP key is too short for the hash function.');\n }\n\n if(!label) {\n label = '';\n }\n md.update(label, 'raw');\n var lHash = md.digest().getBytes();\n\n // split the message into its parts\n var y = em.charAt(0);\n var maskedSeed = em.substring(1, md.digestLength + 1);\n var maskedDB = em.substring(1 + md.digestLength);\n\n var seedMask = rsa_mgf1(maskedDB, md.digestLength, mgf1Md);\n var seed = forge.util.xorBytes(maskedSeed, seedMask, maskedSeed.length);\n\n var dbMask = rsa_mgf1(seed, keyLength - md.digestLength - 1, mgf1Md);\n var db = forge.util.xorBytes(maskedDB, dbMask, maskedDB.length);\n\n var lHashPrime = db.substring(0, md.digestLength);\n\n // constant time check that all values match what is expected\n var error = (y !== '\\x00');\n\n // constant time check lHash vs lHashPrime\n for(var i = 0; i < md.digestLength; ++i) {\n error |= (lHash.charAt(i) !== lHashPrime.charAt(i));\n }\n\n // \"constant time\" find the 0x1 byte separating the padding (zeros) from the\n // message\n // TODO: It must be possible to do this in a better/smarter way?\n var in_ps = 1;\n var index = md.digestLength;\n for(var j = md.digestLength; j < db.length; j++) {\n var code = db.charCodeAt(j);\n\n var is_0 = (code & 0x1) ^ 0x1;\n\n // non-zero if not 0 or 1 in the ps section\n var error_mask = in_ps ? 0xfffe : 0x0000;\n error |= (code & error_mask);\n\n // latch in_ps to zero after we find 0x1\n in_ps = in_ps & is_0;\n index += in_ps;\n }\n\n if(error || db.charCodeAt(index) !== 0x1) {\n throw new Error('Invalid RSAES-OAEP padding.');\n }\n\n return db.substring(index + 1);\n};\n\nfunction rsa_mgf1(seed, maskLength, hash) {\n // default to SHA-1 message digest\n if(!hash) {\n hash = forge.md.sha1.create();\n }\n var t = '';\n var count = Math.ceil(maskLength / hash.digestLength);\n for(var i = 0; i < count; ++i) {\n var c = String.fromCharCode(\n (i >> 24) & 0xFF, (i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF);\n hash.start();\n hash.update(seed + c);\n t += hash.digest().getBytes();\n }\n return t.substring(0, maskLength);\n}\n","/**\n * Javascript implementation of PKCS#12.\n *\n * @author Dave Longley\n * @author Stefan Siegl \n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n * Copyright (c) 2012 Stefan Siegl \n *\n * The ASN.1 representation of PKCS#12 is as follows\n * (see ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-12/pkcs-12-tc1.pdf for details)\n *\n * PFX ::= SEQUENCE {\n * version INTEGER {v3(3)}(v3,...),\n * authSafe ContentInfo,\n * macData MacData OPTIONAL\n * }\n *\n * MacData ::= SEQUENCE {\n * mac DigestInfo,\n * macSalt OCTET STRING,\n * iterations INTEGER DEFAULT 1\n * }\n * Note: The iterations default is for historical reasons and its use is\n * deprecated. A higher value, like 1024, is recommended.\n *\n * DigestInfo is defined in PKCS#7 as follows:\n *\n * DigestInfo ::= SEQUENCE {\n * digestAlgorithm DigestAlgorithmIdentifier,\n * digest Digest\n * }\n *\n * DigestAlgorithmIdentifier ::= AlgorithmIdentifier\n *\n * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters\n * for the algorithm, if any. In the case of SHA1 there is none.\n *\n * AlgorithmIdentifer ::= SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * parameters ANY DEFINED BY algorithm OPTIONAL\n * }\n *\n * Digest ::= OCTET STRING\n *\n *\n * ContentInfo ::= SEQUENCE {\n * contentType ContentType,\n * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL\n * }\n *\n * ContentType ::= OBJECT IDENTIFIER\n *\n * AuthenticatedSafe ::= SEQUENCE OF ContentInfo\n * -- Data if unencrypted\n * -- EncryptedData if password-encrypted\n * -- EnvelopedData if public key-encrypted\n *\n *\n * SafeContents ::= SEQUENCE OF SafeBag\n *\n * SafeBag ::= SEQUENCE {\n * bagId BAG-TYPE.&id ({PKCS12BagSet})\n * bagValue [0] EXPLICIT BAG-TYPE.&Type({PKCS12BagSet}{@bagId}),\n * bagAttributes SET OF PKCS12Attribute OPTIONAL\n * }\n *\n * PKCS12Attribute ::= SEQUENCE {\n * attrId ATTRIBUTE.&id ({PKCS12AttrSet}),\n * attrValues SET OF ATTRIBUTE.&Type ({PKCS12AttrSet}{@attrId})\n * } -- This type is compatible with the X.500 type 'Attribute'\n *\n * PKCS12AttrSet ATTRIBUTE ::= {\n * friendlyName | -- from PKCS #9\n * localKeyId, -- from PKCS #9\n * ... -- Other attributes are allowed\n * }\n *\n * CertBag ::= SEQUENCE {\n * certId BAG-TYPE.&id ({CertTypes}),\n * certValue [0] EXPLICIT BAG-TYPE.&Type ({CertTypes}{@certId})\n * }\n *\n * x509Certificate BAG-TYPE ::= {OCTET STRING IDENTIFIED BY {certTypes 1}}\n * -- DER-encoded X.509 certificate stored in OCTET STRING\n *\n * sdsiCertificate BAG-TYPE ::= {IA5String IDENTIFIED BY {certTypes 2}}\n * -- Base64-encoded SDSI certificate stored in IA5String\n *\n * CertTypes BAG-TYPE ::= {\n * x509Certificate |\n * sdsiCertificate,\n * ... -- For future extensions\n * }\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./hmac');\nrequire('./oids');\nrequire('./pkcs7asn1');\nrequire('./pbe');\nrequire('./random');\nrequire('./rsa');\nrequire('./sha1');\nrequire('./util');\nrequire('./x509');\n\n// shortcut for asn.1 & PKI API\nvar asn1 = forge.asn1;\nvar pki = forge.pki;\n\n// shortcut for PKCS#12 API\nvar p12 = module.exports = forge.pkcs12 = forge.pkcs12 || {};\n\nvar contentInfoValidator = {\n name: 'ContentInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE, // a ContentInfo\n constructed: true,\n value: [{\n name: 'ContentInfo.contentType',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'contentType'\n }, {\n name: 'ContentInfo.content',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n constructed: true,\n captureAsn1: 'content'\n }]\n};\n\nvar pfxValidator = {\n name: 'PFX',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PFX.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n },\n contentInfoValidator, {\n name: 'PFX.macData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n optional: true,\n captureAsn1: 'mac',\n value: [{\n name: 'PFX.macData.mac',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE, // DigestInfo\n constructed: true,\n value: [{\n name: 'PFX.macData.mac.digestAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE, // DigestAlgorithmIdentifier\n constructed: true,\n value: [{\n name: 'PFX.macData.mac.digestAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'macAlgorithm'\n }, {\n name: 'PFX.macData.mac.digestAlgorithm.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n captureAsn1: 'macAlgorithmParameters'\n }]\n }, {\n name: 'PFX.macData.mac.digest',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'macDigest'\n }]\n }, {\n name: 'PFX.macData.macSalt',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'macSalt'\n }, {\n name: 'PFX.macData.iterations',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n optional: true,\n capture: 'macIterations'\n }]\n }]\n};\n\nvar safeBagValidator = {\n name: 'SafeBag',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SafeBag.bagId',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'bagId'\n }, {\n name: 'SafeBag.bagValue',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n constructed: true,\n captureAsn1: 'bagValue'\n }, {\n name: 'SafeBag.bagAttributes',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true,\n optional: true,\n capture: 'bagAttributes'\n }]\n};\n\nvar attributeValidator = {\n name: 'Attribute',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'Attribute.attrId',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'oid'\n }, {\n name: 'Attribute.attrValues',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true,\n capture: 'values'\n }]\n};\n\nvar certBagValidator = {\n name: 'CertBag',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'CertBag.certId',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'certId'\n }, {\n name: 'CertBag.certValue',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n constructed: true,\n /* So far we only support X.509 certificates (which are wrapped in\n an OCTET STRING, hence hard code that here). */\n value: [{\n name: 'CertBag.certValue[0]',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.OCTETSTRING,\n constructed: false,\n capture: 'cert'\n }]\n }]\n};\n\n/**\n * Search SafeContents structure for bags with matching attributes.\n *\n * The search can optionally be narrowed by a certain bag type.\n *\n * @param safeContents the SafeContents structure to search in.\n * @param attrName the name of the attribute to compare against.\n * @param attrValue the attribute value to search for.\n * @param [bagType] bag type to narrow search by.\n *\n * @return an array of matching bags.\n */\nfunction _getBagsByAttribute(safeContents, attrName, attrValue, bagType) {\n var result = [];\n\n for(var i = 0; i < safeContents.length; i++) {\n for(var j = 0; j < safeContents[i].safeBags.length; j++) {\n var bag = safeContents[i].safeBags[j];\n if(bagType !== undefined && bag.type !== bagType) {\n continue;\n }\n // only filter by bag type, no attribute specified\n if(attrName === null) {\n result.push(bag);\n continue;\n }\n if(bag.attributes[attrName] !== undefined &&\n bag.attributes[attrName].indexOf(attrValue) >= 0) {\n result.push(bag);\n }\n }\n }\n\n return result;\n}\n\n/**\n * Converts a PKCS#12 PFX in ASN.1 notation into a PFX object.\n *\n * @param obj The PKCS#12 PFX in ASN.1 notation.\n * @param strict true to use strict DER decoding, false not to (default: true).\n * @param {String} password Password to decrypt with (optional).\n *\n * @return PKCS#12 PFX object.\n */\np12.pkcs12FromAsn1 = function(obj, strict, password) {\n // handle args\n if(typeof strict === 'string') {\n password = strict;\n strict = true;\n } else if(strict === undefined) {\n strict = true;\n }\n\n // validate PFX and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, pfxValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#12 PFX. ' +\n 'ASN.1 object is not an PKCS#12 PFX.');\n error.errors = error;\n throw error;\n }\n\n var pfx = {\n version: capture.version.charCodeAt(0),\n safeContents: [],\n\n /**\n * Gets bags with matching attributes.\n *\n * @param filter the attributes to filter by:\n * [localKeyId] the localKeyId to search for.\n * [localKeyIdHex] the localKeyId in hex to search for.\n * [friendlyName] the friendly name to search for.\n * [bagType] bag type to narrow each attribute search by.\n *\n * @return a map of attribute type to an array of matching bags or, if no\n * attribute was given but a bag type, the map key will be the\n * bag type.\n */\n getBags: function(filter) {\n var rval = {};\n\n var localKeyId;\n if('localKeyId' in filter) {\n localKeyId = filter.localKeyId;\n } else if('localKeyIdHex' in filter) {\n localKeyId = forge.util.hexToBytes(filter.localKeyIdHex);\n }\n\n // filter on bagType only\n if(localKeyId === undefined && !('friendlyName' in filter) &&\n 'bagType' in filter) {\n rval[filter.bagType] = _getBagsByAttribute(\n pfx.safeContents, null, null, filter.bagType);\n }\n\n if(localKeyId !== undefined) {\n rval.localKeyId = _getBagsByAttribute(\n pfx.safeContents, 'localKeyId',\n localKeyId, filter.bagType);\n }\n if('friendlyName' in filter) {\n rval.friendlyName = _getBagsByAttribute(\n pfx.safeContents, 'friendlyName',\n filter.friendlyName, filter.bagType);\n }\n\n return rval;\n },\n\n /**\n * DEPRECATED: use getBags() instead.\n *\n * Get bags with matching friendlyName attribute.\n *\n * @param friendlyName the friendly name to search for.\n * @param [bagType] bag type to narrow search by.\n *\n * @return an array of bags with matching friendlyName attribute.\n */\n getBagsByFriendlyName: function(friendlyName, bagType) {\n return _getBagsByAttribute(\n pfx.safeContents, 'friendlyName', friendlyName, bagType);\n },\n\n /**\n * DEPRECATED: use getBags() instead.\n *\n * Get bags with matching localKeyId attribute.\n *\n * @param localKeyId the localKeyId to search for.\n * @param [bagType] bag type to narrow search by.\n *\n * @return an array of bags with matching localKeyId attribute.\n */\n getBagsByLocalKeyId: function(localKeyId, bagType) {\n return _getBagsByAttribute(\n pfx.safeContents, 'localKeyId', localKeyId, bagType);\n }\n };\n\n if(capture.version.charCodeAt(0) !== 3) {\n var error = new Error('PKCS#12 PFX of version other than 3 not supported.');\n error.version = capture.version.charCodeAt(0);\n throw error;\n }\n\n if(asn1.derToOid(capture.contentType) !== pki.oids.data) {\n var error = new Error('Only PKCS#12 PFX in password integrity mode supported.');\n error.oid = asn1.derToOid(capture.contentType);\n throw error;\n }\n\n var data = capture.content.value[0];\n if(data.tagClass !== asn1.Class.UNIVERSAL ||\n data.type !== asn1.Type.OCTETSTRING) {\n throw new Error('PKCS#12 authSafe content data is not an OCTET STRING.');\n }\n data = _decodePkcs7Data(data);\n\n // check for MAC\n if(capture.mac) {\n var md = null;\n var macKeyBytes = 0;\n var macAlgorithm = asn1.derToOid(capture.macAlgorithm);\n switch(macAlgorithm) {\n case pki.oids.sha1:\n md = forge.md.sha1.create();\n macKeyBytes = 20;\n break;\n case pki.oids.sha256:\n md = forge.md.sha256.create();\n macKeyBytes = 32;\n break;\n case pki.oids.sha384:\n md = forge.md.sha384.create();\n macKeyBytes = 48;\n break;\n case pki.oids.sha512:\n md = forge.md.sha512.create();\n macKeyBytes = 64;\n break;\n case pki.oids.md5:\n md = forge.md.md5.create();\n macKeyBytes = 16;\n break;\n }\n if(md === null) {\n throw new Error('PKCS#12 uses unsupported MAC algorithm: ' + macAlgorithm);\n }\n\n // verify MAC (iterations default to 1)\n var macSalt = new forge.util.ByteBuffer(capture.macSalt);\n var macIterations = (('macIterations' in capture) ?\n parseInt(forge.util.bytesToHex(capture.macIterations), 16) : 1);\n var macKey = p12.generateKey(\n password, macSalt, 3, macIterations, macKeyBytes, md);\n var mac = forge.hmac.create();\n mac.start(md, macKey);\n mac.update(data.value);\n var macValue = mac.getMac();\n if(macValue.getBytes() !== capture.macDigest) {\n throw new Error('PKCS#12 MAC could not be verified. Invalid password?');\n }\n }\n\n _decodeAuthenticatedSafe(pfx, data.value, strict, password);\n return pfx;\n};\n\n/**\n * Decodes PKCS#7 Data. PKCS#7 (RFC 2315) defines \"Data\" as an OCTET STRING,\n * but it is sometimes an OCTET STRING that is composed/constructed of chunks,\n * each its own OCTET STRING. This is BER-encoding vs. DER-encoding. This\n * function transforms this corner-case into the usual simple,\n * non-composed/constructed OCTET STRING.\n *\n * This function may be moved to ASN.1 at some point to better deal with\n * more BER-encoding issues, should they arise.\n *\n * @param data the ASN.1 Data object to transform.\n */\nfunction _decodePkcs7Data(data) {\n // handle special case of \"chunked\" data content: an octet string composed\n // of other octet strings\n if(data.composed || data.constructed) {\n var value = forge.util.createBuffer();\n for(var i = 0; i < data.value.length; ++i) {\n value.putBytes(data.value[i].value);\n }\n data.composed = data.constructed = false;\n data.value = value.getBytes();\n }\n return data;\n}\n\n/**\n * Decode PKCS#12 AuthenticatedSafe (BER encoded) into PFX object.\n *\n * The AuthenticatedSafe is a BER-encoded SEQUENCE OF ContentInfo.\n *\n * @param pfx The PKCS#12 PFX object to fill.\n * @param {String} authSafe BER-encoded AuthenticatedSafe.\n * @param strict true to use strict DER decoding, false not to.\n * @param {String} password Password to decrypt with (optional).\n */\nfunction _decodeAuthenticatedSafe(pfx, authSafe, strict, password) {\n authSafe = asn1.fromDer(authSafe, strict); /* actually it's BER encoded */\n\n if(authSafe.tagClass !== asn1.Class.UNIVERSAL ||\n authSafe.type !== asn1.Type.SEQUENCE ||\n authSafe.constructed !== true) {\n throw new Error('PKCS#12 AuthenticatedSafe expected to be a ' +\n 'SEQUENCE OF ContentInfo');\n }\n\n for(var i = 0; i < authSafe.value.length; i++) {\n var contentInfo = authSafe.value[i];\n\n // validate contentInfo and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(contentInfo, contentInfoValidator, capture, errors)) {\n var error = new Error('Cannot read ContentInfo.');\n error.errors = errors;\n throw error;\n }\n\n var obj = {\n encrypted: false\n };\n var safeContents = null;\n var data = capture.content.value[0];\n switch(asn1.derToOid(capture.contentType)) {\n case pki.oids.data:\n if(data.tagClass !== asn1.Class.UNIVERSAL ||\n data.type !== asn1.Type.OCTETSTRING) {\n throw new Error('PKCS#12 SafeContents Data is not an OCTET STRING.');\n }\n safeContents = _decodePkcs7Data(data).value;\n break;\n case pki.oids.encryptedData:\n safeContents = _decryptSafeContents(data, password);\n obj.encrypted = true;\n break;\n default:\n var error = new Error('Unsupported PKCS#12 contentType.');\n error.contentType = asn1.derToOid(capture.contentType);\n throw error;\n }\n\n obj.safeBags = _decodeSafeContents(safeContents, strict, password);\n pfx.safeContents.push(obj);\n }\n}\n\n/**\n * Decrypt PKCS#7 EncryptedData structure.\n *\n * @param data ASN.1 encoded EncryptedContentInfo object.\n * @param password The user-provided password.\n *\n * @return The decrypted SafeContents (ASN.1 object).\n */\nfunction _decryptSafeContents(data, password) {\n var capture = {};\n var errors = [];\n if(!asn1.validate(\n data, forge.pkcs7.asn1.encryptedDataValidator, capture, errors)) {\n var error = new Error('Cannot read EncryptedContentInfo.');\n error.errors = errors;\n throw error;\n }\n\n var oid = asn1.derToOid(capture.contentType);\n if(oid !== pki.oids.data) {\n var error = new Error(\n 'PKCS#12 EncryptedContentInfo ContentType is not Data.');\n error.oid = oid;\n throw error;\n }\n\n // get cipher\n oid = asn1.derToOid(capture.encAlgorithm);\n var cipher = pki.pbe.getCipher(oid, capture.encParameter, password);\n\n // get encrypted data\n var encryptedContentAsn1 = _decodePkcs7Data(capture.encryptedContentAsn1);\n var encrypted = forge.util.createBuffer(encryptedContentAsn1.value);\n\n cipher.update(encrypted);\n if(!cipher.finish()) {\n throw new Error('Failed to decrypt PKCS#12 SafeContents.');\n }\n\n return cipher.output.getBytes();\n}\n\n/**\n * Decode PKCS#12 SafeContents (BER-encoded) into array of Bag objects.\n *\n * The safeContents is a BER-encoded SEQUENCE OF SafeBag.\n *\n * @param {String} safeContents BER-encoded safeContents.\n * @param strict true to use strict DER decoding, false not to.\n * @param {String} password Password to decrypt with (optional).\n *\n * @return {Array} Array of Bag objects.\n */\nfunction _decodeSafeContents(safeContents, strict, password) {\n // if strict and no safe contents, return empty safes\n if(!strict && safeContents.length === 0) {\n return [];\n }\n\n // actually it's BER-encoded\n safeContents = asn1.fromDer(safeContents, strict);\n\n if(safeContents.tagClass !== asn1.Class.UNIVERSAL ||\n safeContents.type !== asn1.Type.SEQUENCE ||\n safeContents.constructed !== true) {\n throw new Error(\n 'PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.');\n }\n\n var res = [];\n for(var i = 0; i < safeContents.value.length; i++) {\n var safeBag = safeContents.value[i];\n\n // validate SafeBag and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(safeBag, safeBagValidator, capture, errors)) {\n var error = new Error('Cannot read SafeBag.');\n error.errors = errors;\n throw error;\n }\n\n /* Create bag object and push to result array. */\n var bag = {\n type: asn1.derToOid(capture.bagId),\n attributes: _decodeBagAttributes(capture.bagAttributes)\n };\n res.push(bag);\n\n var validator, decoder;\n var bagAsn1 = capture.bagValue.value[0];\n switch(bag.type) {\n case pki.oids.pkcs8ShroudedKeyBag:\n /* bagAsn1 has a EncryptedPrivateKeyInfo, which we need to decrypt.\n Afterwards we can handle it like a keyBag,\n which is a PrivateKeyInfo. */\n bagAsn1 = pki.decryptPrivateKeyInfo(bagAsn1, password);\n if(bagAsn1 === null) {\n throw new Error(\n 'Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?');\n }\n\n /* fall through */\n case pki.oids.keyBag:\n /* A PKCS#12 keyBag is a simple PrivateKeyInfo as understood by our\n PKI module, hence we don't have to do validation/capturing here,\n just pass what we already got. */\n try {\n bag.key = pki.privateKeyFromAsn1(bagAsn1);\n } catch(e) {\n // ignore unknown key type, pass asn1 value\n bag.key = null;\n bag.asn1 = bagAsn1;\n }\n continue; /* Nothing more to do. */\n\n case pki.oids.certBag:\n /* A PKCS#12 certBag can wrap both X.509 and sdsi certificates.\n Therefore put the SafeBag content through another validator to\n capture the fields. Afterwards check & store the results. */\n validator = certBagValidator;\n decoder = function() {\n if(asn1.derToOid(capture.certId) !== pki.oids.x509Certificate) {\n var error = new Error(\n 'Unsupported certificate type, only X.509 supported.');\n error.oid = asn1.derToOid(capture.certId);\n throw error;\n }\n\n // true=produce cert hash\n var certAsn1 = asn1.fromDer(capture.cert, strict);\n try {\n bag.cert = pki.certificateFromAsn1(certAsn1, true);\n } catch(e) {\n // ignore unknown cert type, pass asn1 value\n bag.cert = null;\n bag.asn1 = certAsn1;\n }\n };\n break;\n\n default:\n var error = new Error('Unsupported PKCS#12 SafeBag type.');\n error.oid = bag.type;\n throw error;\n }\n\n /* Validate SafeBag value (i.e. CertBag, etc.) and capture data if needed. */\n if(validator !== undefined &&\n !asn1.validate(bagAsn1, validator, capture, errors)) {\n var error = new Error('Cannot read PKCS#12 ' + validator.name);\n error.errors = errors;\n throw error;\n }\n\n /* Call decoder function from above to store the results. */\n decoder();\n }\n\n return res;\n}\n\n/**\n * Decode PKCS#12 SET OF PKCS12Attribute into JavaScript object.\n *\n * @param attributes SET OF PKCS12Attribute (ASN.1 object).\n *\n * @return the decoded attributes.\n */\nfunction _decodeBagAttributes(attributes) {\n var decodedAttrs = {};\n\n if(attributes !== undefined) {\n for(var i = 0; i < attributes.length; ++i) {\n var capture = {};\n var errors = [];\n if(!asn1.validate(attributes[i], attributeValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#12 BagAttribute.');\n error.errors = errors;\n throw error;\n }\n\n var oid = asn1.derToOid(capture.oid);\n if(pki.oids[oid] === undefined) {\n // unsupported attribute type, ignore.\n continue;\n }\n\n decodedAttrs[pki.oids[oid]] = [];\n for(var j = 0; j < capture.values.length; ++j) {\n decodedAttrs[pki.oids[oid]].push(capture.values[j].value);\n }\n }\n }\n\n return decodedAttrs;\n}\n\n/**\n * Wraps a private key and certificate in a PKCS#12 PFX wrapper. If a\n * password is provided then the private key will be encrypted.\n *\n * An entire certificate chain may also be included. To do this, pass\n * an array for the \"cert\" parameter where the first certificate is\n * the one that is paired with the private key and each subsequent one\n * verifies the previous one. The certificates may be in PEM format or\n * have been already parsed by Forge.\n *\n * @todo implement password-based-encryption for the whole package\n *\n * @param key the private key.\n * @param cert the certificate (may be an array of certificates in order\n * to specify a certificate chain).\n * @param password the password to use, null for none.\n * @param options:\n * algorithm the encryption algorithm to use\n * ('aes128', 'aes192', 'aes256', '3des'), defaults to 'aes128'.\n * count the iteration count to use.\n * saltSize the salt size to use.\n * useMac true to include a MAC, false not to, defaults to true.\n * localKeyId the local key ID to use, in hex.\n * friendlyName the friendly name to use.\n * generateLocalKeyId true to generate a random local key ID,\n * false not to, defaults to true.\n *\n * @return the PKCS#12 PFX ASN.1 object.\n */\np12.toPkcs12Asn1 = function(key, cert, password, options) {\n // set default options\n options = options || {};\n options.saltSize = options.saltSize || 8;\n options.count = options.count || 2048;\n options.algorithm = options.algorithm || options.encAlgorithm || 'aes128';\n if(!('useMac' in options)) {\n options.useMac = true;\n }\n if(!('localKeyId' in options)) {\n options.localKeyId = null;\n }\n if(!('generateLocalKeyId' in options)) {\n options.generateLocalKeyId = true;\n }\n\n var localKeyId = options.localKeyId;\n var bagAttrs;\n if(localKeyId !== null) {\n localKeyId = forge.util.hexToBytes(localKeyId);\n } else if(options.generateLocalKeyId) {\n // use SHA-1 of paired cert, if available\n if(cert) {\n var pairedCert = forge.util.isArray(cert) ? cert[0] : cert;\n if(typeof pairedCert === 'string') {\n pairedCert = pki.certificateFromPem(pairedCert);\n }\n var sha1 = forge.md.sha1.create();\n sha1.update(asn1.toDer(pki.certificateToAsn1(pairedCert)).getBytes());\n localKeyId = sha1.digest().getBytes();\n } else {\n // FIXME: consider using SHA-1 of public key (which can be generated\n // from private key components), see: cert.generateSubjectKeyIdentifier\n // generate random bytes\n localKeyId = forge.random.getBytes(20);\n }\n }\n\n var attrs = [];\n if(localKeyId !== null) {\n attrs.push(\n // localKeyID\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // attrId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.localKeyId).getBytes()),\n // attrValues\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n localKeyId)\n ])\n ]));\n }\n if('friendlyName' in options) {\n attrs.push(\n // friendlyName\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // attrId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.friendlyName).getBytes()),\n // attrValues\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BMPSTRING, false,\n options.friendlyName)\n ])\n ]));\n }\n\n if(attrs.length > 0) {\n bagAttrs = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, attrs);\n }\n\n // collect contents for AuthenticatedSafe\n var contents = [];\n\n // create safe bag(s) for certificate chain\n var chain = [];\n if(cert !== null) {\n if(forge.util.isArray(cert)) {\n chain = cert;\n } else {\n chain = [cert];\n }\n }\n\n var certSafeBags = [];\n for(var i = 0; i < chain.length; ++i) {\n // convert cert from PEM as necessary\n cert = chain[i];\n if(typeof cert === 'string') {\n cert = pki.certificateFromPem(cert);\n }\n\n // SafeBag\n var certBagAttrs = (i === 0) ? bagAttrs : undefined;\n var certAsn1 = pki.certificateToAsn1(cert);\n var certSafeBag =\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // bagId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.certBag).getBytes()),\n // bagValue\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n // CertBag\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // certId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.x509Certificate).getBytes()),\n // certValue (x509Certificate)\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(certAsn1).getBytes())\n ])])]),\n // bagAttributes (OPTIONAL)\n certBagAttrs\n ]);\n certSafeBags.push(certSafeBag);\n }\n\n if(certSafeBags.length > 0) {\n // SafeContents\n var certSafeContents = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, certSafeBags);\n\n // ContentInfo\n var certCI =\n // PKCS#7 ContentInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // contentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n // OID for the content type is 'data'\n asn1.oidToDer(pki.oids.data).getBytes()),\n // content\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(certSafeContents).getBytes())\n ])\n ]);\n contents.push(certCI);\n }\n\n // create safe contents for private key\n var keyBag = null;\n if(key !== null) {\n // SafeBag\n var pkAsn1 = pki.wrapRsaPrivateKey(pki.privateKeyToAsn1(key));\n if(password === null) {\n // no encryption\n keyBag = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // bagId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.keyBag).getBytes()),\n // bagValue\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n // PrivateKeyInfo\n pkAsn1\n ]),\n // bagAttributes (OPTIONAL)\n bagAttrs\n ]);\n } else {\n // encrypted PrivateKeyInfo\n keyBag = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // bagId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.pkcs8ShroudedKeyBag).getBytes()),\n // bagValue\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n // EncryptedPrivateKeyInfo\n pki.encryptPrivateKeyInfo(pkAsn1, password, options)\n ]),\n // bagAttributes (OPTIONAL)\n bagAttrs\n ]);\n }\n\n // SafeContents\n var keySafeContents =\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [keyBag]);\n\n // ContentInfo\n var keyCI =\n // PKCS#7 ContentInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // contentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n // OID for the content type is 'data'\n asn1.oidToDer(pki.oids.data).getBytes()),\n // content\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(keySafeContents).getBytes())\n ])\n ]);\n contents.push(keyCI);\n }\n\n // create AuthenticatedSafe by stringing together the contents\n var safe = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, contents);\n\n var macData;\n if(options.useMac) {\n // MacData\n var sha1 = forge.md.sha1.create();\n var macSalt = new forge.util.ByteBuffer(\n forge.random.getBytes(options.saltSize));\n var count = options.count;\n // 160-bit key\n var key = p12.generateKey(password, macSalt, 3, count, 20);\n var mac = forge.hmac.create();\n mac.start(sha1, key);\n mac.update(asn1.toDer(safe).getBytes());\n var macValue = mac.getMac();\n macData = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // mac DigestInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // digestAlgorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm = SHA-1\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.sha1).getBytes()),\n // parameters = Null\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]),\n // digest\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,\n false, macValue.getBytes())\n ]),\n // macSalt OCTET STRING\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, macSalt.getBytes()),\n // iterations INTEGER (XXX: Only support count < 65536)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(count).getBytes()\n )\n ]);\n }\n\n // PFX\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version (3)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(3).getBytes()),\n // PKCS#7 ContentInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // contentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n // OID for the content type is 'data'\n asn1.oidToDer(pki.oids.data).getBytes()),\n // content\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(safe).getBytes())\n ])\n ]),\n macData\n ]);\n};\n\n/**\n * Derives a PKCS#12 key.\n *\n * @param password the password to derive the key material from, null or\n * undefined for none.\n * @param salt the salt, as a ByteBuffer, to use.\n * @param id the PKCS#12 ID byte (1 = key material, 2 = IV, 3 = MAC).\n * @param iter the iteration count.\n * @param n the number of bytes to derive from the password.\n * @param md the message digest to use, defaults to SHA-1.\n *\n * @return a ByteBuffer with the bytes derived from the password.\n */\np12.generateKey = forge.pbe.generatePkcs12Key;\n","/**\n * Javascript implementation of PKCS#7 v1.5.\n *\n * @author Stefan Siegl\n * @author Dave Longley\n *\n * Copyright (c) 2012 Stefan Siegl \n * Copyright (c) 2012-2015 Digital Bazaar, Inc.\n *\n * Currently this implementation only supports ContentType of EnvelopedData,\n * EncryptedData, or SignedData at the root level. The top level elements may\n * contain only a ContentInfo of ContentType Data, i.e. plain data. Further\n * nesting is not (yet) supported.\n *\n * The Forge validators for PKCS #7's ASN.1 structures are available from\n * a separate file pkcs7asn1.js, since those are referenced from other\n * PKCS standards like PKCS #12.\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./asn1');\nrequire('./des');\nrequire('./oids');\nrequire('./pem');\nrequire('./pkcs7asn1');\nrequire('./random');\nrequire('./util');\nrequire('./x509');\n\n// shortcut for ASN.1 API\nvar asn1 = forge.asn1;\n\n// shortcut for PKCS#7 API\nvar p7 = module.exports = forge.pkcs7 = forge.pkcs7 || {};\n\n/**\n * Converts a PKCS#7 message from PEM format.\n *\n * @param pem the PEM-formatted PKCS#7 message.\n *\n * @return the PKCS#7 message.\n */\np7.messageFromPem = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'PKCS7') {\n var error = new Error('Could not convert PKCS#7 message from PEM; PEM ' +\n 'header type is not \"PKCS#7\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert PKCS#7 message from PEM; PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body);\n\n return p7.messageFromAsn1(obj);\n};\n\n/**\n * Converts a PKCS#7 message to PEM format.\n *\n * @param msg The PKCS#7 message object\n * @param maxline The maximum characters per line, defaults to 64.\n *\n * @return The PEM-formatted PKCS#7 message.\n */\np7.messageToPem = function(msg, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var pemObj = {\n type: 'PKCS7',\n body: asn1.toDer(msg.toAsn1()).getBytes()\n };\n return forge.pem.encode(pemObj, {maxline: maxline});\n};\n\n/**\n * Converts a PKCS#7 message from an ASN.1 object.\n *\n * @param obj the ASN.1 representation of a ContentInfo.\n *\n * @return the PKCS#7 message.\n */\np7.messageFromAsn1 = function(obj) {\n // validate root level ContentInfo and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, p7.asn1.contentInfoValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#7 message. ' +\n 'ASN.1 object is not an PKCS#7 ContentInfo.');\n error.errors = errors;\n throw error;\n }\n\n var contentType = asn1.derToOid(capture.contentType);\n var msg;\n\n switch(contentType) {\n case forge.pki.oids.envelopedData:\n msg = p7.createEnvelopedData();\n break;\n\n case forge.pki.oids.encryptedData:\n msg = p7.createEncryptedData();\n break;\n\n case forge.pki.oids.signedData:\n msg = p7.createSignedData();\n break;\n\n default:\n throw new Error('Cannot read PKCS#7 message. ContentType with OID ' +\n contentType + ' is not (yet) supported.');\n }\n\n msg.fromAsn1(capture.content.value[0]);\n return msg;\n};\n\np7.createSignedData = function() {\n var msg = null;\n msg = {\n type: forge.pki.oids.signedData,\n version: 1,\n certificates: [],\n crls: [],\n // TODO: add json-formatted signer stuff here?\n signers: [],\n // populated during sign()\n digestAlgorithmIdentifiers: [],\n contentInfo: null,\n signerInfos: [],\n\n fromAsn1: function(obj) {\n // validate SignedData content block and capture data.\n _fromAsn1(msg, obj, p7.asn1.signedDataValidator);\n msg.certificates = [];\n msg.crls = [];\n msg.digestAlgorithmIdentifiers = [];\n msg.contentInfo = null;\n msg.signerInfos = [];\n\n if(msg.rawCapture.certificates) {\n var certs = msg.rawCapture.certificates.value;\n for(var i = 0; i < certs.length; ++i) {\n msg.certificates.push(forge.pki.certificateFromAsn1(certs[i]));\n }\n }\n\n // TODO: parse crls\n },\n\n toAsn1: function() {\n // degenerate case with no content\n if(!msg.contentInfo) {\n msg.sign();\n }\n\n var certs = [];\n for(var i = 0; i < msg.certificates.length; ++i) {\n certs.push(forge.pki.certificateToAsn1(msg.certificates[i]));\n }\n\n var crls = [];\n // TODO: implement CRLs\n\n // [0] SignedData\n var signedData = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(msg.version).getBytes()),\n // DigestAlgorithmIdentifiers\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SET, true,\n msg.digestAlgorithmIdentifiers),\n // ContentInfo\n msg.contentInfo\n ])\n ]);\n if(certs.length > 0) {\n // [0] IMPLICIT ExtendedCertificatesAndCertificates OPTIONAL\n signedData.value[0].value.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, certs));\n }\n if(crls.length > 0) {\n // [1] IMPLICIT CertificateRevocationLists OPTIONAL\n signedData.value[0].value.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, crls));\n }\n // SignerInfos\n signedData.value[0].value.push(\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true,\n msg.signerInfos));\n\n // ContentInfo\n return asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // ContentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(msg.type).getBytes()),\n // [0] SignedData\n signedData\n ]);\n },\n\n /**\n * Add (another) entity to list of signers.\n *\n * Note: If authenticatedAttributes are provided, then, per RFC 2315,\n * they must include at least two attributes: content type and\n * message digest. The message digest attribute value will be\n * auto-calculated during signing and will be ignored if provided.\n *\n * Here's an example of providing these two attributes:\n *\n * forge.pkcs7.createSignedData();\n * p7.addSigner({\n * issuer: cert.issuer.attributes,\n * serialNumber: cert.serialNumber,\n * key: privateKey,\n * digestAlgorithm: forge.pki.oids.sha1,\n * authenticatedAttributes: [{\n * type: forge.pki.oids.contentType,\n * value: forge.pki.oids.data\n * }, {\n * type: forge.pki.oids.messageDigest\n * }]\n * });\n *\n * TODO: Support [subjectKeyIdentifier] as signer's ID.\n *\n * @param signer the signer information:\n * key the signer's private key.\n * [certificate] a certificate containing the public key\n * associated with the signer's private key; use this option as\n * an alternative to specifying signer.issuer and\n * signer.serialNumber.\n * [issuer] the issuer attributes (eg: cert.issuer.attributes).\n * [serialNumber] the signer's certificate's serial number in\n * hexadecimal (eg: cert.serialNumber).\n * [digestAlgorithm] the message digest OID, as a string, to use\n * (eg: forge.pki.oids.sha1).\n * [authenticatedAttributes] an optional array of attributes\n * to also sign along with the content.\n */\n addSigner: function(signer) {\n var issuer = signer.issuer;\n var serialNumber = signer.serialNumber;\n if(signer.certificate) {\n var cert = signer.certificate;\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n issuer = cert.issuer.attributes;\n serialNumber = cert.serialNumber;\n }\n var key = signer.key;\n if(!key) {\n throw new Error(\n 'Could not add PKCS#7 signer; no private key specified.');\n }\n if(typeof key === 'string') {\n key = forge.pki.privateKeyFromPem(key);\n }\n\n // ensure OID known for digest algorithm\n var digestAlgorithm = signer.digestAlgorithm || forge.pki.oids.sha1;\n switch(digestAlgorithm) {\n case forge.pki.oids.sha1:\n case forge.pki.oids.sha256:\n case forge.pki.oids.sha384:\n case forge.pki.oids.sha512:\n case forge.pki.oids.md5:\n break;\n default:\n throw new Error(\n 'Could not add PKCS#7 signer; unknown message digest algorithm: ' +\n digestAlgorithm);\n }\n\n // if authenticatedAttributes is present, then the attributes\n // must contain at least PKCS #9 content-type and message-digest\n var authenticatedAttributes = signer.authenticatedAttributes || [];\n if(authenticatedAttributes.length > 0) {\n var contentType = false;\n var messageDigest = false;\n for(var i = 0; i < authenticatedAttributes.length; ++i) {\n var attr = authenticatedAttributes[i];\n if(!contentType && attr.type === forge.pki.oids.contentType) {\n contentType = true;\n if(messageDigest) {\n break;\n }\n continue;\n }\n if(!messageDigest && attr.type === forge.pki.oids.messageDigest) {\n messageDigest = true;\n if(contentType) {\n break;\n }\n continue;\n }\n }\n\n if(!contentType || !messageDigest) {\n throw new Error('Invalid signer.authenticatedAttributes. If ' +\n 'signer.authenticatedAttributes is specified, then it must ' +\n 'contain at least two attributes, PKCS #9 content-type and ' +\n 'PKCS #9 message-digest.');\n }\n }\n\n msg.signers.push({\n key: key,\n version: 1,\n issuer: issuer,\n serialNumber: serialNumber,\n digestAlgorithm: digestAlgorithm,\n signatureAlgorithm: forge.pki.oids.rsaEncryption,\n signature: null,\n authenticatedAttributes: authenticatedAttributes,\n unauthenticatedAttributes: []\n });\n },\n\n /**\n * Signs the content.\n * @param options Options to apply when signing:\n * [detached] boolean. If signing should be done in detached mode. Defaults to false.\n */\n sign: function(options) {\n options = options || {};\n // auto-generate content info\n if(typeof msg.content !== 'object' || msg.contentInfo === null) {\n // use Data ContentInfo\n msg.contentInfo = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // ContentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(forge.pki.oids.data).getBytes())\n ]);\n\n // add actual content, if present\n if('content' in msg) {\n var content;\n if(msg.content instanceof forge.util.ByteBuffer) {\n content = msg.content.bytes();\n } else if(typeof msg.content === 'string') {\n content = forge.util.encodeUtf8(msg.content);\n }\n\n if (options.detached) {\n msg.detachedContent = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, content);\n } else {\n msg.contentInfo.value.push(\n // [0] EXPLICIT content\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n content)\n ]));\n }\n }\n }\n\n // no signers, return early (degenerate case for certificate container)\n if(msg.signers.length === 0) {\n return;\n }\n\n // generate digest algorithm identifiers\n var mds = addDigestAlgorithmIds();\n\n // generate signerInfos\n addSignerInfos(mds);\n },\n\n verify: function() {\n throw new Error('PKCS#7 signature verification not yet implemented.');\n },\n\n /**\n * Add a certificate.\n *\n * @param cert the certificate to add.\n */\n addCertificate: function(cert) {\n // convert from PEM\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n msg.certificates.push(cert);\n },\n\n /**\n * Add a certificate revokation list.\n *\n * @param crl the certificate revokation list to add.\n */\n addCertificateRevokationList: function(crl) {\n throw new Error('PKCS#7 CRL support not yet implemented.');\n }\n };\n return msg;\n\n function addDigestAlgorithmIds() {\n var mds = {};\n\n for(var i = 0; i < msg.signers.length; ++i) {\n var signer = msg.signers[i];\n var oid = signer.digestAlgorithm;\n if(!(oid in mds)) {\n // content digest\n mds[oid] = forge.md[forge.pki.oids[oid]].create();\n }\n if(signer.authenticatedAttributes.length === 0) {\n // no custom attributes to digest; use content message digest\n signer.md = mds[oid];\n } else {\n // custom attributes to be digested; use own message digest\n // TODO: optimize to just copy message digest state if that\n // feature is ever supported with message digests\n signer.md = forge.md[forge.pki.oids[oid]].create();\n }\n }\n\n // add unique digest algorithm identifiers\n msg.digestAlgorithmIdentifiers = [];\n for(var oid in mds) {\n msg.digestAlgorithmIdentifiers.push(\n // AlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(oid).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]));\n }\n\n return mds;\n }\n\n function addSignerInfos(mds) {\n var content;\n\n if (msg.detachedContent) {\n // Signature has been made in detached mode.\n content = msg.detachedContent;\n } else {\n // Note: ContentInfo is a SEQUENCE with 2 values, second value is\n // the content field and is optional for a ContentInfo but required here\n // since signers are present\n // get ContentInfo content\n content = msg.contentInfo.value[1];\n // skip [0] EXPLICIT content wrapper\n content = content.value[0];\n }\n\n if(!content) {\n throw new Error(\n 'Could not sign PKCS#7 message; there is no content to sign.');\n }\n\n // get ContentInfo content type\n var contentType = asn1.derToOid(msg.contentInfo.value[0].value);\n\n // serialize content\n var bytes = asn1.toDer(content);\n\n // skip identifier and length per RFC 2315 9.3\n // skip identifier (1 byte)\n bytes.getByte();\n // read and discard length bytes\n asn1.getBerValueLength(bytes);\n bytes = bytes.getBytes();\n\n // digest content DER value bytes\n for(var oid in mds) {\n mds[oid].start().update(bytes);\n }\n\n // sign content\n var signingTime = new Date();\n for(var i = 0; i < msg.signers.length; ++i) {\n var signer = msg.signers[i];\n\n if(signer.authenticatedAttributes.length === 0) {\n // if ContentInfo content type is not \"Data\", then\n // authenticatedAttributes must be present per RFC 2315\n if(contentType !== forge.pki.oids.data) {\n throw new Error(\n 'Invalid signer; authenticatedAttributes must be present ' +\n 'when the ContentInfo content type is not PKCS#7 Data.');\n }\n } else {\n // process authenticated attributes\n // [0] IMPLICIT\n signer.authenticatedAttributesAsn1 = asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, 0, true, []);\n\n // per RFC 2315, attributes are to be digested using a SET container\n // not the above [0] IMPLICIT container\n var attrsAsn1 = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SET, true, []);\n\n for(var ai = 0; ai < signer.authenticatedAttributes.length; ++ai) {\n var attr = signer.authenticatedAttributes[ai];\n if(attr.type === forge.pki.oids.messageDigest) {\n // use content message digest as value\n attr.value = mds[signer.digestAlgorithm].digest();\n } else if(attr.type === forge.pki.oids.signingTime) {\n // auto-populate signing time if not already set\n if(!attr.value) {\n attr.value = signingTime;\n }\n }\n\n // convert to ASN.1 and push onto Attributes SET (for signing) and\n // onto authenticatedAttributesAsn1 to complete SignedData ASN.1\n // TODO: optimize away duplication\n attrsAsn1.value.push(_attributeToAsn1(attr));\n signer.authenticatedAttributesAsn1.value.push(_attributeToAsn1(attr));\n }\n\n // DER-serialize and digest SET OF attributes only\n bytes = asn1.toDer(attrsAsn1).getBytes();\n signer.md.start().update(bytes);\n }\n\n // sign digest\n signer.signature = signer.key.sign(signer.md, 'RSASSA-PKCS1-V1_5');\n }\n\n // add signer info\n msg.signerInfos = _signersToAsn1(msg.signers);\n }\n};\n\n/**\n * Creates an empty PKCS#7 message of type EncryptedData.\n *\n * @return the message.\n */\np7.createEncryptedData = function() {\n var msg = null;\n msg = {\n type: forge.pki.oids.encryptedData,\n version: 0,\n encryptedContent: {\n algorithm: forge.pki.oids['aes256-CBC']\n },\n\n /**\n * Reads an EncryptedData content block (in ASN.1 format)\n *\n * @param obj The ASN.1 representation of the EncryptedData content block\n */\n fromAsn1: function(obj) {\n // Validate EncryptedData content block and capture data.\n _fromAsn1(msg, obj, p7.asn1.encryptedDataValidator);\n },\n\n /**\n * Decrypt encrypted content\n *\n * @param key The (symmetric) key as a byte buffer\n */\n decrypt: function(key) {\n if(key !== undefined) {\n msg.encryptedContent.key = key;\n }\n _decryptContent(msg);\n }\n };\n return msg;\n};\n\n/**\n * Creates an empty PKCS#7 message of type EnvelopedData.\n *\n * @return the message.\n */\np7.createEnvelopedData = function() {\n var msg = null;\n msg = {\n type: forge.pki.oids.envelopedData,\n version: 0,\n recipients: [],\n encryptedContent: {\n algorithm: forge.pki.oids['aes256-CBC']\n },\n\n /**\n * Reads an EnvelopedData content block (in ASN.1 format)\n *\n * @param obj the ASN.1 representation of the EnvelopedData content block.\n */\n fromAsn1: function(obj) {\n // validate EnvelopedData content block and capture data\n var capture = _fromAsn1(msg, obj, p7.asn1.envelopedDataValidator);\n msg.recipients = _recipientsFromAsn1(capture.recipientInfos.value);\n },\n\n toAsn1: function() {\n // ContentInfo\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // ContentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(msg.type).getBytes()),\n // [0] EnvelopedData\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(msg.version).getBytes()),\n // RecipientInfos\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true,\n _recipientsToAsn1(msg.recipients)),\n // EncryptedContentInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true,\n _encryptedContentToAsn1(msg.encryptedContent))\n ])\n ])\n ]);\n },\n\n /**\n * Find recipient by X.509 certificate's issuer.\n *\n * @param cert the certificate with the issuer to look for.\n *\n * @return the recipient object.\n */\n findRecipient: function(cert) {\n var sAttr = cert.issuer.attributes;\n\n for(var i = 0; i < msg.recipients.length; ++i) {\n var r = msg.recipients[i];\n var rAttr = r.issuer;\n\n if(r.serialNumber !== cert.serialNumber) {\n continue;\n }\n\n if(rAttr.length !== sAttr.length) {\n continue;\n }\n\n var match = true;\n for(var j = 0; j < sAttr.length; ++j) {\n if(rAttr[j].type !== sAttr[j].type ||\n rAttr[j].value !== sAttr[j].value) {\n match = false;\n break;\n }\n }\n\n if(match) {\n return r;\n }\n }\n\n return null;\n },\n\n /**\n * Decrypt enveloped content\n *\n * @param recipient The recipient object related to the private key\n * @param privKey The (RSA) private key object\n */\n decrypt: function(recipient, privKey) {\n if(msg.encryptedContent.key === undefined && recipient !== undefined &&\n privKey !== undefined) {\n switch(recipient.encryptedContent.algorithm) {\n case forge.pki.oids.rsaEncryption:\n case forge.pki.oids.desCBC:\n var key = privKey.decrypt(recipient.encryptedContent.content);\n msg.encryptedContent.key = forge.util.createBuffer(key);\n break;\n\n default:\n throw new Error('Unsupported asymmetric cipher, ' +\n 'OID ' + recipient.encryptedContent.algorithm);\n }\n }\n\n _decryptContent(msg);\n },\n\n /**\n * Add (another) entity to list of recipients.\n *\n * @param cert The certificate of the entity to add.\n */\n addRecipient: function(cert) {\n msg.recipients.push({\n version: 0,\n issuer: cert.issuer.attributes,\n serialNumber: cert.serialNumber,\n encryptedContent: {\n // We simply assume rsaEncryption here, since forge.pki only\n // supports RSA so far. If the PKI module supports other\n // ciphers one day, we need to modify this one as well.\n algorithm: forge.pki.oids.rsaEncryption,\n key: cert.publicKey\n }\n });\n },\n\n /**\n * Encrypt enveloped content.\n *\n * This function supports two optional arguments, cipher and key, which\n * can be used to influence symmetric encryption. Unless cipher is\n * provided, the cipher specified in encryptedContent.algorithm is used\n * (defaults to AES-256-CBC). If no key is provided, encryptedContent.key\n * is (re-)used. If that one's not set, a random key will be generated\n * automatically.\n *\n * @param [key] The key to be used for symmetric encryption.\n * @param [cipher] The OID of the symmetric cipher to use.\n */\n encrypt: function(key, cipher) {\n // Part 1: Symmetric encryption\n if(msg.encryptedContent.content === undefined) {\n cipher = cipher || msg.encryptedContent.algorithm;\n key = key || msg.encryptedContent.key;\n\n var keyLen, ivLen, ciphFn;\n switch(cipher) {\n case forge.pki.oids['aes128-CBC']:\n keyLen = 16;\n ivLen = 16;\n ciphFn = forge.aes.createEncryptionCipher;\n break;\n\n case forge.pki.oids['aes192-CBC']:\n keyLen = 24;\n ivLen = 16;\n ciphFn = forge.aes.createEncryptionCipher;\n break;\n\n case forge.pki.oids['aes256-CBC']:\n keyLen = 32;\n ivLen = 16;\n ciphFn = forge.aes.createEncryptionCipher;\n break;\n\n case forge.pki.oids['des-EDE3-CBC']:\n keyLen = 24;\n ivLen = 8;\n ciphFn = forge.des.createEncryptionCipher;\n break;\n\n default:\n throw new Error('Unsupported symmetric cipher, OID ' + cipher);\n }\n\n if(key === undefined) {\n key = forge.util.createBuffer(forge.random.getBytes(keyLen));\n } else if(key.length() != keyLen) {\n throw new Error('Symmetric key has wrong length; ' +\n 'got ' + key.length() + ' bytes, expected ' + keyLen + '.');\n }\n\n // Keep a copy of the key & IV in the object, so the caller can\n // use it for whatever reason.\n msg.encryptedContent.algorithm = cipher;\n msg.encryptedContent.key = key;\n msg.encryptedContent.parameter = forge.util.createBuffer(\n forge.random.getBytes(ivLen));\n\n var ciph = ciphFn(key);\n ciph.start(msg.encryptedContent.parameter.copy());\n ciph.update(msg.content);\n\n // The finish function does PKCS#7 padding by default, therefore\n // no action required by us.\n if(!ciph.finish()) {\n throw new Error('Symmetric encryption failed.');\n }\n\n msg.encryptedContent.content = ciph.output;\n }\n\n // Part 2: asymmetric encryption for each recipient\n for(var i = 0; i < msg.recipients.length; ++i) {\n var recipient = msg.recipients[i];\n\n // Nothing to do, encryption already done.\n if(recipient.encryptedContent.content !== undefined) {\n continue;\n }\n\n switch(recipient.encryptedContent.algorithm) {\n case forge.pki.oids.rsaEncryption:\n recipient.encryptedContent.content =\n recipient.encryptedContent.key.encrypt(\n msg.encryptedContent.key.data);\n break;\n\n default:\n throw new Error('Unsupported asymmetric cipher, OID ' +\n recipient.encryptedContent.algorithm);\n }\n }\n }\n };\n return msg;\n};\n\n/**\n * Converts a single recipient from an ASN.1 object.\n *\n * @param obj the ASN.1 RecipientInfo.\n *\n * @return the recipient object.\n */\nfunction _recipientFromAsn1(obj) {\n // validate EnvelopedData content block and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, p7.asn1.recipientInfoValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#7 RecipientInfo. ' +\n 'ASN.1 object is not an PKCS#7 RecipientInfo.');\n error.errors = errors;\n throw error;\n }\n\n return {\n version: capture.version.charCodeAt(0),\n issuer: forge.pki.RDNAttributesAsArray(capture.issuer),\n serialNumber: forge.util.createBuffer(capture.serial).toHex(),\n encryptedContent: {\n algorithm: asn1.derToOid(capture.encAlgorithm),\n parameter: capture.encParameter.value,\n content: capture.encKey\n }\n };\n}\n\n/**\n * Converts a single recipient object to an ASN.1 object.\n *\n * @param obj the recipient object.\n *\n * @return the ASN.1 RecipientInfo.\n */\nfunction _recipientToAsn1(obj) {\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(obj.version).getBytes()),\n // IssuerAndSerialNumber\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Name\n forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),\n // Serial\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n forge.util.hexToBytes(obj.serialNumber))\n ]),\n // KeyEncryptionAlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(obj.encryptedContent.algorithm).getBytes()),\n // Parameter, force NULL, only RSA supported for now.\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]),\n // EncryptedKey\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n obj.encryptedContent.content)\n ]);\n}\n\n/**\n * Map a set of RecipientInfo ASN.1 objects to recipient objects.\n *\n * @param infos an array of ASN.1 representations RecipientInfo (i.e. SET OF).\n *\n * @return an array of recipient objects.\n */\nfunction _recipientsFromAsn1(infos) {\n var ret = [];\n for(var i = 0; i < infos.length; ++i) {\n ret.push(_recipientFromAsn1(infos[i]));\n }\n return ret;\n}\n\n/**\n * Map an array of recipient objects to ASN.1 RecipientInfo objects.\n *\n * @param recipients an array of recipientInfo objects.\n *\n * @return an array of ASN.1 RecipientInfos.\n */\nfunction _recipientsToAsn1(recipients) {\n var ret = [];\n for(var i = 0; i < recipients.length; ++i) {\n ret.push(_recipientToAsn1(recipients[i]));\n }\n return ret;\n}\n\n/**\n * Converts a single signer from an ASN.1 object.\n *\n * @param obj the ASN.1 representation of a SignerInfo.\n *\n * @return the signer object.\n */\nfunction _signerFromAsn1(obj) {\n // validate EnvelopedData content block and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, p7.asn1.signerInfoValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#7 SignerInfo. ' +\n 'ASN.1 object is not an PKCS#7 SignerInfo.');\n error.errors = errors;\n throw error;\n }\n\n var rval = {\n version: capture.version.charCodeAt(0),\n issuer: forge.pki.RDNAttributesAsArray(capture.issuer),\n serialNumber: forge.util.createBuffer(capture.serial).toHex(),\n digestAlgorithm: asn1.derToOid(capture.digestAlgorithm),\n signatureAlgorithm: asn1.derToOid(capture.signatureAlgorithm),\n signature: capture.signature,\n authenticatedAttributes: [],\n unauthenticatedAttributes: []\n };\n\n // TODO: convert attributes\n var authenticatedAttributes = capture.authenticatedAttributes || [];\n var unauthenticatedAttributes = capture.unauthenticatedAttributes || [];\n\n return rval;\n}\n\n/**\n * Converts a single signerInfo object to an ASN.1 object.\n *\n * @param obj the signerInfo object.\n *\n * @return the ASN.1 representation of a SignerInfo.\n */\nfunction _signerToAsn1(obj) {\n // SignerInfo\n var rval = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(obj.version).getBytes()),\n // issuerAndSerialNumber\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // name\n forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),\n // serial\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n forge.util.hexToBytes(obj.serialNumber))\n ]),\n // digestAlgorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(obj.digestAlgorithm).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ])\n ]);\n\n // authenticatedAttributes (OPTIONAL)\n if(obj.authenticatedAttributesAsn1) {\n // add ASN.1 previously generated during signing\n rval.value.push(obj.authenticatedAttributesAsn1);\n }\n\n // digestEncryptionAlgorithm\n rval.value.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(obj.signatureAlgorithm).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]));\n\n // encryptedDigest\n rval.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, obj.signature));\n\n // unauthenticatedAttributes (OPTIONAL)\n if(obj.unauthenticatedAttributes.length > 0) {\n // [1] IMPLICIT\n var attrsAsn1 = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, []);\n for(var i = 0; i < obj.unauthenticatedAttributes.length; ++i) {\n var attr = obj.unauthenticatedAttributes[i];\n attrsAsn1.values.push(_attributeToAsn1(attr));\n }\n rval.value.push(attrsAsn1);\n }\n\n return rval;\n}\n\n/**\n * Map a set of SignerInfo ASN.1 objects to an array of signer objects.\n *\n * @param signerInfoAsn1s an array of ASN.1 SignerInfos (i.e. SET OF).\n *\n * @return an array of signers objects.\n */\nfunction _signersFromAsn1(signerInfoAsn1s) {\n var ret = [];\n for(var i = 0; i < signerInfoAsn1s.length; ++i) {\n ret.push(_signerFromAsn1(signerInfoAsn1s[i]));\n }\n return ret;\n}\n\n/**\n * Map an array of signer objects to ASN.1 objects.\n *\n * @param signers an array of signer objects.\n *\n * @return an array of ASN.1 SignerInfos.\n */\nfunction _signersToAsn1(signers) {\n var ret = [];\n for(var i = 0; i < signers.length; ++i) {\n ret.push(_signerToAsn1(signers[i]));\n }\n return ret;\n}\n\n/**\n * Convert an attribute object to an ASN.1 Attribute.\n *\n * @param attr the attribute object.\n *\n * @return the ASN.1 Attribute.\n */\nfunction _attributeToAsn1(attr) {\n var value;\n\n // TODO: generalize to support more attributes\n if(attr.type === forge.pki.oids.contentType) {\n value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(attr.value).getBytes());\n } else if(attr.type === forge.pki.oids.messageDigest) {\n value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n attr.value.bytes());\n } else if(attr.type === forge.pki.oids.signingTime) {\n /* Note per RFC 2985: Dates between 1 January 1950 and 31 December 2049\n (inclusive) MUST be encoded as UTCTime. Any dates with year values\n before 1950 or after 2049 MUST be encoded as GeneralizedTime. [Further,]\n UTCTime values MUST be expressed in Greenwich Mean Time (Zulu) and MUST\n include seconds (i.e., times are YYMMDDHHMMSSZ), even where the\n number of seconds is zero. Midnight (GMT) must be represented as\n \"YYMMDD000000Z\". */\n // TODO: make these module-level constants\n var jan_1_1950 = new Date('1950-01-01T00:00:00Z');\n var jan_1_2050 = new Date('2050-01-01T00:00:00Z');\n var date = attr.value;\n if(typeof date === 'string') {\n // try to parse date\n var timestamp = Date.parse(date);\n if(!isNaN(timestamp)) {\n date = new Date(timestamp);\n } else if(date.length === 13) {\n // YYMMDDHHMMSSZ (13 chars for UTCTime)\n date = asn1.utcTimeToDate(date);\n } else {\n // assume generalized time\n date = asn1.generalizedTimeToDate(date);\n }\n }\n\n if(date >= jan_1_1950 && date < jan_1_2050) {\n value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.UTCTIME, false,\n asn1.dateToUtcTime(date));\n } else {\n value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.GENERALIZEDTIME, false,\n asn1.dateToGeneralizedTime(date));\n }\n }\n\n // TODO: expose as common API call\n // create a RelativeDistinguishedName set\n // each value in the set is an AttributeTypeAndValue first\n // containing the type (an OID) and second the value\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // AttributeType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(attr.type).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n // AttributeValue\n value\n ])\n ]);\n}\n\n/**\n * Map messages encrypted content to ASN.1 objects.\n *\n * @param ec The encryptedContent object of the message.\n *\n * @return ASN.1 representation of the encryptedContent object (SEQUENCE).\n */\nfunction _encryptedContentToAsn1(ec) {\n return [\n // ContentType, always Data for the moment\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(forge.pki.oids.data).getBytes()),\n // ContentEncryptionAlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(ec.algorithm).getBytes()),\n // Parameters (IV)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n ec.parameter.getBytes())\n ]),\n // [0] EncryptedContent\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n ec.content.getBytes())\n ])\n ];\n}\n\n/**\n * Reads the \"common part\" of an PKCS#7 content block (in ASN.1 format)\n *\n * This function reads the \"common part\" of the PKCS#7 content blocks\n * EncryptedData and EnvelopedData, i.e. version number and symmetrically\n * encrypted content block.\n *\n * The result of the ASN.1 validate and capture process is returned\n * to allow the caller to extract further data, e.g. the list of recipients\n * in case of a EnvelopedData object.\n *\n * @param msg the PKCS#7 object to read the data to.\n * @param obj the ASN.1 representation of the content block.\n * @param validator the ASN.1 structure validator object to use.\n *\n * @return the value map captured by validator object.\n */\nfunction _fromAsn1(msg, obj, validator) {\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, validator, capture, errors)) {\n var error = new Error('Cannot read PKCS#7 message. ' +\n 'ASN.1 object is not a supported PKCS#7 message.');\n error.errors = error;\n throw error;\n }\n\n // Check contentType, so far we only support (raw) Data.\n var contentType = asn1.derToOid(capture.contentType);\n if(contentType !== forge.pki.oids.data) {\n throw new Error('Unsupported PKCS#7 message. ' +\n 'Only wrapped ContentType Data supported.');\n }\n\n if(capture.encryptedContent) {\n var content = '';\n if(forge.util.isArray(capture.encryptedContent)) {\n for(var i = 0; i < capture.encryptedContent.length; ++i) {\n if(capture.encryptedContent[i].type !== asn1.Type.OCTETSTRING) {\n throw new Error('Malformed PKCS#7 message, expecting encrypted ' +\n 'content constructed of only OCTET STRING objects.');\n }\n content += capture.encryptedContent[i].value;\n }\n } else {\n content = capture.encryptedContent;\n }\n msg.encryptedContent = {\n algorithm: asn1.derToOid(capture.encAlgorithm),\n parameter: forge.util.createBuffer(capture.encParameter.value),\n content: forge.util.createBuffer(content)\n };\n }\n\n if(capture.content) {\n var content = '';\n if(forge.util.isArray(capture.content)) {\n for(var i = 0; i < capture.content.length; ++i) {\n if(capture.content[i].type !== asn1.Type.OCTETSTRING) {\n throw new Error('Malformed PKCS#7 message, expecting ' +\n 'content constructed of only OCTET STRING objects.');\n }\n content += capture.content[i].value;\n }\n } else {\n content = capture.content;\n }\n msg.content = forge.util.createBuffer(content);\n }\n\n msg.version = capture.version.charCodeAt(0);\n msg.rawCapture = capture;\n\n return capture;\n}\n\n/**\n * Decrypt the symmetrically encrypted content block of the PKCS#7 message.\n *\n * Decryption is skipped in case the PKCS#7 message object already has a\n * (decrypted) content attribute. The algorithm, key and cipher parameters\n * (probably the iv) are taken from the encryptedContent attribute of the\n * message object.\n *\n * @param The PKCS#7 message object.\n */\nfunction _decryptContent(msg) {\n if(msg.encryptedContent.key === undefined) {\n throw new Error('Symmetric key not available.');\n }\n\n if(msg.content === undefined) {\n var ciph;\n\n switch(msg.encryptedContent.algorithm) {\n case forge.pki.oids['aes128-CBC']:\n case forge.pki.oids['aes192-CBC']:\n case forge.pki.oids['aes256-CBC']:\n ciph = forge.aes.createDecryptionCipher(msg.encryptedContent.key);\n break;\n\n case forge.pki.oids['desCBC']:\n case forge.pki.oids['des-EDE3-CBC']:\n ciph = forge.des.createDecryptionCipher(msg.encryptedContent.key);\n break;\n\n default:\n throw new Error('Unsupported symmetric cipher, OID ' +\n msg.encryptedContent.algorithm);\n }\n ciph.start(msg.encryptedContent.parameter);\n ciph.update(msg.encryptedContent.content);\n\n if(!ciph.finish()) {\n throw new Error('Symmetric decryption failed.');\n }\n\n msg.content = ciph.output;\n }\n}\n","/**\n * Javascript implementation of ASN.1 validators for PKCS#7 v1.5.\n *\n * @author Dave Longley\n * @author Stefan Siegl\n *\n * Copyright (c) 2012-2015 Digital Bazaar, Inc.\n * Copyright (c) 2012 Stefan Siegl \n *\n * The ASN.1 representation of PKCS#7 is as follows\n * (see RFC #2315 for details, http://www.ietf.org/rfc/rfc2315.txt):\n *\n * A PKCS#7 message consists of a ContentInfo on root level, which may\n * contain any number of further ContentInfo nested into it.\n *\n * ContentInfo ::= SEQUENCE {\n * contentType ContentType,\n * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL\n * }\n *\n * ContentType ::= OBJECT IDENTIFIER\n *\n * EnvelopedData ::= SEQUENCE {\n * version Version,\n * recipientInfos RecipientInfos,\n * encryptedContentInfo EncryptedContentInfo\n * }\n *\n * EncryptedData ::= SEQUENCE {\n * version Version,\n * encryptedContentInfo EncryptedContentInfo\n * }\n *\n * id-signedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)\n * us(840) rsadsi(113549) pkcs(1) pkcs7(7) 2 }\n *\n * SignedData ::= SEQUENCE {\n * version INTEGER,\n * digestAlgorithms DigestAlgorithmIdentifiers,\n * contentInfo ContentInfo,\n * certificates [0] IMPLICIT Certificates OPTIONAL,\n * crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,\n * signerInfos SignerInfos\n * }\n *\n * SignerInfos ::= SET OF SignerInfo\n *\n * SignerInfo ::= SEQUENCE {\n * version Version,\n * issuerAndSerialNumber IssuerAndSerialNumber,\n * digestAlgorithm DigestAlgorithmIdentifier,\n * authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL,\n * digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier,\n * encryptedDigest EncryptedDigest,\n * unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL\n * }\n *\n * EncryptedDigest ::= OCTET STRING\n *\n * Attributes ::= SET OF Attribute\n *\n * Attribute ::= SEQUENCE {\n * attrType OBJECT IDENTIFIER,\n * attrValues SET OF AttributeValue\n * }\n *\n * AttributeValue ::= ANY\n *\n * Version ::= INTEGER\n *\n * RecipientInfos ::= SET OF RecipientInfo\n *\n * EncryptedContentInfo ::= SEQUENCE {\n * contentType ContentType,\n * contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,\n * encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL\n * }\n *\n * ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier\n *\n * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters\n * for the algorithm, if any. In the case of AES and DES3, there is only one,\n * the IV.\n *\n * AlgorithmIdentifer ::= SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * parameters ANY DEFINED BY algorithm OPTIONAL\n * }\n *\n * EncryptedContent ::= OCTET STRING\n *\n * RecipientInfo ::= SEQUENCE {\n * version Version,\n * issuerAndSerialNumber IssuerAndSerialNumber,\n * keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,\n * encryptedKey EncryptedKey\n * }\n *\n * IssuerAndSerialNumber ::= SEQUENCE {\n * issuer Name,\n * serialNumber CertificateSerialNumber\n * }\n *\n * CertificateSerialNumber ::= INTEGER\n *\n * KeyEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier\n *\n * EncryptedKey ::= OCTET STRING\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./util');\n\n// shortcut for ASN.1 API\nvar asn1 = forge.asn1;\n\n// shortcut for PKCS#7 API\nvar p7v = module.exports = forge.pkcs7asn1 = forge.pkcs7asn1 || {};\nforge.pkcs7 = forge.pkcs7 || {};\nforge.pkcs7.asn1 = p7v;\n\nvar contentInfoValidator = {\n name: 'ContentInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'ContentInfo.ContentType',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'contentType'\n }, {\n name: 'ContentInfo.content',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n optional: true,\n captureAsn1: 'content'\n }]\n};\np7v.contentInfoValidator = contentInfoValidator;\n\nvar encryptedContentInfoValidator = {\n name: 'EncryptedContentInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EncryptedContentInfo.contentType',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'contentType'\n }, {\n name: 'EncryptedContentInfo.contentEncryptionAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EncryptedContentInfo.contentEncryptionAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'encAlgorithm'\n }, {\n name: 'EncryptedContentInfo.contentEncryptionAlgorithm.parameter',\n tagClass: asn1.Class.UNIVERSAL,\n captureAsn1: 'encParameter'\n }]\n }, {\n name: 'EncryptedContentInfo.encryptedContent',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n /* The PKCS#7 structure output by OpenSSL somewhat differs from what\n * other implementations do generate.\n *\n * OpenSSL generates a structure like this:\n * SEQUENCE {\n * ...\n * [0]\n * 26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38\n * C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45\n * ...\n * }\n *\n * Whereas other implementations (and this PKCS#7 module) generate:\n * SEQUENCE {\n * ...\n * [0] {\n * OCTET STRING\n * 26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38\n * C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45\n * ...\n * }\n * }\n *\n * In order to support both, we just capture the context specific\n * field here. The OCTET STRING bit is removed below.\n */\n capture: 'encryptedContent',\n captureAsn1: 'encryptedContentAsn1'\n }]\n};\n\np7v.envelopedDataValidator = {\n name: 'EnvelopedData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EnvelopedData.Version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n }, {\n name: 'EnvelopedData.RecipientInfos',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true,\n captureAsn1: 'recipientInfos'\n }].concat(encryptedContentInfoValidator)\n};\n\np7v.encryptedDataValidator = {\n name: 'EncryptedData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EncryptedData.Version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n }].concat(encryptedContentInfoValidator)\n};\n\nvar signerValidator = {\n name: 'SignerInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SignerInfo.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false\n }, {\n name: 'SignerInfo.issuerAndSerialNumber',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SignerInfo.issuerAndSerialNumber.issuer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'issuer'\n }, {\n name: 'SignerInfo.issuerAndSerialNumber.serialNumber',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'serial'\n }]\n }, {\n name: 'SignerInfo.digestAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SignerInfo.digestAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'digestAlgorithm'\n }, {\n name: 'SignerInfo.digestAlgorithm.parameter',\n tagClass: asn1.Class.UNIVERSAL,\n constructed: false,\n captureAsn1: 'digestParameter',\n optional: true\n }]\n }, {\n name: 'SignerInfo.authenticatedAttributes',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n optional: true,\n capture: 'authenticatedAttributes'\n }, {\n name: 'SignerInfo.digestEncryptionAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n capture: 'signatureAlgorithm'\n }, {\n name: 'SignerInfo.encryptedDigest',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'signature'\n }, {\n name: 'SignerInfo.unauthenticatedAttributes',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 1,\n constructed: true,\n optional: true,\n capture: 'unauthenticatedAttributes'\n }]\n};\n\np7v.signedDataValidator = {\n name: 'SignedData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SignedData.Version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n }, {\n name: 'SignedData.DigestAlgorithms',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true,\n captureAsn1: 'digestAlgorithms'\n },\n contentInfoValidator,\n {\n name: 'SignedData.Certificates',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n optional: true,\n captureAsn1: 'certificates'\n }, {\n name: 'SignedData.CertificateRevocationLists',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 1,\n optional: true,\n captureAsn1: 'crls'\n }, {\n name: 'SignedData.SignerInfos',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n capture: 'signerInfos',\n optional: true,\n value: [signerValidator]\n }]\n};\n\np7v.recipientInfoValidator = {\n name: 'RecipientInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'RecipientInfo.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n }, {\n name: 'RecipientInfo.issuerAndSerial',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'RecipientInfo.issuerAndSerial.issuer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'issuer'\n }, {\n name: 'RecipientInfo.issuerAndSerial.serialNumber',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'serial'\n }]\n }, {\n name: 'RecipientInfo.keyEncryptionAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'RecipientInfo.keyEncryptionAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'encAlgorithm'\n }, {\n name: 'RecipientInfo.keyEncryptionAlgorithm.parameter',\n tagClass: asn1.Class.UNIVERSAL,\n constructed: false,\n captureAsn1: 'encParameter'\n }]\n }, {\n name: 'RecipientInfo.encryptedKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'encKey'\n }]\n};\n","/**\n * Javascript implementation of a basic Public Key Infrastructure, including\n * support for RSA public and private keys.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./oids');\nrequire('./pbe');\nrequire('./pem');\nrequire('./pbkdf2');\nrequire('./pkcs12');\nrequire('./pss');\nrequire('./rsa');\nrequire('./util');\nrequire('./x509');\n\n// shortcut for asn.1 API\nvar asn1 = forge.asn1;\n\n/* Public Key Infrastructure (PKI) implementation. */\nvar pki = module.exports = forge.pki = forge.pki || {};\n\n/**\n * NOTE: THIS METHOD IS DEPRECATED. Use pem.decode() instead.\n *\n * Converts PEM-formatted data to DER.\n *\n * @param pem the PEM-formatted data.\n *\n * @return the DER-formatted data.\n */\npki.pemToDer = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert PEM to DER; PEM is encrypted.');\n }\n return forge.util.createBuffer(msg.body);\n};\n\n/**\n * Converts an RSA private key from PEM format.\n *\n * @param pem the PEM-formatted private key.\n *\n * @return the private key.\n */\npki.privateKeyFromPem = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'PRIVATE KEY' && msg.type !== 'RSA PRIVATE KEY') {\n var error = new Error('Could not convert private key from PEM; PEM ' +\n 'header type is not \"PRIVATE KEY\" or \"RSA PRIVATE KEY\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert private key from PEM; PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body);\n\n return pki.privateKeyFromAsn1(obj);\n};\n\n/**\n * Converts an RSA private key to PEM format.\n *\n * @param key the private key.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted private key.\n */\npki.privateKeyToPem = function(key, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'RSA PRIVATE KEY',\n body: asn1.toDer(pki.privateKeyToAsn1(key)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Converts a PrivateKeyInfo to PEM format.\n *\n * @param pki the PrivateKeyInfo.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted private key.\n */\npki.privateKeyInfoToPem = function(pki, maxline) {\n // convert to DER, then PEM-encode\n var msg = {\n type: 'PRIVATE KEY',\n body: asn1.toDer(pki).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n","/**\n * Prime number generation API.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\nrequire('./jsbn');\nrequire('./random');\n\n(function() {\n\n// forge.prime already defined\nif(forge.prime) {\n module.exports = forge.prime;\n return;\n}\n\n/* PRIME API */\nvar prime = module.exports = forge.prime = forge.prime || {};\n\nvar BigInteger = forge.jsbn.BigInteger;\n\n// primes are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29\nvar GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];\nvar THIRTY = new BigInteger(null);\nTHIRTY.fromInt(30);\nvar op_or = function(x, y) {return x|y;};\n\n/**\n * Generates a random probable prime with the given number of bits.\n *\n * Alternative algorithms can be specified by name as a string or as an\n * object with custom options like so:\n *\n * {\n * name: 'PRIMEINC',\n * options: {\n * maxBlockTime: ,\n * millerRabinTests: ,\n * workerScript: ,\n * workers: .\n * workLoad: the size of the work load, ie: number of possible prime\n * numbers for each web worker to check per work assignment,\n * (default: 100).\n * }\n * }\n *\n * @param bits the number of bits for the prime number.\n * @param options the options to use.\n * [algorithm] the algorithm to use (default: 'PRIMEINC').\n * [prng] a custom crypto-secure pseudo-random number generator to use,\n * that must define \"getBytesSync\".\n *\n * @return callback(err, num) called once the operation completes.\n */\nprime.generateProbablePrime = function(bits, options, callback) {\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n // default to PRIMEINC algorithm\n var algorithm = options.algorithm || 'PRIMEINC';\n if(typeof algorithm === 'string') {\n algorithm = {name: algorithm};\n }\n algorithm.options = algorithm.options || {};\n\n // create prng with api that matches BigInteger secure random\n var prng = options.prng || forge.random;\n var rng = {\n // x is an array to fill with bytes\n nextBytes: function(x) {\n var b = prng.getBytesSync(x.length);\n for(var i = 0; i < x.length; ++i) {\n x[i] = b.charCodeAt(i);\n }\n }\n };\n\n if(algorithm.name === 'PRIMEINC') {\n return primeincFindPrime(bits, rng, algorithm.options, callback);\n }\n\n throw new Error('Invalid prime generation algorithm: ' + algorithm.name);\n};\n\nfunction primeincFindPrime(bits, rng, options, callback) {\n if('workers' in options) {\n return primeincFindPrimeWithWorkers(bits, rng, options, callback);\n }\n return primeincFindPrimeWithoutWorkers(bits, rng, options, callback);\n}\n\nfunction primeincFindPrimeWithoutWorkers(bits, rng, options, callback) {\n // initialize random number\n var num = generateRandom(bits, rng);\n\n /* Note: All primes are of the form 30k+i for i < 30 and gcd(30, i)=1. The\n number we are given is always aligned at 30k + 1. Each time the number is\n determined not to be prime we add to get to the next 'i', eg: if the number\n was at 30k + 1 we add 6. */\n var deltaIdx = 0;\n\n // get required number of MR tests\n var mrTests = getMillerRabinTests(num.bitLength());\n if('millerRabinTests' in options) {\n mrTests = options.millerRabinTests;\n }\n\n // find prime nearest to 'num' for maxBlockTime ms\n // 10 ms gives 5ms of leeway for other calculations before dropping\n // below 60fps (1000/60 == 16.67), but in reality, the number will\n // likely be higher due to an 'atomic' big int modPow\n var maxBlockTime = 10;\n if('maxBlockTime' in options) {\n maxBlockTime = options.maxBlockTime;\n }\n\n _primeinc(num, bits, rng, deltaIdx, mrTests, maxBlockTime, callback);\n}\n\nfunction _primeinc(num, bits, rng, deltaIdx, mrTests, maxBlockTime, callback) {\n var start = +new Date();\n do {\n // overflow, regenerate random number\n if(num.bitLength() > bits) {\n num = generateRandom(bits, rng);\n }\n // do primality test\n if(num.isProbablePrime(mrTests)) {\n return callback(null, num);\n }\n // get next potential prime\n num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);\n } while(maxBlockTime < 0 || (+new Date() - start < maxBlockTime));\n\n // keep trying later\n forge.util.setImmediate(function() {\n _primeinc(num, bits, rng, deltaIdx, mrTests, maxBlockTime, callback);\n });\n}\n\n// NOTE: This algorithm is indeterminate in nature because workers\n// run in parallel looking at different segments of numbers. Even if this\n// algorithm is run twice with the same input from a predictable RNG, it\n// may produce different outputs.\nfunction primeincFindPrimeWithWorkers(bits, rng, options, callback) {\n // web workers unavailable\n if(typeof Worker === 'undefined') {\n return primeincFindPrimeWithoutWorkers(bits, rng, options, callback);\n }\n\n // initialize random number\n var num = generateRandom(bits, rng);\n\n // use web workers to generate keys\n var numWorkers = options.workers;\n var workLoad = options.workLoad || 100;\n var range = workLoad * 30 / 8;\n var workerScript = options.workerScript || 'forge/prime.worker.js';\n if(numWorkers === -1) {\n return forge.util.estimateCores(function(err, cores) {\n if(err) {\n // default to 2\n cores = 2;\n }\n numWorkers = cores - 1;\n generate();\n });\n }\n generate();\n\n function generate() {\n // require at least 1 worker\n numWorkers = Math.max(1, numWorkers);\n\n // TODO: consider optimizing by starting workers outside getPrime() ...\n // note that in order to clean up they will have to be made internally\n // asynchronous which may actually be slower\n\n // start workers immediately\n var workers = [];\n for(var i = 0; i < numWorkers; ++i) {\n // FIXME: fix path or use blob URLs\n workers[i] = new Worker(workerScript);\n }\n var running = numWorkers;\n\n // listen for requests from workers and assign ranges to find prime\n for(var i = 0; i < numWorkers; ++i) {\n workers[i].addEventListener('message', workerMessage);\n }\n\n /* Note: The distribution of random numbers is unknown. Therefore, each\n web worker is continuously allocated a range of numbers to check for a\n random number until one is found.\n\n Every 30 numbers will be checked just 8 times, because prime numbers\n have the form:\n\n 30k+i, for i < 30 and gcd(30, i)=1 (there are 8 values of i for this)\n\n Therefore, if we want a web worker to run N checks before asking for\n a new range of numbers, each range must contain N*30/8 numbers.\n\n For 100 checks (workLoad), this is a range of 375. */\n\n var found = false;\n function workerMessage(e) {\n // ignore message, prime already found\n if(found) {\n return;\n }\n\n --running;\n var data = e.data;\n if(data.found) {\n // terminate all workers\n for(var i = 0; i < workers.length; ++i) {\n workers[i].terminate();\n }\n found = true;\n return callback(null, new BigInteger(data.prime, 16));\n }\n\n // overflow, regenerate random number\n if(num.bitLength() > bits) {\n num = generateRandom(bits, rng);\n }\n\n // assign new range to check\n var hex = num.toString(16);\n\n // start prime search\n e.target.postMessage({\n hex: hex,\n workLoad: workLoad\n });\n\n num.dAddOffset(range, 0);\n }\n }\n}\n\n/**\n * Generates a random number using the given number of bits and RNG.\n *\n * @param bits the number of bits for the number.\n * @param rng the random number generator to use.\n *\n * @return the random number.\n */\nfunction generateRandom(bits, rng) {\n var num = new BigInteger(bits, rng);\n // force MSB set\n var bits1 = bits - 1;\n if(!num.testBit(bits1)) {\n num.bitwiseTo(BigInteger.ONE.shiftLeft(bits1), op_or, num);\n }\n // align number on 30k+1 boundary\n num.dAddOffset(31 - num.mod(THIRTY).byteValue(), 0);\n return num;\n}\n\n/**\n * Returns the required number of Miller-Rabin tests to generate a\n * prime with an error probability of (1/2)^80.\n *\n * See Handbook of Applied Cryptography Chapter 4, Table 4.4.\n *\n * @param bits the bit size.\n *\n * @return the required number of iterations.\n */\nfunction getMillerRabinTests(bits) {\n if(bits <= 100) return 27;\n if(bits <= 150) return 18;\n if(bits <= 200) return 15;\n if(bits <= 250) return 12;\n if(bits <= 300) return 9;\n if(bits <= 350) return 8;\n if(bits <= 400) return 7;\n if(bits <= 500) return 6;\n if(bits <= 600) return 5;\n if(bits <= 800) return 4;\n if(bits <= 1250) return 3;\n return 2;\n}\n\n})();\n","/**\n * A javascript implementation of a cryptographically-secure\n * Pseudo Random Number Generator (PRNG). The Fortuna algorithm is followed\n * here though the use of SHA-256 is not enforced; when generating an\n * a PRNG context, the hashing algorithm and block cipher used for\n * the generator are specified via a plugin.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\nvar _crypto = null;\nif(forge.util.isNodejs && !forge.options.usePureJavaScript &&\n !process.versions['node-webkit']) {\n _crypto = require('crypto');\n}\n\n/* PRNG API */\nvar prng = module.exports = forge.prng = forge.prng || {};\n\n/**\n * Creates a new PRNG context.\n *\n * A PRNG plugin must be passed in that will provide:\n *\n * 1. A function that initializes the key and seed of a PRNG context. It\n * will be given a 16 byte key and a 16 byte seed. Any key expansion\n * or transformation of the seed from a byte string into an array of\n * integers (or similar) should be performed.\n * 2. The cryptographic function used by the generator. It takes a key and\n * a seed.\n * 3. A seed increment function. It takes the seed and returns seed + 1.\n * 4. An api to create a message digest.\n *\n * For an example, see random.js.\n *\n * @param plugin the PRNG plugin to use.\n */\nprng.create = function(plugin) {\n var ctx = {\n plugin: plugin,\n key: null,\n seed: null,\n time: null,\n // number of reseeds so far\n reseeds: 0,\n // amount of data generated so far\n generated: 0,\n // no initial key bytes\n keyBytes: ''\n };\n\n // create 32 entropy pools (each is a message digest)\n var md = plugin.md;\n var pools = new Array(32);\n for(var i = 0; i < 32; ++i) {\n pools[i] = md.create();\n }\n ctx.pools = pools;\n\n // entropy pools are written to cyclically, starting at index 0\n ctx.pool = 0;\n\n /**\n * Generates random bytes. The bytes may be generated synchronously or\n * asynchronously. Web workers must use the asynchronous interface or\n * else the behavior is undefined.\n *\n * @param count the number of random bytes to generate.\n * @param [callback(err, bytes)] called once the operation completes.\n *\n * @return count random bytes as a string.\n */\n ctx.generate = function(count, callback) {\n // do synchronously\n if(!callback) {\n return ctx.generateSync(count);\n }\n\n // simple generator using counter-based CBC\n var cipher = ctx.plugin.cipher;\n var increment = ctx.plugin.increment;\n var formatKey = ctx.plugin.formatKey;\n var formatSeed = ctx.plugin.formatSeed;\n var b = forge.util.createBuffer();\n\n // paranoid deviation from Fortuna:\n // reset key for every request to protect previously\n // generated random bytes should the key be discovered;\n // there is no 100ms based reseeding because of this\n // forced reseed for every `generate` call\n ctx.key = null;\n\n generate();\n\n function generate(err) {\n if(err) {\n return callback(err);\n }\n\n // sufficient bytes generated\n if(b.length() >= count) {\n return callback(null, b.getBytes(count));\n }\n\n // if amount of data generated is greater than 1 MiB, trigger reseed\n if(ctx.generated > 0xfffff) {\n ctx.key = null;\n }\n\n if(ctx.key === null) {\n // prevent stack overflow\n return forge.util.nextTick(function() {\n _reseed(generate);\n });\n }\n\n // generate the random bytes\n var bytes = cipher(ctx.key, ctx.seed);\n ctx.generated += bytes.length;\n b.putBytes(bytes);\n\n // generate bytes for a new key and seed\n ctx.key = formatKey(cipher(ctx.key, increment(ctx.seed)));\n ctx.seed = formatSeed(cipher(ctx.key, ctx.seed));\n\n forge.util.setImmediate(generate);\n }\n };\n\n /**\n * Generates random bytes synchronously.\n *\n * @param count the number of random bytes to generate.\n *\n * @return count random bytes as a string.\n */\n ctx.generateSync = function(count) {\n // simple generator using counter-based CBC\n var cipher = ctx.plugin.cipher;\n var increment = ctx.plugin.increment;\n var formatKey = ctx.plugin.formatKey;\n var formatSeed = ctx.plugin.formatSeed;\n\n // paranoid deviation from Fortuna:\n // reset key for every request to protect previously\n // generated random bytes should the key be discovered;\n // there is no 100ms based reseeding because of this\n // forced reseed for every `generateSync` call\n ctx.key = null;\n\n var b = forge.util.createBuffer();\n while(b.length() < count) {\n // if amount of data generated is greater than 1 MiB, trigger reseed\n if(ctx.generated > 0xfffff) {\n ctx.key = null;\n }\n\n if(ctx.key === null) {\n _reseedSync();\n }\n\n // generate the random bytes\n var bytes = cipher(ctx.key, ctx.seed);\n ctx.generated += bytes.length;\n b.putBytes(bytes);\n\n // generate bytes for a new key and seed\n ctx.key = formatKey(cipher(ctx.key, increment(ctx.seed)));\n ctx.seed = formatSeed(cipher(ctx.key, ctx.seed));\n }\n\n return b.getBytes(count);\n };\n\n /**\n * Private function that asynchronously reseeds a generator.\n *\n * @param callback(err) called once the operation completes.\n */\n function _reseed(callback) {\n if(ctx.pools[0].messageLength >= 32) {\n _seed();\n return callback();\n }\n // not enough seed data...\n var needed = (32 - ctx.pools[0].messageLength) << 5;\n ctx.seedFile(needed, function(err, bytes) {\n if(err) {\n return callback(err);\n }\n ctx.collect(bytes);\n _seed();\n callback();\n });\n }\n\n /**\n * Private function that synchronously reseeds a generator.\n */\n function _reseedSync() {\n if(ctx.pools[0].messageLength >= 32) {\n return _seed();\n }\n // not enough seed data...\n var needed = (32 - ctx.pools[0].messageLength) << 5;\n ctx.collect(ctx.seedFileSync(needed));\n _seed();\n }\n\n /**\n * Private function that seeds a generator once enough bytes are available.\n */\n function _seed() {\n // update reseed count\n ctx.reseeds = (ctx.reseeds === 0xffffffff) ? 0 : ctx.reseeds + 1;\n\n // goal is to update `key` via:\n // key = hash(key + s)\n // where 's' is all collected entropy from selected pools, then...\n\n // create a plugin-based message digest\n var md = ctx.plugin.md.create();\n\n // consume current key bytes\n md.update(ctx.keyBytes);\n\n // digest the entropy of pools whose index k meet the\n // condition 'n mod 2^k == 0' where n is the number of reseeds\n var _2powK = 1;\n for(var k = 0; k < 32; ++k) {\n if(ctx.reseeds % _2powK === 0) {\n md.update(ctx.pools[k].digest().getBytes());\n ctx.pools[k].start();\n }\n _2powK = _2powK << 1;\n }\n\n // get digest for key bytes\n ctx.keyBytes = md.digest().getBytes();\n\n // paranoid deviation from Fortuna:\n // update `seed` via `seed = hash(key)`\n // instead of initializing to zero once and only\n // ever incrementing it\n md.start();\n md.update(ctx.keyBytes);\n var seedBytes = md.digest().getBytes();\n\n // update state\n ctx.key = ctx.plugin.formatKey(ctx.keyBytes);\n ctx.seed = ctx.plugin.formatSeed(seedBytes);\n ctx.generated = 0;\n }\n\n /**\n * The built-in default seedFile. This seedFile is used when entropy\n * is needed immediately.\n *\n * @param needed the number of bytes that are needed.\n *\n * @return the random bytes.\n */\n function defaultSeedFile(needed) {\n // use window.crypto.getRandomValues strong source of entropy if available\n var getRandomValues = null;\n var globalScope = forge.util.globalScope;\n var _crypto = globalScope.crypto || globalScope.msCrypto;\n if(_crypto && _crypto.getRandomValues) {\n getRandomValues = function(arr) {\n return _crypto.getRandomValues(arr);\n };\n }\n\n var b = forge.util.createBuffer();\n if(getRandomValues) {\n while(b.length() < needed) {\n // max byte length is 65536 before QuotaExceededError is thrown\n // http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues\n var count = Math.max(1, Math.min(needed - b.length(), 65536) / 4);\n var entropy = new Uint32Array(Math.floor(count));\n try {\n getRandomValues(entropy);\n for(var i = 0; i < entropy.length; ++i) {\n b.putInt32(entropy[i]);\n }\n } catch(e) {\n /* only ignore QuotaExceededError */\n if(!(typeof QuotaExceededError !== 'undefined' &&\n e instanceof QuotaExceededError)) {\n throw e;\n }\n }\n }\n }\n\n // be sad and add some weak random data\n if(b.length() < needed) {\n /* Draws from Park-Miller \"minimal standard\" 31 bit PRNG,\n implemented with David G. Carta's optimization: with 32 bit math\n and without division (Public Domain). */\n var hi, lo, next;\n var seed = Math.floor(Math.random() * 0x010000);\n while(b.length() < needed) {\n lo = 16807 * (seed & 0xFFFF);\n hi = 16807 * (seed >> 16);\n lo += (hi & 0x7FFF) << 16;\n lo += hi >> 15;\n lo = (lo & 0x7FFFFFFF) + (lo >> 31);\n seed = lo & 0xFFFFFFFF;\n\n // consume lower 3 bytes of seed\n for(var i = 0; i < 3; ++i) {\n // throw in more pseudo random\n next = seed >>> (i << 3);\n next ^= Math.floor(Math.random() * 0x0100);\n b.putByte(String.fromCharCode(next & 0xFF));\n }\n }\n }\n\n return b.getBytes(needed);\n }\n // initialize seed file APIs\n if(_crypto) {\n // use nodejs async API\n ctx.seedFile = function(needed, callback) {\n _crypto.randomBytes(needed, function(err, bytes) {\n if(err) {\n return callback(err);\n }\n callback(null, bytes.toString());\n });\n };\n // use nodejs sync API\n ctx.seedFileSync = function(needed) {\n return _crypto.randomBytes(needed).toString();\n };\n } else {\n ctx.seedFile = function(needed, callback) {\n try {\n callback(null, defaultSeedFile(needed));\n } catch(e) {\n callback(e);\n }\n };\n ctx.seedFileSync = defaultSeedFile;\n }\n\n /**\n * Adds entropy to a prng ctx's accumulator.\n *\n * @param bytes the bytes of entropy as a string.\n */\n ctx.collect = function(bytes) {\n // iterate over pools distributing entropy cyclically\n var count = bytes.length;\n for(var i = 0; i < count; ++i) {\n ctx.pools[ctx.pool].update(bytes.substr(i, 1));\n ctx.pool = (ctx.pool === 31) ? 0 : ctx.pool + 1;\n }\n };\n\n /**\n * Collects an integer of n bits.\n *\n * @param i the integer entropy.\n * @param n the number of bits in the integer.\n */\n ctx.collectInt = function(i, n) {\n var bytes = '';\n for(var x = 0; x < n; x += 8) {\n bytes += String.fromCharCode((i >> x) & 0xFF);\n }\n ctx.collect(bytes);\n };\n\n /**\n * Registers a Web Worker to receive immediate entropy from the main thread.\n * This method is required until Web Workers can access the native crypto\n * API. This method should be called twice for each created worker, once in\n * the main thread, and once in the worker itself.\n *\n * @param worker the worker to register.\n */\n ctx.registerWorker = function(worker) {\n // worker receives random bytes\n if(worker === self) {\n ctx.seedFile = function(needed, callback) {\n function listener(e) {\n var data = e.data;\n if(data.forge && data.forge.prng) {\n self.removeEventListener('message', listener);\n callback(data.forge.prng.err, data.forge.prng.bytes);\n }\n }\n self.addEventListener('message', listener);\n self.postMessage({forge: {prng: {needed: needed}}});\n };\n } else {\n // main thread sends random bytes upon request\n var listener = function(e) {\n var data = e.data;\n if(data.forge && data.forge.prng) {\n ctx.seedFile(data.forge.prng.needed, function(err, bytes) {\n worker.postMessage({forge: {prng: {err: err, bytes: bytes}}});\n });\n }\n };\n // TODO: do we need to remove the event listener when the worker dies?\n worker.addEventListener('message', listener);\n }\n };\n\n return ctx;\n};\n","/**\n * Javascript implementation of PKCS#1 PSS signature padding.\n *\n * @author Stefan Siegl\n *\n * Copyright (c) 2012 Stefan Siegl \n */\nvar forge = require('./forge');\nrequire('./random');\nrequire('./util');\n\n// shortcut for PSS API\nvar pss = module.exports = forge.pss = forge.pss || {};\n\n/**\n * Creates a PSS signature scheme object.\n *\n * There are several ways to provide a salt for encoding:\n *\n * 1. Specify the saltLength only and the built-in PRNG will generate it.\n * 2. Specify the saltLength and a custom PRNG with 'getBytesSync' defined that\n * will be used.\n * 3. Specify the salt itself as a forge.util.ByteBuffer.\n *\n * @param options the options to use:\n * md the message digest object to use, a forge md instance.\n * mgf the mask generation function to use, a forge mgf instance.\n * [saltLength] the length of the salt in octets.\n * [prng] the pseudo-random number generator to use to produce a salt.\n * [salt] the salt to use when encoding.\n *\n * @return a signature scheme object.\n */\npss.create = function(options) {\n // backwards compatibility w/legacy args: hash, mgf, sLen\n if(arguments.length === 3) {\n options = {\n md: arguments[0],\n mgf: arguments[1],\n saltLength: arguments[2]\n };\n }\n\n var hash = options.md;\n var mgf = options.mgf;\n var hLen = hash.digestLength;\n\n var salt_ = options.salt || null;\n if(typeof salt_ === 'string') {\n // assume binary-encoded string\n salt_ = forge.util.createBuffer(salt_);\n }\n\n var sLen;\n if('saltLength' in options) {\n sLen = options.saltLength;\n } else if(salt_ !== null) {\n sLen = salt_.length();\n } else {\n throw new Error('Salt length not specified or specific salt not given.');\n }\n\n if(salt_ !== null && salt_.length() !== sLen) {\n throw new Error('Given salt length does not match length of given salt.');\n }\n\n var prng = options.prng || forge.random;\n\n var pssobj = {};\n\n /**\n * Encodes a PSS signature.\n *\n * This function implements EMSA-PSS-ENCODE as per RFC 3447, section 9.1.1.\n *\n * @param md the message digest object with the hash to sign.\n * @param modsBits the length of the RSA modulus in bits.\n *\n * @return the encoded message as a binary-encoded string of length\n * ceil((modBits - 1) / 8).\n */\n pssobj.encode = function(md, modBits) {\n var i;\n var emBits = modBits - 1;\n var emLen = Math.ceil(emBits / 8);\n\n /* 2. Let mHash = Hash(M), an octet string of length hLen. */\n var mHash = md.digest().getBytes();\n\n /* 3. If emLen < hLen + sLen + 2, output \"encoding error\" and stop. */\n if(emLen < hLen + sLen + 2) {\n throw new Error('Message is too long to encrypt.');\n }\n\n /* 4. Generate a random octet string salt of length sLen; if sLen = 0,\n * then salt is the empty string. */\n var salt;\n if(salt_ === null) {\n salt = prng.getBytesSync(sLen);\n } else {\n salt = salt_.bytes();\n }\n\n /* 5. Let M' = (0x)00 00 00 00 00 00 00 00 || mHash || salt; */\n var m_ = new forge.util.ByteBuffer();\n m_.fillWithByte(0, 8);\n m_.putBytes(mHash);\n m_.putBytes(salt);\n\n /* 6. Let H = Hash(M'), an octet string of length hLen. */\n hash.start();\n hash.update(m_.getBytes());\n var h = hash.digest().getBytes();\n\n /* 7. Generate an octet string PS consisting of emLen - sLen - hLen - 2\n * zero octets. The length of PS may be 0. */\n var ps = new forge.util.ByteBuffer();\n ps.fillWithByte(0, emLen - sLen - hLen - 2);\n\n /* 8. Let DB = PS || 0x01 || salt; DB is an octet string of length\n * emLen - hLen - 1. */\n ps.putByte(0x01);\n ps.putBytes(salt);\n var db = ps.getBytes();\n\n /* 9. Let dbMask = MGF(H, emLen - hLen - 1). */\n var maskLen = emLen - hLen - 1;\n var dbMask = mgf.generate(h, maskLen);\n\n /* 10. Let maskedDB = DB \\xor dbMask. */\n var maskedDB = '';\n for(i = 0; i < maskLen; i++) {\n maskedDB += String.fromCharCode(db.charCodeAt(i) ^ dbMask.charCodeAt(i));\n }\n\n /* 11. Set the leftmost 8emLen - emBits bits of the leftmost octet in\n * maskedDB to zero. */\n var mask = (0xFF00 >> (8 * emLen - emBits)) & 0xFF;\n maskedDB = String.fromCharCode(maskedDB.charCodeAt(0) & ~mask) +\n maskedDB.substr(1);\n\n /* 12. Let EM = maskedDB || H || 0xbc.\n * 13. Output EM. */\n return maskedDB + h + String.fromCharCode(0xbc);\n };\n\n /**\n * Verifies a PSS signature.\n *\n * This function implements EMSA-PSS-VERIFY as per RFC 3447, section 9.1.2.\n *\n * @param mHash the message digest hash, as a binary-encoded string, to\n * compare against the signature.\n * @param em the encoded message, as a binary-encoded string\n * (RSA decryption result).\n * @param modsBits the length of the RSA modulus in bits.\n *\n * @return true if the signature was verified, false if not.\n */\n pssobj.verify = function(mHash, em, modBits) {\n var i;\n var emBits = modBits - 1;\n var emLen = Math.ceil(emBits / 8);\n\n /* c. Convert the message representative m to an encoded message EM\n * of length emLen = ceil((modBits - 1) / 8) octets, where modBits\n * is the length in bits of the RSA modulus n */\n em = em.substr(-emLen);\n\n /* 3. If emLen < hLen + sLen + 2, output \"inconsistent\" and stop. */\n if(emLen < hLen + sLen + 2) {\n throw new Error('Inconsistent parameters to PSS signature verification.');\n }\n\n /* 4. If the rightmost octet of EM does not have hexadecimal value\n * 0xbc, output \"inconsistent\" and stop. */\n if(em.charCodeAt(emLen - 1) !== 0xbc) {\n throw new Error('Encoded message does not end in 0xBC.');\n }\n\n /* 5. Let maskedDB be the leftmost emLen - hLen - 1 octets of EM, and\n * let H be the next hLen octets. */\n var maskLen = emLen - hLen - 1;\n var maskedDB = em.substr(0, maskLen);\n var h = em.substr(maskLen, hLen);\n\n /* 6. If the leftmost 8emLen - emBits bits of the leftmost octet in\n * maskedDB are not all equal to zero, output \"inconsistent\" and stop. */\n var mask = (0xFF00 >> (8 * emLen - emBits)) & 0xFF;\n if((maskedDB.charCodeAt(0) & mask) !== 0) {\n throw new Error('Bits beyond keysize not zero as expected.');\n }\n\n /* 7. Let dbMask = MGF(H, emLen - hLen - 1). */\n var dbMask = mgf.generate(h, maskLen);\n\n /* 8. Let DB = maskedDB \\xor dbMask. */\n var db = '';\n for(i = 0; i < maskLen; i++) {\n db += String.fromCharCode(maskedDB.charCodeAt(i) ^ dbMask.charCodeAt(i));\n }\n\n /* 9. Set the leftmost 8emLen - emBits bits of the leftmost octet\n * in DB to zero. */\n db = String.fromCharCode(db.charCodeAt(0) & ~mask) + db.substr(1);\n\n /* 10. If the emLen - hLen - sLen - 2 leftmost octets of DB are not zero\n * or if the octet at position emLen - hLen - sLen - 1 (the leftmost\n * position is \"position 1\") does not have hexadecimal value 0x01,\n * output \"inconsistent\" and stop. */\n var checkLen = emLen - hLen - sLen - 2;\n for(i = 0; i < checkLen; i++) {\n if(db.charCodeAt(i) !== 0x00) {\n throw new Error('Leftmost octets not zero as expected');\n }\n }\n\n if(db.charCodeAt(checkLen) !== 0x01) {\n throw new Error('Inconsistent PSS signature, 0x01 marker not found');\n }\n\n /* 11. Let salt be the last sLen octets of DB. */\n var salt = db.substr(-sLen);\n\n /* 12. Let M' = (0x)00 00 00 00 00 00 00 00 || mHash || salt */\n var m_ = new forge.util.ByteBuffer();\n m_.fillWithByte(0, 8);\n m_.putBytes(mHash);\n m_.putBytes(salt);\n\n /* 13. Let H' = Hash(M'), an octet string of length hLen. */\n hash.start();\n hash.update(m_.getBytes());\n var h_ = hash.digest().getBytes();\n\n /* 14. If H = H', output \"consistent.\" Otherwise, output \"inconsistent.\" */\n return h === h_;\n };\n\n return pssobj;\n};\n","/**\n * An API for getting cryptographically-secure random bytes. The bytes are\n * generated using the Fortuna algorithm devised by Bruce Schneier and\n * Niels Ferguson.\n *\n * Getting strong random bytes is not yet easy to do in javascript. The only\n * truish random entropy that can be collected is from the mouse, keyboard, or\n * from timing with respect to page loads, etc. This generator makes a poor\n * attempt at providing random bytes when those sources haven't yet provided\n * enough entropy to initially seed or to reseed the PRNG.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2009-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./sha256');\nrequire('./prng');\nrequire('./util');\n\n(function() {\n\n// forge.random already defined\nif(forge.random && forge.random.getBytes) {\n module.exports = forge.random;\n return;\n}\n\n(function(jQuery) {\n\n// the default prng plugin, uses AES-128\nvar prng_aes = {};\nvar _prng_aes_output = new Array(4);\nvar _prng_aes_buffer = forge.util.createBuffer();\nprng_aes.formatKey = function(key) {\n // convert the key into 32-bit integers\n var tmp = forge.util.createBuffer(key);\n key = new Array(4);\n key[0] = tmp.getInt32();\n key[1] = tmp.getInt32();\n key[2] = tmp.getInt32();\n key[3] = tmp.getInt32();\n\n // return the expanded key\n return forge.aes._expandKey(key, false);\n};\nprng_aes.formatSeed = function(seed) {\n // convert seed into 32-bit integers\n var tmp = forge.util.createBuffer(seed);\n seed = new Array(4);\n seed[0] = tmp.getInt32();\n seed[1] = tmp.getInt32();\n seed[2] = tmp.getInt32();\n seed[3] = tmp.getInt32();\n return seed;\n};\nprng_aes.cipher = function(key, seed) {\n forge.aes._updateBlock(key, seed, _prng_aes_output, false);\n _prng_aes_buffer.putInt32(_prng_aes_output[0]);\n _prng_aes_buffer.putInt32(_prng_aes_output[1]);\n _prng_aes_buffer.putInt32(_prng_aes_output[2]);\n _prng_aes_buffer.putInt32(_prng_aes_output[3]);\n return _prng_aes_buffer.getBytes();\n};\nprng_aes.increment = function(seed) {\n // FIXME: do we care about carry or signed issues?\n ++seed[3];\n return seed;\n};\nprng_aes.md = forge.md.sha256;\n\n/**\n * Creates a new PRNG.\n */\nfunction spawnPrng() {\n var ctx = forge.prng.create(prng_aes);\n\n /**\n * Gets random bytes. If a native secure crypto API is unavailable, this\n * method tries to make the bytes more unpredictable by drawing from data that\n * can be collected from the user of the browser, eg: mouse movement.\n *\n * If a callback is given, this method will be called asynchronously.\n *\n * @param count the number of random bytes to get.\n * @param [callback(err, bytes)] called once the operation completes.\n *\n * @return the random bytes in a string.\n */\n ctx.getBytes = function(count, callback) {\n return ctx.generate(count, callback);\n };\n\n /**\n * Gets random bytes asynchronously. If a native secure crypto API is\n * unavailable, this method tries to make the bytes more unpredictable by\n * drawing from data that can be collected from the user of the browser,\n * eg: mouse movement.\n *\n * @param count the number of random bytes to get.\n *\n * @return the random bytes in a string.\n */\n ctx.getBytesSync = function(count) {\n return ctx.generate(count);\n };\n\n return ctx;\n}\n\n// create default prng context\nvar _ctx = spawnPrng();\n\n// add other sources of entropy only if window.crypto.getRandomValues is not\n// available -- otherwise this source will be automatically used by the prng\nvar getRandomValues = null;\nvar globalScope = forge.util.globalScope;\nvar _crypto = globalScope.crypto || globalScope.msCrypto;\nif(_crypto && _crypto.getRandomValues) {\n getRandomValues = function(arr) {\n return _crypto.getRandomValues(arr);\n };\n}\n\nif(forge.options.usePureJavaScript ||\n (!forge.util.isNodejs && !getRandomValues)) {\n // if this is a web worker, do not use weak entropy, instead register to\n // receive strong entropy asynchronously from the main thread\n if(typeof window === 'undefined' || window.document === undefined) {\n // FIXME:\n }\n\n // get load time entropy\n _ctx.collectInt(+new Date(), 32);\n\n // add some entropy from navigator object\n if(typeof(navigator) !== 'undefined') {\n var _navBytes = '';\n for(var key in navigator) {\n try {\n if(typeof(navigator[key]) == 'string') {\n _navBytes += navigator[key];\n }\n } catch(e) {\n /* Some navigator keys might not be accessible, e.g. the geolocation\n attribute throws an exception if touched in Mozilla chrome://\n context.\n\n Silently ignore this and just don't use this as a source of\n entropy. */\n }\n }\n _ctx.collect(_navBytes);\n _navBytes = null;\n }\n\n // add mouse and keyboard collectors if jquery is available\n if(jQuery) {\n // set up mouse entropy capture\n jQuery().mousemove(function(e) {\n // add mouse coords\n _ctx.collectInt(e.clientX, 16);\n _ctx.collectInt(e.clientY, 16);\n });\n\n // set up keyboard entropy capture\n jQuery().keypress(function(e) {\n _ctx.collectInt(e.charCode, 8);\n });\n }\n}\n\n/* Random API */\nif(!forge.random) {\n forge.random = _ctx;\n} else {\n // extend forge.random with _ctx\n for(var key in _ctx) {\n forge.random[key] = _ctx[key];\n }\n}\n\n// expose spawn PRNG\nforge.random.createInstance = spawnPrng;\n\nmodule.exports = forge.random;\n\n})(typeof(jQuery) !== 'undefined' ? jQuery : null);\n\n})();\n","/**\n * RC2 implementation.\n *\n * @author Stefan Siegl\n *\n * Copyright (c) 2012 Stefan Siegl \n *\n * Information on the RC2 cipher is available from RFC #2268,\n * http://www.ietf.org/rfc/rfc2268.txt\n */\nvar forge = require('./forge');\nrequire('./util');\n\nvar piTable = [\n 0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d,\n 0xc6, 0x7e, 0x37, 0x83, 0x2b, 0x76, 0x53, 0x8e, 0x62, 0x4c, 0x64, 0x88, 0x44, 0x8b, 0xfb, 0xa2,\n 0x17, 0x9a, 0x59, 0xf5, 0x87, 0xb3, 0x4f, 0x13, 0x61, 0x45, 0x6d, 0x8d, 0x09, 0x81, 0x7d, 0x32,\n 0xbd, 0x8f, 0x40, 0xeb, 0x86, 0xb7, 0x7b, 0x0b, 0xf0, 0x95, 0x21, 0x22, 0x5c, 0x6b, 0x4e, 0x82,\n 0x54, 0xd6, 0x65, 0x93, 0xce, 0x60, 0xb2, 0x1c, 0x73, 0x56, 0xc0, 0x14, 0xa7, 0x8c, 0xf1, 0xdc,\n 0x12, 0x75, 0xca, 0x1f, 0x3b, 0xbe, 0xe4, 0xd1, 0x42, 0x3d, 0xd4, 0x30, 0xa3, 0x3c, 0xb6, 0x26,\n 0x6f, 0xbf, 0x0e, 0xda, 0x46, 0x69, 0x07, 0x57, 0x27, 0xf2, 0x1d, 0x9b, 0xbc, 0x94, 0x43, 0x03,\n 0xf8, 0x11, 0xc7, 0xf6, 0x90, 0xef, 0x3e, 0xe7, 0x06, 0xc3, 0xd5, 0x2f, 0xc8, 0x66, 0x1e, 0xd7,\n 0x08, 0xe8, 0xea, 0xde, 0x80, 0x52, 0xee, 0xf7, 0x84, 0xaa, 0x72, 0xac, 0x35, 0x4d, 0x6a, 0x2a,\n 0x96, 0x1a, 0xd2, 0x71, 0x5a, 0x15, 0x49, 0x74, 0x4b, 0x9f, 0xd0, 0x5e, 0x04, 0x18, 0xa4, 0xec,\n 0xc2, 0xe0, 0x41, 0x6e, 0x0f, 0x51, 0xcb, 0xcc, 0x24, 0x91, 0xaf, 0x50, 0xa1, 0xf4, 0x70, 0x39,\n 0x99, 0x7c, 0x3a, 0x85, 0x23, 0xb8, 0xb4, 0x7a, 0xfc, 0x02, 0x36, 0x5b, 0x25, 0x55, 0x97, 0x31,\n 0x2d, 0x5d, 0xfa, 0x98, 0xe3, 0x8a, 0x92, 0xae, 0x05, 0xdf, 0x29, 0x10, 0x67, 0x6c, 0xba, 0xc9,\n 0xd3, 0x00, 0xe6, 0xcf, 0xe1, 0x9e, 0xa8, 0x2c, 0x63, 0x16, 0x01, 0x3f, 0x58, 0xe2, 0x89, 0xa9,\n 0x0d, 0x38, 0x34, 0x1b, 0xab, 0x33, 0xff, 0xb0, 0xbb, 0x48, 0x0c, 0x5f, 0xb9, 0xb1, 0xcd, 0x2e,\n 0xc5, 0xf3, 0xdb, 0x47, 0xe5, 0xa5, 0x9c, 0x77, 0x0a, 0xa6, 0x20, 0x68, 0xfe, 0x7f, 0xc1, 0xad\n];\n\nvar s = [1, 2, 3, 5];\n\n/**\n * Rotate a word left by given number of bits.\n *\n * Bits that are shifted out on the left are put back in on the right\n * hand side.\n *\n * @param word The word to shift left.\n * @param bits The number of bits to shift by.\n * @return The rotated word.\n */\nvar rol = function(word, bits) {\n return ((word << bits) & 0xffff) | ((word & 0xffff) >> (16 - bits));\n};\n\n/**\n * Rotate a word right by given number of bits.\n *\n * Bits that are shifted out on the right are put back in on the left\n * hand side.\n *\n * @param word The word to shift right.\n * @param bits The number of bits to shift by.\n * @return The rotated word.\n */\nvar ror = function(word, bits) {\n return ((word & 0xffff) >> bits) | ((word << (16 - bits)) & 0xffff);\n};\n\n/* RC2 API */\nmodule.exports = forge.rc2 = forge.rc2 || {};\n\n/**\n * Perform RC2 key expansion as per RFC #2268, section 2.\n *\n * @param key variable-length user key (between 1 and 128 bytes)\n * @param effKeyBits number of effective key bits (default: 128)\n * @return the expanded RC2 key (ByteBuffer of 128 bytes)\n */\nforge.rc2.expandKey = function(key, effKeyBits) {\n if(typeof key === 'string') {\n key = forge.util.createBuffer(key);\n }\n effKeyBits = effKeyBits || 128;\n\n /* introduce variables that match the names used in RFC #2268 */\n var L = key;\n var T = key.length();\n var T1 = effKeyBits;\n var T8 = Math.ceil(T1 / 8);\n var TM = 0xff >> (T1 & 0x07);\n var i;\n\n for(i = T; i < 128; i++) {\n L.putByte(piTable[(L.at(i - 1) + L.at(i - T)) & 0xff]);\n }\n\n L.setAt(128 - T8, piTable[L.at(128 - T8) & TM]);\n\n for(i = 127 - T8; i >= 0; i--) {\n L.setAt(i, piTable[L.at(i + 1) ^ L.at(i + T8)]);\n }\n\n return L;\n};\n\n/**\n * Creates a RC2 cipher object.\n *\n * @param key the symmetric key to use (as base for key generation).\n * @param bits the number of effective key bits.\n * @param encrypt false for decryption, true for encryption.\n *\n * @return the cipher.\n */\nvar createCipher = function(key, bits, encrypt) {\n var _finish = false, _input = null, _output = null, _iv = null;\n var mixRound, mashRound;\n var i, j, K = [];\n\n /* Expand key and fill into K[] Array */\n key = forge.rc2.expandKey(key, bits);\n for(i = 0; i < 64; i++) {\n K.push(key.getInt16Le());\n }\n\n if(encrypt) {\n /**\n * Perform one mixing round \"in place\".\n *\n * @param R Array of four words to perform mixing on.\n */\n mixRound = function(R) {\n for(i = 0; i < 4; i++) {\n R[i] += K[j] + (R[(i + 3) % 4] & R[(i + 2) % 4]) +\n ((~R[(i + 3) % 4]) & R[(i + 1) % 4]);\n R[i] = rol(R[i], s[i]);\n j++;\n }\n };\n\n /**\n * Perform one mashing round \"in place\".\n *\n * @param R Array of four words to perform mashing on.\n */\n mashRound = function(R) {\n for(i = 0; i < 4; i++) {\n R[i] += K[R[(i + 3) % 4] & 63];\n }\n };\n } else {\n /**\n * Perform one r-mixing round \"in place\".\n *\n * @param R Array of four words to perform mixing on.\n */\n mixRound = function(R) {\n for(i = 3; i >= 0; i--) {\n R[i] = ror(R[i], s[i]);\n R[i] -= K[j] + (R[(i + 3) % 4] & R[(i + 2) % 4]) +\n ((~R[(i + 3) % 4]) & R[(i + 1) % 4]);\n j--;\n }\n };\n\n /**\n * Perform one r-mashing round \"in place\".\n *\n * @param R Array of four words to perform mashing on.\n */\n mashRound = function(R) {\n for(i = 3; i >= 0; i--) {\n R[i] -= K[R[(i + 3) % 4] & 63];\n }\n };\n }\n\n /**\n * Run the specified cipher execution plan.\n *\n * This function takes four words from the input buffer, applies the IV on\n * it (if requested) and runs the provided execution plan.\n *\n * The plan must be put together in form of a array of arrays. Where the\n * outer one is simply a list of steps to perform and the inner one needs\n * to have two elements: the first one telling how many rounds to perform,\n * the second one telling what to do (i.e. the function to call).\n *\n * @param {Array} plan The plan to execute.\n */\n var runPlan = function(plan) {\n var R = [];\n\n /* Get data from input buffer and fill the four words into R */\n for(i = 0; i < 4; i++) {\n var val = _input.getInt16Le();\n\n if(_iv !== null) {\n if(encrypt) {\n /* We're encrypting, apply the IV first. */\n val ^= _iv.getInt16Le();\n } else {\n /* We're decryption, keep cipher text for next block. */\n _iv.putInt16Le(val);\n }\n }\n\n R.push(val & 0xffff);\n }\n\n /* Reset global \"j\" variable as per spec. */\n j = encrypt ? 0 : 63;\n\n /* Run execution plan. */\n for(var ptr = 0; ptr < plan.length; ptr++) {\n for(var ctr = 0; ctr < plan[ptr][0]; ctr++) {\n plan[ptr][1](R);\n }\n }\n\n /* Write back result to output buffer. */\n for(i = 0; i < 4; i++) {\n if(_iv !== null) {\n if(encrypt) {\n /* We're encrypting in CBC-mode, feed back encrypted bytes into\n IV buffer to carry it forward to next block. */\n _iv.putInt16Le(R[i]);\n } else {\n R[i] ^= _iv.getInt16Le();\n }\n }\n\n _output.putInt16Le(R[i]);\n }\n };\n\n /* Create cipher object */\n var cipher = null;\n cipher = {\n /**\n * Starts or restarts the encryption or decryption process, whichever\n * was previously configured.\n *\n * To use the cipher in CBC mode, iv may be given either as a string\n * of bytes, or as a byte buffer. For ECB mode, give null as iv.\n *\n * @param iv the initialization vector to use, null for ECB mode.\n * @param output the output the buffer to write to, null to create one.\n */\n start: function(iv, output) {\n if(iv) {\n /* CBC mode */\n if(typeof iv === 'string') {\n iv = forge.util.createBuffer(iv);\n }\n }\n\n _finish = false;\n _input = forge.util.createBuffer();\n _output = output || new forge.util.createBuffer();\n _iv = iv;\n\n cipher.output = _output;\n },\n\n /**\n * Updates the next block.\n *\n * @param input the buffer to read from.\n */\n update: function(input) {\n if(!_finish) {\n // not finishing, so fill the input buffer with more input\n _input.putBuffer(input);\n }\n\n while(_input.length() >= 8) {\n runPlan([\n [ 5, mixRound ],\n [ 1, mashRound ],\n [ 6, mixRound ],\n [ 1, mashRound ],\n [ 5, mixRound ]\n ]);\n }\n },\n\n /**\n * Finishes encrypting or decrypting.\n *\n * @param pad a padding function to use, null for PKCS#7 padding,\n * signature(blockSize, buffer, decrypt).\n *\n * @return true if successful, false on error.\n */\n finish: function(pad) {\n var rval = true;\n\n if(encrypt) {\n if(pad) {\n rval = pad(8, _input, !encrypt);\n } else {\n // add PKCS#7 padding to block (each pad byte is the\n // value of the number of pad bytes)\n var padding = (_input.length() === 8) ? 8 : (8 - _input.length());\n _input.fillWithByte(padding, padding);\n }\n }\n\n if(rval) {\n // do final update\n _finish = true;\n cipher.update();\n }\n\n if(!encrypt) {\n // check for error: input data not a multiple of block size\n rval = (_input.length() === 0);\n if(rval) {\n if(pad) {\n rval = pad(8, _output, !encrypt);\n } else {\n // ensure padding byte count is valid\n var len = _output.length();\n var count = _output.at(len - 1);\n\n if(count > len) {\n rval = false;\n } else {\n // trim off padding bytes\n _output.truncate(count);\n }\n }\n }\n }\n\n return rval;\n }\n };\n\n return cipher;\n};\n\n/**\n * Creates an RC2 cipher object to encrypt data in ECB or CBC mode using the\n * given symmetric key. The output will be stored in the 'output' member\n * of the returned cipher.\n *\n * The key and iv may be given as a string of bytes or a byte buffer.\n * The cipher is initialized to use 128 effective key bits.\n *\n * @param key the symmetric key to use.\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n *\n * @return the cipher.\n */\nforge.rc2.startEncrypting = function(key, iv, output) {\n var cipher = forge.rc2.createEncryptionCipher(key, 128);\n cipher.start(iv, output);\n return cipher;\n};\n\n/**\n * Creates an RC2 cipher object to encrypt data in ECB or CBC mode using the\n * given symmetric key.\n *\n * The key may be given as a string of bytes or a byte buffer.\n *\n * To start encrypting call start() on the cipher with an iv and optional\n * output buffer.\n *\n * @param key the symmetric key to use.\n *\n * @return the cipher.\n */\nforge.rc2.createEncryptionCipher = function(key, bits) {\n return createCipher(key, bits, true);\n};\n\n/**\n * Creates an RC2 cipher object to decrypt data in ECB or CBC mode using the\n * given symmetric key. The output will be stored in the 'output' member\n * of the returned cipher.\n *\n * The key and iv may be given as a string of bytes or a byte buffer.\n * The cipher is initialized to use 128 effective key bits.\n *\n * @param key the symmetric key to use.\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n *\n * @return the cipher.\n */\nforge.rc2.startDecrypting = function(key, iv, output) {\n var cipher = forge.rc2.createDecryptionCipher(key, 128);\n cipher.start(iv, output);\n return cipher;\n};\n\n/**\n * Creates an RC2 cipher object to decrypt data in ECB or CBC mode using the\n * given symmetric key.\n *\n * The key may be given as a string of bytes or a byte buffer.\n *\n * To start decrypting call start() on the cipher with an iv and optional\n * output buffer.\n *\n * @param key the symmetric key to use.\n *\n * @return the cipher.\n */\nforge.rc2.createDecryptionCipher = function(key, bits) {\n return createCipher(key, bits, false);\n};\n","/**\n * Javascript implementation of basic RSA algorithms.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n *\n * The only algorithm currently supported for PKI is RSA.\n *\n * An RSA key is often stored in ASN.1 DER format. The SubjectPublicKeyInfo\n * ASN.1 structure is composed of an algorithm of type AlgorithmIdentifier\n * and a subjectPublicKey of type bit string.\n *\n * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters\n * for the algorithm, if any. In the case of RSA, there aren't any.\n *\n * SubjectPublicKeyInfo ::= SEQUENCE {\n * algorithm AlgorithmIdentifier,\n * subjectPublicKey BIT STRING\n * }\n *\n * AlgorithmIdentifer ::= SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * parameters ANY DEFINED BY algorithm OPTIONAL\n * }\n *\n * For an RSA public key, the subjectPublicKey is:\n *\n * RSAPublicKey ::= SEQUENCE {\n * modulus INTEGER, -- n\n * publicExponent INTEGER -- e\n * }\n *\n * PrivateKeyInfo ::= SEQUENCE {\n * version Version,\n * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,\n * privateKey PrivateKey,\n * attributes [0] IMPLICIT Attributes OPTIONAL\n * }\n *\n * Version ::= INTEGER\n * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier\n * PrivateKey ::= OCTET STRING\n * Attributes ::= SET OF Attribute\n *\n * An RSA private key as the following structure:\n *\n * RSAPrivateKey ::= SEQUENCE {\n * version Version,\n * modulus INTEGER, -- n\n * publicExponent INTEGER, -- e\n * privateExponent INTEGER, -- d\n * prime1 INTEGER, -- p\n * prime2 INTEGER, -- q\n * exponent1 INTEGER, -- d mod (p-1)\n * exponent2 INTEGER, -- d mod (q-1)\n * coefficient INTEGER -- (inverse of q) mod p\n * }\n *\n * Version ::= INTEGER\n *\n * The OID for the RSA key algorithm is: 1.2.840.113549.1.1.1\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./jsbn');\nrequire('./oids');\nrequire('./pkcs1');\nrequire('./prime');\nrequire('./random');\nrequire('./util');\n\nif(typeof BigInteger === 'undefined') {\n var BigInteger = forge.jsbn.BigInteger;\n}\n\nvar _crypto = forge.util.isNodejs ? require('crypto') : null;\n\n// shortcut for asn.1 API\nvar asn1 = forge.asn1;\n\n// shortcut for util API\nvar util = forge.util;\n\n/*\n * RSA encryption and decryption, see RFC 2313.\n */\nforge.pki = forge.pki || {};\nmodule.exports = forge.pki.rsa = forge.rsa = forge.rsa || {};\nvar pki = forge.pki;\n\n// for finding primes, which are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29\nvar GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];\n\n// validator for a PrivateKeyInfo structure\nvar privateKeyValidator = {\n // PrivateKeyInfo\n name: 'PrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // Version (INTEGER)\n name: 'PrivateKeyInfo.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyVersion'\n }, {\n // privateKeyAlgorithm\n name: 'PrivateKeyInfo.privateKeyAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'privateKeyOid'\n }]\n }, {\n // PrivateKey\n name: 'PrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'privateKey'\n }]\n};\n\n// validator for an RSA private key\nvar rsaPrivateKeyValidator = {\n // RSAPrivateKey\n name: 'RSAPrivateKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // Version (INTEGER)\n name: 'RSAPrivateKey.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyVersion'\n }, {\n // modulus (n)\n name: 'RSAPrivateKey.modulus',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyModulus'\n }, {\n // publicExponent (e)\n name: 'RSAPrivateKey.publicExponent',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyPublicExponent'\n }, {\n // privateExponent (d)\n name: 'RSAPrivateKey.privateExponent',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyPrivateExponent'\n }, {\n // prime1 (p)\n name: 'RSAPrivateKey.prime1',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyPrime1'\n }, {\n // prime2 (q)\n name: 'RSAPrivateKey.prime2',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyPrime2'\n }, {\n // exponent1 (d mod (p-1))\n name: 'RSAPrivateKey.exponent1',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyExponent1'\n }, {\n // exponent2 (d mod (q-1))\n name: 'RSAPrivateKey.exponent2',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyExponent2'\n }, {\n // coefficient ((inverse of q) mod p)\n name: 'RSAPrivateKey.coefficient',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyCoefficient'\n }]\n};\n\n// validator for an RSA public key\nvar rsaPublicKeyValidator = {\n // RSAPublicKey\n name: 'RSAPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // modulus (n)\n name: 'RSAPublicKey.modulus',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'publicKeyModulus'\n }, {\n // publicExponent (e)\n name: 'RSAPublicKey.exponent',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'publicKeyExponent'\n }]\n};\n\n// validator for an SubjectPublicKeyInfo structure\n// Note: Currently only works with an RSA public key\nvar publicKeyValidator = forge.pki.rsa.publicKeyValidator = {\n name: 'SubjectPublicKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'subjectPublicKeyInfo',\n value: [{\n name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'publicKeyOid'\n }]\n }, {\n // subjectPublicKey\n name: 'SubjectPublicKeyInfo.subjectPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n value: [{\n // RSAPublicKey\n name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n optional: true,\n captureAsn1: 'rsaPublicKey'\n }]\n }]\n};\n\n/**\n * Wrap digest in DigestInfo object.\n *\n * This function implements EMSA-PKCS1-v1_5-ENCODE as per RFC 3447.\n *\n * DigestInfo ::= SEQUENCE {\n * digestAlgorithm DigestAlgorithmIdentifier,\n * digest Digest\n * }\n *\n * DigestAlgorithmIdentifier ::= AlgorithmIdentifier\n * Digest ::= OCTET STRING\n *\n * @param md the message digest object with the hash to sign.\n *\n * @return the encoded message (ready for RSA encrytion)\n */\nvar emsaPkcs1v15encode = function(md) {\n // get the oid for the algorithm\n var oid;\n if(md.algorithm in pki.oids) {\n oid = pki.oids[md.algorithm];\n } else {\n var error = new Error('Unknown message digest algorithm.');\n error.algorithm = md.algorithm;\n throw error;\n }\n var oidBytes = asn1.oidToDer(oid).getBytes();\n\n // create the digest info\n var digestInfo = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n var digestAlgorithm = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n digestAlgorithm.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OID, false, oidBytes));\n digestAlgorithm.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.NULL, false, ''));\n var digest = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,\n false, md.digest().getBytes());\n digestInfo.value.push(digestAlgorithm);\n digestInfo.value.push(digest);\n\n // encode digest info\n return asn1.toDer(digestInfo).getBytes();\n};\n\n/**\n * Performs x^c mod n (RSA encryption or decryption operation).\n *\n * @param x the number to raise and mod.\n * @param key the key to use.\n * @param pub true if the key is public, false if private.\n *\n * @return the result of x^c mod n.\n */\nvar _modPow = function(x, key, pub) {\n if(pub) {\n return x.modPow(key.e, key.n);\n }\n\n if(!key.p || !key.q) {\n // allow calculation without CRT params (slow)\n return x.modPow(key.d, key.n);\n }\n\n // pre-compute dP, dQ, and qInv if necessary\n if(!key.dP) {\n key.dP = key.d.mod(key.p.subtract(BigInteger.ONE));\n }\n if(!key.dQ) {\n key.dQ = key.d.mod(key.q.subtract(BigInteger.ONE));\n }\n if(!key.qInv) {\n key.qInv = key.q.modInverse(key.p);\n }\n\n /* Chinese remainder theorem (CRT) states:\n\n Suppose n1, n2, ..., nk are positive integers which are pairwise\n coprime (n1 and n2 have no common factors other than 1). For any\n integers x1, x2, ..., xk there exists an integer x solving the\n system of simultaneous congruences (where ~= means modularly\n congruent so a ~= b mod n means a mod n = b mod n):\n\n x ~= x1 mod n1\n x ~= x2 mod n2\n ...\n x ~= xk mod nk\n\n This system of congruences has a single simultaneous solution x\n between 0 and n - 1. Furthermore, each xk solution and x itself\n is congruent modulo the product n = n1*n2*...*nk.\n So x1 mod n = x2 mod n = xk mod n = x mod n.\n\n The single simultaneous solution x can be solved with the following\n equation:\n\n x = sum(xi*ri*si) mod n where ri = n/ni and si = ri^-1 mod ni.\n\n Where x is less than n, xi = x mod ni.\n\n For RSA we are only concerned with k = 2. The modulus n = pq, where\n p and q are coprime. The RSA decryption algorithm is:\n\n y = x^d mod n\n\n Given the above:\n\n x1 = x^d mod p\n r1 = n/p = q\n s1 = q^-1 mod p\n x2 = x^d mod q\n r2 = n/q = p\n s2 = p^-1 mod q\n\n So y = (x1r1s1 + x2r2s2) mod n\n = ((x^d mod p)q(q^-1 mod p) + (x^d mod q)p(p^-1 mod q)) mod n\n\n According to Fermat's Little Theorem, if the modulus P is prime,\n for any integer A not evenly divisible by P, A^(P-1) ~= 1 mod P.\n Since A is not divisible by P it follows that if:\n N ~= M mod (P - 1), then A^N mod P = A^M mod P. Therefore:\n\n A^N mod P = A^(M mod (P - 1)) mod P. (The latter takes less effort\n to calculate). In order to calculate x^d mod p more quickly the\n exponent d mod (p - 1) is stored in the RSA private key (the same\n is done for x^d mod q). These values are referred to as dP and dQ\n respectively. Therefore we now have:\n\n y = ((x^dP mod p)q(q^-1 mod p) + (x^dQ mod q)p(p^-1 mod q)) mod n\n\n Since we'll be reducing x^dP by modulo p (same for q) we can also\n reduce x by p (and q respectively) before hand. Therefore, let\n\n xp = ((x mod p)^dP mod p), and\n xq = ((x mod q)^dQ mod q), yielding:\n\n y = (xp*q*(q^-1 mod p) + xq*p*(p^-1 mod q)) mod n\n\n This can be further reduced to a simple algorithm that only\n requires 1 inverse (the q inverse is used) to be used and stored.\n The algorithm is called Garner's algorithm. If qInv is the\n inverse of q, we simply calculate:\n\n y = (qInv*(xp - xq) mod p) * q + xq\n\n However, there are two further complications. First, we need to\n ensure that xp > xq to prevent signed BigIntegers from being used\n so we add p until this is true (since we will be mod'ing with\n p anyway). Then, there is a known timing attack on algorithms\n using the CRT. To mitigate this risk, \"cryptographic blinding\"\n should be used. This requires simply generating a random number r\n between 0 and n-1 and its inverse and multiplying x by r^e before\n calculating y and then multiplying y by r^-1 afterwards. Note that\n r must be coprime with n (gcd(r, n) === 1) in order to have an\n inverse.\n */\n\n // cryptographic blinding\n var r;\n do {\n r = new BigInteger(\n forge.util.bytesToHex(forge.random.getBytes(key.n.bitLength() / 8)),\n 16);\n } while(r.compareTo(key.n) >= 0 || !r.gcd(key.n).equals(BigInteger.ONE));\n x = x.multiply(r.modPow(key.e, key.n)).mod(key.n);\n\n // calculate xp and xq\n var xp = x.mod(key.p).modPow(key.dP, key.p);\n var xq = x.mod(key.q).modPow(key.dQ, key.q);\n\n // xp must be larger than xq to avoid signed bit usage\n while(xp.compareTo(xq) < 0) {\n xp = xp.add(key.p);\n }\n\n // do last step\n var y = xp.subtract(xq)\n .multiply(key.qInv).mod(key.p)\n .multiply(key.q).add(xq);\n\n // remove effect of random for cryptographic blinding\n y = y.multiply(r.modInverse(key.n)).mod(key.n);\n\n return y;\n};\n\n/**\n * NOTE: THIS METHOD IS DEPRECATED, use 'sign' on a private key object or\n * 'encrypt' on a public key object instead.\n *\n * Performs RSA encryption.\n *\n * The parameter bt controls whether to put padding bytes before the\n * message passed in. Set bt to either true or false to disable padding\n * completely (in order to handle e.g. EMSA-PSS encoding seperately before),\n * signaling whether the encryption operation is a public key operation\n * (i.e. encrypting data) or not, i.e. private key operation (data signing).\n *\n * For PKCS#1 v1.5 padding pass in the block type to use, i.e. either 0x01\n * (for signing) or 0x02 (for encryption). The key operation mode (private\n * or public) is derived from this flag in that case).\n *\n * @param m the message to encrypt as a byte string.\n * @param key the RSA key to use.\n * @param bt for PKCS#1 v1.5 padding, the block type to use\n * (0x01 for private key, 0x02 for public),\n * to disable padding: true = public key, false = private key.\n *\n * @return the encrypted bytes as a string.\n */\npki.rsa.encrypt = function(m, key, bt) {\n var pub = bt;\n var eb;\n\n // get the length of the modulus in bytes\n var k = Math.ceil(key.n.bitLength() / 8);\n\n if(bt !== false && bt !== true) {\n // legacy, default to PKCS#1 v1.5 padding\n pub = (bt === 0x02);\n eb = _encodePkcs1_v1_5(m, key, bt);\n } else {\n eb = forge.util.createBuffer();\n eb.putBytes(m);\n }\n\n // load encryption block as big integer 'x'\n // FIXME: hex conversion inefficient, get BigInteger w/byte strings\n var x = new BigInteger(eb.toHex(), 16);\n\n // do RSA encryption\n var y = _modPow(x, key, pub);\n\n // convert y into the encrypted data byte string, if y is shorter in\n // bytes than k, then prepend zero bytes to fill up ed\n // FIXME: hex conversion inefficient, get BigInteger w/byte strings\n var yhex = y.toString(16);\n var ed = forge.util.createBuffer();\n var zeros = k - Math.ceil(yhex.length / 2);\n while(zeros > 0) {\n ed.putByte(0x00);\n --zeros;\n }\n ed.putBytes(forge.util.hexToBytes(yhex));\n return ed.getBytes();\n};\n\n/**\n * NOTE: THIS METHOD IS DEPRECATED, use 'decrypt' on a private key object or\n * 'verify' on a public key object instead.\n *\n * Performs RSA decryption.\n *\n * The parameter ml controls whether to apply PKCS#1 v1.5 padding\n * or not. Set ml = false to disable padding removal completely\n * (in order to handle e.g. EMSA-PSS later on) and simply pass back\n * the RSA encryption block.\n *\n * @param ed the encrypted data to decrypt in as a byte string.\n * @param key the RSA key to use.\n * @param pub true for a public key operation, false for private.\n * @param ml the message length, if known, false to disable padding.\n *\n * @return the decrypted message as a byte string.\n */\npki.rsa.decrypt = function(ed, key, pub, ml) {\n // get the length of the modulus in bytes\n var k = Math.ceil(key.n.bitLength() / 8);\n\n // error if the length of the encrypted data ED is not k\n if(ed.length !== k) {\n var error = new Error('Encrypted message length is invalid.');\n error.length = ed.length;\n error.expected = k;\n throw error;\n }\n\n // convert encrypted data into a big integer\n // FIXME: hex conversion inefficient, get BigInteger w/byte strings\n var y = new BigInteger(forge.util.createBuffer(ed).toHex(), 16);\n\n // y must be less than the modulus or it wasn't the result of\n // a previous mod operation (encryption) using that modulus\n if(y.compareTo(key.n) >= 0) {\n throw new Error('Encrypted message is invalid.');\n }\n\n // do RSA decryption\n var x = _modPow(y, key, pub);\n\n // create the encryption block, if x is shorter in bytes than k, then\n // prepend zero bytes to fill up eb\n // FIXME: hex conversion inefficient, get BigInteger w/byte strings\n var xhex = x.toString(16);\n var eb = forge.util.createBuffer();\n var zeros = k - Math.ceil(xhex.length / 2);\n while(zeros > 0) {\n eb.putByte(0x00);\n --zeros;\n }\n eb.putBytes(forge.util.hexToBytes(xhex));\n\n if(ml !== false) {\n // legacy, default to PKCS#1 v1.5 padding\n return _decodePkcs1_v1_5(eb.getBytes(), key, pub);\n }\n\n // return message\n return eb.getBytes();\n};\n\n/**\n * Creates an RSA key-pair generation state object. It is used to allow\n * key-generation to be performed in steps. It also allows for a UI to\n * display progress updates.\n *\n * @param bits the size for the private key in bits, defaults to 2048.\n * @param e the public exponent to use, defaults to 65537 (0x10001).\n * @param [options] the options to use.\n * prng a custom crypto-secure pseudo-random number generator to use,\n * that must define \"getBytesSync\".\n * algorithm the algorithm to use (default: 'PRIMEINC').\n *\n * @return the state object to use to generate the key-pair.\n */\npki.rsa.createKeyPairGenerationState = function(bits, e, options) {\n // TODO: migrate step-based prime generation code to forge.prime\n\n // set default bits\n if(typeof(bits) === 'string') {\n bits = parseInt(bits, 10);\n }\n bits = bits || 2048;\n\n // create prng with api that matches BigInteger secure random\n options = options || {};\n var prng = options.prng || forge.random;\n var rng = {\n // x is an array to fill with bytes\n nextBytes: function(x) {\n var b = prng.getBytesSync(x.length);\n for(var i = 0; i < x.length; ++i) {\n x[i] = b.charCodeAt(i);\n }\n }\n };\n\n var algorithm = options.algorithm || 'PRIMEINC';\n\n // create PRIMEINC algorithm state\n var rval;\n if(algorithm === 'PRIMEINC') {\n rval = {\n algorithm: algorithm,\n state: 0,\n bits: bits,\n rng: rng,\n eInt: e || 65537,\n e: new BigInteger(null),\n p: null,\n q: null,\n qBits: bits >> 1,\n pBits: bits - (bits >> 1),\n pqState: 0,\n num: null,\n keys: null\n };\n rval.e.fromInt(rval.eInt);\n } else {\n throw new Error('Invalid key generation algorithm: ' + algorithm);\n }\n\n return rval;\n};\n\n/**\n * Attempts to runs the key-generation algorithm for at most n seconds\n * (approximately) using the given state. When key-generation has completed,\n * the keys will be stored in state.keys.\n *\n * To use this function to update a UI while generating a key or to prevent\n * causing browser lockups/warnings, set \"n\" to a value other than 0. A\n * simple pattern for generating a key and showing a progress indicator is:\n *\n * var state = pki.rsa.createKeyPairGenerationState(2048);\n * var step = function() {\n * // step key-generation, run algorithm for 100 ms, repeat\n * if(!forge.pki.rsa.stepKeyPairGenerationState(state, 100)) {\n * setTimeout(step, 1);\n * } else {\n * // key-generation complete\n * // TODO: turn off progress indicator here\n * // TODO: use the generated key-pair in \"state.keys\"\n * }\n * };\n * // TODO: turn on progress indicator here\n * setTimeout(step, 0);\n *\n * @param state the state to use.\n * @param n the maximum number of milliseconds to run the algorithm for, 0\n * to run the algorithm to completion.\n *\n * @return true if the key-generation completed, false if not.\n */\npki.rsa.stepKeyPairGenerationState = function(state, n) {\n // set default algorithm if not set\n if(!('algorithm' in state)) {\n state.algorithm = 'PRIMEINC';\n }\n\n // TODO: migrate step-based prime generation code to forge.prime\n // TODO: abstract as PRIMEINC algorithm\n\n // do key generation (based on Tom Wu's rsa.js, see jsbn.js license)\n // with some minor optimizations and designed to run in steps\n\n // local state vars\n var THIRTY = new BigInteger(null);\n THIRTY.fromInt(30);\n var deltaIdx = 0;\n var op_or = function(x, y) {return x | y;};\n\n // keep stepping until time limit is reached or done\n var t1 = +new Date();\n var t2;\n var total = 0;\n while(state.keys === null && (n <= 0 || total < n)) {\n // generate p or q\n if(state.state === 0) {\n /* Note: All primes are of the form:\n\n 30k+i, for i < 30 and gcd(30, i)=1, where there are 8 values for i\n\n When we generate a random number, we always align it at 30k + 1. Each\n time the number is determined not to be prime we add to get to the\n next 'i', eg: if the number was at 30k + 1 we add 6. */\n var bits = (state.p === null) ? state.pBits : state.qBits;\n var bits1 = bits - 1;\n\n // get a random number\n if(state.pqState === 0) {\n state.num = new BigInteger(bits, state.rng);\n // force MSB set\n if(!state.num.testBit(bits1)) {\n state.num.bitwiseTo(\n BigInteger.ONE.shiftLeft(bits1), op_or, state.num);\n }\n // align number on 30k+1 boundary\n state.num.dAddOffset(31 - state.num.mod(THIRTY).byteValue(), 0);\n deltaIdx = 0;\n\n ++state.pqState;\n } else if(state.pqState === 1) {\n // try to make the number a prime\n if(state.num.bitLength() > bits) {\n // overflow, try again\n state.pqState = 0;\n // do primality test\n } else if(state.num.isProbablePrime(\n _getMillerRabinTests(state.num.bitLength()))) {\n ++state.pqState;\n } else {\n // get next potential prime\n state.num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);\n }\n } else if(state.pqState === 2) {\n // ensure number is coprime with e\n state.pqState =\n (state.num.subtract(BigInteger.ONE).gcd(state.e)\n .compareTo(BigInteger.ONE) === 0) ? 3 : 0;\n } else if(state.pqState === 3) {\n // store p or q\n state.pqState = 0;\n if(state.p === null) {\n state.p = state.num;\n } else {\n state.q = state.num;\n }\n\n // advance state if both p and q are ready\n if(state.p !== null && state.q !== null) {\n ++state.state;\n }\n state.num = null;\n }\n } else if(state.state === 1) {\n // ensure p is larger than q (swap them if not)\n if(state.p.compareTo(state.q) < 0) {\n state.num = state.p;\n state.p = state.q;\n state.q = state.num;\n }\n ++state.state;\n } else if(state.state === 2) {\n // compute phi: (p - 1)(q - 1) (Euler's totient function)\n state.p1 = state.p.subtract(BigInteger.ONE);\n state.q1 = state.q.subtract(BigInteger.ONE);\n state.phi = state.p1.multiply(state.q1);\n ++state.state;\n } else if(state.state === 3) {\n // ensure e and phi are coprime\n if(state.phi.gcd(state.e).compareTo(BigInteger.ONE) === 0) {\n // phi and e are coprime, advance\n ++state.state;\n } else {\n // phi and e aren't coprime, so generate a new p and q\n state.p = null;\n state.q = null;\n state.state = 0;\n }\n } else if(state.state === 4) {\n // create n, ensure n is has the right number of bits\n state.n = state.p.multiply(state.q);\n\n // ensure n is right number of bits\n if(state.n.bitLength() === state.bits) {\n // success, advance\n ++state.state;\n } else {\n // failed, get new q\n state.q = null;\n state.state = 0;\n }\n } else if(state.state === 5) {\n // set keys\n var d = state.e.modInverse(state.phi);\n state.keys = {\n privateKey: pki.rsa.setPrivateKey(\n state.n, state.e, d, state.p, state.q,\n d.mod(state.p1), d.mod(state.q1),\n state.q.modInverse(state.p)),\n publicKey: pki.rsa.setPublicKey(state.n, state.e)\n };\n }\n\n // update timing\n t2 = +new Date();\n total += t2 - t1;\n t1 = t2;\n }\n\n return state.keys !== null;\n};\n\n/**\n * Generates an RSA public-private key pair in a single call.\n *\n * To generate a key-pair in steps (to allow for progress updates and to\n * prevent blocking or warnings in slow browsers) then use the key-pair\n * generation state functions.\n *\n * To generate a key-pair asynchronously (either through web-workers, if\n * available, or by breaking up the work on the main thread), pass a\n * callback function.\n *\n * @param [bits] the size for the private key in bits, defaults to 2048.\n * @param [e] the public exponent to use, defaults to 65537.\n * @param [options] options for key-pair generation, if given then 'bits'\n * and 'e' must *not* be given:\n * bits the size for the private key in bits, (default: 2048).\n * e the public exponent to use, (default: 65537 (0x10001)).\n * workerScript the worker script URL.\n * workers the number of web workers (if supported) to use,\n * (default: 2).\n * workLoad the size of the work load, ie: number of possible prime\n * numbers for each web worker to check per work assignment,\n * (default: 100).\n * prng a custom crypto-secure pseudo-random number generator to use,\n * that must define \"getBytesSync\". Disables use of native APIs.\n * algorithm the algorithm to use (default: 'PRIMEINC').\n * @param [callback(err, keypair)] called once the operation completes.\n *\n * @return an object with privateKey and publicKey properties.\n */\npki.rsa.generateKeyPair = function(bits, e, options, callback) {\n // (bits), (options), (callback)\n if(arguments.length === 1) {\n if(typeof bits === 'object') {\n options = bits;\n bits = undefined;\n } else if(typeof bits === 'function') {\n callback = bits;\n bits = undefined;\n }\n } else if(arguments.length === 2) {\n // (bits, e), (bits, options), (bits, callback), (options, callback)\n if(typeof bits === 'number') {\n if(typeof e === 'function') {\n callback = e;\n e = undefined;\n } else if(typeof e !== 'number') {\n options = e;\n e = undefined;\n }\n } else {\n options = bits;\n callback = e;\n bits = undefined;\n e = undefined;\n }\n } else if(arguments.length === 3) {\n // (bits, e, options), (bits, e, callback), (bits, options, callback)\n if(typeof e === 'number') {\n if(typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n } else {\n callback = options;\n options = e;\n e = undefined;\n }\n }\n options = options || {};\n if(bits === undefined) {\n bits = options.bits || 2048;\n }\n if(e === undefined) {\n e = options.e || 0x10001;\n }\n\n // use native code if permitted, available, and parameters are acceptable\n if(!forge.options.usePureJavaScript && !options.prng &&\n bits >= 256 && bits <= 16384 && (e === 0x10001 || e === 3)) {\n if(callback) {\n // try native async\n if(_detectNodeCrypto('generateKeyPair')) {\n return _crypto.generateKeyPair('rsa', {\n modulusLength: bits,\n publicExponent: e,\n publicKeyEncoding: {\n type: 'spki',\n format: 'pem'\n },\n privateKeyEncoding: {\n type: 'pkcs8',\n format: 'pem'\n }\n }, function(err, pub, priv) {\n if(err) {\n return callback(err);\n }\n callback(null, {\n privateKey: pki.privateKeyFromPem(priv),\n publicKey: pki.publicKeyFromPem(pub)\n });\n });\n }\n if(_detectSubtleCrypto('generateKey') &&\n _detectSubtleCrypto('exportKey')) {\n // use standard native generateKey\n return util.globalScope.crypto.subtle.generateKey({\n name: 'RSASSA-PKCS1-v1_5',\n modulusLength: bits,\n publicExponent: _intToUint8Array(e),\n hash: {name: 'SHA-256'}\n }, true /* key can be exported*/, ['sign', 'verify'])\n .then(function(pair) {\n return util.globalScope.crypto.subtle.exportKey(\n 'pkcs8', pair.privateKey);\n // avoiding catch(function(err) {...}) to support IE <= 8\n }).then(undefined, function(err) {\n callback(err);\n }).then(function(pkcs8) {\n if(pkcs8) {\n var privateKey = pki.privateKeyFromAsn1(\n asn1.fromDer(forge.util.createBuffer(pkcs8)));\n callback(null, {\n privateKey: privateKey,\n publicKey: pki.setRsaPublicKey(privateKey.n, privateKey.e)\n });\n }\n });\n }\n if(_detectSubtleMsCrypto('generateKey') &&\n _detectSubtleMsCrypto('exportKey')) {\n var genOp = util.globalScope.msCrypto.subtle.generateKey({\n name: 'RSASSA-PKCS1-v1_5',\n modulusLength: bits,\n publicExponent: _intToUint8Array(e),\n hash: {name: 'SHA-256'}\n }, true /* key can be exported*/, ['sign', 'verify']);\n genOp.oncomplete = function(e) {\n var pair = e.target.result;\n var exportOp = util.globalScope.msCrypto.subtle.exportKey(\n 'pkcs8', pair.privateKey);\n exportOp.oncomplete = function(e) {\n var pkcs8 = e.target.result;\n var privateKey = pki.privateKeyFromAsn1(\n asn1.fromDer(forge.util.createBuffer(pkcs8)));\n callback(null, {\n privateKey: privateKey,\n publicKey: pki.setRsaPublicKey(privateKey.n, privateKey.e)\n });\n };\n exportOp.onerror = function(err) {\n callback(err);\n };\n };\n genOp.onerror = function(err) {\n callback(err);\n };\n return;\n }\n } else {\n // try native sync\n if(_detectNodeCrypto('generateKeyPairSync')) {\n var keypair = _crypto.generateKeyPairSync('rsa', {\n modulusLength: bits,\n publicExponent: e,\n publicKeyEncoding: {\n type: 'spki',\n format: 'pem'\n },\n privateKeyEncoding: {\n type: 'pkcs8',\n format: 'pem'\n }\n });\n return {\n privateKey: pki.privateKeyFromPem(keypair.privateKey),\n publicKey: pki.publicKeyFromPem(keypair.publicKey)\n };\n }\n }\n }\n\n // use JavaScript implementation\n var state = pki.rsa.createKeyPairGenerationState(bits, e, options);\n if(!callback) {\n pki.rsa.stepKeyPairGenerationState(state, 0);\n return state.keys;\n }\n _generateKeyPair(state, options, callback);\n};\n\n/**\n * Sets an RSA public key from BigIntegers modulus and exponent.\n *\n * @param n the modulus.\n * @param e the exponent.\n *\n * @return the public key.\n */\npki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {\n var key = {\n n: n,\n e: e\n };\n\n /**\n * Encrypts the given data with this public key. Newer applications\n * should use the 'RSA-OAEP' decryption scheme, 'RSAES-PKCS1-V1_5' is for\n * legacy applications.\n *\n * @param data the byte string to encrypt.\n * @param scheme the encryption scheme to use:\n * 'RSAES-PKCS1-V1_5' (default),\n * 'RSA-OAEP',\n * 'RAW', 'NONE', or null to perform raw RSA encryption,\n * an object with an 'encode' property set to a function\n * with the signature 'function(data, key)' that returns\n * a binary-encoded string representing the encoded data.\n * @param schemeOptions any scheme-specific options.\n *\n * @return the encrypted byte string.\n */\n key.encrypt = function(data, scheme, schemeOptions) {\n if(typeof scheme === 'string') {\n scheme = scheme.toUpperCase();\n } else if(scheme === undefined) {\n scheme = 'RSAES-PKCS1-V1_5';\n }\n\n if(scheme === 'RSAES-PKCS1-V1_5') {\n scheme = {\n encode: function(m, key, pub) {\n return _encodePkcs1_v1_5(m, key, 0x02).getBytes();\n }\n };\n } else if(scheme === 'RSA-OAEP' || scheme === 'RSAES-OAEP') {\n scheme = {\n encode: function(m, key) {\n return forge.pkcs1.encode_rsa_oaep(key, m, schemeOptions);\n }\n };\n } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {\n scheme = {encode: function(e) {return e;}};\n } else if(typeof scheme === 'string') {\n throw new Error('Unsupported encryption scheme: \"' + scheme + '\".');\n }\n\n // do scheme-based encoding then rsa encryption\n var e = scheme.encode(data, key, true);\n return pki.rsa.encrypt(e, key, true);\n };\n\n /**\n * Verifies the given signature against the given digest.\n *\n * PKCS#1 supports multiple (currently two) signature schemes:\n * RSASSA-PKCS1-V1_5 and RSASSA-PSS.\n *\n * By default this implementation uses the \"old scheme\", i.e.\n * RSASSA-PKCS1-V1_5, in which case once RSA-decrypted, the\n * signature is an OCTET STRING that holds a DigestInfo.\n *\n * DigestInfo ::= SEQUENCE {\n * digestAlgorithm DigestAlgorithmIdentifier,\n * digest Digest\n * }\n * DigestAlgorithmIdentifier ::= AlgorithmIdentifier\n * Digest ::= OCTET STRING\n *\n * To perform PSS signature verification, provide an instance\n * of Forge PSS object as the scheme parameter.\n *\n * @param digest the message digest hash to compare against the signature,\n * as a binary-encoded string.\n * @param signature the signature to verify, as a binary-encoded string.\n * @param scheme signature verification scheme to use:\n * 'RSASSA-PKCS1-V1_5' or undefined for RSASSA PKCS#1 v1.5,\n * a Forge PSS object for RSASSA-PSS,\n * 'NONE' or null for none, DigestInfo will not be expected, but\n * PKCS#1 v1.5 padding will still be used.\n *\n * @return true if the signature was verified, false if not.\n */\n key.verify = function(digest, signature, scheme) {\n if(typeof scheme === 'string') {\n scheme = scheme.toUpperCase();\n } else if(scheme === undefined) {\n scheme = 'RSASSA-PKCS1-V1_5';\n }\n\n if(scheme === 'RSASSA-PKCS1-V1_5') {\n scheme = {\n verify: function(digest, d) {\n // remove padding\n d = _decodePkcs1_v1_5(d, key, true);\n // d is ASN.1 BER-encoded DigestInfo\n var obj = asn1.fromDer(d);\n // compare the given digest to the decrypted one\n return digest === obj.value[1].value;\n }\n };\n } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {\n scheme = {\n verify: function(digest, d) {\n // remove padding\n d = _decodePkcs1_v1_5(d, key, true);\n return digest === d;\n }\n };\n }\n\n // do rsa decryption w/o any decoding, then verify -- which does decoding\n var d = pki.rsa.decrypt(signature, key, true, false);\n return scheme.verify(digest, d, key.n.bitLength());\n };\n\n return key;\n};\n\n/**\n * Sets an RSA private key from BigIntegers modulus, exponent, primes,\n * prime exponents, and modular multiplicative inverse.\n *\n * @param n the modulus.\n * @param e the public exponent.\n * @param d the private exponent ((inverse of e) mod n).\n * @param p the first prime.\n * @param q the second prime.\n * @param dP exponent1 (d mod (p-1)).\n * @param dQ exponent2 (d mod (q-1)).\n * @param qInv ((inverse of q) mod p)\n *\n * @return the private key.\n */\npki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(\n n, e, d, p, q, dP, dQ, qInv) {\n var key = {\n n: n,\n e: e,\n d: d,\n p: p,\n q: q,\n dP: dP,\n dQ: dQ,\n qInv: qInv\n };\n\n /**\n * Decrypts the given data with this private key. The decryption scheme\n * must match the one used to encrypt the data.\n *\n * @param data the byte string to decrypt.\n * @param scheme the decryption scheme to use:\n * 'RSAES-PKCS1-V1_5' (default),\n * 'RSA-OAEP',\n * 'RAW', 'NONE', or null to perform raw RSA decryption.\n * @param schemeOptions any scheme-specific options.\n *\n * @return the decrypted byte string.\n */\n key.decrypt = function(data, scheme, schemeOptions) {\n if(typeof scheme === 'string') {\n scheme = scheme.toUpperCase();\n } else if(scheme === undefined) {\n scheme = 'RSAES-PKCS1-V1_5';\n }\n\n // do rsa decryption w/o any decoding\n var d = pki.rsa.decrypt(data, key, false, false);\n\n if(scheme === 'RSAES-PKCS1-V1_5') {\n scheme = {decode: _decodePkcs1_v1_5};\n } else if(scheme === 'RSA-OAEP' || scheme === 'RSAES-OAEP') {\n scheme = {\n decode: function(d, key) {\n return forge.pkcs1.decode_rsa_oaep(key, d, schemeOptions);\n }\n };\n } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {\n scheme = {decode: function(d) {return d;}};\n } else {\n throw new Error('Unsupported encryption scheme: \"' + scheme + '\".');\n }\n\n // decode according to scheme\n return scheme.decode(d, key, false);\n };\n\n /**\n * Signs the given digest, producing a signature.\n *\n * PKCS#1 supports multiple (currently two) signature schemes:\n * RSASSA-PKCS1-V1_5 and RSASSA-PSS.\n *\n * By default this implementation uses the \"old scheme\", i.e.\n * RSASSA-PKCS1-V1_5. In order to generate a PSS signature, provide\n * an instance of Forge PSS object as the scheme parameter.\n *\n * @param md the message digest object with the hash to sign.\n * @param scheme the signature scheme to use:\n * 'RSASSA-PKCS1-V1_5' or undefined for RSASSA PKCS#1 v1.5,\n * a Forge PSS object for RSASSA-PSS,\n * 'NONE' or null for none, DigestInfo will not be used but\n * PKCS#1 v1.5 padding will still be used.\n *\n * @return the signature as a byte string.\n */\n key.sign = function(md, scheme) {\n /* Note: The internal implementation of RSA operations is being\n transitioned away from a PKCS#1 v1.5 hard-coded scheme. Some legacy\n code like the use of an encoding block identifier 'bt' will eventually\n be removed. */\n\n // private key operation\n var bt = false;\n\n if(typeof scheme === 'string') {\n scheme = scheme.toUpperCase();\n }\n\n if(scheme === undefined || scheme === 'RSASSA-PKCS1-V1_5') {\n scheme = {encode: emsaPkcs1v15encode};\n bt = 0x01;\n } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {\n scheme = {encode: function() {return md;}};\n bt = 0x01;\n }\n\n // encode and then encrypt\n var d = scheme.encode(md, key.n.bitLength());\n return pki.rsa.encrypt(d, key, bt);\n };\n\n return key;\n};\n\n/**\n * Wraps an RSAPrivateKey ASN.1 object in an ASN.1 PrivateKeyInfo object.\n *\n * @param rsaKey the ASN.1 RSAPrivateKey.\n *\n * @return the ASN.1 PrivateKeyInfo.\n */\npki.wrapRsaPrivateKey = function(rsaKey) {\n // PrivateKeyInfo\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version (0)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(0).getBytes()),\n // privateKeyAlgorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]),\n // PrivateKey\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(rsaKey).getBytes())\n ]);\n};\n\n/**\n * Converts a private key from an ASN.1 object.\n *\n * @param obj the ASN.1 representation of a PrivateKeyInfo containing an\n * RSAPrivateKey or an RSAPrivateKey.\n *\n * @return the private key.\n */\npki.privateKeyFromAsn1 = function(obj) {\n // get PrivateKeyInfo\n var capture = {};\n var errors = [];\n if(asn1.validate(obj, privateKeyValidator, capture, errors)) {\n obj = asn1.fromDer(forge.util.createBuffer(capture.privateKey));\n }\n\n // get RSAPrivateKey\n capture = {};\n errors = [];\n if(!asn1.validate(obj, rsaPrivateKeyValidator, capture, errors)) {\n var error = new Error('Cannot read private key. ' +\n 'ASN.1 object does not contain an RSAPrivateKey.');\n error.errors = errors;\n throw error;\n }\n\n // Note: Version is currently ignored.\n // capture.privateKeyVersion\n // FIXME: inefficient, get a BigInteger that uses byte strings\n var n, e, d, p, q, dP, dQ, qInv;\n n = forge.util.createBuffer(capture.privateKeyModulus).toHex();\n e = forge.util.createBuffer(capture.privateKeyPublicExponent).toHex();\n d = forge.util.createBuffer(capture.privateKeyPrivateExponent).toHex();\n p = forge.util.createBuffer(capture.privateKeyPrime1).toHex();\n q = forge.util.createBuffer(capture.privateKeyPrime2).toHex();\n dP = forge.util.createBuffer(capture.privateKeyExponent1).toHex();\n dQ = forge.util.createBuffer(capture.privateKeyExponent2).toHex();\n qInv = forge.util.createBuffer(capture.privateKeyCoefficient).toHex();\n\n // set private key\n return pki.setRsaPrivateKey(\n new BigInteger(n, 16),\n new BigInteger(e, 16),\n new BigInteger(d, 16),\n new BigInteger(p, 16),\n new BigInteger(q, 16),\n new BigInteger(dP, 16),\n new BigInteger(dQ, 16),\n new BigInteger(qInv, 16));\n};\n\n/**\n * Converts a private key to an ASN.1 RSAPrivateKey.\n *\n * @param key the private key.\n *\n * @return the ASN.1 representation of an RSAPrivateKey.\n */\npki.privateKeyToAsn1 = pki.privateKeyToRSAPrivateKey = function(key) {\n // RSAPrivateKey\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version (0 = only 2 primes, 1 multiple primes)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(0).getBytes()),\n // modulus (n)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.n)),\n // publicExponent (e)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.e)),\n // privateExponent (d)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.d)),\n // privateKeyPrime1 (p)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.p)),\n // privateKeyPrime2 (q)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.q)),\n // privateKeyExponent1 (dP)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.dP)),\n // privateKeyExponent2 (dQ)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.dQ)),\n // coefficient (qInv)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.qInv))\n ]);\n};\n\n/**\n * Converts a public key from an ASN.1 SubjectPublicKeyInfo or RSAPublicKey.\n *\n * @param obj the asn1 representation of a SubjectPublicKeyInfo or RSAPublicKey.\n *\n * @return the public key.\n */\npki.publicKeyFromAsn1 = function(obj) {\n // get SubjectPublicKeyInfo\n var capture = {};\n var errors = [];\n if(asn1.validate(obj, publicKeyValidator, capture, errors)) {\n // get oid\n var oid = asn1.derToOid(capture.publicKeyOid);\n if(oid !== pki.oids.rsaEncryption) {\n var error = new Error('Cannot read public key. Unknown OID.');\n error.oid = oid;\n throw error;\n }\n obj = capture.rsaPublicKey;\n }\n\n // get RSA params\n errors = [];\n if(!asn1.validate(obj, rsaPublicKeyValidator, capture, errors)) {\n var error = new Error('Cannot read public key. ' +\n 'ASN.1 object does not contain an RSAPublicKey.');\n error.errors = errors;\n throw error;\n }\n\n // FIXME: inefficient, get a BigInteger that uses byte strings\n var n = forge.util.createBuffer(capture.publicKeyModulus).toHex();\n var e = forge.util.createBuffer(capture.publicKeyExponent).toHex();\n\n // set public key\n return pki.setRsaPublicKey(\n new BigInteger(n, 16),\n new BigInteger(e, 16));\n};\n\n/**\n * Converts a public key to an ASN.1 SubjectPublicKeyInfo.\n *\n * @param key the public key.\n *\n * @return the asn1 representation of a SubjectPublicKeyInfo.\n */\npki.publicKeyToAsn1 = pki.publicKeyToSubjectPublicKeyInfo = function(key) {\n // SubjectPublicKeyInfo\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // AlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]),\n // subjectPublicKey\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, [\n pki.publicKeyToRSAPublicKey(key)\n ])\n ]);\n};\n\n/**\n * Converts a public key to an ASN.1 RSAPublicKey.\n *\n * @param key the public key.\n *\n * @return the asn1 representation of a RSAPublicKey.\n */\npki.publicKeyToRSAPublicKey = function(key) {\n // RSAPublicKey\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // modulus (n)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.n)),\n // publicExponent (e)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.e))\n ]);\n};\n\n/**\n * Encodes a message using PKCS#1 v1.5 padding.\n *\n * @param m the message to encode.\n * @param key the RSA key to use.\n * @param bt the block type to use, i.e. either 0x01 (for signing) or 0x02\n * (for encryption).\n *\n * @return the padded byte buffer.\n */\nfunction _encodePkcs1_v1_5(m, key, bt) {\n var eb = forge.util.createBuffer();\n\n // get the length of the modulus in bytes\n var k = Math.ceil(key.n.bitLength() / 8);\n\n /* use PKCS#1 v1.5 padding */\n if(m.length > (k - 11)) {\n var error = new Error('Message is too long for PKCS#1 v1.5 padding.');\n error.length = m.length;\n error.max = k - 11;\n throw error;\n }\n\n /* A block type BT, a padding string PS, and the data D shall be\n formatted into an octet string EB, the encryption block:\n\n EB = 00 || BT || PS || 00 || D\n\n The block type BT shall be a single octet indicating the structure of\n the encryption block. For this version of the document it shall have\n value 00, 01, or 02. For a private-key operation, the block type\n shall be 00 or 01. For a public-key operation, it shall be 02.\n\n The padding string PS shall consist of k-3-||D|| octets. For block\n type 00, the octets shall have value 00; for block type 01, they\n shall have value FF; and for block type 02, they shall be\n pseudorandomly generated and nonzero. This makes the length of the\n encryption block EB equal to k. */\n\n // build the encryption block\n eb.putByte(0x00);\n eb.putByte(bt);\n\n // create the padding\n var padNum = k - 3 - m.length;\n var padByte;\n // private key op\n if(bt === 0x00 || bt === 0x01) {\n padByte = (bt === 0x00) ? 0x00 : 0xFF;\n for(var i = 0; i < padNum; ++i) {\n eb.putByte(padByte);\n }\n } else {\n // public key op\n // pad with random non-zero values\n while(padNum > 0) {\n var numZeros = 0;\n var padBytes = forge.random.getBytes(padNum);\n for(var i = 0; i < padNum; ++i) {\n padByte = padBytes.charCodeAt(i);\n if(padByte === 0) {\n ++numZeros;\n } else {\n eb.putByte(padByte);\n }\n }\n padNum = numZeros;\n }\n }\n\n // zero followed by message\n eb.putByte(0x00);\n eb.putBytes(m);\n\n return eb;\n}\n\n/**\n * Decodes a message using PKCS#1 v1.5 padding.\n *\n * @param em the message to decode.\n * @param key the RSA key to use.\n * @param pub true if the key is a public key, false if it is private.\n * @param ml the message length, if specified.\n *\n * @return the decoded bytes.\n */\nfunction _decodePkcs1_v1_5(em, key, pub, ml) {\n // get the length of the modulus in bytes\n var k = Math.ceil(key.n.bitLength() / 8);\n\n /* It is an error if any of the following conditions occurs:\n\n 1. The encryption block EB cannot be parsed unambiguously.\n 2. The padding string PS consists of fewer than eight octets\n or is inconsisent with the block type BT.\n 3. The decryption process is a public-key operation and the block\n type BT is not 00 or 01, or the decryption process is a\n private-key operation and the block type is not 02.\n */\n\n // parse the encryption block\n var eb = forge.util.createBuffer(em);\n var first = eb.getByte();\n var bt = eb.getByte();\n if(first !== 0x00 ||\n (pub && bt !== 0x00 && bt !== 0x01) ||\n (!pub && bt != 0x02) ||\n (pub && bt === 0x00 && typeof(ml) === 'undefined')) {\n throw new Error('Encryption block is invalid.');\n }\n\n var padNum = 0;\n if(bt === 0x00) {\n // check all padding bytes for 0x00\n padNum = k - 3 - ml;\n for(var i = 0; i < padNum; ++i) {\n if(eb.getByte() !== 0x00) {\n throw new Error('Encryption block is invalid.');\n }\n }\n } else if(bt === 0x01) {\n // find the first byte that isn't 0xFF, should be after all padding\n padNum = 0;\n while(eb.length() > 1) {\n if(eb.getByte() !== 0xFF) {\n --eb.read;\n break;\n }\n ++padNum;\n }\n } else if(bt === 0x02) {\n // look for 0x00 byte\n padNum = 0;\n while(eb.length() > 1) {\n if(eb.getByte() === 0x00) {\n --eb.read;\n break;\n }\n ++padNum;\n }\n }\n\n // zero must be 0x00 and padNum must be (k - 3 - message length)\n var zero = eb.getByte();\n if(zero !== 0x00 || padNum !== (k - 3 - eb.length())) {\n throw new Error('Encryption block is invalid.');\n }\n\n return eb.getBytes();\n}\n\n/**\n * Runs the key-generation algorithm asynchronously, either in the background\n * via Web Workers, or using the main thread and setImmediate.\n *\n * @param state the key-pair generation state.\n * @param [options] options for key-pair generation:\n * workerScript the worker script URL.\n * workers the number of web workers (if supported) to use,\n * (default: 2, -1 to use estimated cores minus one).\n * workLoad the size of the work load, ie: number of possible prime\n * numbers for each web worker to check per work assignment,\n * (default: 100).\n * @param callback(err, keypair) called once the operation completes.\n */\nfunction _generateKeyPair(state, options, callback) {\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n var opts = {\n algorithm: {\n name: options.algorithm || 'PRIMEINC',\n options: {\n workers: options.workers || 2,\n workLoad: options.workLoad || 100,\n workerScript: options.workerScript\n }\n }\n };\n if('prng' in options) {\n opts.prng = options.prng;\n }\n\n generate();\n\n function generate() {\n // find p and then q (done in series to simplify)\n getPrime(state.pBits, function(err, num) {\n if(err) {\n return callback(err);\n }\n state.p = num;\n if(state.q !== null) {\n return finish(err, state.q);\n }\n getPrime(state.qBits, finish);\n });\n }\n\n function getPrime(bits, callback) {\n forge.prime.generateProbablePrime(bits, opts, callback);\n }\n\n function finish(err, num) {\n if(err) {\n return callback(err);\n }\n\n // set q\n state.q = num;\n\n // ensure p is larger than q (swap them if not)\n if(state.p.compareTo(state.q) < 0) {\n var tmp = state.p;\n state.p = state.q;\n state.q = tmp;\n }\n\n // ensure p is coprime with e\n if(state.p.subtract(BigInteger.ONE).gcd(state.e)\n .compareTo(BigInteger.ONE) !== 0) {\n state.p = null;\n generate();\n return;\n }\n\n // ensure q is coprime with e\n if(state.q.subtract(BigInteger.ONE).gcd(state.e)\n .compareTo(BigInteger.ONE) !== 0) {\n state.q = null;\n getPrime(state.qBits, finish);\n return;\n }\n\n // compute phi: (p - 1)(q - 1) (Euler's totient function)\n state.p1 = state.p.subtract(BigInteger.ONE);\n state.q1 = state.q.subtract(BigInteger.ONE);\n state.phi = state.p1.multiply(state.q1);\n\n // ensure e and phi are coprime\n if(state.phi.gcd(state.e).compareTo(BigInteger.ONE) !== 0) {\n // phi and e aren't coprime, so generate a new p and q\n state.p = state.q = null;\n generate();\n return;\n }\n\n // create n, ensure n is has the right number of bits\n state.n = state.p.multiply(state.q);\n if(state.n.bitLength() !== state.bits) {\n // failed, get new q\n state.q = null;\n getPrime(state.qBits, finish);\n return;\n }\n\n // set keys\n var d = state.e.modInverse(state.phi);\n state.keys = {\n privateKey: pki.rsa.setPrivateKey(\n state.n, state.e, d, state.p, state.q,\n d.mod(state.p1), d.mod(state.q1),\n state.q.modInverse(state.p)),\n publicKey: pki.rsa.setPublicKey(state.n, state.e)\n };\n\n callback(null, state.keys);\n }\n}\n\n/**\n * Converts a positive BigInteger into 2's-complement big-endian bytes.\n *\n * @param b the big integer to convert.\n *\n * @return the bytes.\n */\nfunction _bnToBytes(b) {\n // prepend 0x00 if first byte >= 0x80\n var hex = b.toString(16);\n if(hex[0] >= '8') {\n hex = '00' + hex;\n }\n var bytes = forge.util.hexToBytes(hex);\n\n // ensure integer is minimally-encoded\n if(bytes.length > 1 &&\n // leading 0x00 for positive integer\n ((bytes.charCodeAt(0) === 0 &&\n (bytes.charCodeAt(1) & 0x80) === 0) ||\n // leading 0xFF for negative integer\n (bytes.charCodeAt(0) === 0xFF &&\n (bytes.charCodeAt(1) & 0x80) === 0x80))) {\n return bytes.substr(1);\n }\n return bytes;\n}\n\n/**\n * Returns the required number of Miller-Rabin tests to generate a\n * prime with an error probability of (1/2)^80.\n *\n * See Handbook of Applied Cryptography Chapter 4, Table 4.4.\n *\n * @param bits the bit size.\n *\n * @return the required number of iterations.\n */\nfunction _getMillerRabinTests(bits) {\n if(bits <= 100) return 27;\n if(bits <= 150) return 18;\n if(bits <= 200) return 15;\n if(bits <= 250) return 12;\n if(bits <= 300) return 9;\n if(bits <= 350) return 8;\n if(bits <= 400) return 7;\n if(bits <= 500) return 6;\n if(bits <= 600) return 5;\n if(bits <= 800) return 4;\n if(bits <= 1250) return 3;\n return 2;\n}\n\n/**\n * Performs feature detection on the Node crypto interface.\n *\n * @param fn the feature (function) to detect.\n *\n * @return true if detected, false if not.\n */\nfunction _detectNodeCrypto(fn) {\n return forge.util.isNodejs && typeof _crypto[fn] === 'function';\n}\n\n/**\n * Performs feature detection on the SubtleCrypto interface.\n *\n * @param fn the feature (function) to detect.\n *\n * @return true if detected, false if not.\n */\nfunction _detectSubtleCrypto(fn) {\n return (typeof util.globalScope !== 'undefined' &&\n typeof util.globalScope.crypto === 'object' &&\n typeof util.globalScope.crypto.subtle === 'object' &&\n typeof util.globalScope.crypto.subtle[fn] === 'function');\n}\n\n/**\n * Performs feature detection on the deprecated Microsoft Internet Explorer\n * outdated SubtleCrypto interface. This function should only be used after\n * checking for the modern, standard SubtleCrypto interface.\n *\n * @param fn the feature (function) to detect.\n *\n * @return true if detected, false if not.\n */\nfunction _detectSubtleMsCrypto(fn) {\n return (typeof util.globalScope !== 'undefined' &&\n typeof util.globalScope.msCrypto === 'object' &&\n typeof util.globalScope.msCrypto.subtle === 'object' &&\n typeof util.globalScope.msCrypto.subtle[fn] === 'function');\n}\n\nfunction _intToUint8Array(x) {\n var bytes = forge.util.hexToBytes(x.toString(16));\n var buffer = new Uint8Array(bytes.length);\n for(var i = 0; i < bytes.length; ++i) {\n buffer[i] = bytes.charCodeAt(i);\n }\n return buffer;\n}\n\nfunction _privateKeyFromJwk(jwk) {\n if(jwk.kty !== 'RSA') {\n throw new Error(\n 'Unsupported key algorithm \"' + jwk.kty + '\"; algorithm must be \"RSA\".');\n }\n return pki.setRsaPrivateKey(\n _base64ToBigInt(jwk.n),\n _base64ToBigInt(jwk.e),\n _base64ToBigInt(jwk.d),\n _base64ToBigInt(jwk.p),\n _base64ToBigInt(jwk.q),\n _base64ToBigInt(jwk.dp),\n _base64ToBigInt(jwk.dq),\n _base64ToBigInt(jwk.qi));\n}\n\nfunction _publicKeyFromJwk(jwk) {\n if(jwk.kty !== 'RSA') {\n throw new Error('Key algorithm must be \"RSA\".');\n }\n return pki.setRsaPublicKey(\n _base64ToBigInt(jwk.n),\n _base64ToBigInt(jwk.e));\n}\n\nfunction _base64ToBigInt(b64) {\n return new BigInteger(forge.util.bytesToHex(forge.util.decode64(b64)), 16);\n}\n","/**\n * Secure Hash Algorithm with 160-bit digest (SHA-1) implementation.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2015 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\nvar sha1 = module.exports = forge.sha1 = forge.sha1 || {};\nforge.md.sha1 = forge.md.algorithms.sha1 = sha1;\n\n/**\n * Creates a SHA-1 message digest object.\n *\n * @return a message digest object.\n */\nsha1.create = function() {\n // do initialization as necessary\n if(!_initialized) {\n _init();\n }\n\n // SHA-1 state contains five 32-bit integers\n var _state = null;\n\n // input buffer\n var _input = forge.util.createBuffer();\n\n // used for word storage\n var _w = new Array(80);\n\n // message digest object\n var md = {\n algorithm: 'sha1',\n blockLength: 64,\n digestLength: 20,\n // 56-bit length of message so far (does not including padding)\n messageLength: 0,\n // true message length\n fullMessageLength: null,\n // size of message length in bytes\n messageLengthSize: 8\n };\n\n /**\n * Starts the digest.\n *\n * @return this digest object.\n */\n md.start = function() {\n // up to 56-bit message length for convenience\n md.messageLength = 0;\n\n // full message length (set md.messageLength64 for backwards-compatibility)\n md.fullMessageLength = md.messageLength64 = [];\n var int32s = md.messageLengthSize / 4;\n for(var i = 0; i < int32s; ++i) {\n md.fullMessageLength.push(0);\n }\n _input = forge.util.createBuffer();\n _state = {\n h0: 0x67452301,\n h1: 0xEFCDAB89,\n h2: 0x98BADCFE,\n h3: 0x10325476,\n h4: 0xC3D2E1F0\n };\n return md;\n };\n // start digest automatically for first time\n md.start();\n\n /**\n * Updates the digest with the given message input. The given input can\n * treated as raw input (no encoding will be applied) or an encoding of\n * 'utf8' maybe given to encode the input using UTF-8.\n *\n * @param msg the message input to update with.\n * @param encoding the encoding to use (default: 'raw', other: 'utf8').\n *\n * @return this digest object.\n */\n md.update = function(msg, encoding) {\n if(encoding === 'utf8') {\n msg = forge.util.encodeUtf8(msg);\n }\n\n // update message length\n var len = msg.length;\n md.messageLength += len;\n len = [(len / 0x100000000) >>> 0, len >>> 0];\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n md.fullMessageLength[i] += len[1];\n len[1] = len[0] + ((md.fullMessageLength[i] / 0x100000000) >>> 0);\n md.fullMessageLength[i] = md.fullMessageLength[i] >>> 0;\n len[0] = ((len[1] / 0x100000000) >>> 0);\n }\n\n // add bytes to input buffer\n _input.putBytes(msg);\n\n // process bytes\n _update(_state, _w, _input);\n\n // compact input buffer every 2K or if empty\n if(_input.read > 2048 || _input.length() === 0) {\n _input.compact();\n }\n\n return md;\n };\n\n /**\n * Produces the digest.\n *\n * @return a byte buffer containing the digest value.\n */\n md.digest = function() {\n /* Note: Here we copy the remaining bytes in the input buffer and\n add the appropriate SHA-1 padding. Then we do the final update\n on a copy of the state so that if the user wants to get\n intermediate digests they can do so. */\n\n /* Determine the number of bytes that must be added to the message\n to ensure its length is congruent to 448 mod 512. In other words,\n the data to be digested must be a multiple of 512 bits (or 128 bytes).\n This data includes the message, some padding, and the length of the\n message. Since the length of the message will be encoded as 8 bytes (64\n bits), that means that the last segment of the data must have 56 bytes\n (448 bits) of message and padding. Therefore, the length of the message\n plus the padding must be congruent to 448 mod 512 because\n 512 - 128 = 448.\n\n In order to fill up the message length it must be filled with\n padding that begins with 1 bit followed by all 0 bits. Padding\n must *always* be present, so if the message length is already\n congruent to 448 mod 512, then 512 padding bits must be added. */\n\n var finalBlock = forge.util.createBuffer();\n finalBlock.putBytes(_input.bytes());\n\n // compute remaining size to be digested (include message length size)\n var remaining = (\n md.fullMessageLength[md.fullMessageLength.length - 1] +\n md.messageLengthSize);\n\n // add padding for overflow blockSize - overflow\n // _padding starts with 1 byte with first bit is set (byte value 128), then\n // there may be up to (blockSize - 1) other pad bytes\n var overflow = remaining & (md.blockLength - 1);\n finalBlock.putBytes(_padding.substr(0, md.blockLength - overflow));\n\n // serialize message length in bits in big-endian order; since length\n // is stored in bytes we multiply by 8 and add carry from next int\n var next, carry;\n var bits = md.fullMessageLength[0] * 8;\n for(var i = 0; i < md.fullMessageLength.length - 1; ++i) {\n next = md.fullMessageLength[i + 1] * 8;\n carry = (next / 0x100000000) >>> 0;\n bits += carry;\n finalBlock.putInt32(bits >>> 0);\n bits = next >>> 0;\n }\n finalBlock.putInt32(bits);\n\n var s2 = {\n h0: _state.h0,\n h1: _state.h1,\n h2: _state.h2,\n h3: _state.h3,\n h4: _state.h4\n };\n _update(s2, _w, finalBlock);\n var rval = forge.util.createBuffer();\n rval.putInt32(s2.h0);\n rval.putInt32(s2.h1);\n rval.putInt32(s2.h2);\n rval.putInt32(s2.h3);\n rval.putInt32(s2.h4);\n return rval;\n };\n\n return md;\n};\n\n// sha-1 padding bytes not initialized yet\nvar _padding = null;\nvar _initialized = false;\n\n/**\n * Initializes the constant tables.\n */\nfunction _init() {\n // create padding\n _padding = String.fromCharCode(128);\n _padding += forge.util.fillString(String.fromCharCode(0x00), 64);\n\n // now initialized\n _initialized = true;\n}\n\n/**\n * Updates a SHA-1 state with the given byte buffer.\n *\n * @param s the SHA-1 state to update.\n * @param w the array to use to store words.\n * @param bytes the byte buffer to update with.\n */\nfunction _update(s, w, bytes) {\n // consume 512 bit (64 byte) chunks\n var t, a, b, c, d, e, f, i;\n var len = bytes.length();\n while(len >= 64) {\n // the w array will be populated with sixteen 32-bit big-endian words\n // and then extended into 80 32-bit words according to SHA-1 algorithm\n // and for 32-79 using Max Locktyukhin's optimization\n\n // initialize hash value for this chunk\n a = s.h0;\n b = s.h1;\n c = s.h2;\n d = s.h3;\n e = s.h4;\n\n // round 1\n for(i = 0; i < 16; ++i) {\n t = bytes.getInt32();\n w[i] = t;\n f = d ^ (b & (c ^ d));\n t = ((a << 5) | (a >>> 27)) + f + e + 0x5A827999 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n for(; i < 20; ++i) {\n t = (w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]);\n t = (t << 1) | (t >>> 31);\n w[i] = t;\n f = d ^ (b & (c ^ d));\n t = ((a << 5) | (a >>> 27)) + f + e + 0x5A827999 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n // round 2\n for(; i < 32; ++i) {\n t = (w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]);\n t = (t << 1) | (t >>> 31);\n w[i] = t;\n f = b ^ c ^ d;\n t = ((a << 5) | (a >>> 27)) + f + e + 0x6ED9EBA1 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n for(; i < 40; ++i) {\n t = (w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]);\n t = (t << 2) | (t >>> 30);\n w[i] = t;\n f = b ^ c ^ d;\n t = ((a << 5) | (a >>> 27)) + f + e + 0x6ED9EBA1 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n // round 3\n for(; i < 60; ++i) {\n t = (w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]);\n t = (t << 2) | (t >>> 30);\n w[i] = t;\n f = (b & c) | (d & (b ^ c));\n t = ((a << 5) | (a >>> 27)) + f + e + 0x8F1BBCDC + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n // round 4\n for(; i < 80; ++i) {\n t = (w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]);\n t = (t << 2) | (t >>> 30);\n w[i] = t;\n f = b ^ c ^ d;\n t = ((a << 5) | (a >>> 27)) + f + e + 0xCA62C1D6 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n\n // update hash state\n s.h0 = (s.h0 + a) | 0;\n s.h1 = (s.h1 + b) | 0;\n s.h2 = (s.h2 + c) | 0;\n s.h3 = (s.h3 + d) | 0;\n s.h4 = (s.h4 + e) | 0;\n\n len -= 64;\n }\n}\n","/**\n * Secure Hash Algorithm with 256-bit digest (SHA-256) implementation.\n *\n * See FIPS 180-2 for details.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2015 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\nvar sha256 = module.exports = forge.sha256 = forge.sha256 || {};\nforge.md.sha256 = forge.md.algorithms.sha256 = sha256;\n\n/**\n * Creates a SHA-256 message digest object.\n *\n * @return a message digest object.\n */\nsha256.create = function() {\n // do initialization as necessary\n if(!_initialized) {\n _init();\n }\n\n // SHA-256 state contains eight 32-bit integers\n var _state = null;\n\n // input buffer\n var _input = forge.util.createBuffer();\n\n // used for word storage\n var _w = new Array(64);\n\n // message digest object\n var md = {\n algorithm: 'sha256',\n blockLength: 64,\n digestLength: 32,\n // 56-bit length of message so far (does not including padding)\n messageLength: 0,\n // true message length\n fullMessageLength: null,\n // size of message length in bytes\n messageLengthSize: 8\n };\n\n /**\n * Starts the digest.\n *\n * @return this digest object.\n */\n md.start = function() {\n // up to 56-bit message length for convenience\n md.messageLength = 0;\n\n // full message length (set md.messageLength64 for backwards-compatibility)\n md.fullMessageLength = md.messageLength64 = [];\n var int32s = md.messageLengthSize / 4;\n for(var i = 0; i < int32s; ++i) {\n md.fullMessageLength.push(0);\n }\n _input = forge.util.createBuffer();\n _state = {\n h0: 0x6A09E667,\n h1: 0xBB67AE85,\n h2: 0x3C6EF372,\n h3: 0xA54FF53A,\n h4: 0x510E527F,\n h5: 0x9B05688C,\n h6: 0x1F83D9AB,\n h7: 0x5BE0CD19\n };\n return md;\n };\n // start digest automatically for first time\n md.start();\n\n /**\n * Updates the digest with the given message input. The given input can\n * treated as raw input (no encoding will be applied) or an encoding of\n * 'utf8' maybe given to encode the input using UTF-8.\n *\n * @param msg the message input to update with.\n * @param encoding the encoding to use (default: 'raw', other: 'utf8').\n *\n * @return this digest object.\n */\n md.update = function(msg, encoding) {\n if(encoding === 'utf8') {\n msg = forge.util.encodeUtf8(msg);\n }\n\n // update message length\n var len = msg.length;\n md.messageLength += len;\n len = [(len / 0x100000000) >>> 0, len >>> 0];\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n md.fullMessageLength[i] += len[1];\n len[1] = len[0] + ((md.fullMessageLength[i] / 0x100000000) >>> 0);\n md.fullMessageLength[i] = md.fullMessageLength[i] >>> 0;\n len[0] = ((len[1] / 0x100000000) >>> 0);\n }\n\n // add bytes to input buffer\n _input.putBytes(msg);\n\n // process bytes\n _update(_state, _w, _input);\n\n // compact input buffer every 2K or if empty\n if(_input.read > 2048 || _input.length() === 0) {\n _input.compact();\n }\n\n return md;\n };\n\n /**\n * Produces the digest.\n *\n * @return a byte buffer containing the digest value.\n */\n md.digest = function() {\n /* Note: Here we copy the remaining bytes in the input buffer and\n add the appropriate SHA-256 padding. Then we do the final update\n on a copy of the state so that if the user wants to get\n intermediate digests they can do so. */\n\n /* Determine the number of bytes that must be added to the message\n to ensure its length is congruent to 448 mod 512. In other words,\n the data to be digested must be a multiple of 512 bits (or 128 bytes).\n This data includes the message, some padding, and the length of the\n message. Since the length of the message will be encoded as 8 bytes (64\n bits), that means that the last segment of the data must have 56 bytes\n (448 bits) of message and padding. Therefore, the length of the message\n plus the padding must be congruent to 448 mod 512 because\n 512 - 128 = 448.\n\n In order to fill up the message length it must be filled with\n padding that begins with 1 bit followed by all 0 bits. Padding\n must *always* be present, so if the message length is already\n congruent to 448 mod 512, then 512 padding bits must be added. */\n\n var finalBlock = forge.util.createBuffer();\n finalBlock.putBytes(_input.bytes());\n\n // compute remaining size to be digested (include message length size)\n var remaining = (\n md.fullMessageLength[md.fullMessageLength.length - 1] +\n md.messageLengthSize);\n\n // add padding for overflow blockSize - overflow\n // _padding starts with 1 byte with first bit is set (byte value 128), then\n // there may be up to (blockSize - 1) other pad bytes\n var overflow = remaining & (md.blockLength - 1);\n finalBlock.putBytes(_padding.substr(0, md.blockLength - overflow));\n\n // serialize message length in bits in big-endian order; since length\n // is stored in bytes we multiply by 8 and add carry from next int\n var next, carry;\n var bits = md.fullMessageLength[0] * 8;\n for(var i = 0; i < md.fullMessageLength.length - 1; ++i) {\n next = md.fullMessageLength[i + 1] * 8;\n carry = (next / 0x100000000) >>> 0;\n bits += carry;\n finalBlock.putInt32(bits >>> 0);\n bits = next >>> 0;\n }\n finalBlock.putInt32(bits);\n\n var s2 = {\n h0: _state.h0,\n h1: _state.h1,\n h2: _state.h2,\n h3: _state.h3,\n h4: _state.h4,\n h5: _state.h5,\n h6: _state.h6,\n h7: _state.h7\n };\n _update(s2, _w, finalBlock);\n var rval = forge.util.createBuffer();\n rval.putInt32(s2.h0);\n rval.putInt32(s2.h1);\n rval.putInt32(s2.h2);\n rval.putInt32(s2.h3);\n rval.putInt32(s2.h4);\n rval.putInt32(s2.h5);\n rval.putInt32(s2.h6);\n rval.putInt32(s2.h7);\n return rval;\n };\n\n return md;\n};\n\n// sha-256 padding bytes not initialized yet\nvar _padding = null;\nvar _initialized = false;\n\n// table of constants\nvar _k = null;\n\n/**\n * Initializes the constant tables.\n */\nfunction _init() {\n // create padding\n _padding = String.fromCharCode(128);\n _padding += forge.util.fillString(String.fromCharCode(0x00), 64);\n\n // create K table for SHA-256\n _k = [\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,\n 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,\n 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,\n 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,\n 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,\n 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,\n 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,\n 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\n 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];\n\n // now initialized\n _initialized = true;\n}\n\n/**\n * Updates a SHA-256 state with the given byte buffer.\n *\n * @param s the SHA-256 state to update.\n * @param w the array to use to store words.\n * @param bytes the byte buffer to update with.\n */\nfunction _update(s, w, bytes) {\n // consume 512 bit (64 byte) chunks\n var t1, t2, s0, s1, ch, maj, i, a, b, c, d, e, f, g, h;\n var len = bytes.length();\n while(len >= 64) {\n // the w array will be populated with sixteen 32-bit big-endian words\n // and then extended into 64 32-bit words according to SHA-256\n for(i = 0; i < 16; ++i) {\n w[i] = bytes.getInt32();\n }\n for(; i < 64; ++i) {\n // XOR word 2 words ago rot right 17, rot right 19, shft right 10\n t1 = w[i - 2];\n t1 =\n ((t1 >>> 17) | (t1 << 15)) ^\n ((t1 >>> 19) | (t1 << 13)) ^\n (t1 >>> 10);\n // XOR word 15 words ago rot right 7, rot right 18, shft right 3\n t2 = w[i - 15];\n t2 =\n ((t2 >>> 7) | (t2 << 25)) ^\n ((t2 >>> 18) | (t2 << 14)) ^\n (t2 >>> 3);\n // sum(t1, word 7 ago, t2, word 16 ago) modulo 2^32\n w[i] = (t1 + w[i - 7] + t2 + w[i - 16]) | 0;\n }\n\n // initialize hash value for this chunk\n a = s.h0;\n b = s.h1;\n c = s.h2;\n d = s.h3;\n e = s.h4;\n f = s.h5;\n g = s.h6;\n h = s.h7;\n\n // round function\n for(i = 0; i < 64; ++i) {\n // Sum1(e)\n s1 =\n ((e >>> 6) | (e << 26)) ^\n ((e >>> 11) | (e << 21)) ^\n ((e >>> 25) | (e << 7));\n // Ch(e, f, g) (optimized the same way as SHA-1)\n ch = g ^ (e & (f ^ g));\n // Sum0(a)\n s0 =\n ((a >>> 2) | (a << 30)) ^\n ((a >>> 13) | (a << 19)) ^\n ((a >>> 22) | (a << 10));\n // Maj(a, b, c) (optimized the same way as SHA-1)\n maj = (a & b) | (c & (a ^ b));\n\n // main algorithm\n t1 = h + s1 + ch + _k[i] + w[i];\n t2 = s0 + maj;\n h = g;\n g = f;\n f = e;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n // can't truncate with `| 0`\n e = (d + t1) >>> 0;\n d = c;\n c = b;\n b = a;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n // can't truncate with `| 0`\n a = (t1 + t2) >>> 0;\n }\n\n // update hash state\n s.h0 = (s.h0 + a) | 0;\n s.h1 = (s.h1 + b) | 0;\n s.h2 = (s.h2 + c) | 0;\n s.h3 = (s.h3 + d) | 0;\n s.h4 = (s.h4 + e) | 0;\n s.h5 = (s.h5 + f) | 0;\n s.h6 = (s.h6 + g) | 0;\n s.h7 = (s.h7 + h) | 0;\n len -= 64;\n }\n}\n","/**\n * Secure Hash Algorithm with a 1024-bit block size implementation.\n *\n * This includes: SHA-512, SHA-384, SHA-512/224, and SHA-512/256. For\n * SHA-256 (block size 512 bits), see sha256.js.\n *\n * See FIPS 180-4 for details.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2014-2015 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\nvar sha512 = module.exports = forge.sha512 = forge.sha512 || {};\n\n// SHA-512\nforge.md.sha512 = forge.md.algorithms.sha512 = sha512;\n\n// SHA-384\nvar sha384 = forge.sha384 = forge.sha512.sha384 = forge.sha512.sha384 || {};\nsha384.create = function() {\n return sha512.create('SHA-384');\n};\nforge.md.sha384 = forge.md.algorithms.sha384 = sha384;\n\n// SHA-512/256\nforge.sha512.sha256 = forge.sha512.sha256 || {\n create: function() {\n return sha512.create('SHA-512/256');\n }\n};\nforge.md['sha512/256'] = forge.md.algorithms['sha512/256'] =\n forge.sha512.sha256;\n\n// SHA-512/224\nforge.sha512.sha224 = forge.sha512.sha224 || {\n create: function() {\n return sha512.create('SHA-512/224');\n }\n};\nforge.md['sha512/224'] = forge.md.algorithms['sha512/224'] =\n forge.sha512.sha224;\n\n/**\n * Creates a SHA-2 message digest object.\n *\n * @param algorithm the algorithm to use (SHA-512, SHA-384, SHA-512/224,\n * SHA-512/256).\n *\n * @return a message digest object.\n */\nsha512.create = function(algorithm) {\n // do initialization as necessary\n if(!_initialized) {\n _init();\n }\n\n if(typeof algorithm === 'undefined') {\n algorithm = 'SHA-512';\n }\n\n if(!(algorithm in _states)) {\n throw new Error('Invalid SHA-512 algorithm: ' + algorithm);\n }\n\n // SHA-512 state contains eight 64-bit integers (each as two 32-bit ints)\n var _state = _states[algorithm];\n var _h = null;\n\n // input buffer\n var _input = forge.util.createBuffer();\n\n // used for 64-bit word storage\n var _w = new Array(80);\n for(var wi = 0; wi < 80; ++wi) {\n _w[wi] = new Array(2);\n }\n\n // determine digest length by algorithm name (default)\n var digestLength = 64;\n switch(algorithm) {\n case 'SHA-384':\n digestLength = 48;\n break;\n case 'SHA-512/256':\n digestLength = 32;\n break;\n case 'SHA-512/224':\n digestLength = 28;\n break;\n }\n\n // message digest object\n var md = {\n // SHA-512 => sha512\n algorithm: algorithm.replace('-', '').toLowerCase(),\n blockLength: 128,\n digestLength: digestLength,\n // 56-bit length of message so far (does not including padding)\n messageLength: 0,\n // true message length\n fullMessageLength: null,\n // size of message length in bytes\n messageLengthSize: 16\n };\n\n /**\n * Starts the digest.\n *\n * @return this digest object.\n */\n md.start = function() {\n // up to 56-bit message length for convenience\n md.messageLength = 0;\n\n // full message length (set md.messageLength128 for backwards-compatibility)\n md.fullMessageLength = md.messageLength128 = [];\n var int32s = md.messageLengthSize / 4;\n for(var i = 0; i < int32s; ++i) {\n md.fullMessageLength.push(0);\n }\n _input = forge.util.createBuffer();\n _h = new Array(_state.length);\n for(var i = 0; i < _state.length; ++i) {\n _h[i] = _state[i].slice(0);\n }\n return md;\n };\n // start digest automatically for first time\n md.start();\n\n /**\n * Updates the digest with the given message input. The given input can\n * treated as raw input (no encoding will be applied) or an encoding of\n * 'utf8' maybe given to encode the input using UTF-8.\n *\n * @param msg the message input to update with.\n * @param encoding the encoding to use (default: 'raw', other: 'utf8').\n *\n * @return this digest object.\n */\n md.update = function(msg, encoding) {\n if(encoding === 'utf8') {\n msg = forge.util.encodeUtf8(msg);\n }\n\n // update message length\n var len = msg.length;\n md.messageLength += len;\n len = [(len / 0x100000000) >>> 0, len >>> 0];\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n md.fullMessageLength[i] += len[1];\n len[1] = len[0] + ((md.fullMessageLength[i] / 0x100000000) >>> 0);\n md.fullMessageLength[i] = md.fullMessageLength[i] >>> 0;\n len[0] = ((len[1] / 0x100000000) >>> 0);\n }\n\n // add bytes to input buffer\n _input.putBytes(msg);\n\n // process bytes\n _update(_h, _w, _input);\n\n // compact input buffer every 2K or if empty\n if(_input.read > 2048 || _input.length() === 0) {\n _input.compact();\n }\n\n return md;\n };\n\n /**\n * Produces the digest.\n *\n * @return a byte buffer containing the digest value.\n */\n md.digest = function() {\n /* Note: Here we copy the remaining bytes in the input buffer and\n add the appropriate SHA-512 padding. Then we do the final update\n on a copy of the state so that if the user wants to get\n intermediate digests they can do so. */\n\n /* Determine the number of bytes that must be added to the message\n to ensure its length is congruent to 896 mod 1024. In other words,\n the data to be digested must be a multiple of 1024 bits (or 128 bytes).\n This data includes the message, some padding, and the length of the\n message. Since the length of the message will be encoded as 16 bytes (128\n bits), that means that the last segment of the data must have 112 bytes\n (896 bits) of message and padding. Therefore, the length of the message\n plus the padding must be congruent to 896 mod 1024 because\n 1024 - 128 = 896.\n\n In order to fill up the message length it must be filled with\n padding that begins with 1 bit followed by all 0 bits. Padding\n must *always* be present, so if the message length is already\n congruent to 896 mod 1024, then 1024 padding bits must be added. */\n\n var finalBlock = forge.util.createBuffer();\n finalBlock.putBytes(_input.bytes());\n\n // compute remaining size to be digested (include message length size)\n var remaining = (\n md.fullMessageLength[md.fullMessageLength.length - 1] +\n md.messageLengthSize);\n\n // add padding for overflow blockSize - overflow\n // _padding starts with 1 byte with first bit is set (byte value 128), then\n // there may be up to (blockSize - 1) other pad bytes\n var overflow = remaining & (md.blockLength - 1);\n finalBlock.putBytes(_padding.substr(0, md.blockLength - overflow));\n\n // serialize message length in bits in big-endian order; since length\n // is stored in bytes we multiply by 8 and add carry from next int\n var next, carry;\n var bits = md.fullMessageLength[0] * 8;\n for(var i = 0; i < md.fullMessageLength.length - 1; ++i) {\n next = md.fullMessageLength[i + 1] * 8;\n carry = (next / 0x100000000) >>> 0;\n bits += carry;\n finalBlock.putInt32(bits >>> 0);\n bits = next >>> 0;\n }\n finalBlock.putInt32(bits);\n\n var h = new Array(_h.length);\n for(var i = 0; i < _h.length; ++i) {\n h[i] = _h[i].slice(0);\n }\n _update(h, _w, finalBlock);\n var rval = forge.util.createBuffer();\n var hlen;\n if(algorithm === 'SHA-512') {\n hlen = h.length;\n } else if(algorithm === 'SHA-384') {\n hlen = h.length - 2;\n } else {\n hlen = h.length - 4;\n }\n for(var i = 0; i < hlen; ++i) {\n rval.putInt32(h[i][0]);\n if(i !== hlen - 1 || algorithm !== 'SHA-512/224') {\n rval.putInt32(h[i][1]);\n }\n }\n return rval;\n };\n\n return md;\n};\n\n// sha-512 padding bytes not initialized yet\nvar _padding = null;\nvar _initialized = false;\n\n// table of constants\nvar _k = null;\n\n// initial hash states\nvar _states = null;\n\n/**\n * Initializes the constant tables.\n */\nfunction _init() {\n // create padding\n _padding = String.fromCharCode(128);\n _padding += forge.util.fillString(String.fromCharCode(0x00), 128);\n\n // create K table for SHA-512\n _k = [\n [0x428a2f98, 0xd728ae22], [0x71374491, 0x23ef65cd],\n [0xb5c0fbcf, 0xec4d3b2f], [0xe9b5dba5, 0x8189dbbc],\n [0x3956c25b, 0xf348b538], [0x59f111f1, 0xb605d019],\n [0x923f82a4, 0xaf194f9b], [0xab1c5ed5, 0xda6d8118],\n [0xd807aa98, 0xa3030242], [0x12835b01, 0x45706fbe],\n [0x243185be, 0x4ee4b28c], [0x550c7dc3, 0xd5ffb4e2],\n [0x72be5d74, 0xf27b896f], [0x80deb1fe, 0x3b1696b1],\n [0x9bdc06a7, 0x25c71235], [0xc19bf174, 0xcf692694],\n [0xe49b69c1, 0x9ef14ad2], [0xefbe4786, 0x384f25e3],\n [0x0fc19dc6, 0x8b8cd5b5], [0x240ca1cc, 0x77ac9c65],\n [0x2de92c6f, 0x592b0275], [0x4a7484aa, 0x6ea6e483],\n [0x5cb0a9dc, 0xbd41fbd4], [0x76f988da, 0x831153b5],\n [0x983e5152, 0xee66dfab], [0xa831c66d, 0x2db43210],\n [0xb00327c8, 0x98fb213f], [0xbf597fc7, 0xbeef0ee4],\n [0xc6e00bf3, 0x3da88fc2], [0xd5a79147, 0x930aa725],\n [0x06ca6351, 0xe003826f], [0x14292967, 0x0a0e6e70],\n [0x27b70a85, 0x46d22ffc], [0x2e1b2138, 0x5c26c926],\n [0x4d2c6dfc, 0x5ac42aed], [0x53380d13, 0x9d95b3df],\n [0x650a7354, 0x8baf63de], [0x766a0abb, 0x3c77b2a8],\n [0x81c2c92e, 0x47edaee6], [0x92722c85, 0x1482353b],\n [0xa2bfe8a1, 0x4cf10364], [0xa81a664b, 0xbc423001],\n [0xc24b8b70, 0xd0f89791], [0xc76c51a3, 0x0654be30],\n [0xd192e819, 0xd6ef5218], [0xd6990624, 0x5565a910],\n [0xf40e3585, 0x5771202a], [0x106aa070, 0x32bbd1b8],\n [0x19a4c116, 0xb8d2d0c8], [0x1e376c08, 0x5141ab53],\n [0x2748774c, 0xdf8eeb99], [0x34b0bcb5, 0xe19b48a8],\n [0x391c0cb3, 0xc5c95a63], [0x4ed8aa4a, 0xe3418acb],\n [0x5b9cca4f, 0x7763e373], [0x682e6ff3, 0xd6b2b8a3],\n [0x748f82ee, 0x5defb2fc], [0x78a5636f, 0x43172f60],\n [0x84c87814, 0xa1f0ab72], [0x8cc70208, 0x1a6439ec],\n [0x90befffa, 0x23631e28], [0xa4506ceb, 0xde82bde9],\n [0xbef9a3f7, 0xb2c67915], [0xc67178f2, 0xe372532b],\n [0xca273ece, 0xea26619c], [0xd186b8c7, 0x21c0c207],\n [0xeada7dd6, 0xcde0eb1e], [0xf57d4f7f, 0xee6ed178],\n [0x06f067aa, 0x72176fba], [0x0a637dc5, 0xa2c898a6],\n [0x113f9804, 0xbef90dae], [0x1b710b35, 0x131c471b],\n [0x28db77f5, 0x23047d84], [0x32caab7b, 0x40c72493],\n [0x3c9ebe0a, 0x15c9bebc], [0x431d67c4, 0x9c100d4c],\n [0x4cc5d4be, 0xcb3e42b6], [0x597f299c, 0xfc657e2a],\n [0x5fcb6fab, 0x3ad6faec], [0x6c44198c, 0x4a475817]\n ];\n\n // initial hash states\n _states = {};\n _states['SHA-512'] = [\n [0x6a09e667, 0xf3bcc908],\n [0xbb67ae85, 0x84caa73b],\n [0x3c6ef372, 0xfe94f82b],\n [0xa54ff53a, 0x5f1d36f1],\n [0x510e527f, 0xade682d1],\n [0x9b05688c, 0x2b3e6c1f],\n [0x1f83d9ab, 0xfb41bd6b],\n [0x5be0cd19, 0x137e2179]\n ];\n _states['SHA-384'] = [\n [0xcbbb9d5d, 0xc1059ed8],\n [0x629a292a, 0x367cd507],\n [0x9159015a, 0x3070dd17],\n [0x152fecd8, 0xf70e5939],\n [0x67332667, 0xffc00b31],\n [0x8eb44a87, 0x68581511],\n [0xdb0c2e0d, 0x64f98fa7],\n [0x47b5481d, 0xbefa4fa4]\n ];\n _states['SHA-512/256'] = [\n [0x22312194, 0xFC2BF72C],\n [0x9F555FA3, 0xC84C64C2],\n [0x2393B86B, 0x6F53B151],\n [0x96387719, 0x5940EABD],\n [0x96283EE2, 0xA88EFFE3],\n [0xBE5E1E25, 0x53863992],\n [0x2B0199FC, 0x2C85B8AA],\n [0x0EB72DDC, 0x81C52CA2]\n ];\n _states['SHA-512/224'] = [\n [0x8C3D37C8, 0x19544DA2],\n [0x73E19966, 0x89DCD4D6],\n [0x1DFAB7AE, 0x32FF9C82],\n [0x679DD514, 0x582F9FCF],\n [0x0F6D2B69, 0x7BD44DA8],\n [0x77E36F73, 0x04C48942],\n [0x3F9D85A8, 0x6A1D36C8],\n [0x1112E6AD, 0x91D692A1]\n ];\n\n // now initialized\n _initialized = true;\n}\n\n/**\n * Updates a SHA-512 state with the given byte buffer.\n *\n * @param s the SHA-512 state to update.\n * @param w the array to use to store words.\n * @param bytes the byte buffer to update with.\n */\nfunction _update(s, w, bytes) {\n // consume 512 bit (128 byte) chunks\n var t1_hi, t1_lo;\n var t2_hi, t2_lo;\n var s0_hi, s0_lo;\n var s1_hi, s1_lo;\n var ch_hi, ch_lo;\n var maj_hi, maj_lo;\n var a_hi, a_lo;\n var b_hi, b_lo;\n var c_hi, c_lo;\n var d_hi, d_lo;\n var e_hi, e_lo;\n var f_hi, f_lo;\n var g_hi, g_lo;\n var h_hi, h_lo;\n var i, hi, lo, w2, w7, w15, w16;\n var len = bytes.length();\n while(len >= 128) {\n // the w array will be populated with sixteen 64-bit big-endian words\n // and then extended into 64 64-bit words according to SHA-512\n for(i = 0; i < 16; ++i) {\n w[i][0] = bytes.getInt32() >>> 0;\n w[i][1] = bytes.getInt32() >>> 0;\n }\n for(; i < 80; ++i) {\n // for word 2 words ago: ROTR 19(x) ^ ROTR 61(x) ^ SHR 6(x)\n w2 = w[i - 2];\n hi = w2[0];\n lo = w2[1];\n\n // high bits\n t1_hi = (\n ((hi >>> 19) | (lo << 13)) ^ // ROTR 19\n ((lo >>> 29) | (hi << 3)) ^ // ROTR 61/(swap + ROTR 29)\n (hi >>> 6)) >>> 0; // SHR 6\n // low bits\n t1_lo = (\n ((hi << 13) | (lo >>> 19)) ^ // ROTR 19\n ((lo << 3) | (hi >>> 29)) ^ // ROTR 61/(swap + ROTR 29)\n ((hi << 26) | (lo >>> 6))) >>> 0; // SHR 6\n\n // for word 15 words ago: ROTR 1(x) ^ ROTR 8(x) ^ SHR 7(x)\n w15 = w[i - 15];\n hi = w15[0];\n lo = w15[1];\n\n // high bits\n t2_hi = (\n ((hi >>> 1) | (lo << 31)) ^ // ROTR 1\n ((hi >>> 8) | (lo << 24)) ^ // ROTR 8\n (hi >>> 7)) >>> 0; // SHR 7\n // low bits\n t2_lo = (\n ((hi << 31) | (lo >>> 1)) ^ // ROTR 1\n ((hi << 24) | (lo >>> 8)) ^ // ROTR 8\n ((hi << 25) | (lo >>> 7))) >>> 0; // SHR 7\n\n // sum(t1, word 7 ago, t2, word 16 ago) modulo 2^64 (carry lo overflow)\n w7 = w[i - 7];\n w16 = w[i - 16];\n lo = (t1_lo + w7[1] + t2_lo + w16[1]);\n w[i][0] = (t1_hi + w7[0] + t2_hi + w16[0] +\n ((lo / 0x100000000) >>> 0)) >>> 0;\n w[i][1] = lo >>> 0;\n }\n\n // initialize hash value for this chunk\n a_hi = s[0][0];\n a_lo = s[0][1];\n b_hi = s[1][0];\n b_lo = s[1][1];\n c_hi = s[2][0];\n c_lo = s[2][1];\n d_hi = s[3][0];\n d_lo = s[3][1];\n e_hi = s[4][0];\n e_lo = s[4][1];\n f_hi = s[5][0];\n f_lo = s[5][1];\n g_hi = s[6][0];\n g_lo = s[6][1];\n h_hi = s[7][0];\n h_lo = s[7][1];\n\n // round function\n for(i = 0; i < 80; ++i) {\n // Sum1(e) = ROTR 14(e) ^ ROTR 18(e) ^ ROTR 41(e)\n s1_hi = (\n ((e_hi >>> 14) | (e_lo << 18)) ^ // ROTR 14\n ((e_hi >>> 18) | (e_lo << 14)) ^ // ROTR 18\n ((e_lo >>> 9) | (e_hi << 23))) >>> 0; // ROTR 41/(swap + ROTR 9)\n s1_lo = (\n ((e_hi << 18) | (e_lo >>> 14)) ^ // ROTR 14\n ((e_hi << 14) | (e_lo >>> 18)) ^ // ROTR 18\n ((e_lo << 23) | (e_hi >>> 9))) >>> 0; // ROTR 41/(swap + ROTR 9)\n\n // Ch(e, f, g) (optimized the same way as SHA-1)\n ch_hi = (g_hi ^ (e_hi & (f_hi ^ g_hi))) >>> 0;\n ch_lo = (g_lo ^ (e_lo & (f_lo ^ g_lo))) >>> 0;\n\n // Sum0(a) = ROTR 28(a) ^ ROTR 34(a) ^ ROTR 39(a)\n s0_hi = (\n ((a_hi >>> 28) | (a_lo << 4)) ^ // ROTR 28\n ((a_lo >>> 2) | (a_hi << 30)) ^ // ROTR 34/(swap + ROTR 2)\n ((a_lo >>> 7) | (a_hi << 25))) >>> 0; // ROTR 39/(swap + ROTR 7)\n s0_lo = (\n ((a_hi << 4) | (a_lo >>> 28)) ^ // ROTR 28\n ((a_lo << 30) | (a_hi >>> 2)) ^ // ROTR 34/(swap + ROTR 2)\n ((a_lo << 25) | (a_hi >>> 7))) >>> 0; // ROTR 39/(swap + ROTR 7)\n\n // Maj(a, b, c) (optimized the same way as SHA-1)\n maj_hi = ((a_hi & b_hi) | (c_hi & (a_hi ^ b_hi))) >>> 0;\n maj_lo = ((a_lo & b_lo) | (c_lo & (a_lo ^ b_lo))) >>> 0;\n\n // main algorithm\n // t1 = (h + s1 + ch + _k[i] + _w[i]) modulo 2^64 (carry lo overflow)\n lo = (h_lo + s1_lo + ch_lo + _k[i][1] + w[i][1]);\n t1_hi = (h_hi + s1_hi + ch_hi + _k[i][0] + w[i][0] +\n ((lo / 0x100000000) >>> 0)) >>> 0;\n t1_lo = lo >>> 0;\n\n // t2 = s0 + maj modulo 2^64 (carry lo overflow)\n lo = s0_lo + maj_lo;\n t2_hi = (s0_hi + maj_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n t2_lo = lo >>> 0;\n\n h_hi = g_hi;\n h_lo = g_lo;\n\n g_hi = f_hi;\n g_lo = f_lo;\n\n f_hi = e_hi;\n f_lo = e_lo;\n\n // e = (d + t1) modulo 2^64 (carry lo overflow)\n lo = d_lo + t1_lo;\n e_hi = (d_hi + t1_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n e_lo = lo >>> 0;\n\n d_hi = c_hi;\n d_lo = c_lo;\n\n c_hi = b_hi;\n c_lo = b_lo;\n\n b_hi = a_hi;\n b_lo = a_lo;\n\n // a = (t1 + t2) modulo 2^64 (carry lo overflow)\n lo = t1_lo + t2_lo;\n a_hi = (t1_hi + t2_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n a_lo = lo >>> 0;\n }\n\n // update hash state (additional modulo 2^64)\n lo = s[0][1] + a_lo;\n s[0][0] = (s[0][0] + a_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[0][1] = lo >>> 0;\n\n lo = s[1][1] + b_lo;\n s[1][0] = (s[1][0] + b_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[1][1] = lo >>> 0;\n\n lo = s[2][1] + c_lo;\n s[2][0] = (s[2][0] + c_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[2][1] = lo >>> 0;\n\n lo = s[3][1] + d_lo;\n s[3][0] = (s[3][0] + d_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[3][1] = lo >>> 0;\n\n lo = s[4][1] + e_lo;\n s[4][0] = (s[4][0] + e_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[4][1] = lo >>> 0;\n\n lo = s[5][1] + f_lo;\n s[5][0] = (s[5][0] + f_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[5][1] = lo >>> 0;\n\n lo = s[6][1] + g_lo;\n s[6][0] = (s[6][0] + g_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[6][1] = lo >>> 0;\n\n lo = s[7][1] + h_lo;\n s[7][0] = (s[7][0] + h_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[7][1] = lo >>> 0;\n\n len -= 128;\n }\n}\n","/**\n * Functions to output keys in SSH-friendly formats.\n *\n * This is part of the Forge project which may be used under the terms of\n * either the BSD License or the GNU General Public License (GPL) Version 2.\n *\n * See: https://github.com/digitalbazaar/forge/blob/cbebca3780658703d925b61b2caffb1d263a6c1d/LICENSE\n *\n * @author https://github.com/shellac\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./hmac');\nrequire('./md5');\nrequire('./sha1');\nrequire('./util');\n\nvar ssh = module.exports = forge.ssh = forge.ssh || {};\n\n/**\n * Encodes (and optionally encrypts) a private RSA key as a Putty PPK file.\n *\n * @param privateKey the key.\n * @param passphrase a passphrase to protect the key (falsy for no encryption).\n * @param comment a comment to include in the key file.\n *\n * @return the PPK file as a string.\n */\nssh.privateKeyToPutty = function(privateKey, passphrase, comment) {\n comment = comment || '';\n passphrase = passphrase || '';\n var algorithm = 'ssh-rsa';\n var encryptionAlgorithm = (passphrase === '') ? 'none' : 'aes256-cbc';\n\n var ppk = 'PuTTY-User-Key-File-2: ' + algorithm + '\\r\\n';\n ppk += 'Encryption: ' + encryptionAlgorithm + '\\r\\n';\n ppk += 'Comment: ' + comment + '\\r\\n';\n\n // public key into buffer for ppk\n var pubbuffer = forge.util.createBuffer();\n _addStringToBuffer(pubbuffer, algorithm);\n _addBigIntegerToBuffer(pubbuffer, privateKey.e);\n _addBigIntegerToBuffer(pubbuffer, privateKey.n);\n\n // write public key\n var pub = forge.util.encode64(pubbuffer.bytes(), 64);\n var length = Math.floor(pub.length / 66) + 1; // 66 = 64 + \\r\\n\n ppk += 'Public-Lines: ' + length + '\\r\\n';\n ppk += pub;\n\n // private key into a buffer\n var privbuffer = forge.util.createBuffer();\n _addBigIntegerToBuffer(privbuffer, privateKey.d);\n _addBigIntegerToBuffer(privbuffer, privateKey.p);\n _addBigIntegerToBuffer(privbuffer, privateKey.q);\n _addBigIntegerToBuffer(privbuffer, privateKey.qInv);\n\n // optionally encrypt the private key\n var priv;\n if(!passphrase) {\n // use the unencrypted buffer\n priv = forge.util.encode64(privbuffer.bytes(), 64);\n } else {\n // encrypt RSA key using passphrase\n var encLen = privbuffer.length() + 16 - 1;\n encLen -= encLen % 16;\n\n // pad private key with sha1-d data -- needs to be a multiple of 16\n var padding = _sha1(privbuffer.bytes());\n\n padding.truncate(padding.length() - encLen + privbuffer.length());\n privbuffer.putBuffer(padding);\n\n var aeskey = forge.util.createBuffer();\n aeskey.putBuffer(_sha1('\\x00\\x00\\x00\\x00', passphrase));\n aeskey.putBuffer(_sha1('\\x00\\x00\\x00\\x01', passphrase));\n\n // encrypt some bytes using CBC mode\n // key is 40 bytes, so truncate *by* 8 bytes\n var cipher = forge.aes.createEncryptionCipher(aeskey.truncate(8), 'CBC');\n cipher.start(forge.util.createBuffer().fillWithByte(0, 16));\n cipher.update(privbuffer.copy());\n cipher.finish();\n var encrypted = cipher.output;\n\n // Note: this appears to differ from Putty -- is forge wrong, or putty?\n // due to padding we finish as an exact multiple of 16\n encrypted.truncate(16); // all padding\n\n priv = forge.util.encode64(encrypted.bytes(), 64);\n }\n\n // output private key\n length = Math.floor(priv.length / 66) + 1; // 64 + \\r\\n\n ppk += '\\r\\nPrivate-Lines: ' + length + '\\r\\n';\n ppk += priv;\n\n // MAC\n var mackey = _sha1('putty-private-key-file-mac-key', passphrase);\n\n var macbuffer = forge.util.createBuffer();\n _addStringToBuffer(macbuffer, algorithm);\n _addStringToBuffer(macbuffer, encryptionAlgorithm);\n _addStringToBuffer(macbuffer, comment);\n macbuffer.putInt32(pubbuffer.length());\n macbuffer.putBuffer(pubbuffer);\n macbuffer.putInt32(privbuffer.length());\n macbuffer.putBuffer(privbuffer);\n\n var hmac = forge.hmac.create();\n hmac.start('sha1', mackey);\n hmac.update(macbuffer.bytes());\n\n ppk += '\\r\\nPrivate-MAC: ' + hmac.digest().toHex() + '\\r\\n';\n\n return ppk;\n};\n\n/**\n * Encodes a public RSA key as an OpenSSH file.\n *\n * @param key the key.\n * @param comment a comment.\n *\n * @return the public key in OpenSSH format.\n */\nssh.publicKeyToOpenSSH = function(key, comment) {\n var type = 'ssh-rsa';\n comment = comment || '';\n\n var buffer = forge.util.createBuffer();\n _addStringToBuffer(buffer, type);\n _addBigIntegerToBuffer(buffer, key.e);\n _addBigIntegerToBuffer(buffer, key.n);\n\n return type + ' ' + forge.util.encode64(buffer.bytes()) + ' ' + comment;\n};\n\n/**\n * Encodes a private RSA key as an OpenSSH file.\n *\n * @param key the key.\n * @param passphrase a passphrase to protect the key (falsy for no encryption).\n *\n * @return the public key in OpenSSH format.\n */\nssh.privateKeyToOpenSSH = function(privateKey, passphrase) {\n if(!passphrase) {\n return forge.pki.privateKeyToPem(privateKey);\n }\n // OpenSSH private key is just a legacy format, it seems\n return forge.pki.encryptRsaPrivateKey(privateKey, passphrase,\n {legacy: true, algorithm: 'aes128'});\n};\n\n/**\n * Gets the SSH fingerprint for the given public key.\n *\n * @param options the options to use.\n * [md] the message digest object to use (defaults to forge.md.md5).\n * [encoding] an alternative output encoding, such as 'hex'\n * (defaults to none, outputs a byte buffer).\n * [delimiter] the delimiter to use between bytes for 'hex' encoded\n * output, eg: ':' (defaults to none).\n *\n * @return the fingerprint as a byte buffer or other encoding based on options.\n */\nssh.getPublicKeyFingerprint = function(key, options) {\n options = options || {};\n var md = options.md || forge.md.md5.create();\n\n var type = 'ssh-rsa';\n var buffer = forge.util.createBuffer();\n _addStringToBuffer(buffer, type);\n _addBigIntegerToBuffer(buffer, key.e);\n _addBigIntegerToBuffer(buffer, key.n);\n\n // hash public key bytes\n md.start();\n md.update(buffer.getBytes());\n var digest = md.digest();\n if(options.encoding === 'hex') {\n var hex = digest.toHex();\n if(options.delimiter) {\n return hex.match(/.{2}/g).join(options.delimiter);\n }\n return hex;\n } else if(options.encoding === 'binary') {\n return digest.getBytes();\n } else if(options.encoding) {\n throw new Error('Unknown encoding \"' + options.encoding + '\".');\n }\n return digest;\n};\n\n/**\n * Adds len(val) then val to a buffer.\n *\n * @param buffer the buffer to add to.\n * @param val a big integer.\n */\nfunction _addBigIntegerToBuffer(buffer, val) {\n var hexVal = val.toString(16);\n // ensure 2s complement +ve\n if(hexVal[0] >= '8') {\n hexVal = '00' + hexVal;\n }\n var bytes = forge.util.hexToBytes(hexVal);\n buffer.putInt32(bytes.length);\n buffer.putBytes(bytes);\n}\n\n/**\n * Adds len(val) then val to a buffer.\n *\n * @param buffer the buffer to add to.\n * @param val a string.\n */\nfunction _addStringToBuffer(buffer, val) {\n buffer.putInt32(val.length);\n buffer.putString(val);\n}\n\n/**\n * Hashes the arguments into one value using SHA-1.\n *\n * @return the sha1 hash of the provided arguments.\n */\nfunction _sha1() {\n var sha = forge.md.sha1.create();\n var num = arguments.length;\n for (var i = 0; i < num; ++i) {\n sha.update(arguments[i]);\n }\n return sha.digest();\n}\n","/**\n * Support for concurrent task management and synchronization in web\n * applications.\n *\n * @author Dave Longley\n * @author David I. Lehn \n *\n * Copyright (c) 2009-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./debug');\nrequire('./log');\nrequire('./util');\n\n// logging category\nvar cat = 'forge.task';\n\n// verbose level\n// 0: off, 1: a little, 2: a whole lot\n// Verbose debug logging is surrounded by a level check to avoid the\n// performance issues with even calling the logging code regardless if it\n// is actually logged. For performance reasons this should not be set to 2\n// for production use.\n// ex: if(sVL >= 2) forge.log.verbose(....)\nvar sVL = 0;\n\n// track tasks for debugging\nvar sTasks = {};\nvar sNextTaskId = 0;\n// debug access\nforge.debug.set(cat, 'tasks', sTasks);\n\n// a map of task type to task queue\nvar sTaskQueues = {};\n// debug access\nforge.debug.set(cat, 'queues', sTaskQueues);\n\n// name for unnamed tasks\nvar sNoTaskName = '?';\n\n// maximum number of doNext() recursions before a context swap occurs\n// FIXME: might need to tweak this based on the browser\nvar sMaxRecursions = 30;\n\n// time slice for doing tasks before a context swap occurs\n// FIXME: might need to tweak this based on the browser\nvar sTimeSlice = 20;\n\n/**\n * Task states.\n *\n * READY: ready to start processing\n * RUNNING: task or a subtask is running\n * BLOCKED: task is waiting to acquire N permits to continue\n * SLEEPING: task is sleeping for a period of time\n * DONE: task is done\n * ERROR: task has an error\n */\nvar READY = 'ready';\nvar RUNNING = 'running';\nvar BLOCKED = 'blocked';\nvar SLEEPING = 'sleeping';\nvar DONE = 'done';\nvar ERROR = 'error';\n\n/**\n * Task actions. Used to control state transitions.\n *\n * STOP: stop processing\n * START: start processing tasks\n * BLOCK: block task from continuing until 1 or more permits are released\n * UNBLOCK: release one or more permits\n * SLEEP: sleep for a period of time\n * WAKEUP: wakeup early from SLEEPING state\n * CANCEL: cancel further tasks\n * FAIL: a failure occured\n */\nvar STOP = 'stop';\nvar START = 'start';\nvar BLOCK = 'block';\nvar UNBLOCK = 'unblock';\nvar SLEEP = 'sleep';\nvar WAKEUP = 'wakeup';\nvar CANCEL = 'cancel';\nvar FAIL = 'fail';\n\n/**\n * State transition table.\n *\n * nextState = sStateTable[currentState][action]\n */\nvar sStateTable = {};\n\nsStateTable[READY] = {};\nsStateTable[READY][STOP] = READY;\nsStateTable[READY][START] = RUNNING;\nsStateTable[READY][CANCEL] = DONE;\nsStateTable[READY][FAIL] = ERROR;\n\nsStateTable[RUNNING] = {};\nsStateTable[RUNNING][STOP] = READY;\nsStateTable[RUNNING][START] = RUNNING;\nsStateTable[RUNNING][BLOCK] = BLOCKED;\nsStateTable[RUNNING][UNBLOCK] = RUNNING;\nsStateTable[RUNNING][SLEEP] = SLEEPING;\nsStateTable[RUNNING][WAKEUP] = RUNNING;\nsStateTable[RUNNING][CANCEL] = DONE;\nsStateTable[RUNNING][FAIL] = ERROR;\n\nsStateTable[BLOCKED] = {};\nsStateTable[BLOCKED][STOP] = BLOCKED;\nsStateTable[BLOCKED][START] = BLOCKED;\nsStateTable[BLOCKED][BLOCK] = BLOCKED;\nsStateTable[BLOCKED][UNBLOCK] = BLOCKED;\nsStateTable[BLOCKED][SLEEP] = BLOCKED;\nsStateTable[BLOCKED][WAKEUP] = BLOCKED;\nsStateTable[BLOCKED][CANCEL] = DONE;\nsStateTable[BLOCKED][FAIL] = ERROR;\n\nsStateTable[SLEEPING] = {};\nsStateTable[SLEEPING][STOP] = SLEEPING;\nsStateTable[SLEEPING][START] = SLEEPING;\nsStateTable[SLEEPING][BLOCK] = SLEEPING;\nsStateTable[SLEEPING][UNBLOCK] = SLEEPING;\nsStateTable[SLEEPING][SLEEP] = SLEEPING;\nsStateTable[SLEEPING][WAKEUP] = SLEEPING;\nsStateTable[SLEEPING][CANCEL] = DONE;\nsStateTable[SLEEPING][FAIL] = ERROR;\n\nsStateTable[DONE] = {};\nsStateTable[DONE][STOP] = DONE;\nsStateTable[DONE][START] = DONE;\nsStateTable[DONE][BLOCK] = DONE;\nsStateTable[DONE][UNBLOCK] = DONE;\nsStateTable[DONE][SLEEP] = DONE;\nsStateTable[DONE][WAKEUP] = DONE;\nsStateTable[DONE][CANCEL] = DONE;\nsStateTable[DONE][FAIL] = ERROR;\n\nsStateTable[ERROR] = {};\nsStateTable[ERROR][STOP] = ERROR;\nsStateTable[ERROR][START] = ERROR;\nsStateTable[ERROR][BLOCK] = ERROR;\nsStateTable[ERROR][UNBLOCK] = ERROR;\nsStateTable[ERROR][SLEEP] = ERROR;\nsStateTable[ERROR][WAKEUP] = ERROR;\nsStateTable[ERROR][CANCEL] = ERROR;\nsStateTable[ERROR][FAIL] = ERROR;\n\n/**\n * Creates a new task.\n *\n * @param options options for this task\n * run: the run function for the task (required)\n * name: the run function for the task (optional)\n * parent: parent of this task (optional)\n *\n * @return the empty task.\n */\nvar Task = function(options) {\n // task id\n this.id = -1;\n\n // task name\n this.name = options.name || sNoTaskName;\n\n // task has no parent\n this.parent = options.parent || null;\n\n // save run function\n this.run = options.run;\n\n // create a queue of subtasks to run\n this.subtasks = [];\n\n // error flag\n this.error = false;\n\n // state of the task\n this.state = READY;\n\n // number of times the task has been blocked (also the number\n // of permits needed to be released to continue running)\n this.blocks = 0;\n\n // timeout id when sleeping\n this.timeoutId = null;\n\n // no swap time yet\n this.swapTime = null;\n\n // no user data\n this.userData = null;\n\n // initialize task\n // FIXME: deal with overflow\n this.id = sNextTaskId++;\n sTasks[this.id] = this;\n if(sVL >= 1) {\n forge.log.verbose(cat, '[%s][%s] init', this.id, this.name, this);\n }\n};\n\n/**\n * Logs debug information on this task and the system state.\n */\nTask.prototype.debug = function(msg) {\n msg = msg || '';\n forge.log.debug(cat, msg,\n '[%s][%s] task:', this.id, this.name, this,\n 'subtasks:', this.subtasks.length,\n 'queue:', sTaskQueues);\n};\n\n/**\n * Adds a subtask to run after task.doNext() or task.fail() is called.\n *\n * @param name human readable name for this task (optional).\n * @param subrun a function to run that takes the current task as\n * its first parameter.\n *\n * @return the current task (useful for chaining next() calls).\n */\nTask.prototype.next = function(name, subrun) {\n // juggle parameters if it looks like no name is given\n if(typeof(name) === 'function') {\n subrun = name;\n\n // inherit parent's name\n name = this.name;\n }\n // create subtask, set parent to this task, propagate callbacks\n var subtask = new Task({\n run: subrun,\n name: name,\n parent: this\n });\n // start subtasks running\n subtask.state = RUNNING;\n subtask.type = this.type;\n subtask.successCallback = this.successCallback || null;\n subtask.failureCallback = this.failureCallback || null;\n\n // queue a new subtask\n this.subtasks.push(subtask);\n\n return this;\n};\n\n/**\n * Adds subtasks to run in parallel after task.doNext() or task.fail()\n * is called.\n *\n * @param name human readable name for this task (optional).\n * @param subrun functions to run that take the current task as\n * their first parameter.\n *\n * @return the current task (useful for chaining next() calls).\n */\nTask.prototype.parallel = function(name, subrun) {\n // juggle parameters if it looks like no name is given\n if(forge.util.isArray(name)) {\n subrun = name;\n\n // inherit parent's name\n name = this.name;\n }\n // Wrap parallel tasks in a regular task so they are started at the\n // proper time.\n return this.next(name, function(task) {\n // block waiting for subtasks\n var ptask = task;\n ptask.block(subrun.length);\n\n // we pass the iterator from the loop below as a parameter\n // to a function because it is otherwise included in the\n // closure and changes as the loop changes -- causing i\n // to always be set to its highest value\n var startParallelTask = function(pname, pi) {\n forge.task.start({\n type: pname,\n run: function(task) {\n subrun[pi](task);\n },\n success: function(task) {\n ptask.unblock();\n },\n failure: function(task) {\n ptask.unblock();\n }\n });\n };\n\n for(var i = 0; i < subrun.length; i++) {\n // Type must be unique so task starts in parallel:\n // name + private string + task id + sub-task index\n // start tasks in parallel and unblock when the finish\n var pname = name + '__parallel-' + task.id + '-' + i;\n var pi = i;\n startParallelTask(pname, pi);\n }\n });\n};\n\n/**\n * Stops a running task.\n */\nTask.prototype.stop = function() {\n this.state = sStateTable[this.state][STOP];\n};\n\n/**\n * Starts running a task.\n */\nTask.prototype.start = function() {\n this.error = false;\n this.state = sStateTable[this.state][START];\n\n // try to restart\n if(this.state === RUNNING) {\n this.start = new Date();\n this.run(this);\n runNext(this, 0);\n }\n};\n\n/**\n * Blocks a task until it one or more permits have been released. The\n * task will not resume until the requested number of permits have\n * been released with call(s) to unblock().\n *\n * @param n number of permits to wait for(default: 1).\n */\nTask.prototype.block = function(n) {\n n = typeof(n) === 'undefined' ? 1 : n;\n this.blocks += n;\n if(this.blocks > 0) {\n this.state = sStateTable[this.state][BLOCK];\n }\n};\n\n/**\n * Releases a permit to unblock a task. If a task was blocked by\n * requesting N permits via block(), then it will only continue\n * running once enough permits have been released via unblock() calls.\n *\n * If multiple processes need to synchronize with a single task then\n * use a condition variable (see forge.task.createCondition). It is\n * an error to unblock a task more times than it has been blocked.\n *\n * @param n number of permits to release (default: 1).\n *\n * @return the current block count (task is unblocked when count is 0)\n */\nTask.prototype.unblock = function(n) {\n n = typeof(n) === 'undefined' ? 1 : n;\n this.blocks -= n;\n if(this.blocks === 0 && this.state !== DONE) {\n this.state = RUNNING;\n runNext(this, 0);\n }\n return this.blocks;\n};\n\n/**\n * Sleep for a period of time before resuming tasks.\n *\n * @param n number of milliseconds to sleep (default: 0).\n */\nTask.prototype.sleep = function(n) {\n n = typeof(n) === 'undefined' ? 0 : n;\n this.state = sStateTable[this.state][SLEEP];\n var self = this;\n this.timeoutId = setTimeout(function() {\n self.timeoutId = null;\n self.state = RUNNING;\n runNext(self, 0);\n }, n);\n};\n\n/**\n * Waits on a condition variable until notified. The next task will\n * not be scheduled until notification. A condition variable can be\n * created with forge.task.createCondition().\n *\n * Once cond.notify() is called, the task will continue.\n *\n * @param cond the condition variable to wait on.\n */\nTask.prototype.wait = function(cond) {\n cond.wait(this);\n};\n\n/**\n * If sleeping, wakeup and continue running tasks.\n */\nTask.prototype.wakeup = function() {\n if(this.state === SLEEPING) {\n cancelTimeout(this.timeoutId);\n this.timeoutId = null;\n this.state = RUNNING;\n runNext(this, 0);\n }\n};\n\n/**\n * Cancel all remaining subtasks of this task.\n */\nTask.prototype.cancel = function() {\n this.state = sStateTable[this.state][CANCEL];\n // remove permits needed\n this.permitsNeeded = 0;\n // cancel timeouts\n if(this.timeoutId !== null) {\n cancelTimeout(this.timeoutId);\n this.timeoutId = null;\n }\n // remove subtasks\n this.subtasks = [];\n};\n\n/**\n * Finishes this task with failure and sets error flag. The entire\n * task will be aborted unless the next task that should execute\n * is passed as a parameter. This allows levels of subtasks to be\n * skipped. For instance, to abort only this tasks's subtasks, then\n * call fail(task.parent). To abort this task's subtasks and its\n * parent's subtasks, call fail(task.parent.parent). To abort\n * all tasks and simply call the task callback, call fail() or\n * fail(null).\n *\n * The task callback (success or failure) will always, eventually, be\n * called.\n *\n * @param next the task to continue at, or null to abort entirely.\n */\nTask.prototype.fail = function(next) {\n // set error flag\n this.error = true;\n\n // finish task\n finish(this, true);\n\n if(next) {\n // propagate task info\n next.error = this.error;\n next.swapTime = this.swapTime;\n next.userData = this.userData;\n\n // do next task as specified\n runNext(next, 0);\n } else {\n if(this.parent !== null) {\n // finish root task (ensures it is removed from task queue)\n var parent = this.parent;\n while(parent.parent !== null) {\n // propagate task info\n parent.error = this.error;\n parent.swapTime = this.swapTime;\n parent.userData = this.userData;\n parent = parent.parent;\n }\n finish(parent, true);\n }\n\n // call failure callback if one exists\n if(this.failureCallback) {\n this.failureCallback(this);\n }\n }\n};\n\n/**\n * Asynchronously start a task.\n *\n * @param task the task to start.\n */\nvar start = function(task) {\n task.error = false;\n task.state = sStateTable[task.state][START];\n setTimeout(function() {\n if(task.state === RUNNING) {\n task.swapTime = +new Date();\n task.run(task);\n runNext(task, 0);\n }\n }, 0);\n};\n\n/**\n * Run the next subtask or finish this task.\n *\n * @param task the task to process.\n * @param recurse the recursion count.\n */\nvar runNext = function(task, recurse) {\n // get time since last context swap (ms), if enough time has passed set\n // swap to true to indicate that doNext was performed asynchronously\n // also, if recurse is too high do asynchronously\n var swap =\n (recurse > sMaxRecursions) ||\n (+new Date() - task.swapTime) > sTimeSlice;\n\n var doNext = function(recurse) {\n recurse++;\n if(task.state === RUNNING) {\n if(swap) {\n // update swap time\n task.swapTime = +new Date();\n }\n\n if(task.subtasks.length > 0) {\n // run next subtask\n var subtask = task.subtasks.shift();\n subtask.error = task.error;\n subtask.swapTime = task.swapTime;\n subtask.userData = task.userData;\n subtask.run(subtask);\n if(!subtask.error) {\n runNext(subtask, recurse);\n }\n } else {\n finish(task);\n\n if(!task.error) {\n // chain back up and run parent\n if(task.parent !== null) {\n // propagate task info\n task.parent.error = task.error;\n task.parent.swapTime = task.swapTime;\n task.parent.userData = task.userData;\n\n // no subtasks left, call run next subtask on parent\n runNext(task.parent, recurse);\n }\n }\n }\n }\n };\n\n if(swap) {\n // we're swapping, so run asynchronously\n setTimeout(doNext, 0);\n } else {\n // not swapping, so run synchronously\n doNext(recurse);\n }\n};\n\n/**\n * Finishes a task and looks for the next task in the queue to start.\n *\n * @param task the task to finish.\n * @param suppressCallbacks true to suppress callbacks.\n */\nvar finish = function(task, suppressCallbacks) {\n // subtask is now done\n task.state = DONE;\n\n delete sTasks[task.id];\n if(sVL >= 1) {\n forge.log.verbose(cat, '[%s][%s] finish',\n task.id, task.name, task);\n }\n\n // only do queue processing for root tasks\n if(task.parent === null) {\n // report error if queue is missing\n if(!(task.type in sTaskQueues)) {\n forge.log.error(cat,\n '[%s][%s] task queue missing [%s]',\n task.id, task.name, task.type);\n } else if(sTaskQueues[task.type].length === 0) {\n // report error if queue is empty\n forge.log.error(cat,\n '[%s][%s] task queue empty [%s]',\n task.id, task.name, task.type);\n } else if(sTaskQueues[task.type][0] !== task) {\n // report error if this task isn't the first in the queue\n forge.log.error(cat,\n '[%s][%s] task not first in queue [%s]',\n task.id, task.name, task.type);\n } else {\n // remove ourselves from the queue\n sTaskQueues[task.type].shift();\n // clean up queue if it is empty\n if(sTaskQueues[task.type].length === 0) {\n if(sVL >= 1) {\n forge.log.verbose(cat, '[%s][%s] delete queue [%s]',\n task.id, task.name, task.type);\n }\n /* Note: Only a task can delete a queue of its own type. This\n is used as a way to synchronize tasks. If a queue for a certain\n task type exists, then a task of that type is running.\n */\n delete sTaskQueues[task.type];\n } else {\n // dequeue the next task and start it\n if(sVL >= 1) {\n forge.log.verbose(cat,\n '[%s][%s] queue start next [%s] remain:%s',\n task.id, task.name, task.type,\n sTaskQueues[task.type].length);\n }\n sTaskQueues[task.type][0].start();\n }\n }\n\n if(!suppressCallbacks) {\n // call final callback if one exists\n if(task.error && task.failureCallback) {\n task.failureCallback(task);\n } else if(!task.error && task.successCallback) {\n task.successCallback(task);\n }\n }\n }\n};\n\n/* Tasks API */\nmodule.exports = forge.task = forge.task || {};\n\n/**\n * Starts a new task that will run the passed function asynchronously.\n *\n * In order to finish the task, either task.doNext() or task.fail()\n * *must* be called.\n *\n * The task must have a type (a string identifier) that can be used to\n * synchronize it with other tasks of the same type. That type can also\n * be used to cancel tasks that haven't started yet.\n *\n * To start a task, the following object must be provided as a parameter\n * (each function takes a task object as its first parameter):\n *\n * {\n * type: the type of task.\n * run: the function to run to execute the task.\n * success: a callback to call when the task succeeds (optional).\n * failure: a callback to call when the task fails (optional).\n * }\n *\n * @param options the object as described above.\n */\nforge.task.start = function(options) {\n // create a new task\n var task = new Task({\n run: options.run,\n name: options.name || sNoTaskName\n });\n task.type = options.type;\n task.successCallback = options.success || null;\n task.failureCallback = options.failure || null;\n\n // append the task onto the appropriate queue\n if(!(task.type in sTaskQueues)) {\n if(sVL >= 1) {\n forge.log.verbose(cat, '[%s][%s] create queue [%s]',\n task.id, task.name, task.type);\n }\n // create the queue with the new task\n sTaskQueues[task.type] = [task];\n start(task);\n } else {\n // push the task onto the queue, it will be run after a task\n // with the same type completes\n sTaskQueues[options.type].push(task);\n }\n};\n\n/**\n * Cancels all tasks of the given type that haven't started yet.\n *\n * @param type the type of task to cancel.\n */\nforge.task.cancel = function(type) {\n // find the task queue\n if(type in sTaskQueues) {\n // empty all but the current task from the queue\n sTaskQueues[type] = [sTaskQueues[type][0]];\n }\n};\n\n/**\n * Creates a condition variable to synchronize tasks. To make a task wait\n * on the condition variable, call task.wait(condition). To notify all\n * tasks that are waiting, call condition.notify().\n *\n * @return the condition variable.\n */\nforge.task.createCondition = function() {\n var cond = {\n // all tasks that are blocked\n tasks: {}\n };\n\n /**\n * Causes the given task to block until notify is called. If the task\n * is already waiting on this condition then this is a no-op.\n *\n * @param task the task to cause to wait.\n */\n cond.wait = function(task) {\n // only block once\n if(!(task.id in cond.tasks)) {\n task.block();\n cond.tasks[task.id] = task;\n }\n };\n\n /**\n * Notifies all waiting tasks to wake up.\n */\n cond.notify = function() {\n // since unblock() will run the next task from here, make sure to\n // clear the condition's blocked task list before unblocking\n var tmp = cond.tasks;\n cond.tasks = {};\n for(var id in tmp) {\n tmp[id].unblock();\n }\n };\n\n return cond;\n};\n","/**\n * A Javascript implementation of Transport Layer Security (TLS).\n *\n * @author Dave Longley\n *\n * Copyright (c) 2009-2014 Digital Bazaar, Inc.\n *\n * The TLS Handshake Protocol involves the following steps:\n *\n * - Exchange hello messages to agree on algorithms, exchange random values,\n * and check for session resumption.\n *\n * - Exchange the necessary cryptographic parameters to allow the client and\n * server to agree on a premaster secret.\n *\n * - Exchange certificates and cryptographic information to allow the client\n * and server to authenticate themselves.\n *\n * - Generate a master secret from the premaster secret and exchanged random\n * values.\n *\n * - Provide security parameters to the record layer.\n *\n * - Allow the client and server to verify that their peer has calculated the\n * same security parameters and that the handshake occurred without tampering\n * by an attacker.\n *\n * Up to 4 different messages may be sent during a key exchange. The server\n * certificate, the server key exchange, the client certificate, and the\n * client key exchange.\n *\n * A typical handshake (from the client's perspective).\n *\n * 1. Client sends ClientHello.\n * 2. Client receives ServerHello.\n * 3. Client receives optional Certificate.\n * 4. Client receives optional ServerKeyExchange.\n * 5. Client receives ServerHelloDone.\n * 6. Client sends optional Certificate.\n * 7. Client sends ClientKeyExchange.\n * 8. Client sends optional CertificateVerify.\n * 9. Client sends ChangeCipherSpec.\n * 10. Client sends Finished.\n * 11. Client receives ChangeCipherSpec.\n * 12. Client receives Finished.\n * 13. Client sends/receives application data.\n *\n * To reuse an existing session:\n *\n * 1. Client sends ClientHello with session ID for reuse.\n * 2. Client receives ServerHello with same session ID if reusing.\n * 3. Client receives ChangeCipherSpec message if reusing.\n * 4. Client receives Finished.\n * 5. Client sends ChangeCipherSpec.\n * 6. Client sends Finished.\n *\n * Note: Client ignores HelloRequest if in the middle of a handshake.\n *\n * Record Layer:\n *\n * The record layer fragments information blocks into TLSPlaintext records\n * carrying data in chunks of 2^14 bytes or less. Client message boundaries are\n * not preserved in the record layer (i.e., multiple client messages of the\n * same ContentType MAY be coalesced into a single TLSPlaintext record, or a\n * single message MAY be fragmented across several records).\n *\n * struct {\n * uint8 major;\n * uint8 minor;\n * } ProtocolVersion;\n *\n * struct {\n * ContentType type;\n * ProtocolVersion version;\n * uint16 length;\n * opaque fragment[TLSPlaintext.length];\n * } TLSPlaintext;\n *\n * type:\n * The higher-level protocol used to process the enclosed fragment.\n *\n * version:\n * The version of the protocol being employed. TLS Version 1.2 uses version\n * {3, 3}. TLS Version 1.0 uses version {3, 1}. Note that a client that\n * supports multiple versions of TLS may not know what version will be\n * employed before it receives the ServerHello.\n *\n * length:\n * The length (in bytes) of the following TLSPlaintext.fragment. The length\n * MUST NOT exceed 2^14 = 16384 bytes.\n *\n * fragment:\n * The application data. This data is transparent and treated as an\n * independent block to be dealt with by the higher-level protocol specified\n * by the type field.\n *\n * Implementations MUST NOT send zero-length fragments of Handshake, Alert, or\n * ChangeCipherSpec content types. Zero-length fragments of Application data\n * MAY be sent as they are potentially useful as a traffic analysis\n * countermeasure.\n *\n * Note: Data of different TLS record layer content types MAY be interleaved.\n * Application data is generally of lower precedence for transmission than\n * other content types. However, records MUST be delivered to the network in\n * the same order as they are protected by the record layer. Recipients MUST\n * receive and process interleaved application layer traffic during handshakes\n * subsequent to the first one on a connection.\n *\n * struct {\n * ContentType type; // same as TLSPlaintext.type\n * ProtocolVersion version;// same as TLSPlaintext.version\n * uint16 length;\n * opaque fragment[TLSCompressed.length];\n * } TLSCompressed;\n *\n * length:\n * The length (in bytes) of the following TLSCompressed.fragment.\n * The length MUST NOT exceed 2^14 + 1024.\n *\n * fragment:\n * The compressed form of TLSPlaintext.fragment.\n *\n * Note: A CompressionMethod.null operation is an identity operation; no fields\n * are altered. In this implementation, since no compression is supported,\n * uncompressed records are always the same as compressed records.\n *\n * Encryption Information:\n *\n * The encryption and MAC functions translate a TLSCompressed structure into a\n * TLSCiphertext. The decryption functions reverse the process. The MAC of the\n * record also includes a sequence number so that missing, extra, or repeated\n * messages are detectable.\n *\n * struct {\n * ContentType type;\n * ProtocolVersion version;\n * uint16 length;\n * select (SecurityParameters.cipher_type) {\n * case stream: GenericStreamCipher;\n * case block: GenericBlockCipher;\n * case aead: GenericAEADCipher;\n * } fragment;\n * } TLSCiphertext;\n *\n * type:\n * The type field is identical to TLSCompressed.type.\n *\n * version:\n * The version field is identical to TLSCompressed.version.\n *\n * length:\n * The length (in bytes) of the following TLSCiphertext.fragment.\n * The length MUST NOT exceed 2^14 + 2048.\n *\n * fragment:\n * The encrypted form of TLSCompressed.fragment, with the MAC.\n *\n * Note: Only CBC Block Ciphers are supported by this implementation.\n *\n * The TLSCompressed.fragment structures are converted to/from block\n * TLSCiphertext.fragment structures.\n *\n * struct {\n * opaque IV[SecurityParameters.record_iv_length];\n * block-ciphered struct {\n * opaque content[TLSCompressed.length];\n * opaque MAC[SecurityParameters.mac_length];\n * uint8 padding[GenericBlockCipher.padding_length];\n * uint8 padding_length;\n * };\n * } GenericBlockCipher;\n *\n * The MAC is generated as described in Section 6.2.3.1.\n *\n * IV:\n * The Initialization Vector (IV) SHOULD be chosen at random, and MUST be\n * unpredictable. Note that in versions of TLS prior to 1.1, there was no\n * IV field, and the last ciphertext block of the previous record (the \"CBC\n * residue\") was used as the IV. This was changed to prevent the attacks\n * described in [CBCATT]. For block ciphers, the IV length is of length\n * SecurityParameters.record_iv_length, which is equal to the\n * SecurityParameters.block_size.\n *\n * padding:\n * Padding that is added to force the length of the plaintext to be an\n * integral multiple of the block cipher's block length. The padding MAY be\n * any length up to 255 bytes, as long as it results in the\n * TLSCiphertext.length being an integral multiple of the block length.\n * Lengths longer than necessary might be desirable to frustrate attacks on\n * a protocol that are based on analysis of the lengths of exchanged\n * messages. Each uint8 in the padding data vector MUST be filled with the\n * padding length value. The receiver MUST check this padding and MUST use\n * the bad_record_mac alert to indicate padding errors.\n *\n * padding_length:\n * The padding length MUST be such that the total size of the\n * GenericBlockCipher structure is a multiple of the cipher's block length.\n * Legal values range from zero to 255, inclusive. This length specifies the\n * length of the padding field exclusive of the padding_length field itself.\n *\n * The encrypted data length (TLSCiphertext.length) is one more than the sum of\n * SecurityParameters.block_length, TLSCompressed.length,\n * SecurityParameters.mac_length, and padding_length.\n *\n * Example: If the block length is 8 bytes, the content length\n * (TLSCompressed.length) is 61 bytes, and the MAC length is 20 bytes, then the\n * length before padding is 82 bytes (this does not include the IV. Thus, the\n * padding length modulo 8 must be equal to 6 in order to make the total length\n * an even multiple of 8 bytes (the block length). The padding length can be\n * 6, 14, 22, and so on, through 254. If the padding length were the minimum\n * necessary, 6, the padding would be 6 bytes, each containing the value 6.\n * Thus, the last 8 octets of the GenericBlockCipher before block encryption\n * would be xx 06 06 06 06 06 06 06, where xx is the last octet of the MAC.\n *\n * Note: With block ciphers in CBC mode (Cipher Block Chaining), it is critical\n * that the entire plaintext of the record be known before any ciphertext is\n * transmitted. Otherwise, it is possible for the attacker to mount the attack\n * described in [CBCATT].\n *\n * Implementation note: Canvel et al. [CBCTIME] have demonstrated a timing\n * attack on CBC padding based on the time required to compute the MAC. In\n * order to defend against this attack, implementations MUST ensure that\n * record processing time is essentially the same whether or not the padding\n * is correct. In general, the best way to do this is to compute the MAC even\n * if the padding is incorrect, and only then reject the packet. For instance,\n * if the pad appears to be incorrect, the implementation might assume a\n * zero-length pad and then compute the MAC. This leaves a small timing\n * channel, since MAC performance depends, to some extent, on the size of the\n * data fragment, but it is not believed to be large enough to be exploitable,\n * due to the large block size of existing MACs and the small size of the\n * timing signal.\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./hmac');\nrequire('./md5');\nrequire('./pem');\nrequire('./pki');\nrequire('./random');\nrequire('./sha1');\nrequire('./util');\n\n/**\n * Generates pseudo random bytes by mixing the result of two hash functions,\n * MD5 and SHA-1.\n *\n * prf_TLS1(secret, label, seed) =\n * P_MD5(S1, label + seed) XOR P_SHA-1(S2, label + seed);\n *\n * Each P_hash function functions as follows:\n *\n * P_hash(secret, seed) = HMAC_hash(secret, A(1) + seed) +\n * HMAC_hash(secret, A(2) + seed) +\n * HMAC_hash(secret, A(3) + seed) + ...\n * A() is defined as:\n * A(0) = seed\n * A(i) = HMAC_hash(secret, A(i-1))\n *\n * The '+' operator denotes concatenation.\n *\n * As many iterations A(N) as are needed are performed to generate enough\n * pseudo random byte output. If an iteration creates more data than is\n * necessary, then it is truncated.\n *\n * Therefore:\n * A(1) = HMAC_hash(secret, A(0))\n * = HMAC_hash(secret, seed)\n * A(2) = HMAC_hash(secret, A(1))\n * = HMAC_hash(secret, HMAC_hash(secret, seed))\n *\n * Therefore:\n * P_hash(secret, seed) =\n * HMAC_hash(secret, HMAC_hash(secret, A(0)) + seed) +\n * HMAC_hash(secret, HMAC_hash(secret, A(1)) + seed) +\n * ...\n *\n * Therefore:\n * P_hash(secret, seed) =\n * HMAC_hash(secret, HMAC_hash(secret, seed) + seed) +\n * HMAC_hash(secret, HMAC_hash(secret, HMAC_hash(secret, seed)) + seed) +\n * ...\n *\n * @param secret the secret to use.\n * @param label the label to use.\n * @param seed the seed value to use.\n * @param length the number of bytes to generate.\n *\n * @return the pseudo random bytes in a byte buffer.\n */\nvar prf_TLS1 = function(secret, label, seed, length) {\n var rval = forge.util.createBuffer();\n\n /* For TLS 1.0, the secret is split in half, into two secrets of equal\n length. If the secret has an odd length then the last byte of the first\n half will be the same as the first byte of the second. The length of the\n two secrets is half of the secret rounded up. */\n var idx = (secret.length >> 1);\n var slen = idx + (secret.length & 1);\n var s1 = secret.substr(0, slen);\n var s2 = secret.substr(idx, slen);\n var ai = forge.util.createBuffer();\n var hmac = forge.hmac.create();\n seed = label + seed;\n\n // determine the number of iterations that must be performed to generate\n // enough output bytes, md5 creates 16 byte hashes, sha1 creates 20\n var md5itr = Math.ceil(length / 16);\n var sha1itr = Math.ceil(length / 20);\n\n // do md5 iterations\n hmac.start('MD5', s1);\n var md5bytes = forge.util.createBuffer();\n ai.putBytes(seed);\n for(var i = 0; i < md5itr; ++i) {\n // HMAC_hash(secret, A(i-1))\n hmac.start(null, null);\n hmac.update(ai.getBytes());\n ai.putBuffer(hmac.digest());\n\n // HMAC_hash(secret, A(i) + seed)\n hmac.start(null, null);\n hmac.update(ai.bytes() + seed);\n md5bytes.putBuffer(hmac.digest());\n }\n\n // do sha1 iterations\n hmac.start('SHA1', s2);\n var sha1bytes = forge.util.createBuffer();\n ai.clear();\n ai.putBytes(seed);\n for(var i = 0; i < sha1itr; ++i) {\n // HMAC_hash(secret, A(i-1))\n hmac.start(null, null);\n hmac.update(ai.getBytes());\n ai.putBuffer(hmac.digest());\n\n // HMAC_hash(secret, A(i) + seed)\n hmac.start(null, null);\n hmac.update(ai.bytes() + seed);\n sha1bytes.putBuffer(hmac.digest());\n }\n\n // XOR the md5 bytes with the sha1 bytes\n rval.putBytes(forge.util.xorBytes(\n md5bytes.getBytes(), sha1bytes.getBytes(), length));\n\n return rval;\n};\n\n/**\n * Generates pseudo random bytes using a SHA256 algorithm. For TLS 1.2.\n *\n * @param secret the secret to use.\n * @param label the label to use.\n * @param seed the seed value to use.\n * @param length the number of bytes to generate.\n *\n * @return the pseudo random bytes in a byte buffer.\n */\nvar prf_sha256 = function(secret, label, seed, length) {\n // FIXME: implement me for TLS 1.2\n};\n\n/**\n * Gets a MAC for a record using the SHA-1 hash algorithm.\n *\n * @param key the mac key.\n * @param state the sequence number (array of two 32-bit integers).\n * @param record the record.\n *\n * @return the sha-1 hash (20 bytes) for the given record.\n */\nvar hmac_sha1 = function(key, seqNum, record) {\n /* MAC is computed like so:\n HMAC_hash(\n key, seqNum +\n TLSCompressed.type +\n TLSCompressed.version +\n TLSCompressed.length +\n TLSCompressed.fragment)\n */\n var hmac = forge.hmac.create();\n hmac.start('SHA1', key);\n var b = forge.util.createBuffer();\n b.putInt32(seqNum[0]);\n b.putInt32(seqNum[1]);\n b.putByte(record.type);\n b.putByte(record.version.major);\n b.putByte(record.version.minor);\n b.putInt16(record.length);\n b.putBytes(record.fragment.bytes());\n hmac.update(b.getBytes());\n return hmac.digest().getBytes();\n};\n\n/**\n * Compresses the TLSPlaintext record into a TLSCompressed record using the\n * deflate algorithm.\n *\n * @param c the TLS connection.\n * @param record the TLSPlaintext record to compress.\n * @param s the ConnectionState to use.\n *\n * @return true on success, false on failure.\n */\nvar deflate = function(c, record, s) {\n var rval = false;\n\n try {\n var bytes = c.deflate(record.fragment.getBytes());\n record.fragment = forge.util.createBuffer(bytes);\n record.length = bytes.length;\n rval = true;\n } catch(ex) {\n // deflate error, fail out\n }\n\n return rval;\n};\n\n/**\n * Decompresses the TLSCompressed record into a TLSPlaintext record using the\n * deflate algorithm.\n *\n * @param c the TLS connection.\n * @param record the TLSCompressed record to decompress.\n * @param s the ConnectionState to use.\n *\n * @return true on success, false on failure.\n */\nvar inflate = function(c, record, s) {\n var rval = false;\n\n try {\n var bytes = c.inflate(record.fragment.getBytes());\n record.fragment = forge.util.createBuffer(bytes);\n record.length = bytes.length;\n rval = true;\n } catch(ex) {\n // inflate error, fail out\n }\n\n return rval;\n};\n\n/**\n * Reads a TLS variable-length vector from a byte buffer.\n *\n * Variable-length vectors are defined by specifying a subrange of legal\n * lengths, inclusively, using the notation . When these are\n * encoded, the actual length precedes the vector's contents in the byte\n * stream. The length will be in the form of a number consuming as many bytes\n * as required to hold the vector's specified maximum (ceiling) length. A\n * variable-length vector with an actual length field of zero is referred to\n * as an empty vector.\n *\n * @param b the byte buffer.\n * @param lenBytes the number of bytes required to store the length.\n *\n * @return the resulting byte buffer.\n */\nvar readVector = function(b, lenBytes) {\n var len = 0;\n switch(lenBytes) {\n case 1:\n len = b.getByte();\n break;\n case 2:\n len = b.getInt16();\n break;\n case 3:\n len = b.getInt24();\n break;\n case 4:\n len = b.getInt32();\n break;\n }\n\n // read vector bytes into a new buffer\n return forge.util.createBuffer(b.getBytes(len));\n};\n\n/**\n * Writes a TLS variable-length vector to a byte buffer.\n *\n * @param b the byte buffer.\n * @param lenBytes the number of bytes required to store the length.\n * @param v the byte buffer vector.\n */\nvar writeVector = function(b, lenBytes, v) {\n // encode length at the start of the vector, where the number of bytes for\n // the length is the maximum number of bytes it would take to encode the\n // vector's ceiling\n b.putInt(v.length(), lenBytes << 3);\n b.putBuffer(v);\n};\n\n/**\n * The tls implementation.\n */\nvar tls = {};\n\n/**\n * Version: TLS 1.2 = 3.3, TLS 1.1 = 3.2, TLS 1.0 = 3.1. Both TLS 1.1 and\n * TLS 1.2 were still too new (ie: openSSL didn't implement them) at the time\n * of this implementation so TLS 1.0 was implemented instead.\n */\ntls.Versions = {\n TLS_1_0: {major: 3, minor: 1},\n TLS_1_1: {major: 3, minor: 2},\n TLS_1_2: {major: 3, minor: 3}\n};\ntls.SupportedVersions = [\n tls.Versions.TLS_1_1,\n tls.Versions.TLS_1_0\n];\ntls.Version = tls.SupportedVersions[0];\n\n/**\n * Maximum fragment size. True maximum is 16384, but we fragment before that\n * to allow for unusual small increases during compression.\n */\ntls.MaxFragment = 16384 - 1024;\n\n/**\n * Whether this entity is considered the \"client\" or \"server\".\n * enum { server, client } ConnectionEnd;\n */\ntls.ConnectionEnd = {\n server: 0,\n client: 1\n};\n\n/**\n * Pseudo-random function algorithm used to generate keys from the master\n * secret.\n * enum { tls_prf_sha256 } PRFAlgorithm;\n */\ntls.PRFAlgorithm = {\n tls_prf_sha256: 0\n};\n\n/**\n * Bulk encryption algorithms.\n * enum { null, rc4, des3, aes } BulkCipherAlgorithm;\n */\ntls.BulkCipherAlgorithm = {\n none: null,\n rc4: 0,\n des3: 1,\n aes: 2\n};\n\n/**\n * Cipher types.\n * enum { stream, block, aead } CipherType;\n */\ntls.CipherType = {\n stream: 0,\n block: 1,\n aead: 2\n};\n\n/**\n * MAC (Message Authentication Code) algorithms.\n * enum { null, hmac_md5, hmac_sha1, hmac_sha256,\n * hmac_sha384, hmac_sha512} MACAlgorithm;\n */\ntls.MACAlgorithm = {\n none: null,\n hmac_md5: 0,\n hmac_sha1: 1,\n hmac_sha256: 2,\n hmac_sha384: 3,\n hmac_sha512: 4\n};\n\n/**\n * Compression algorithms.\n * enum { null(0), deflate(1), (255) } CompressionMethod;\n */\ntls.CompressionMethod = {\n none: 0,\n deflate: 1\n};\n\n/**\n * TLS record content types.\n * enum {\n * change_cipher_spec(20), alert(21), handshake(22),\n * application_data(23), (255)\n * } ContentType;\n */\ntls.ContentType = {\n change_cipher_spec: 20,\n alert: 21,\n handshake: 22,\n application_data: 23,\n heartbeat: 24\n};\n\n/**\n * TLS handshake types.\n * enum {\n * hello_request(0), client_hello(1), server_hello(2),\n * certificate(11), server_key_exchange (12),\n * certificate_request(13), server_hello_done(14),\n * certificate_verify(15), client_key_exchange(16),\n * finished(20), (255)\n * } HandshakeType;\n */\ntls.HandshakeType = {\n hello_request: 0,\n client_hello: 1,\n server_hello: 2,\n certificate: 11,\n server_key_exchange: 12,\n certificate_request: 13,\n server_hello_done: 14,\n certificate_verify: 15,\n client_key_exchange: 16,\n finished: 20\n};\n\n/**\n * TLS Alert Protocol.\n *\n * enum { warning(1), fatal(2), (255) } AlertLevel;\n *\n * enum {\n * close_notify(0),\n * unexpected_message(10),\n * bad_record_mac(20),\n * decryption_failed(21),\n * record_overflow(22),\n * decompression_failure(30),\n * handshake_failure(40),\n * bad_certificate(42),\n * unsupported_certificate(43),\n * certificate_revoked(44),\n * certificate_expired(45),\n * certificate_unknown(46),\n * illegal_parameter(47),\n * unknown_ca(48),\n * access_denied(49),\n * decode_error(50),\n * decrypt_error(51),\n * export_restriction(60),\n * protocol_version(70),\n * insufficient_security(71),\n * internal_error(80),\n * user_canceled(90),\n * no_renegotiation(100),\n * (255)\n * } AlertDescription;\n *\n * struct {\n * AlertLevel level;\n * AlertDescription description;\n * } Alert;\n */\ntls.Alert = {};\ntls.Alert.Level = {\n warning: 1,\n fatal: 2\n};\ntls.Alert.Description = {\n close_notify: 0,\n unexpected_message: 10,\n bad_record_mac: 20,\n decryption_failed: 21,\n record_overflow: 22,\n decompression_failure: 30,\n handshake_failure: 40,\n bad_certificate: 42,\n unsupported_certificate: 43,\n certificate_revoked: 44,\n certificate_expired: 45,\n certificate_unknown: 46,\n illegal_parameter: 47,\n unknown_ca: 48,\n access_denied: 49,\n decode_error: 50,\n decrypt_error: 51,\n export_restriction: 60,\n protocol_version: 70,\n insufficient_security: 71,\n internal_error: 80,\n user_canceled: 90,\n no_renegotiation: 100\n};\n\n/**\n * TLS Heartbeat Message types.\n * enum {\n * heartbeat_request(1),\n * heartbeat_response(2),\n * (255)\n * } HeartbeatMessageType;\n */\ntls.HeartbeatMessageType = {\n heartbeat_request: 1,\n heartbeat_response: 2\n};\n\n/**\n * Supported cipher suites.\n */\ntls.CipherSuites = {};\n\n/**\n * Gets a supported cipher suite from its 2 byte ID.\n *\n * @param twoBytes two bytes in a string.\n *\n * @return the matching supported cipher suite or null.\n */\ntls.getCipherSuite = function(twoBytes) {\n var rval = null;\n for(var key in tls.CipherSuites) {\n var cs = tls.CipherSuites[key];\n if(cs.id[0] === twoBytes.charCodeAt(0) &&\n cs.id[1] === twoBytes.charCodeAt(1)) {\n rval = cs;\n break;\n }\n }\n return rval;\n};\n\n/**\n * Called when an unexpected record is encountered.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleUnexpected = function(c, record) {\n // if connection is client and closed, ignore unexpected messages\n var ignore = (!c.open && c.entity === tls.ConnectionEnd.client);\n if(!ignore) {\n c.error(c, {\n message: 'Unexpected message. Received TLS record out of order.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.unexpected_message\n }\n });\n }\n};\n\n/**\n * Called when a client receives a HelloRequest record.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleHelloRequest = function(c, record, length) {\n // ignore renegotiation requests from the server during a handshake, but\n // if handshaking, send a warning alert that renegotation is denied\n if(!c.handshaking && c.handshakes > 0) {\n // send alert warning\n tls.queue(c, tls.createAlert(c, {\n level: tls.Alert.Level.warning,\n description: tls.Alert.Description.no_renegotiation\n }));\n tls.flush(c);\n }\n\n // continue\n c.process();\n};\n\n/**\n * Parses a hello message from a ClientHello or ServerHello record.\n *\n * @param record the record to parse.\n *\n * @return the parsed message.\n */\ntls.parseHelloMessage = function(c, record, length) {\n var msg = null;\n\n var client = (c.entity === tls.ConnectionEnd.client);\n\n // minimum of 38 bytes in message\n if(length < 38) {\n c.error(c, {\n message: client ?\n 'Invalid ServerHello message. Message too short.' :\n 'Invalid ClientHello message. Message too short.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n } else {\n // use 'remaining' to calculate # of remaining bytes in the message\n var b = record.fragment;\n var remaining = b.length();\n msg = {\n version: {\n major: b.getByte(),\n minor: b.getByte()\n },\n random: forge.util.createBuffer(b.getBytes(32)),\n session_id: readVector(b, 1),\n extensions: []\n };\n if(client) {\n msg.cipher_suite = b.getBytes(2);\n msg.compression_method = b.getByte();\n } else {\n msg.cipher_suites = readVector(b, 2);\n msg.compression_methods = readVector(b, 1);\n }\n\n // read extensions if there are any bytes left in the message\n remaining = length - (remaining - b.length());\n if(remaining > 0) {\n // parse extensions\n var exts = readVector(b, 2);\n while(exts.length() > 0) {\n msg.extensions.push({\n type: [exts.getByte(), exts.getByte()],\n data: readVector(exts, 2)\n });\n }\n\n // TODO: make extension support modular\n if(!client) {\n for(var i = 0; i < msg.extensions.length; ++i) {\n var ext = msg.extensions[i];\n\n // support SNI extension\n if(ext.type[0] === 0x00 && ext.type[1] === 0x00) {\n // get server name list\n var snl = readVector(ext.data, 2);\n while(snl.length() > 0) {\n // read server name type\n var snType = snl.getByte();\n\n // only HostName type (0x00) is known, break out if\n // another type is detected\n if(snType !== 0x00) {\n break;\n }\n\n // add host name to server name list\n c.session.extensions.server_name.serverNameList.push(\n readVector(snl, 2).getBytes());\n }\n }\n }\n }\n }\n\n // version already set, do not allow version change\n if(c.session.version) {\n if(msg.version.major !== c.session.version.major ||\n msg.version.minor !== c.session.version.minor) {\n return c.error(c, {\n message: 'TLS version change is disallowed during renegotiation.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.protocol_version\n }\n });\n }\n }\n\n // get the chosen (ServerHello) cipher suite\n if(client) {\n // FIXME: should be checking configured acceptable cipher suites\n c.session.cipherSuite = tls.getCipherSuite(msg.cipher_suite);\n } else {\n // get a supported preferred (ClientHello) cipher suite\n // choose the first supported cipher suite\n var tmp = forge.util.createBuffer(msg.cipher_suites.bytes());\n while(tmp.length() > 0) {\n // FIXME: should be checking configured acceptable suites\n // cipher suites take up 2 bytes\n c.session.cipherSuite = tls.getCipherSuite(tmp.getBytes(2));\n if(c.session.cipherSuite !== null) {\n break;\n }\n }\n }\n\n // cipher suite not supported\n if(c.session.cipherSuite === null) {\n return c.error(c, {\n message: 'No cipher suites in common.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.handshake_failure\n },\n cipherSuite: forge.util.bytesToHex(msg.cipher_suite)\n });\n }\n\n // TODO: handle compression methods\n if(client) {\n c.session.compressionMethod = msg.compression_method;\n } else {\n // no compression\n c.session.compressionMethod = tls.CompressionMethod.none;\n }\n }\n\n return msg;\n};\n\n/**\n * Creates security parameters for the given connection based on the given\n * hello message.\n *\n * @param c the TLS connection.\n * @param msg the hello message.\n */\ntls.createSecurityParameters = function(c, msg) {\n /* Note: security params are from TLS 1.2, some values like prf_algorithm\n are ignored for TLS 1.0/1.1 and the builtin as specified in the spec is\n used. */\n\n // TODO: handle other options from server when more supported\n\n // get client and server randoms\n var client = (c.entity === tls.ConnectionEnd.client);\n var msgRandom = msg.random.bytes();\n var cRandom = client ? c.session.sp.client_random : msgRandom;\n var sRandom = client ? msgRandom : tls.createRandom().getBytes();\n\n // create new security parameters\n c.session.sp = {\n entity: c.entity,\n prf_algorithm: tls.PRFAlgorithm.tls_prf_sha256,\n bulk_cipher_algorithm: null,\n cipher_type: null,\n enc_key_length: null,\n block_length: null,\n fixed_iv_length: null,\n record_iv_length: null,\n mac_algorithm: null,\n mac_length: null,\n mac_key_length: null,\n compression_algorithm: c.session.compressionMethod,\n pre_master_secret: null,\n master_secret: null,\n client_random: cRandom,\n server_random: sRandom\n };\n};\n\n/**\n * Called when a client receives a ServerHello record.\n *\n * When a ServerHello message will be sent:\n * The server will send this message in response to a client hello message\n * when it was able to find an acceptable set of algorithms. If it cannot\n * find such a match, it will respond with a handshake failure alert.\n *\n * uint24 length;\n * struct {\n * ProtocolVersion server_version;\n * Random random;\n * SessionID session_id;\n * CipherSuite cipher_suite;\n * CompressionMethod compression_method;\n * select(extensions_present) {\n * case false:\n * struct {};\n * case true:\n * Extension extensions<0..2^16-1>;\n * };\n * } ServerHello;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleServerHello = function(c, record, length) {\n var msg = tls.parseHelloMessage(c, record, length);\n if(c.fail) {\n return;\n }\n\n // ensure server version is compatible\n if(msg.version.minor <= c.version.minor) {\n c.version.minor = msg.version.minor;\n } else {\n return c.error(c, {\n message: 'Incompatible TLS version.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.protocol_version\n }\n });\n }\n\n // indicate session version has been set\n c.session.version = c.version;\n\n // get the session ID from the message\n var sessionId = msg.session_id.bytes();\n\n // if the session ID is not blank and matches the cached one, resume\n // the session\n if(sessionId.length > 0 && sessionId === c.session.id) {\n // resuming session, expect a ChangeCipherSpec next\n c.expect = SCC;\n c.session.resuming = true;\n\n // get new server random\n c.session.sp.server_random = msg.random.bytes();\n } else {\n // not resuming, expect a server Certificate message next\n c.expect = SCE;\n c.session.resuming = false;\n\n // create new security parameters\n tls.createSecurityParameters(c, msg);\n }\n\n // set new session ID\n c.session.id = sessionId;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a server receives a ClientHello record.\n *\n * When a ClientHello message will be sent:\n * When a client first connects to a server it is required to send the\n * client hello as its first message. The client can also send a client\n * hello in response to a hello request or on its own initiative in order\n * to renegotiate the security parameters in an existing connection.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleClientHello = function(c, record, length) {\n var msg = tls.parseHelloMessage(c, record, length);\n if(c.fail) {\n return;\n }\n\n // get the session ID from the message\n var sessionId = msg.session_id.bytes();\n\n // see if the given session ID is in the cache\n var session = null;\n if(c.sessionCache) {\n session = c.sessionCache.getSession(sessionId);\n if(session === null) {\n // session ID not found\n sessionId = '';\n } else if(session.version.major !== msg.version.major ||\n session.version.minor > msg.version.minor) {\n // if session version is incompatible with client version, do not resume\n session = null;\n sessionId = '';\n }\n }\n\n // no session found to resume, generate a new session ID\n if(sessionId.length === 0) {\n sessionId = forge.random.getBytes(32);\n }\n\n // update session\n c.session.id = sessionId;\n c.session.clientHelloVersion = msg.version;\n c.session.sp = {};\n if(session) {\n // use version and security parameters from resumed session\n c.version = c.session.version = session.version;\n c.session.sp = session.sp;\n } else {\n // use highest compatible minor version\n var version;\n for(var i = 1; i < tls.SupportedVersions.length; ++i) {\n version = tls.SupportedVersions[i];\n if(version.minor <= msg.version.minor) {\n break;\n }\n }\n c.version = {major: version.major, minor: version.minor};\n c.session.version = c.version;\n }\n\n // if a session is set, resume it\n if(session !== null) {\n // resuming session, expect a ChangeCipherSpec next\n c.expect = CCC;\n c.session.resuming = true;\n\n // get new client random\n c.session.sp.client_random = msg.random.bytes();\n } else {\n // not resuming, expect a Certificate or ClientKeyExchange\n c.expect = (c.verifyClient !== false) ? CCE : CKE;\n c.session.resuming = false;\n\n // create new security parameters\n tls.createSecurityParameters(c, msg);\n }\n\n // connection now open\n c.open = true;\n\n // queue server hello\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createServerHello(c)\n }));\n\n if(c.session.resuming) {\n // queue change cipher spec message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.change_cipher_spec,\n data: tls.createChangeCipherSpec()\n }));\n\n // create pending state\n c.state.pending = tls.createConnectionState(c);\n\n // change current write state to pending write state\n c.state.current.write = c.state.pending.write;\n\n // queue finished\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createFinished(c)\n }));\n } else {\n // queue server certificate\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createCertificate(c)\n }));\n\n if(!c.fail) {\n // queue server key exchange\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createServerKeyExchange(c)\n }));\n\n // request client certificate if set\n if(c.verifyClient !== false) {\n // queue certificate request\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createCertificateRequest(c)\n }));\n }\n\n // queue server hello done\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createServerHelloDone(c)\n }));\n }\n }\n\n // send records\n tls.flush(c);\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a Certificate record.\n *\n * When this message will be sent:\n * The server must send a certificate whenever the agreed-upon key exchange\n * method is not an anonymous one. This message will always immediately\n * follow the server hello message.\n *\n * Meaning of this message:\n * The certificate type must be appropriate for the selected cipher suite's\n * key exchange algorithm, and is generally an X.509v3 certificate. It must\n * contain a key which matches the key exchange method, as follows. Unless\n * otherwise specified, the signing algorithm for the certificate must be\n * the same as the algorithm for the certificate key. Unless otherwise\n * specified, the public key may be of any length.\n *\n * opaque ASN.1Cert<1..2^24-1>;\n * struct {\n * ASN.1Cert certificate_list<1..2^24-1>;\n * } Certificate;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleCertificate = function(c, record, length) {\n // minimum of 3 bytes in message\n if(length < 3) {\n return c.error(c, {\n message: 'Invalid Certificate message. Message too short.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n }\n\n var b = record.fragment;\n var msg = {\n certificate_list: readVector(b, 3)\n };\n\n /* The sender's certificate will be first in the list (chain), each\n subsequent one that follows will certify the previous one, but root\n certificates (self-signed) that specify the certificate authority may\n be omitted under the assumption that clients must already possess it. */\n var cert, asn1;\n var certs = [];\n try {\n while(msg.certificate_list.length() > 0) {\n // each entry in msg.certificate_list is a vector with 3 len bytes\n cert = readVector(msg.certificate_list, 3);\n asn1 = forge.asn1.fromDer(cert);\n cert = forge.pki.certificateFromAsn1(asn1, true);\n certs.push(cert);\n }\n } catch(ex) {\n return c.error(c, {\n message: 'Could not parse certificate list.',\n cause: ex,\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.bad_certificate\n }\n });\n }\n\n // ensure at least 1 certificate was provided if in client-mode\n // or if verifyClient was set to true to require a certificate\n // (as opposed to 'optional')\n var client = (c.entity === tls.ConnectionEnd.client);\n if((client || c.verifyClient === true) && certs.length === 0) {\n // error, no certificate\n c.error(c, {\n message: client ?\n 'No server certificate provided.' :\n 'No client certificate provided.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n } else if(certs.length === 0) {\n // no certs to verify\n // expect a ServerKeyExchange or ClientKeyExchange message next\n c.expect = client ? SKE : CKE;\n } else {\n // save certificate in session\n if(client) {\n c.session.serverCertificate = certs[0];\n } else {\n c.session.clientCertificate = certs[0];\n }\n\n if(tls.verifyCertificateChain(c, certs)) {\n // expect a ServerKeyExchange or ClientKeyExchange message next\n c.expect = client ? SKE : CKE;\n }\n }\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a ServerKeyExchange record.\n *\n * When this message will be sent:\n * This message will be sent immediately after the server certificate\n * message (or the server hello message, if this is an anonymous\n * negotiation).\n *\n * The server key exchange message is sent by the server only when the\n * server certificate message (if sent) does not contain enough data to\n * allow the client to exchange a premaster secret.\n *\n * Meaning of this message:\n * This message conveys cryptographic information to allow the client to\n * communicate the premaster secret: either an RSA public key to encrypt\n * the premaster secret with, or a Diffie-Hellman public key with which the\n * client can complete a key exchange (with the result being the premaster\n * secret.)\n *\n * enum {\n * dhe_dss, dhe_rsa, dh_anon, rsa, dh_dss, dh_rsa\n * } KeyExchangeAlgorithm;\n *\n * struct {\n * opaque dh_p<1..2^16-1>;\n * opaque dh_g<1..2^16-1>;\n * opaque dh_Ys<1..2^16-1>;\n * } ServerDHParams;\n *\n * struct {\n * select(KeyExchangeAlgorithm) {\n * case dh_anon:\n * ServerDHParams params;\n * case dhe_dss:\n * case dhe_rsa:\n * ServerDHParams params;\n * digitally-signed struct {\n * opaque client_random[32];\n * opaque server_random[32];\n * ServerDHParams params;\n * } signed_params;\n * case rsa:\n * case dh_dss:\n * case dh_rsa:\n * struct {};\n * };\n * } ServerKeyExchange;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleServerKeyExchange = function(c, record, length) {\n // this implementation only supports RSA, no Diffie-Hellman support\n // so any length > 0 is invalid\n if(length > 0) {\n return c.error(c, {\n message: 'Invalid key parameters. Only RSA is supported.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.unsupported_certificate\n }\n });\n }\n\n // expect an optional CertificateRequest message next\n c.expect = SCR;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a ClientKeyExchange record.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleClientKeyExchange = function(c, record, length) {\n // this implementation only supports RSA, no Diffie-Hellman support\n // so any length < 48 is invalid\n if(length < 48) {\n return c.error(c, {\n message: 'Invalid key parameters. Only RSA is supported.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.unsupported_certificate\n }\n });\n }\n\n var b = record.fragment;\n var msg = {\n enc_pre_master_secret: readVector(b, 2).getBytes()\n };\n\n // do rsa decryption\n var privateKey = null;\n if(c.getPrivateKey) {\n try {\n privateKey = c.getPrivateKey(c, c.session.serverCertificate);\n privateKey = forge.pki.privateKeyFromPem(privateKey);\n } catch(ex) {\n c.error(c, {\n message: 'Could not get private key.',\n cause: ex,\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n }\n }\n\n if(privateKey === null) {\n return c.error(c, {\n message: 'No private key set.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n }\n\n try {\n // decrypt 48-byte pre-master secret\n var sp = c.session.sp;\n sp.pre_master_secret = privateKey.decrypt(msg.enc_pre_master_secret);\n\n // ensure client hello version matches first 2 bytes\n var version = c.session.clientHelloVersion;\n if(version.major !== sp.pre_master_secret.charCodeAt(0) ||\n version.minor !== sp.pre_master_secret.charCodeAt(1)) {\n // error, do not send alert (see BLEI attack below)\n throw new Error('TLS version rollback attack detected.');\n }\n } catch(ex) {\n /* Note: Daniel Bleichenbacher [BLEI] can be used to attack a\n TLS server which is using PKCS#1 encoded RSA, so instead of\n failing here, we generate 48 random bytes and use that as\n the pre-master secret. */\n sp.pre_master_secret = forge.random.getBytes(48);\n }\n\n // expect a CertificateVerify message if a Certificate was received that\n // does not have fixed Diffie-Hellman params, otherwise expect\n // ChangeCipherSpec\n c.expect = CCC;\n if(c.session.clientCertificate !== null) {\n // only RSA support, so expect CertificateVerify\n // TODO: support Diffie-Hellman\n c.expect = CCV;\n }\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a CertificateRequest record.\n *\n * When this message will be sent:\n * A non-anonymous server can optionally request a certificate from the\n * client, if appropriate for the selected cipher suite. This message, if\n * sent, will immediately follow the Server Key Exchange message (if it is\n * sent; otherwise, the Server Certificate message).\n *\n * enum {\n * rsa_sign(1), dss_sign(2), rsa_fixed_dh(3), dss_fixed_dh(4),\n * rsa_ephemeral_dh_RESERVED(5), dss_ephemeral_dh_RESERVED(6),\n * fortezza_dms_RESERVED(20), (255)\n * } ClientCertificateType;\n *\n * opaque DistinguishedName<1..2^16-1>;\n *\n * struct {\n * ClientCertificateType certificate_types<1..2^8-1>;\n * SignatureAndHashAlgorithm supported_signature_algorithms<2^16-1>;\n * DistinguishedName certificate_authorities<0..2^16-1>;\n * } CertificateRequest;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleCertificateRequest = function(c, record, length) {\n // minimum of 3 bytes in message\n if(length < 3) {\n return c.error(c, {\n message: 'Invalid CertificateRequest. Message too short.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n }\n\n // TODO: TLS 1.2+ has different format including\n // SignatureAndHashAlgorithm after cert types\n var b = record.fragment;\n var msg = {\n certificate_types: readVector(b, 1),\n certificate_authorities: readVector(b, 2)\n };\n\n // save certificate request in session\n c.session.certificateRequest = msg;\n\n // expect a ServerHelloDone message next\n c.expect = SHD;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a server receives a CertificateVerify record.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleCertificateVerify = function(c, record, length) {\n if(length < 2) {\n return c.error(c, {\n message: 'Invalid CertificateVerify. Message too short.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n }\n\n // rewind to get full bytes for message so it can be manually\n // digested below (special case for CertificateVerify messages because\n // they must be digested *after* handling as opposed to all others)\n var b = record.fragment;\n b.read -= 4;\n var msgBytes = b.bytes();\n b.read += 4;\n\n var msg = {\n signature: readVector(b, 2).getBytes()\n };\n\n // TODO: add support for DSA\n\n // generate data to verify\n var verify = forge.util.createBuffer();\n verify.putBuffer(c.session.md5.digest());\n verify.putBuffer(c.session.sha1.digest());\n verify = verify.getBytes();\n\n try {\n var cert = c.session.clientCertificate;\n /*b = forge.pki.rsa.decrypt(\n msg.signature, cert.publicKey, true, verify.length);\n if(b !== verify) {*/\n if(!cert.publicKey.verify(verify, msg.signature, 'NONE')) {\n throw new Error('CertificateVerify signature does not match.');\n }\n\n // digest message now that it has been handled\n c.session.md5.update(msgBytes);\n c.session.sha1.update(msgBytes);\n } catch(ex) {\n return c.error(c, {\n message: 'Bad signature in CertificateVerify.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.handshake_failure\n }\n });\n }\n\n // expect ChangeCipherSpec\n c.expect = CCC;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a ServerHelloDone record.\n *\n * When this message will be sent:\n * The server hello done message is sent by the server to indicate the end\n * of the server hello and associated messages. After sending this message\n * the server will wait for a client response.\n *\n * Meaning of this message:\n * This message means that the server is done sending messages to support\n * the key exchange, and the client can proceed with its phase of the key\n * exchange.\n *\n * Upon receipt of the server hello done message the client should verify\n * that the server provided a valid certificate if required and check that\n * the server hello parameters are acceptable.\n *\n * struct {} ServerHelloDone;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleServerHelloDone = function(c, record, length) {\n // len must be 0 bytes\n if(length > 0) {\n return c.error(c, {\n message: 'Invalid ServerHelloDone message. Invalid length.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.record_overflow\n }\n });\n }\n\n if(c.serverCertificate === null) {\n // no server certificate was provided\n var error = {\n message: 'No server certificate provided. Not enough security.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.insufficient_security\n }\n };\n\n // call application callback\n var depth = 0;\n var ret = c.verify(c, error.alert.description, depth, []);\n if(ret !== true) {\n // check for custom alert info\n if(ret || ret === 0) {\n // set custom message and alert description\n if(typeof ret === 'object' && !forge.util.isArray(ret)) {\n if(ret.message) {\n error.message = ret.message;\n }\n if(ret.alert) {\n error.alert.description = ret.alert;\n }\n } else if(typeof ret === 'number') {\n // set custom alert description\n error.alert.description = ret;\n }\n }\n\n // send error\n return c.error(c, error);\n }\n }\n\n // create client certificate message if requested\n if(c.session.certificateRequest !== null) {\n record = tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createCertificate(c)\n });\n tls.queue(c, record);\n }\n\n // create client key exchange message\n record = tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createClientKeyExchange(c)\n });\n tls.queue(c, record);\n\n // expect no messages until the following callback has been called\n c.expect = SER;\n\n // create callback to handle client signature (for client-certs)\n var callback = function(c, signature) {\n if(c.session.certificateRequest !== null &&\n c.session.clientCertificate !== null) {\n // create certificate verify message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createCertificateVerify(c, signature)\n }));\n }\n\n // create change cipher spec message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.change_cipher_spec,\n data: tls.createChangeCipherSpec()\n }));\n\n // create pending state\n c.state.pending = tls.createConnectionState(c);\n\n // change current write state to pending write state\n c.state.current.write = c.state.pending.write;\n\n // create finished message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createFinished(c)\n }));\n\n // expect a server ChangeCipherSpec message next\n c.expect = SCC;\n\n // send records\n tls.flush(c);\n\n // continue\n c.process();\n };\n\n // if there is no certificate request or no client certificate, do\n // callback immediately\n if(c.session.certificateRequest === null ||\n c.session.clientCertificate === null) {\n return callback(c, null);\n }\n\n // otherwise get the client signature\n tls.getClientSignature(c, callback);\n};\n\n/**\n * Called when a ChangeCipherSpec record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleChangeCipherSpec = function(c, record) {\n if(record.fragment.getByte() !== 0x01) {\n return c.error(c, {\n message: 'Invalid ChangeCipherSpec message received.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n }\n\n // create pending state if:\n // 1. Resuming session in client mode OR\n // 2. NOT resuming session in server mode\n var client = (c.entity === tls.ConnectionEnd.client);\n if((c.session.resuming && client) || (!c.session.resuming && !client)) {\n c.state.pending = tls.createConnectionState(c);\n }\n\n // change current read state to pending read state\n c.state.current.read = c.state.pending.read;\n\n // clear pending state if:\n // 1. NOT resuming session in client mode OR\n // 2. resuming a session in server mode\n if((!c.session.resuming && client) || (c.session.resuming && !client)) {\n c.state.pending = null;\n }\n\n // expect a Finished record next\n c.expect = client ? SFI : CFI;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a Finished record is received.\n *\n * When this message will be sent:\n * A finished message is always sent immediately after a change\n * cipher spec message to verify that the key exchange and\n * authentication processes were successful. It is essential that a\n * change cipher spec message be received between the other\n * handshake messages and the Finished message.\n *\n * Meaning of this message:\n * The finished message is the first protected with the just-\n * negotiated algorithms, keys, and secrets. Recipients of finished\n * messages must verify that the contents are correct. Once a side\n * has sent its Finished message and received and validated the\n * Finished message from its peer, it may begin to send and receive\n * application data over the connection.\n *\n * struct {\n * opaque verify_data[verify_data_length];\n * } Finished;\n *\n * verify_data\n * PRF(master_secret, finished_label, Hash(handshake_messages))\n * [0..verify_data_length-1];\n *\n * finished_label\n * For Finished messages sent by the client, the string\n * \"client finished\". For Finished messages sent by the server, the\n * string \"server finished\".\n *\n * verify_data_length depends on the cipher suite. If it is not specified\n * by the cipher suite, then it is 12. Versions of TLS < 1.2 always used\n * 12 bytes.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleFinished = function(c, record, length) {\n // rewind to get full bytes for message so it can be manually\n // digested below (special case for Finished messages because they\n // must be digested *after* handling as opposed to all others)\n var b = record.fragment;\n b.read -= 4;\n var msgBytes = b.bytes();\n b.read += 4;\n\n // message contains only verify_data\n var vd = record.fragment.getBytes();\n\n // ensure verify data is correct\n b = forge.util.createBuffer();\n b.putBuffer(c.session.md5.digest());\n b.putBuffer(c.session.sha1.digest());\n\n // set label based on entity type\n var client = (c.entity === tls.ConnectionEnd.client);\n var label = client ? 'server finished' : 'client finished';\n\n // TODO: determine prf function and verify length for TLS 1.2\n var sp = c.session.sp;\n var vdl = 12;\n var prf = prf_TLS1;\n b = prf(sp.master_secret, label, b.getBytes(), vdl);\n if(b.getBytes() !== vd) {\n return c.error(c, {\n message: 'Invalid verify_data in Finished message.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.decrypt_error\n }\n });\n }\n\n // digest finished message now that it has been handled\n c.session.md5.update(msgBytes);\n c.session.sha1.update(msgBytes);\n\n // resuming session as client or NOT resuming session as server\n if((c.session.resuming && client) || (!c.session.resuming && !client)) {\n // create change cipher spec message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.change_cipher_spec,\n data: tls.createChangeCipherSpec()\n }));\n\n // change current write state to pending write state, clear pending\n c.state.current.write = c.state.pending.write;\n c.state.pending = null;\n\n // create finished message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createFinished(c)\n }));\n }\n\n // expect application data next\n c.expect = client ? SAD : CAD;\n\n // handshake complete\n c.handshaking = false;\n ++c.handshakes;\n\n // save access to peer certificate\n c.peerCertificate = client ?\n c.session.serverCertificate : c.session.clientCertificate;\n\n // send records\n tls.flush(c);\n\n // now connected\n c.isConnected = true;\n c.connected(c);\n\n // continue\n c.process();\n};\n\n/**\n * Called when an Alert record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleAlert = function(c, record) {\n // read alert\n var b = record.fragment;\n var alert = {\n level: b.getByte(),\n description: b.getByte()\n };\n\n // TODO: consider using a table?\n // get appropriate message\n var msg;\n switch(alert.description) {\n case tls.Alert.Description.close_notify:\n msg = 'Connection closed.';\n break;\n case tls.Alert.Description.unexpected_message:\n msg = 'Unexpected message.';\n break;\n case tls.Alert.Description.bad_record_mac:\n msg = 'Bad record MAC.';\n break;\n case tls.Alert.Description.decryption_failed:\n msg = 'Decryption failed.';\n break;\n case tls.Alert.Description.record_overflow:\n msg = 'Record overflow.';\n break;\n case tls.Alert.Description.decompression_failure:\n msg = 'Decompression failed.';\n break;\n case tls.Alert.Description.handshake_failure:\n msg = 'Handshake failure.';\n break;\n case tls.Alert.Description.bad_certificate:\n msg = 'Bad certificate.';\n break;\n case tls.Alert.Description.unsupported_certificate:\n msg = 'Unsupported certificate.';\n break;\n case tls.Alert.Description.certificate_revoked:\n msg = 'Certificate revoked.';\n break;\n case tls.Alert.Description.certificate_expired:\n msg = 'Certificate expired.';\n break;\n case tls.Alert.Description.certificate_unknown:\n msg = 'Certificate unknown.';\n break;\n case tls.Alert.Description.illegal_parameter:\n msg = 'Illegal parameter.';\n break;\n case tls.Alert.Description.unknown_ca:\n msg = 'Unknown certificate authority.';\n break;\n case tls.Alert.Description.access_denied:\n msg = 'Access denied.';\n break;\n case tls.Alert.Description.decode_error:\n msg = 'Decode error.';\n break;\n case tls.Alert.Description.decrypt_error:\n msg = 'Decrypt error.';\n break;\n case tls.Alert.Description.export_restriction:\n msg = 'Export restriction.';\n break;\n case tls.Alert.Description.protocol_version:\n msg = 'Unsupported protocol version.';\n break;\n case tls.Alert.Description.insufficient_security:\n msg = 'Insufficient security.';\n break;\n case tls.Alert.Description.internal_error:\n msg = 'Internal error.';\n break;\n case tls.Alert.Description.user_canceled:\n msg = 'User canceled.';\n break;\n case tls.Alert.Description.no_renegotiation:\n msg = 'Renegotiation not supported.';\n break;\n default:\n msg = 'Unknown error.';\n break;\n }\n\n // close connection on close_notify, not an error\n if(alert.description === tls.Alert.Description.close_notify) {\n return c.close();\n }\n\n // call error handler\n c.error(c, {\n message: msg,\n send: false,\n // origin is the opposite end\n origin: (c.entity === tls.ConnectionEnd.client) ? 'server' : 'client',\n alert: alert\n });\n\n // continue\n c.process();\n};\n\n/**\n * Called when a Handshake record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleHandshake = function(c, record) {\n // get the handshake type and message length\n var b = record.fragment;\n var type = b.getByte();\n var length = b.getInt24();\n\n // see if the record fragment doesn't yet contain the full message\n if(length > b.length()) {\n // cache the record, clear its fragment, and reset the buffer read\n // pointer before the type and length were read\n c.fragmented = record;\n record.fragment = forge.util.createBuffer();\n b.read -= 4;\n\n // continue\n return c.process();\n }\n\n // full message now available, clear cache, reset read pointer to\n // before type and length\n c.fragmented = null;\n b.read -= 4;\n\n // save the handshake bytes for digestion after handler is found\n // (include type and length of handshake msg)\n var bytes = b.bytes(length + 4);\n\n // restore read pointer\n b.read += 4;\n\n // handle expected message\n if(type in hsTable[c.entity][c.expect]) {\n // initialize server session\n if(c.entity === tls.ConnectionEnd.server && !c.open && !c.fail) {\n c.handshaking = true;\n c.session = {\n version: null,\n extensions: {\n server_name: {\n serverNameList: []\n }\n },\n cipherSuite: null,\n compressionMethod: null,\n serverCertificate: null,\n clientCertificate: null,\n md5: forge.md.md5.create(),\n sha1: forge.md.sha1.create()\n };\n }\n\n /* Update handshake messages digest. Finished and CertificateVerify\n messages are not digested here. They can't be digested as part of\n the verify_data that they contain. These messages are manually\n digested in their handlers. HelloRequest messages are simply never\n included in the handshake message digest according to spec. */\n if(type !== tls.HandshakeType.hello_request &&\n type !== tls.HandshakeType.certificate_verify &&\n type !== tls.HandshakeType.finished) {\n c.session.md5.update(bytes);\n c.session.sha1.update(bytes);\n }\n\n // handle specific handshake type record\n hsTable[c.entity][c.expect][type](c, record, length);\n } else {\n // unexpected record\n tls.handleUnexpected(c, record);\n }\n};\n\n/**\n * Called when an ApplicationData record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleApplicationData = function(c, record) {\n // buffer data, notify that its ready\n c.data.putBuffer(record.fragment);\n c.dataReady(c);\n\n // continue\n c.process();\n};\n\n/**\n * Called when a Heartbeat record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleHeartbeat = function(c, record) {\n // get the heartbeat type and payload\n var b = record.fragment;\n var type = b.getByte();\n var length = b.getInt16();\n var payload = b.getBytes(length);\n\n if(type === tls.HeartbeatMessageType.heartbeat_request) {\n // discard request during handshake or if length is too large\n if(c.handshaking || length > payload.length) {\n // continue\n return c.process();\n }\n // retransmit payload\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.heartbeat,\n data: tls.createHeartbeat(\n tls.HeartbeatMessageType.heartbeat_response, payload)\n }));\n tls.flush(c);\n } else if(type === tls.HeartbeatMessageType.heartbeat_response) {\n // check payload against expected payload, discard heartbeat if no match\n if(payload !== c.expectedHeartbeatPayload) {\n // continue\n return c.process();\n }\n\n // notify that a valid heartbeat was received\n if(c.heartbeatReceived) {\n c.heartbeatReceived(c, forge.util.createBuffer(payload));\n }\n }\n\n // continue\n c.process();\n};\n\n/**\n * The transistional state tables for receiving TLS records. It maps the\n * current TLS engine state and a received record to a function to handle the\n * record and update the state.\n *\n * For instance, if the current state is SHE, then the TLS engine is expecting\n * a ServerHello record. Once a record is received, the handler function is\n * looked up using the state SHE and the record's content type.\n *\n * The resulting function will either be an error handler or a record handler.\n * The function will take whatever action is appropriate and update the state\n * for the next record.\n *\n * The states are all based on possible server record types. Note that the\n * client will never specifically expect to receive a HelloRequest or an alert\n * from the server so there is no state that reflects this. These messages may\n * occur at any time.\n *\n * There are two tables for mapping states because there is a second tier of\n * types for handshake messages. Once a record with a content type of handshake\n * is received, the handshake record handler will look up the handshake type in\n * the secondary map to get its appropriate handler.\n *\n * Valid message orders are as follows:\n *\n * =======================FULL HANDSHAKE======================\n * Client Server\n *\n * ClientHello -------->\n * ServerHello\n * Certificate*\n * ServerKeyExchange*\n * CertificateRequest*\n * <-------- ServerHelloDone\n * Certificate*\n * ClientKeyExchange\n * CertificateVerify*\n * [ChangeCipherSpec]\n * Finished -------->\n * [ChangeCipherSpec]\n * <-------- Finished\n * Application Data <-------> Application Data\n *\n * =====================SESSION RESUMPTION=====================\n * Client Server\n *\n * ClientHello -------->\n * ServerHello\n * [ChangeCipherSpec]\n * <-------- Finished\n * [ChangeCipherSpec]\n * Finished -------->\n * Application Data <-------> Application Data\n */\n// client expect states (indicate which records are expected to be received)\nvar SHE = 0; // rcv server hello\nvar SCE = 1; // rcv server certificate\nvar SKE = 2; // rcv server key exchange\nvar SCR = 3; // rcv certificate request\nvar SHD = 4; // rcv server hello done\nvar SCC = 5; // rcv change cipher spec\nvar SFI = 6; // rcv finished\nvar SAD = 7; // rcv application data\nvar SER = 8; // not expecting any messages at this point\n\n// server expect states\nvar CHE = 0; // rcv client hello\nvar CCE = 1; // rcv client certificate\nvar CKE = 2; // rcv client key exchange\nvar CCV = 3; // rcv certificate verify\nvar CCC = 4; // rcv change cipher spec\nvar CFI = 5; // rcv finished\nvar CAD = 6; // rcv application data\nvar CER = 7; // not expecting any messages at this point\n\n// map client current expect state and content type to function\nvar __ = tls.handleUnexpected;\nvar R0 = tls.handleChangeCipherSpec;\nvar R1 = tls.handleAlert;\nvar R2 = tls.handleHandshake;\nvar R3 = tls.handleApplicationData;\nvar R4 = tls.handleHeartbeat;\nvar ctTable = [];\nctTable[tls.ConnectionEnd.client] = [\n// CC,AL,HS,AD,HB\n/*SHE*/[__,R1,R2,__,R4],\n/*SCE*/[__,R1,R2,__,R4],\n/*SKE*/[__,R1,R2,__,R4],\n/*SCR*/[__,R1,R2,__,R4],\n/*SHD*/[__,R1,R2,__,R4],\n/*SCC*/[R0,R1,__,__,R4],\n/*SFI*/[__,R1,R2,__,R4],\n/*SAD*/[__,R1,R2,R3,R4],\n/*SER*/[__,R1,R2,__,R4]\n];\n\n// map server current expect state and content type to function\nctTable[tls.ConnectionEnd.server] = [\n// CC,AL,HS,AD\n/*CHE*/[__,R1,R2,__,R4],\n/*CCE*/[__,R1,R2,__,R4],\n/*CKE*/[__,R1,R2,__,R4],\n/*CCV*/[__,R1,R2,__,R4],\n/*CCC*/[R0,R1,__,__,R4],\n/*CFI*/[__,R1,R2,__,R4],\n/*CAD*/[__,R1,R2,R3,R4],\n/*CER*/[__,R1,R2,__,R4]\n];\n\n// map client current expect state and handshake type to function\nvar H0 = tls.handleHelloRequest;\nvar H1 = tls.handleServerHello;\nvar H2 = tls.handleCertificate;\nvar H3 = tls.handleServerKeyExchange;\nvar H4 = tls.handleCertificateRequest;\nvar H5 = tls.handleServerHelloDone;\nvar H6 = tls.handleFinished;\nvar hsTable = [];\nhsTable[tls.ConnectionEnd.client] = [\n// HR,01,SH,03,04,05,06,07,08,09,10,SC,SK,CR,HD,15,CK,17,18,19,FI\n/*SHE*/[__,__,H1,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*SCE*/[H0,__,__,__,__,__,__,__,__,__,__,H2,H3,H4,H5,__,__,__,__,__,__],\n/*SKE*/[H0,__,__,__,__,__,__,__,__,__,__,__,H3,H4,H5,__,__,__,__,__,__],\n/*SCR*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,H4,H5,__,__,__,__,__,__],\n/*SHD*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,H5,__,__,__,__,__,__],\n/*SCC*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*SFI*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H6],\n/*SAD*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*SER*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__]\n];\n\n// map server current expect state and handshake type to function\n// Note: CAD[CH] does not map to FB because renegotation is prohibited\nvar H7 = tls.handleClientHello;\nvar H8 = tls.handleClientKeyExchange;\nvar H9 = tls.handleCertificateVerify;\nhsTable[tls.ConnectionEnd.server] = [\n// 01,CH,02,03,04,05,06,07,08,09,10,CC,12,13,14,CV,CK,17,18,19,FI\n/*CHE*/[__,H7,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*CCE*/[__,__,__,__,__,__,__,__,__,__,__,H2,__,__,__,__,__,__,__,__,__],\n/*CKE*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H8,__,__,__,__],\n/*CCV*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H9,__,__,__,__,__],\n/*CCC*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*CFI*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H6],\n/*CAD*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*CER*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__]\n];\n\n/**\n * Generates the master_secret and keys using the given security parameters.\n *\n * The security parameters for a TLS connection state are defined as such:\n *\n * struct {\n * ConnectionEnd entity;\n * PRFAlgorithm prf_algorithm;\n * BulkCipherAlgorithm bulk_cipher_algorithm;\n * CipherType cipher_type;\n * uint8 enc_key_length;\n * uint8 block_length;\n * uint8 fixed_iv_length;\n * uint8 record_iv_length;\n * MACAlgorithm mac_algorithm;\n * uint8 mac_length;\n * uint8 mac_key_length;\n * CompressionMethod compression_algorithm;\n * opaque master_secret[48];\n * opaque client_random[32];\n * opaque server_random[32];\n * } SecurityParameters;\n *\n * Note that this definition is from TLS 1.2. In TLS 1.0 some of these\n * parameters are ignored because, for instance, the PRFAlgorithm is a\n * builtin-fixed algorithm combining iterations of MD5 and SHA-1 in TLS 1.0.\n *\n * The Record Protocol requires an algorithm to generate keys required by the\n * current connection state.\n *\n * The master secret is expanded into a sequence of secure bytes, which is then\n * split to a client write MAC key, a server write MAC key, a client write\n * encryption key, and a server write encryption key. In TLS 1.0 a client write\n * IV and server write IV are also generated. Each of these is generated from\n * the byte sequence in that order. Unused values are empty. In TLS 1.2, some\n * AEAD ciphers may additionally require a client write IV and a server write\n * IV (see Section 6.2.3.3).\n *\n * When keys, MAC keys, and IVs are generated, the master secret is used as an\n * entropy source.\n *\n * To generate the key material, compute:\n *\n * master_secret = PRF(pre_master_secret, \"master secret\",\n * ClientHello.random + ServerHello.random)\n *\n * key_block = PRF(SecurityParameters.master_secret,\n * \"key expansion\",\n * SecurityParameters.server_random +\n * SecurityParameters.client_random);\n *\n * until enough output has been generated. Then, the key_block is\n * partitioned as follows:\n *\n * client_write_MAC_key[SecurityParameters.mac_key_length]\n * server_write_MAC_key[SecurityParameters.mac_key_length]\n * client_write_key[SecurityParameters.enc_key_length]\n * server_write_key[SecurityParameters.enc_key_length]\n * client_write_IV[SecurityParameters.fixed_iv_length]\n * server_write_IV[SecurityParameters.fixed_iv_length]\n *\n * In TLS 1.2, the client_write_IV and server_write_IV are only generated for\n * implicit nonce techniques as described in Section 3.2.1 of [AEAD]. This\n * implementation uses TLS 1.0 so IVs are generated.\n *\n * Implementation note: The currently defined cipher suite which requires the\n * most material is AES_256_CBC_SHA256. It requires 2 x 32 byte keys and 2 x 32\n * byte MAC keys, for a total 128 bytes of key material. In TLS 1.0 it also\n * requires 2 x 16 byte IVs, so it actually takes 160 bytes of key material.\n *\n * @param c the connection.\n * @param sp the security parameters to use.\n *\n * @return the security keys.\n */\ntls.generateKeys = function(c, sp) {\n // TLS_RSA_WITH_AES_128_CBC_SHA (required to be compliant with TLS 1.2) &\n // TLS_RSA_WITH_AES_256_CBC_SHA are the only cipher suites implemented\n // at present\n\n // TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA is required to be compliant with\n // TLS 1.0 but we don't care right now because AES is better and we have\n // an implementation for it\n\n // TODO: TLS 1.2 implementation\n /*\n // determine the PRF\n var prf;\n switch(sp.prf_algorithm) {\n case tls.PRFAlgorithm.tls_prf_sha256:\n prf = prf_sha256;\n break;\n default:\n // should never happen\n throw new Error('Invalid PRF');\n }\n */\n\n // TLS 1.0/1.1 implementation\n var prf = prf_TLS1;\n\n // concatenate server and client random\n var random = sp.client_random + sp.server_random;\n\n // only create master secret if session is new\n if(!c.session.resuming) {\n // create master secret, clean up pre-master secret\n sp.master_secret = prf(\n sp.pre_master_secret, 'master secret', random, 48).bytes();\n sp.pre_master_secret = null;\n }\n\n // generate the amount of key material needed\n random = sp.server_random + sp.client_random;\n var length = 2 * sp.mac_key_length + 2 * sp.enc_key_length;\n\n // include IV for TLS/1.0\n var tls10 = (c.version.major === tls.Versions.TLS_1_0.major &&\n c.version.minor === tls.Versions.TLS_1_0.minor);\n if(tls10) {\n length += 2 * sp.fixed_iv_length;\n }\n var km = prf(sp.master_secret, 'key expansion', random, length);\n\n // split the key material into the MAC and encryption keys\n var rval = {\n client_write_MAC_key: km.getBytes(sp.mac_key_length),\n server_write_MAC_key: km.getBytes(sp.mac_key_length),\n client_write_key: km.getBytes(sp.enc_key_length),\n server_write_key: km.getBytes(sp.enc_key_length)\n };\n\n // include TLS 1.0 IVs\n if(tls10) {\n rval.client_write_IV = km.getBytes(sp.fixed_iv_length);\n rval.server_write_IV = km.getBytes(sp.fixed_iv_length);\n }\n\n return rval;\n};\n\n/**\n * Creates a new initialized TLS connection state. A connection state has\n * a read mode and a write mode.\n *\n * compression state:\n * The current state of the compression algorithm.\n *\n * cipher state:\n * The current state of the encryption algorithm. This will consist of the\n * scheduled key for that connection. For stream ciphers, this will also\n * contain whatever state information is necessary to allow the stream to\n * continue to encrypt or decrypt data.\n *\n * MAC key:\n * The MAC key for the connection.\n *\n * sequence number:\n * Each connection state contains a sequence number, which is maintained\n * separately for read and write states. The sequence number MUST be set to\n * zero whenever a connection state is made the active state. Sequence\n * numbers are of type uint64 and may not exceed 2^64-1. Sequence numbers do\n * not wrap. If a TLS implementation would need to wrap a sequence number,\n * it must renegotiate instead. A sequence number is incremented after each\n * record: specifically, the first record transmitted under a particular\n * connection state MUST use sequence number 0.\n *\n * @param c the connection.\n *\n * @return the new initialized TLS connection state.\n */\ntls.createConnectionState = function(c) {\n var client = (c.entity === tls.ConnectionEnd.client);\n\n var createMode = function() {\n var mode = {\n // two 32-bit numbers, first is most significant\n sequenceNumber: [0, 0],\n macKey: null,\n macLength: 0,\n macFunction: null,\n cipherState: null,\n cipherFunction: function(record) {return true;},\n compressionState: null,\n compressFunction: function(record) {return true;},\n updateSequenceNumber: function() {\n if(mode.sequenceNumber[1] === 0xFFFFFFFF) {\n mode.sequenceNumber[1] = 0;\n ++mode.sequenceNumber[0];\n } else {\n ++mode.sequenceNumber[1];\n }\n }\n };\n return mode;\n };\n var state = {\n read: createMode(),\n write: createMode()\n };\n\n // update function in read mode will decrypt then decompress a record\n state.read.update = function(c, record) {\n if(!state.read.cipherFunction(record, state.read)) {\n c.error(c, {\n message: 'Could not decrypt record or bad MAC.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n // doesn't matter if decryption failed or MAC was\n // invalid, return the same error so as not to reveal\n // which one occurred\n description: tls.Alert.Description.bad_record_mac\n }\n });\n } else if(!state.read.compressFunction(c, record, state.read)) {\n c.error(c, {\n message: 'Could not decompress record.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.decompression_failure\n }\n });\n }\n return !c.fail;\n };\n\n // update function in write mode will compress then encrypt a record\n state.write.update = function(c, record) {\n if(!state.write.compressFunction(c, record, state.write)) {\n // error, but do not send alert since it would require\n // compression as well\n c.error(c, {\n message: 'Could not compress record.',\n send: false,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n } else if(!state.write.cipherFunction(record, state.write)) {\n // error, but do not send alert since it would require\n // encryption as well\n c.error(c, {\n message: 'Could not encrypt record.',\n send: false,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n }\n return !c.fail;\n };\n\n // handle security parameters\n if(c.session) {\n var sp = c.session.sp;\n c.session.cipherSuite.initSecurityParameters(sp);\n\n // generate keys\n sp.keys = tls.generateKeys(c, sp);\n state.read.macKey = client ?\n sp.keys.server_write_MAC_key : sp.keys.client_write_MAC_key;\n state.write.macKey = client ?\n sp.keys.client_write_MAC_key : sp.keys.server_write_MAC_key;\n\n // cipher suite setup\n c.session.cipherSuite.initConnectionState(state, c, sp);\n\n // compression setup\n switch(sp.compression_algorithm) {\n case tls.CompressionMethod.none:\n break;\n case tls.CompressionMethod.deflate:\n state.read.compressFunction = inflate;\n state.write.compressFunction = deflate;\n break;\n default:\n throw new Error('Unsupported compression algorithm.');\n }\n }\n\n return state;\n};\n\n/**\n * Creates a Random structure.\n *\n * struct {\n * uint32 gmt_unix_time;\n * opaque random_bytes[28];\n * } Random;\n *\n * gmt_unix_time:\n * The current time and date in standard UNIX 32-bit format (seconds since\n * the midnight starting Jan 1, 1970, UTC, ignoring leap seconds) according\n * to the sender's internal clock. Clocks are not required to be set\n * correctly by the basic TLS protocol; higher-level or application\n * protocols may define additional requirements. Note that, for historical\n * reasons, the data element is named using GMT, the predecessor of the\n * current worldwide time base, UTC.\n * random_bytes:\n * 28 bytes generated by a secure random number generator.\n *\n * @return the Random structure as a byte array.\n */\ntls.createRandom = function() {\n // get UTC milliseconds\n var d = new Date();\n var utc = +d + d.getTimezoneOffset() * 60000;\n var rval = forge.util.createBuffer();\n rval.putInt32(utc);\n rval.putBytes(forge.random.getBytes(28));\n return rval;\n};\n\n/**\n * Creates a TLS record with the given type and data.\n *\n * @param c the connection.\n * @param options:\n * type: the record type.\n * data: the plain text data in a byte buffer.\n *\n * @return the created record.\n */\ntls.createRecord = function(c, options) {\n if(!options.data) {\n return null;\n }\n var record = {\n type: options.type,\n version: {\n major: c.version.major,\n minor: c.version.minor\n },\n length: options.data.length(),\n fragment: options.data\n };\n return record;\n};\n\n/**\n * Creates a TLS alert record.\n *\n * @param c the connection.\n * @param alert:\n * level: the TLS alert level.\n * description: the TLS alert description.\n *\n * @return the created alert record.\n */\ntls.createAlert = function(c, alert) {\n var b = forge.util.createBuffer();\n b.putByte(alert.level);\n b.putByte(alert.description);\n return tls.createRecord(c, {\n type: tls.ContentType.alert,\n data: b\n });\n};\n\n/* The structure of a TLS handshake message.\n *\n * struct {\n * HandshakeType msg_type; // handshake type\n * uint24 length; // bytes in message\n * select(HandshakeType) {\n * case hello_request: HelloRequest;\n * case client_hello: ClientHello;\n * case server_hello: ServerHello;\n * case certificate: Certificate;\n * case server_key_exchange: ServerKeyExchange;\n * case certificate_request: CertificateRequest;\n * case server_hello_done: ServerHelloDone;\n * case certificate_verify: CertificateVerify;\n * case client_key_exchange: ClientKeyExchange;\n * case finished: Finished;\n * } body;\n * } Handshake;\n */\n\n/**\n * Creates a ClientHello message.\n *\n * opaque SessionID<0..32>;\n * enum { null(0), deflate(1), (255) } CompressionMethod;\n * uint8 CipherSuite[2];\n *\n * struct {\n * ProtocolVersion client_version;\n * Random random;\n * SessionID session_id;\n * CipherSuite cipher_suites<2..2^16-2>;\n * CompressionMethod compression_methods<1..2^8-1>;\n * select(extensions_present) {\n * case false:\n * struct {};\n * case true:\n * Extension extensions<0..2^16-1>;\n * };\n * } ClientHello;\n *\n * The extension format for extended client hellos and server hellos is:\n *\n * struct {\n * ExtensionType extension_type;\n * opaque extension_data<0..2^16-1>;\n * } Extension;\n *\n * Here:\n *\n * - \"extension_type\" identifies the particular extension type.\n * - \"extension_data\" contains information specific to the particular\n * extension type.\n *\n * The extension types defined in this document are:\n *\n * enum {\n * server_name(0), max_fragment_length(1),\n * client_certificate_url(2), trusted_ca_keys(3),\n * truncated_hmac(4), status_request(5), (65535)\n * } ExtensionType;\n *\n * @param c the connection.\n *\n * @return the ClientHello byte buffer.\n */\ntls.createClientHello = function(c) {\n // save hello version\n c.session.clientHelloVersion = {\n major: c.version.major,\n minor: c.version.minor\n };\n\n // create supported cipher suites\n var cipherSuites = forge.util.createBuffer();\n for(var i = 0; i < c.cipherSuites.length; ++i) {\n var cs = c.cipherSuites[i];\n cipherSuites.putByte(cs.id[0]);\n cipherSuites.putByte(cs.id[1]);\n }\n var cSuites = cipherSuites.length();\n\n // create supported compression methods, null always supported, but\n // also support deflate if connection has inflate and deflate methods\n var compressionMethods = forge.util.createBuffer();\n compressionMethods.putByte(tls.CompressionMethod.none);\n // FIXME: deflate support disabled until issues with raw deflate data\n // without zlib headers are resolved\n /*\n if(c.inflate !== null && c.deflate !== null) {\n compressionMethods.putByte(tls.CompressionMethod.deflate);\n }\n */\n var cMethods = compressionMethods.length();\n\n // create TLS SNI (server name indication) extension if virtual host\n // has been specified, see RFC 3546\n var extensions = forge.util.createBuffer();\n if(c.virtualHost) {\n // create extension struct\n var ext = forge.util.createBuffer();\n ext.putByte(0x00); // type server_name (ExtensionType is 2 bytes)\n ext.putByte(0x00);\n\n /* In order to provide the server name, clients MAY include an\n * extension of type \"server_name\" in the (extended) client hello.\n * The \"extension_data\" field of this extension SHALL contain\n * \"ServerNameList\" where:\n *\n * struct {\n * NameType name_type;\n * select(name_type) {\n * case host_name: HostName;\n * } name;\n * } ServerName;\n *\n * enum {\n * host_name(0), (255)\n * } NameType;\n *\n * opaque HostName<1..2^16-1>;\n *\n * struct {\n * ServerName server_name_list<1..2^16-1>\n * } ServerNameList;\n */\n var serverName = forge.util.createBuffer();\n serverName.putByte(0x00); // type host_name\n writeVector(serverName, 2, forge.util.createBuffer(c.virtualHost));\n\n // ServerNameList is in extension_data\n var snList = forge.util.createBuffer();\n writeVector(snList, 2, serverName);\n writeVector(ext, 2, snList);\n extensions.putBuffer(ext);\n }\n var extLength = extensions.length();\n if(extLength > 0) {\n // add extension vector length\n extLength += 2;\n }\n\n // determine length of the handshake message\n // cipher suites and compression methods size will need to be\n // updated if more get added to the list\n var sessionId = c.session.id;\n var length =\n sessionId.length + 1 + // session ID vector\n 2 + // version (major + minor)\n 4 + 28 + // random time and random bytes\n 2 + cSuites + // cipher suites vector\n 1 + cMethods + // compression methods vector\n extLength; // extensions vector\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.client_hello);\n rval.putInt24(length); // handshake length\n rval.putByte(c.version.major); // major version\n rval.putByte(c.version.minor); // minor version\n rval.putBytes(c.session.sp.client_random); // random time + bytes\n writeVector(rval, 1, forge.util.createBuffer(sessionId));\n writeVector(rval, 2, cipherSuites);\n writeVector(rval, 1, compressionMethods);\n if(extLength > 0) {\n writeVector(rval, 2, extensions);\n }\n return rval;\n};\n\n/**\n * Creates a ServerHello message.\n *\n * @param c the connection.\n *\n * @return the ServerHello byte buffer.\n */\ntls.createServerHello = function(c) {\n // determine length of the handshake message\n var sessionId = c.session.id;\n var length =\n sessionId.length + 1 + // session ID vector\n 2 + // version (major + minor)\n 4 + 28 + // random time and random bytes\n 2 + // chosen cipher suite\n 1; // chosen compression method\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.server_hello);\n rval.putInt24(length); // handshake length\n rval.putByte(c.version.major); // major version\n rval.putByte(c.version.minor); // minor version\n rval.putBytes(c.session.sp.server_random); // random time + bytes\n writeVector(rval, 1, forge.util.createBuffer(sessionId));\n rval.putByte(c.session.cipherSuite.id[0]);\n rval.putByte(c.session.cipherSuite.id[1]);\n rval.putByte(c.session.compressionMethod);\n return rval;\n};\n\n/**\n * Creates a Certificate message.\n *\n * When this message will be sent:\n * This is the first message the client can send after receiving a server\n * hello done message and the first message the server can send after\n * sending a ServerHello. This client message is only sent if the server\n * requests a certificate. If no suitable certificate is available, the\n * client should send a certificate message containing no certificates. If\n * client authentication is required by the server for the handshake to\n * continue, it may respond with a fatal handshake failure alert.\n *\n * opaque ASN.1Cert<1..2^24-1>;\n *\n * struct {\n * ASN.1Cert certificate_list<0..2^24-1>;\n * } Certificate;\n *\n * @param c the connection.\n *\n * @return the Certificate byte buffer.\n */\ntls.createCertificate = function(c) {\n // TODO: check certificate request to ensure types are supported\n\n // get a certificate (a certificate as a PEM string)\n var client = (c.entity === tls.ConnectionEnd.client);\n var cert = null;\n if(c.getCertificate) {\n var hint;\n if(client) {\n hint = c.session.certificateRequest;\n } else {\n hint = c.session.extensions.server_name.serverNameList;\n }\n cert = c.getCertificate(c, hint);\n }\n\n // buffer to hold certificate list\n var certList = forge.util.createBuffer();\n if(cert !== null) {\n try {\n // normalize cert to a chain of certificates\n if(!forge.util.isArray(cert)) {\n cert = [cert];\n }\n var asn1 = null;\n for(var i = 0; i < cert.length; ++i) {\n var msg = forge.pem.decode(cert[i])[0];\n if(msg.type !== 'CERTIFICATE' &&\n msg.type !== 'X509 CERTIFICATE' &&\n msg.type !== 'TRUSTED CERTIFICATE') {\n var error = new Error('Could not convert certificate from PEM; PEM ' +\n 'header type is not \"CERTIFICATE\", \"X509 CERTIFICATE\", or ' +\n '\"TRUSTED CERTIFICATE\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert certificate from PEM; PEM is encrypted.');\n }\n\n var der = forge.util.createBuffer(msg.body);\n if(asn1 === null) {\n asn1 = forge.asn1.fromDer(der.bytes(), false);\n }\n\n // certificate entry is itself a vector with 3 length bytes\n var certBuffer = forge.util.createBuffer();\n writeVector(certBuffer, 3, der);\n\n // add cert vector to cert list vector\n certList.putBuffer(certBuffer);\n }\n\n // save certificate\n cert = forge.pki.certificateFromAsn1(asn1);\n if(client) {\n c.session.clientCertificate = cert;\n } else {\n c.session.serverCertificate = cert;\n }\n } catch(ex) {\n return c.error(c, {\n message: 'Could not send certificate list.',\n cause: ex,\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.bad_certificate\n }\n });\n }\n }\n\n // determine length of the handshake message\n var length = 3 + certList.length(); // cert list vector\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.certificate);\n rval.putInt24(length);\n writeVector(rval, 3, certList);\n return rval;\n};\n\n/**\n * Creates a ClientKeyExchange message.\n *\n * When this message will be sent:\n * This message is always sent by the client. It will immediately follow the\n * client certificate message, if it is sent. Otherwise it will be the first\n * message sent by the client after it receives the server hello done\n * message.\n *\n * Meaning of this message:\n * With this message, the premaster secret is set, either though direct\n * transmission of the RSA-encrypted secret, or by the transmission of\n * Diffie-Hellman parameters which will allow each side to agree upon the\n * same premaster secret. When the key exchange method is DH_RSA or DH_DSS,\n * client certification has been requested, and the client was able to\n * respond with a certificate which contained a Diffie-Hellman public key\n * whose parameters (group and generator) matched those specified by the\n * server in its certificate, this message will not contain any data.\n *\n * Meaning of this message:\n * If RSA is being used for key agreement and authentication, the client\n * generates a 48-byte premaster secret, encrypts it using the public key\n * from the server's certificate or the temporary RSA key provided in a\n * server key exchange message, and sends the result in an encrypted\n * premaster secret message. This structure is a variant of the client\n * key exchange message, not a message in itself.\n *\n * struct {\n * select(KeyExchangeAlgorithm) {\n * case rsa: EncryptedPreMasterSecret;\n * case diffie_hellman: ClientDiffieHellmanPublic;\n * } exchange_keys;\n * } ClientKeyExchange;\n *\n * struct {\n * ProtocolVersion client_version;\n * opaque random[46];\n * } PreMasterSecret;\n *\n * struct {\n * public-key-encrypted PreMasterSecret pre_master_secret;\n * } EncryptedPreMasterSecret;\n *\n * A public-key-encrypted element is encoded as a vector <0..2^16-1>.\n *\n * @param c the connection.\n *\n * @return the ClientKeyExchange byte buffer.\n */\ntls.createClientKeyExchange = function(c) {\n // create buffer to encrypt\n var b = forge.util.createBuffer();\n\n // add highest client-supported protocol to help server avoid version\n // rollback attacks\n b.putByte(c.session.clientHelloVersion.major);\n b.putByte(c.session.clientHelloVersion.minor);\n\n // generate and add 46 random bytes\n b.putBytes(forge.random.getBytes(46));\n\n // save pre-master secret\n var sp = c.session.sp;\n sp.pre_master_secret = b.getBytes();\n\n // RSA-encrypt the pre-master secret\n var key = c.session.serverCertificate.publicKey;\n b = key.encrypt(sp.pre_master_secret);\n\n /* Note: The encrypted pre-master secret will be stored in a\n public-key-encrypted opaque vector that has the length prefixed using\n 2 bytes, so include those 2 bytes in the handshake message length. This\n is done as a minor optimization instead of calling writeVector(). */\n\n // determine length of the handshake message\n var length = b.length + 2;\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.client_key_exchange);\n rval.putInt24(length);\n // add vector length bytes\n rval.putInt16(b.length);\n rval.putBytes(b);\n return rval;\n};\n\n/**\n * Creates a ServerKeyExchange message.\n *\n * @param c the connection.\n *\n * @return the ServerKeyExchange byte buffer.\n */\ntls.createServerKeyExchange = function(c) {\n // this implementation only supports RSA, no Diffie-Hellman support,\n // so this record is empty\n\n // determine length of the handshake message\n var length = 0;\n\n // build record fragment\n var rval = forge.util.createBuffer();\n if(length > 0) {\n rval.putByte(tls.HandshakeType.server_key_exchange);\n rval.putInt24(length);\n }\n return rval;\n};\n\n/**\n * Gets the signed data used to verify a client-side certificate. See\n * tls.createCertificateVerify() for details.\n *\n * @param c the connection.\n * @param callback the callback to call once the signed data is ready.\n */\ntls.getClientSignature = function(c, callback) {\n // generate data to RSA encrypt\n var b = forge.util.createBuffer();\n b.putBuffer(c.session.md5.digest());\n b.putBuffer(c.session.sha1.digest());\n b = b.getBytes();\n\n // create default signing function as necessary\n c.getSignature = c.getSignature || function(c, b, callback) {\n // do rsa encryption, call callback\n var privateKey = null;\n if(c.getPrivateKey) {\n try {\n privateKey = c.getPrivateKey(c, c.session.clientCertificate);\n privateKey = forge.pki.privateKeyFromPem(privateKey);\n } catch(ex) {\n c.error(c, {\n message: 'Could not get private key.',\n cause: ex,\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n }\n }\n if(privateKey === null) {\n c.error(c, {\n message: 'No private key set.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n } else {\n b = privateKey.sign(b, null);\n }\n callback(c, b);\n };\n\n // get client signature\n c.getSignature(c, b, callback);\n};\n\n/**\n * Creates a CertificateVerify message.\n *\n * Meaning of this message:\n * This structure conveys the client's Diffie-Hellman public value\n * (Yc) if it was not already included in the client's certificate.\n * The encoding used for Yc is determined by the enumerated\n * PublicValueEncoding. This structure is a variant of the client\n * key exchange message, not a message in itself.\n *\n * When this message will be sent:\n * This message is used to provide explicit verification of a client\n * certificate. This message is only sent following a client\n * certificate that has signing capability (i.e. all certificates\n * except those containing fixed Diffie-Hellman parameters). When\n * sent, it will immediately follow the client key exchange message.\n *\n * struct {\n * Signature signature;\n * } CertificateVerify;\n *\n * CertificateVerify.signature.md5_hash\n * MD5(handshake_messages);\n *\n * Certificate.signature.sha_hash\n * SHA(handshake_messages);\n *\n * Here handshake_messages refers to all handshake messages sent or\n * received starting at client hello up to but not including this\n * message, including the type and length fields of the handshake\n * messages.\n *\n * select(SignatureAlgorithm) {\n * case anonymous: struct { };\n * case rsa:\n * digitally-signed struct {\n * opaque md5_hash[16];\n * opaque sha_hash[20];\n * };\n * case dsa:\n * digitally-signed struct {\n * opaque sha_hash[20];\n * };\n * } Signature;\n *\n * In digital signing, one-way hash functions are used as input for a\n * signing algorithm. A digitally-signed element is encoded as an opaque\n * vector <0..2^16-1>, where the length is specified by the signing\n * algorithm and key.\n *\n * In RSA signing, a 36-byte structure of two hashes (one SHA and one\n * MD5) is signed (encrypted with the private key). It is encoded with\n * PKCS #1 block type 0 or type 1 as described in [PKCS1].\n *\n * In DSS, the 20 bytes of the SHA hash are run directly through the\n * Digital Signing Algorithm with no additional hashing.\n *\n * @param c the connection.\n * @param signature the signature to include in the message.\n *\n * @return the CertificateVerify byte buffer.\n */\ntls.createCertificateVerify = function(c, signature) {\n /* Note: The signature will be stored in a \"digitally-signed\" opaque\n vector that has the length prefixed using 2 bytes, so include those\n 2 bytes in the handshake message length. This is done as a minor\n optimization instead of calling writeVector(). */\n\n // determine length of the handshake message\n var length = signature.length + 2;\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.certificate_verify);\n rval.putInt24(length);\n // add vector length bytes\n rval.putInt16(signature.length);\n rval.putBytes(signature);\n return rval;\n};\n\n/**\n * Creates a CertificateRequest message.\n *\n * @param c the connection.\n *\n * @return the CertificateRequest byte buffer.\n */\ntls.createCertificateRequest = function(c) {\n // TODO: support other certificate types\n var certTypes = forge.util.createBuffer();\n\n // common RSA certificate type\n certTypes.putByte(0x01);\n\n // add distinguished names from CA store\n var cAs = forge.util.createBuffer();\n for(var key in c.caStore.certs) {\n var cert = c.caStore.certs[key];\n var dn = forge.pki.distinguishedNameToAsn1(cert.subject);\n var byteBuffer = forge.asn1.toDer(dn);\n cAs.putInt16(byteBuffer.length());\n cAs.putBuffer(byteBuffer);\n }\n\n // TODO: TLS 1.2+ has a different format\n\n // determine length of the handshake message\n var length =\n 1 + certTypes.length() +\n 2 + cAs.length();\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.certificate_request);\n rval.putInt24(length);\n writeVector(rval, 1, certTypes);\n writeVector(rval, 2, cAs);\n return rval;\n};\n\n/**\n * Creates a ServerHelloDone message.\n *\n * @param c the connection.\n *\n * @return the ServerHelloDone byte buffer.\n */\ntls.createServerHelloDone = function(c) {\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.server_hello_done);\n rval.putInt24(0);\n return rval;\n};\n\n/**\n * Creates a ChangeCipherSpec message.\n *\n * The change cipher spec protocol exists to signal transitions in\n * ciphering strategies. The protocol consists of a single message,\n * which is encrypted and compressed under the current (not the pending)\n * connection state. The message consists of a single byte of value 1.\n *\n * struct {\n * enum { change_cipher_spec(1), (255) } type;\n * } ChangeCipherSpec;\n *\n * @return the ChangeCipherSpec byte buffer.\n */\ntls.createChangeCipherSpec = function() {\n var rval = forge.util.createBuffer();\n rval.putByte(0x01);\n return rval;\n};\n\n/**\n * Creates a Finished message.\n *\n * struct {\n * opaque verify_data[12];\n * } Finished;\n *\n * verify_data\n * PRF(master_secret, finished_label, MD5(handshake_messages) +\n * SHA-1(handshake_messages)) [0..11];\n *\n * finished_label\n * For Finished messages sent by the client, the string \"client\n * finished\". For Finished messages sent by the server, the\n * string \"server finished\".\n *\n * handshake_messages\n * All of the data from all handshake messages up to but not\n * including this message. This is only data visible at the\n * handshake layer and does not include record layer headers.\n * This is the concatenation of all the Handshake structures as\n * defined in 7.4 exchanged thus far.\n *\n * @param c the connection.\n *\n * @return the Finished byte buffer.\n */\ntls.createFinished = function(c) {\n // generate verify_data\n var b = forge.util.createBuffer();\n b.putBuffer(c.session.md5.digest());\n b.putBuffer(c.session.sha1.digest());\n\n // TODO: determine prf function and verify length for TLS 1.2\n var client = (c.entity === tls.ConnectionEnd.client);\n var sp = c.session.sp;\n var vdl = 12;\n var prf = prf_TLS1;\n var label = client ? 'client finished' : 'server finished';\n b = prf(sp.master_secret, label, b.getBytes(), vdl);\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.finished);\n rval.putInt24(b.length());\n rval.putBuffer(b);\n return rval;\n};\n\n/**\n * Creates a HeartbeatMessage (See RFC 6520).\n *\n * struct {\n * HeartbeatMessageType type;\n * uint16 payload_length;\n * opaque payload[HeartbeatMessage.payload_length];\n * opaque padding[padding_length];\n * } HeartbeatMessage;\n *\n * The total length of a HeartbeatMessage MUST NOT exceed 2^14 or\n * max_fragment_length when negotiated as defined in [RFC6066].\n *\n * type: The message type, either heartbeat_request or heartbeat_response.\n *\n * payload_length: The length of the payload.\n *\n * payload: The payload consists of arbitrary content.\n *\n * padding: The padding is random content that MUST be ignored by the\n * receiver. The length of a HeartbeatMessage is TLSPlaintext.length\n * for TLS and DTLSPlaintext.length for DTLS. Furthermore, the\n * length of the type field is 1 byte, and the length of the\n * payload_length is 2. Therefore, the padding_length is\n * TLSPlaintext.length - payload_length - 3 for TLS and\n * DTLSPlaintext.length - payload_length - 3 for DTLS. The\n * padding_length MUST be at least 16.\n *\n * The sender of a HeartbeatMessage MUST use a random padding of at\n * least 16 bytes. The padding of a received HeartbeatMessage message\n * MUST be ignored.\n *\n * If the payload_length of a received HeartbeatMessage is too large,\n * the received HeartbeatMessage MUST be discarded silently.\n *\n * @param c the connection.\n * @param type the tls.HeartbeatMessageType.\n * @param payload the heartbeat data to send as the payload.\n * @param [payloadLength] the payload length to use, defaults to the\n * actual payload length.\n *\n * @return the HeartbeatRequest byte buffer.\n */\ntls.createHeartbeat = function(type, payload, payloadLength) {\n if(typeof payloadLength === 'undefined') {\n payloadLength = payload.length;\n }\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(type); // heartbeat message type\n rval.putInt16(payloadLength); // payload length\n rval.putBytes(payload); // payload\n // padding\n var plaintextLength = rval.length();\n var paddingLength = Math.max(16, plaintextLength - payloadLength - 3);\n rval.putBytes(forge.random.getBytes(paddingLength));\n return rval;\n};\n\n/**\n * Fragments, compresses, encrypts, and queues a record for delivery.\n *\n * @param c the connection.\n * @param record the record to queue.\n */\ntls.queue = function(c, record) {\n // error during record creation\n if(!record) {\n return;\n }\n\n if(record.fragment.length() === 0) {\n if(record.type === tls.ContentType.handshake ||\n record.type === tls.ContentType.alert ||\n record.type === tls.ContentType.change_cipher_spec) {\n // Empty handshake, alert of change cipher spec messages are not allowed per the TLS specification and should not be sent.\n return;\n }\n }\n\n // if the record is a handshake record, update handshake hashes\n if(record.type === tls.ContentType.handshake) {\n var bytes = record.fragment.bytes();\n c.session.md5.update(bytes);\n c.session.sha1.update(bytes);\n bytes = null;\n }\n\n // handle record fragmentation\n var records;\n if(record.fragment.length() <= tls.MaxFragment) {\n records = [record];\n } else {\n // fragment data as long as it is too long\n records = [];\n var data = record.fragment.bytes();\n while(data.length > tls.MaxFragment) {\n records.push(tls.createRecord(c, {\n type: record.type,\n data: forge.util.createBuffer(data.slice(0, tls.MaxFragment))\n }));\n data = data.slice(tls.MaxFragment);\n }\n // add last record\n if(data.length > 0) {\n records.push(tls.createRecord(c, {\n type: record.type,\n data: forge.util.createBuffer(data)\n }));\n }\n }\n\n // compress and encrypt all fragmented records\n for(var i = 0; i < records.length && !c.fail; ++i) {\n // update the record using current write state\n var rec = records[i];\n var s = c.state.current.write;\n if(s.update(c, rec)) {\n // store record\n c.records.push(rec);\n }\n }\n};\n\n/**\n * Flushes all queued records to the output buffer and calls the\n * tlsDataReady() handler on the given connection.\n *\n * @param c the connection.\n *\n * @return true on success, false on failure.\n */\ntls.flush = function(c) {\n for(var i = 0; i < c.records.length; ++i) {\n var record = c.records[i];\n\n // add record header and fragment\n c.tlsData.putByte(record.type);\n c.tlsData.putByte(record.version.major);\n c.tlsData.putByte(record.version.minor);\n c.tlsData.putInt16(record.fragment.length());\n c.tlsData.putBuffer(c.records[i].fragment);\n }\n c.records = [];\n return c.tlsDataReady(c);\n};\n\n/**\n * Maps a pki.certificateError to a tls.Alert.Description.\n *\n * @param error the error to map.\n *\n * @return the alert description.\n */\nvar _certErrorToAlertDesc = function(error) {\n switch(error) {\n case true:\n return true;\n case forge.pki.certificateError.bad_certificate:\n return tls.Alert.Description.bad_certificate;\n case forge.pki.certificateError.unsupported_certificate:\n return tls.Alert.Description.unsupported_certificate;\n case forge.pki.certificateError.certificate_revoked:\n return tls.Alert.Description.certificate_revoked;\n case forge.pki.certificateError.certificate_expired:\n return tls.Alert.Description.certificate_expired;\n case forge.pki.certificateError.certificate_unknown:\n return tls.Alert.Description.certificate_unknown;\n case forge.pki.certificateError.unknown_ca:\n return tls.Alert.Description.unknown_ca;\n default:\n return tls.Alert.Description.bad_certificate;\n }\n};\n\n/**\n * Maps a tls.Alert.Description to a pki.certificateError.\n *\n * @param desc the alert description.\n *\n * @return the certificate error.\n */\nvar _alertDescToCertError = function(desc) {\n switch(desc) {\n case true:\n return true;\n case tls.Alert.Description.bad_certificate:\n return forge.pki.certificateError.bad_certificate;\n case tls.Alert.Description.unsupported_certificate:\n return forge.pki.certificateError.unsupported_certificate;\n case tls.Alert.Description.certificate_revoked:\n return forge.pki.certificateError.certificate_revoked;\n case tls.Alert.Description.certificate_expired:\n return forge.pki.certificateError.certificate_expired;\n case tls.Alert.Description.certificate_unknown:\n return forge.pki.certificateError.certificate_unknown;\n case tls.Alert.Description.unknown_ca:\n return forge.pki.certificateError.unknown_ca;\n default:\n return forge.pki.certificateError.bad_certificate;\n }\n};\n\n/**\n * Verifies a certificate chain against the given connection's\n * Certificate Authority store.\n *\n * @param c the TLS connection.\n * @param chain the certificate chain to verify, with the root or highest\n * authority at the end.\n *\n * @return true if successful, false if not.\n */\ntls.verifyCertificateChain = function(c, chain) {\n try {\n // Make a copy of c.verifyOptions so that we can modify options.verify\n // without modifying c.verifyOptions.\n var options = {};\n for (var key in c.verifyOptions) {\n options[key] = c.verifyOptions[key];\n }\n\n options.verify = function(vfd, depth, chain) {\n // convert pki.certificateError to tls alert description\n var desc = _certErrorToAlertDesc(vfd);\n\n // call application callback\n var ret = c.verify(c, vfd, depth, chain);\n if(ret !== true) {\n if(typeof ret === 'object' && !forge.util.isArray(ret)) {\n // throw custom error\n var error = new Error('The application rejected the certificate.');\n error.send = true;\n error.alert = {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.bad_certificate\n };\n if(ret.message) {\n error.message = ret.message;\n }\n if(ret.alert) {\n error.alert.description = ret.alert;\n }\n throw error;\n }\n\n // convert tls alert description to pki.certificateError\n if(ret !== vfd) {\n ret = _alertDescToCertError(ret);\n }\n }\n\n return ret;\n };\n\n // verify chain\n forge.pki.verifyCertificateChain(c.caStore, chain, options);\n } catch(ex) {\n // build tls error if not already customized\n var err = ex;\n if(typeof err !== 'object' || forge.util.isArray(err)) {\n err = {\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: _certErrorToAlertDesc(ex)\n }\n };\n }\n if(!('send' in err)) {\n err.send = true;\n }\n if(!('alert' in err)) {\n err.alert = {\n level: tls.Alert.Level.fatal,\n description: _certErrorToAlertDesc(err.error)\n };\n }\n\n // send error\n c.error(c, err);\n }\n\n return !c.fail;\n};\n\n/**\n * Creates a new TLS session cache.\n *\n * @param cache optional map of session ID to cached session.\n * @param capacity the maximum size for the cache (default: 100).\n *\n * @return the new TLS session cache.\n */\ntls.createSessionCache = function(cache, capacity) {\n var rval = null;\n\n // assume input is already a session cache object\n if(cache && cache.getSession && cache.setSession && cache.order) {\n rval = cache;\n } else {\n // create cache\n rval = {};\n rval.cache = cache || {};\n rval.capacity = Math.max(capacity || 100, 1);\n rval.order = [];\n\n // store order for sessions, delete session overflow\n for(var key in cache) {\n if(rval.order.length <= capacity) {\n rval.order.push(key);\n } else {\n delete cache[key];\n }\n }\n\n // get a session from a session ID (or get any session)\n rval.getSession = function(sessionId) {\n var session = null;\n var key = null;\n\n // if session ID provided, use it\n if(sessionId) {\n key = forge.util.bytesToHex(sessionId);\n } else if(rval.order.length > 0) {\n // get first session from cache\n key = rval.order[0];\n }\n\n if(key !== null && key in rval.cache) {\n // get cached session and remove from cache\n session = rval.cache[key];\n delete rval.cache[key];\n for(var i in rval.order) {\n if(rval.order[i] === key) {\n rval.order.splice(i, 1);\n break;\n }\n }\n }\n\n return session;\n };\n\n // set a session in the cache\n rval.setSession = function(sessionId, session) {\n // remove session from cache if at capacity\n if(rval.order.length === rval.capacity) {\n var key = rval.order.shift();\n delete rval.cache[key];\n }\n // add session to cache\n var key = forge.util.bytesToHex(sessionId);\n rval.order.push(key);\n rval.cache[key] = session;\n };\n }\n\n return rval;\n};\n\n/**\n * Creates a new TLS connection.\n *\n * See public createConnection() docs for more details.\n *\n * @param options the options for this connection.\n *\n * @return the new TLS connection.\n */\ntls.createConnection = function(options) {\n var caStore = null;\n if(options.caStore) {\n // if CA store is an array, convert it to a CA store object\n if(forge.util.isArray(options.caStore)) {\n caStore = forge.pki.createCaStore(options.caStore);\n } else {\n caStore = options.caStore;\n }\n } else {\n // create empty CA store\n caStore = forge.pki.createCaStore();\n }\n\n // setup default cipher suites\n var cipherSuites = options.cipherSuites || null;\n if(cipherSuites === null) {\n cipherSuites = [];\n for(var key in tls.CipherSuites) {\n cipherSuites.push(tls.CipherSuites[key]);\n }\n }\n\n // set default entity\n var entity = (options.server || false) ?\n tls.ConnectionEnd.server : tls.ConnectionEnd.client;\n\n // create session cache if requested\n var sessionCache = options.sessionCache ?\n tls.createSessionCache(options.sessionCache) : null;\n\n // create TLS connection\n var c = {\n version: {major: tls.Version.major, minor: tls.Version.minor},\n entity: entity,\n sessionId: options.sessionId,\n caStore: caStore,\n sessionCache: sessionCache,\n cipherSuites: cipherSuites,\n connected: options.connected,\n virtualHost: options.virtualHost || null,\n verifyClient: options.verifyClient || false,\n verify: options.verify || function(cn, vfd, dpth, cts) {return vfd;},\n verifyOptions: options.verifyOptions || {},\n getCertificate: options.getCertificate || null,\n getPrivateKey: options.getPrivateKey || null,\n getSignature: options.getSignature || null,\n input: forge.util.createBuffer(),\n tlsData: forge.util.createBuffer(),\n data: forge.util.createBuffer(),\n tlsDataReady: options.tlsDataReady,\n dataReady: options.dataReady,\n heartbeatReceived: options.heartbeatReceived,\n closed: options.closed,\n error: function(c, ex) {\n // set origin if not set\n ex.origin = ex.origin ||\n ((c.entity === tls.ConnectionEnd.client) ? 'client' : 'server');\n\n // send TLS alert\n if(ex.send) {\n tls.queue(c, tls.createAlert(c, ex.alert));\n tls.flush(c);\n }\n\n // error is fatal by default\n var fatal = (ex.fatal !== false);\n if(fatal) {\n // set fail flag\n c.fail = true;\n }\n\n // call error handler first\n options.error(c, ex);\n\n if(fatal) {\n // fatal error, close connection, do not clear fail\n c.close(false);\n }\n },\n deflate: options.deflate || null,\n inflate: options.inflate || null\n };\n\n /**\n * Resets a closed TLS connection for reuse. Called in c.close().\n *\n * @param clearFail true to clear the fail flag (default: true).\n */\n c.reset = function(clearFail) {\n c.version = {major: tls.Version.major, minor: tls.Version.minor};\n c.record = null;\n c.session = null;\n c.peerCertificate = null;\n c.state = {\n pending: null,\n current: null\n };\n c.expect = (c.entity === tls.ConnectionEnd.client) ? SHE : CHE;\n c.fragmented = null;\n c.records = [];\n c.open = false;\n c.handshakes = 0;\n c.handshaking = false;\n c.isConnected = false;\n c.fail = !(clearFail || typeof(clearFail) === 'undefined');\n c.input.clear();\n c.tlsData.clear();\n c.data.clear();\n c.state.current = tls.createConnectionState(c);\n };\n\n // do initial reset of connection\n c.reset();\n\n /**\n * Updates the current TLS engine state based on the given record.\n *\n * @param c the TLS connection.\n * @param record the TLS record to act on.\n */\n var _update = function(c, record) {\n // get record handler (align type in table by subtracting lowest)\n var aligned = record.type - tls.ContentType.change_cipher_spec;\n var handlers = ctTable[c.entity][c.expect];\n if(aligned in handlers) {\n handlers[aligned](c, record);\n } else {\n // unexpected record\n tls.handleUnexpected(c, record);\n }\n };\n\n /**\n * Reads the record header and initializes the next record on the given\n * connection.\n *\n * @param c the TLS connection with the next record.\n *\n * @return 0 if the input data could be processed, otherwise the\n * number of bytes required for data to be processed.\n */\n var _readRecordHeader = function(c) {\n var rval = 0;\n\n // get input buffer and its length\n var b = c.input;\n var len = b.length();\n\n // need at least 5 bytes to initialize a record\n if(len < 5) {\n rval = 5 - len;\n } else {\n // enough bytes for header\n // initialize record\n c.record = {\n type: b.getByte(),\n version: {\n major: b.getByte(),\n minor: b.getByte()\n },\n length: b.getInt16(),\n fragment: forge.util.createBuffer(),\n ready: false\n };\n\n // check record version\n var compatibleVersion = (c.record.version.major === c.version.major);\n if(compatibleVersion && c.session && c.session.version) {\n // session version already set, require same minor version\n compatibleVersion = (c.record.version.minor === c.version.minor);\n }\n if(!compatibleVersion) {\n c.error(c, {\n message: 'Incompatible TLS version.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.protocol_version\n }\n });\n }\n }\n\n return rval;\n };\n\n /**\n * Reads the next record's contents and appends its message to any\n * previously fragmented message.\n *\n * @param c the TLS connection with the next record.\n *\n * @return 0 if the input data could be processed, otherwise the\n * number of bytes required for data to be processed.\n */\n var _readRecord = function(c) {\n var rval = 0;\n\n // ensure there is enough input data to get the entire record\n var b = c.input;\n var len = b.length();\n if(len < c.record.length) {\n // not enough data yet, return how much is required\n rval = c.record.length - len;\n } else {\n // there is enough data to parse the pending record\n // fill record fragment and compact input buffer\n c.record.fragment.putBytes(b.getBytes(c.record.length));\n b.compact();\n\n // update record using current read state\n var s = c.state.current.read;\n if(s.update(c, c.record)) {\n // see if there is a previously fragmented message that the\n // new record's message fragment should be appended to\n if(c.fragmented !== null) {\n // if the record type matches a previously fragmented\n // record, append the record fragment to it\n if(c.fragmented.type === c.record.type) {\n // concatenate record fragments\n c.fragmented.fragment.putBuffer(c.record.fragment);\n c.record = c.fragmented;\n } else {\n // error, invalid fragmented record\n c.error(c, {\n message: 'Invalid fragmented record.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description:\n tls.Alert.Description.unexpected_message\n }\n });\n }\n }\n\n // record is now ready\n c.record.ready = true;\n }\n }\n\n return rval;\n };\n\n /**\n * Performs a handshake using the TLS Handshake Protocol, as a client.\n *\n * This method should only be called if the connection is in client mode.\n *\n * @param sessionId the session ID to use, null to start a new one.\n */\n c.handshake = function(sessionId) {\n // error to call this in non-client mode\n if(c.entity !== tls.ConnectionEnd.client) {\n // not fatal error\n c.error(c, {\n message: 'Cannot initiate handshake as a server.',\n fatal: false\n });\n } else if(c.handshaking) {\n // handshake is already in progress, fail but not fatal error\n c.error(c, {\n message: 'Handshake already in progress.',\n fatal: false\n });\n } else {\n // clear fail flag on reuse\n if(c.fail && !c.open && c.handshakes === 0) {\n c.fail = false;\n }\n\n // now handshaking\n c.handshaking = true;\n\n // default to blank (new session)\n sessionId = sessionId || '';\n\n // if a session ID was specified, try to find it in the cache\n var session = null;\n if(sessionId.length > 0) {\n if(c.sessionCache) {\n session = c.sessionCache.getSession(sessionId);\n }\n\n // matching session not found in cache, clear session ID\n if(session === null) {\n sessionId = '';\n }\n }\n\n // no session given, grab a session from the cache, if available\n if(sessionId.length === 0 && c.sessionCache) {\n session = c.sessionCache.getSession();\n if(session !== null) {\n sessionId = session.id;\n }\n }\n\n // set up session\n c.session = {\n id: sessionId,\n version: null,\n cipherSuite: null,\n compressionMethod: null,\n serverCertificate: null,\n certificateRequest: null,\n clientCertificate: null,\n sp: {},\n md5: forge.md.md5.create(),\n sha1: forge.md.sha1.create()\n };\n\n // use existing session information\n if(session) {\n // only update version on connection, session version not yet set\n c.version = session.version;\n c.session.sp = session.sp;\n }\n\n // generate new client random\n c.session.sp.client_random = tls.createRandom().getBytes();\n\n // connection now open\n c.open = true;\n\n // send hello\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createClientHello(c)\n }));\n tls.flush(c);\n }\n };\n\n /**\n * Called when TLS protocol data has been received from somewhere and should\n * be processed by the TLS engine.\n *\n * @param data the TLS protocol data, as a string, to process.\n *\n * @return 0 if the data could be processed, otherwise the number of bytes\n * required for data to be processed.\n */\n c.process = function(data) {\n var rval = 0;\n\n // buffer input data\n if(data) {\n c.input.putBytes(data);\n }\n\n // process next record if no failure, process will be called after\n // each record is handled (since handling can be asynchronous)\n if(!c.fail) {\n // reset record if ready and now empty\n if(c.record !== null &&\n c.record.ready && c.record.fragment.isEmpty()) {\n c.record = null;\n }\n\n // if there is no pending record, try to read record header\n if(c.record === null) {\n rval = _readRecordHeader(c);\n }\n\n // read the next record (if record not yet ready)\n if(!c.fail && c.record !== null && !c.record.ready) {\n rval = _readRecord(c);\n }\n\n // record ready to be handled, update engine state\n if(!c.fail && c.record !== null && c.record.ready) {\n _update(c, c.record);\n }\n }\n\n return rval;\n };\n\n /**\n * Requests that application data be packaged into a TLS record. The\n * tlsDataReady handler will be called when the TLS record(s) have been\n * prepared.\n *\n * @param data the application data, as a raw 'binary' encoded string, to\n * be sent; to send utf-16/utf-8 string data, use the return value\n * of util.encodeUtf8(str).\n *\n * @return true on success, false on failure.\n */\n c.prepare = function(data) {\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.application_data,\n data: forge.util.createBuffer(data)\n }));\n return tls.flush(c);\n };\n\n /**\n * Requests that a heartbeat request be packaged into a TLS record for\n * transmission. The tlsDataReady handler will be called when TLS record(s)\n * have been prepared.\n *\n * When a heartbeat response has been received, the heartbeatReceived\n * handler will be called with the matching payload. This handler can\n * be used to clear a retransmission timer, etc.\n *\n * @param payload the heartbeat data to send as the payload in the message.\n * @param [payloadLength] the payload length to use, defaults to the\n * actual payload length.\n *\n * @return true on success, false on failure.\n */\n c.prepareHeartbeatRequest = function(payload, payloadLength) {\n if(payload instanceof forge.util.ByteBuffer) {\n payload = payload.bytes();\n }\n if(typeof payloadLength === 'undefined') {\n payloadLength = payload.length;\n }\n c.expectedHeartbeatPayload = payload;\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.heartbeat,\n data: tls.createHeartbeat(\n tls.HeartbeatMessageType.heartbeat_request, payload, payloadLength)\n }));\n return tls.flush(c);\n };\n\n /**\n * Closes the connection (sends a close_notify alert).\n *\n * @param clearFail true to clear the fail flag (default: true).\n */\n c.close = function(clearFail) {\n // save session if connection didn't fail\n if(!c.fail && c.sessionCache && c.session) {\n // only need to preserve session ID, version, and security params\n var session = {\n id: c.session.id,\n version: c.session.version,\n sp: c.session.sp\n };\n session.sp.keys = null;\n c.sessionCache.setSession(session.id, session);\n }\n\n if(c.open) {\n // connection no longer open, clear input\n c.open = false;\n c.input.clear();\n\n // if connected or handshaking, send an alert\n if(c.isConnected || c.handshaking) {\n c.isConnected = c.handshaking = false;\n\n // send close_notify alert\n tls.queue(c, tls.createAlert(c, {\n level: tls.Alert.Level.warning,\n description: tls.Alert.Description.close_notify\n }));\n tls.flush(c);\n }\n\n // call handler\n c.closed(c);\n }\n\n // reset TLS connection, do not clear fail flag\n c.reset(clearFail);\n };\n\n return c;\n};\n\n/* TLS API */\nmodule.exports = forge.tls = forge.tls || {};\n\n// expose non-functions\nfor(var key in tls) {\n if(typeof tls[key] !== 'function') {\n forge.tls[key] = tls[key];\n }\n}\n\n// expose prf_tls1 for testing\nforge.tls.prf_tls1 = prf_TLS1;\n\n// expose sha1 hmac method\nforge.tls.hmac_sha1 = hmac_sha1;\n\n// expose session cache creation\nforge.tls.createSessionCache = tls.createSessionCache;\n\n/**\n * Creates a new TLS connection. This does not make any assumptions about the\n * transport layer that TLS is working on top of, ie: it does not assume there\n * is a TCP/IP connection or establish one. A TLS connection is totally\n * abstracted away from the layer is runs on top of, it merely establishes a\n * secure channel between a client\" and a \"server\".\n *\n * A TLS connection contains 4 connection states: pending read and write, and\n * current read and write.\n *\n * At initialization, the current read and write states will be null. Only once\n * the security parameters have been set and the keys have been generated can\n * the pending states be converted into current states. Current states will be\n * updated for each record processed.\n *\n * A custom certificate verify callback may be provided to check information\n * like the common name on the server's certificate. It will be called for\n * every certificate in the chain. It has the following signature:\n *\n * variable func(c, certs, index, preVerify)\n * Where:\n * c The TLS connection\n * verified Set to true if certificate was verified, otherwise the alert\n * tls.Alert.Description for why the certificate failed.\n * depth The current index in the chain, where 0 is the server's cert.\n * certs The certificate chain, *NOTE* if the server was anonymous then\n * the chain will be empty.\n *\n * The function returns true on success and on failure either the appropriate\n * tls.Alert.Description or an object with 'alert' set to the appropriate\n * tls.Alert.Description and 'message' set to a custom error message. If true\n * is not returned then the connection will abort using, in order of\n * availability, first the returned alert description, second the preVerify\n * alert description, and lastly the default 'bad_certificate'.\n *\n * There are three callbacks that can be used to make use of client-side\n * certificates where each takes the TLS connection as the first parameter:\n *\n * getCertificate(conn, hint)\n * The second parameter is a hint as to which certificate should be\n * returned. If the connection entity is a client, then the hint will be\n * the CertificateRequest message from the server that is part of the\n * TLS protocol. If the connection entity is a server, then it will be\n * the servername list provided via an SNI extension the ClientHello, if\n * one was provided (empty array if not). The hint can be examined to\n * determine which certificate to use (advanced). Most implementations\n * will just return a certificate. The return value must be a\n * PEM-formatted certificate or an array of PEM-formatted certificates\n * that constitute a certificate chain, with the first in the array/chain\n * being the client's certificate.\n * getPrivateKey(conn, certificate)\n * The second parameter is an forge.pki X.509 certificate object that\n * is associated with the requested private key. The return value must\n * be a PEM-formatted private key.\n * getSignature(conn, bytes, callback)\n * This callback can be used instead of getPrivateKey if the private key\n * is not directly accessible in javascript or should not be. For\n * instance, a secure external web service could provide the signature\n * in exchange for appropriate credentials. The second parameter is a\n * string of bytes to be signed that are part of the TLS protocol. These\n * bytes are used to verify that the private key for the previously\n * provided client-side certificate is accessible to the client. The\n * callback is a function that takes 2 parameters, the TLS connection\n * and the RSA encrypted (signed) bytes as a string. This callback must\n * be called once the signature is ready.\n *\n * @param options the options for this connection:\n * server: true if the connection is server-side, false for client.\n * sessionId: a session ID to reuse, null for a new connection.\n * caStore: an array of certificates to trust.\n * sessionCache: a session cache to use.\n * cipherSuites: an optional array of cipher suites to use,\n * see tls.CipherSuites.\n * connected: function(conn) called when the first handshake completes.\n * virtualHost: the virtual server name to use in a TLS SNI extension.\n * verifyClient: true to require a client certificate in server mode,\n * 'optional' to request one, false not to (default: false).\n * verify: a handler used to custom verify certificates in the chain.\n * verifyOptions: an object with options for the certificate chain validation.\n * See documentation of pki.verifyCertificateChain for possible options.\n * verifyOptions.verify is ignored. If you wish to specify a verify handler\n * use the verify key.\n * getCertificate: an optional callback used to get a certificate or\n * a chain of certificates (as an array).\n * getPrivateKey: an optional callback used to get a private key.\n * getSignature: an optional callback used to get a signature.\n * tlsDataReady: function(conn) called when TLS protocol data has been\n * prepared and is ready to be used (typically sent over a socket\n * connection to its destination), read from conn.tlsData buffer.\n * dataReady: function(conn) called when application data has\n * been parsed from a TLS record and should be consumed by the\n * application, read from conn.data buffer.\n * closed: function(conn) called when the connection has been closed.\n * error: function(conn, error) called when there was an error.\n * deflate: function(inBytes) if provided, will deflate TLS records using\n * the deflate algorithm if the server supports it.\n * inflate: function(inBytes) if provided, will inflate TLS records using\n * the deflate algorithm if the server supports it.\n *\n * @return the new TLS connection.\n */\nforge.tls.createConnection = tls.createConnection;\n","/**\n * Utility functions for web applications.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2018 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nvar baseN = require('./baseN');\n\n/* Utilities API */\nvar util = module.exports = forge.util = forge.util || {};\n\n// define setImmediate and nextTick\n(function() {\n // use native nextTick (unless we're in webpack)\n // webpack (or better node-libs-browser polyfill) sets process.browser.\n // this way we can detect webpack properly\n if(typeof process !== 'undefined' && process.nextTick && !process.browser) {\n util.nextTick = process.nextTick;\n if(typeof setImmediate === 'function') {\n util.setImmediate = setImmediate;\n } else {\n // polyfill setImmediate with nextTick, older versions of node\n // (those w/o setImmediate) won't totally starve IO\n util.setImmediate = util.nextTick;\n }\n return;\n }\n\n // polyfill nextTick with native setImmediate\n if(typeof setImmediate === 'function') {\n util.setImmediate = function() { return setImmediate.apply(undefined, arguments); };\n util.nextTick = function(callback) {\n return setImmediate(callback);\n };\n return;\n }\n\n /* Note: A polyfill upgrade pattern is used here to allow combining\n polyfills. For example, MutationObserver is fast, but blocks UI updates,\n so it needs to allow UI updates periodically, so it falls back on\n postMessage or setTimeout. */\n\n // polyfill with setTimeout\n util.setImmediate = function(callback) {\n setTimeout(callback, 0);\n };\n\n // upgrade polyfill to use postMessage\n if(typeof window !== 'undefined' &&\n typeof window.postMessage === 'function') {\n var msg = 'forge.setImmediate';\n var callbacks = [];\n util.setImmediate = function(callback) {\n callbacks.push(callback);\n // only send message when one hasn't been sent in\n // the current turn of the event loop\n if(callbacks.length === 1) {\n window.postMessage(msg, '*');\n }\n };\n function handler(event) {\n if(event.source === window && event.data === msg) {\n event.stopPropagation();\n var copy = callbacks.slice();\n callbacks.length = 0;\n copy.forEach(function(callback) {\n callback();\n });\n }\n }\n window.addEventListener('message', handler, true);\n }\n\n // upgrade polyfill to use MutationObserver\n if(typeof MutationObserver !== 'undefined') {\n // polyfill with MutationObserver\n var now = Date.now();\n var attr = true;\n var div = document.createElement('div');\n var callbacks = [];\n new MutationObserver(function() {\n var copy = callbacks.slice();\n callbacks.length = 0;\n copy.forEach(function(callback) {\n callback();\n });\n }).observe(div, {attributes: true});\n var oldSetImmediate = util.setImmediate;\n util.setImmediate = function(callback) {\n if(Date.now() - now > 15) {\n now = Date.now();\n oldSetImmediate(callback);\n } else {\n callbacks.push(callback);\n // only trigger observer when it hasn't been triggered in\n // the current turn of the event loop\n if(callbacks.length === 1) {\n div.setAttribute('a', attr = !attr);\n }\n }\n };\n }\n\n util.nextTick = util.setImmediate;\n})();\n\n// check if running under Node.js\nutil.isNodejs =\n typeof process !== 'undefined' && process.versions && process.versions.node;\n\n\n// 'self' will also work in Web Workers (instance of WorkerGlobalScope) while\n// it will point to `window` in the main thread.\n// To remain compatible with older browsers, we fall back to 'window' if 'self'\n// is not available.\nutil.globalScope = (function() {\n if(util.isNodejs) {\n return global;\n }\n\n return typeof self === 'undefined' ? window : self;\n})();\n\n// define isArray\nutil.isArray = Array.isArray || function(x) {\n return Object.prototype.toString.call(x) === '[object Array]';\n};\n\n// define isArrayBuffer\nutil.isArrayBuffer = function(x) {\n return typeof ArrayBuffer !== 'undefined' && x instanceof ArrayBuffer;\n};\n\n// define isArrayBufferView\nutil.isArrayBufferView = function(x) {\n return x && util.isArrayBuffer(x.buffer) && x.byteLength !== undefined;\n};\n\n/**\n * Ensure a bits param is 8, 16, 24, or 32. Used to validate input for\n * algorithms where bit manipulation, JavaScript limitations, and/or algorithm\n * design only allow for byte operations of a limited size.\n *\n * @param n number of bits.\n *\n * Throw Error if n invalid.\n */\nfunction _checkBitsParam(n) {\n if(!(n === 8 || n === 16 || n === 24 || n === 32)) {\n throw new Error('Only 8, 16, 24, or 32 bits supported: ' + n);\n }\n}\n\n// TODO: set ByteBuffer to best available backing\nutil.ByteBuffer = ByteStringBuffer;\n\n/** Buffer w/BinaryString backing */\n\n/**\n * Constructor for a binary string backed byte buffer.\n *\n * @param [b] the bytes to wrap (either encoded as string, one byte per\n * character, or as an ArrayBuffer or Typed Array).\n */\nfunction ByteStringBuffer(b) {\n // TODO: update to match DataBuffer API\n\n // the data in this buffer\n this.data = '';\n // the pointer for reading from this buffer\n this.read = 0;\n\n if(typeof b === 'string') {\n this.data = b;\n } else if(util.isArrayBuffer(b) || util.isArrayBufferView(b)) {\n if(typeof Buffer !== 'undefined' && b instanceof Buffer) {\n this.data = b.toString('binary');\n } else {\n // convert native buffer to forge buffer\n // FIXME: support native buffers internally instead\n var arr = new Uint8Array(b);\n try {\n this.data = String.fromCharCode.apply(null, arr);\n } catch(e) {\n for(var i = 0; i < arr.length; ++i) {\n this.putByte(arr[i]);\n }\n }\n }\n } else if(b instanceof ByteStringBuffer ||\n (typeof b === 'object' && typeof b.data === 'string' &&\n typeof b.read === 'number')) {\n // copy existing buffer\n this.data = b.data;\n this.read = b.read;\n }\n\n // used for v8 optimization\n this._constructedStringLength = 0;\n}\nutil.ByteStringBuffer = ByteStringBuffer;\n\n/* Note: This is an optimization for V8-based browsers. When V8 concatenates\n a string, the strings are only joined logically using a \"cons string\" or\n \"constructed/concatenated string\". These containers keep references to one\n another and can result in very large memory usage. For example, if a 2MB\n string is constructed by concatenating 4 bytes together at a time, the\n memory usage will be ~44MB; so ~22x increase. The strings are only joined\n together when an operation requiring their joining takes place, such as\n substr(). This function is called when adding data to this buffer to ensure\n these types of strings are periodically joined to reduce the memory\n footprint. */\nvar _MAX_CONSTRUCTED_STRING_LENGTH = 4096;\nutil.ByteStringBuffer.prototype._optimizeConstructedString = function(x) {\n this._constructedStringLength += x;\n if(this._constructedStringLength > _MAX_CONSTRUCTED_STRING_LENGTH) {\n // this substr() should cause the constructed string to join\n this.data.substr(0, 1);\n this._constructedStringLength = 0;\n }\n};\n\n/**\n * Gets the number of bytes in this buffer.\n *\n * @return the number of bytes in this buffer.\n */\nutil.ByteStringBuffer.prototype.length = function() {\n return this.data.length - this.read;\n};\n\n/**\n * Gets whether or not this buffer is empty.\n *\n * @return true if this buffer is empty, false if not.\n */\nutil.ByteStringBuffer.prototype.isEmpty = function() {\n return this.length() <= 0;\n};\n\n/**\n * Puts a byte in this buffer.\n *\n * @param b the byte to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putByte = function(b) {\n return this.putBytes(String.fromCharCode(b));\n};\n\n/**\n * Puts a byte in this buffer N times.\n *\n * @param b the byte to put.\n * @param n the number of bytes of value b to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.fillWithByte = function(b, n) {\n b = String.fromCharCode(b);\n var d = this.data;\n while(n > 0) {\n if(n & 1) {\n d += b;\n }\n n >>>= 1;\n if(n > 0) {\n b += b;\n }\n }\n this.data = d;\n this._optimizeConstructedString(n);\n return this;\n};\n\n/**\n * Puts bytes in this buffer.\n *\n * @param bytes the bytes (as a binary encoded string) to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putBytes = function(bytes) {\n this.data += bytes;\n this._optimizeConstructedString(bytes.length);\n return this;\n};\n\n/**\n * Puts a UTF-16 encoded string into this buffer.\n *\n * @param str the string to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putString = function(str) {\n return this.putBytes(util.encodeUtf8(str));\n};\n\n/**\n * Puts a 16-bit integer in this buffer in big-endian order.\n *\n * @param i the 16-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt16 = function(i) {\n return this.putBytes(\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i & 0xFF));\n};\n\n/**\n * Puts a 24-bit integer in this buffer in big-endian order.\n *\n * @param i the 24-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt24 = function(i) {\n return this.putBytes(\n String.fromCharCode(i >> 16 & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i & 0xFF));\n};\n\n/**\n * Puts a 32-bit integer in this buffer in big-endian order.\n *\n * @param i the 32-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt32 = function(i) {\n return this.putBytes(\n String.fromCharCode(i >> 24 & 0xFF) +\n String.fromCharCode(i >> 16 & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i & 0xFF));\n};\n\n/**\n * Puts a 16-bit integer in this buffer in little-endian order.\n *\n * @param i the 16-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt16Le = function(i) {\n return this.putBytes(\n String.fromCharCode(i & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF));\n};\n\n/**\n * Puts a 24-bit integer in this buffer in little-endian order.\n *\n * @param i the 24-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt24Le = function(i) {\n return this.putBytes(\n String.fromCharCode(i & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i >> 16 & 0xFF));\n};\n\n/**\n * Puts a 32-bit integer in this buffer in little-endian order.\n *\n * @param i the 32-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt32Le = function(i) {\n return this.putBytes(\n String.fromCharCode(i & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i >> 16 & 0xFF) +\n String.fromCharCode(i >> 24 & 0xFF));\n};\n\n/**\n * Puts an n-bit integer in this buffer in big-endian order.\n *\n * @param i the n-bit integer.\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt = function(i, n) {\n _checkBitsParam(n);\n var bytes = '';\n do {\n n -= 8;\n bytes += String.fromCharCode((i >> n) & 0xFF);\n } while(n > 0);\n return this.putBytes(bytes);\n};\n\n/**\n * Puts a signed n-bit integer in this buffer in big-endian order. Two's\n * complement representation is used.\n *\n * @param i the n-bit integer.\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putSignedInt = function(i, n) {\n // putInt checks n\n if(i < 0) {\n i += 2 << (n - 1);\n }\n return this.putInt(i, n);\n};\n\n/**\n * Puts the given buffer into this buffer.\n *\n * @param buffer the buffer to put into this one.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putBuffer = function(buffer) {\n return this.putBytes(buffer.getBytes());\n};\n\n/**\n * Gets a byte from this buffer and advances the read pointer by 1.\n *\n * @return the byte.\n */\nutil.ByteStringBuffer.prototype.getByte = function() {\n return this.data.charCodeAt(this.read++);\n};\n\n/**\n * Gets a uint16 from this buffer in big-endian order and advances the read\n * pointer by 2.\n *\n * @return the uint16.\n */\nutil.ByteStringBuffer.prototype.getInt16 = function() {\n var rval = (\n this.data.charCodeAt(this.read) << 8 ^\n this.data.charCodeAt(this.read + 1));\n this.read += 2;\n return rval;\n};\n\n/**\n * Gets a uint24 from this buffer in big-endian order and advances the read\n * pointer by 3.\n *\n * @return the uint24.\n */\nutil.ByteStringBuffer.prototype.getInt24 = function() {\n var rval = (\n this.data.charCodeAt(this.read) << 16 ^\n this.data.charCodeAt(this.read + 1) << 8 ^\n this.data.charCodeAt(this.read + 2));\n this.read += 3;\n return rval;\n};\n\n/**\n * Gets a uint32 from this buffer in big-endian order and advances the read\n * pointer by 4.\n *\n * @return the word.\n */\nutil.ByteStringBuffer.prototype.getInt32 = function() {\n var rval = (\n this.data.charCodeAt(this.read) << 24 ^\n this.data.charCodeAt(this.read + 1) << 16 ^\n this.data.charCodeAt(this.read + 2) << 8 ^\n this.data.charCodeAt(this.read + 3));\n this.read += 4;\n return rval;\n};\n\n/**\n * Gets a uint16 from this buffer in little-endian order and advances the read\n * pointer by 2.\n *\n * @return the uint16.\n */\nutil.ByteStringBuffer.prototype.getInt16Le = function() {\n var rval = (\n this.data.charCodeAt(this.read) ^\n this.data.charCodeAt(this.read + 1) << 8);\n this.read += 2;\n return rval;\n};\n\n/**\n * Gets a uint24 from this buffer in little-endian order and advances the read\n * pointer by 3.\n *\n * @return the uint24.\n */\nutil.ByteStringBuffer.prototype.getInt24Le = function() {\n var rval = (\n this.data.charCodeAt(this.read) ^\n this.data.charCodeAt(this.read + 1) << 8 ^\n this.data.charCodeAt(this.read + 2) << 16);\n this.read += 3;\n return rval;\n};\n\n/**\n * Gets a uint32 from this buffer in little-endian order and advances the read\n * pointer by 4.\n *\n * @return the word.\n */\nutil.ByteStringBuffer.prototype.getInt32Le = function() {\n var rval = (\n this.data.charCodeAt(this.read) ^\n this.data.charCodeAt(this.read + 1) << 8 ^\n this.data.charCodeAt(this.read + 2) << 16 ^\n this.data.charCodeAt(this.read + 3) << 24);\n this.read += 4;\n return rval;\n};\n\n/**\n * Gets an n-bit integer from this buffer in big-endian order and advances the\n * read pointer by ceil(n/8).\n *\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return the integer.\n */\nutil.ByteStringBuffer.prototype.getInt = function(n) {\n _checkBitsParam(n);\n var rval = 0;\n do {\n // TODO: Use (rval * 0x100) if adding support for 33 to 53 bits.\n rval = (rval << 8) + this.data.charCodeAt(this.read++);\n n -= 8;\n } while(n > 0);\n return rval;\n};\n\n/**\n * Gets a signed n-bit integer from this buffer in big-endian order, using\n * two's complement, and advances the read pointer by n/8.\n *\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return the integer.\n */\nutil.ByteStringBuffer.prototype.getSignedInt = function(n) {\n // getInt checks n\n var x = this.getInt(n);\n var max = 2 << (n - 2);\n if(x >= max) {\n x -= max << 1;\n }\n return x;\n};\n\n/**\n * Reads bytes out as a binary encoded string and clears them from the\n * buffer. Note that the resulting string is binary encoded (in node.js this\n * encoding is referred to as `binary`, it is *not* `utf8`).\n *\n * @param count the number of bytes to read, undefined or null for all.\n *\n * @return a binary encoded string of bytes.\n */\nutil.ByteStringBuffer.prototype.getBytes = function(count) {\n var rval;\n if(count) {\n // read count bytes\n count = Math.min(this.length(), count);\n rval = this.data.slice(this.read, this.read + count);\n this.read += count;\n } else if(count === 0) {\n rval = '';\n } else {\n // read all bytes, optimize to only copy when needed\n rval = (this.read === 0) ? this.data : this.data.slice(this.read);\n this.clear();\n }\n return rval;\n};\n\n/**\n * Gets a binary encoded string of the bytes from this buffer without\n * modifying the read pointer.\n *\n * @param count the number of bytes to get, omit to get all.\n *\n * @return a string full of binary encoded characters.\n */\nutil.ByteStringBuffer.prototype.bytes = function(count) {\n return (typeof(count) === 'undefined' ?\n this.data.slice(this.read) :\n this.data.slice(this.read, this.read + count));\n};\n\n/**\n * Gets a byte at the given index without modifying the read pointer.\n *\n * @param i the byte index.\n *\n * @return the byte.\n */\nutil.ByteStringBuffer.prototype.at = function(i) {\n return this.data.charCodeAt(this.read + i);\n};\n\n/**\n * Puts a byte at the given index without modifying the read pointer.\n *\n * @param i the byte index.\n * @param b the byte to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.setAt = function(i, b) {\n this.data = this.data.substr(0, this.read + i) +\n String.fromCharCode(b) +\n this.data.substr(this.read + i + 1);\n return this;\n};\n\n/**\n * Gets the last byte without modifying the read pointer.\n *\n * @return the last byte.\n */\nutil.ByteStringBuffer.prototype.last = function() {\n return this.data.charCodeAt(this.data.length - 1);\n};\n\n/**\n * Creates a copy of this buffer.\n *\n * @return the copy.\n */\nutil.ByteStringBuffer.prototype.copy = function() {\n var c = util.createBuffer(this.data);\n c.read = this.read;\n return c;\n};\n\n/**\n * Compacts this buffer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.compact = function() {\n if(this.read > 0) {\n this.data = this.data.slice(this.read);\n this.read = 0;\n }\n return this;\n};\n\n/**\n * Clears this buffer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.clear = function() {\n this.data = '';\n this.read = 0;\n return this;\n};\n\n/**\n * Shortens this buffer by triming bytes off of the end of this buffer.\n *\n * @param count the number of bytes to trim off.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.truncate = function(count) {\n var len = Math.max(0, this.length() - count);\n this.data = this.data.substr(this.read, len);\n this.read = 0;\n return this;\n};\n\n/**\n * Converts this buffer to a hexadecimal string.\n *\n * @return a hexadecimal string.\n */\nutil.ByteStringBuffer.prototype.toHex = function() {\n var rval = '';\n for(var i = this.read; i < this.data.length; ++i) {\n var b = this.data.charCodeAt(i);\n if(b < 16) {\n rval += '0';\n }\n rval += b.toString(16);\n }\n return rval;\n};\n\n/**\n * Converts this buffer to a UTF-16 string (standard JavaScript string).\n *\n * @return a UTF-16 string.\n */\nutil.ByteStringBuffer.prototype.toString = function() {\n return util.decodeUtf8(this.bytes());\n};\n\n/** End Buffer w/BinaryString backing */\n\n/** Buffer w/UInt8Array backing */\n\n/**\n * FIXME: Experimental. Do not use yet.\n *\n * Constructor for an ArrayBuffer-backed byte buffer.\n *\n * The buffer may be constructed from a string, an ArrayBuffer, DataView, or a\n * TypedArray.\n *\n * If a string is given, its encoding should be provided as an option,\n * otherwise it will default to 'binary'. A 'binary' string is encoded such\n * that each character is one byte in length and size.\n *\n * If an ArrayBuffer, DataView, or TypedArray is given, it will be used\n * *directly* without any copying. Note that, if a write to the buffer requires\n * more space, the buffer will allocate a new backing ArrayBuffer to\n * accommodate. The starting read and write offsets for the buffer may be\n * given as options.\n *\n * @param [b] the initial bytes for this buffer.\n * @param options the options to use:\n * [readOffset] the starting read offset to use (default: 0).\n * [writeOffset] the starting write offset to use (default: the\n * length of the first parameter).\n * [growSize] the minimum amount, in bytes, to grow the buffer by to\n * accommodate writes (default: 1024).\n * [encoding] the encoding ('binary', 'utf8', 'utf16', 'hex') for the\n * first parameter, if it is a string (default: 'binary').\n */\nfunction DataBuffer(b, options) {\n // default options\n options = options || {};\n\n // pointers for read from/write to buffer\n this.read = options.readOffset || 0;\n this.growSize = options.growSize || 1024;\n\n var isArrayBuffer = util.isArrayBuffer(b);\n var isArrayBufferView = util.isArrayBufferView(b);\n if(isArrayBuffer || isArrayBufferView) {\n // use ArrayBuffer directly\n if(isArrayBuffer) {\n this.data = new DataView(b);\n } else {\n // TODO: adjust read/write offset based on the type of view\n // or specify that this must be done in the options ... that the\n // offsets are byte-based\n this.data = new DataView(b.buffer, b.byteOffset, b.byteLength);\n }\n this.write = ('writeOffset' in options ?\n options.writeOffset : this.data.byteLength);\n return;\n }\n\n // initialize to empty array buffer and add any given bytes using putBytes\n this.data = new DataView(new ArrayBuffer(0));\n this.write = 0;\n\n if(b !== null && b !== undefined) {\n this.putBytes(b);\n }\n\n if('writeOffset' in options) {\n this.write = options.writeOffset;\n }\n}\nutil.DataBuffer = DataBuffer;\n\n/**\n * Gets the number of bytes in this buffer.\n *\n * @return the number of bytes in this buffer.\n */\nutil.DataBuffer.prototype.length = function() {\n return this.write - this.read;\n};\n\n/**\n * Gets whether or not this buffer is empty.\n *\n * @return true if this buffer is empty, false if not.\n */\nutil.DataBuffer.prototype.isEmpty = function() {\n return this.length() <= 0;\n};\n\n/**\n * Ensures this buffer has enough empty space to accommodate the given number\n * of bytes. An optional parameter may be given that indicates a minimum\n * amount to grow the buffer if necessary. If the parameter is not given,\n * the buffer will be grown by some previously-specified default amount\n * or heuristic.\n *\n * @param amount the number of bytes to accommodate.\n * @param [growSize] the minimum amount, in bytes, to grow the buffer by if\n * necessary.\n */\nutil.DataBuffer.prototype.accommodate = function(amount, growSize) {\n if(this.length() >= amount) {\n return this;\n }\n growSize = Math.max(growSize || this.growSize, amount);\n\n // grow buffer\n var src = new Uint8Array(\n this.data.buffer, this.data.byteOffset, this.data.byteLength);\n var dst = new Uint8Array(this.length() + growSize);\n dst.set(src);\n this.data = new DataView(dst.buffer);\n\n return this;\n};\n\n/**\n * Puts a byte in this buffer.\n *\n * @param b the byte to put.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putByte = function(b) {\n this.accommodate(1);\n this.data.setUint8(this.write++, b);\n return this;\n};\n\n/**\n * Puts a byte in this buffer N times.\n *\n * @param b the byte to put.\n * @param n the number of bytes of value b to put.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.fillWithByte = function(b, n) {\n this.accommodate(n);\n for(var i = 0; i < n; ++i) {\n this.data.setUint8(b);\n }\n return this;\n};\n\n/**\n * Puts bytes in this buffer. The bytes may be given as a string, an\n * ArrayBuffer, a DataView, or a TypedArray.\n *\n * @param bytes the bytes to put.\n * @param [encoding] the encoding for the first parameter ('binary', 'utf8',\n * 'utf16', 'hex'), if it is a string (default: 'binary').\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putBytes = function(bytes, encoding) {\n if(util.isArrayBufferView(bytes)) {\n var src = new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n var len = src.byteLength - src.byteOffset;\n this.accommodate(len);\n var dst = new Uint8Array(this.data.buffer, this.write);\n dst.set(src);\n this.write += len;\n return this;\n }\n\n if(util.isArrayBuffer(bytes)) {\n var src = new Uint8Array(bytes);\n this.accommodate(src.byteLength);\n var dst = new Uint8Array(this.data.buffer);\n dst.set(src, this.write);\n this.write += src.byteLength;\n return this;\n }\n\n // bytes is a util.DataBuffer or equivalent\n if(bytes instanceof util.DataBuffer ||\n (typeof bytes === 'object' &&\n typeof bytes.read === 'number' && typeof bytes.write === 'number' &&\n util.isArrayBufferView(bytes.data))) {\n var src = new Uint8Array(bytes.data.byteLength, bytes.read, bytes.length());\n this.accommodate(src.byteLength);\n var dst = new Uint8Array(bytes.data.byteLength, this.write);\n dst.set(src);\n this.write += src.byteLength;\n return this;\n }\n\n if(bytes instanceof util.ByteStringBuffer) {\n // copy binary string and process as the same as a string parameter below\n bytes = bytes.data;\n encoding = 'binary';\n }\n\n // string conversion\n encoding = encoding || 'binary';\n if(typeof bytes === 'string') {\n var view;\n\n // decode from string\n if(encoding === 'hex') {\n this.accommodate(Math.ceil(bytes.length / 2));\n view = new Uint8Array(this.data.buffer, this.write);\n this.write += util.binary.hex.decode(bytes, view, this.write);\n return this;\n }\n if(encoding === 'base64') {\n this.accommodate(Math.ceil(bytes.length / 4) * 3);\n view = new Uint8Array(this.data.buffer, this.write);\n this.write += util.binary.base64.decode(bytes, view, this.write);\n return this;\n }\n\n // encode text as UTF-8 bytes\n if(encoding === 'utf8') {\n // encode as UTF-8 then decode string as raw binary\n bytes = util.encodeUtf8(bytes);\n encoding = 'binary';\n }\n\n // decode string as raw binary\n if(encoding === 'binary' || encoding === 'raw') {\n // one byte per character\n this.accommodate(bytes.length);\n view = new Uint8Array(this.data.buffer, this.write);\n this.write += util.binary.raw.decode(view);\n return this;\n }\n\n // encode text as UTF-16 bytes\n if(encoding === 'utf16') {\n // two bytes per character\n this.accommodate(bytes.length * 2);\n view = new Uint16Array(this.data.buffer, this.write);\n this.write += util.text.utf16.encode(view);\n return this;\n }\n\n throw new Error('Invalid encoding: ' + encoding);\n }\n\n throw Error('Invalid parameter: ' + bytes);\n};\n\n/**\n * Puts the given buffer into this buffer.\n *\n * @param buffer the buffer to put into this one.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putBuffer = function(buffer) {\n this.putBytes(buffer);\n buffer.clear();\n return this;\n};\n\n/**\n * Puts a string into this buffer.\n *\n * @param str the string to put.\n * @param [encoding] the encoding for the string (default: 'utf16').\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putString = function(str) {\n return this.putBytes(str, 'utf16');\n};\n\n/**\n * Puts a 16-bit integer in this buffer in big-endian order.\n *\n * @param i the 16-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt16 = function(i) {\n this.accommodate(2);\n this.data.setInt16(this.write, i);\n this.write += 2;\n return this;\n};\n\n/**\n * Puts a 24-bit integer in this buffer in big-endian order.\n *\n * @param i the 24-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt24 = function(i) {\n this.accommodate(3);\n this.data.setInt16(this.write, i >> 8 & 0xFFFF);\n this.data.setInt8(this.write, i >> 16 & 0xFF);\n this.write += 3;\n return this;\n};\n\n/**\n * Puts a 32-bit integer in this buffer in big-endian order.\n *\n * @param i the 32-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt32 = function(i) {\n this.accommodate(4);\n this.data.setInt32(this.write, i);\n this.write += 4;\n return this;\n};\n\n/**\n * Puts a 16-bit integer in this buffer in little-endian order.\n *\n * @param i the 16-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt16Le = function(i) {\n this.accommodate(2);\n this.data.setInt16(this.write, i, true);\n this.write += 2;\n return this;\n};\n\n/**\n * Puts a 24-bit integer in this buffer in little-endian order.\n *\n * @param i the 24-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt24Le = function(i) {\n this.accommodate(3);\n this.data.setInt8(this.write, i >> 16 & 0xFF);\n this.data.setInt16(this.write, i >> 8 & 0xFFFF, true);\n this.write += 3;\n return this;\n};\n\n/**\n * Puts a 32-bit integer in this buffer in little-endian order.\n *\n * @param i the 32-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt32Le = function(i) {\n this.accommodate(4);\n this.data.setInt32(this.write, i, true);\n this.write += 4;\n return this;\n};\n\n/**\n * Puts an n-bit integer in this buffer in big-endian order.\n *\n * @param i the n-bit integer.\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt = function(i, n) {\n _checkBitsParam(n);\n this.accommodate(n / 8);\n do {\n n -= 8;\n this.data.setInt8(this.write++, (i >> n) & 0xFF);\n } while(n > 0);\n return this;\n};\n\n/**\n * Puts a signed n-bit integer in this buffer in big-endian order. Two's\n * complement representation is used.\n *\n * @param i the n-bit integer.\n * @param n the number of bits in the integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putSignedInt = function(i, n) {\n _checkBitsParam(n);\n this.accommodate(n / 8);\n if(i < 0) {\n i += 2 << (n - 1);\n }\n return this.putInt(i, n);\n};\n\n/**\n * Gets a byte from this buffer and advances the read pointer by 1.\n *\n * @return the byte.\n */\nutil.DataBuffer.prototype.getByte = function() {\n return this.data.getInt8(this.read++);\n};\n\n/**\n * Gets a uint16 from this buffer in big-endian order and advances the read\n * pointer by 2.\n *\n * @return the uint16.\n */\nutil.DataBuffer.prototype.getInt16 = function() {\n var rval = this.data.getInt16(this.read);\n this.read += 2;\n return rval;\n};\n\n/**\n * Gets a uint24 from this buffer in big-endian order and advances the read\n * pointer by 3.\n *\n * @return the uint24.\n */\nutil.DataBuffer.prototype.getInt24 = function() {\n var rval = (\n this.data.getInt16(this.read) << 8 ^\n this.data.getInt8(this.read + 2));\n this.read += 3;\n return rval;\n};\n\n/**\n * Gets a uint32 from this buffer in big-endian order and advances the read\n * pointer by 4.\n *\n * @return the word.\n */\nutil.DataBuffer.prototype.getInt32 = function() {\n var rval = this.data.getInt32(this.read);\n this.read += 4;\n return rval;\n};\n\n/**\n * Gets a uint16 from this buffer in little-endian order and advances the read\n * pointer by 2.\n *\n * @return the uint16.\n */\nutil.DataBuffer.prototype.getInt16Le = function() {\n var rval = this.data.getInt16(this.read, true);\n this.read += 2;\n return rval;\n};\n\n/**\n * Gets a uint24 from this buffer in little-endian order and advances the read\n * pointer by 3.\n *\n * @return the uint24.\n */\nutil.DataBuffer.prototype.getInt24Le = function() {\n var rval = (\n this.data.getInt8(this.read) ^\n this.data.getInt16(this.read + 1, true) << 8);\n this.read += 3;\n return rval;\n};\n\n/**\n * Gets a uint32 from this buffer in little-endian order and advances the read\n * pointer by 4.\n *\n * @return the word.\n */\nutil.DataBuffer.prototype.getInt32Le = function() {\n var rval = this.data.getInt32(this.read, true);\n this.read += 4;\n return rval;\n};\n\n/**\n * Gets an n-bit integer from this buffer in big-endian order and advances the\n * read pointer by n/8.\n *\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return the integer.\n */\nutil.DataBuffer.prototype.getInt = function(n) {\n _checkBitsParam(n);\n var rval = 0;\n do {\n // TODO: Use (rval * 0x100) if adding support for 33 to 53 bits.\n rval = (rval << 8) + this.data.getInt8(this.read++);\n n -= 8;\n } while(n > 0);\n return rval;\n};\n\n/**\n * Gets a signed n-bit integer from this buffer in big-endian order, using\n * two's complement, and advances the read pointer by n/8.\n *\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return the integer.\n */\nutil.DataBuffer.prototype.getSignedInt = function(n) {\n // getInt checks n\n var x = this.getInt(n);\n var max = 2 << (n - 2);\n if(x >= max) {\n x -= max << 1;\n }\n return x;\n};\n\n/**\n * Reads bytes out as a binary encoded string and clears them from the\n * buffer.\n *\n * @param count the number of bytes to read, undefined or null for all.\n *\n * @return a binary encoded string of bytes.\n */\nutil.DataBuffer.prototype.getBytes = function(count) {\n // TODO: deprecate this method, it is poorly named and\n // this.toString('binary') replaces it\n // add a toTypedArray()/toArrayBuffer() function\n var rval;\n if(count) {\n // read count bytes\n count = Math.min(this.length(), count);\n rval = this.data.slice(this.read, this.read + count);\n this.read += count;\n } else if(count === 0) {\n rval = '';\n } else {\n // read all bytes, optimize to only copy when needed\n rval = (this.read === 0) ? this.data : this.data.slice(this.read);\n this.clear();\n }\n return rval;\n};\n\n/**\n * Gets a binary encoded string of the bytes from this buffer without\n * modifying the read pointer.\n *\n * @param count the number of bytes to get, omit to get all.\n *\n * @return a string full of binary encoded characters.\n */\nutil.DataBuffer.prototype.bytes = function(count) {\n // TODO: deprecate this method, it is poorly named, add \"getString()\"\n return (typeof(count) === 'undefined' ?\n this.data.slice(this.read) :\n this.data.slice(this.read, this.read + count));\n};\n\n/**\n * Gets a byte at the given index without modifying the read pointer.\n *\n * @param i the byte index.\n *\n * @return the byte.\n */\nutil.DataBuffer.prototype.at = function(i) {\n return this.data.getUint8(this.read + i);\n};\n\n/**\n * Puts a byte at the given index without modifying the read pointer.\n *\n * @param i the byte index.\n * @param b the byte to put.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.setAt = function(i, b) {\n this.data.setUint8(i, b);\n return this;\n};\n\n/**\n * Gets the last byte without modifying the read pointer.\n *\n * @return the last byte.\n */\nutil.DataBuffer.prototype.last = function() {\n return this.data.getUint8(this.write - 1);\n};\n\n/**\n * Creates a copy of this buffer.\n *\n * @return the copy.\n */\nutil.DataBuffer.prototype.copy = function() {\n return new util.DataBuffer(this);\n};\n\n/**\n * Compacts this buffer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.compact = function() {\n if(this.read > 0) {\n var src = new Uint8Array(this.data.buffer, this.read);\n var dst = new Uint8Array(src.byteLength);\n dst.set(src);\n this.data = new DataView(dst);\n this.write -= this.read;\n this.read = 0;\n }\n return this;\n};\n\n/**\n * Clears this buffer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.clear = function() {\n this.data = new DataView(new ArrayBuffer(0));\n this.read = this.write = 0;\n return this;\n};\n\n/**\n * Shortens this buffer by triming bytes off of the end of this buffer.\n *\n * @param count the number of bytes to trim off.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.truncate = function(count) {\n this.write = Math.max(0, this.length() - count);\n this.read = Math.min(this.read, this.write);\n return this;\n};\n\n/**\n * Converts this buffer to a hexadecimal string.\n *\n * @return a hexadecimal string.\n */\nutil.DataBuffer.prototype.toHex = function() {\n var rval = '';\n for(var i = this.read; i < this.data.byteLength; ++i) {\n var b = this.data.getUint8(i);\n if(b < 16) {\n rval += '0';\n }\n rval += b.toString(16);\n }\n return rval;\n};\n\n/**\n * Converts this buffer to a string, using the given encoding. If no\n * encoding is given, 'utf8' (UTF-8) is used.\n *\n * @param [encoding] the encoding to use: 'binary', 'utf8', 'utf16', 'hex',\n * 'base64' (default: 'utf8').\n *\n * @return a string representation of the bytes in this buffer.\n */\nutil.DataBuffer.prototype.toString = function(encoding) {\n var view = new Uint8Array(this.data, this.read, this.length());\n encoding = encoding || 'utf8';\n\n // encode to string\n if(encoding === 'binary' || encoding === 'raw') {\n return util.binary.raw.encode(view);\n }\n if(encoding === 'hex') {\n return util.binary.hex.encode(view);\n }\n if(encoding === 'base64') {\n return util.binary.base64.encode(view);\n }\n\n // decode to text\n if(encoding === 'utf8') {\n return util.text.utf8.decode(view);\n }\n if(encoding === 'utf16') {\n return util.text.utf16.decode(view);\n }\n\n throw new Error('Invalid encoding: ' + encoding);\n};\n\n/** End Buffer w/UInt8Array backing */\n\n/**\n * Creates a buffer that stores bytes. A value may be given to populate the\n * buffer with data. This value can either be string of encoded bytes or a\n * regular string of characters. When passing a string of binary encoded\n * bytes, the encoding `raw` should be given. This is also the default. When\n * passing a string of characters, the encoding `utf8` should be given.\n *\n * @param [input] a string with encoded bytes to store in the buffer.\n * @param [encoding] (default: 'raw', other: 'utf8').\n */\nutil.createBuffer = function(input, encoding) {\n // TODO: deprecate, use new ByteBuffer() instead\n encoding = encoding || 'raw';\n if(input !== undefined && encoding === 'utf8') {\n input = util.encodeUtf8(input);\n }\n return new util.ByteBuffer(input);\n};\n\n/**\n * Fills a string with a particular value. If you want the string to be a byte\n * string, pass in String.fromCharCode(theByte).\n *\n * @param c the character to fill the string with, use String.fromCharCode\n * to fill the string with a byte value.\n * @param n the number of characters of value c to fill with.\n *\n * @return the filled string.\n */\nutil.fillString = function(c, n) {\n var s = '';\n while(n > 0) {\n if(n & 1) {\n s += c;\n }\n n >>>= 1;\n if(n > 0) {\n c += c;\n }\n }\n return s;\n};\n\n/**\n * Performs a per byte XOR between two byte strings and returns the result as a\n * string of bytes.\n *\n * @param s1 first string of bytes.\n * @param s2 second string of bytes.\n * @param n the number of bytes to XOR.\n *\n * @return the XOR'd result.\n */\nutil.xorBytes = function(s1, s2, n) {\n var s3 = '';\n var b = '';\n var t = '';\n var i = 0;\n var c = 0;\n for(; n > 0; --n, ++i) {\n b = s1.charCodeAt(i) ^ s2.charCodeAt(i);\n if(c >= 10) {\n s3 += t;\n t = '';\n c = 0;\n }\n t += String.fromCharCode(b);\n ++c;\n }\n s3 += t;\n return s3;\n};\n\n/**\n * Converts a hex string into a 'binary' encoded string of bytes.\n *\n * @param hex the hexadecimal string to convert.\n *\n * @return the binary-encoded string of bytes.\n */\nutil.hexToBytes = function(hex) {\n // TODO: deprecate: \"Deprecated. Use util.binary.hex.decode instead.\"\n var rval = '';\n var i = 0;\n if(hex.length & 1 == 1) {\n // odd number of characters, convert first character alone\n i = 1;\n rval += String.fromCharCode(parseInt(hex[0], 16));\n }\n // convert 2 characters (1 byte) at a time\n for(; i < hex.length; i += 2) {\n rval += String.fromCharCode(parseInt(hex.substr(i, 2), 16));\n }\n return rval;\n};\n\n/**\n * Converts a 'binary' encoded string of bytes to hex.\n *\n * @param bytes the byte string to convert.\n *\n * @return the string of hexadecimal characters.\n */\nutil.bytesToHex = function(bytes) {\n // TODO: deprecate: \"Deprecated. Use util.binary.hex.encode instead.\"\n return util.createBuffer(bytes).toHex();\n};\n\n/**\n * Converts an 32-bit integer to 4-big-endian byte string.\n *\n * @param i the integer.\n *\n * @return the byte string.\n */\nutil.int32ToBytes = function(i) {\n return (\n String.fromCharCode(i >> 24 & 0xFF) +\n String.fromCharCode(i >> 16 & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i & 0xFF));\n};\n\n// base64 characters, reverse mapping\nvar _base64 =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\nvar _base64Idx = [\n/*43 -43 = 0*/\n/*'+', 1, 2, 3,'/' */\n 62, -1, -1, -1, 63,\n\n/*'0','1','2','3','4','5','6','7','8','9' */\n 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n\n/*15, 16, 17,'=', 19, 20, 21 */\n -1, -1, -1, 64, -1, -1, -1,\n\n/*65 - 43 = 22*/\n/*'A','B','C','D','E','F','G','H','I','J','K','L','M', */\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\n\n/*'N','O','P','Q','R','S','T','U','V','W','X','Y','Z' */\n 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,\n\n/*91 - 43 = 48 */\n/*48, 49, 50, 51, 52, 53 */\n -1, -1, -1, -1, -1, -1,\n\n/*97 - 43 = 54*/\n/*'a','b','c','d','e','f','g','h','i','j','k','l','m' */\n 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,\n\n/*'n','o','p','q','r','s','t','u','v','w','x','y','z' */\n 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51\n];\n\n// base58 characters (Bitcoin alphabet)\nvar _base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n\n/**\n * Base64 encodes a 'binary' encoded string of bytes.\n *\n * @param input the binary encoded string of bytes to base64-encode.\n * @param maxline the maximum number of encoded characters per line to use,\n * defaults to none.\n *\n * @return the base64-encoded output.\n */\nutil.encode64 = function(input, maxline) {\n // TODO: deprecate: \"Deprecated. Use util.binary.base64.encode instead.\"\n var line = '';\n var output = '';\n var chr1, chr2, chr3;\n var i = 0;\n while(i < input.length) {\n chr1 = input.charCodeAt(i++);\n chr2 = input.charCodeAt(i++);\n chr3 = input.charCodeAt(i++);\n\n // encode 4 character group\n line += _base64.charAt(chr1 >> 2);\n line += _base64.charAt(((chr1 & 3) << 4) | (chr2 >> 4));\n if(isNaN(chr2)) {\n line += '==';\n } else {\n line += _base64.charAt(((chr2 & 15) << 2) | (chr3 >> 6));\n line += isNaN(chr3) ? '=' : _base64.charAt(chr3 & 63);\n }\n\n if(maxline && line.length > maxline) {\n output += line.substr(0, maxline) + '\\r\\n';\n line = line.substr(maxline);\n }\n }\n output += line;\n return output;\n};\n\n/**\n * Base64 decodes a string into a 'binary' encoded string of bytes.\n *\n * @param input the base64-encoded input.\n *\n * @return the binary encoded string.\n */\nutil.decode64 = function(input) {\n // TODO: deprecate: \"Deprecated. Use util.binary.base64.decode instead.\"\n\n // remove all non-base64 characters\n input = input.replace(/[^A-Za-z0-9\\+\\/\\=]/g, '');\n\n var output = '';\n var enc1, enc2, enc3, enc4;\n var i = 0;\n\n while(i < input.length) {\n enc1 = _base64Idx[input.charCodeAt(i++) - 43];\n enc2 = _base64Idx[input.charCodeAt(i++) - 43];\n enc3 = _base64Idx[input.charCodeAt(i++) - 43];\n enc4 = _base64Idx[input.charCodeAt(i++) - 43];\n\n output += String.fromCharCode((enc1 << 2) | (enc2 >> 4));\n if(enc3 !== 64) {\n // decoded at least 2 bytes\n output += String.fromCharCode(((enc2 & 15) << 4) | (enc3 >> 2));\n if(enc4 !== 64) {\n // decoded 3 bytes\n output += String.fromCharCode(((enc3 & 3) << 6) | enc4);\n }\n }\n }\n\n return output;\n};\n\n/**\n * Encodes the given string of characters (a standard JavaScript\n * string) as a binary encoded string where the bytes represent\n * a UTF-8 encoded string of characters. Non-ASCII characters will be\n * encoded as multiple bytes according to UTF-8.\n *\n * @param str a standard string of characters to encode.\n *\n * @return the binary encoded string.\n */\nutil.encodeUtf8 = function(str) {\n return unescape(encodeURIComponent(str));\n};\n\n/**\n * Decodes a binary encoded string that contains bytes that\n * represent a UTF-8 encoded string of characters -- into a\n * string of characters (a standard JavaScript string).\n *\n * @param str the binary encoded string to decode.\n *\n * @return the resulting standard string of characters.\n */\nutil.decodeUtf8 = function(str) {\n return decodeURIComponent(escape(str));\n};\n\n// binary encoding/decoding tools\n// FIXME: Experimental. Do not use yet.\nutil.binary = {\n raw: {},\n hex: {},\n base64: {},\n base58: {},\n baseN : {\n encode: baseN.encode,\n decode: baseN.decode\n }\n};\n\n/**\n * Encodes a Uint8Array as a binary-encoded string. This encoding uses\n * a value between 0 and 255 for each character.\n *\n * @param bytes the Uint8Array to encode.\n *\n * @return the binary-encoded string.\n */\nutil.binary.raw.encode = function(bytes) {\n return String.fromCharCode.apply(null, bytes);\n};\n\n/**\n * Decodes a binary-encoded string to a Uint8Array. This encoding uses\n * a value between 0 and 255 for each character.\n *\n * @param str the binary-encoded string to decode.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.binary.raw.decode = function(str, output, offset) {\n var out = output;\n if(!out) {\n out = new Uint8Array(str.length);\n }\n offset = offset || 0;\n var j = offset;\n for(var i = 0; i < str.length; ++i) {\n out[j++] = str.charCodeAt(i);\n }\n return output ? (j - offset) : out;\n};\n\n/**\n * Encodes a 'binary' string, ArrayBuffer, DataView, TypedArray, or\n * ByteBuffer as a string of hexadecimal characters.\n *\n * @param bytes the bytes to convert.\n *\n * @return the string of hexadecimal characters.\n */\nutil.binary.hex.encode = util.bytesToHex;\n\n/**\n * Decodes a hex-encoded string to a Uint8Array.\n *\n * @param hex the hexadecimal string to convert.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.binary.hex.decode = function(hex, output, offset) {\n var out = output;\n if(!out) {\n out = new Uint8Array(Math.ceil(hex.length / 2));\n }\n offset = offset || 0;\n var i = 0, j = offset;\n if(hex.length & 1) {\n // odd number of characters, convert first character alone\n i = 1;\n out[j++] = parseInt(hex[0], 16);\n }\n // convert 2 characters (1 byte) at a time\n for(; i < hex.length; i += 2) {\n out[j++] = parseInt(hex.substr(i, 2), 16);\n }\n return output ? (j - offset) : out;\n};\n\n/**\n * Base64-encodes a Uint8Array.\n *\n * @param input the Uint8Array to encode.\n * @param maxline the maximum number of encoded characters per line to use,\n * defaults to none.\n *\n * @return the base64-encoded output string.\n */\nutil.binary.base64.encode = function(input, maxline) {\n var line = '';\n var output = '';\n var chr1, chr2, chr3;\n var i = 0;\n while(i < input.byteLength) {\n chr1 = input[i++];\n chr2 = input[i++];\n chr3 = input[i++];\n\n // encode 4 character group\n line += _base64.charAt(chr1 >> 2);\n line += _base64.charAt(((chr1 & 3) << 4) | (chr2 >> 4));\n if(isNaN(chr2)) {\n line += '==';\n } else {\n line += _base64.charAt(((chr2 & 15) << 2) | (chr3 >> 6));\n line += isNaN(chr3) ? '=' : _base64.charAt(chr3 & 63);\n }\n\n if(maxline && line.length > maxline) {\n output += line.substr(0, maxline) + '\\r\\n';\n line = line.substr(maxline);\n }\n }\n output += line;\n return output;\n};\n\n/**\n * Decodes a base64-encoded string to a Uint8Array.\n *\n * @param input the base64-encoded input string.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.binary.base64.decode = function(input, output, offset) {\n var out = output;\n if(!out) {\n out = new Uint8Array(Math.ceil(input.length / 4) * 3);\n }\n\n // remove all non-base64 characters\n input = input.replace(/[^A-Za-z0-9\\+\\/\\=]/g, '');\n\n offset = offset || 0;\n var enc1, enc2, enc3, enc4;\n var i = 0, j = offset;\n\n while(i < input.length) {\n enc1 = _base64Idx[input.charCodeAt(i++) - 43];\n enc2 = _base64Idx[input.charCodeAt(i++) - 43];\n enc3 = _base64Idx[input.charCodeAt(i++) - 43];\n enc4 = _base64Idx[input.charCodeAt(i++) - 43];\n\n out[j++] = (enc1 << 2) | (enc2 >> 4);\n if(enc3 !== 64) {\n // decoded at least 2 bytes\n out[j++] = ((enc2 & 15) << 4) | (enc3 >> 2);\n if(enc4 !== 64) {\n // decoded 3 bytes\n out[j++] = ((enc3 & 3) << 6) | enc4;\n }\n }\n }\n\n // make sure result is the exact decoded length\n return output ? (j - offset) : out.subarray(0, j);\n};\n\n// add support for base58 encoding/decoding with Bitcoin alphabet\nutil.binary.base58.encode = function(input, maxline) {\n return util.binary.baseN.encode(input, _base58, maxline);\n};\nutil.binary.base58.decode = function(input, maxline) {\n return util.binary.baseN.decode(input, _base58, maxline);\n};\n\n// text encoding/decoding tools\n// FIXME: Experimental. Do not use yet.\nutil.text = {\n utf8: {},\n utf16: {}\n};\n\n/**\n * Encodes the given string as UTF-8 in a Uint8Array.\n *\n * @param str the string to encode.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.text.utf8.encode = function(str, output, offset) {\n str = util.encodeUtf8(str);\n var out = output;\n if(!out) {\n out = new Uint8Array(str.length);\n }\n offset = offset || 0;\n var j = offset;\n for(var i = 0; i < str.length; ++i) {\n out[j++] = str.charCodeAt(i);\n }\n return output ? (j - offset) : out;\n};\n\n/**\n * Decodes the UTF-8 contents from a Uint8Array.\n *\n * @param bytes the Uint8Array to decode.\n *\n * @return the resulting string.\n */\nutil.text.utf8.decode = function(bytes) {\n return util.decodeUtf8(String.fromCharCode.apply(null, bytes));\n};\n\n/**\n * Encodes the given string as UTF-16 in a Uint8Array.\n *\n * @param str the string to encode.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.text.utf16.encode = function(str, output, offset) {\n var out = output;\n if(!out) {\n out = new Uint8Array(str.length * 2);\n }\n var view = new Uint16Array(out.buffer);\n offset = offset || 0;\n var j = offset;\n var k = offset;\n for(var i = 0; i < str.length; ++i) {\n view[k++] = str.charCodeAt(i);\n j += 2;\n }\n return output ? (j - offset) : out;\n};\n\n/**\n * Decodes the UTF-16 contents from a Uint8Array.\n *\n * @param bytes the Uint8Array to decode.\n *\n * @return the resulting string.\n */\nutil.text.utf16.decode = function(bytes) {\n return String.fromCharCode.apply(null, new Uint16Array(bytes.buffer));\n};\n\n/**\n * Deflates the given data using a flash interface.\n *\n * @param api the flash interface.\n * @param bytes the data.\n * @param raw true to return only raw deflate data, false to include zlib\n * header and trailer.\n *\n * @return the deflated data as a string.\n */\nutil.deflate = function(api, bytes, raw) {\n bytes = util.decode64(api.deflate(util.encode64(bytes)).rval);\n\n // strip zlib header and trailer if necessary\n if(raw) {\n // zlib header is 2 bytes (CMF,FLG) where FLG indicates that\n // there is a 4-byte DICT (alder-32) block before the data if\n // its 5th bit is set\n var start = 2;\n var flg = bytes.charCodeAt(1);\n if(flg & 0x20) {\n start = 6;\n }\n // zlib trailer is 4 bytes of adler-32\n bytes = bytes.substring(start, bytes.length - 4);\n }\n\n return bytes;\n};\n\n/**\n * Inflates the given data using a flash interface.\n *\n * @param api the flash interface.\n * @param bytes the data.\n * @param raw true if the incoming data has no zlib header or trailer and is\n * raw DEFLATE data.\n *\n * @return the inflated data as a string, null on error.\n */\nutil.inflate = function(api, bytes, raw) {\n // TODO: add zlib header and trailer if necessary/possible\n var rval = api.inflate(util.encode64(bytes)).rval;\n return (rval === null) ? null : util.decode64(rval);\n};\n\n/**\n * Sets a storage object.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n * @param obj the storage object, null to remove.\n */\nvar _setStorageObject = function(api, id, obj) {\n if(!api) {\n throw new Error('WebStorage not available.');\n }\n\n var rval;\n if(obj === null) {\n rval = api.removeItem(id);\n } else {\n // json-encode and base64-encode object\n obj = util.encode64(JSON.stringify(obj));\n rval = api.setItem(id, obj);\n }\n\n // handle potential flash error\n if(typeof(rval) !== 'undefined' && rval.rval !== true) {\n var error = new Error(rval.error.message);\n error.id = rval.error.id;\n error.name = rval.error.name;\n throw error;\n }\n};\n\n/**\n * Gets a storage object.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n *\n * @return the storage object entry or null if none exists.\n */\nvar _getStorageObject = function(api, id) {\n if(!api) {\n throw new Error('WebStorage not available.');\n }\n\n // get the existing entry\n var rval = api.getItem(id);\n\n /* Note: We check api.init because we can't do (api == localStorage)\n on IE because of \"Class doesn't support Automation\" exception. Only\n the flash api has an init method so this works too, but we need a\n better solution in the future. */\n\n // flash returns item wrapped in an object, handle special case\n if(api.init) {\n if(rval.rval === null) {\n if(rval.error) {\n var error = new Error(rval.error.message);\n error.id = rval.error.id;\n error.name = rval.error.name;\n throw error;\n }\n // no error, but also no item\n rval = null;\n } else {\n rval = rval.rval;\n }\n }\n\n // handle decoding\n if(rval !== null) {\n // base64-decode and json-decode data\n rval = JSON.parse(util.decode64(rval));\n }\n\n return rval;\n};\n\n/**\n * Stores an item in local storage.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n * @param key the key for the item.\n * @param data the data for the item (any javascript object/primitive).\n */\nvar _setItem = function(api, id, key, data) {\n // get storage object\n var obj = _getStorageObject(api, id);\n if(obj === null) {\n // create a new storage object\n obj = {};\n }\n // update key\n obj[key] = data;\n\n // set storage object\n _setStorageObject(api, id, obj);\n};\n\n/**\n * Gets an item from local storage.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n * @param key the key for the item.\n *\n * @return the item.\n */\nvar _getItem = function(api, id, key) {\n // get storage object\n var rval = _getStorageObject(api, id);\n if(rval !== null) {\n // return data at key\n rval = (key in rval) ? rval[key] : null;\n }\n\n return rval;\n};\n\n/**\n * Removes an item from local storage.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n * @param key the key for the item.\n */\nvar _removeItem = function(api, id, key) {\n // get storage object\n var obj = _getStorageObject(api, id);\n if(obj !== null && key in obj) {\n // remove key\n delete obj[key];\n\n // see if entry has no keys remaining\n var empty = true;\n for(var prop in obj) {\n empty = false;\n break;\n }\n if(empty) {\n // remove entry entirely if no keys are left\n obj = null;\n }\n\n // set storage object\n _setStorageObject(api, id, obj);\n }\n};\n\n/**\n * Clears the local disk storage identified by the given ID.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n */\nvar _clearItems = function(api, id) {\n _setStorageObject(api, id, null);\n};\n\n/**\n * Calls a storage function.\n *\n * @param func the function to call.\n * @param args the arguments for the function.\n * @param location the location argument.\n *\n * @return the return value from the function.\n */\nvar _callStorageFunction = function(func, args, location) {\n var rval = null;\n\n // default storage types\n if(typeof(location) === 'undefined') {\n location = ['web', 'flash'];\n }\n\n // apply storage types in order of preference\n var type;\n var done = false;\n var exception = null;\n for(var idx in location) {\n type = location[idx];\n try {\n if(type === 'flash' || type === 'both') {\n if(args[0] === null) {\n throw new Error('Flash local storage not available.');\n }\n rval = func.apply(this, args);\n done = (type === 'flash');\n }\n if(type === 'web' || type === 'both') {\n args[0] = localStorage;\n rval = func.apply(this, args);\n done = true;\n }\n } catch(ex) {\n exception = ex;\n }\n if(done) {\n break;\n }\n }\n\n if(!done) {\n throw exception;\n }\n\n return rval;\n};\n\n/**\n * Stores an item on local disk.\n *\n * The available types of local storage include 'flash', 'web', and 'both'.\n *\n * The type 'flash' refers to flash local storage (SharedObject). In order\n * to use flash local storage, the 'api' parameter must be valid. The type\n * 'web' refers to WebStorage, if supported by the browser. The type 'both'\n * refers to storing using both 'flash' and 'web', not just one or the\n * other.\n *\n * The location array should list the storage types to use in order of\n * preference:\n *\n * ['flash']: flash only storage\n * ['web']: web only storage\n * ['both']: try to store in both\n * ['flash','web']: store in flash first, but if not available, 'web'\n * ['web','flash']: store in web first, but if not available, 'flash'\n *\n * The location array defaults to: ['web', 'flash']\n *\n * @param api the flash interface, null to use only WebStorage.\n * @param id the storage ID to use.\n * @param key the key for the item.\n * @param data the data for the item (any javascript object/primitive).\n * @param location an array with the preferred types of storage to use.\n */\nutil.setItem = function(api, id, key, data, location) {\n _callStorageFunction(_setItem, arguments, location);\n};\n\n/**\n * Gets an item on local disk.\n *\n * Set setItem() for details on storage types.\n *\n * @param api the flash interface, null to use only WebStorage.\n * @param id the storage ID to use.\n * @param key the key for the item.\n * @param location an array with the preferred types of storage to use.\n *\n * @return the item.\n */\nutil.getItem = function(api, id, key, location) {\n return _callStorageFunction(_getItem, arguments, location);\n};\n\n/**\n * Removes an item on local disk.\n *\n * Set setItem() for details on storage types.\n *\n * @param api the flash interface.\n * @param id the storage ID to use.\n * @param key the key for the item.\n * @param location an array with the preferred types of storage to use.\n */\nutil.removeItem = function(api, id, key, location) {\n _callStorageFunction(_removeItem, arguments, location);\n};\n\n/**\n * Clears the local disk storage identified by the given ID.\n *\n * Set setItem() for details on storage types.\n *\n * @param api the flash interface if flash is available.\n * @param id the storage ID to use.\n * @param location an array with the preferred types of storage to use.\n */\nutil.clearItems = function(api, id, location) {\n _callStorageFunction(_clearItems, arguments, location);\n};\n\n/**\n * Parses the scheme, host, and port from an http(s) url.\n *\n * @param str the url string.\n *\n * @return the parsed url object or null if the url is invalid.\n */\nutil.parseUrl = function(str) {\n // FIXME: this regex looks a bit broken\n var regex = /^(https?):\\/\\/([^:&^\\/]*):?(\\d*)(.*)$/g;\n regex.lastIndex = 0;\n var m = regex.exec(str);\n var url = (m === null) ? null : {\n full: str,\n scheme: m[1],\n host: m[2],\n port: m[3],\n path: m[4]\n };\n if(url) {\n url.fullHost = url.host;\n if(url.port) {\n if(url.port !== 80 && url.scheme === 'http') {\n url.fullHost += ':' + url.port;\n } else if(url.port !== 443 && url.scheme === 'https') {\n url.fullHost += ':' + url.port;\n }\n } else if(url.scheme === 'http') {\n url.port = 80;\n } else if(url.scheme === 'https') {\n url.port = 443;\n }\n url.full = url.scheme + '://' + url.fullHost;\n }\n return url;\n};\n\n/* Storage for query variables */\nvar _queryVariables = null;\n\n/**\n * Returns the window location query variables. Query is parsed on the first\n * call and the same object is returned on subsequent calls. The mapping\n * is from keys to an array of values. Parameters without values will have\n * an object key set but no value added to the value array. Values are\n * unescaped.\n *\n * ...?k1=v1&k2=v2:\n * {\n * \"k1\": [\"v1\"],\n * \"k2\": [\"v2\"]\n * }\n *\n * ...?k1=v1&k1=v2:\n * {\n * \"k1\": [\"v1\", \"v2\"]\n * }\n *\n * ...?k1=v1&k2:\n * {\n * \"k1\": [\"v1\"],\n * \"k2\": []\n * }\n *\n * ...?k1=v1&k1:\n * {\n * \"k1\": [\"v1\"]\n * }\n *\n * ...?k1&k1:\n * {\n * \"k1\": []\n * }\n *\n * @param query the query string to parse (optional, default to cached\n * results from parsing window location search query).\n *\n * @return object mapping keys to variables.\n */\nutil.getQueryVariables = function(query) {\n var parse = function(q) {\n var rval = {};\n var kvpairs = q.split('&');\n for(var i = 0; i < kvpairs.length; i++) {\n var pos = kvpairs[i].indexOf('=');\n var key;\n var val;\n if(pos > 0) {\n key = kvpairs[i].substring(0, pos);\n val = kvpairs[i].substring(pos + 1);\n } else {\n key = kvpairs[i];\n val = null;\n }\n if(!(key in rval)) {\n rval[key] = [];\n }\n // disallow overriding object prototype keys\n if(!(key in Object.prototype) && val !== null) {\n rval[key].push(unescape(val));\n }\n }\n return rval;\n };\n\n var rval;\n if(typeof(query) === 'undefined') {\n // set cached variables if needed\n if(_queryVariables === null) {\n if(typeof(window) !== 'undefined' && window.location && window.location.search) {\n // parse window search query\n _queryVariables = parse(window.location.search.substring(1));\n } else {\n // no query variables available\n _queryVariables = {};\n }\n }\n rval = _queryVariables;\n } else {\n // parse given query\n rval = parse(query);\n }\n return rval;\n};\n\n/**\n * Parses a fragment into a path and query. This method will take a URI\n * fragment and break it up as if it were the main URI. For example:\n * /bar/baz?a=1&b=2\n * results in:\n * {\n * path: [\"bar\", \"baz\"],\n * query: {\"k1\": [\"v1\"], \"k2\": [\"v2\"]}\n * }\n *\n * @return object with a path array and query object.\n */\nutil.parseFragment = function(fragment) {\n // default to whole fragment\n var fp = fragment;\n var fq = '';\n // split into path and query if possible at the first '?'\n var pos = fragment.indexOf('?');\n if(pos > 0) {\n fp = fragment.substring(0, pos);\n fq = fragment.substring(pos + 1);\n }\n // split path based on '/' and ignore first element if empty\n var path = fp.split('/');\n if(path.length > 0 && path[0] === '') {\n path.shift();\n }\n // convert query into object\n var query = (fq === '') ? {} : util.getQueryVariables(fq);\n\n return {\n pathString: fp,\n queryString: fq,\n path: path,\n query: query\n };\n};\n\n/**\n * Makes a request out of a URI-like request string. This is intended to\n * be used where a fragment id (after a URI '#') is parsed as a URI with\n * path and query parts. The string should have a path beginning and\n * delimited by '/' and optional query parameters following a '?'. The\n * query should be a standard URL set of key value pairs delimited by\n * '&'. For backwards compatibility the initial '/' on the path is not\n * required. The request object has the following API, (fully described\n * in the method code):\n * {\n * path: .\n * query: ,\n * getPath(i): get part or all of the split path array,\n * getQuery(k, i): get part or all of a query key array,\n * getQueryLast(k, _default): get last element of a query key array.\n * }\n *\n * @return object with request parameters.\n */\nutil.makeRequest = function(reqString) {\n var frag = util.parseFragment(reqString);\n var req = {\n // full path string\n path: frag.pathString,\n // full query string\n query: frag.queryString,\n /**\n * Get path or element in path.\n *\n * @param i optional path index.\n *\n * @return path or part of path if i provided.\n */\n getPath: function(i) {\n return (typeof(i) === 'undefined') ? frag.path : frag.path[i];\n },\n /**\n * Get query, values for a key, or value for a key index.\n *\n * @param k optional query key.\n * @param i optional query key index.\n *\n * @return query, values for a key, or value for a key index.\n */\n getQuery: function(k, i) {\n var rval;\n if(typeof(k) === 'undefined') {\n rval = frag.query;\n } else {\n rval = frag.query[k];\n if(rval && typeof(i) !== 'undefined') {\n rval = rval[i];\n }\n }\n return rval;\n },\n getQueryLast: function(k, _default) {\n var rval;\n var vals = req.getQuery(k);\n if(vals) {\n rval = vals[vals.length - 1];\n } else {\n rval = _default;\n }\n return rval;\n }\n };\n return req;\n};\n\n/**\n * Makes a URI out of a path, an object with query parameters, and a\n * fragment. Uses jQuery.param() internally for query string creation.\n * If the path is an array, it will be joined with '/'.\n *\n * @param path string path or array of strings.\n * @param query object with query parameters. (optional)\n * @param fragment fragment string. (optional)\n *\n * @return string object with request parameters.\n */\nutil.makeLink = function(path, query, fragment) {\n // join path parts if needed\n path = jQuery.isArray(path) ? path.join('/') : path;\n\n var qstr = jQuery.param(query || {});\n fragment = fragment || '';\n return path +\n ((qstr.length > 0) ? ('?' + qstr) : '') +\n ((fragment.length > 0) ? ('#' + fragment) : '');\n};\n\n/**\n * Check if an object is empty.\n *\n * Taken from:\n * http://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object-from-json/679937#679937\n *\n * @param object the object to check.\n */\nutil.isEmpty = function(obj) {\n for(var prop in obj) {\n if(obj.hasOwnProperty(prop)) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * Format with simple printf-style interpolation.\n *\n * %%: literal '%'\n * %s,%o: convert next argument into a string.\n *\n * @param format the string to format.\n * @param ... arguments to interpolate into the format string.\n */\nutil.format = function(format) {\n var re = /%./g;\n // current match\n var match;\n // current part\n var part;\n // current arg index\n var argi = 0;\n // collected parts to recombine later\n var parts = [];\n // last index found\n var last = 0;\n // loop while matches remain\n while((match = re.exec(format))) {\n part = format.substring(last, re.lastIndex - 2);\n // don't add empty strings (ie, parts between %s%s)\n if(part.length > 0) {\n parts.push(part);\n }\n last = re.lastIndex;\n // switch on % code\n var code = match[0][1];\n switch(code) {\n case 's':\n case 'o':\n // check if enough arguments were given\n if(argi < arguments.length) {\n parts.push(arguments[argi++ + 1]);\n } else {\n parts.push('');\n }\n break;\n // FIXME: do proper formating for numbers, etc\n //case 'f':\n //case 'd':\n case '%':\n parts.push('%');\n break;\n default:\n parts.push('<%' + code + '?>');\n }\n }\n // add trailing part of format string\n parts.push(format.substring(last));\n return parts.join('');\n};\n\n/**\n * Formats a number.\n *\n * http://snipplr.com/view/5945/javascript-numberformat--ported-from-php/\n */\nutil.formatNumber = function(number, decimals, dec_point, thousands_sep) {\n // http://kevin.vanzonneveld.net\n // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)\n // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)\n // + bugfix by: Michael White (http://crestidg.com)\n // + bugfix by: Benjamin Lupton\n // + bugfix by: Allan Jensen (http://www.winternet.no)\n // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)\n // * example 1: number_format(1234.5678, 2, '.', '');\n // * returns 1: 1234.57\n\n var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;\n var d = dec_point === undefined ? ',' : dec_point;\n var t = thousands_sep === undefined ?\n '.' : thousands_sep, s = n < 0 ? '-' : '';\n var i = parseInt((n = Math.abs(+n || 0).toFixed(c)), 10) + '';\n var j = (i.length > 3) ? i.length % 3 : 0;\n return s + (j ? i.substr(0, j) + t : '') +\n i.substr(j).replace(/(\\d{3})(?=\\d)/g, '$1' + t) +\n (c ? d + Math.abs(n - i).toFixed(c).slice(2) : '');\n};\n\n/**\n * Formats a byte size.\n *\n * http://snipplr.com/view/5949/format-humanize-file-byte-size-presentation-in-javascript/\n */\nutil.formatSize = function(size) {\n if(size >= 1073741824) {\n size = util.formatNumber(size / 1073741824, 2, '.', '') + ' GiB';\n } else if(size >= 1048576) {\n size = util.formatNumber(size / 1048576, 2, '.', '') + ' MiB';\n } else if(size >= 1024) {\n size = util.formatNumber(size / 1024, 0) + ' KiB';\n } else {\n size = util.formatNumber(size, 0) + ' bytes';\n }\n return size;\n};\n\n/**\n * Converts an IPv4 or IPv6 string representation into bytes (in network order).\n *\n * @param ip the IPv4 or IPv6 address to convert.\n *\n * @return the 4-byte IPv6 or 16-byte IPv6 address or null if the address can't\n * be parsed.\n */\nutil.bytesFromIP = function(ip) {\n if(ip.indexOf('.') !== -1) {\n return util.bytesFromIPv4(ip);\n }\n if(ip.indexOf(':') !== -1) {\n return util.bytesFromIPv6(ip);\n }\n return null;\n};\n\n/**\n * Converts an IPv4 string representation into bytes (in network order).\n *\n * @param ip the IPv4 address to convert.\n *\n * @return the 4-byte address or null if the address can't be parsed.\n */\nutil.bytesFromIPv4 = function(ip) {\n ip = ip.split('.');\n if(ip.length !== 4) {\n return null;\n }\n var b = util.createBuffer();\n for(var i = 0; i < ip.length; ++i) {\n var num = parseInt(ip[i], 10);\n if(isNaN(num)) {\n return null;\n }\n b.putByte(num);\n }\n return b.getBytes();\n};\n\n/**\n * Converts an IPv6 string representation into bytes (in network order).\n *\n * @param ip the IPv6 address to convert.\n *\n * @return the 16-byte address or null if the address can't be parsed.\n */\nutil.bytesFromIPv6 = function(ip) {\n var blanks = 0;\n ip = ip.split(':').filter(function(e) {\n if(e.length === 0) ++blanks;\n return true;\n });\n var zeros = (8 - ip.length + blanks) * 2;\n var b = util.createBuffer();\n for(var i = 0; i < 8; ++i) {\n if(!ip[i] || ip[i].length === 0) {\n b.fillWithByte(0, zeros);\n zeros = 0;\n continue;\n }\n var bytes = util.hexToBytes(ip[i]);\n if(bytes.length < 2) {\n b.putByte(0);\n }\n b.putBytes(bytes);\n }\n return b.getBytes();\n};\n\n/**\n * Converts 4-bytes into an IPv4 string representation or 16-bytes into\n * an IPv6 string representation. The bytes must be in network order.\n *\n * @param bytes the bytes to convert.\n *\n * @return the IPv4 or IPv6 string representation if 4 or 16 bytes,\n * respectively, are given, otherwise null.\n */\nutil.bytesToIP = function(bytes) {\n if(bytes.length === 4) {\n return util.bytesToIPv4(bytes);\n }\n if(bytes.length === 16) {\n return util.bytesToIPv6(bytes);\n }\n return null;\n};\n\n/**\n * Converts 4-bytes into an IPv4 string representation. The bytes must be\n * in network order.\n *\n * @param bytes the bytes to convert.\n *\n * @return the IPv4 string representation or null for an invalid # of bytes.\n */\nutil.bytesToIPv4 = function(bytes) {\n if(bytes.length !== 4) {\n return null;\n }\n var ip = [];\n for(var i = 0; i < bytes.length; ++i) {\n ip.push(bytes.charCodeAt(i));\n }\n return ip.join('.');\n};\n\n/**\n * Converts 16-bytes into an IPv16 string representation. The bytes must be\n * in network order.\n *\n * @param bytes the bytes to convert.\n *\n * @return the IPv16 string representation or null for an invalid # of bytes.\n */\nutil.bytesToIPv6 = function(bytes) {\n if(bytes.length !== 16) {\n return null;\n }\n var ip = [];\n var zeroGroups = [];\n var zeroMaxGroup = 0;\n for(var i = 0; i < bytes.length; i += 2) {\n var hex = util.bytesToHex(bytes[i] + bytes[i + 1]);\n // canonicalize zero representation\n while(hex[0] === '0' && hex !== '0') {\n hex = hex.substr(1);\n }\n if(hex === '0') {\n var last = zeroGroups[zeroGroups.length - 1];\n var idx = ip.length;\n if(!last || idx !== last.end + 1) {\n zeroGroups.push({start: idx, end: idx});\n } else {\n last.end = idx;\n if((last.end - last.start) >\n (zeroGroups[zeroMaxGroup].end - zeroGroups[zeroMaxGroup].start)) {\n zeroMaxGroup = zeroGroups.length - 1;\n }\n }\n }\n ip.push(hex);\n }\n if(zeroGroups.length > 0) {\n var group = zeroGroups[zeroMaxGroup];\n // only shorten group of length > 0\n if(group.end - group.start > 0) {\n ip.splice(group.start, group.end - group.start + 1, '');\n if(group.start === 0) {\n ip.unshift('');\n }\n if(group.end === 7) {\n ip.push('');\n }\n }\n }\n return ip.join(':');\n};\n\n/**\n * Estimates the number of processes that can be run concurrently. If\n * creating Web Workers, keep in mind that the main JavaScript process needs\n * its own core.\n *\n * @param options the options to use:\n * update true to force an update (not use the cached value).\n * @param callback(err, max) called once the operation completes.\n */\nutil.estimateCores = function(options, callback) {\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n if('cores' in util && !options.update) {\n return callback(null, util.cores);\n }\n if(typeof navigator !== 'undefined' &&\n 'hardwareConcurrency' in navigator &&\n navigator.hardwareConcurrency > 0) {\n util.cores = navigator.hardwareConcurrency;\n return callback(null, util.cores);\n }\n if(typeof Worker === 'undefined') {\n // workers not available\n util.cores = 1;\n return callback(null, util.cores);\n }\n if(typeof Blob === 'undefined') {\n // can't estimate, default to 2\n util.cores = 2;\n return callback(null, util.cores);\n }\n\n // create worker concurrency estimation code as blob\n var blobUrl = URL.createObjectURL(new Blob(['(',\n function() {\n self.addEventListener('message', function(e) {\n // run worker for 4 ms\n var st = Date.now();\n var et = st + 4;\n while(Date.now() < et);\n self.postMessage({st: st, et: et});\n });\n }.toString(),\n ')()'], {type: 'application/javascript'}));\n\n // take 5 samples using 16 workers\n sample([], 5, 16);\n\n function sample(max, samples, numWorkers) {\n if(samples === 0) {\n // get overlap average\n var avg = Math.floor(max.reduce(function(avg, x) {\n return avg + x;\n }, 0) / max.length);\n util.cores = Math.max(1, avg);\n URL.revokeObjectURL(blobUrl);\n return callback(null, util.cores);\n }\n map(numWorkers, function(err, results) {\n max.push(reduce(numWorkers, results));\n sample(max, samples - 1, numWorkers);\n });\n }\n\n function map(numWorkers, callback) {\n var workers = [];\n var results = [];\n for(var i = 0; i < numWorkers; ++i) {\n var worker = new Worker(blobUrl);\n worker.addEventListener('message', function(e) {\n results.push(e.data);\n if(results.length === numWorkers) {\n for(var i = 0; i < numWorkers; ++i) {\n workers[i].terminate();\n }\n callback(null, results);\n }\n });\n workers.push(worker);\n }\n for(var i = 0; i < numWorkers; ++i) {\n workers[i].postMessage(i);\n }\n }\n\n function reduce(numWorkers, results) {\n // find overlapping time windows\n var overlaps = [];\n for(var n = 0; n < numWorkers; ++n) {\n var r1 = results[n];\n var overlap = overlaps[n] = [];\n for(var i = 0; i < numWorkers; ++i) {\n if(n === i) {\n continue;\n }\n var r2 = results[i];\n if((r1.st > r2.st && r1.st < r2.et) ||\n (r2.st > r1.st && r2.st < r1.et)) {\n overlap.push(i);\n }\n }\n }\n // get maximum overlaps ... don't include overlapping worker itself\n // as the main JS process was also being scheduled during the work and\n // would have to be subtracted from the estimate anyway\n return overlaps.reduce(function(max, overlap) {\n return Math.max(max, overlap.length);\n }, 0);\n }\n};\n","/**\n * Javascript implementation of X.509 and related components (such as\n * Certification Signing Requests) of a Public Key Infrastructure.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n *\n * The ASN.1 representation of an X.509v3 certificate is as follows\n * (see RFC 2459):\n *\n * Certificate ::= SEQUENCE {\n * tbsCertificate TBSCertificate,\n * signatureAlgorithm AlgorithmIdentifier,\n * signatureValue BIT STRING\n * }\n *\n * TBSCertificate ::= SEQUENCE {\n * version [0] EXPLICIT Version DEFAULT v1,\n * serialNumber CertificateSerialNumber,\n * signature AlgorithmIdentifier,\n * issuer Name,\n * validity Validity,\n * subject Name,\n * subjectPublicKeyInfo SubjectPublicKeyInfo,\n * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,\n * -- If present, version shall be v2 or v3\n * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,\n * -- If present, version shall be v2 or v3\n * extensions [3] EXPLICIT Extensions OPTIONAL\n * -- If present, version shall be v3\n * }\n *\n * Version ::= INTEGER { v1(0), v2(1), v3(2) }\n *\n * CertificateSerialNumber ::= INTEGER\n *\n * Name ::= CHOICE {\n * // only one possible choice for now\n * RDNSequence\n * }\n *\n * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName\n *\n * RelativeDistinguishedName ::= SET OF AttributeTypeAndValue\n *\n * AttributeTypeAndValue ::= SEQUENCE {\n * type AttributeType,\n * value AttributeValue\n * }\n * AttributeType ::= OBJECT IDENTIFIER\n * AttributeValue ::= ANY DEFINED BY AttributeType\n *\n * Validity ::= SEQUENCE {\n * notBefore Time,\n * notAfter Time\n * }\n *\n * Time ::= CHOICE {\n * utcTime UTCTime,\n * generalTime GeneralizedTime\n * }\n *\n * UniqueIdentifier ::= BIT STRING\n *\n * SubjectPublicKeyInfo ::= SEQUENCE {\n * algorithm AlgorithmIdentifier,\n * subjectPublicKey BIT STRING\n * }\n *\n * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension\n *\n * Extension ::= SEQUENCE {\n * extnID OBJECT IDENTIFIER,\n * critical BOOLEAN DEFAULT FALSE,\n * extnValue OCTET STRING\n * }\n *\n * The only key algorithm currently supported for PKI is RSA.\n *\n * RSASSA-PSS signatures are described in RFC 3447 and RFC 4055.\n *\n * PKCS#10 v1.7 describes certificate signing requests:\n *\n * CertificationRequestInfo:\n *\n * CertificationRequestInfo ::= SEQUENCE {\n * version INTEGER { v1(0) } (v1,...),\n * subject Name,\n * subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},\n * attributes [0] Attributes{{ CRIAttributes }}\n * }\n *\n * Attributes { ATTRIBUTE:IOSet } ::= SET OF Attribute{{ IOSet }}\n *\n * CRIAttributes ATTRIBUTE ::= {\n * ... -- add any locally defined attributes here -- }\n *\n * Attribute { ATTRIBUTE:IOSet } ::= SEQUENCE {\n * type ATTRIBUTE.&id({IOSet}),\n * values SET SIZE(1..MAX) OF ATTRIBUTE.&Type({IOSet}{@type})\n * }\n *\n * CertificationRequest ::= SEQUENCE {\n * certificationRequestInfo CertificationRequestInfo,\n * signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }},\n * signature BIT STRING\n * }\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./asn1');\nrequire('./des');\nrequire('./md');\nrequire('./mgf');\nrequire('./oids');\nrequire('./pem');\nrequire('./pss');\nrequire('./rsa');\nrequire('./util');\n\n// shortcut for asn.1 API\nvar asn1 = forge.asn1;\n\n/* Public Key Infrastructure (PKI) implementation. */\nvar pki = module.exports = forge.pki = forge.pki || {};\nvar oids = pki.oids;\n\n// short name OID mappings\nvar _shortNames = {};\n_shortNames['CN'] = oids['commonName'];\n_shortNames['commonName'] = 'CN';\n_shortNames['C'] = oids['countryName'];\n_shortNames['countryName'] = 'C';\n_shortNames['L'] = oids['localityName'];\n_shortNames['localityName'] = 'L';\n_shortNames['ST'] = oids['stateOrProvinceName'];\n_shortNames['stateOrProvinceName'] = 'ST';\n_shortNames['O'] = oids['organizationName'];\n_shortNames['organizationName'] = 'O';\n_shortNames['OU'] = oids['organizationalUnitName'];\n_shortNames['organizationalUnitName'] = 'OU';\n_shortNames['E'] = oids['emailAddress'];\n_shortNames['emailAddress'] = 'E';\n\n// validator for an SubjectPublicKeyInfo structure\n// Note: Currently only works with an RSA public key\nvar publicKeyValidator = forge.pki.rsa.publicKeyValidator;\n\n// validator for an X.509v3 certificate\nvar x509CertificateValidator = {\n name: 'Certificate',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'Certificate.TBSCertificate',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'tbsCertificate',\n value: [{\n name: 'Certificate.TBSCertificate.version',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n optional: true,\n value: [{\n name: 'Certificate.TBSCertificate.version.integer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'certVersion'\n }]\n }, {\n name: 'Certificate.TBSCertificate.serialNumber',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'certSerialNumber'\n }, {\n name: 'Certificate.TBSCertificate.signature',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'Certificate.TBSCertificate.signature.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'certinfoSignatureOid'\n }, {\n name: 'Certificate.TBSCertificate.signature.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n optional: true,\n captureAsn1: 'certinfoSignatureParams'\n }]\n }, {\n name: 'Certificate.TBSCertificate.issuer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'certIssuer'\n }, {\n name: 'Certificate.TBSCertificate.validity',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n // Note: UTC and generalized times may both appear so the capture\n // names are based on their detected order, the names used below\n // are only for the common case, which validity time really means\n // \"notBefore\" and which means \"notAfter\" will be determined by order\n value: [{\n // notBefore (Time) (UTC time case)\n name: 'Certificate.TBSCertificate.validity.notBefore (utc)',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.UTCTIME,\n constructed: false,\n optional: true,\n capture: 'certValidity1UTCTime'\n }, {\n // notBefore (Time) (generalized time case)\n name: 'Certificate.TBSCertificate.validity.notBefore (generalized)',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.GENERALIZEDTIME,\n constructed: false,\n optional: true,\n capture: 'certValidity2GeneralizedTime'\n }, {\n // notAfter (Time) (only UTC time is supported)\n name: 'Certificate.TBSCertificate.validity.notAfter (utc)',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.UTCTIME,\n constructed: false,\n optional: true,\n capture: 'certValidity3UTCTime'\n }, {\n // notAfter (Time) (only UTC time is supported)\n name: 'Certificate.TBSCertificate.validity.notAfter (generalized)',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.GENERALIZEDTIME,\n constructed: false,\n optional: true,\n capture: 'certValidity4GeneralizedTime'\n }]\n }, {\n // Name (subject) (RDNSequence)\n name: 'Certificate.TBSCertificate.subject',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'certSubject'\n },\n // SubjectPublicKeyInfo\n publicKeyValidator,\n {\n // issuerUniqueID (optional)\n name: 'Certificate.TBSCertificate.issuerUniqueID',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 1,\n constructed: true,\n optional: true,\n value: [{\n name: 'Certificate.TBSCertificate.issuerUniqueID.id',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n // TODO: support arbitrary bit length ids\n captureBitStringValue: 'certIssuerUniqueId'\n }]\n }, {\n // subjectUniqueID (optional)\n name: 'Certificate.TBSCertificate.subjectUniqueID',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 2,\n constructed: true,\n optional: true,\n value: [{\n name: 'Certificate.TBSCertificate.subjectUniqueID.id',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n // TODO: support arbitrary bit length ids\n captureBitStringValue: 'certSubjectUniqueId'\n }]\n }, {\n // Extensions (optional)\n name: 'Certificate.TBSCertificate.extensions',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 3,\n constructed: true,\n captureAsn1: 'certExtensions',\n optional: true\n }]\n }, {\n // AlgorithmIdentifier (signature algorithm)\n name: 'Certificate.signatureAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // algorithm\n name: 'Certificate.signatureAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'certSignatureOid'\n }, {\n name: 'Certificate.TBSCertificate.signature.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n optional: true,\n captureAsn1: 'certSignatureParams'\n }]\n }, {\n // SignatureValue\n name: 'Certificate.signatureValue',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n captureBitStringValue: 'certSignature'\n }]\n};\n\nvar rsassaPssParameterValidator = {\n name: 'rsapss',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'rsapss.hashAlgorithm',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n value: [{\n name: 'rsapss.hashAlgorithm.AlgorithmIdentifier',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.SEQUENCE,\n constructed: true,\n optional: true,\n value: [{\n name: 'rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'hashOid'\n /* parameter block omitted, for SHA1 NULL anyhow. */\n }]\n }]\n }, {\n name: 'rsapss.maskGenAlgorithm',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 1,\n constructed: true,\n value: [{\n name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.SEQUENCE,\n constructed: true,\n optional: true,\n value: [{\n name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'maskGenOid'\n }, {\n name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.params',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'maskGenHashOid'\n /* parameter block omitted, for SHA1 NULL anyhow. */\n }]\n }]\n }]\n }, {\n name: 'rsapss.saltLength',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 2,\n optional: true,\n value: [{\n name: 'rsapss.saltLength.saltLength',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.INTEGER,\n constructed: false,\n capture: 'saltLength'\n }]\n }, {\n name: 'rsapss.trailerField',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 3,\n optional: true,\n value: [{\n name: 'rsapss.trailer.trailer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.INTEGER,\n constructed: false,\n capture: 'trailer'\n }]\n }]\n};\n\n// validator for a CertificationRequestInfo structure\nvar certificationRequestInfoValidator = {\n name: 'CertificationRequestInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'certificationRequestInfo',\n value: [{\n name: 'CertificationRequestInfo.integer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'certificationRequestInfoVersion'\n }, {\n // Name (subject) (RDNSequence)\n name: 'CertificationRequestInfo.subject',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'certificationRequestInfoSubject'\n },\n // SubjectPublicKeyInfo\n publicKeyValidator,\n {\n name: 'CertificationRequestInfo.attributes',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n optional: true,\n capture: 'certificationRequestInfoAttributes',\n value: [{\n name: 'CertificationRequestInfo.attributes',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'CertificationRequestInfo.attributes.type',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false\n }, {\n name: 'CertificationRequestInfo.attributes.value',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true\n }]\n }]\n }]\n};\n\n// validator for a CertificationRequest structure\nvar certificationRequestValidator = {\n name: 'CertificationRequest',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'csr',\n value: [\n certificationRequestInfoValidator, {\n // AlgorithmIdentifier (signature algorithm)\n name: 'CertificationRequest.signatureAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // algorithm\n name: 'CertificationRequest.signatureAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'csrSignatureOid'\n }, {\n name: 'CertificationRequest.signatureAlgorithm.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n optional: true,\n captureAsn1: 'csrSignatureParams'\n }]\n }, {\n // signature\n name: 'CertificationRequest.signature',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n captureBitStringValue: 'csrSignature'\n }\n ]\n};\n\n/**\n * Converts an RDNSequence of ASN.1 DER-encoded RelativeDistinguishedName\n * sets into an array with objects that have type and value properties.\n *\n * @param rdn the RDNSequence to convert.\n * @param md a message digest to append type and value to if provided.\n */\npki.RDNAttributesAsArray = function(rdn, md) {\n var rval = [];\n\n // each value in 'rdn' in is a SET of RelativeDistinguishedName\n var set, attr, obj;\n for(var si = 0; si < rdn.value.length; ++si) {\n // get the RelativeDistinguishedName set\n set = rdn.value[si];\n\n // each value in the SET is an AttributeTypeAndValue sequence\n // containing first a type (an OID) and second a value (defined by\n // the OID)\n for(var i = 0; i < set.value.length; ++i) {\n obj = {};\n attr = set.value[i];\n obj.type = asn1.derToOid(attr.value[0].value);\n obj.value = attr.value[1].value;\n obj.valueTagClass = attr.value[1].type;\n // if the OID is known, get its name and short name\n if(obj.type in oids) {\n obj.name = oids[obj.type];\n if(obj.name in _shortNames) {\n obj.shortName = _shortNames[obj.name];\n }\n }\n if(md) {\n md.update(obj.type);\n md.update(obj.value);\n }\n rval.push(obj);\n }\n }\n\n return rval;\n};\n\n/**\n * Converts ASN.1 CRIAttributes into an array with objects that have type and\n * value properties.\n *\n * @param attributes the CRIAttributes to convert.\n */\npki.CRIAttributesAsArray = function(attributes) {\n var rval = [];\n\n // each value in 'attributes' in is a SEQUENCE with an OID and a SET\n for(var si = 0; si < attributes.length; ++si) {\n // get the attribute sequence\n var seq = attributes[si];\n\n // each value in the SEQUENCE containing first a type (an OID) and\n // second a set of values (defined by the OID)\n var type = asn1.derToOid(seq.value[0].value);\n var values = seq.value[1].value;\n for(var vi = 0; vi < values.length; ++vi) {\n var obj = {};\n obj.type = type;\n obj.value = values[vi].value;\n obj.valueTagClass = values[vi].type;\n // if the OID is known, get its name and short name\n if(obj.type in oids) {\n obj.name = oids[obj.type];\n if(obj.name in _shortNames) {\n obj.shortName = _shortNames[obj.name];\n }\n }\n // parse extensions\n if(obj.type === oids.extensionRequest) {\n obj.extensions = [];\n for(var ei = 0; ei < obj.value.length; ++ei) {\n obj.extensions.push(pki.certificateExtensionFromAsn1(obj.value[ei]));\n }\n }\n rval.push(obj);\n }\n }\n\n return rval;\n};\n\n/**\n * Gets an issuer or subject attribute from its name, type, or short name.\n *\n * @param obj the issuer or subject object.\n * @param options a short name string or an object with:\n * shortName the short name for the attribute.\n * name the name for the attribute.\n * type the type for the attribute.\n *\n * @return the attribute.\n */\nfunction _getAttribute(obj, options) {\n if(typeof options === 'string') {\n options = {shortName: options};\n }\n\n var rval = null;\n var attr;\n for(var i = 0; rval === null && i < obj.attributes.length; ++i) {\n attr = obj.attributes[i];\n if(options.type && options.type === attr.type) {\n rval = attr;\n } else if(options.name && options.name === attr.name) {\n rval = attr;\n } else if(options.shortName && options.shortName === attr.shortName) {\n rval = attr;\n }\n }\n return rval;\n}\n\n/**\n * Converts signature parameters from ASN.1 structure.\n *\n * Currently only RSASSA-PSS supported. The PKCS#1 v1.5 signature scheme had\n * no parameters.\n *\n * RSASSA-PSS-params ::= SEQUENCE {\n * hashAlgorithm [0] HashAlgorithm DEFAULT\n * sha1Identifier,\n * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT\n * mgf1SHA1Identifier,\n * saltLength [2] INTEGER DEFAULT 20,\n * trailerField [3] INTEGER DEFAULT 1\n * }\n *\n * HashAlgorithm ::= AlgorithmIdentifier\n *\n * MaskGenAlgorithm ::= AlgorithmIdentifier\n *\n * AlgorithmIdentifer ::= SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * parameters ANY DEFINED BY algorithm OPTIONAL\n * }\n *\n * @param oid The OID specifying the signature algorithm\n * @param obj The ASN.1 structure holding the parameters\n * @param fillDefaults Whether to use return default values where omitted\n * @return signature parameter object\n */\nvar _readSignatureParameters = function(oid, obj, fillDefaults) {\n var params = {};\n\n if(oid !== oids['RSASSA-PSS']) {\n return params;\n }\n\n if(fillDefaults) {\n params = {\n hash: {\n algorithmOid: oids['sha1']\n },\n mgf: {\n algorithmOid: oids['mgf1'],\n hash: {\n algorithmOid: oids['sha1']\n }\n },\n saltLength: 20\n };\n }\n\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, rsassaPssParameterValidator, capture, errors)) {\n var error = new Error('Cannot read RSASSA-PSS parameter block.');\n error.errors = errors;\n throw error;\n }\n\n if(capture.hashOid !== undefined) {\n params.hash = params.hash || {};\n params.hash.algorithmOid = asn1.derToOid(capture.hashOid);\n }\n\n if(capture.maskGenOid !== undefined) {\n params.mgf = params.mgf || {};\n params.mgf.algorithmOid = asn1.derToOid(capture.maskGenOid);\n params.mgf.hash = params.mgf.hash || {};\n params.mgf.hash.algorithmOid = asn1.derToOid(capture.maskGenHashOid);\n }\n\n if(capture.saltLength !== undefined) {\n params.saltLength = capture.saltLength.charCodeAt(0);\n }\n\n return params;\n};\n\n/**\n * Converts an X.509 certificate from PEM format.\n *\n * Note: If the certificate is to be verified then compute hash should\n * be set to true. This will scan the TBSCertificate part of the ASN.1\n * object while it is converted so it doesn't need to be converted back\n * to ASN.1-DER-encoding later.\n *\n * @param pem the PEM-formatted certificate.\n * @param computeHash true to compute the hash for verification.\n * @param strict true to be strict when checking ASN.1 value lengths, false to\n * allow truncated values (default: true).\n *\n * @return the certificate.\n */\npki.certificateFromPem = function(pem, computeHash, strict) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'CERTIFICATE' &&\n msg.type !== 'X509 CERTIFICATE' &&\n msg.type !== 'TRUSTED CERTIFICATE') {\n var error = new Error(\n 'Could not convert certificate from PEM; PEM header type ' +\n 'is not \"CERTIFICATE\", \"X509 CERTIFICATE\", or \"TRUSTED CERTIFICATE\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error(\n 'Could not convert certificate from PEM; PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body, strict);\n\n return pki.certificateFromAsn1(obj, computeHash);\n};\n\n/**\n * Converts an X.509 certificate to PEM format.\n *\n * @param cert the certificate.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted certificate.\n */\npki.certificateToPem = function(cert, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'CERTIFICATE',\n body: asn1.toDer(pki.certificateToAsn1(cert)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Converts an RSA public key from PEM format.\n *\n * @param pem the PEM-formatted public key.\n *\n * @return the public key.\n */\npki.publicKeyFromPem = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'PUBLIC KEY' && msg.type !== 'RSA PUBLIC KEY') {\n var error = new Error('Could not convert public key from PEM; PEM header ' +\n 'type is not \"PUBLIC KEY\" or \"RSA PUBLIC KEY\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert public key from PEM; PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body);\n\n return pki.publicKeyFromAsn1(obj);\n};\n\n/**\n * Converts an RSA public key to PEM format (using a SubjectPublicKeyInfo).\n *\n * @param key the public key.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted public key.\n */\npki.publicKeyToPem = function(key, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'PUBLIC KEY',\n body: asn1.toDer(pki.publicKeyToAsn1(key)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Converts an RSA public key to PEM format (using an RSAPublicKey).\n *\n * @param key the public key.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted public key.\n */\npki.publicKeyToRSAPublicKeyPem = function(key, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'RSA PUBLIC KEY',\n body: asn1.toDer(pki.publicKeyToRSAPublicKey(key)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Gets a fingerprint for the given public key.\n *\n * @param options the options to use.\n * [md] the message digest object to use (defaults to forge.md.sha1).\n * [type] the type of fingerprint, such as 'RSAPublicKey',\n * 'SubjectPublicKeyInfo' (defaults to 'RSAPublicKey').\n * [encoding] an alternative output encoding, such as 'hex'\n * (defaults to none, outputs a byte buffer).\n * [delimiter] the delimiter to use between bytes for 'hex' encoded\n * output, eg: ':' (defaults to none).\n *\n * @return the fingerprint as a byte buffer or other encoding based on options.\n */\npki.getPublicKeyFingerprint = function(key, options) {\n options = options || {};\n var md = options.md || forge.md.sha1.create();\n var type = options.type || 'RSAPublicKey';\n\n var bytes;\n switch(type) {\n case 'RSAPublicKey':\n bytes = asn1.toDer(pki.publicKeyToRSAPublicKey(key)).getBytes();\n break;\n case 'SubjectPublicKeyInfo':\n bytes = asn1.toDer(pki.publicKeyToAsn1(key)).getBytes();\n break;\n default:\n throw new Error('Unknown fingerprint type \"' + options.type + '\".');\n }\n\n // hash public key bytes\n md.start();\n md.update(bytes);\n var digest = md.digest();\n if(options.encoding === 'hex') {\n var hex = digest.toHex();\n if(options.delimiter) {\n return hex.match(/.{2}/g).join(options.delimiter);\n }\n return hex;\n } else if(options.encoding === 'binary') {\n return digest.getBytes();\n } else if(options.encoding) {\n throw new Error('Unknown encoding \"' + options.encoding + '\".');\n }\n return digest;\n};\n\n/**\n * Converts a PKCS#10 certification request (CSR) from PEM format.\n *\n * Note: If the certification request is to be verified then compute hash\n * should be set to true. This will scan the CertificationRequestInfo part of\n * the ASN.1 object while it is converted so it doesn't need to be converted\n * back to ASN.1-DER-encoding later.\n *\n * @param pem the PEM-formatted certificate.\n * @param computeHash true to compute the hash for verification.\n * @param strict true to be strict when checking ASN.1 value lengths, false to\n * allow truncated values (default: true).\n *\n * @return the certification request (CSR).\n */\npki.certificationRequestFromPem = function(pem, computeHash, strict) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'CERTIFICATE REQUEST') {\n var error = new Error('Could not convert certification request from PEM; ' +\n 'PEM header type is not \"CERTIFICATE REQUEST\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert certification request from PEM; ' +\n 'PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body, strict);\n\n return pki.certificationRequestFromAsn1(obj, computeHash);\n};\n\n/**\n * Converts a PKCS#10 certification request (CSR) to PEM format.\n *\n * @param csr the certification request.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted certification request.\n */\npki.certificationRequestToPem = function(csr, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'CERTIFICATE REQUEST',\n body: asn1.toDer(pki.certificationRequestToAsn1(csr)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Creates an empty X.509v3 RSA certificate.\n *\n * @return the certificate.\n */\npki.createCertificate = function() {\n var cert = {};\n cert.version = 0x02;\n cert.serialNumber = '00';\n cert.signatureOid = null;\n cert.signature = null;\n cert.siginfo = {};\n cert.siginfo.algorithmOid = null;\n cert.validity = {};\n cert.validity.notBefore = new Date();\n cert.validity.notAfter = new Date();\n\n cert.issuer = {};\n cert.issuer.getField = function(sn) {\n return _getAttribute(cert.issuer, sn);\n };\n cert.issuer.addField = function(attr) {\n _fillMissingFields([attr]);\n cert.issuer.attributes.push(attr);\n };\n cert.issuer.attributes = [];\n cert.issuer.hash = null;\n\n cert.subject = {};\n cert.subject.getField = function(sn) {\n return _getAttribute(cert.subject, sn);\n };\n cert.subject.addField = function(attr) {\n _fillMissingFields([attr]);\n cert.subject.attributes.push(attr);\n };\n cert.subject.attributes = [];\n cert.subject.hash = null;\n\n cert.extensions = [];\n cert.publicKey = null;\n cert.md = null;\n\n /**\n * Sets the subject of this certificate.\n *\n * @param attrs the array of subject attributes to use.\n * @param uniqueId an optional a unique ID to use.\n */\n cert.setSubject = function(attrs, uniqueId) {\n // set new attributes, clear hash\n _fillMissingFields(attrs);\n cert.subject.attributes = attrs;\n delete cert.subject.uniqueId;\n if(uniqueId) {\n // TODO: support arbitrary bit length ids\n cert.subject.uniqueId = uniqueId;\n }\n cert.subject.hash = null;\n };\n\n /**\n * Sets the issuer of this certificate.\n *\n * @param attrs the array of issuer attributes to use.\n * @param uniqueId an optional a unique ID to use.\n */\n cert.setIssuer = function(attrs, uniqueId) {\n // set new attributes, clear hash\n _fillMissingFields(attrs);\n cert.issuer.attributes = attrs;\n delete cert.issuer.uniqueId;\n if(uniqueId) {\n // TODO: support arbitrary bit length ids\n cert.issuer.uniqueId = uniqueId;\n }\n cert.issuer.hash = null;\n };\n\n /**\n * Sets the extensions of this certificate.\n *\n * @param exts the array of extensions to use.\n */\n cert.setExtensions = function(exts) {\n for(var i = 0; i < exts.length; ++i) {\n _fillMissingExtensionFields(exts[i], {cert: cert});\n }\n // set new extensions\n cert.extensions = exts;\n };\n\n /**\n * Gets an extension by its name or id.\n *\n * @param options the name to use or an object with:\n * name the name to use.\n * id the id to use.\n *\n * @return the extension or null if not found.\n */\n cert.getExtension = function(options) {\n if(typeof options === 'string') {\n options = {name: options};\n }\n\n var rval = null;\n var ext;\n for(var i = 0; rval === null && i < cert.extensions.length; ++i) {\n ext = cert.extensions[i];\n if(options.id && ext.id === options.id) {\n rval = ext;\n } else if(options.name && ext.name === options.name) {\n rval = ext;\n }\n }\n return rval;\n };\n\n /**\n * Signs this certificate using the given private key.\n *\n * @param key the private key to sign with.\n * @param md the message digest object to use (defaults to forge.md.sha1).\n */\n cert.sign = function(key, md) {\n // TODO: get signature OID from private key\n cert.md = md || forge.md.sha1.create();\n var algorithmOid = oids[cert.md.algorithm + 'WithRSAEncryption'];\n if(!algorithmOid) {\n var error = new Error('Could not compute certificate digest. ' +\n 'Unknown message digest algorithm OID.');\n error.algorithm = cert.md.algorithm;\n throw error;\n }\n cert.signatureOid = cert.siginfo.algorithmOid = algorithmOid;\n\n // get TBSCertificate, convert to DER\n cert.tbsCertificate = pki.getTBSCertificate(cert);\n var bytes = asn1.toDer(cert.tbsCertificate);\n\n // digest and sign\n cert.md.update(bytes.getBytes());\n cert.signature = key.sign(cert.md);\n };\n\n /**\n * Attempts verify the signature on the passed certificate using this\n * certificate's public key.\n *\n * @param child the certificate to verify.\n *\n * @return true if verified, false if not.\n */\n cert.verify = function(child) {\n var rval = false;\n\n if(!cert.issued(child)) {\n var issuer = child.issuer;\n var subject = cert.subject;\n var error = new Error(\n 'The parent certificate did not issue the given child ' +\n 'certificate; the child certificate\\'s issuer does not match the ' +\n 'parent\\'s subject.');\n error.expectedIssuer = issuer.attributes;\n error.actualIssuer = subject.attributes;\n throw error;\n }\n\n var md = child.md;\n if(md === null) {\n // check signature OID for supported signature types\n if(child.signatureOid in oids) {\n var oid = oids[child.signatureOid];\n switch(oid) {\n case 'sha1WithRSAEncryption':\n md = forge.md.sha1.create();\n break;\n case 'md5WithRSAEncryption':\n md = forge.md.md5.create();\n break;\n case 'sha256WithRSAEncryption':\n md = forge.md.sha256.create();\n break;\n case 'sha384WithRSAEncryption':\n md = forge.md.sha384.create();\n break;\n case 'sha512WithRSAEncryption':\n md = forge.md.sha512.create();\n break;\n case 'RSASSA-PSS':\n md = forge.md.sha256.create();\n break;\n }\n }\n if(md === null) {\n var error = new Error('Could not compute certificate digest. ' +\n 'Unknown signature OID.');\n error.signatureOid = child.signatureOid;\n throw error;\n }\n\n // produce DER formatted TBSCertificate and digest it\n var tbsCertificate = child.tbsCertificate || pki.getTBSCertificate(child);\n var bytes = asn1.toDer(tbsCertificate);\n md.update(bytes.getBytes());\n }\n\n if(md !== null) {\n var scheme;\n\n switch(child.signatureOid) {\n case oids.sha1WithRSAEncryption:\n scheme = undefined; /* use PKCS#1 v1.5 padding scheme */\n break;\n case oids['RSASSA-PSS']:\n var hash, mgf;\n\n /* initialize mgf */\n hash = oids[child.signatureParameters.mgf.hash.algorithmOid];\n if(hash === undefined || forge.md[hash] === undefined) {\n var error = new Error('Unsupported MGF hash function.');\n error.oid = child.signatureParameters.mgf.hash.algorithmOid;\n error.name = hash;\n throw error;\n }\n\n mgf = oids[child.signatureParameters.mgf.algorithmOid];\n if(mgf === undefined || forge.mgf[mgf] === undefined) {\n var error = new Error('Unsupported MGF function.');\n error.oid = child.signatureParameters.mgf.algorithmOid;\n error.name = mgf;\n throw error;\n }\n\n mgf = forge.mgf[mgf].create(forge.md[hash].create());\n\n /* initialize hash function */\n hash = oids[child.signatureParameters.hash.algorithmOid];\n if(hash === undefined || forge.md[hash] === undefined) {\n throw {\n message: 'Unsupported RSASSA-PSS hash function.',\n oid: child.signatureParameters.hash.algorithmOid,\n name: hash\n };\n }\n\n scheme = forge.pss.create(forge.md[hash].create(), mgf,\n child.signatureParameters.saltLength);\n break;\n }\n\n // verify signature on cert using public key\n rval = cert.publicKey.verify(\n md.digest().getBytes(), child.signature, scheme);\n }\n\n return rval;\n };\n\n /**\n * Returns true if this certificate's issuer matches the passed\n * certificate's subject. Note that no signature check is performed.\n *\n * @param parent the certificate to check.\n *\n * @return true if this certificate's issuer matches the passed certificate's\n * subject.\n */\n cert.isIssuer = function(parent) {\n var rval = false;\n\n var i = cert.issuer;\n var s = parent.subject;\n\n // compare hashes if present\n if(i.hash && s.hash) {\n rval = (i.hash === s.hash);\n } else if(i.attributes.length === s.attributes.length) {\n // all attributes are the same so issuer matches subject\n rval = true;\n var iattr, sattr;\n for(var n = 0; rval && n < i.attributes.length; ++n) {\n iattr = i.attributes[n];\n sattr = s.attributes[n];\n if(iattr.type !== sattr.type || iattr.value !== sattr.value) {\n // attribute mismatch\n rval = false;\n }\n }\n }\n\n return rval;\n };\n\n /**\n * Returns true if this certificate's subject matches the issuer of the\n * given certificate). Note that not signature check is performed.\n *\n * @param child the certificate to check.\n *\n * @return true if this certificate's subject matches the passed\n * certificate's issuer.\n */\n cert.issued = function(child) {\n return child.isIssuer(cert);\n };\n\n /**\n * Generates the subjectKeyIdentifier for this certificate as byte buffer.\n *\n * @return the subjectKeyIdentifier for this certificate as byte buffer.\n */\n cert.generateSubjectKeyIdentifier = function() {\n /* See: 4.2.1.2 section of the the RFC3280, keyIdentifier is either:\n\n (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the\n value of the BIT STRING subjectPublicKey (excluding the tag,\n length, and number of unused bits).\n\n (2) The keyIdentifier is composed of a four bit type field with\n the value 0100 followed by the least significant 60 bits of the\n SHA-1 hash of the value of the BIT STRING subjectPublicKey\n (excluding the tag, length, and number of unused bit string bits).\n */\n\n // skipping the tag, length, and number of unused bits is the same\n // as just using the RSAPublicKey (for RSA keys, which are the\n // only ones supported)\n return pki.getPublicKeyFingerprint(cert.publicKey, {type: 'RSAPublicKey'});\n };\n\n /**\n * Verifies the subjectKeyIdentifier extension value for this certificate\n * against its public key. If no extension is found, false will be\n * returned.\n *\n * @return true if verified, false if not.\n */\n cert.verifySubjectKeyIdentifier = function() {\n var oid = oids['subjectKeyIdentifier'];\n for(var i = 0; i < cert.extensions.length; ++i) {\n var ext = cert.extensions[i];\n if(ext.id === oid) {\n var ski = cert.generateSubjectKeyIdentifier().getBytes();\n return (forge.util.hexToBytes(ext.subjectKeyIdentifier) === ski);\n }\n }\n return false;\n };\n\n return cert;\n};\n\n/**\n * Converts an X.509v3 RSA certificate from an ASN.1 object.\n *\n * Note: If the certificate is to be verified then compute hash should\n * be set to true. There is currently no implementation for converting\n * a certificate back to ASN.1 so the TBSCertificate part of the ASN.1\n * object needs to be scanned before the cert object is created.\n *\n * @param obj the asn1 representation of an X.509v3 RSA certificate.\n * @param computeHash true to compute the hash for verification.\n *\n * @return the certificate.\n */\npki.certificateFromAsn1 = function(obj, computeHash) {\n // validate certificate and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, x509CertificateValidator, capture, errors)) {\n var error = new Error('Cannot read X.509 certificate. ' +\n 'ASN.1 object is not an X509v3 Certificate.');\n error.errors = errors;\n throw error;\n }\n\n // get oid\n var oid = asn1.derToOid(capture.publicKeyOid);\n if(oid !== pki.oids.rsaEncryption) {\n throw new Error('Cannot read public key. OID is not RSA.');\n }\n\n // create certificate\n var cert = pki.createCertificate();\n cert.version = capture.certVersion ?\n capture.certVersion.charCodeAt(0) : 0;\n var serial = forge.util.createBuffer(capture.certSerialNumber);\n cert.serialNumber = serial.toHex();\n cert.signatureOid = forge.asn1.derToOid(capture.certSignatureOid);\n cert.signatureParameters = _readSignatureParameters(\n cert.signatureOid, capture.certSignatureParams, true);\n cert.siginfo.algorithmOid = forge.asn1.derToOid(capture.certinfoSignatureOid);\n cert.siginfo.parameters = _readSignatureParameters(cert.siginfo.algorithmOid,\n capture.certinfoSignatureParams, false);\n cert.signature = capture.certSignature;\n\n var validity = [];\n if(capture.certValidity1UTCTime !== undefined) {\n validity.push(asn1.utcTimeToDate(capture.certValidity1UTCTime));\n }\n if(capture.certValidity2GeneralizedTime !== undefined) {\n validity.push(asn1.generalizedTimeToDate(\n capture.certValidity2GeneralizedTime));\n }\n if(capture.certValidity3UTCTime !== undefined) {\n validity.push(asn1.utcTimeToDate(capture.certValidity3UTCTime));\n }\n if(capture.certValidity4GeneralizedTime !== undefined) {\n validity.push(asn1.generalizedTimeToDate(\n capture.certValidity4GeneralizedTime));\n }\n if(validity.length > 2) {\n throw new Error('Cannot read notBefore/notAfter validity times; more ' +\n 'than two times were provided in the certificate.');\n }\n if(validity.length < 2) {\n throw new Error('Cannot read notBefore/notAfter validity times; they ' +\n 'were not provided as either UTCTime or GeneralizedTime.');\n }\n cert.validity.notBefore = validity[0];\n cert.validity.notAfter = validity[1];\n\n // keep TBSCertificate to preserve signature when exporting\n cert.tbsCertificate = capture.tbsCertificate;\n\n if(computeHash) {\n // check signature OID for supported signature types\n cert.md = null;\n if(cert.signatureOid in oids) {\n var oid = oids[cert.signatureOid];\n switch(oid) {\n case 'sha1WithRSAEncryption':\n cert.md = forge.md.sha1.create();\n break;\n case 'md5WithRSAEncryption':\n cert.md = forge.md.md5.create();\n break;\n case 'sha256WithRSAEncryption':\n cert.md = forge.md.sha256.create();\n break;\n case 'sha384WithRSAEncryption':\n cert.md = forge.md.sha384.create();\n break;\n case 'sha512WithRSAEncryption':\n cert.md = forge.md.sha512.create();\n break;\n case 'RSASSA-PSS':\n cert.md = forge.md.sha256.create();\n break;\n }\n }\n if(cert.md === null) {\n var error = new Error('Could not compute certificate digest. ' +\n 'Unknown signature OID.');\n error.signatureOid = cert.signatureOid;\n throw error;\n }\n\n // produce DER formatted TBSCertificate and digest it\n var bytes = asn1.toDer(cert.tbsCertificate);\n cert.md.update(bytes.getBytes());\n }\n\n // handle issuer, build issuer message digest\n var imd = forge.md.sha1.create();\n cert.issuer.getField = function(sn) {\n return _getAttribute(cert.issuer, sn);\n };\n cert.issuer.addField = function(attr) {\n _fillMissingFields([attr]);\n cert.issuer.attributes.push(attr);\n };\n cert.issuer.attributes = pki.RDNAttributesAsArray(capture.certIssuer, imd);\n if(capture.certIssuerUniqueId) {\n cert.issuer.uniqueId = capture.certIssuerUniqueId;\n }\n cert.issuer.hash = imd.digest().toHex();\n\n // handle subject, build subject message digest\n var smd = forge.md.sha1.create();\n cert.subject.getField = function(sn) {\n return _getAttribute(cert.subject, sn);\n };\n cert.subject.addField = function(attr) {\n _fillMissingFields([attr]);\n cert.subject.attributes.push(attr);\n };\n cert.subject.attributes = pki.RDNAttributesAsArray(capture.certSubject, smd);\n if(capture.certSubjectUniqueId) {\n cert.subject.uniqueId = capture.certSubjectUniqueId;\n }\n cert.subject.hash = smd.digest().toHex();\n\n // handle extensions\n if(capture.certExtensions) {\n cert.extensions = pki.certificateExtensionsFromAsn1(capture.certExtensions);\n } else {\n cert.extensions = [];\n }\n\n // convert RSA public key from ASN.1\n cert.publicKey = pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);\n\n return cert;\n};\n\n/**\n * Converts an ASN.1 extensions object (with extension sequences as its\n * values) into an array of extension objects with types and values.\n *\n * Supported extensions:\n *\n * id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }\n * KeyUsage ::= BIT STRING {\n * digitalSignature (0),\n * nonRepudiation (1),\n * keyEncipherment (2),\n * dataEncipherment (3),\n * keyAgreement (4),\n * keyCertSign (5),\n * cRLSign (6),\n * encipherOnly (7),\n * decipherOnly (8)\n * }\n *\n * id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 }\n * BasicConstraints ::= SEQUENCE {\n * cA BOOLEAN DEFAULT FALSE,\n * pathLenConstraint INTEGER (0..MAX) OPTIONAL\n * }\n *\n * subjectAltName EXTENSION ::= {\n * SYNTAX GeneralNames\n * IDENTIFIED BY id-ce-subjectAltName\n * }\n *\n * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName\n *\n * GeneralName ::= CHOICE {\n * otherName [0] INSTANCE OF OTHER-NAME,\n * rfc822Name [1] IA5String,\n * dNSName [2] IA5String,\n * x400Address [3] ORAddress,\n * directoryName [4] Name,\n * ediPartyName [5] EDIPartyName,\n * uniformResourceIdentifier [6] IA5String,\n * IPAddress [7] OCTET STRING,\n * registeredID [8] OBJECT IDENTIFIER\n * }\n *\n * OTHER-NAME ::= TYPE-IDENTIFIER\n *\n * EDIPartyName ::= SEQUENCE {\n * nameAssigner [0] DirectoryString {ub-name} OPTIONAL,\n * partyName [1] DirectoryString {ub-name}\n * }\n *\n * @param exts the extensions ASN.1 with extension sequences to parse.\n *\n * @return the array.\n */\npki.certificateExtensionsFromAsn1 = function(exts) {\n var rval = [];\n for(var i = 0; i < exts.value.length; ++i) {\n // get extension sequence\n var extseq = exts.value[i];\n for(var ei = 0; ei < extseq.value.length; ++ei) {\n rval.push(pki.certificateExtensionFromAsn1(extseq.value[ei]));\n }\n }\n\n return rval;\n};\n\n/**\n * Parses a single certificate extension from ASN.1.\n *\n * @param ext the extension in ASN.1 format.\n *\n * @return the parsed extension as an object.\n */\npki.certificateExtensionFromAsn1 = function(ext) {\n // an extension has:\n // [0] extnID OBJECT IDENTIFIER\n // [1] critical BOOLEAN DEFAULT FALSE\n // [2] extnValue OCTET STRING\n var e = {};\n e.id = asn1.derToOid(ext.value[0].value);\n e.critical = false;\n if(ext.value[1].type === asn1.Type.BOOLEAN) {\n e.critical = (ext.value[1].value.charCodeAt(0) !== 0x00);\n e.value = ext.value[2].value;\n } else {\n e.value = ext.value[1].value;\n }\n // if the oid is known, get its name\n if(e.id in oids) {\n e.name = oids[e.id];\n\n // handle key usage\n if(e.name === 'keyUsage') {\n // get value as BIT STRING\n var ev = asn1.fromDer(e.value);\n var b2 = 0x00;\n var b3 = 0x00;\n if(ev.value.length > 1) {\n // skip first byte, just indicates unused bits which\n // will be padded with 0s anyway\n // get bytes with flag bits\n b2 = ev.value.charCodeAt(1);\n b3 = ev.value.length > 2 ? ev.value.charCodeAt(2) : 0;\n }\n // set flags\n e.digitalSignature = (b2 & 0x80) === 0x80;\n e.nonRepudiation = (b2 & 0x40) === 0x40;\n e.keyEncipherment = (b2 & 0x20) === 0x20;\n e.dataEncipherment = (b2 & 0x10) === 0x10;\n e.keyAgreement = (b2 & 0x08) === 0x08;\n e.keyCertSign = (b2 & 0x04) === 0x04;\n e.cRLSign = (b2 & 0x02) === 0x02;\n e.encipherOnly = (b2 & 0x01) === 0x01;\n e.decipherOnly = (b3 & 0x80) === 0x80;\n } else if(e.name === 'basicConstraints') {\n // handle basic constraints\n // get value as SEQUENCE\n var ev = asn1.fromDer(e.value);\n // get cA BOOLEAN flag (defaults to false)\n if(ev.value.length > 0 && ev.value[0].type === asn1.Type.BOOLEAN) {\n e.cA = (ev.value[0].value.charCodeAt(0) !== 0x00);\n } else {\n e.cA = false;\n }\n // get path length constraint\n var value = null;\n if(ev.value.length > 0 && ev.value[0].type === asn1.Type.INTEGER) {\n value = ev.value[0].value;\n } else if(ev.value.length > 1) {\n value = ev.value[1].value;\n }\n if(value !== null) {\n e.pathLenConstraint = asn1.derToInteger(value);\n }\n } else if(e.name === 'extKeyUsage') {\n // handle extKeyUsage\n // value is a SEQUENCE of OIDs\n var ev = asn1.fromDer(e.value);\n for(var vi = 0; vi < ev.value.length; ++vi) {\n var oid = asn1.derToOid(ev.value[vi].value);\n if(oid in oids) {\n e[oids[oid]] = true;\n } else {\n e[oid] = true;\n }\n }\n } else if(e.name === 'nsCertType') {\n // handle nsCertType\n // get value as BIT STRING\n var ev = asn1.fromDer(e.value);\n var b2 = 0x00;\n if(ev.value.length > 1) {\n // skip first byte, just indicates unused bits which\n // will be padded with 0s anyway\n // get bytes with flag bits\n b2 = ev.value.charCodeAt(1);\n }\n // set flags\n e.client = (b2 & 0x80) === 0x80;\n e.server = (b2 & 0x40) === 0x40;\n e.email = (b2 & 0x20) === 0x20;\n e.objsign = (b2 & 0x10) === 0x10;\n e.reserved = (b2 & 0x08) === 0x08;\n e.sslCA = (b2 & 0x04) === 0x04;\n e.emailCA = (b2 & 0x02) === 0x02;\n e.objCA = (b2 & 0x01) === 0x01;\n } else if(\n e.name === 'subjectAltName' ||\n e.name === 'issuerAltName') {\n // handle subjectAltName/issuerAltName\n e.altNames = [];\n\n // ev is a SYNTAX SEQUENCE\n var gn;\n var ev = asn1.fromDer(e.value);\n for(var n = 0; n < ev.value.length; ++n) {\n // get GeneralName\n gn = ev.value[n];\n\n var altName = {\n type: gn.type,\n value: gn.value\n };\n e.altNames.push(altName);\n\n // Note: Support for types 1,2,6,7,8\n switch(gn.type) {\n // rfc822Name\n case 1:\n // dNSName\n case 2:\n // uniformResourceIdentifier (URI)\n case 6:\n break;\n // IPAddress\n case 7:\n // convert to IPv4/IPv6 string representation\n altName.ip = forge.util.bytesToIP(gn.value);\n break;\n // registeredID\n case 8:\n altName.oid = asn1.derToOid(gn.value);\n break;\n default:\n // unsupported\n }\n }\n } else if(e.name === 'subjectKeyIdentifier') {\n // value is an OCTETSTRING w/the hash of the key-type specific\n // public key structure (eg: RSAPublicKey)\n var ev = asn1.fromDer(e.value);\n e.subjectKeyIdentifier = forge.util.bytesToHex(ev.value);\n }\n }\n return e;\n};\n\n/**\n * Converts a PKCS#10 certification request (CSR) from an ASN.1 object.\n *\n * Note: If the certification request is to be verified then compute hash\n * should be set to true. There is currently no implementation for converting\n * a certificate back to ASN.1 so the CertificationRequestInfo part of the\n * ASN.1 object needs to be scanned before the csr object is created.\n *\n * @param obj the asn1 representation of a PKCS#10 certification request (CSR).\n * @param computeHash true to compute the hash for verification.\n *\n * @return the certification request (CSR).\n */\npki.certificationRequestFromAsn1 = function(obj, computeHash) {\n // validate certification request and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, certificationRequestValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#10 certificate request. ' +\n 'ASN.1 object is not a PKCS#10 CertificationRequest.');\n error.errors = errors;\n throw error;\n }\n\n // get oid\n var oid = asn1.derToOid(capture.publicKeyOid);\n if(oid !== pki.oids.rsaEncryption) {\n throw new Error('Cannot read public key. OID is not RSA.');\n }\n\n // create certification request\n var csr = pki.createCertificationRequest();\n csr.version = capture.csrVersion ? capture.csrVersion.charCodeAt(0) : 0;\n csr.signatureOid = forge.asn1.derToOid(capture.csrSignatureOid);\n csr.signatureParameters = _readSignatureParameters(\n csr.signatureOid, capture.csrSignatureParams, true);\n csr.siginfo.algorithmOid = forge.asn1.derToOid(capture.csrSignatureOid);\n csr.siginfo.parameters = _readSignatureParameters(\n csr.siginfo.algorithmOid, capture.csrSignatureParams, false);\n csr.signature = capture.csrSignature;\n\n // keep CertificationRequestInfo to preserve signature when exporting\n csr.certificationRequestInfo = capture.certificationRequestInfo;\n\n if(computeHash) {\n // check signature OID for supported signature types\n csr.md = null;\n if(csr.signatureOid in oids) {\n var oid = oids[csr.signatureOid];\n switch(oid) {\n case 'sha1WithRSAEncryption':\n csr.md = forge.md.sha1.create();\n break;\n case 'md5WithRSAEncryption':\n csr.md = forge.md.md5.create();\n break;\n case 'sha256WithRSAEncryption':\n csr.md = forge.md.sha256.create();\n break;\n case 'sha384WithRSAEncryption':\n csr.md = forge.md.sha384.create();\n break;\n case 'sha512WithRSAEncryption':\n csr.md = forge.md.sha512.create();\n break;\n case 'RSASSA-PSS':\n csr.md = forge.md.sha256.create();\n break;\n }\n }\n if(csr.md === null) {\n var error = new Error('Could not compute certification request digest. ' +\n 'Unknown signature OID.');\n error.signatureOid = csr.signatureOid;\n throw error;\n }\n\n // produce DER formatted CertificationRequestInfo and digest it\n var bytes = asn1.toDer(csr.certificationRequestInfo);\n csr.md.update(bytes.getBytes());\n }\n\n // handle subject, build subject message digest\n var smd = forge.md.sha1.create();\n csr.subject.getField = function(sn) {\n return _getAttribute(csr.subject, sn);\n };\n csr.subject.addField = function(attr) {\n _fillMissingFields([attr]);\n csr.subject.attributes.push(attr);\n };\n csr.subject.attributes = pki.RDNAttributesAsArray(\n capture.certificationRequestInfoSubject, smd);\n csr.subject.hash = smd.digest().toHex();\n\n // convert RSA public key from ASN.1\n csr.publicKey = pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);\n\n // convert attributes from ASN.1\n csr.getAttribute = function(sn) {\n return _getAttribute(csr, sn);\n };\n csr.addAttribute = function(attr) {\n _fillMissingFields([attr]);\n csr.attributes.push(attr);\n };\n csr.attributes = pki.CRIAttributesAsArray(\n capture.certificationRequestInfoAttributes || []);\n\n return csr;\n};\n\n/**\n * Creates an empty certification request (a CSR or certificate signing\n * request). Once created, its public key and attributes can be set and then\n * it can be signed.\n *\n * @return the empty certification request.\n */\npki.createCertificationRequest = function() {\n var csr = {};\n csr.version = 0x00;\n csr.signatureOid = null;\n csr.signature = null;\n csr.siginfo = {};\n csr.siginfo.algorithmOid = null;\n\n csr.subject = {};\n csr.subject.getField = function(sn) {\n return _getAttribute(csr.subject, sn);\n };\n csr.subject.addField = function(attr) {\n _fillMissingFields([attr]);\n csr.subject.attributes.push(attr);\n };\n csr.subject.attributes = [];\n csr.subject.hash = null;\n\n csr.publicKey = null;\n csr.attributes = [];\n csr.getAttribute = function(sn) {\n return _getAttribute(csr, sn);\n };\n csr.addAttribute = function(attr) {\n _fillMissingFields([attr]);\n csr.attributes.push(attr);\n };\n csr.md = null;\n\n /**\n * Sets the subject of this certification request.\n *\n * @param attrs the array of subject attributes to use.\n */\n csr.setSubject = function(attrs) {\n // set new attributes\n _fillMissingFields(attrs);\n csr.subject.attributes = attrs;\n csr.subject.hash = null;\n };\n\n /**\n * Sets the attributes of this certification request.\n *\n * @param attrs the array of attributes to use.\n */\n csr.setAttributes = function(attrs) {\n // set new attributes\n _fillMissingFields(attrs);\n csr.attributes = attrs;\n };\n\n /**\n * Signs this certification request using the given private key.\n *\n * @param key the private key to sign with.\n * @param md the message digest object to use (defaults to forge.md.sha1).\n */\n csr.sign = function(key, md) {\n // TODO: get signature OID from private key\n csr.md = md || forge.md.sha1.create();\n var algorithmOid = oids[csr.md.algorithm + 'WithRSAEncryption'];\n if(!algorithmOid) {\n var error = new Error('Could not compute certification request digest. ' +\n 'Unknown message digest algorithm OID.');\n error.algorithm = csr.md.algorithm;\n throw error;\n }\n csr.signatureOid = csr.siginfo.algorithmOid = algorithmOid;\n\n // get CertificationRequestInfo, convert to DER\n csr.certificationRequestInfo = pki.getCertificationRequestInfo(csr);\n var bytes = asn1.toDer(csr.certificationRequestInfo);\n\n // digest and sign\n csr.md.update(bytes.getBytes());\n csr.signature = key.sign(csr.md);\n };\n\n /**\n * Attempts verify the signature on the passed certification request using\n * its public key.\n *\n * A CSR that has been exported to a file in PEM format can be verified using\n * OpenSSL using this command:\n *\n * openssl req -in -verify -noout -text\n *\n * @return true if verified, false if not.\n */\n csr.verify = function() {\n var rval = false;\n\n var md = csr.md;\n if(md === null) {\n // check signature OID for supported signature types\n if(csr.signatureOid in oids) {\n // TODO: create DRY `OID to md` function\n var oid = oids[csr.signatureOid];\n switch(oid) {\n case 'sha1WithRSAEncryption':\n md = forge.md.sha1.create();\n break;\n case 'md5WithRSAEncryption':\n md = forge.md.md5.create();\n break;\n case 'sha256WithRSAEncryption':\n md = forge.md.sha256.create();\n break;\n case 'sha384WithRSAEncryption':\n md = forge.md.sha384.create();\n break;\n case 'sha512WithRSAEncryption':\n md = forge.md.sha512.create();\n break;\n case 'RSASSA-PSS':\n md = forge.md.sha256.create();\n break;\n }\n }\n if(md === null) {\n var error = new Error(\n 'Could not compute certification request digest. ' +\n 'Unknown signature OID.');\n error.signatureOid = csr.signatureOid;\n throw error;\n }\n\n // produce DER formatted CertificationRequestInfo and digest it\n var cri = csr.certificationRequestInfo ||\n pki.getCertificationRequestInfo(csr);\n var bytes = asn1.toDer(cri);\n md.update(bytes.getBytes());\n }\n\n if(md !== null) {\n var scheme;\n\n switch(csr.signatureOid) {\n case oids.sha1WithRSAEncryption:\n /* use PKCS#1 v1.5 padding scheme */\n break;\n case oids['RSASSA-PSS']:\n var hash, mgf;\n\n /* initialize mgf */\n hash = oids[csr.signatureParameters.mgf.hash.algorithmOid];\n if(hash === undefined || forge.md[hash] === undefined) {\n var error = new Error('Unsupported MGF hash function.');\n error.oid = csr.signatureParameters.mgf.hash.algorithmOid;\n error.name = hash;\n throw error;\n }\n\n mgf = oids[csr.signatureParameters.mgf.algorithmOid];\n if(mgf === undefined || forge.mgf[mgf] === undefined) {\n var error = new Error('Unsupported MGF function.');\n error.oid = csr.signatureParameters.mgf.algorithmOid;\n error.name = mgf;\n throw error;\n }\n\n mgf = forge.mgf[mgf].create(forge.md[hash].create());\n\n /* initialize hash function */\n hash = oids[csr.signatureParameters.hash.algorithmOid];\n if(hash === undefined || forge.md[hash] === undefined) {\n var error = new Error('Unsupported RSASSA-PSS hash function.');\n error.oid = csr.signatureParameters.hash.algorithmOid;\n error.name = hash;\n throw error;\n }\n\n scheme = forge.pss.create(forge.md[hash].create(), mgf,\n csr.signatureParameters.saltLength);\n break;\n }\n\n // verify signature on csr using its public key\n rval = csr.publicKey.verify(\n md.digest().getBytes(), csr.signature, scheme);\n }\n\n return rval;\n };\n\n return csr;\n};\n\n/**\n * Converts an X.509 subject or issuer to an ASN.1 RDNSequence.\n *\n * @param obj the subject or issuer (distinguished name).\n *\n * @return the ASN.1 RDNSequence.\n */\nfunction _dnToAsn1(obj) {\n // create an empty RDNSequence\n var rval = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n\n // iterate over attributes\n var attr, set;\n var attrs = obj.attributes;\n for(var i = 0; i < attrs.length; ++i) {\n attr = attrs[i];\n var value = attr.value;\n\n // reuse tag class for attribute value if available\n var valueTagClass = asn1.Type.PRINTABLESTRING;\n if('valueTagClass' in attr) {\n valueTagClass = attr.valueTagClass;\n\n if(valueTagClass === asn1.Type.UTF8) {\n value = forge.util.encodeUtf8(value);\n }\n // FIXME: handle more encodings\n }\n\n // create a RelativeDistinguishedName set\n // each value in the set is an AttributeTypeAndValue first\n // containing the type (an OID) and second the value\n set = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // AttributeType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(attr.type).getBytes()),\n // AttributeValue\n asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)\n ])\n ]);\n rval.value.push(set);\n }\n\n return rval;\n}\n\n/**\n * Gets all printable attributes (typically of an issuer or subject) in a\n * simplified JSON format for display.\n *\n * @param attrs the attributes.\n *\n * @return the JSON for display.\n */\nfunction _getAttributesAsJson(attrs) {\n var rval = {};\n for(var i = 0; i < attrs.length; ++i) {\n var attr = attrs[i];\n if(attr.shortName && (\n attr.valueTagClass === asn1.Type.UTF8 ||\n attr.valueTagClass === asn1.Type.PRINTABLESTRING ||\n attr.valueTagClass === asn1.Type.IA5STRING)) {\n var value = attr.value;\n if(attr.valueTagClass === asn1.Type.UTF8) {\n value = forge.util.encodeUtf8(attr.value);\n }\n if(!(attr.shortName in rval)) {\n rval[attr.shortName] = value;\n } else if(forge.util.isArray(rval[attr.shortName])) {\n rval[attr.shortName].push(value);\n } else {\n rval[attr.shortName] = [rval[attr.shortName], value];\n }\n }\n }\n return rval;\n}\n\n/**\n * Fills in missing fields in attributes.\n *\n * @param attrs the attributes to fill missing fields in.\n */\nfunction _fillMissingFields(attrs) {\n var attr;\n for(var i = 0; i < attrs.length; ++i) {\n attr = attrs[i];\n\n // populate missing name\n if(typeof attr.name === 'undefined') {\n if(attr.type && attr.type in pki.oids) {\n attr.name = pki.oids[attr.type];\n } else if(attr.shortName && attr.shortName in _shortNames) {\n attr.name = pki.oids[_shortNames[attr.shortName]];\n }\n }\n\n // populate missing type (OID)\n if(typeof attr.type === 'undefined') {\n if(attr.name && attr.name in pki.oids) {\n attr.type = pki.oids[attr.name];\n } else {\n var error = new Error('Attribute type not specified.');\n error.attribute = attr;\n throw error;\n }\n }\n\n // populate missing shortname\n if(typeof attr.shortName === 'undefined') {\n if(attr.name && attr.name in _shortNames) {\n attr.shortName = _shortNames[attr.name];\n }\n }\n\n // convert extensions to value\n if(attr.type === oids.extensionRequest) {\n attr.valueConstructed = true;\n attr.valueTagClass = asn1.Type.SEQUENCE;\n if(!attr.value && attr.extensions) {\n attr.value = [];\n for(var ei = 0; ei < attr.extensions.length; ++ei) {\n attr.value.push(pki.certificateExtensionToAsn1(\n _fillMissingExtensionFields(attr.extensions[ei])));\n }\n }\n }\n\n if(typeof attr.value === 'undefined') {\n var error = new Error('Attribute value not specified.');\n error.attribute = attr;\n throw error;\n }\n }\n}\n\n/**\n * Fills in missing fields in certificate extensions.\n *\n * @param e the extension.\n * @param [options] the options to use.\n * [cert] the certificate the extensions are for.\n *\n * @return the extension.\n */\nfunction _fillMissingExtensionFields(e, options) {\n options = options || {};\n\n // populate missing name\n if(typeof e.name === 'undefined') {\n if(e.id && e.id in pki.oids) {\n e.name = pki.oids[e.id];\n }\n }\n\n // populate missing id\n if(typeof e.id === 'undefined') {\n if(e.name && e.name in pki.oids) {\n e.id = pki.oids[e.name];\n } else {\n var error = new Error('Extension ID not specified.');\n error.extension = e;\n throw error;\n }\n }\n\n if(typeof e.value !== 'undefined') {\n return e;\n }\n\n // handle missing value:\n\n // value is a BIT STRING\n if(e.name === 'keyUsage') {\n // build flags\n var unused = 0;\n var b2 = 0x00;\n var b3 = 0x00;\n if(e.digitalSignature) {\n b2 |= 0x80;\n unused = 7;\n }\n if(e.nonRepudiation) {\n b2 |= 0x40;\n unused = 6;\n }\n if(e.keyEncipherment) {\n b2 |= 0x20;\n unused = 5;\n }\n if(e.dataEncipherment) {\n b2 |= 0x10;\n unused = 4;\n }\n if(e.keyAgreement) {\n b2 |= 0x08;\n unused = 3;\n }\n if(e.keyCertSign) {\n b2 |= 0x04;\n unused = 2;\n }\n if(e.cRLSign) {\n b2 |= 0x02;\n unused = 1;\n }\n if(e.encipherOnly) {\n b2 |= 0x01;\n unused = 0;\n }\n if(e.decipherOnly) {\n b3 |= 0x80;\n unused = 7;\n }\n\n // create bit string\n var value = String.fromCharCode(unused);\n if(b3 !== 0) {\n value += String.fromCharCode(b2) + String.fromCharCode(b3);\n } else if(b2 !== 0) {\n value += String.fromCharCode(b2);\n }\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, value);\n } else if(e.name === 'basicConstraints') {\n // basicConstraints is a SEQUENCE\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n // cA BOOLEAN flag defaults to false\n if(e.cA) {\n e.value.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,\n String.fromCharCode(0xFF)));\n }\n if('pathLenConstraint' in e) {\n e.value.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(e.pathLenConstraint).getBytes()));\n }\n } else if(e.name === 'extKeyUsage') {\n // extKeyUsage is a SEQUENCE of OIDs\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n var seq = e.value.value;\n for(var key in e) {\n if(e[key] !== true) {\n continue;\n }\n // key is name in OID map\n if(key in oids) {\n seq.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID,\n false, asn1.oidToDer(oids[key]).getBytes()));\n } else if(key.indexOf('.') !== -1) {\n // assume key is an OID\n seq.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID,\n false, asn1.oidToDer(key).getBytes()));\n }\n }\n } else if(e.name === 'nsCertType') {\n // nsCertType is a BIT STRING\n // build flags\n var unused = 0;\n var b2 = 0x00;\n\n if(e.client) {\n b2 |= 0x80;\n unused = 7;\n }\n if(e.server) {\n b2 |= 0x40;\n unused = 6;\n }\n if(e.email) {\n b2 |= 0x20;\n unused = 5;\n }\n if(e.objsign) {\n b2 |= 0x10;\n unused = 4;\n }\n if(e.reserved) {\n b2 |= 0x08;\n unused = 3;\n }\n if(e.sslCA) {\n b2 |= 0x04;\n unused = 2;\n }\n if(e.emailCA) {\n b2 |= 0x02;\n unused = 1;\n }\n if(e.objCA) {\n b2 |= 0x01;\n unused = 0;\n }\n\n // create bit string\n var value = String.fromCharCode(unused);\n if(b2 !== 0) {\n value += String.fromCharCode(b2);\n }\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, value);\n } else if(e.name === 'subjectAltName' || e.name === 'issuerAltName') {\n // SYNTAX SEQUENCE\n e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n\n var altName;\n for(var n = 0; n < e.altNames.length; ++n) {\n altName = e.altNames[n];\n var value = altName.value;\n // handle IP\n if(altName.type === 7 && altName.ip) {\n value = forge.util.bytesFromIP(altName.ip);\n if(value === null) {\n var error = new Error(\n 'Extension \"ip\" value is not a valid IPv4 or IPv6 address.');\n error.extension = e;\n throw error;\n }\n } else if(altName.type === 8) {\n // handle OID\n if(altName.oid) {\n value = asn1.oidToDer(asn1.oidToDer(altName.oid));\n } else {\n // deprecated ... convert value to OID\n value = asn1.oidToDer(value);\n }\n }\n e.value.value.push(asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, altName.type, false,\n value));\n }\n } else if(e.name === 'nsComment' && options.cert) {\n // sanity check value is ASCII (req'd) and not too big\n if(!(/^[\\x00-\\x7F]*$/.test(e.comment)) ||\n (e.comment.length < 1) || (e.comment.length > 128)) {\n throw new Error('Invalid \"nsComment\" content.');\n }\n // IA5STRING opaque comment\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.IA5STRING, false, e.comment);\n } else if(e.name === 'subjectKeyIdentifier' && options.cert) {\n var ski = options.cert.generateSubjectKeyIdentifier();\n e.subjectKeyIdentifier = ski.toHex();\n // OCTETSTRING w/digest\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, ski.getBytes());\n } else if(e.name === 'authorityKeyIdentifier' && options.cert) {\n // SYNTAX SEQUENCE\n e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n var seq = e.value.value;\n\n if(e.keyIdentifier) {\n var keyIdentifier = (e.keyIdentifier === true ?\n options.cert.generateSubjectKeyIdentifier().getBytes() :\n e.keyIdentifier);\n seq.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, false, keyIdentifier));\n }\n\n if(e.authorityCertIssuer) {\n var authorityCertIssuer = [\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 4, true, [\n _dnToAsn1(e.authorityCertIssuer === true ?\n options.cert.issuer : e.authorityCertIssuer)\n ])\n ];\n seq.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, authorityCertIssuer));\n }\n\n if(e.serialNumber) {\n var serialNumber = forge.util.hexToBytes(e.serialNumber === true ?\n options.cert.serialNumber : e.serialNumber);\n seq.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, false, serialNumber));\n }\n } else if(e.name === 'cRLDistributionPoints') {\n e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n var seq = e.value.value;\n\n // Create sub SEQUENCE of DistributionPointName\n var subSeq = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n\n // Create fullName CHOICE\n var fullNameGeneralNames = asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, 0, true, []);\n var altName;\n for(var n = 0; n < e.altNames.length; ++n) {\n altName = e.altNames[n];\n var value = altName.value;\n // handle IP\n if(altName.type === 7 && altName.ip) {\n value = forge.util.bytesFromIP(altName.ip);\n if(value === null) {\n var error = new Error(\n 'Extension \"ip\" value is not a valid IPv4 or IPv6 address.');\n error.extension = e;\n throw error;\n }\n } else if(altName.type === 8) {\n // handle OID\n if(altName.oid) {\n value = asn1.oidToDer(asn1.oidToDer(altName.oid));\n } else {\n // deprecated ... convert value to OID\n value = asn1.oidToDer(value);\n }\n }\n fullNameGeneralNames.value.push(asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, altName.type, false,\n value));\n }\n\n // Add to the parent SEQUENCE\n subSeq.value.push(asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, 0, true, [fullNameGeneralNames]));\n seq.push(subSeq);\n }\n\n // ensure value has been defined by now\n if(typeof e.value === 'undefined') {\n var error = new Error('Extension value not specified.');\n error.extension = e;\n throw error;\n }\n\n return e;\n}\n\n/**\n * Convert signature parameters object to ASN.1\n *\n * @param {String} oid Signature algorithm OID\n * @param params The signature parametrs object\n * @return ASN.1 object representing signature parameters\n */\nfunction _signatureParametersToAsn1(oid, params) {\n switch(oid) {\n case oids['RSASSA-PSS']:\n var parts = [];\n\n if(params.hash.algorithmOid !== undefined) {\n parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(params.hash.algorithmOid).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ])\n ]));\n }\n\n if(params.mgf.algorithmOid !== undefined) {\n parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(params.mgf.algorithmOid).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(params.mgf.hash.algorithmOid).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ])\n ])\n ]));\n }\n\n if(params.saltLength !== undefined) {\n parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(params.saltLength).getBytes())\n ]));\n }\n\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, parts);\n\n default:\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '');\n }\n}\n\n/**\n * Converts a certification request's attributes to an ASN.1 set of\n * CRIAttributes.\n *\n * @param csr certification request.\n *\n * @return the ASN.1 set of CRIAttributes.\n */\nfunction _CRIAttributesToAsn1(csr) {\n // create an empty context-specific container\n var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, []);\n\n // no attributes, return empty container\n if(csr.attributes.length === 0) {\n return rval;\n }\n\n // each attribute has a sequence with a type and a set of values\n var attrs = csr.attributes;\n for(var i = 0; i < attrs.length; ++i) {\n var attr = attrs[i];\n var value = attr.value;\n\n // reuse tag class for attribute value if available\n var valueTagClass = asn1.Type.UTF8;\n if('valueTagClass' in attr) {\n valueTagClass = attr.valueTagClass;\n }\n if(valueTagClass === asn1.Type.UTF8) {\n value = forge.util.encodeUtf8(value);\n }\n var valueConstructed = false;\n if('valueConstructed' in attr) {\n valueConstructed = attr.valueConstructed;\n }\n // FIXME: handle more encodings\n\n // create a RelativeDistinguishedName set\n // each value in the set is an AttributeTypeAndValue first\n // containing the type (an OID) and second the value\n var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // AttributeType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(attr.type).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n // AttributeValue\n asn1.create(\n asn1.Class.UNIVERSAL, valueTagClass, valueConstructed, value)\n ])\n ]);\n rval.value.push(seq);\n }\n\n return rval;\n}\n\nvar jan_1_1950 = new Date('1950-01-01T00:00:00Z');\nvar jan_1_2050 = new Date('2050-01-01T00:00:00Z');\n\n/**\n * Converts a Date object to ASN.1\n * Handles the different format before and after 1st January 2050\n *\n * @param date date object.\n *\n * @return the ASN.1 object representing the date.\n */\nfunction _dateToAsn1(date) {\n if(date >= jan_1_1950 && date < jan_1_2050) {\n return asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.UTCTIME, false,\n asn1.dateToUtcTime(date));\n } else {\n return asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.GENERALIZEDTIME, false,\n asn1.dateToGeneralizedTime(date));\n }\n}\n\n/**\n * Gets the ASN.1 TBSCertificate part of an X.509v3 certificate.\n *\n * @param cert the certificate.\n *\n * @return the asn1 TBSCertificate.\n */\npki.getTBSCertificate = function(cert) {\n // TBSCertificate\n var notBefore = _dateToAsn1(cert.validity.notBefore);\n var notAfter = _dateToAsn1(cert.validity.notAfter);\n var tbs = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n // integer\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(cert.version).getBytes())\n ]),\n // serialNumber\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n forge.util.hexToBytes(cert.serialNumber)),\n // signature\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(cert.siginfo.algorithmOid).getBytes()),\n // parameters\n _signatureParametersToAsn1(\n cert.siginfo.algorithmOid, cert.siginfo.parameters)\n ]),\n // issuer\n _dnToAsn1(cert.issuer),\n // validity\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n notBefore,\n notAfter\n ]),\n // subject\n _dnToAsn1(cert.subject),\n // SubjectPublicKeyInfo\n pki.publicKeyToAsn1(cert.publicKey)\n ]);\n\n if(cert.issuer.uniqueId) {\n // issuerUniqueID (optional)\n tbs.value.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,\n // TODO: support arbitrary bit length ids\n String.fromCharCode(0x00) +\n cert.issuer.uniqueId\n )\n ])\n );\n }\n if(cert.subject.uniqueId) {\n // subjectUniqueID (optional)\n tbs.value.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,\n // TODO: support arbitrary bit length ids\n String.fromCharCode(0x00) +\n cert.subject.uniqueId\n )\n ])\n );\n }\n\n if(cert.extensions.length > 0) {\n // extensions (optional)\n tbs.value.push(pki.certificateExtensionsToAsn1(cert.extensions));\n }\n\n return tbs;\n};\n\n/**\n * Gets the ASN.1 CertificationRequestInfo part of a\n * PKCS#10 CertificationRequest.\n *\n * @param csr the certification request.\n *\n * @return the asn1 CertificationRequestInfo.\n */\npki.getCertificationRequestInfo = function(csr) {\n // CertificationRequestInfo\n var cri = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(csr.version).getBytes()),\n // subject\n _dnToAsn1(csr.subject),\n // SubjectPublicKeyInfo\n pki.publicKeyToAsn1(csr.publicKey),\n // attributes\n _CRIAttributesToAsn1(csr)\n ]);\n\n return cri;\n};\n\n/**\n * Converts a DistinguishedName (subject or issuer) to an ASN.1 object.\n *\n * @param dn the DistinguishedName.\n *\n * @return the asn1 representation of a DistinguishedName.\n */\npki.distinguishedNameToAsn1 = function(dn) {\n return _dnToAsn1(dn);\n};\n\n/**\n * Converts an X.509v3 RSA certificate to an ASN.1 object.\n *\n * @param cert the certificate.\n *\n * @return the asn1 representation of an X.509v3 RSA certificate.\n */\npki.certificateToAsn1 = function(cert) {\n // prefer cached TBSCertificate over generating one\n var tbsCertificate = cert.tbsCertificate || pki.getTBSCertificate(cert);\n\n // Certificate\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // TBSCertificate\n tbsCertificate,\n // AlgorithmIdentifier (signature algorithm)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(cert.signatureOid).getBytes()),\n // parameters\n _signatureParametersToAsn1(cert.signatureOid, cert.signatureParameters)\n ]),\n // SignatureValue\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,\n String.fromCharCode(0x00) + cert.signature)\n ]);\n};\n\n/**\n * Converts X.509v3 certificate extensions to ASN.1.\n *\n * @param exts the extensions to convert.\n *\n * @return the extensions in ASN.1 format.\n */\npki.certificateExtensionsToAsn1 = function(exts) {\n // create top-level extension container\n var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 3, true, []);\n\n // create extension sequence (stores a sequence for each extension)\n var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n rval.value.push(seq);\n\n for(var i = 0; i < exts.length; ++i) {\n seq.value.push(pki.certificateExtensionToAsn1(exts[i]));\n }\n\n return rval;\n};\n\n/**\n * Converts a single certificate extension to ASN.1.\n *\n * @param ext the extension to convert.\n *\n * @return the extension in ASN.1 format.\n */\npki.certificateExtensionToAsn1 = function(ext) {\n // create a sequence for each extension\n var extseq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n\n // extnID (OID)\n extseq.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(ext.id).getBytes()));\n\n // critical defaults to false\n if(ext.critical) {\n // critical BOOLEAN DEFAULT FALSE\n extseq.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,\n String.fromCharCode(0xFF)));\n }\n\n var value = ext.value;\n if(typeof ext.value !== 'string') {\n // value is asn.1\n value = asn1.toDer(value).getBytes();\n }\n\n // extnValue (OCTET STRING)\n extseq.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, value));\n\n return extseq;\n};\n\n/**\n * Converts a PKCS#10 certification request to an ASN.1 object.\n *\n * @param csr the certification request.\n *\n * @return the asn1 representation of a certification request.\n */\npki.certificationRequestToAsn1 = function(csr) {\n // prefer cached CertificationRequestInfo over generating one\n var cri = csr.certificationRequestInfo ||\n pki.getCertificationRequestInfo(csr);\n\n // Certificate\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // CertificationRequestInfo\n cri,\n // AlgorithmIdentifier (signature algorithm)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(csr.signatureOid).getBytes()),\n // parameters\n _signatureParametersToAsn1(csr.signatureOid, csr.signatureParameters)\n ]),\n // signature\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,\n String.fromCharCode(0x00) + csr.signature)\n ]);\n};\n\n/**\n * Creates a CA store.\n *\n * @param certs an optional array of certificate objects or PEM-formatted\n * certificate strings to add to the CA store.\n *\n * @return the CA store.\n */\npki.createCaStore = function(certs) {\n // create CA store\n var caStore = {\n // stored certificates\n certs: {}\n };\n\n /**\n * Gets the certificate that issued the passed certificate or its\n * 'parent'.\n *\n * @param cert the certificate to get the parent for.\n *\n * @return the parent certificate or null if none was found.\n */\n caStore.getIssuer = function(cert) {\n var rval = getBySubject(cert.issuer);\n\n // see if there are multiple matches\n /*if(forge.util.isArray(rval)) {\n // TODO: resolve multiple matches by checking\n // authorityKey/subjectKey/issuerUniqueID/other identifiers, etc.\n // FIXME: or alternatively do authority key mapping\n // if possible (X.509v1 certs can't work?)\n throw new Error('Resolving multiple issuer matches not implemented yet.');\n }*/\n\n return rval;\n };\n\n /**\n * Adds a trusted certificate to the store.\n *\n * @param cert the certificate to add as a trusted certificate (either a\n * pki.certificate object or a PEM-formatted certificate).\n */\n caStore.addCertificate = function(cert) {\n // convert from pem if necessary\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n\n ensureSubjectHasHash(cert.subject);\n\n if(!caStore.hasCertificate(cert)) { // avoid duplicate certificates in store\n if(cert.subject.hash in caStore.certs) {\n // subject hash already exists, append to array\n var tmp = caStore.certs[cert.subject.hash];\n if(!forge.util.isArray(tmp)) {\n tmp = [tmp];\n }\n tmp.push(cert);\n caStore.certs[cert.subject.hash] = tmp;\n } else {\n caStore.certs[cert.subject.hash] = cert;\n }\n }\n };\n\n /**\n * Checks to see if the given certificate is in the store.\n *\n * @param cert the certificate to check (either a pki.certificate or a\n * PEM-formatted certificate).\n *\n * @return true if the certificate is in the store, false if not.\n */\n caStore.hasCertificate = function(cert) {\n // convert from pem if necessary\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n\n var match = getBySubject(cert.subject);\n if(!match) {\n return false;\n }\n if(!forge.util.isArray(match)) {\n match = [match];\n }\n // compare DER-encoding of certificates\n var der1 = asn1.toDer(pki.certificateToAsn1(cert)).getBytes();\n for(var i = 0; i < match.length; ++i) {\n var der2 = asn1.toDer(pki.certificateToAsn1(match[i])).getBytes();\n if(der1 === der2) {\n return true;\n }\n }\n return false;\n };\n\n /**\n * Lists all of the certificates kept in the store.\n *\n * @return an array of all of the pki.certificate objects in the store.\n */\n caStore.listAllCertificates = function() {\n var certList = [];\n\n for(var hash in caStore.certs) {\n if(caStore.certs.hasOwnProperty(hash)) {\n var value = caStore.certs[hash];\n if(!forge.util.isArray(value)) {\n certList.push(value);\n } else {\n for(var i = 0; i < value.length; ++i) {\n certList.push(value[i]);\n }\n }\n }\n }\n\n return certList;\n };\n\n /**\n * Removes a certificate from the store.\n *\n * @param cert the certificate to remove (either a pki.certificate or a\n * PEM-formatted certificate).\n *\n * @return the certificate that was removed or null if the certificate\n * wasn't in store.\n */\n caStore.removeCertificate = function(cert) {\n var result;\n\n // convert from pem if necessary\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n ensureSubjectHasHash(cert.subject);\n if(!caStore.hasCertificate(cert)) {\n return null;\n }\n\n var match = getBySubject(cert.subject);\n\n if(!forge.util.isArray(match)) {\n result = caStore.certs[cert.subject.hash];\n delete caStore.certs[cert.subject.hash];\n return result;\n }\n\n // compare DER-encoding of certificates\n var der1 = asn1.toDer(pki.certificateToAsn1(cert)).getBytes();\n for(var i = 0; i < match.length; ++i) {\n var der2 = asn1.toDer(pki.certificateToAsn1(match[i])).getBytes();\n if(der1 === der2) {\n result = match[i];\n match.splice(i, 1);\n }\n }\n if(match.length === 0) {\n delete caStore.certs[cert.subject.hash];\n }\n\n return result;\n };\n\n function getBySubject(subject) {\n ensureSubjectHasHash(subject);\n return caStore.certs[subject.hash] || null;\n }\n\n function ensureSubjectHasHash(subject) {\n // produce subject hash if it doesn't exist\n if(!subject.hash) {\n var md = forge.md.sha1.create();\n subject.attributes = pki.RDNAttributesAsArray(_dnToAsn1(subject), md);\n subject.hash = md.digest().toHex();\n }\n }\n\n // auto-add passed in certs\n if(certs) {\n // parse PEM-formatted certificates as necessary\n for(var i = 0; i < certs.length; ++i) {\n var cert = certs[i];\n caStore.addCertificate(cert);\n }\n }\n\n return caStore;\n};\n\n/**\n * Certificate verification errors, based on TLS.\n */\npki.certificateError = {\n bad_certificate: 'forge.pki.BadCertificate',\n unsupported_certificate: 'forge.pki.UnsupportedCertificate',\n certificate_revoked: 'forge.pki.CertificateRevoked',\n certificate_expired: 'forge.pki.CertificateExpired',\n certificate_unknown: 'forge.pki.CertificateUnknown',\n unknown_ca: 'forge.pki.UnknownCertificateAuthority'\n};\n\n/**\n * Verifies a certificate chain against the given Certificate Authority store\n * with an optional custom verify callback.\n *\n * @param caStore a certificate store to verify against.\n * @param chain the certificate chain to verify, with the root or highest\n * authority at the end (an array of certificates).\n * @param options a callback to be called for every certificate in the chain or\n * an object with:\n * verify a callback to be called for every certificate in the\n * chain\n * validityCheckDate the date against which the certificate\n * validity period should be checked. Pass null to not check\n * the validity period. By default, the current date is used.\n *\n * The verify callback has the following signature:\n *\n * verified - Set to true if certificate was verified, otherwise the\n * pki.certificateError for why the certificate failed.\n * depth - The current index in the chain, where 0 is the end point's cert.\n * certs - The certificate chain, *NOTE* an empty chain indicates an anonymous\n * end point.\n *\n * The function returns true on success and on failure either the appropriate\n * pki.certificateError or an object with 'error' set to the appropriate\n * pki.certificateError and 'message' set to a custom error message.\n *\n * @return true if successful, error thrown if not.\n */\npki.verifyCertificateChain = function(caStore, chain, options) {\n /* From: RFC3280 - Internet X.509 Public Key Infrastructure Certificate\n Section 6: Certification Path Validation\n See inline parentheticals related to this particular implementation.\n\n The primary goal of path validation is to verify the binding between\n a subject distinguished name or a subject alternative name and subject\n public key, as represented in the end entity certificate, based on the\n public key of the trust anchor. This requires obtaining a sequence of\n certificates that support that binding. That sequence should be provided\n in the passed 'chain'. The trust anchor should be in the given CA\n store. The 'end entity' certificate is the certificate provided by the\n end point (typically a server) and is the first in the chain.\n\n To meet this goal, the path validation process verifies, among other\n things, that a prospective certification path (a sequence of n\n certificates or a 'chain') satisfies the following conditions:\n\n (a) for all x in {1, ..., n-1}, the subject of certificate x is\n the issuer of certificate x+1;\n\n (b) certificate 1 is issued by the trust anchor;\n\n (c) certificate n is the certificate to be validated; and\n\n (d) for all x in {1, ..., n}, the certificate was valid at the\n time in question.\n\n Note that here 'n' is index 0 in the chain and 1 is the last certificate\n in the chain and it must be signed by a certificate in the connection's\n CA store.\n\n The path validation process also determines the set of certificate\n policies that are valid for this path, based on the certificate policies\n extension, policy mapping extension, policy constraints extension, and\n inhibit any-policy extension.\n\n Note: Policy mapping extension not supported (Not Required).\n\n Note: If the certificate has an unsupported critical extension, then it\n must be rejected.\n\n Note: A certificate is self-issued if the DNs that appear in the subject\n and issuer fields are identical and are not empty.\n\n The path validation algorithm assumes the following seven inputs are\n provided to the path processing logic. What this specific implementation\n will use is provided parenthetically:\n\n (a) a prospective certification path of length n (the 'chain')\n (b) the current date/time: ('now').\n (c) user-initial-policy-set: A set of certificate policy identifiers\n naming the policies that are acceptable to the certificate user.\n The user-initial-policy-set contains the special value any-policy\n if the user is not concerned about certificate policy\n (Not implemented. Any policy is accepted).\n (d) trust anchor information, describing a CA that serves as a trust\n anchor for the certification path. The trust anchor information\n includes:\n\n (1) the trusted issuer name,\n (2) the trusted public key algorithm,\n (3) the trusted public key, and\n (4) optionally, the trusted public key parameters associated\n with the public key.\n\n (Trust anchors are provided via certificates in the CA store).\n\n The trust anchor information may be provided to the path processing\n procedure in the form of a self-signed certificate. The trusted anchor\n information is trusted because it was delivered to the path processing\n procedure by some trustworthy out-of-band procedure. If the trusted\n public key algorithm requires parameters, then the parameters are\n provided along with the trusted public key (No parameters used in this\n implementation).\n\n (e) initial-policy-mapping-inhibit, which indicates if policy mapping is\n allowed in the certification path.\n (Not implemented, no policy checking)\n\n (f) initial-explicit-policy, which indicates if the path must be valid\n for at least one of the certificate policies in the user-initial-\n policy-set.\n (Not implemented, no policy checking)\n\n (g) initial-any-policy-inhibit, which indicates whether the\n anyPolicy OID should be processed if it is included in a\n certificate.\n (Not implemented, so any policy is valid provided that it is\n not marked as critical) */\n\n /* Basic Path Processing:\n\n For each certificate in the 'chain', the following is checked:\n\n 1. The certificate validity period includes the current time.\n 2. The certificate was signed by its parent (where the parent is either\n the next in the chain or from the CA store). Allow processing to\n continue to the next step if no parent is found but the certificate is\n in the CA store.\n 3. TODO: The certificate has not been revoked.\n 4. The certificate issuer name matches the parent's subject name.\n 5. TODO: If the certificate is self-issued and not the final certificate\n in the chain, skip this step, otherwise verify that the subject name\n is within one of the permitted subtrees of X.500 distinguished names\n and that each of the alternative names in the subjectAltName extension\n (critical or non-critical) is within one of the permitted subtrees for\n that name type.\n 6. TODO: If the certificate is self-issued and not the final certificate\n in the chain, skip this step, otherwise verify that the subject name\n is not within one of the excluded subtrees for X.500 distinguished\n names and none of the subjectAltName extension names are excluded for\n that name type.\n 7. The other steps in the algorithm for basic path processing involve\n handling the policy extension which is not presently supported in this\n implementation. Instead, if a critical policy extension is found, the\n certificate is rejected as not supported.\n 8. If the certificate is not the first or if its the only certificate in\n the chain (having no parent from the CA store or is self-signed) and it\n has a critical key usage extension, verify that the keyCertSign bit is\n set. If the key usage extension exists, verify that the basic\n constraints extension exists. If the basic constraints extension exists,\n verify that the cA flag is set. If pathLenConstraint is set, ensure that\n the number of certificates that precede in the chain (come earlier\n in the chain as implemented below), excluding the very first in the\n chain (typically the end-entity one), isn't greater than the\n pathLenConstraint. This constraint limits the number of intermediate\n CAs that may appear below a CA before only end-entity certificates\n may be issued. */\n\n // if a verify callback is passed as the third parameter, package it within\n // the options object. This is to support a legacy function signature that\n // expected the verify callback as the third parameter.\n if(typeof options === 'function') {\n options = {verify: options};\n }\n options = options || {};\n\n // copy cert chain references to another array to protect against changes\n // in verify callback\n chain = chain.slice(0);\n var certs = chain.slice(0);\n\n var validityCheckDate = options.validityCheckDate;\n // if no validityCheckDate is specified, default to the current date. Make\n // sure to maintain the value null because it indicates that the validity\n // period should not be checked.\n if(typeof validityCheckDate === 'undefined') {\n validityCheckDate = new Date();\n }\n\n // verify each cert in the chain using its parent, where the parent\n // is either the next in the chain or from the CA store\n var first = true;\n var error = null;\n var depth = 0;\n do {\n var cert = chain.shift();\n var parent = null;\n var selfSigned = false;\n\n if(validityCheckDate) {\n // 1. check valid time\n if(validityCheckDate < cert.validity.notBefore ||\n validityCheckDate > cert.validity.notAfter) {\n error = {\n message: 'Certificate is not valid yet or has expired.',\n error: pki.certificateError.certificate_expired,\n notBefore: cert.validity.notBefore,\n notAfter: cert.validity.notAfter,\n // TODO: we might want to reconsider renaming 'now' to\n // 'validityCheckDate' should this API be changed in the future.\n now: validityCheckDate\n };\n }\n }\n\n // 2. verify with parent from chain or CA store\n if(error === null) {\n parent = chain[0] || caStore.getIssuer(cert);\n if(parent === null) {\n // check for self-signed cert\n if(cert.isIssuer(cert)) {\n selfSigned = true;\n parent = cert;\n }\n }\n\n if(parent) {\n // FIXME: current CA store implementation might have multiple\n // certificates where the issuer can't be determined from the\n // certificate (happens rarely with, eg: old certificates) so normalize\n // by always putting parents into an array\n // TODO: there's may be an extreme degenerate case currently uncovered\n // where an old intermediate certificate seems to have a matching parent\n // but none of the parents actually verify ... but the intermediate\n // is in the CA and it should pass this check; needs investigation\n var parents = parent;\n if(!forge.util.isArray(parents)) {\n parents = [parents];\n }\n\n // try to verify with each possible parent (typically only one)\n var verified = false;\n while(!verified && parents.length > 0) {\n parent = parents.shift();\n try {\n verified = parent.verify(cert);\n } catch(ex) {\n // failure to verify, don't care why, try next one\n }\n }\n\n if(!verified) {\n error = {\n message: 'Certificate signature is invalid.',\n error: pki.certificateError.bad_certificate\n };\n }\n }\n\n if(error === null && (!parent || selfSigned) &&\n !caStore.hasCertificate(cert)) {\n // no parent issuer and certificate itself is not trusted\n error = {\n message: 'Certificate is not trusted.',\n error: pki.certificateError.unknown_ca\n };\n }\n }\n\n // TODO: 3. check revoked\n\n // 4. check for matching issuer/subject\n if(error === null && parent && !cert.isIssuer(parent)) {\n // parent is not issuer\n error = {\n message: 'Certificate issuer is invalid.',\n error: pki.certificateError.bad_certificate\n };\n }\n\n // 5. TODO: check names with permitted names tree\n\n // 6. TODO: check names against excluded names tree\n\n // 7. check for unsupported critical extensions\n if(error === null) {\n // supported extensions\n var se = {\n keyUsage: true,\n basicConstraints: true\n };\n for(var i = 0; error === null && i < cert.extensions.length; ++i) {\n var ext = cert.extensions[i];\n if(ext.critical && !(ext.name in se)) {\n error = {\n message:\n 'Certificate has an unsupported critical extension.',\n error: pki.certificateError.unsupported_certificate\n };\n }\n }\n }\n\n // 8. check for CA if cert is not first or is the only certificate\n // remaining in chain with no parent or is self-signed\n if(error === null &&\n (!first || (chain.length === 0 && (!parent || selfSigned)))) {\n // first check keyUsage extension and then basic constraints\n var bcExt = cert.getExtension('basicConstraints');\n var keyUsageExt = cert.getExtension('keyUsage');\n if(keyUsageExt !== null) {\n // keyCertSign must be true and there must be a basic\n // constraints extension\n if(!keyUsageExt.keyCertSign || bcExt === null) {\n // bad certificate\n error = {\n message:\n 'Certificate keyUsage or basicConstraints conflict ' +\n 'or indicate that the certificate is not a CA. ' +\n 'If the certificate is the only one in the chain or ' +\n 'isn\\'t the first then the certificate must be a ' +\n 'valid CA.',\n error: pki.certificateError.bad_certificate\n };\n }\n }\n // basic constraints cA flag must be set\n if(error === null && bcExt !== null && !bcExt.cA) {\n // bad certificate\n error = {\n message:\n 'Certificate basicConstraints indicates the certificate ' +\n 'is not a CA.',\n error: pki.certificateError.bad_certificate\n };\n }\n // if error is not null and keyUsage is available, then we know it\n // has keyCertSign and there is a basic constraints extension too,\n // which means we can check pathLenConstraint (if it exists)\n if(error === null && keyUsageExt !== null &&\n 'pathLenConstraint' in bcExt) {\n // pathLen is the maximum # of intermediate CA certs that can be\n // found between the current certificate and the end-entity (depth 0)\n // certificate; this number does not include the end-entity (depth 0,\n // last in the chain) even if it happens to be a CA certificate itself\n var pathLen = depth - 1;\n if(pathLen > bcExt.pathLenConstraint) {\n // pathLenConstraint violated, bad certificate\n error = {\n message:\n 'Certificate basicConstraints pathLenConstraint violated.',\n error: pki.certificateError.bad_certificate\n };\n }\n }\n }\n\n // call application callback\n var vfd = (error === null) ? true : error.error;\n var ret = options.verify ? options.verify(vfd, depth, certs) : vfd;\n if(ret === true) {\n // clear any set error\n error = null;\n } else {\n // if passed basic tests, set default message and alert\n if(vfd === true) {\n error = {\n message: 'The application rejected the certificate.',\n error: pki.certificateError.bad_certificate\n };\n }\n\n // check for custom error info\n if(ret || ret === 0) {\n // set custom message and error\n if(typeof ret === 'object' && !forge.util.isArray(ret)) {\n if(ret.message) {\n error.message = ret.message;\n }\n if(ret.error) {\n error.error = ret.error;\n }\n } else if(typeof ret === 'string') {\n // set custom error\n error.error = ret;\n }\n }\n\n // throw error\n throw error;\n }\n\n // no longer first cert in chain\n first = false;\n ++depth;\n } while(chain.length > 0);\n\n return true;\n};\n","var wrappy = require('wrappy')\nmodule.exports = wrappy(once)\nmodule.exports.strict = wrappy(onceStrict)\n\nonce.proto = once(function () {\n Object.defineProperty(Function.prototype, 'once', {\n value: function () {\n return once(this)\n },\n configurable: true\n })\n\n Object.defineProperty(Function.prototype, 'onceStrict', {\n value: function () {\n return onceStrict(this)\n },\n configurable: true\n })\n})\n\nfunction once (fn) {\n var f = function () {\n if (f.called) return f.value\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n f.called = false\n return f\n}\n\nfunction onceStrict (fn) {\n var f = function () {\n if (f.called)\n throw new Error(f.onceError)\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n var name = fn.name || 'Function wrapped with `once`'\n f.onceError = name + \" shouldn't be called more than once\"\n f.called = false\n return f\n}\n","var once = require('once')\nvar eos = require('end-of-stream')\nvar fs = require('fs') // we only need fs to get the ReadStream and WriteStream prototypes\n\nvar noop = function () {}\nvar ancient = /^v?\\.0/.test(process.version)\n\nvar isFn = function (fn) {\n return typeof fn === 'function'\n}\n\nvar isFS = function (stream) {\n if (!ancient) return false // newer node version do not need to care about fs is a special way\n if (!fs) return false // browser\n return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close)\n}\n\nvar isRequest = function (stream) {\n return stream.setHeader && isFn(stream.abort)\n}\n\nvar destroyer = function (stream, reading, writing, callback) {\n callback = once(callback)\n\n var closed = false\n stream.on('close', function () {\n closed = true\n })\n\n eos(stream, {readable: reading, writable: writing}, function (err) {\n if (err) return callback(err)\n closed = true\n callback()\n })\n\n var destroyed = false\n return function (err) {\n if (closed) return\n if (destroyed) return\n destroyed = true\n\n if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks\n if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want\n\n if (isFn(stream.destroy)) return stream.destroy()\n\n callback(err || new Error('stream was destroyed'))\n }\n}\n\nvar call = function (fn) {\n fn()\n}\n\nvar pipe = function (from, to) {\n return from.pipe(to)\n}\n\nvar pump = function () {\n var streams = Array.prototype.slice.call(arguments)\n var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop\n\n if (Array.isArray(streams[0])) streams = streams[0]\n if (streams.length < 2) throw new Error('pump requires two streams per minimum')\n\n var error\n var destroys = streams.map(function (stream, i) {\n var reading = i < streams.length - 1\n var writing = i > 0\n return destroyer(stream, reading, writing, function (err) {\n if (!error) error = err\n if (err) destroys.forEach(call)\n if (reading) return\n destroys.forEach(call)\n callback(error)\n })\n })\n\n return streams.reduce(pipe)\n}\n\nmodule.exports = pump\n","'use strict';\n\nconst codes = {};\n\nfunction createErrorType(code, message, Base) {\n if (!Base) {\n Base = Error\n }\n\n function getMessage (arg1, arg2, arg3) {\n if (typeof message === 'string') {\n return message\n } else {\n return message(arg1, arg2, arg3)\n }\n }\n\n class NodeError extends Base {\n constructor (arg1, arg2, arg3) {\n super(getMessage(arg1, arg2, arg3));\n }\n }\n\n NodeError.prototype.name = Base.name;\n NodeError.prototype.code = code;\n\n codes[code] = NodeError;\n}\n\n// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js\nfunction oneOf(expected, thing) {\n if (Array.isArray(expected)) {\n const len = expected.length;\n expected = expected.map((i) => String(i));\n if (len > 2) {\n return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +\n expected[len - 1];\n } else if (len === 2) {\n return `one of ${thing} ${expected[0]} or ${expected[1]}`;\n } else {\n return `of ${thing} ${expected[0]}`;\n }\n } else {\n return `of ${thing} ${String(expected)}`;\n }\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\nfunction startsWith(str, search, pos) {\n\treturn str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith\nfunction endsWith(str, search, this_len) {\n\tif (this_len === undefined || this_len > str.length) {\n\t\tthis_len = str.length;\n\t}\n\treturn str.substring(this_len - search.length, this_len) === search;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes\nfunction includes(str, search, start) {\n if (typeof start !== 'number') {\n start = 0;\n }\n\n if (start + search.length > str.length) {\n return false;\n } else {\n return str.indexOf(search, start) !== -1;\n }\n}\n\ncreateErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {\n return 'The value \"' + value + '\" is invalid for option \"' + name + '\"'\n}, TypeError);\ncreateErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {\n // determiner: 'must be' or 'must not be'\n let determiner;\n if (typeof expected === 'string' && startsWith(expected, 'not ')) {\n determiner = 'must not be';\n expected = expected.replace(/^not /, '');\n } else {\n determiner = 'must be';\n }\n\n let msg;\n if (endsWith(name, ' argument')) {\n // For cases like 'first argument'\n msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;\n } else {\n const type = includes(name, '.') ? 'property' : 'argument';\n msg = `The \"${name}\" ${type} ${determiner} ${oneOf(expected, 'type')}`;\n }\n\n msg += `. Received type ${typeof actual}`;\n return msg;\n}, TypeError);\ncreateErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');\ncreateErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {\n return 'The ' + name + ' method is not implemented'\n});\ncreateErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');\ncreateErrorType('ERR_STREAM_DESTROYED', function (name) {\n return 'Cannot call ' + name + ' after a stream was destroyed';\n});\ncreateErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');\ncreateErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');\ncreateErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');\ncreateErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);\ncreateErrorType('ERR_UNKNOWN_ENCODING', function (arg) {\n return 'Unknown encoding: ' + arg\n}, TypeError);\ncreateErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');\n\nmodule.exports.codes = codes;\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n'use strict';\n/**/\n\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n\n for (var key in obj) {\n keys.push(key);\n }\n\n return keys;\n};\n/**/\n\n\nmodule.exports = Duplex;\n\nvar Readable = require('./_stream_readable');\n\nvar Writable = require('./_stream_writable');\n\nrequire('inherits')(Duplex, Readable);\n\n{\n // Allow the keys array to be GC'ed.\n var keys = objectKeys(Writable.prototype);\n\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n Readable.call(this, options);\n Writable.call(this, options);\n this.allowHalfOpen = true;\n\n if (options) {\n if (options.readable === false) this.readable = false;\n if (options.writable === false) this.writable = false;\n\n if (options.allowHalfOpen === false) {\n this.allowHalfOpen = false;\n this.once('end', onend);\n }\n }\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.highWaterMark;\n }\n});\nObject.defineProperty(Duplex.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\nObject.defineProperty(Duplex.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.length;\n }\n}); // the no-half-open enforcer\n\nfunction onend() {\n // If the writable side ended, then we're ok.\n if (this._writableState.ended) return; // no more data can be written.\n // But allow more writes to happen in this tick.\n\n process.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\nrequire('inherits')(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n'use strict';\n\nmodule.exports = Readable;\n/**/\n\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n/**/\n\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function EElistenerCount(emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\n\n\nvar Stream = require('./internal/streams/stream');\n/**/\n\n\nvar Buffer = require('buffer').Buffer;\n\nvar OurUint8Array = global.Uint8Array || function () {};\n\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\n\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n/**/\n\n\nvar debugUtil = require('util');\n\nvar debug;\n\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function debug() {};\n}\n/**/\n\n\nvar BufferList = require('./internal/streams/buffer_list');\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nvar _require = require('./internal/streams/state'),\n getHighWaterMark = _require.getHighWaterMark;\n\nvar _require$codes = require('../errors').codes,\n ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,\n ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.\n\n\nvar StringDecoder;\nvar createReadableStreamAsyncIterator;\nvar from;\n\nrequire('inherits')(Readable, Stream);\n\nvar errorOrDestroy = destroyImpl.errorOrDestroy;\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream, isDuplex) {\n Duplex = Duplex || require('./_stream_duplex');\n options = options || {}; // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n\n this.objectMode = !!options.objectMode;\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n\n this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n\n this.sync = true; // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n this.paused = true; // Should close be emitted on destroy. Defaults to true.\n\n this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')\n\n this.autoDestroy = !!options.autoDestroy; // has it been destroyed\n\n this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n\n this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s\n\n this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled\n\n this.readingMore = false;\n this.decoder = null;\n this.encoding = null;\n\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside\n // the ReadableState constructor, at least with V8 6.5\n\n var isDuplex = this instanceof Duplex;\n this._readableState = new ReadableState(options, this, isDuplex); // legacy\n\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._readableState === undefined) {\n return false;\n }\n\n return this._readableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._readableState.destroyed = value;\n }\n});\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\n\nReadable.prototype._destroy = function (err, cb) {\n cb(err);\n}; // Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\n\n\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n}; // Unshift should *always* be something directly out of read()\n\n\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n debug('readableAddChunk', chunk);\n var state = stream._readableState;\n\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n\n if (er) {\n errorOrDestroy(stream, er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());\n } else if (state.destroyed) {\n return false;\n } else {\n state.reading = false;\n\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n maybeReadMore(stream, state);\n }\n } // We can push more data if we are below the highWaterMark.\n // Also, if we have no data yet, we can stand some more bytes.\n // This is to work around cases where hwm=0, such as the repl.\n\n\n return !state.ended && (state.length < state.highWaterMark || state.length === 0);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n state.awaitDrain = 0;\n stream.emit('data', chunk);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n if (state.needReadable) emitReadable(stream);\n }\n\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);\n }\n\n return er;\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n}; // backwards compatibility.\n\n\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n var decoder = new StringDecoder(enc);\n this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8\n\n this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:\n\n var p = this._readableState.buffer.head;\n var content = '';\n\n while (p !== null) {\n content += decoder.write(p.data);\n p = p.next;\n }\n\n this._readableState.buffer.clear();\n\n if (content !== '') this._readableState.buffer.push(content);\n this._readableState.length = content.length;\n return this;\n}; // Don't raise the hwm > 1GB\n\n\nvar MAX_HWM = 0x40000000;\n\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n\n return n;\n} // This function is designed to be inlinable, so please take care when making\n// changes to the function body.\n\n\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n } // If we're asking for more than the current hwm, then raise the hwm.\n\n\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n; // Don't have enough\n\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n\n return state.length;\n} // you can override either this method, or the async _read(n) below.\n\n\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n\n if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.\n\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n } // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n // if we need a readable event, then we need to do some reading.\n\n\n var doRead = state.needReadable;\n debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some\n\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n } // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n\n\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true; // if the length is currently zero, then we *need* a readable event.\n\n if (state.length === 0) state.needReadable = true; // call internal read method\n\n this._read(state.highWaterMark);\n\n state.sync = false; // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = state.length <= state.highWaterMark;\n n = 0;\n } else {\n state.length -= n;\n state.awaitDrain = 0;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.\n\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n debug('onEofChunk');\n if (state.ended) return;\n\n if (state.decoder) {\n var chunk = state.decoder.end();\n\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n\n state.ended = true;\n\n if (state.sync) {\n // if we are sync, wait until next tick to emit the data.\n // Otherwise we risk emitting data in the flow()\n // the readable code triggers during a read() call\n emitReadable(stream);\n } else {\n // emit 'readable' now to make sure it gets picked up.\n state.needReadable = false;\n\n if (!state.emittedReadable) {\n state.emittedReadable = true;\n emitReadable_(stream);\n }\n }\n} // Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\n\n\nfunction emitReadable(stream) {\n var state = stream._readableState;\n debug('emitReadable', state.needReadable, state.emittedReadable);\n state.needReadable = false;\n\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n process.nextTick(emitReadable_, stream);\n }\n}\n\nfunction emitReadable_(stream) {\n var state = stream._readableState;\n debug('emitReadable_', state.destroyed, state.length, state.ended);\n\n if (!state.destroyed && (state.length || state.ended)) {\n stream.emit('readable');\n state.emittedReadable = false;\n } // The stream needs another readable event if\n // 1. It is not flowing, as the flow mechanism will take\n // care of it.\n // 2. It is not ended.\n // 3. It is below the highWaterMark, so we can schedule\n // another readable later.\n\n\n state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;\n flow(stream);\n} // at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\n\n\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n process.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n // Attempt to read more data if we should.\n //\n // The conditions for reading more data are (one of):\n // - Not enough data buffered (state.length < state.highWaterMark). The loop\n // is responsible for filling the buffer with enough data if such data\n // is available. If highWaterMark is 0 and we are not in the flowing mode\n // we should _not_ attempt to buffer any extra data. We'll get more data\n // when the stream consumer calls read() instead.\n // - No data in the buffer, and the stream is in flowing mode. In this mode\n // the loop below is responsible for ensuring read() is called. Failing to\n // call read here would abort the flow and there's no other mechanism for\n // continuing the flow if the stream consumer has just subscribed to the\n // 'data' event.\n //\n // In addition to the above conditions to keep reading data, the following\n // conditions prevent the data from being read:\n // - The stream has ended (state.ended).\n // - There is already a pending 'read' operation (state.reading). This is a\n // case where the the stream has called the implementation defined _read()\n // method, but they are processing the call asynchronously and have _not_\n // called push() with new data. In this case we skip performing more\n // read()s. The execution ends in this method again after the _read() ends\n // up calling push() with more data.\n while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {\n var len = state.length;\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length) // didn't get any data, stop spinning.\n break;\n }\n\n state.readingMore = false;\n} // abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\n\n\nReadable.prototype._read = function (n) {\n errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n\n default:\n state.pipes.push(dest);\n break;\n }\n\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);\n dest.on('unpipe', onunpipe);\n\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n } // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n\n\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n var cleanedUp = false;\n\n function cleanup() {\n debug('cleanup'); // cleanup event handlers once the pipe is broken\n\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n cleanedUp = true; // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n src.on('data', ondata);\n\n function ondata(chunk) {\n debug('ondata');\n var ret = dest.write(chunk);\n debug('dest.write', ret);\n\n if (ret === false) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', state.awaitDrain);\n state.awaitDrain++;\n }\n\n src.pause();\n }\n } // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n\n\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);\n } // Make sure our error handler is attached before userland ones.\n\n\n prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.\n\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n\n dest.once('close', onclose);\n\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n } // tell the dest that it's being piped to\n\n\n dest.emit('pipe', src); // start the flow if it hasn't been started already.\n\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function pipeOnDrainFunctionResult() {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = {\n hasUnpiped: false\n }; // if we're not piping anywhere, then do nothing.\n\n if (state.pipesCount === 0) return this; // just one destination. most common case.\n\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n if (!dest) dest = state.pipes; // got a match.\n\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n } // slow case. multiple pipe destinations.\n\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, {\n hasUnpiped: false\n });\n }\n\n return this;\n } // try to find the right one.\n\n\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n dest.emit('unpipe', this, unpipeInfo);\n return this;\n}; // set up data events if they are asked for\n// Ensure readable listeners eventually get something\n\n\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n var state = this._readableState;\n\n if (ev === 'data') {\n // update readableListening so that resume() may be a no-op\n // a few lines down. This is needed to support once('readable').\n state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused\n\n if (state.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.flowing = false;\n state.emittedReadable = false;\n debug('on readable', state.length, state.reading);\n\n if (state.length) {\n emitReadable(this);\n } else if (!state.reading) {\n process.nextTick(nReadingNextTick, this);\n }\n }\n }\n\n return res;\n};\n\nReadable.prototype.addListener = Readable.prototype.on;\n\nReadable.prototype.removeListener = function (ev, fn) {\n var res = Stream.prototype.removeListener.call(this, ev, fn);\n\n if (ev === 'readable') {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nReadable.prototype.removeAllListeners = function (ev) {\n var res = Stream.prototype.removeAllListeners.apply(this, arguments);\n\n if (ev === 'readable' || ev === undefined) {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nfunction updateReadableListening(self) {\n var state = self._readableState;\n state.readableListening = self.listenerCount('readable') > 0;\n\n if (state.resumeScheduled && !state.paused) {\n // flowing needs to be set to true now, otherwise\n // the upcoming resume will not flow.\n state.flowing = true; // crude way to check if we should resume\n } else if (self.listenerCount('data') > 0) {\n self.resume();\n }\n}\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n} // pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\n\n\nReadable.prototype.resume = function () {\n var state = this._readableState;\n\n if (!state.flowing) {\n debug('resume'); // we flow only if there is no one listening\n // for readable, but we still have to call\n // resume()\n\n state.flowing = !state.readableListening;\n resume(this, state);\n }\n\n state.paused = false;\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n process.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n debug('resume', state.reading);\n\n if (!state.reading) {\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n\n if (this._readableState.flowing !== false) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n\n this._readableState.paused = true;\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n\n while (state.flowing && stream.read() !== null) {\n ;\n }\n} // wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\n\n\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n stream.on('end', function () {\n debug('wrapped end');\n\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode\n\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n\n if (!ret) {\n paused = true;\n stream.pause();\n }\n }); // proxy all the other methods.\n // important when wrapping filters and duplexes.\n\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function methodWrap(method) {\n return function methodWrapReturnFunction() {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n } // proxy certain important events.\n\n\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n } // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n\n\n this._read = function (n) {\n debug('wrapped _read', n);\n\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nif (typeof Symbol === 'function') {\n Readable.prototype[Symbol.asyncIterator] = function () {\n if (createReadableStreamAsyncIterator === undefined) {\n createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');\n }\n\n return createReadableStreamAsyncIterator(this);\n };\n}\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.highWaterMark;\n }\n});\nObject.defineProperty(Readable.prototype, 'readableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState && this._readableState.buffer;\n }\n});\nObject.defineProperty(Readable.prototype, 'readableFlowing', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.flowing;\n },\n set: function set(state) {\n if (this._readableState) {\n this._readableState.flowing = state;\n }\n }\n}); // exposed for testing purposes only.\n\nReadable._fromList = fromList;\nObject.defineProperty(Readable.prototype, 'readableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.length;\n }\n}); // Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\n\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = state.buffer.consume(n, state.decoder);\n }\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n debug('endReadable', state.endEmitted);\n\n if (!state.endEmitted) {\n state.ended = true;\n process.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.\n\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n\n if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the writable side is ready for autoDestroy as well\n var wState = stream._writableState;\n\n if (!wState || wState.autoDestroy && wState.finished) {\n stream.destroy();\n }\n }\n }\n}\n\nif (typeof Symbol === 'function') {\n Readable.from = function (iterable, opts) {\n if (from === undefined) {\n from = require('./internal/streams/from');\n }\n\n return from(Readable, iterable, opts);\n };\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n'use strict';\n\nmodule.exports = Transform;\n\nvar _require$codes = require('../errors').codes,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,\n ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,\n ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;\n\nvar Duplex = require('./_stream_duplex');\n\nrequire('inherits')(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n var cb = ts.writecb;\n\n if (cb === null) {\n return this.emit('error', new ERR_MULTIPLE_CALLBACK());\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n cb(er);\n var rs = this._readableState;\n rs.reading = false;\n\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n Duplex.call(this, options);\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n }; // start out asking for a readable event once data is transformed.\n\n this._readableState.needReadable = true; // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n if (typeof options.flush === 'function') this._flush = options.flush;\n } // When the writable side finishes, then flush out anything remaining.\n\n\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function' && !this._readableState.destroyed) {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n}; // This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\n\n\nTransform.prototype._transform = function (chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n}; // Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\n\n\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && !ts.transforming) {\n ts.transforming = true;\n\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data); // TODO(BridgeAR): Write a test for these two error cases\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n\n if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();\n if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n'use strict';\n\nmodule.exports = Writable;\n/* */\n\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n} // It seems a linked list but it is not\n// there will be only 2 of these for each stream\n\n\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\n\n\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n/**/\n\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\n\nvar Stream = require('./internal/streams/stream');\n/**/\n\n\nvar Buffer = require('buffer').Buffer;\n\nvar OurUint8Array = global.Uint8Array || function () {};\n\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\n\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nvar _require = require('./internal/streams/state'),\n getHighWaterMark = _require.getHighWaterMark;\n\nvar _require$codes = require('../errors').codes,\n ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,\n ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,\n ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,\n ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,\n ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,\n ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;\n\nvar errorOrDestroy = destroyImpl.errorOrDestroy;\n\nrequire('inherits')(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream, isDuplex) {\n Duplex = Duplex || require('./_stream_duplex');\n options = options || {}; // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream,\n // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.\n\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n\n this.objectMode = !!options.objectMode;\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n\n this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called\n\n this.finalCalled = false; // drain event flag.\n\n this.needDrain = false; // at the start of calling end()\n\n this.ending = false; // when end() has been called, and returned\n\n this.ended = false; // when 'finish' is emitted\n\n this.finished = false; // has it been destroyed\n\n this.destroyed = false; // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n\n this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n\n this.length = 0; // a flag to see when we're in the middle of a write.\n\n this.writing = false; // when true all writes will be buffered until .uncork() call\n\n this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n\n this.sync = true; // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n\n this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)\n\n this.onwrite = function (er) {\n onwrite(stream, er);\n }; // the callback that the user supplies to write(chunk,encoding,cb)\n\n\n this.writecb = null; // the amount that is being written when _write is called.\n\n this.writelen = 0;\n this.bufferedRequest = null;\n this.lastBufferedRequest = null; // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n\n this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n\n this.prefinished = false; // True if the error was already emitted and should not be thrown again\n\n this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.\n\n this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')\n\n this.autoDestroy = !!options.autoDestroy; // count buffered requests\n\n this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n\n while (current) {\n out.push(current);\n current = current.next;\n }\n\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function writableStateBufferGetter() {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})(); // Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\n\n\nvar realHasInstance;\n\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function value(object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function realHasInstance(object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n // Checking for a Stream.Duplex instance is faster here instead of inside\n // the WritableState constructor, at least with V8 6.5\n\n var isDuplex = this instanceof Duplex;\n if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);\n this._writableState = new WritableState(options, this, isDuplex); // legacy.\n\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n if (typeof options.writev === 'function') this._writev = options.writev;\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n} // Otherwise people can pipe Writable streams, which is just wrong.\n\n\nWritable.prototype.pipe = function () {\n errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb\n\n errorOrDestroy(stream, er);\n process.nextTick(cb, er);\n} // Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\n\n\nfunction validChunk(stream, state, chunk, cb) {\n var er;\n\n if (chunk === null) {\n er = new ERR_STREAM_NULL_VALUES();\n } else if (typeof chunk !== 'string' && !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);\n }\n\n if (er) {\n errorOrDestroy(stream, er);\n process.nextTick(cb, er);\n return false;\n }\n\n return true;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n if (typeof cb !== 'function') cb = nop;\n if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n return ret;\n};\n\nWritable.prototype.cork = function () {\n this._writableState.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.highWaterMark;\n }\n}); // if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\n\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n\n var len = state.objectMode ? 1 : chunk.length;\n state.length += len;\n var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.\n\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n process.nextTick(cb, er); // this can emit finish, and it will always happen\n // after error\n\n process.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n errorOrDestroy(stream, er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n errorOrDestroy(stream, er); // this can emit finish, but finish must\n // always follow error\n\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();\n onwriteStateUpdate(state);\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state) || stream.destroyed;\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n process.nextTick(afterWrite, stream, state, finished, cb);\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n} // Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\n\n\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it\n\n\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n var count = 0;\n var allBuffers = true;\n\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n\n buffer.allBuffers = allBuffers;\n doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n\n state.pendingcb++;\n state.lastBufferedRequest = null;\n\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks\n\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n } // ignore unnecessary end() calls.\n\n\n if (!state.ending) endWritable(this, state, cb);\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.length;\n }\n});\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\n\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n\n if (err) {\n errorOrDestroy(stream, err);\n }\n\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\n\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function' && !state.destroyed) {\n state.pendingcb++;\n state.finalCalled = true;\n process.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n\n if (need) {\n prefinish(stream, state);\n\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n\n if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the readable side is ready for autoDestroy as well\n var rState = stream._readableState;\n\n if (!rState || rState.autoDestroy && rState.endEmitted) {\n stream.destroy();\n }\n }\n }\n }\n\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n\n if (cb) {\n if (state.finished) process.nextTick(cb);else stream.once('finish', cb);\n }\n\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n } // reuse the free corkReq.\n\n\n state.corkedRequestsFree.next = corkReq;\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._writableState === undefined) {\n return false;\n }\n\n return this._writableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._writableState.destroyed = value;\n }\n});\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\n\nWritable.prototype._destroy = function (err, cb) {\n cb(err);\n};","'use strict';\n\nvar _Object$setPrototypeO;\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar finished = require('./end-of-stream');\n\nvar kLastResolve = Symbol('lastResolve');\nvar kLastReject = Symbol('lastReject');\nvar kError = Symbol('error');\nvar kEnded = Symbol('ended');\nvar kLastPromise = Symbol('lastPromise');\nvar kHandlePromise = Symbol('handlePromise');\nvar kStream = Symbol('stream');\n\nfunction createIterResult(value, done) {\n return {\n value: value,\n done: done\n };\n}\n\nfunction readAndResolve(iter) {\n var resolve = iter[kLastResolve];\n\n if (resolve !== null) {\n var data = iter[kStream].read(); // we defer if data is null\n // we can be expecting either 'end' or\n // 'error'\n\n if (data !== null) {\n iter[kLastPromise] = null;\n iter[kLastResolve] = null;\n iter[kLastReject] = null;\n resolve(createIterResult(data, false));\n }\n }\n}\n\nfunction onReadable(iter) {\n // we wait for the next tick, because it might\n // emit an error with process.nextTick\n process.nextTick(readAndResolve, iter);\n}\n\nfunction wrapForNext(lastPromise, iter) {\n return function (resolve, reject) {\n lastPromise.then(function () {\n if (iter[kEnded]) {\n resolve(createIterResult(undefined, true));\n return;\n }\n\n iter[kHandlePromise](resolve, reject);\n }, reject);\n };\n}\n\nvar AsyncIteratorPrototype = Object.getPrototypeOf(function () {});\nvar ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {\n get stream() {\n return this[kStream];\n },\n\n next: function next() {\n var _this = this;\n\n // if we have detected an error in the meanwhile\n // reject straight away\n var error = this[kError];\n\n if (error !== null) {\n return Promise.reject(error);\n }\n\n if (this[kEnded]) {\n return Promise.resolve(createIterResult(undefined, true));\n }\n\n if (this[kStream].destroyed) {\n // We need to defer via nextTick because if .destroy(err) is\n // called, the error will be emitted via nextTick, and\n // we cannot guarantee that there is no error lingering around\n // waiting to be emitted.\n return new Promise(function (resolve, reject) {\n process.nextTick(function () {\n if (_this[kError]) {\n reject(_this[kError]);\n } else {\n resolve(createIterResult(undefined, true));\n }\n });\n });\n } // if we have multiple next() calls\n // we will wait for the previous Promise to finish\n // this logic is optimized to support for await loops,\n // where next() is only called once at a time\n\n\n var lastPromise = this[kLastPromise];\n var promise;\n\n if (lastPromise) {\n promise = new Promise(wrapForNext(lastPromise, this));\n } else {\n // fast path needed to support multiple this.push()\n // without triggering the next() queue\n var data = this[kStream].read();\n\n if (data !== null) {\n return Promise.resolve(createIterResult(data, false));\n }\n\n promise = new Promise(this[kHandlePromise]);\n }\n\n this[kLastPromise] = promise;\n return promise;\n }\n}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {\n return this;\n}), _defineProperty(_Object$setPrototypeO, \"return\", function _return() {\n var _this2 = this;\n\n // destroy(err, cb) is a private API\n // we can guarantee we have that here, because we control the\n // Readable class this is attached to\n return new Promise(function (resolve, reject) {\n _this2[kStream].destroy(null, function (err) {\n if (err) {\n reject(err);\n return;\n }\n\n resolve(createIterResult(undefined, true));\n });\n });\n}), _Object$setPrototypeO), AsyncIteratorPrototype);\n\nvar createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {\n var _Object$create;\n\n var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {\n value: stream,\n writable: true\n }), _defineProperty(_Object$create, kLastResolve, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kLastReject, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kError, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kEnded, {\n value: stream._readableState.endEmitted,\n writable: true\n }), _defineProperty(_Object$create, kHandlePromise, {\n value: function value(resolve, reject) {\n var data = iterator[kStream].read();\n\n if (data) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n resolve(createIterResult(data, false));\n } else {\n iterator[kLastResolve] = resolve;\n iterator[kLastReject] = reject;\n }\n },\n writable: true\n }), _Object$create));\n iterator[kLastPromise] = null;\n finished(stream, function (err) {\n if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {\n var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise\n // returned by next() and store the error\n\n if (reject !== null) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n reject(err);\n }\n\n iterator[kError] = err;\n return;\n }\n\n var resolve = iterator[kLastResolve];\n\n if (resolve !== null) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n resolve(createIterResult(undefined, true));\n }\n\n iterator[kEnded] = true;\n });\n stream.on('readable', onReadable.bind(null, iterator));\n return iterator;\n};\n\nmodule.exports = createReadableStreamAsyncIterator;","'use strict';\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar _require = require('buffer'),\n Buffer = _require.Buffer;\n\nvar _require2 = require('util'),\n inspect = _require2.inspect;\n\nvar custom = inspect && inspect.custom || 'inspect';\n\nfunction copyBuffer(src, target, offset) {\n Buffer.prototype.copy.call(src, target, offset);\n}\n\nmodule.exports =\n/*#__PURE__*/\nfunction () {\n function BufferList() {\n _classCallCheck(this, BufferList);\n\n this.head = null;\n this.tail = null;\n this.length = 0;\n }\n\n _createClass(BufferList, [{\n key: \"push\",\n value: function push(v) {\n var entry = {\n data: v,\n next: null\n };\n if (this.length > 0) this.tail.next = entry;else this.head = entry;\n this.tail = entry;\n ++this.length;\n }\n }, {\n key: \"unshift\",\n value: function unshift(v) {\n var entry = {\n data: v,\n next: this.head\n };\n if (this.length === 0) this.tail = entry;\n this.head = entry;\n ++this.length;\n }\n }, {\n key: \"shift\",\n value: function shift() {\n if (this.length === 0) return;\n var ret = this.head.data;\n if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;\n --this.length;\n return ret;\n }\n }, {\n key: \"clear\",\n value: function clear() {\n this.head = this.tail = null;\n this.length = 0;\n }\n }, {\n key: \"join\",\n value: function join(s) {\n if (this.length === 0) return '';\n var p = this.head;\n var ret = '' + p.data;\n\n while (p = p.next) {\n ret += s + p.data;\n }\n\n return ret;\n }\n }, {\n key: \"concat\",\n value: function concat(n) {\n if (this.length === 0) return Buffer.alloc(0);\n var ret = Buffer.allocUnsafe(n >>> 0);\n var p = this.head;\n var i = 0;\n\n while (p) {\n copyBuffer(p.data, ret, i);\n i += p.data.length;\n p = p.next;\n }\n\n return ret;\n } // Consumes a specified amount of bytes or characters from the buffered data.\n\n }, {\n key: \"consume\",\n value: function consume(n, hasStrings) {\n var ret;\n\n if (n < this.head.data.length) {\n // `slice` is the same for buffers and strings.\n ret = this.head.data.slice(0, n);\n this.head.data = this.head.data.slice(n);\n } else if (n === this.head.data.length) {\n // First chunk is a perfect match.\n ret = this.shift();\n } else {\n // Result spans more than one buffer.\n ret = hasStrings ? this._getString(n) : this._getBuffer(n);\n }\n\n return ret;\n }\n }, {\n key: \"first\",\n value: function first() {\n return this.head.data;\n } // Consumes a specified amount of characters from the buffered data.\n\n }, {\n key: \"_getString\",\n value: function _getString(n) {\n var p = this.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) this.head = p.next;else this.head = this.tail = null;\n } else {\n this.head = p;\n p.data = str.slice(nb);\n }\n\n break;\n }\n\n ++c;\n }\n\n this.length -= c;\n return ret;\n } // Consumes a specified amount of bytes from the buffered data.\n\n }, {\n key: \"_getBuffer\",\n value: function _getBuffer(n) {\n var ret = Buffer.allocUnsafe(n);\n var p = this.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) this.head = p.next;else this.head = this.tail = null;\n } else {\n this.head = p;\n p.data = buf.slice(nb);\n }\n\n break;\n }\n\n ++c;\n }\n\n this.length -= c;\n return ret;\n } // Make sure the linked list only shows the minimal necessary information.\n\n }, {\n key: custom,\n value: function value(_, options) {\n return inspect(this, _objectSpread({}, options, {\n // Only inspect one level.\n depth: 0,\n // It should not recurse.\n customInspect: false\n }));\n }\n }]);\n\n return BufferList;\n}();","'use strict'; // undocumented cb() API, needed for core, not for public API\n\nfunction destroy(err, cb) {\n var _this = this;\n\n var readableDestroyed = this._readableState && this._readableState.destroyed;\n var writableDestroyed = this._writableState && this._writableState.destroyed;\n\n if (readableDestroyed || writableDestroyed) {\n if (cb) {\n cb(err);\n } else if (err) {\n if (!this._writableState) {\n process.nextTick(emitErrorNT, this, err);\n } else if (!this._writableState.errorEmitted) {\n this._writableState.errorEmitted = true;\n process.nextTick(emitErrorNT, this, err);\n }\n }\n\n return this;\n } // we set destroyed to true before firing error callbacks in order\n // to make it re-entrance safe in case destroy() is called within callbacks\n\n\n if (this._readableState) {\n this._readableState.destroyed = true;\n } // if this is a duplex stream mark the writable part as destroyed as well\n\n\n if (this._writableState) {\n this._writableState.destroyed = true;\n }\n\n this._destroy(err || null, function (err) {\n if (!cb && err) {\n if (!_this._writableState) {\n process.nextTick(emitErrorAndCloseNT, _this, err);\n } else if (!_this._writableState.errorEmitted) {\n _this._writableState.errorEmitted = true;\n process.nextTick(emitErrorAndCloseNT, _this, err);\n } else {\n process.nextTick(emitCloseNT, _this);\n }\n } else if (cb) {\n process.nextTick(emitCloseNT, _this);\n cb(err);\n } else {\n process.nextTick(emitCloseNT, _this);\n }\n });\n\n return this;\n}\n\nfunction emitErrorAndCloseNT(self, err) {\n emitErrorNT(self, err);\n emitCloseNT(self);\n}\n\nfunction emitCloseNT(self) {\n if (self._writableState && !self._writableState.emitClose) return;\n if (self._readableState && !self._readableState.emitClose) return;\n self.emit('close');\n}\n\nfunction undestroy() {\n if (this._readableState) {\n this._readableState.destroyed = false;\n this._readableState.reading = false;\n this._readableState.ended = false;\n this._readableState.endEmitted = false;\n }\n\n if (this._writableState) {\n this._writableState.destroyed = false;\n this._writableState.ended = false;\n this._writableState.ending = false;\n this._writableState.finalCalled = false;\n this._writableState.prefinished = false;\n this._writableState.finished = false;\n this._writableState.errorEmitted = false;\n }\n}\n\nfunction emitErrorNT(self, err) {\n self.emit('error', err);\n}\n\nfunction errorOrDestroy(stream, err) {\n // We have tests that rely on errors being emitted\n // in the same tick, so changing this is semver major.\n // For now when you opt-in to autoDestroy we allow\n // the error to be emitted nextTick. In a future\n // semver major update we should change the default to this.\n var rState = stream._readableState;\n var wState = stream._writableState;\n if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);\n}\n\nmodule.exports = {\n destroy: destroy,\n undestroy: undestroy,\n errorOrDestroy: errorOrDestroy\n};","// Ported from https://github.com/mafintosh/end-of-stream with\n// permission from the author, Mathias Buus (@mafintosh).\n'use strict';\n\nvar ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;\n\nfunction once(callback) {\n var called = false;\n return function () {\n if (called) return;\n called = true;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n callback.apply(this, args);\n };\n}\n\nfunction noop() {}\n\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function';\n}\n\nfunction eos(stream, opts, callback) {\n if (typeof opts === 'function') return eos(stream, null, opts);\n if (!opts) opts = {};\n callback = once(callback || noop);\n var readable = opts.readable || opts.readable !== false && stream.readable;\n var writable = opts.writable || opts.writable !== false && stream.writable;\n\n var onlegacyfinish = function onlegacyfinish() {\n if (!stream.writable) onfinish();\n };\n\n var writableEnded = stream._writableState && stream._writableState.finished;\n\n var onfinish = function onfinish() {\n writable = false;\n writableEnded = true;\n if (!readable) callback.call(stream);\n };\n\n var readableEnded = stream._readableState && stream._readableState.endEmitted;\n\n var onend = function onend() {\n readable = false;\n readableEnded = true;\n if (!writable) callback.call(stream);\n };\n\n var onerror = function onerror(err) {\n callback.call(stream, err);\n };\n\n var onclose = function onclose() {\n var err;\n\n if (readable && !readableEnded) {\n if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();\n return callback.call(stream, err);\n }\n\n if (writable && !writableEnded) {\n if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();\n return callback.call(stream, err);\n }\n };\n\n var onrequest = function onrequest() {\n stream.req.on('finish', onfinish);\n };\n\n if (isRequest(stream)) {\n stream.on('complete', onfinish);\n stream.on('abort', onclose);\n if (stream.req) onrequest();else stream.on('request', onrequest);\n } else if (writable && !stream._writableState) {\n // legacy streams\n stream.on('end', onlegacyfinish);\n stream.on('close', onlegacyfinish);\n }\n\n stream.on('end', onend);\n stream.on('finish', onfinish);\n if (opts.error !== false) stream.on('error', onerror);\n stream.on('close', onclose);\n return function () {\n stream.removeListener('complete', onfinish);\n stream.removeListener('abort', onclose);\n stream.removeListener('request', onrequest);\n if (stream.req) stream.req.removeListener('finish', onfinish);\n stream.removeListener('end', onlegacyfinish);\n stream.removeListener('close', onlegacyfinish);\n stream.removeListener('finish', onfinish);\n stream.removeListener('end', onend);\n stream.removeListener('error', onerror);\n stream.removeListener('close', onclose);\n };\n}\n\nmodule.exports = eos;","'use strict';\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar ERR_INVALID_ARG_TYPE = require('../../../errors').codes.ERR_INVALID_ARG_TYPE;\n\nfunction from(Readable, iterable, opts) {\n var iterator;\n\n if (iterable && typeof iterable.next === 'function') {\n iterator = iterable;\n } else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);\n\n var readable = new Readable(_objectSpread({\n objectMode: true\n }, opts)); // Reading boolean to protect against _read\n // being called before last iteration completion.\n\n var reading = false;\n\n readable._read = function () {\n if (!reading) {\n reading = true;\n next();\n }\n };\n\n function next() {\n return _next2.apply(this, arguments);\n }\n\n function _next2() {\n _next2 = _asyncToGenerator(function* () {\n try {\n var _ref = yield iterator.next(),\n value = _ref.value,\n done = _ref.done;\n\n if (done) {\n readable.push(null);\n } else if (readable.push((yield value))) {\n next();\n } else {\n reading = false;\n }\n } catch (err) {\n readable.destroy(err);\n }\n });\n return _next2.apply(this, arguments);\n }\n\n return readable;\n}\n\nmodule.exports = from;","// Ported from https://github.com/mafintosh/pump with\n// permission from the author, Mathias Buus (@mafintosh).\n'use strict';\n\nvar eos;\n\nfunction once(callback) {\n var called = false;\n return function () {\n if (called) return;\n called = true;\n callback.apply(void 0, arguments);\n };\n}\n\nvar _require$codes = require('../../../errors').codes,\n ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,\n ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;\n\nfunction noop(err) {\n // Rethrow the error if it exists to avoid swallowing it\n if (err) throw err;\n}\n\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function';\n}\n\nfunction destroyer(stream, reading, writing, callback) {\n callback = once(callback);\n var closed = false;\n stream.on('close', function () {\n closed = true;\n });\n if (eos === undefined) eos = require('./end-of-stream');\n eos(stream, {\n readable: reading,\n writable: writing\n }, function (err) {\n if (err) return callback(err);\n closed = true;\n callback();\n });\n var destroyed = false;\n return function (err) {\n if (closed) return;\n if (destroyed) return;\n destroyed = true; // request.destroy just do .end - .abort is what we want\n\n if (isRequest(stream)) return stream.abort();\n if (typeof stream.destroy === 'function') return stream.destroy();\n callback(err || new ERR_STREAM_DESTROYED('pipe'));\n };\n}\n\nfunction call(fn) {\n fn();\n}\n\nfunction pipe(from, to) {\n return from.pipe(to);\n}\n\nfunction popCallback(streams) {\n if (!streams.length) return noop;\n if (typeof streams[streams.length - 1] !== 'function') return noop;\n return streams.pop();\n}\n\nfunction pipeline() {\n for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {\n streams[_key] = arguments[_key];\n }\n\n var callback = popCallback(streams);\n if (Array.isArray(streams[0])) streams = streams[0];\n\n if (streams.length < 2) {\n throw new ERR_MISSING_ARGS('streams');\n }\n\n var error;\n var destroys = streams.map(function (stream, i) {\n var reading = i < streams.length - 1;\n var writing = i > 0;\n return destroyer(stream, reading, writing, function (err) {\n if (!error) error = err;\n if (err) destroys.forEach(call);\n if (reading) return;\n destroys.forEach(call);\n callback(error);\n });\n });\n return streams.reduce(pipe);\n}\n\nmodule.exports = pipeline;","'use strict';\n\nvar ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;\n\nfunction highWaterMarkFrom(options, isDuplex, duplexKey) {\n return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;\n}\n\nfunction getHighWaterMark(state, options, duplexKey, isDuplex) {\n var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);\n\n if (hwm != null) {\n if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {\n var name = isDuplex ? duplexKey : 'highWaterMark';\n throw new ERR_INVALID_OPT_VALUE(name, hwm);\n }\n\n return Math.floor(hwm);\n } // Default value\n\n\n return state.objectMode ? 16 : 16 * 1024;\n}\n\nmodule.exports = {\n getHighWaterMark: getHighWaterMark\n};","module.exports = require('stream');\n","var Stream = require('stream');\nif (process.env.READABLE_STREAM === 'disable' && Stream) {\n module.exports = Stream.Readable;\n Object.assign(module.exports, Stream);\n module.exports.Stream = Stream;\n} else {\n exports = module.exports = require('./lib/_stream_readable.js');\n exports.Stream = Stream || exports;\n exports.Readable = exports;\n exports.Writable = require('./lib/_stream_writable.js');\n exports.Duplex = require('./lib/_stream_duplex.js');\n exports.Transform = require('./lib/_stream_transform.js');\n exports.PassThrough = require('./lib/_stream_passthrough.js');\n exports.finished = require('./lib/internal/streams/end-of-stream.js');\n exports.pipeline = require('./lib/internal/streams/pipeline.js');\n}\n","/* eslint-disable node/no-deprecated-api */\n\n'use strict'\n\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\nvar safer = {}\n\nvar key\n\nfor (key in buffer) {\n if (!buffer.hasOwnProperty(key)) continue\n if (key === 'SlowBuffer' || key === 'Buffer') continue\n safer[key] = buffer[key]\n}\n\nvar Safer = safer.Buffer = {}\nfor (key in Buffer) {\n if (!Buffer.hasOwnProperty(key)) continue\n if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue\n Safer[key] = Buffer[key]\n}\n\nsafer.Buffer.prototype = Buffer.prototype\n\nif (!Safer.from || Safer.from === Uint8Array.from) {\n Safer.from = function (value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('The \"value\" argument must not be of type number. Received type ' + typeof value)\n }\n if (value && typeof value.length === 'undefined') {\n throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)\n }\n return Buffer(value, encodingOrOffset, length)\n }\n}\n\nif (!Safer.alloc) {\n Safer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('The \"size\" argument must be of type number. Received type ' + typeof size)\n }\n if (size < 0 || size >= 2 * (1 << 30)) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n var buf = Buffer(size)\n if (!fill || fill.length === 0) {\n buf.fill(0)\n } else if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n return buf\n }\n}\n\nif (!safer.kStringMaxLength) {\n try {\n safer.kStringMaxLength = process.binding('buffer').kStringMaxLength\n } catch (e) {\n // we can't determine kStringMaxLength in environments where process.binding\n // is unsupported, so let's not set it\n }\n}\n\nif (!safer.constants) {\n safer.constants = {\n MAX_LENGTH: safer.kMaxLength\n }\n if (safer.kStringMaxLength) {\n safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength\n }\n}\n\nmodule.exports = safer\n","var fs = require('fs');\n\nmodule.exports = function (filepath, split, encoding) {\n split = typeof split !== 'undefined' ? split : \"\\n\";\n encoding = typeof encoding !== 'undefined' ? encoding : \"utf8\";\n\n var ca = [];\n var chain = fs.readFileSync(filepath, encoding);\n if(chain.indexOf(\"-END CERTIFICATE-\") < 0 || chain.indexOf(\"-BEGIN CERTIFICATE-\") < 0){\n throw Error(\"File does not contain 'BEGIN CERTIFICATE' or 'END CERTIFICATE'\");\n }\n chain = chain.split(split);\n var cert = [];\n var _i, _len;\n for (_i = 0, _len = chain.length; _i < _len; _i++) {\n var line = chain[_i];\n if (!(line.length !== 0)) {\n continue;\n }\n cert.push(line);\n if (line.match(/-END CERTIFICATE-/)) {\n ca.push(cert.join(split));\n cert = [];\n }\n }\n return ca;\n}\n","'use strict';\n\nconst {\n Duplex: DuplexStream,\n Readable: ReadableStream,\n Writable: WritableStream,\n} = require('stream');\n\nconst {\n CHANNEL_EXTENDED_DATATYPE: { STDERR },\n} = require('./protocol/constants.js');\nconst { bufferSlice } = require('./protocol/utils.js');\n\nconst PACKET_SIZE = 32 * 1024;\nconst MAX_WINDOW = 2 * 1024 * 1024;\nconst WINDOW_THRESHOLD = MAX_WINDOW / 2;\n\nclass ClientStderr extends ReadableStream {\n constructor(channel, streamOpts) {\n super(streamOpts);\n\n this._channel = channel;\n }\n _read(n) {\n if (this._channel._waitChanDrain) {\n this._channel._waitChanDrain = false;\n if (this._channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(this._channel);\n }\n }\n}\n\nclass ServerStderr extends WritableStream {\n constructor(channel) {\n super({ highWaterMark: MAX_WINDOW });\n\n this._channel = channel;\n }\n\n _write(data, encoding, cb) {\n const channel = this._channel;\n const protocol = channel._client._protocol;\n const outgoing = channel.outgoing;\n const packetSize = outgoing.packetSize;\n const id = outgoing.id;\n let window = outgoing.window;\n const len = data.length;\n let p = 0;\n\n if (outgoing.state !== 'open')\n return;\n\n while (len - p > 0 && window > 0) {\n let sliceLen = len - p;\n if (sliceLen > window)\n sliceLen = window;\n if (sliceLen > packetSize)\n sliceLen = packetSize;\n\n if (p === 0 && sliceLen === len)\n protocol.channelExtData(id, data, STDERR);\n else\n protocol.channelExtData(id, bufferSlice(data, p, p + sliceLen), STDERR);\n\n p += sliceLen;\n window -= sliceLen;\n }\n\n outgoing.window = window;\n\n if (len - p > 0) {\n if (window === 0)\n channel._waitWindow = true;\n if (p > 0)\n channel._chunkErr = bufferSlice(data, p, len);\n else\n channel._chunkErr = data;\n channel._chunkcbErr = cb;\n return;\n }\n\n cb();\n }\n}\n\nclass Channel extends DuplexStream {\n constructor(client, info, opts) {\n const streamOpts = {\n highWaterMark: MAX_WINDOW,\n allowHalfOpen: (!opts || (opts && opts.allowHalfOpen !== false)),\n emitClose: false,\n };\n super(streamOpts);\n this.allowHalfOpen = streamOpts.allowHalfOpen;\n\n const server = !!(opts && opts.server);\n\n this.server = server;\n this.type = info.type;\n this.subtype = undefined;\n\n /*\n incoming and outgoing contain these properties:\n {\n id: undefined,\n window: undefined,\n packetSize: undefined,\n state: 'closed'\n }\n */\n this.incoming = info.incoming;\n this.outgoing = info.outgoing;\n this._callbacks = [];\n\n this._client = client;\n this._hasX11 = false;\n this._exit = {\n code: undefined,\n signal: undefined,\n dump: undefined,\n desc: undefined,\n };\n\n this.stdin = this.stdout = this;\n\n if (server)\n this.stderr = new ServerStderr(this);\n else\n this.stderr = new ClientStderr(this, streamOpts);\n\n // Outgoing data\n this._waitWindow = false; // SSH-level backpressure\n\n // Incoming data\n this._waitChanDrain = false; // Channel Readable side backpressure\n\n this._chunk = undefined;\n this._chunkcb = undefined;\n this._chunkErr = undefined;\n this._chunkcbErr = undefined;\n\n this.on('finish', onFinish)\n .on('prefinish', onFinish); // For node v0.11+\n\n this.on('end', onEnd).on('close', onEnd);\n }\n\n _read(n) {\n if (this._waitChanDrain) {\n this._waitChanDrain = false;\n if (this.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(this);\n }\n }\n\n _write(data, encoding, cb) {\n const protocol = this._client._protocol;\n const outgoing = this.outgoing;\n const packetSize = outgoing.packetSize;\n const id = outgoing.id;\n let window = outgoing.window;\n const len = data.length;\n let p = 0;\n\n if (outgoing.state !== 'open')\n return;\n\n while (len - p > 0 && window > 0) {\n let sliceLen = len - p;\n if (sliceLen > window)\n sliceLen = window;\n if (sliceLen > packetSize)\n sliceLen = packetSize;\n\n if (p === 0 && sliceLen === len)\n protocol.channelData(id, data);\n else\n protocol.channelData(id, bufferSlice(data, p, p + sliceLen));\n\n p += sliceLen;\n window -= sliceLen;\n }\n\n outgoing.window = window;\n\n if (len - p > 0) {\n if (window === 0)\n this._waitWindow = true;\n if (p > 0)\n this._chunk = bufferSlice(data, p, len);\n else\n this._chunk = data;\n this._chunkcb = cb;\n return;\n }\n\n cb();\n }\n\n eof() {\n if (this.outgoing.state === 'open') {\n this.outgoing.state = 'eof';\n this._client._protocol.channelEOF(this.outgoing.id);\n }\n }\n\n close() {\n if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {\n this.outgoing.state = 'closing';\n this._client._protocol.channelClose(this.outgoing.id);\n }\n }\n\n destroy() {\n this.end();\n this.close();\n }\n\n // Session type-specific methods =============================================\n setWindow(rows, cols, height, width) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (this.type === 'session'\n && (this.subtype === 'shell' || this.subtype === 'exec')\n && this.writable\n && this.outgoing.state === 'open') {\n this._client._protocol.windowChange(this.outgoing.id,\n rows,\n cols,\n height,\n width);\n }\n }\n\n signal(signalName) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (this.type === 'session'\n && this.writable\n && this.outgoing.state === 'open') {\n this._client._protocol.signal(this.outgoing.id, signalName);\n }\n }\n\n exit(statusOrSignal, coreDumped, msg) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (this.type === 'session'\n && this.writable\n && this.outgoing.state === 'open') {\n if (typeof statusOrSignal === 'number') {\n this._client._protocol.exitStatus(this.outgoing.id, statusOrSignal);\n } else {\n this._client._protocol.exitSignal(this.outgoing.id,\n statusOrSignal,\n coreDumped,\n msg);\n }\n }\n }\n\n}\n\nfunction onFinish() {\n this.eof();\n if (this.server || !this.allowHalfOpen)\n this.close();\n this.writable = false;\n}\n\nfunction onEnd() {\n this.readable = false;\n}\n\nfunction windowAdjust(self) {\n if (self.outgoing.state === 'closed')\n return;\n const amt = MAX_WINDOW - self.incoming.window;\n if (amt <= 0)\n return;\n self.incoming.window += amt;\n self._client._protocol.channelWindowAdjust(self.outgoing.id, amt);\n}\n\nmodule.exports = {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n};\n",null,"// TODO:\n// * add `.connected` or similar property to allow immediate connection\n// status checking\n// * add/improve debug output during user authentication phase\n'use strict';\n\nconst {\n createHash,\n getHashes,\n randomFillSync,\n} = require('crypto');\nconst { Socket } = require('net');\nconst { lookup: dnsLookup } = require('dns');\nconst EventEmitter = require('events');\nconst HASHES = getHashes();\n\nconst {\n COMPAT,\n CHANNEL_EXTENDED_DATATYPE: { STDERR },\n CHANNEL_OPEN_FAILURE,\n DEFAULT_CIPHER,\n DEFAULT_COMPRESSION,\n DEFAULT_KEX,\n DEFAULT_MAC,\n DEFAULT_SERVER_HOST_KEY,\n DISCONNECT_REASON,\n DISCONNECT_REASON_BY_VALUE,\n SUPPORTED_CIPHER,\n SUPPORTED_COMPRESSION,\n SUPPORTED_KEX,\n SUPPORTED_MAC,\n SUPPORTED_SERVER_HOST_KEY,\n} = require('./protocol/constants.js');\nconst { init: cryptoInit } = require('./protocol/crypto.js');\nconst Protocol = require('./protocol/Protocol.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst { SFTP } = require('./protocol/SFTP.js');\nconst {\n bufferCopy,\n makeBufferParser,\n makeError,\n readUInt32BE,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./protocol/utils.js');\n\nconst { AgentContext, createAgent, isAgent } = require('./agent.js');\nconst {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n} = require('./Channel.js');\nconst {\n ChannelManager,\n generateAlgorithmList,\n isWritable,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n} = require('./utils.js');\n\nconst bufferParser = makeBufferParser();\nconst sigParser = makeBufferParser();\nconst RE_OPENSSH = /^OpenSSH_(?:(?![0-4])\\d)|(?:\\d{2,})/;\nconst noop = (err) => {};\n\nclass Client extends EventEmitter {\n constructor() {\n super();\n\n this.config = {\n host: undefined,\n port: undefined,\n localAddress: undefined,\n localPort: undefined,\n forceIPv4: undefined,\n forceIPv6: undefined,\n keepaliveCountMax: undefined,\n keepaliveInterval: undefined,\n readyTimeout: undefined,\n ident: undefined,\n\n username: undefined,\n password: undefined,\n privateKey: undefined,\n tryKeyboard: undefined,\n agent: undefined,\n allowAgentFwd: undefined,\n authHandler: undefined,\n\n hostHashAlgo: undefined,\n hostHashCb: undefined,\n strictVendor: undefined,\n debug: undefined\n };\n\n this._agent = undefined;\n this._readyTimeout = undefined;\n this._chanMgr = undefined;\n this._callbacks = undefined;\n this._forwarding = undefined;\n this._forwardingUnix = undefined;\n this._acceptX11 = undefined;\n this._agentFwdEnabled = undefined;\n this._remoteVer = undefined;\n\n this._protocol = undefined;\n this._sock = undefined;\n this._resetKA = undefined;\n }\n\n connect(cfg) {\n if (this._sock && isWritable(this._sock)) {\n this.once('close', () => {\n this.connect(cfg);\n });\n this.end();\n return this;\n }\n\n this.config.host = cfg.hostname || cfg.host || 'localhost';\n this.config.port = cfg.port || 22;\n this.config.localAddress = (typeof cfg.localAddress === 'string'\n ? cfg.localAddress\n : undefined);\n this.config.localPort = (typeof cfg.localPort === 'string'\n || typeof cfg.localPort === 'number'\n ? cfg.localPort\n : undefined);\n this.config.forceIPv4 = cfg.forceIPv4 || false;\n this.config.forceIPv6 = cfg.forceIPv6 || false;\n this.config.keepaliveCountMax = (typeof cfg.keepaliveCountMax === 'number'\n && cfg.keepaliveCountMax >= 0\n ? cfg.keepaliveCountMax\n : 3);\n this.config.keepaliveInterval = (typeof cfg.keepaliveInterval === 'number'\n && cfg.keepaliveInterval > 0\n ? cfg.keepaliveInterval\n : 0);\n this.config.readyTimeout = (typeof cfg.readyTimeout === 'number'\n && cfg.readyTimeout >= 0\n ? cfg.readyTimeout\n : 20000);\n this.config.ident = (typeof cfg.ident === 'string'\n || Buffer.isBuffer(cfg.ident)\n ? cfg.ident\n : undefined);\n\n const algorithms = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: [],\n },\n sc: undefined,\n };\n let allOfferDefaults = true;\n if (typeof cfg.algorithms === 'object' && cfg.algorithms !== null) {\n algorithms.kex = generateAlgorithmList(cfg.algorithms.kex,\n DEFAULT_KEX,\n SUPPORTED_KEX);\n if (algorithms.kex !== DEFAULT_KEX)\n allOfferDefaults = false;\n\n algorithms.serverHostKey =\n generateAlgorithmList(cfg.algorithms.serverHostKey,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY);\n if (algorithms.serverHostKey !== DEFAULT_SERVER_HOST_KEY)\n allOfferDefaults = false;\n\n algorithms.cs.cipher = generateAlgorithmList(cfg.algorithms.cipher,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER);\n if (algorithms.cs.cipher !== DEFAULT_CIPHER)\n allOfferDefaults = false;\n\n algorithms.cs.mac = generateAlgorithmList(cfg.algorithms.hmac,\n DEFAULT_MAC,\n SUPPORTED_MAC);\n if (algorithms.cs.mac !== DEFAULT_MAC)\n allOfferDefaults = false;\n\n algorithms.cs.compress = generateAlgorithmList(cfg.algorithms.compress,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION);\n if (algorithms.cs.compress !== DEFAULT_COMPRESSION)\n allOfferDefaults = false;\n\n if (!allOfferDefaults)\n algorithms.sc = algorithms.cs;\n }\n\n if (typeof cfg.username === 'string')\n this.config.username = cfg.username;\n else if (typeof cfg.user === 'string')\n this.config.username = cfg.user;\n else\n throw new Error('Invalid username');\n\n this.config.password = (typeof cfg.password === 'string'\n ? cfg.password\n : undefined);\n this.config.privateKey = (typeof cfg.privateKey === 'string'\n || Buffer.isBuffer(cfg.privateKey)\n ? cfg.privateKey\n : undefined);\n this.config.localHostname = (typeof cfg.localHostname === 'string'\n ? cfg.localHostname\n : undefined);\n this.config.localUsername = (typeof cfg.localUsername === 'string'\n ? cfg.localUsername\n : undefined);\n this.config.tryKeyboard = (cfg.tryKeyboard === true);\n if (typeof cfg.agent === 'string' && cfg.agent.length)\n this.config.agent = createAgent(cfg.agent);\n else if (isAgent(cfg.agent))\n this.config.agent = cfg.agent;\n else\n this.config.agent = undefined;\n this.config.allowAgentFwd = (cfg.agentForward === true\n && this.config.agent !== undefined);\n let authHandler = this.config.authHandler = (\n typeof cfg.authHandler === 'function'\n || Array.isArray(cfg.authHandler)\n ? cfg.authHandler\n : undefined\n );\n\n this.config.strictVendor = (typeof cfg.strictVendor === 'boolean'\n ? cfg.strictVendor\n : true);\n\n const debug = this.config.debug = (typeof cfg.debug === 'function'\n ? cfg.debug\n : undefined);\n\n if (cfg.agentForward === true && !this.config.allowAgentFwd) {\n throw new Error(\n 'You must set a valid agent path to allow agent forwarding'\n );\n }\n\n let callbacks = this._callbacks = [];\n this._chanMgr = new ChannelManager(this);\n this._forwarding = {};\n this._forwardingUnix = {};\n this._acceptX11 = 0;\n this._agentFwdEnabled = false;\n this._agent = (this.config.agent ? this.config.agent : undefined);\n this._remoteVer = undefined;\n let privateKey;\n\n if (this.config.privateKey) {\n privateKey = parseKey(this.config.privateKey, cfg.passphrase);\n if (privateKey instanceof Error)\n throw new Error(`Cannot parse privateKey: ${privateKey.message}`);\n if (Array.isArray(privateKey)) {\n // OpenSSH's newer format only stores 1 key for now\n privateKey = privateKey[0];\n }\n if (privateKey.getPrivatePEM() === null) {\n throw new Error(\n 'privateKey value does not contain a (valid) private key'\n );\n }\n }\n\n let hostVerifier;\n if (typeof cfg.hostVerifier === 'function') {\n const hashCb = cfg.hostVerifier;\n let hasher;\n if (HASHES.indexOf(cfg.hostHash) !== -1) {\n // Default to old behavior of hashing on user's behalf\n hasher = createHash(cfg.hostHash);\n }\n hostVerifier = (key, verify) => {\n if (hasher) {\n hasher.update(key);\n key = hasher.digest('hex');\n }\n const ret = hashCb(key, verify);\n if (ret !== undefined)\n verify(ret);\n };\n }\n\n const sock = this._sock = (cfg.sock || new Socket());\n let ready = false;\n let sawHeader = false;\n if (this._protocol)\n this._protocol.cleanup();\n const DEBUG_HANDLER = (!debug ? undefined : (p, display, msg) => {\n debug(`Debug output from server: ${JSON.stringify(msg)}`);\n });\n const proto = this._protocol = new Protocol({\n ident: this.config.ident,\n offer: (allOfferDefaults ? undefined : algorithms),\n onWrite: (data) => {\n if (isWritable(sock))\n sock.write(data);\n },\n onError: (err) => {\n if (err.level === 'handshake')\n clearTimeout(this._readyTimeout);\n if (!proto._destruct)\n sock.removeAllListeners('data');\n this.emit('error', err);\n try {\n sock.end();\n } catch {}\n },\n onHeader: (header) => {\n sawHeader = true;\n this._remoteVer = header.versions.software;\n if (header.greeting)\n this.emit('greeting', header.greeting);\n },\n onHandshakeComplete: (negotiated) => {\n this.emit('handshake', negotiated);\n if (!ready) {\n ready = true;\n proto.service('ssh-userauth');\n }\n },\n debug,\n hostVerifier,\n messageHandlers: {\n DEBUG: DEBUG_HANDLER,\n DISCONNECT: (p, reason, desc) => {\n if (reason !== DISCONNECT_REASON.BY_APPLICATION) {\n if (!desc) {\n desc = DISCONNECT_REASON_BY_VALUE[reason];\n if (desc === undefined)\n desc = `Unexpected disconnection reason: ${reason}`;\n }\n const err = new Error(desc);\n err.code = reason;\n this.emit('error', err);\n }\n sock.end();\n },\n SERVICE_ACCEPT: (p, name) => {\n if (name === 'ssh-userauth')\n tryNextAuth();\n },\n USERAUTH_BANNER: (p, msg) => {\n this.emit('banner', msg);\n },\n USERAUTH_SUCCESS: (p) => {\n // Start keepalive mechanism\n resetKA();\n\n clearTimeout(this._readyTimeout);\n\n this.emit('ready');\n },\n USERAUTH_FAILURE: (p, authMethods, partialSuccess) => {\n if (curAuth.type === 'agent') {\n const pos = curAuth.agentCtx.pos();\n debug && debug(`Client: Agent key #${pos + 1} failed`);\n return tryNextAgentKey();\n }\n\n debug && debug(`Client: ${curAuth.type} auth failed`);\n\n curPartial = partialSuccess;\n curAuthsLeft = authMethods;\n tryNextAuth();\n },\n USERAUTH_PASSWD_CHANGEREQ: (p, prompt) => {\n if (curAuth.type === 'password') {\n // TODO: support a `changePrompt()` on `curAuth` that defaults to\n // emitting 'change password' as before\n this.emit('change password', prompt, (newPassword) => {\n proto.authPassword(\n this.config.username,\n this.config.password,\n newPassword\n );\n });\n }\n },\n USERAUTH_PK_OK: (p) => {\n if (curAuth.type === 'agent') {\n const key = curAuth.agentCtx.currentKey();\n proto.authPK(curAuth.username, key, (buf, cb) => {\n curAuth.agentCtx.sign(key, buf, {}, (err, signed) => {\n if (err) {\n err.level = 'agent';\n this.emit('error', err);\n } else {\n return cb(signed);\n }\n\n tryNextAgentKey();\n });\n });\n } else if (curAuth.type === 'publickey') {\n proto.authPK(curAuth.username, curAuth.key, (buf, cb) => {\n const signature = curAuth.key.sign(buf);\n if (signature instanceof Error) {\n signature.message =\n `Error signing data with key: ${signature.message}`;\n signature.level = 'client-authentication';\n this.emit('error', signature);\n return tryNextAuth();\n }\n cb(signature);\n });\n }\n },\n USERAUTH_INFO_REQUEST: (p, name, instructions, prompts) => {\n if (curAuth.type === 'keyboard-interactive') {\n const nprompts = (Array.isArray(prompts) ? prompts.length : 0);\n if (nprompts === 0) {\n debug && debug(\n 'Client: Sending automatic USERAUTH_INFO_RESPONSE'\n );\n proto.authInfoRes();\n return;\n }\n // We sent a keyboard-interactive user authentication request and\n // now the server is sending us the prompts we need to present to\n // the user\n curAuth.prompt(\n name,\n instructions,\n '',\n prompts,\n (answers) => {\n proto.authInfoRes(answers);\n }\n );\n }\n },\n REQUEST_SUCCESS: (p, data) => {\n if (callbacks.length)\n callbacks.shift()(false, data);\n },\n REQUEST_FAILURE: (p) => {\n if (callbacks.length)\n callbacks.shift()(true);\n },\n GLOBAL_REQUEST: (p, name, wantReply, data) => {\n switch (name) {\n case 'hostkeys-00@openssh.com':\n // Automatically verify keys before passing to end user\n hostKeysProve(this, data, (err, keys) => {\n if (err)\n return;\n this.emit('hostkeys', keys);\n });\n if (wantReply)\n proto.requestSuccess();\n break;\n default:\n // Auto-reject all other global requests, this can be especially\n // useful if the server is sending us dummy keepalive global\n // requests\n if (wantReply)\n proto.requestFailure();\n }\n },\n CHANNEL_OPEN: (p, info) => {\n // Handle incoming requests from server, typically a forwarded TCP or\n // X11 connection\n onCHANNEL_OPEN(this, info);\n },\n CHANNEL_OPEN_CONFIRMATION: (p, info) => {\n const channel = this._chanMgr.get(info.recipient);\n if (typeof channel !== 'function')\n return;\n\n const isSFTP = (channel.type === 'sftp');\n const type = (isSFTP ? 'session' : channel.type);\n const chanInfo = {\n type,\n incoming: {\n id: info.recipient,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n const instance = (\n isSFTP\n ? new SFTP(this, chanInfo, { debug })\n : new Channel(this, chanInfo)\n );\n this._chanMgr.update(info.recipient, instance);\n channel(undefined, instance);\n },\n CHANNEL_OPEN_FAILURE: (p, recipient, reason, description) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'function')\n return;\n\n const info = { reason, description };\n onChannelOpenFailure(this, recipient, info, channel);\n },\n CHANNEL_DATA: (p, recipient, data) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (channel.push(data) === false) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_EXTENDED_DATA: (p, recipient, data, type) => {\n if (type !== STDERR)\n return;\n\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (!channel.stderr.push(data)) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_WINDOW_ADJUST: (p, recipient, amount) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The other side is allowing us to send `amount` more bytes of data\n channel.outgoing.window += amount;\n\n if (channel._waitWindow) {\n channel._waitWindow = false;\n\n if (channel._chunk) {\n channel._write(channel._chunk, null, channel._chunkcb);\n } else if (channel._chunkcb) {\n channel._chunkcb();\n } else if (channel._chunkErr) {\n channel.stderr._write(channel._chunkErr,\n null,\n channel._chunkcbErr);\n } else if (channel._chunkcbErr) {\n channel._chunkcbErr();\n }\n }\n },\n CHANNEL_SUCCESS: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n this._resetKA();\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(false);\n },\n CHANNEL_FAILURE: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n this._resetKA();\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(true);\n },\n CHANNEL_REQUEST: (p, recipient, type, wantReply, data) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n const exit = channel._exit;\n if (exit.code !== undefined)\n return;\n switch (type) {\n case 'exit-status':\n channel.emit('exit', exit.code = data);\n return;\n case 'exit-signal':\n channel.emit('exit',\n exit.code = null,\n exit.signal = `SIG${data.signal}`,\n exit.dump = data.coreDumped,\n exit.desc = data.errorMessage);\n return;\n }\n\n // Keepalive request? OpenSSH will send one as a channel request if\n // there is a channel open\n\n if (wantReply)\n p.channelFailure(channel.outgoing.id);\n },\n CHANNEL_EOF: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.incoming.state !== 'open')\n return;\n channel.incoming.state = 'eof';\n\n if (channel.readable)\n channel.push(null);\n if (channel.stderr.readable)\n channel.stderr.push(null);\n },\n CHANNEL_CLOSE: (p, recipient) => {\n onCHANNEL_CLOSE(this, recipient, this._chanMgr.get(recipient));\n },\n },\n });\n\n sock.pause();\n\n // TODO: check keepalive implementation\n // Keepalive-related\n const kainterval = this.config.keepaliveInterval;\n const kacountmax = this.config.keepaliveCountMax;\n let kacount = 0;\n let katimer;\n const sendKA = () => {\n if (++kacount > kacountmax) {\n clearInterval(katimer);\n if (sock.readable) {\n const err = new Error('Keepalive timeout');\n err.level = 'client-timeout';\n this.emit('error', err);\n sock.destroy();\n }\n return;\n }\n if (isWritable(sock)) {\n // Append dummy callback to keep correct callback order\n callbacks.push(resetKA);\n proto.ping();\n } else {\n clearInterval(katimer);\n }\n };\n function resetKA() {\n if (kainterval > 0) {\n kacount = 0;\n clearInterval(katimer);\n if (isWritable(sock))\n katimer = setInterval(sendKA, kainterval);\n }\n }\n this._resetKA = resetKA;\n\n const onDone = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n if (wasConnected && !sawHeader) {\n const err =\n makeError('Connection lost before handshake', 'protocol', true);\n this.emit('error', err);\n }\n };\n })();\n const onConnect = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n\n wasConnected = true;\n debug && debug('Socket connected');\n this.emit('connect');\n\n cryptoInit.then(() => {\n proto.start();\n sock.on('data', (data) => {\n try {\n proto.parse(data, 0, data.length);\n } catch (ex) {\n this.emit('error', ex);\n try {\n if (isWritable(sock))\n sock.end();\n } catch {}\n }\n });\n\n // Drain stderr if we are connection hopping using an exec stream\n if (sock.stderr && typeof sock.stderr.resume === 'function')\n sock.stderr.resume();\n\n sock.resume();\n }).catch((err) => {\n this.emit('error', err);\n try {\n if (isWritable(sock))\n sock.end();\n } catch {}\n });\n };\n })();\n let wasConnected = false;\n sock.on('connect', onConnect)\n .on('timeout', () => {\n this.emit('timeout');\n }).on('error', (err) => {\n debug && debug(`Socket error: ${err.message}`);\n clearTimeout(this._readyTimeout);\n err.level = 'client-socket';\n this.emit('error', err);\n }).on('end', () => {\n debug && debug('Socket ended');\n onDone();\n proto.cleanup();\n clearTimeout(this._readyTimeout);\n clearInterval(katimer);\n this.emit('end');\n }).on('close', () => {\n debug && debug('Socket closed');\n onDone();\n proto.cleanup();\n clearTimeout(this._readyTimeout);\n clearInterval(katimer);\n this.emit('close');\n\n // Notify outstanding channel requests of disconnection ...\n const callbacks_ = callbacks;\n callbacks = this._callbacks = [];\n const err = new Error('No response from server');\n for (let i = 0; i < callbacks_.length; ++i)\n callbacks_[i](err);\n\n // Simulate error for any channels waiting to be opened\n this._chanMgr.cleanup(err);\n });\n\n // Begin authentication handling ===========================================\n let curAuth;\n let curPartial = null;\n let curAuthsLeft = null;\n const authsAllowed = ['none'];\n if (this.config.password !== undefined)\n authsAllowed.push('password');\n if (privateKey !== undefined)\n authsAllowed.push('publickey');\n if (this._agent !== undefined)\n authsAllowed.push('agent');\n if (this.config.tryKeyboard)\n authsAllowed.push('keyboard-interactive');\n if (privateKey !== undefined\n && this.config.localHostname !== undefined\n && this.config.localUsername !== undefined) {\n authsAllowed.push('hostbased');\n }\n\n if (Array.isArray(authHandler))\n authHandler = makeSimpleAuthHandler(authHandler);\n else if (typeof authHandler !== 'function')\n authHandler = makeSimpleAuthHandler(authsAllowed);\n\n let hasSentAuth = false;\n const doNextAuth = (nextAuth) => {\n if (hasSentAuth)\n return;\n hasSentAuth = true;\n\n if (nextAuth === false) {\n const err = new Error('All configured authentication methods failed');\n err.level = 'client-authentication';\n this.emit('error', err);\n this.end();\n return;\n }\n\n if (typeof nextAuth === 'string') {\n // Remain backwards compatible with original `authHandler()` usage,\n // which only supported passing names of next method to try using data\n // from the `connect()` config object\n\n const type = nextAuth;\n if (authsAllowed.indexOf(type) === -1)\n return skipAuth(`Authentication method not allowed: ${type}`);\n\n const username = this.config.username;\n switch (type) {\n case 'password':\n nextAuth = { type, username, password: this.config.password };\n break;\n case 'publickey':\n nextAuth = { type, username, key: privateKey };\n break;\n case 'hostbased':\n nextAuth = {\n type,\n username,\n key: privateKey,\n localHostname: this.config.localHostname,\n localUsername: this.config.localUsername,\n };\n break;\n case 'agent':\n nextAuth = {\n type,\n username,\n agentCtx: new AgentContext(this._agent),\n };\n break;\n case 'keyboard-interactive':\n nextAuth = {\n type,\n username,\n prompt: (...args) => this.emit('keyboard-interactive', ...args),\n };\n break;\n case 'none':\n nextAuth = { type, username };\n break;\n default:\n return skipAuth(\n `Skipping unsupported authentication method: ${nextAuth}`\n );\n }\n } else if (typeof nextAuth !== 'object' || nextAuth === null) {\n return skipAuth(\n `Skipping invalid authentication attempt: ${nextAuth}`\n );\n } else {\n const username = nextAuth.username;\n if (typeof username !== 'string') {\n return skipAuth(\n `Skipping invalid authentication attempt: ${nextAuth}`\n );\n }\n const type = nextAuth.type;\n switch (type) {\n case 'password': {\n const { password } = nextAuth;\n if (typeof password !== 'string' && !Buffer.isBuffer(password))\n return skipAuth('Skipping invalid password auth attempt');\n nextAuth = { type, username, password };\n break;\n }\n case 'publickey': {\n const key = parseKey(nextAuth.key, nextAuth.passphrase);\n if (key instanceof Error)\n return skipAuth('Skipping invalid key auth attempt');\n if (!key.isPrivateKey())\n return skipAuth('Skipping non-private key');\n nextAuth = { type, username, key };\n break;\n }\n case 'hostbased': {\n const { localHostname, localUsername } = nextAuth;\n const key = parseKey(nextAuth.key, nextAuth.passphrase);\n if (key instanceof Error\n || typeof localHostname !== 'string'\n || typeof localUsername !== 'string') {\n return skipAuth('Skipping invalid hostbased auth attempt');\n }\n if (!key.isPrivateKey())\n return skipAuth('Skipping non-private key');\n nextAuth = { type, username, key, localHostname, localUsername };\n break;\n }\n case 'agent': {\n let agent = nextAuth.agent;\n if (typeof agent === 'string' && agent.length) {\n agent = createAgent(agent);\n } else if (!isAgent(agent)) {\n return skipAuth(\n `Skipping invalid agent: ${nextAuth.agent}`\n );\n }\n nextAuth = { type, username, agentCtx: new AgentContext(agent) };\n break;\n }\n case 'keyboard-interactive': {\n const { prompt } = nextAuth;\n if (typeof prompt !== 'function') {\n return skipAuth(\n 'Skipping invalid keyboard-interactive auth attempt'\n );\n }\n nextAuth = { type, username, prompt };\n break;\n }\n case 'none':\n nextAuth = { type, username };\n break;\n default:\n return skipAuth(\n `Skipping unsupported authentication method: ${nextAuth}`\n );\n }\n }\n curAuth = nextAuth;\n\n // Begin authentication method's process\n try {\n const username = curAuth.username;\n switch (curAuth.type) {\n case 'password':\n proto.authPassword(username, curAuth.password);\n break;\n case 'publickey':\n proto.authPK(username, curAuth.key);\n break;\n case 'hostbased':\n proto.authHostbased(username,\n curAuth.key,\n curAuth.localHostname,\n curAuth.localUsername,\n (buf, cb) => {\n const signature = curAuth.key.sign(buf);\n if (signature instanceof Error) {\n signature.message =\n `Error while signing with key: ${signature.message}`;\n signature.level = 'client-authentication';\n this.emit('error', signature);\n return tryNextAuth();\n }\n\n cb(signature);\n });\n break;\n case 'agent':\n curAuth.agentCtx.init((err) => {\n if (err) {\n err.level = 'agent';\n this.emit('error', err);\n return tryNextAuth();\n }\n tryNextAgentKey();\n });\n break;\n case 'keyboard-interactive':\n proto.authKeyboard(username);\n break;\n case 'none':\n proto.authNone(username);\n break;\n }\n } finally {\n hasSentAuth = false;\n }\n };\n\n function skipAuth(msg) {\n debug && debug(msg);\n process.nextTick(tryNextAuth);\n }\n\n function tryNextAuth() {\n hasSentAuth = false;\n const auth = authHandler(curAuthsLeft, curPartial, doNextAuth);\n if (hasSentAuth || auth === undefined)\n return;\n doNextAuth(auth);\n }\n\n const tryNextAgentKey = () => {\n if (curAuth.type === 'agent') {\n const key = curAuth.agentCtx.nextKey();\n if (key === false) {\n debug && debug('Agent: No more keys left to try');\n debug && debug('Client: agent auth failed');\n tryNextAuth();\n } else {\n const pos = curAuth.agentCtx.pos();\n debug && debug(`Agent: Trying key #${pos + 1}`);\n proto.authPK(curAuth.username, key);\n }\n }\n };\n\n const startTimeout = () => {\n if (this.config.readyTimeout > 0) {\n this._readyTimeout = setTimeout(() => {\n const err = new Error('Timed out while waiting for handshake');\n err.level = 'client-timeout';\n this.emit('error', err);\n sock.destroy();\n }, this.config.readyTimeout);\n }\n };\n\n if (!cfg.sock) {\n let host = this.config.host;\n const forceIPv4 = this.config.forceIPv4;\n const forceIPv6 = this.config.forceIPv6;\n\n debug && debug(`Client: Trying ${host} on port ${this.config.port} ...`);\n\n const doConnect = () => {\n startTimeout();\n sock.connect({\n host,\n port: this.config.port,\n localAddress: this.config.localAddress,\n localPort: this.config.localPort\n });\n sock.setNoDelay(true);\n sock.setMaxListeners(0);\n sock.setTimeout(typeof cfg.timeout === 'number' ? cfg.timeout : 0);\n };\n\n if ((!forceIPv4 && !forceIPv6) || (forceIPv4 && forceIPv6)) {\n doConnect();\n } else {\n dnsLookup(host, (forceIPv4 ? 4 : 6), (err, address, family) => {\n if (err) {\n const type = (forceIPv4 ? 'IPv4' : 'IPv6');\n const error = new Error(\n `Error while looking up ${type} address for '${host}': ${err}`\n );\n clearTimeout(this._readyTimeout);\n error.level = 'client-dns';\n this.emit('error', error);\n this.emit('close');\n return;\n }\n host = address;\n doConnect();\n });\n }\n } else {\n // Custom socket passed in\n startTimeout();\n if (typeof sock.connecting === 'boolean') {\n // net.Socket\n\n if (!sock.connecting) {\n // Already connected\n onConnect();\n }\n } else {\n // Assume socket/stream is already \"connected\"\n onConnect();\n }\n }\n\n return this;\n }\n\n end() {\n if (this._sock && isWritable(this._sock)) {\n this._protocol.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n this._sock.end();\n }\n return this;\n }\n\n destroy() {\n this._sock && isWritable(this._sock) && this._sock.destroy();\n return this;\n }\n\n exec(cmd, opts, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const extraOpts = { allowHalfOpen: (opts.allowHalfOpen !== false) };\n\n openChannel(this, 'session', extraOpts, (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n const todo = [];\n\n function reqCb(err) {\n if (err) {\n chan.close();\n cb(err);\n return;\n }\n if (todo.length)\n todo.shift()();\n }\n\n if (this.config.allowAgentFwd === true\n || (opts\n && opts.agentForward === true\n && this._agent !== undefined)) {\n todo.push(() => reqAgentFwd(chan, reqCb));\n }\n\n if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.env === 'object' && opts.env !== null)\n reqEnv(chan, opts.env);\n if ((typeof opts.pty === 'object' && opts.pty !== null)\n || opts.pty === true) {\n todo.push(() => reqPty(chan, opts.pty, reqCb));\n }\n if ((typeof opts.x11 === 'object' && opts.x11 !== null)\n || opts.x11 === 'number'\n || opts.x11 === true) {\n todo.push(() => reqX11(chan, opts.x11, reqCb));\n }\n }\n\n todo.push(() => reqExec(chan, cmd, opts, cb));\n todo.shift()();\n });\n\n return this;\n }\n\n shell(wndopts, opts, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof wndopts === 'function') {\n cb = wndopts;\n wndopts = opts = undefined;\n } else if (typeof opts === 'function') {\n cb = opts;\n opts = undefined;\n }\n if (wndopts && (wndopts.x11 !== undefined || wndopts.env !== undefined)) {\n opts = wndopts;\n wndopts = undefined;\n }\n\n openChannel(this, 'session', (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n const todo = [];\n\n function reqCb(err) {\n if (err) {\n chan.close();\n cb(err);\n return;\n }\n if (todo.length)\n todo.shift()();\n }\n\n if (this.config.allowAgentFwd === true\n || (opts\n && opts.agentForward === true\n && this._agent !== undefined)) {\n todo.push(() => reqAgentFwd(chan, reqCb));\n }\n\n if (wndopts !== false)\n todo.push(() => reqPty(chan, wndopts, reqCb));\n\n if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.env === 'object' && opts.env !== null)\n reqEnv(chan, opts.env);\n if ((typeof opts.x11 === 'object' && opts.x11 !== null)\n || opts.x11 === 'number'\n || opts.x11 === true) {\n todo.push(() => reqX11(chan, opts.x11, reqCb));\n }\n }\n\n todo.push(() => reqShell(chan, cb));\n todo.shift()();\n });\n\n return this;\n }\n\n subsys(name, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n openChannel(this, 'session', (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n reqSubsystem(chan, name, (err, stream) => {\n if (err) {\n cb(err);\n return;\n }\n\n cb(undefined, stream);\n });\n });\n\n return this;\n }\n\n forwardIn(bindAddr, bindPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request for the server to start forwarding TCP connections to us\n // on a particular address and port\n\n const wantReply = (typeof cb === 'function');\n\n if (wantReply) {\n this._callbacks.push((had_err, data) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to bind to ${bindAddr}:${bindPort}`));\n return;\n }\n\n let realPort = bindPort;\n if (bindPort === 0 && data && data.length >= 4) {\n realPort = readUInt32BE(data, 0);\n if (!(this._protocol._compatFlags & COMPAT.DYN_RPORT_BUG))\n bindPort = realPort;\n }\n\n this._forwarding[`${bindAddr}:${bindPort}`] = realPort;\n\n cb(undefined, realPort);\n });\n }\n\n this._protocol.tcpipForward(bindAddr, bindPort, wantReply);\n\n return this;\n }\n\n unforwardIn(bindAddr, bindPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request to stop forwarding us new connections for a particular\n // address and port\n\n const wantReply = (typeof cb === 'function');\n\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to unbind from ${bindAddr}:${bindPort}`));\n return;\n }\n\n delete this._forwarding[`${bindAddr}:${bindPort}`];\n\n cb();\n });\n }\n\n this._protocol.cancelTcpipForward(bindAddr, bindPort, wantReply);\n\n return this;\n }\n\n forwardOut(srcIP, srcPort, dstIP, dstPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request to forward a TCP connection to the server\n\n const cfg = {\n srcIP: srcIP,\n srcPort: srcPort,\n dstIP: dstIP,\n dstPort: dstPort\n };\n\n if (typeof cb !== 'function')\n cb = noop;\n\n openChannel(this, 'direct-tcpip', cfg, cb);\n\n return this;\n }\n\n openssh_noMoreSessions(cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to disable future sessions'));\n return;\n }\n\n cb();\n });\n }\n\n this._protocol.openssh_noMoreSessions(wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_forwardInStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to bind to ${socketPath}`));\n return;\n }\n this._forwardingUnix[socketPath] = true;\n cb();\n });\n }\n\n this._protocol.openssh_streamLocalForward(socketPath, wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_unforwardInStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to unbind from ${socketPath}`));\n return;\n }\n delete this._forwardingUnix[socketPath];\n cb();\n });\n }\n\n this._protocol.openssh_cancelStreamLocalForward(socketPath, wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_forwardOutStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof cb !== 'function')\n cb = noop;\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n openChannel(this, 'direct-streamlocal@openssh.com', { socketPath }, cb);\n return this;\n }\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n sftp(cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n openChannel(this, 'sftp', (err, sftp) => {\n if (err) {\n cb(err);\n return;\n }\n\n reqSubsystem(sftp, 'sftp', (err, sftp_) => {\n if (err) {\n cb(err);\n return;\n }\n\n function removeListeners() {\n sftp.removeListener('ready', onReady);\n sftp.removeListener('error', onError);\n sftp.removeListener('exit', onExit);\n sftp.removeListener('close', onExit);\n }\n\n function onReady() {\n // TODO: do not remove exit/close in case remote end closes the\n // channel abruptly and we need to notify outstanding callbacks\n removeListeners();\n cb(undefined, sftp);\n }\n\n function onError(err) {\n removeListeners();\n cb(err);\n }\n\n function onExit(code, signal) {\n removeListeners();\n let msg;\n if (typeof code === 'number')\n msg = `Received exit code ${code} while establishing SFTP session`;\n else if (signal !== undefined)\n msg = `Received signal ${signal} while establishing SFTP session`;\n else\n msg = 'Received unexpected SFTP session termination';\n const err = new Error(msg);\n err.code = code;\n err.signal = signal;\n cb(err);\n }\n\n sftp.on('ready', onReady)\n .on('error', onError)\n .on('exit', onExit)\n .on('close', onExit);\n\n sftp._init();\n });\n });\n\n return this;\n }\n}\n\nfunction openChannel(self, type, opts, cb) {\n // Ask the server to open a channel for some purpose\n // (e.g. session (sftp, exec, shell), or forwarding a TCP connection\n const initWindow = MAX_WINDOW;\n const maxPacket = PACKET_SIZE;\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const wrapper = (err, stream) => {\n cb(err, stream);\n };\n wrapper.type = type;\n\n const localChan = self._chanMgr.add(wrapper);\n\n if (localChan === -1) {\n cb(new Error('No free channels available'));\n return;\n }\n\n switch (type) {\n case 'session':\n case 'sftp':\n self._protocol.session(localChan, initWindow, maxPacket);\n break;\n case 'direct-tcpip':\n self._protocol.directTcpip(localChan, initWindow, maxPacket, opts);\n break;\n case 'direct-streamlocal@openssh.com':\n self._protocol.openssh_directStreamLocal(\n localChan, initWindow, maxPacket, opts\n );\n break;\n default:\n throw new Error(`Unsupported channel type: ${type}`);\n }\n}\n\nfunction reqX11(chan, screen, cb) {\n // Asks server to start sending us X11 connections\n const cfg = {\n single: false,\n protocol: 'MIT-MAGIC-COOKIE-1',\n cookie: undefined,\n screen: 0\n };\n\n if (typeof screen === 'function') {\n cb = screen;\n } else if (typeof screen === 'object' && screen !== null) {\n if (typeof screen.single === 'boolean')\n cfg.single = screen.single;\n if (typeof screen.screen === 'number')\n cfg.screen = screen.screen;\n if (typeof screen.protocol === 'string')\n cfg.protocol = screen.protocol;\n if (typeof screen.cookie === 'string')\n cfg.cookie = screen.cookie;\n else if (Buffer.isBuffer(screen.cookie))\n cfg.cookie = screen.cookie.hexSlice(0, screen.cookie.length);\n }\n if (cfg.cookie === undefined)\n cfg.cookie = randomCookie();\n\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n if (wantReply)\n cb(new Error('Channel is not open'));\n return;\n }\n\n if (wantReply) {\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to request X11'));\n return;\n }\n\n chan._hasX11 = true;\n ++chan._client._acceptX11;\n chan.once('close', () => {\n if (chan._client._acceptX11)\n --chan._client._acceptX11;\n });\n\n cb();\n });\n }\n\n chan._client._protocol.x11Forward(chan.outgoing.id, cfg, wantReply);\n}\n\nfunction reqPty(chan, opts, cb) {\n let rows = 24;\n let cols = 80;\n let width = 640;\n let height = 480;\n let term = 'vt100';\n let modes = null;\n\n if (typeof opts === 'function') {\n cb = opts;\n } else if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.rows === 'number')\n rows = opts.rows;\n if (typeof opts.cols === 'number')\n cols = opts.cols;\n if (typeof opts.width === 'number')\n width = opts.width;\n if (typeof opts.height === 'number')\n height = opts.height;\n if (typeof opts.term === 'string')\n term = opts.term;\n if (typeof opts.modes === 'object')\n modes = opts.modes;\n }\n\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n if (wantReply)\n cb(new Error('Channel is not open'));\n return;\n }\n\n if (wantReply) {\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to request a pseudo-terminal'));\n return;\n }\n cb();\n });\n }\n\n chan._client._protocol.pty(chan.outgoing.id,\n rows,\n cols,\n height,\n width,\n term,\n modes,\n wantReply);\n}\n\nfunction reqAgentFwd(chan, cb) {\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n wantReply && cb(new Error('Channel is not open'));\n return;\n }\n if (chan._client._agentFwdEnabled) {\n wantReply && cb(false);\n return;\n }\n\n chan._client._agentFwdEnabled = true;\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n chan._client._agentFwdEnabled = false;\n if (wantReply) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to request agent forwarding'));\n }\n return;\n }\n\n if (wantReply)\n cb();\n });\n\n chan._client._protocol.openssh_agentForward(chan.outgoing.id, true);\n}\n\nfunction reqShell(chan, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to open shell'));\n return;\n }\n chan.subtype = 'shell';\n cb(undefined, chan);\n });\n\n chan._client._protocol.shell(chan.outgoing.id, true);\n}\n\nfunction reqExec(chan, cmd, opts, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to exec'));\n return;\n }\n chan.subtype = 'exec';\n chan.allowHalfOpen = (opts.allowHalfOpen !== false);\n cb(undefined, chan);\n });\n\n chan._client._protocol.exec(chan.outgoing.id, cmd, true);\n}\n\nfunction reqEnv(chan, env) {\n if (chan.outgoing.state !== 'open')\n return;\n\n const keys = Object.keys(env || {});\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n const val = env[key];\n chan._client._protocol.env(chan.outgoing.id, key, val, false);\n }\n}\n\nfunction reqSubsystem(chan, name, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to start subsystem: ${name}`));\n return;\n }\n chan.subtype = 'subsystem';\n cb(undefined, chan);\n });\n\n chan._client._protocol.subsystem(chan.outgoing.id, name, true);\n}\n\n// TODO: inline implementation into single call site\nfunction onCHANNEL_OPEN(self, info) {\n // The server is trying to open a channel with us, this is usually when\n // we asked the server to forward us connections on some port and now they\n // are asking us to accept/deny an incoming connection on their side\n\n let localChan = -1;\n let reason;\n\n const accept = () => {\n const chanInfo = {\n type: info.type,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n const stream = new Channel(self, chanInfo);\n self._chanMgr.update(localChan, stream);\n\n self._protocol.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n return stream;\n };\n const reject = () => {\n if (reason === undefined) {\n if (localChan === -1)\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n else\n reason = CHANNEL_OPEN_FAILURE.CONNECT_FAILED;\n }\n\n if (localChan !== -1)\n self._chanMgr.remove(localChan);\n\n self._protocol.channelOpenFail(info.sender, reason, '');\n };\n const reserveChannel = () => {\n localChan = self._chanMgr.add();\n\n if (localChan === -1) {\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of incoming channel open: '\n + 'no channels available'\n );\n }\n }\n\n return (localChan !== -1);\n };\n\n const data = info.data;\n switch (info.type) {\n case 'forwarded-tcpip': {\n const val = self._forwarding[`${data.destIP}:${data.destPort}`];\n if (val !== undefined && reserveChannel()) {\n if (data.destPort === 0)\n data.destPort = val;\n self.emit('tcp connection', data, accept, reject);\n return;\n }\n break;\n }\n case 'forwarded-streamlocal@openssh.com':\n if (self._forwardingUnix[data.socketPath] !== undefined\n && reserveChannel()) {\n self.emit('unix connection', data, accept, reject);\n return;\n }\n break;\n case 'auth-agent@openssh.com':\n if (self._agentFwdEnabled\n && typeof self._agent.getStream === 'function'\n && reserveChannel()) {\n self._agent.getStream((err, stream) => {\n if (err)\n return reject();\n\n const upstream = accept();\n upstream.pipe(stream).pipe(upstream);\n });\n return;\n }\n break;\n case 'x11':\n if (self._acceptX11 !== 0 && reserveChannel()) {\n self.emit('x11', data, accept, reject);\n return;\n }\n break;\n default:\n // Automatically reject any unsupported channel open requests\n reason = CHANNEL_OPEN_FAILURE.UNKNOWN_CHANNEL_TYPE;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of unsupported incoming channel open '\n + `type: ${info.type}`\n );\n }\n }\n\n if (reason === undefined) {\n reason = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of unexpected incoming channel open for: '\n + info.type\n );\n }\n }\n\n reject();\n}\n\nconst randomCookie = (() => {\n const buffer = Buffer.allocUnsafe(16);\n return () => {\n randomFillSync(buffer, 0, 16);\n return buffer.hexSlice(0, 16);\n };\n})();\n\nfunction makeSimpleAuthHandler(authList) {\n if (!Array.isArray(authList))\n throw new Error('authList must be an array');\n\n let a = 0;\n return (authsLeft, partialSuccess, cb) => {\n if (a === authList.length)\n return false;\n return authList[a++];\n };\n}\n\nfunction hostKeysProve(client, keys_, cb) {\n if (!client._sock || !isWritable(client._sock))\n return;\n\n if (typeof cb !== 'function')\n cb = noop;\n\n if (!Array.isArray(keys_))\n throw new TypeError('Invalid keys argument type');\n\n const keys = [];\n for (const key of keys_) {\n const parsed = parseKey(key);\n if (parsed instanceof Error)\n throw parsed;\n keys.push(parsed);\n }\n\n if (!client.config.strictVendor\n || (client.config.strictVendor && RE_OPENSSH.test(client._remoteVer))) {\n client._callbacks.push((had_err, data) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Server failed to prove supplied keys'));\n return;\n }\n\n // TODO: move all of this parsing/verifying logic out of the client?\n const ret = [];\n let keyIdx = 0;\n bufferParser.init(data, 0);\n while (bufferParser.avail()) {\n if (keyIdx === keys.length)\n break;\n const key = keys[keyIdx++];\n const keyPublic = key.getPublicSSH();\n\n const sigEntry = bufferParser.readString();\n sigParser.init(sigEntry, 0);\n const type = sigParser.readString(true);\n let value = sigParser.readString();\n\n let algo;\n if (type !== key.type) {\n if (key.type === 'ssh-rsa') {\n switch (type) {\n case 'rsa-sha2-256':\n algo = 'sha256';\n break;\n case 'rsa-sha2-512':\n algo = 'sha512';\n break;\n default:\n continue;\n }\n } else {\n continue;\n }\n }\n\n const sessionID = client._protocol._kex.sessionID;\n const verifyData = Buffer.allocUnsafe(\n 4 + 29 + 4 + sessionID.length + 4 + keyPublic.length\n );\n let p = 0;\n writeUInt32BE(verifyData, 29, p);\n verifyData.utf8Write('hostkeys-prove-00@openssh.com', p += 4, 29);\n writeUInt32BE(verifyData, sessionID.length, p += 29);\n bufferCopy(sessionID, verifyData, 0, sessionID.length, p += 4);\n writeUInt32BE(verifyData, keyPublic.length, p += sessionID.length);\n bufferCopy(keyPublic, verifyData, 0, keyPublic.length, p += 4);\n\n if (!(value = sigSSHToASN1(value, type)))\n continue;\n if (key.verify(verifyData, value, algo) === true)\n ret.push(key);\n }\n sigParser.clear();\n bufferParser.clear();\n\n cb(null, ret);\n });\n\n client._protocol.openssh_hostKeysProve(keys);\n return;\n }\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n}\n\nmodule.exports = Client;\n","'use strict';\n\nconst { Agent: HttpAgent } = require('http');\nconst { Agent: HttpsAgent } = require('https');\nconst { connect: tlsConnect } = require('tls');\n\nlet Client;\n\nfor (const ctor of [HttpAgent, HttpsAgent]) {\n class SSHAgent extends ctor {\n constructor(connectCfg, agentOptions) {\n super(agentOptions);\n\n this._connectCfg = connectCfg;\n this._defaultSrcIP = (agentOptions && agentOptions.srcIP) || 'localhost';\n }\n\n createConnection(options, cb) {\n const srcIP = (options && options.localAddress) || this._defaultSrcIP;\n const srcPort = (options && options.localPort) || 0;\n const dstIP = options.host;\n const dstPort = options.port;\n\n if (Client === undefined)\n Client = require('./client.js');\n\n const client = new Client();\n let triedForward = false;\n client.on('ready', () => {\n client.forwardOut(srcIP, srcPort, dstIP, dstPort, (err, stream) => {\n triedForward = true;\n if (err) {\n client.end();\n return cb(err);\n }\n stream.once('close', () => client.end());\n cb(null, decorateStream(stream, ctor, options));\n });\n }).on('error', cb).on('close', () => {\n if (!triedForward)\n cb(new Error('Unexpected connection close'));\n }).connect(this._connectCfg);\n }\n }\n\n exports[ctor === HttpAgent ? 'SSHTTPAgent' : 'SSHTTPSAgent'] = SSHAgent;\n}\n\nfunction noop() {}\n\nfunction decorateStream(stream, ctor, options) {\n if (ctor === HttpAgent) {\n // HTTP\n stream.setKeepAlive = noop;\n stream.setNoDelay = noop;\n stream.setTimeout = noop;\n stream.ref = noop;\n stream.unref = noop;\n stream.destroySoon = stream.destroy;\n return stream;\n }\n\n // HTTPS\n options.socket = stream;\n const wrapped = tlsConnect(options);\n\n // This is a workaround for a regression in node v12.16.3+\n // https://github.com/nodejs/node/issues/35904\n const onClose = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n if (stream.isPaused())\n stream.resume();\n };\n })();\n // 'end' listener is needed because 'close' is not emitted in some scenarios\n // in node v12.x for some unknown reason\n wrapped.on('end', onClose).on('close', onClose);\n\n return wrapped;\n}\n","'use strict';\n\nconst {\n AgentProtocol,\n BaseAgent,\n createAgent,\n CygwinAgent,\n OpenSSHAgent,\n PageantAgent,\n} = require('./agent.js');\nconst {\n SSHTTPAgent: HTTPAgent,\n SSHTTPSAgent: HTTPSAgent,\n} = require('./http-agents.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst {\n flagsToString,\n OPEN_MODE,\n STATUS_CODE,\n stringToFlags,\n} = require('./protocol/SFTP.js');\n\nmodule.exports = {\n AgentProtocol,\n BaseAgent,\n createAgent,\n Client: require('./client.js'),\n CygwinAgent,\n HTTPAgent,\n HTTPSAgent,\n OpenSSHAgent,\n PageantAgent,\n Server: require('./server.js'),\n utils: {\n parseKey,\n sftp: {\n flagsToString,\n OPEN_MODE,\n STATUS_CODE,\n stringToFlags,\n },\n },\n};\n","/*\n TODO:\n * Replace `buffer._pos` usage in keyParser.js and elsewhere\n * Utilize optional \"writev\" support when writing packets from\n cipher.encrypt()\n * Built-in support for automatic re-keying, on by default\n * Revisit receiving unexpected/unknown packets\n * Error (fatal or otherwise) or ignore or pass on to user (in some or all\n cases)?\n * Including server/client check for single directional packet types?\n * Check packets for validity or bail as early as possible?\n * Automatic re-key every 2**31 packets after the last key exchange (sent or\n received), as suggested by RFC4344. OpenSSH currently does this.\n * Automatic re-key every so many blocks depending on cipher. RFC4344:\n Because of a birthday property of block ciphers and some modes of\n operation, implementations must be careful not to encrypt too many\n blocks with the same encryption key.\n\n Let L be the block length (in bits) of an SSH encryption method's\n block cipher (e.g., 128 for AES). If L is at least 128, then, after\n rekeying, an SSH implementation SHOULD NOT encrypt more than 2**(L/4)\n blocks before rekeying again. If L is at least 128, then SSH\n implementations should also attempt to force a rekey before receiving\n more than 2**(L/4) blocks. If L is less than 128 (which is the case\n for older ciphers such as 3DES, Blowfish, CAST-128, and IDEA), then,\n although it may be too expensive to rekey every 2**(L/4) blocks, it\n is still advisable for SSH implementations to follow the original\n recommendation in [RFC4253]: rekey at least once for every gigabyte\n of transmitted data.\n\n Note that if L is less than or equal to 128, then the recommendation\n in this subsection supersedes the recommendation in Section 3.1. If\n an SSH implementation uses a block cipher with a larger block size\n (e.g., Rijndael with 256-bit blocks), then the recommendations in\n Section 3.1 may supersede the recommendations in this subsection\n (depending on the lengths of the packets).\n*/\n\n'use strict';\n\nconst { inspect } = require('util');\n\nconst { bindingAvailable, NullCipher, NullDecipher } = require('./crypto.js');\nconst {\n COMPAT_CHECKS,\n DISCONNECT_REASON,\n MESSAGE,\n SIGNALS,\n TERMINAL_MODE,\n} = require('./constants.js');\nconst {\n DEFAULT_KEXINIT,\n KexInit,\n kexinit,\n onKEXPayload,\n} = require('./kex.js');\nconst {\n parseKey,\n} = require('./keyParser.js');\nconst MESSAGE_HANDLERS = require('./handlers.js');\nconst {\n bufferCopy,\n bufferFill,\n bufferSlice,\n convertSignature,\n sendPacket,\n writeUInt32BE,\n} = require('./utils.js');\nconst {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n} = require('./zlib.js');\n\nconst MODULE_VER = require('../../package.json').version;\n\nconst VALID_DISCONNECT_REASONS = new Map(\n Object.values(DISCONNECT_REASON).map((n) => [n, 1])\n);\nconst IDENT_RAW = Buffer.from(`SSH-2.0-ssh2js${MODULE_VER}`);\nconst IDENT = Buffer.from(`${IDENT_RAW}\\r\\n`);\nconst MAX_LINE_LEN = 8192;\nconst MAX_LINES = 1024;\nconst PING_PAYLOAD = Buffer.from([\n MESSAGE.GLOBAL_REQUEST,\n // \"keepalive@openssh.com\"\n 0, 0, 0, 21,\n 107, 101, 101, 112, 97, 108, 105, 118, 101, 64, 111, 112, 101, 110, 115,\n 115, 104, 46, 99, 111, 109,\n // Request a reply\n 1,\n]);\nconst NO_TERMINAL_MODES_BUFFER = Buffer.from([ TERMINAL_MODE.TTY_OP_END ]);\n\nfunction noop() {}\n\n/*\n Inbound:\n * kexinit payload (needed only until exchange hash is generated)\n * raw ident\n * rekey packet queue\n * expected packet (implemented as separate _parse() function?)\n Outbound:\n * kexinit payload (needed only until exchange hash is generated)\n * rekey packet queue\n * kex secret (needed only until NEWKEYS)\n * exchange hash (needed only until NEWKEYS)\n * session ID (set to exchange hash from initial handshake)\n*/\nclass Protocol {\n constructor(config) {\n const onWrite = config.onWrite;\n if (typeof onWrite !== 'function')\n throw new Error('Missing onWrite function');\n this._onWrite = (data) => { onWrite(data); };\n\n const onError = config.onError;\n if (typeof onError !== 'function')\n throw new Error('Missing onError function');\n this._onError = (err) => { onError(err); };\n\n const debug = config.debug;\n this._debug = (typeof debug === 'function'\n ? (msg) => { debug(msg); }\n : undefined);\n\n const onHeader = config.onHeader;\n this._onHeader = (typeof onHeader === 'function'\n ? (...args) => { onHeader(...args); }\n : noop);\n\n const onPacket = config.onPacket;\n this._onPacket = (typeof onPacket === 'function'\n ? () => { onPacket(); }\n : noop);\n\n let onHandshakeComplete = config.onHandshakeComplete;\n if (typeof onHandshakeComplete !== 'function')\n onHandshakeComplete = noop;\n this._onHandshakeComplete = (...args) => {\n this._debug && this._debug('Handshake completed');\n\n // Process packets queued during a rekey where necessary\n const oldQueue = this._queue;\n if (oldQueue) {\n this._queue = undefined;\n this._debug && this._debug(\n `Draining outbound queue (${oldQueue.length}) ...`\n );\n for (let i = 0; i < oldQueue.length; ++i) {\n const data = oldQueue[i];\n // data === payload only\n\n // XXX: hacky\n let finalized = this._packetRW.write.finalize(data);\n if (finalized === data) {\n const packet = this._cipher.allocPacket(data.length);\n packet.set(data, 5);\n finalized = packet;\n }\n\n sendPacket(this, finalized);\n }\n this._debug && this._debug('... finished draining outbound queue');\n }\n\n onHandshakeComplete(...args);\n };\n this._queue = undefined;\n\n const messageHandlers = config.messageHandlers;\n if (typeof messageHandlers === 'object' && messageHandlers !== null)\n this._handlers = messageHandlers;\n else\n this._handlers = {};\n\n this._onPayload = onPayload.bind(this);\n\n this._server = !!config.server;\n this._banner = undefined;\n let greeting;\n if (this._server) {\n if (typeof config.hostKeys !== 'object' || config.hostKeys === null)\n throw new Error('Missing server host key(s)');\n this._hostKeys = config.hostKeys;\n\n // Greeting displayed before the ssh identification string is sent, this\n // is usually ignored by most clients\n if (typeof config.greeting === 'string' && config.greeting.length) {\n greeting = (config.greeting.slice(-2) === '\\r\\n'\n ? config.greeting\n : `${config.greeting}\\r\\n`);\n }\n\n // Banner shown after the handshake completes, but before user\n // authentication begins\n if (typeof config.banner === 'string' && config.banner.length) {\n this._banner = (config.banner.slice(-2) === '\\r\\n'\n ? config.banner\n : `${config.banner}\\r\\n`);\n }\n } else {\n this._hostKeys = undefined;\n }\n\n let offer = config.offer;\n if (typeof offer !== 'object' || offer === null)\n offer = DEFAULT_KEXINIT;\n else if (offer.constructor !== KexInit)\n offer = new KexInit(offer);\n this._kex = undefined;\n this._kexinit = undefined;\n this._offer = offer;\n this._cipher = new NullCipher(0, this._onWrite);\n this._decipher = undefined;\n this._skipNextInboundPacket = false;\n this._packetRW = {\n read: new PacketReader(),\n write: new PacketWriter(this),\n };\n this._hostVerifier = (!this._server\n && typeof config.hostVerifier === 'function'\n ? config.hostVerifier\n : undefined);\n\n this._parse = parseHeader;\n this._buffer = undefined;\n this._authsQueue = [];\n this._authenticated = false;\n this._remoteIdentRaw = undefined;\n let sentIdent;\n if (typeof config.ident === 'string') {\n this._identRaw = Buffer.from(`SSH-2.0-${config.ident}`);\n\n sentIdent = Buffer.allocUnsafe(this._identRaw.length + 2);\n sentIdent.set(this._identRaw, 0);\n sentIdent[sentIdent.length - 2] = 13; // '\\r'\n sentIdent[sentIdent.length - 1] = 10; // '\\n'\n } else if (Buffer.isBuffer(config.ident)) {\n const fullIdent = Buffer.allocUnsafe(8 + config.ident.length);\n fullIdent.latin1Write('SSH-2.0-', 0, 8);\n fullIdent.set(config.ident, 8);\n this._identRaw = fullIdent;\n\n sentIdent = Buffer.allocUnsafe(fullIdent.length + 2);\n sentIdent.set(fullIdent, 0);\n sentIdent[sentIdent.length - 2] = 13; // '\\r'\n sentIdent[sentIdent.length - 1] = 10; // '\\n'\n } else {\n this._identRaw = IDENT_RAW;\n sentIdent = IDENT;\n }\n this._compatFlags = 0;\n\n if (this._debug) {\n if (bindingAvailable)\n this._debug('Custom crypto binding available');\n else\n this._debug('Custom crypto binding not available');\n }\n\n this._debug && this._debug(\n `Local ident: ${inspect(this._identRaw.toString())}`\n );\n this.start = () => {\n this.start = undefined;\n if (greeting)\n this._onWrite(greeting);\n this._onWrite(sentIdent);\n };\n }\n _destruct(reason) {\n this._packetRW.read.cleanup();\n this._packetRW.write.cleanup();\n this._cipher && this._cipher.free();\n this._decipher && this._decipher.free();\n if (typeof reason !== 'string' || reason.length === 0)\n reason = 'fatal error';\n this.parse = () => {\n throw new Error(`Instance unusable after ${reason}`);\n };\n this._onWrite = () => {\n throw new Error(`Instance unusable after ${reason}`);\n };\n this._destruct = undefined;\n }\n cleanup() {\n this._destruct && this._destruct();\n }\n parse(chunk, i, len) {\n while (i < len)\n i = this._parse(chunk, i, len);\n }\n\n // Protocol message API\n\n // ===========================================================================\n // Common/Shared =============================================================\n // ===========================================================================\n\n // Global\n // ------\n disconnect(reason) {\n const pktLen = 1 + 4 + 4 + 4;\n // We don't use _packetRW.write.* here because we need to make sure that\n // we always get a full packet allocated because this message can be sent\n // at any time -- even during a key exchange\n let p = this._packetRW.write.allocStartKEX;\n const packet = this._packetRW.write.alloc(pktLen, true);\n const end = p + pktLen;\n\n if (!VALID_DISCONNECT_REASONS.has(reason))\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n\n packet[p] = MESSAGE.DISCONNECT;\n writeUInt32BE(packet, reason, ++p);\n packet.fill(0, p += 4, end);\n\n this._debug && this._debug(`Outbound: Sending DISCONNECT (${reason})`);\n sendPacket(this, this._packetRW.write.finalize(packet, true), true);\n }\n ping() {\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(PING_PAYLOAD.length);\n\n packet.set(PING_PAYLOAD, p);\n\n this._debug && this._debug(\n 'Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n rekey() {\n if (this._kexinit === undefined) {\n this._debug && this._debug('Outbound: Initiated explicit rekey');\n this._queue = [];\n kexinit(this);\n } else {\n this._debug && this._debug('Outbound: Ignoring rekey during handshake');\n }\n }\n\n // 'ssh-connection' service-specific\n // ---------------------------------\n requestSuccess(data) {\n let p = this._packetRW.write.allocStart;\n let packet;\n if (Buffer.isBuffer(data)) {\n packet = this._packetRW.write.alloc(1 + data.length);\n\n packet[p] = MESSAGE.REQUEST_SUCCESS;\n\n packet.set(data, ++p);\n } else {\n packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.REQUEST_SUCCESS;\n }\n\n this._debug && this._debug('Outbound: Sending REQUEST_SUCCESS');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n requestFailure() {\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.REQUEST_FAILURE;\n\n this._debug && this._debug('Outbound: Sending REQUEST_FAILURE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelSuccess(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_SUCCESS;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelFailure(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_FAILURE;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelEOF(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_EOF;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_EOF (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelClose(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_CLOSE;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelWindowAdjust(chan, amount) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_WINDOW_ADJUST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, amount, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${chan}, ${amount})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelData(chan, data) {\n const isBuffer = Buffer.isBuffer(data);\n const dataLen = (isBuffer ? data.length : Buffer.byteLength(data));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + dataLen);\n\n packet[p] = MESSAGE.CHANNEL_DATA;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, dataLen, p += 4);\n\n if (isBuffer)\n packet.set(data, p += 4);\n else\n packet.utf8Write(data, p += 4, dataLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_DATA (r:${chan}, ${dataLen})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelExtData(chan, data, type) {\n const isBuffer = Buffer.isBuffer(data);\n const dataLen = (isBuffer ? data.length : Buffer.byteLength(data));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + dataLen);\n\n packet[p] = MESSAGE.CHANNEL_EXTENDED_DATA;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, type, p += 4);\n\n writeUInt32BE(packet, dataLen, p += 4);\n\n if (isBuffer)\n packet.set(data, p += 4);\n else\n packet.utf8Write(data, p += 4, dataLen);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelOpenConfirm(remote, local, initWindow, maxPacket) {\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN_CONFIRMATION;\n\n writeUInt32BE(packet, remote, ++p);\n\n writeUInt32BE(packet, local, p += 4);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${remote}, l:${local})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelOpenFail(remote, reason, desc) {\n if (typeof desc !== 'string')\n desc = '';\n\n const descLen = Buffer.byteLength(desc);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + descLen + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN_FAILURE;\n\n writeUInt32BE(packet, remote, ++p);\n\n writeUInt32BE(packet, reason, p += 4);\n\n writeUInt32BE(packet, descLen, p += 4);\n\n p += 4;\n if (descLen) {\n packet.utf8Write(desc, p, descLen);\n p += descLen;\n }\n\n writeUInt32BE(packet, 0, p); // Empty language tag\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${remote})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // ===========================================================================\n // Client-specific ===========================================================\n // ===========================================================================\n\n // Global\n // ------\n service(name) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const nameLen = Buffer.byteLength(name);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + nameLen);\n\n packet[p] = MESSAGE.SERVICE_REQUEST;\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(name, p += 4, nameLen);\n\n this._debug && this._debug(`Outbound: Sending SERVICE_REQUEST (${name})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // 'ssh-userauth' service-specific\n // -------------------------------\n authPassword(username, password, newPassword) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n const passLen = Buffer.byteLength(password);\n const newPassLen = (newPassword ? Buffer.byteLength(newPassword) : 0);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 8 + 1 + 4 + passLen\n + (newPassword ? 4 + newPassLen : 0)\n );\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 8, p += 14);\n packet.utf8Write('password', p += 4, 8);\n\n packet[p += 8] = (newPassword ? 1 : 0);\n\n writeUInt32BE(packet, passLen, ++p);\n if (Buffer.isBuffer(password))\n bufferCopy(password, packet, 0, passLen, p += 4);\n else\n packet.utf8Write(password, p += 4, passLen);\n\n if (newPassword) {\n writeUInt32BE(packet, newPassLen, p += passLen);\n if (Buffer.isBuffer(newPassword))\n bufferCopy(newPassword, packet, 0, newPassLen, p += 4);\n else\n packet.utf8Write(newPassword, p += 4, newPassLen);\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (changed password)'\n );\n } else {\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (password)'\n );\n }\n\n this._authsQueue.push('password');\n\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authPK(username, pubKey, cbSign) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n pubKey = parseKey(pubKey);\n if (pubKey instanceof Error)\n throw new Error('Invalid key');\n\n const keyType = pubKey.type;\n pubKey = pubKey.getPublicSSH();\n\n const userLen = Buffer.byteLength(username);\n const algoLen = Buffer.byteLength(keyType);\n const pubKeyLen = pubKey.length;\n const sessionID = this._kex.sessionID;\n const sesLen = sessionID.length;\n const payloadLen =\n (cbSign ? 4 + sesLen : 0)\n + 1 + 4 + userLen + 4 + 14 + 4 + 9 + 1 + 4 + algoLen + 4 + pubKeyLen;\n let packet;\n let p;\n if (cbSign) {\n packet = Buffer.allocUnsafe(payloadLen);\n p = 0;\n writeUInt32BE(packet, sesLen, p);\n packet.set(sessionID, p += 4);\n p += sesLen;\n } else {\n packet = this._packetRW.write.alloc(payloadLen);\n p = this._packetRW.write.allocStart;\n }\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 9, p += 14);\n packet.utf8Write('publickey', p += 4, 9);\n\n packet[p += 9] = (cbSign ? 1 : 0);\n\n writeUInt32BE(packet, algoLen, ++p);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, pubKeyLen, p += algoLen);\n packet.set(pubKey, p += 4);\n\n if (!cbSign) {\n this._authsQueue.push('publickey');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (publickey -- check)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n return;\n }\n\n cbSign(packet, (signature) => {\n signature = convertSignature(signature, keyType);\n if (signature === false)\n throw new Error('Error while converting handshake signature');\n\n const sigLen = signature.length;\n p = this._packetRW.write.allocStart;\n packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 9 + 1 + 4 + algoLen + 4 + pubKeyLen + 4\n + 4 + algoLen + 4 + sigLen\n );\n\n // TODO: simply copy from original \"packet\" to new `packet` to avoid\n // having to write each individual field a second time?\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 9, p += 14);\n packet.utf8Write('publickey', p += 4, 9);\n\n packet[p += 9] = 1;\n\n writeUInt32BE(packet, algoLen, ++p);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, pubKeyLen, p += algoLen);\n packet.set(pubKey, p += 4);\n\n writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += pubKeyLen);\n\n writeUInt32BE(packet, algoLen, p += 4);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, sigLen, p += algoLen);\n packet.set(signature, p += 4);\n\n // Servers shouldn't send packet type 60 in response to signed publickey\n // attempts, but if they do, interpret as type 60.\n this._authsQueue.push('publickey');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (publickey)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n });\n }\n authHostbased(username, pubKey, hostname, userlocal, cbSign) {\n // TODO: Make DRY by sharing similar code with authPK()\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n pubKey = parseKey(pubKey);\n if (pubKey instanceof Error)\n throw new Error('Invalid key');\n\n const keyType = pubKey.type;\n pubKey = pubKey.getPublicSSH();\n\n const userLen = Buffer.byteLength(username);\n const algoLen = Buffer.byteLength(keyType);\n const pubKeyLen = pubKey.length;\n const sessionID = this._kex.sessionID;\n const sesLen = sessionID.length;\n const hostnameLen = Buffer.byteLength(hostname);\n const userlocalLen = Buffer.byteLength(userlocal);\n const data = Buffer.allocUnsafe(\n 4 + sesLen + 1 + 4 + userLen + 4 + 14 + 4 + 9 + 4 + algoLen\n + 4 + pubKeyLen + 4 + hostnameLen + 4 + userlocalLen\n );\n let p = 0;\n\n writeUInt32BE(data, sesLen, p);\n data.set(sessionID, p += 4);\n\n data[p += sesLen] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(data, userLen, ++p);\n data.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(data, 14, p += userLen);\n data.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(data, 9, p += 14);\n data.utf8Write('hostbased', p += 4, 9);\n\n writeUInt32BE(data, algoLen, p += 9);\n data.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(data, pubKeyLen, p += algoLen);\n data.set(pubKey, p += 4);\n\n writeUInt32BE(data, hostnameLen, p += pubKeyLen);\n data.utf8Write(hostname, p += 4, hostnameLen);\n\n writeUInt32BE(data, userlocalLen, p += hostnameLen);\n data.utf8Write(userlocal, p += 4, userlocalLen);\n\n cbSign(data, (signature) => {\n signature = convertSignature(signature, keyType);\n if (!signature)\n throw new Error('Error while converting handshake signature');\n\n const sigLen = signature.length;\n const reqDataLen = (data.length - sesLen - 4);\n p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n reqDataLen + 4 + 4 + algoLen + 4 + sigLen\n );\n\n bufferCopy(data, packet, 4 + sesLen, data.length, p);\n\n writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += reqDataLen);\n writeUInt32BE(packet, algoLen, p += 4);\n packet.utf8Write(keyType, p += 4, algoLen);\n writeUInt32BE(packet, sigLen, p += algoLen);\n packet.set(signature, p += 4);\n\n this._authsQueue.push('hostbased');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (hostbased)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n });\n }\n authKeyboard(username) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 20 + 4 + 4\n );\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 20, p += 14);\n packet.utf8Write('keyboard-interactive', p += 4, 20);\n\n writeUInt32BE(packet, 0, p += 20);\n\n writeUInt32BE(packet, 0, p += 4);\n\n this._authsQueue.push('keyboard-interactive');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authNone(username) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + userLen + 4 + 14 + 4 + 4);\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 4, p += 14);\n packet.utf8Write('none', p += 4, 4);\n\n this._authsQueue.push('none');\n\n this._debug && this._debug('Outbound: Sending USERAUTH_REQUEST (none)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authInfoRes(responses) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let responsesTotalLen = 0;\n let responseLens;\n\n if (responses) {\n responseLens = new Array(responses.length);\n for (let i = 0; i < responses.length; ++i) {\n const len = Buffer.byteLength(responses[i]);\n responseLens[i] = len;\n responsesTotalLen += 4 + len;\n }\n }\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + responsesTotalLen);\n\n packet[p] = MESSAGE.USERAUTH_INFO_RESPONSE;\n\n if (responses) {\n writeUInt32BE(packet, responses.length, ++p);\n p += 4;\n for (let i = 0; i < responses.length; ++i) {\n const len = responseLens[i];\n writeUInt32BE(packet, len, p);\n p += 4;\n if (len) {\n packet.utf8Write(responses[i], p, len);\n p += len;\n }\n }\n } else {\n writeUInt32BE(packet, 0, ++p);\n }\n\n this._debug && this._debug('Outbound: Sending USERAUTH_INFO_RESPONSE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // 'ssh-connection' service-specific\n // ---------------------------------\n tcpipForward(bindAddr, bindPort, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const addrLen = Buffer.byteLength(bindAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 13 + 1 + 4 + addrLen + 4);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 13, ++p);\n packet.utf8Write('tcpip-forward', p += 4, 13);\n\n packet[p += 13] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, addrLen, ++p);\n packet.utf8Write(bindAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, bindPort, p += addrLen);\n\n this._debug\n && this._debug('Outbound: Sending GLOBAL_REQUEST (tcpip-forward)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n cancelTcpipForward(bindAddr, bindPort, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const addrLen = Buffer.byteLength(bindAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 20 + 1 + 4 + addrLen + 4);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 20, ++p);\n packet.utf8Write('cancel-tcpip-forward', p += 4, 20);\n\n packet[p += 20] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, addrLen, ++p);\n packet.utf8Write(bindAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, bindPort, p += addrLen);\n\n this._debug\n && this._debug('Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_streamLocalForward(socketPath, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const socketPathLen = Buffer.byteLength(socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 31 + 1 + 4 + socketPathLen\n );\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 31, ++p);\n packet.utf8Write('streamlocal-forward@openssh.com', p += 4, 31);\n\n packet[p += 31] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, socketPathLen, ++p);\n packet.utf8Write(socketPath, p += 4, socketPathLen);\n\n this._debug && this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_cancelStreamLocalForward(socketPath, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const socketPathLen = Buffer.byteLength(socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 38 + 1 + 4 + socketPathLen\n );\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 38, ++p);\n packet.utf8Write('cancel-streamlocal-forward@openssh.com', p += 4, 38);\n\n packet[p += 38] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, socketPathLen, ++p);\n packet.utf8Write(socketPath, p += 4, socketPathLen);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending GLOBAL_REQUEST '\n + '(cancel-streamlocal-forward@openssh.com)'\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n directTcpip(chan, initWindow, maxPacket, cfg) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const srcLen = Buffer.byteLength(cfg.srcIP);\n const dstLen = Buffer.byteLength(cfg.dstIP);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 12 + 4 + 4 + 4 + 4 + srcLen + 4 + 4 + dstLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 12, ++p);\n packet.utf8Write('direct-tcpip', p += 4, 12);\n\n writeUInt32BE(packet, chan, p += 12);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, dstLen, p += 4);\n packet.utf8Write(cfg.dstIP, p += 4, dstLen);\n\n writeUInt32BE(packet, cfg.dstPort, p += dstLen);\n\n writeUInt32BE(packet, srcLen, p += 4);\n packet.utf8Write(cfg.srcIP, p += 4, srcLen);\n\n writeUInt32BE(packet, cfg.srcPort, p += srcLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, direct-tcpip)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_directStreamLocal(chan, initWindow, maxPacket, cfg) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const pathLen = Buffer.byteLength(cfg.socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 30 + 4 + 4 + 4 + 4 + pathLen + 4 + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 30, ++p);\n packet.utf8Write('direct-streamlocal@openssh.com', p += 4, 30);\n\n writeUInt32BE(packet, chan, p += 30);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, pathLen, p += 4);\n packet.utf8Write(cfg.socketPath, p += 4, pathLen);\n\n // zero-fill reserved fields (string and uint32)\n bufferFill(packet, 0, p += pathLen, p + 8);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_OPEN '\n + `(r:${chan}, direct-streamlocal@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_noMoreSessions(wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 28 + 1);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 28, ++p);\n packet.utf8Write('no-more-sessions@openssh.com', p += 4, 28);\n\n packet[p += 28] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n this._debug && this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n session(chan, initWindow, maxPacket) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 7 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 7, ++p);\n packet.utf8Write('session', p += 4, 7);\n\n writeUInt32BE(packet, chan, p += 7);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_OPEN (r:${chan}, session)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n windowChange(chan, rows, cols, height, width) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 13 + 1 + 4 + 4 + 4 + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 13, p += 4);\n packet.utf8Write('window-change', p += 4, 13);\n\n packet[p += 13] = 0;\n\n writeUInt32BE(packet, cols, ++p);\n\n writeUInt32BE(packet, rows, p += 4);\n\n writeUInt32BE(packet, width, p += 4);\n\n writeUInt32BE(packet, height, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, window-change)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n pty(chan, rows, cols, height, width, term, modes, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n if (!term || !term.length)\n term = 'vt100';\n if (modes\n && !Buffer.isBuffer(modes)\n && !Array.isArray(modes)\n && typeof modes === 'object'\n && modes !== null) {\n modes = modesToBytes(modes);\n }\n if (!modes || !modes.length)\n modes = NO_TERMINAL_MODES_BUFFER;\n\n const termLen = term.length;\n const modesLen = modes.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 7 + 1 + 4 + termLen + 4 + 4 + 4 + 4 + 4 + modesLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 7, p += 4);\n packet.utf8Write('pty-req', p += 4, 7);\n\n packet[p += 7] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, termLen, ++p);\n packet.utf8Write(term, p += 4, termLen);\n\n writeUInt32BE(packet, cols, p += termLen);\n\n writeUInt32BE(packet, rows, p += 4);\n\n writeUInt32BE(packet, width, p += 4);\n\n writeUInt32BE(packet, height, p += 4);\n\n writeUInt32BE(packet, modesLen, p += 4);\n p += 4;\n if (Array.isArray(modes)) {\n for (let i = 0; i < modesLen; ++i)\n packet[p++] = modes[i];\n } else if (Buffer.isBuffer(modes)) {\n packet.set(modes, p);\n }\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, pty-req)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n shell(chan, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 5 + 1);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 5, p += 4);\n packet.utf8Write('shell', p += 4, 5);\n\n packet[p += 5] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, shell)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exec(chan, cmd, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const isBuf = Buffer.isBuffer(cmd);\n const cmdLen = (isBuf ? cmd.length : Buffer.byteLength(cmd));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + 1 + 4 + cmdLen);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 4, p += 4);\n packet.utf8Write('exec', p += 4, 4);\n\n packet[p += 4] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, cmdLen, ++p);\n if (isBuf)\n packet.set(cmd, p += 4);\n else\n packet.utf8Write(cmd, p += 4, cmdLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exec: ${cmd})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n signal(chan, signal) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const origSignal = signal;\n\n signal = signal.toUpperCase();\n if (signal.slice(0, 3) === 'SIG')\n signal = signal.slice(3);\n\n if (SIGNALS[signal] !== 1)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n const signalLen = signal.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 6 + 1 + 4 + signalLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 6, p += 4);\n packet.utf8Write('signal', p += 4, 6);\n\n packet[p += 6] = 0;\n\n writeUInt32BE(packet, signalLen, ++p);\n packet.utf8Write(signal, p += 4, signalLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, signal: ${signal})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n env(chan, key, val, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const keyLen = Buffer.byteLength(key);\n const isBuf = Buffer.isBuffer(val);\n const valLen = (isBuf ? val.length : Buffer.byteLength(val));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 3 + 1 + 4 + keyLen + 4 + valLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 3, p += 4);\n packet.utf8Write('env', p += 4, 3);\n\n packet[p += 3] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, keyLen, ++p);\n packet.utf8Write(key, p += 4, keyLen);\n\n writeUInt32BE(packet, valLen, p += keyLen);\n if (isBuf)\n packet.set(val, p += 4);\n else\n packet.utf8Write(val, p += 4, valLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, env: ${key}=${val})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n x11Forward(chan, cfg, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const protocol = cfg.protocol;\n const cookie = cfg.cookie;\n const isBufProto = Buffer.isBuffer(protocol);\n const protoLen = (isBufProto\n ? protocol.length\n : Buffer.byteLength(protocol));\n const isBufCookie = Buffer.isBuffer(cookie);\n const cookieLen = (isBufCookie\n ? cookie.length\n : Buffer.byteLength(cookie));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 7 + 1 + 1 + 4 + protoLen + 4 + cookieLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 7, p += 4);\n packet.utf8Write('x11-req', p += 4, 7);\n\n packet[p += 7] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n packet[++p] = (cfg.single ? 1 : 0);\n\n writeUInt32BE(packet, protoLen, ++p);\n if (isBufProto)\n packet.set(protocol, p += 4);\n else\n packet.utf8Write(protocol, p += 4, protoLen);\n\n writeUInt32BE(packet, cookieLen, p += protoLen);\n if (isBufCookie)\n packet.set(cookie, p += 4);\n else\n packet.latin1Write(cookie, p += 4, cookieLen);\n\n writeUInt32BE(packet, (cfg.screen || 0), p += cookieLen);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, x11-req)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n subsystem(chan, name, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n const nameLen = Buffer.byteLength(name);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 9 + 1 + 4 + nameLen);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 9, p += 4);\n packet.utf8Write('subsystem', p += 4, 9);\n\n packet[p += 9] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(name, p += 4, nameLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, subsystem: ${name})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_agentForward(chan, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 26 + 1);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 26, p += 4);\n packet.utf8Write('auth-agent-req@openssh.com', p += 4, 26);\n\n packet[p += 26] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_REQUEST '\n + `(r:${chan}, auth-agent-req@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_hostKeysProve(keys) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let keysTotal = 0;\n const publicKeys = [];\n for (const key of keys) {\n const publicKey = key.getPublicSSH();\n keysTotal += 4 + publicKey.length;\n publicKeys.push(publicKey);\n }\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 29 + 1 + keysTotal);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 29, ++p);\n packet.utf8Write('hostkeys-prove-00@openssh.com', p += 4, 29);\n\n packet[p += 29] = 1; // want reply\n\n ++p;\n for (const buf of publicKeys) {\n writeUInt32BE(packet, buf.length, p);\n bufferCopy(buf, packet, 0, buf.length, p += 4);\n p += buf.length;\n }\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)'\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // ===========================================================================\n // Server-specific ===========================================================\n // ===========================================================================\n\n // Global\n // ------\n serviceAccept(svcName) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const svcNameLen = Buffer.byteLength(svcName);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + svcNameLen);\n\n packet[p] = MESSAGE.SERVICE_ACCEPT;\n\n writeUInt32BE(packet, svcNameLen, ++p);\n packet.utf8Write(svcName, p += 4, svcNameLen);\n\n this._debug && this._debug(`Outbound: Sending SERVICE_ACCEPT (${svcName})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n\n if (this._server && this._banner && svcName === 'ssh-userauth') {\n const banner = this._banner;\n this._banner = undefined; // Prevent banner from being displayed again\n const bannerLen = Buffer.byteLength(banner);\n p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + bannerLen + 4);\n\n packet[p] = MESSAGE.USERAUTH_BANNER;\n\n writeUInt32BE(packet, bannerLen, ++p);\n packet.utf8Write(banner, p += 4, bannerLen);\n\n writeUInt32BE(packet, 0, p += bannerLen); // Empty language tag\n\n this._debug && this._debug('Outbound: Sending USERAUTH_BANNER');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n }\n // 'ssh-connection' service-specific\n forwardedTcpip(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const boundAddrLen = Buffer.byteLength(cfg.boundAddr);\n const remoteAddrLen = Buffer.byteLength(cfg.remoteAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 15 + 4 + 4 + 4 + 4 + boundAddrLen + 4 + 4 + remoteAddrLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 15, ++p);\n packet.utf8Write('forwarded-tcpip', p += 4, 15);\n\n writeUInt32BE(packet, chan, p += 15);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, boundAddrLen, p += 4);\n packet.utf8Write(cfg.boundAddr, p += 4, boundAddrLen);\n\n writeUInt32BE(packet, cfg.boundPort, p += boundAddrLen);\n\n writeUInt32BE(packet, remoteAddrLen, p += 4);\n packet.utf8Write(cfg.remoteAddr, p += 4, remoteAddrLen);\n\n writeUInt32BE(packet, cfg.remotePort, p += remoteAddrLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, forwarded-tcpip)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n x11(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const addrLen = Buffer.byteLength(cfg.originAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 3 + 4 + 4 + 4 + 4 + addrLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 3, ++p);\n packet.utf8Write('x11', p += 4, 3);\n\n writeUInt32BE(packet, chan, p += 3);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, addrLen, p += 4);\n packet.utf8Write(cfg.originAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, cfg.originPort, p += addrLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, x11)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_authAgent(chan, initWindow, maxPacket) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 22 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 22, ++p);\n packet.utf8Write('auth-agent@openssh.com', p += 4, 22);\n\n writeUInt32BE(packet, chan, p += 22);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, auth-agent@openssh.com)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_forwardedStreamLocal(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const pathLen = Buffer.byteLength(cfg.socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 33 + 4 + 4 + 4 + 4 + pathLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 33, ++p);\n packet.utf8Write('forwarded-streamlocal@openssh.com', p += 4, 33);\n\n writeUInt32BE(packet, chan, p += 33);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, pathLen, p += 4);\n packet.utf8Write(cfg.socketPath, p += 4, pathLen);\n\n writeUInt32BE(packet, 0, p += pathLen);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_OPEN '\n + `(r:${chan}, forwarded-streamlocal@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exitStatus(chan, status) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 11 + 1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-status', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, status, ++p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-status: ${status})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exitSignal(chan, name, coreDumped, msg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n\n const origSignal = name;\n\n if (typeof origSignal !== 'string' || !origSignal)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n let signal = name.toUpperCase();\n if (signal.slice(0, 3) === 'SIG')\n signal = signal.slice(3);\n\n if (SIGNALS[signal] !== 1)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n const nameLen = Buffer.byteLength(signal);\n const msgLen = (msg ? Buffer.byteLength(msg) : 0);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 11 + 1 + 4 + nameLen + 1 + 4 + msgLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-signal', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(signal, p += 4, nameLen);\n\n packet[p += nameLen] = (coreDumped ? 1 : 0);\n\n writeUInt32BE(packet, msgLen, ++p);\n\n p += 4;\n if (msgLen) {\n packet.utf8Write(msg, p, msgLen);\n p += msgLen;\n }\n\n writeUInt32BE(packet, 0, p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-signal: ${name})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n // 'ssh-userauth' service-specific\n authFailure(authMethods, isPartial) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0)\n throw new Error('No auth in progress');\n\n let methods;\n\n if (typeof authMethods === 'boolean') {\n isPartial = authMethods;\n authMethods = undefined;\n }\n\n if (authMethods) {\n methods = [];\n for (let i = 0; i < authMethods.length; ++i) {\n if (authMethods[i].toLowerCase() === 'none')\n continue;\n methods.push(authMethods[i]);\n }\n methods = methods.join(',');\n } else {\n methods = '';\n }\n\n const methodsLen = methods.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + methodsLen + 1);\n\n packet[p] = MESSAGE.USERAUTH_FAILURE;\n\n writeUInt32BE(packet, methodsLen, ++p);\n packet.utf8Write(methods, p += 4, methodsLen);\n\n packet[p += methodsLen] = (isPartial === true ? 1 : 0);\n\n this._authsQueue.shift();\n\n this._debug && this._debug('Outbound: Sending USERAUTH_FAILURE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authSuccess() {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0)\n throw new Error('No auth in progress');\n\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.USERAUTH_SUCCESS;\n\n this._authsQueue.shift();\n this._authenticated = true;\n\n this._debug && this._debug('Outbound: Sending USERAUTH_SUCCESS');\n sendPacket(this, this._packetRW.write.finalize(packet));\n\n if (this._kex.negotiated.cs.compress === 'zlib@openssh.com')\n this._packetRW.read = new ZlibPacketReader();\n if (this._kex.negotiated.sc.compress === 'zlib@openssh.com')\n this._packetRW.write = new ZlibPacketWriter(this);\n }\n authPKOK(keyAlgo, key) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0 || this._authsQueue[0] !== 'publickey')\n throw new Error('\"publickey\" auth not in progress');\n\n // TODO: support parsed key for `key`\n\n const keyAlgoLen = Buffer.byteLength(keyAlgo);\n const keyLen = key.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + keyAlgoLen + 4 + keyLen);\n\n packet[p] = MESSAGE.USERAUTH_PK_OK;\n\n writeUInt32BE(packet, keyAlgoLen, ++p);\n packet.utf8Write(keyAlgo, p += 4, keyAlgoLen);\n\n writeUInt32BE(packet, keyLen, p += keyAlgoLen);\n packet.set(key, p += 4);\n\n this._authsQueue.shift();\n\n this._debug && this._debug('Outbound: Sending USERAUTH_PK_OK');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authPasswdChg(prompt) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const promptLen = Buffer.byteLength(prompt);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + promptLen + 4);\n\n packet[p] = MESSAGE.USERAUTH_PASSWD_CHANGEREQ;\n\n writeUInt32BE(packet, promptLen, ++p);\n packet.utf8Write(prompt, p += 4, promptLen);\n\n writeUInt32BE(packet, 0, p += promptLen); // Empty language tag\n\n this._debug && this._debug('Outbound: Sending USERAUTH_PASSWD_CHANGEREQ');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authInfoReq(name, instructions, prompts) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n let promptsLen = 0;\n const nameLen = name ? Buffer.byteLength(name) : 0;\n const instrLen = instructions ? Buffer.byteLength(instructions) : 0;\n\n for (let i = 0; i < prompts.length; ++i)\n promptsLen += 4 + Buffer.byteLength(prompts[i].prompt) + 1;\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + nameLen + 4 + instrLen + 4 + 4 + promptsLen\n );\n\n packet[p] = MESSAGE.USERAUTH_INFO_REQUEST;\n\n writeUInt32BE(packet, nameLen, ++p);\n p += 4;\n if (name) {\n packet.utf8Write(name, p, nameLen);\n p += nameLen;\n }\n\n writeUInt32BE(packet, instrLen, p);\n p += 4;\n if (instructions) {\n packet.utf8Write(instructions, p, instrLen);\n p += instrLen;\n }\n\n writeUInt32BE(packet, 0, p);\n\n writeUInt32BE(packet, prompts.length, p += 4);\n p += 4;\n for (let i = 0; i < prompts.length; ++i) {\n const prompt = prompts[i];\n const promptLen = Buffer.byteLength(prompt.prompt);\n\n writeUInt32BE(packet, promptLen, p);\n p += 4;\n if (promptLen) {\n packet.utf8Write(prompt.prompt, p, promptLen);\n p += promptLen;\n }\n packet[p++] = (prompt.echo ? 1 : 0);\n }\n\n this._debug && this._debug('Outbound: Sending USERAUTH_INFO_REQUEST');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n}\n\n// SSH-protoversion-softwareversion (SP comments) CR LF\nconst RE_IDENT = /^SSH-(2\\.0|1\\.99)-([^ ]+)(?: (.*))?$/;\n\n// TODO: optimize this by starting n bytes from the end of this._buffer instead\n// of the beginning\nfunction parseHeader(chunk, p, len) {\n let data;\n let chunkOffset;\n if (this._buffer) {\n data = Buffer.allocUnsafe(this._buffer.length + (len - p));\n data.set(this._buffer, 0);\n if (p === 0) {\n data.set(chunk, this._buffer.length);\n } else {\n data.set(new Uint8Array(chunk.buffer,\n chunk.byteOffset + p,\n (len - p)),\n this._buffer.length);\n }\n chunkOffset = this._buffer.length;\n p = 0;\n } else {\n data = chunk;\n chunkOffset = 0;\n }\n const op = p;\n let start = p;\n let end = p;\n let needNL = false;\n let lineLen = 0;\n let lines = 0;\n for (; p < data.length; ++p) {\n const ch = data[p];\n\n if (ch === 13 /* '\\r' */) {\n needNL = true;\n continue;\n }\n\n if (ch === 10 /* '\\n' */) {\n if (end > start\n && end - start > 4\n && data[start] === 83 /* 'S' */\n && data[start + 1] === 83 /* 'S' */\n && data[start + 2] === 72 /* 'H' */\n && data[start + 3] === 45 /* '-' */) {\n\n const full = data.latin1Slice(op, end + 1);\n const identRaw = (start === op ? full : full.slice(start - op));\n const m = RE_IDENT.exec(identRaw);\n if (!m)\n throw new Error('Invalid identification string');\n\n const header = {\n greeting: (start === op ? '' : full.slice(0, start - op)),\n identRaw,\n versions: {\n protocol: m[1],\n software: m[2],\n },\n comments: m[3]\n };\n\n // Needed during handshake\n this._remoteIdentRaw = Buffer.from(identRaw);\n\n this._debug && this._debug(`Remote ident: ${inspect(identRaw)}`);\n this._compatFlags = getCompatFlags(header);\n\n this._buffer = undefined;\n this._decipher =\n new NullDecipher(0, onKEXPayload.bind(this, { firstPacket: true }));\n this._parse = parsePacket;\n\n this._onHeader(header);\n if (!this._destruct) {\n // We disconnected inside _onHeader\n return len;\n }\n\n kexinit(this);\n\n return p + 1 - chunkOffset;\n }\n\n // Only allow pre-ident greetings when we're a client\n if (this._server)\n throw new Error('Greetings from clients not permitted');\n\n if (++lines > MAX_LINES)\n throw new Error('Max greeting lines exceeded');\n\n needNL = false;\n start = p + 1;\n lineLen = 0;\n } else if (needNL) {\n throw new Error('Invalid header: expected newline');\n } else if (++lineLen >= MAX_LINE_LEN) {\n throw new Error('Header line too long');\n }\n\n end = p;\n }\n if (!this._buffer)\n this._buffer = bufferSlice(data, op);\n\n return p - chunkOffset;\n}\n\nfunction parsePacket(chunk, p, len) {\n return this._decipher.decrypt(chunk, p, len);\n}\n\nfunction onPayload(payload) {\n // XXX: move this to the Decipher implementations?\n\n this._onPacket();\n\n if (payload.length === 0) {\n this._debug && this._debug('Inbound: Skipping empty packet payload');\n return;\n }\n\n payload = this._packetRW.read.read(payload);\n\n const type = payload[0];\n if (type === MESSAGE.USERAUTH_SUCCESS\n && !this._server\n && !this._authenticated) {\n this._authenticated = true;\n if (this._kex.negotiated.cs.compress === 'zlib@openssh.com')\n this._packetRW.write = new ZlibPacketWriter(this);\n if (this._kex.negotiated.sc.compress === 'zlib@openssh.com')\n this._packetRW.read = new ZlibPacketReader();\n }\n const handler = MESSAGE_HANDLERS[type];\n if (handler === undefined) {\n this._debug && this._debug(`Inbound: Unsupported message type: ${type}`);\n return;\n }\n\n return handler(this, payload);\n}\n\nfunction getCompatFlags(header) {\n const software = header.versions.software;\n\n let flags = 0;\n\n for (const rule of COMPAT_CHECKS) {\n if (typeof rule[0] === 'string') {\n if (software === rule[0])\n flags |= rule[1];\n } else if (rule[0].test(software)) {\n flags |= rule[1];\n }\n }\n\n return flags;\n}\n\nfunction modesToBytes(modes) {\n const keys = Object.keys(modes);\n const bytes = Buffer.allocUnsafe((5 * keys.length) + 1);\n let b = 0;\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n if (key === 'TTY_OP_END')\n continue;\n\n const opcode = TERMINAL_MODE[key];\n if (opcode === undefined)\n continue;\n\n const val = modes[key];\n if (typeof val === 'number' && isFinite(val)) {\n bytes[b++] = opcode;\n bytes[b++] = val >>> 24;\n bytes[b++] = val >>> 16;\n bytes[b++] = val >>> 8;\n bytes[b++] = val;\n }\n }\n\n bytes[b++] = TERMINAL_MODE.TTY_OP_END;\n\n if (b < bytes.length)\n return bufferSlice(bytes, 0, b);\n\n return bytes;\n}\n\nmodule.exports = Protocol;\n","'use strict';\n\nconst EventEmitter = require('events');\nconst fs = require('fs');\nconst { constants } = fs;\nconst {\n Readable: ReadableStream,\n Writable: WritableStream\n} = require('stream');\nconst { inherits, isDate } = require('util');\n\nconst FastBuffer = Buffer[Symbol.species];\n\nconst {\n bufferCopy,\n bufferSlice,\n makeBufferParser,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst ATTR = {\n SIZE: 0x00000001,\n UIDGID: 0x00000002,\n PERMISSIONS: 0x00000004,\n ACMODTIME: 0x00000008,\n EXTENDED: 0x80000000,\n};\n\n// Large enough to store all possible attributes\nconst ATTRS_BUF = Buffer.alloc(28);\n\nconst STATUS_CODE = {\n OK: 0,\n EOF: 1,\n NO_SUCH_FILE: 2,\n PERMISSION_DENIED: 3,\n FAILURE: 4,\n BAD_MESSAGE: 5,\n NO_CONNECTION: 6,\n CONNECTION_LOST: 7,\n OP_UNSUPPORTED: 8\n};\n\nconst VALID_STATUS_CODES = new Map(\n Object.values(STATUS_CODE).map((n) => [n, 1])\n);\n\nconst STATUS_CODE_STR = {\n [STATUS_CODE.OK]: 'No error',\n [STATUS_CODE.EOF]: 'End of file',\n [STATUS_CODE.NO_SUCH_FILE]: 'No such file or directory',\n [STATUS_CODE.PERMISSION_DENIED]: 'Permission denied',\n [STATUS_CODE.FAILURE]: 'Failure',\n [STATUS_CODE.BAD_MESSAGE]: 'Bad message',\n [STATUS_CODE.NO_CONNECTION]: 'No connection',\n [STATUS_CODE.CONNECTION_LOST]: 'Connection lost',\n [STATUS_CODE.OP_UNSUPPORTED]: 'Operation unsupported',\n};\n\nconst REQUEST = {\n INIT: 1,\n OPEN: 3,\n CLOSE: 4,\n READ: 5,\n WRITE: 6,\n LSTAT: 7,\n FSTAT: 8,\n SETSTAT: 9,\n FSETSTAT: 10,\n OPENDIR: 11,\n READDIR: 12,\n REMOVE: 13,\n MKDIR: 14,\n RMDIR: 15,\n REALPATH: 16,\n STAT: 17,\n RENAME: 18,\n READLINK: 19,\n SYMLINK: 20,\n EXTENDED: 200\n};\n\nconst RESPONSE = {\n VERSION: 2,\n STATUS: 101,\n HANDLE: 102,\n DATA: 103,\n NAME: 104,\n ATTRS: 105,\n EXTENDED: 201\n};\n\nconst OPEN_MODE = {\n READ: 0x00000001,\n WRITE: 0x00000002,\n APPEND: 0x00000004,\n CREAT: 0x00000008,\n TRUNC: 0x00000010,\n EXCL: 0x00000020\n};\n\nconst PKT_RW_OVERHEAD = 2 * 1024;\nconst MAX_REQID = 2 ** 32 - 1;\nconst CLIENT_VERSION_BUFFER = Buffer.from([\n 0, 0, 0, 5 /* length */,\n REQUEST.INIT,\n 0, 0, 0, 3 /* version */\n]);\nconst SERVER_VERSION_BUFFER = Buffer.from([\n 0, 0, 0, 5 /* length */,\n RESPONSE.VERSION,\n 0, 0, 0, 3 /* version */\n]);\n\nconst RE_OPENSSH = /^SSH-2.0-(?:OpenSSH|dropbear)/;\nconst OPENSSH_MAX_PKT_LEN = 256 * 1024;\n\nconst bufferParser = makeBufferParser();\n\nconst fakeStderr = {\n readable: false,\n writable: false,\n push: (data) => {},\n once: () => {},\n on: () => {},\n emit: () => {},\n end: () => {},\n};\n\nfunction noop() {}\n\n// Emulates enough of `Channel` to be able to be used as a drop-in replacement\n// in order to process incoming data with as little overhead as possible\nclass SFTP extends EventEmitter {\n constructor(client, chanInfo, cfg) {\n super();\n\n if (typeof cfg !== 'object' || !cfg)\n cfg = {};\n\n const remoteIdentRaw = client._protocol._remoteIdentRaw;\n\n this.server = !!cfg.server;\n this._debug = (typeof cfg.debug === 'function' ? cfg.debug : undefined);\n this._isOpenSSH = (remoteIdentRaw && RE_OPENSSH.test(remoteIdentRaw));\n\n this._version = -1;\n this._extensions = {};\n this._biOpt = cfg.biOpt;\n this._pktLenBytes = 0;\n this._pktLen = 0;\n this._pktPos = 0;\n this._pktType = 0;\n this._pktData = undefined;\n this._writeReqid = -1;\n this._requests = {};\n this._maxInPktLen = OPENSSH_MAX_PKT_LEN;\n this._maxOutPktLen = 34000;\n this._maxReadLen =\n (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;\n this._maxWriteLen =\n (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;\n\n this.maxOpenHandles = undefined;\n\n // Channel compatibility\n this._client = client;\n this._protocol = client._protocol;\n this._callbacks = [];\n this._hasX11 = false;\n this._exit = {\n code: undefined,\n signal: undefined,\n dump: undefined,\n desc: undefined,\n };\n this._waitWindow = false; // SSH-level backpressure\n this._chunkcb = undefined;\n this._buffer = [];\n this.type = chanInfo.type;\n this.subtype = undefined;\n this.incoming = chanInfo.incoming;\n this.outgoing = chanInfo.outgoing;\n this.stderr = fakeStderr;\n this.readable = true;\n }\n\n // This handles incoming data to parse\n push(data) {\n if (data === null) {\n cleanupRequests(this);\n if (!this.readable)\n return;\n // No more incoming data from the remote side\n this.readable = false;\n this.emit('end');\n return;\n }\n /*\n uint32 length\n byte type\n byte[length - 1] data payload\n */\n let p = 0;\n\n while (p < data.length) {\n if (this._pktLenBytes < 4) {\n let nb = Math.min(4 - this._pktLenBytes, data.length - p);\n this._pktLenBytes += nb;\n\n while (nb--)\n this._pktLen = (this._pktLen << 8) + data[p++];\n\n if (this._pktLenBytes < 4)\n return;\n if (this._pktLen === 0)\n return doFatalSFTPError(this, 'Invalid packet length');\n if (this._pktLen > this._maxInPktLen) {\n const max = this._maxInPktLen;\n return doFatalSFTPError(\n this,\n `Packet length ${this._pktLen} exceeds max length of ${max}`\n );\n }\n if (p >= data.length)\n return;\n }\n if (this._pktPos < this._pktLen) {\n const nb = Math.min(this._pktLen - this._pktPos, data.length - p);\n if (p !== 0 || nb !== data.length) {\n if (nb === this._pktLen) {\n this._pkt = new FastBuffer(data.buffer, data.byteOffset + p, nb);\n } else {\n if (!this._pkt)\n this._pkt = Buffer.allocUnsafe(this._pktLen);\n this._pkt.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._pktPos\n );\n }\n } else if (nb === this._pktLen) {\n this._pkt = data;\n } else {\n if (!this._pkt)\n this._pkt = Buffer.allocUnsafe(this._pktLen);\n this._pkt.set(data, this._pktPos);\n }\n p += nb;\n this._pktPos += nb;\n if (this._pktPos < this._pktLen)\n return;\n }\n\n const type = this._pkt[0];\n const payload = this._pkt;\n\n // Prepare for next packet\n this._pktLen = 0;\n this._pktLenBytes = 0;\n this._pkt = undefined;\n this._pktPos = 0;\n\n const handler = (this.server\n ? SERVER_HANDLERS[type]\n : CLIENT_HANDLERS[type]);\n if (!handler)\n return doFatalSFTPError(this, `Unknown packet type ${type}`);\n\n if (this._version === -1) {\n if (this.server) {\n if (type !== REQUEST.INIT)\n return doFatalSFTPError(this, `Expected INIT packet, got ${type}`);\n } else if (type !== RESPONSE.VERSION) {\n return doFatalSFTPError(this, `Expected VERSION packet, got ${type}`);\n }\n }\n\n if (handler(this, payload) === false)\n return;\n }\n }\n\n end() {\n this.destroy();\n }\n destroy() {\n if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {\n this.outgoing.state = 'closing';\n this._protocol.channelClose(this.outgoing.id);\n }\n }\n _init() {\n this._init = noop;\n if (!this.server)\n sendOrBuffer(this, CLIENT_VERSION_BUFFER);\n }\n\n // ===========================================================================\n // Client-specific ===========================================================\n // ===========================================================================\n createReadStream(path, options) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n return new ReadStream(this, path, options);\n }\n createWriteStream(path, options) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n return new WriteStream(this, path, options);\n }\n open(path, flags_, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (typeof attrs === 'function') {\n cb = attrs;\n attrs = undefined;\n }\n\n const flags = (typeof flags_ === 'number' ? flags_ : stringToFlags(flags_));\n if (flags === null)\n throw new Error(`Unknown flags string: ${flags_}`);\n\n let attrsFlags = 0;\n let attrsLen = 0;\n if (typeof attrs === 'string' || typeof attrs === 'number')\n attrs = { mode: attrs };\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n attrsFlags = attrs.flags;\n attrsLen = attrs.nb;\n }\n\n /*\n uint32 id\n string filename\n uint32 pflags\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.OPEN;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n writeUInt32BE(buf, attrsFlags, p += 4);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPEN`\n );\n }\n close(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.CLOSE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} CLOSE`\n );\n }\n read(handle, buf, off, len, position, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n if (!Buffer.isBuffer(buf))\n throw new Error('buffer is not a Buffer');\n if (off >= buf.length)\n throw new Error('offset is out of bounds');\n if (off + len > buf.length)\n throw new Error('length extends beyond buffer');\n if (position === null)\n throw new Error('null position currently unsupported');\n\n read_(this, handle, buf, off, len, position, cb);\n }\n readData(handle, buf, off, len, position, cb) {\n // Backwards compatibility\n this.read(handle, buf, off, len, position, cb);\n }\n write(handle, buf, off, len, position, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n if (!Buffer.isBuffer(buf))\n throw new Error('buffer is not a Buffer');\n if (off > buf.length)\n throw new Error('offset is out of bounds');\n if (off + len > buf.length)\n throw new Error('length extends beyond buffer');\n if (position === null)\n throw new Error('null position currently unsupported');\n\n if (!len) {\n cb && process.nextTick(cb, undefined, 0);\n return;\n }\n\n const maxDataLen = this._maxWriteLen;\n const overflow = Math.max(len - maxDataLen, 0);\n const origPosition = position;\n\n if (overflow)\n len = maxDataLen;\n\n /*\n uint32 id\n string handle\n uint64 offset\n string data\n */\n const handleLen = handle.length;\n let p = 9;\n const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4 + len);\n\n writeUInt32BE(out, out.length - 4, 0);\n out[4] = REQUEST.WRITE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(out, reqid, 5);\n\n writeUInt32BE(out, handleLen, p);\n out.set(handle, p += 4);\n p += handleLen;\n for (let i = 7; i >= 0; --i) {\n out[p + i] = position & 0xFF;\n position /= 256;\n }\n writeUInt32BE(out, len, p += 8);\n bufferCopy(buf, out, off, off + len, p += 4);\n\n this._requests[reqid] = {\n cb: (err) => {\n if (err) {\n if (typeof cb === 'function')\n cb(err);\n } else if (overflow) {\n this.write(handle,\n buf,\n off + len,\n overflow,\n origPosition + len,\n cb);\n } else if (typeof cb === 'function') {\n cb(undefined, off + len);\n }\n }\n };\n\n const isSent = sendOrBuffer(this, out);\n if (this._debug) {\n const how = (isSent ? 'Sent' : 'Buffered');\n this._debug(`SFTP: Outbound: ${how} WRITE (id:${reqid})`);\n }\n }\n writeData(handle, buf, off, len, position, cb) {\n // Backwards compatibility\n this.write(handle, buf, off, len, position, cb);\n }\n fastGet(remotePath, localPath, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n fastXfer(this, fs, remotePath, localPath, opts, cb);\n }\n fastPut(localPath, remotePath, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n fastXfer(fs, this, localPath, remotePath, opts, cb);\n }\n readFile(path, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, flag: 'r' };\n else if (!options)\n options = { encoding: null, flag: 'r' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n const encoding = options.encoding;\n if (encoding && !Buffer.isEncoding(encoding))\n throw new Error(`Unknown encoding: ${encoding}`);\n\n // First stat the file, so we know the size.\n let size;\n let buffer; // Single buffer with file data\n let buffers; // List for when size is unknown\n let pos = 0;\n let handle;\n\n // SFTPv3 does not support using -1 for read position, so we have to track\n // read position manually\n let bytesRead = 0;\n\n const flag = options.flag || 'r';\n\n const read = () => {\n if (size === 0) {\n buffer = Buffer.allocUnsafe(8192);\n this.read(handle, buffer, 0, 8192, bytesRead, afterRead);\n } else {\n this.read(handle, buffer, pos, size - pos, bytesRead, afterRead);\n }\n };\n\n const afterRead = (er, nbytes) => {\n let eof;\n if (er) {\n eof = (er.code === STATUS_CODE.EOF);\n if (!eof) {\n return this.close(handle, () => {\n return callback && callback(er);\n });\n }\n } else {\n eof = false;\n }\n\n if (eof || (size === 0 && nbytes === 0))\n return close();\n\n bytesRead += nbytes;\n pos += nbytes;\n if (size !== 0) {\n if (pos === size)\n close();\n else\n read();\n } else {\n // Unknown size, just read until we don't get bytes.\n buffers.push(bufferSlice(buffer, 0, nbytes));\n read();\n }\n };\n afterRead._wantEOFError = true;\n\n const close = () => {\n this.close(handle, (er) => {\n if (size === 0) {\n // Collect the data into the buffers list.\n buffer = Buffer.concat(buffers, pos);\n } else if (pos < size) {\n buffer = bufferSlice(buffer, 0, pos);\n }\n\n if (encoding)\n buffer = buffer.toString(encoding);\n return callback && callback(er, buffer);\n });\n };\n\n this.open(path, flag, 0o666, (er, handle_) => {\n if (er)\n return callback && callback(er);\n handle = handle_;\n\n const tryStat = (er, st) => {\n if (er) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.stat(path, (er_, st_) => {\n if (er_) {\n return this.close(handle, () => {\n callback && callback(er);\n });\n }\n tryStat(null, st_);\n });\n return;\n }\n\n size = st.size || 0;\n if (size === 0) {\n // The kernel lies about many files.\n // Go ahead and try to read some bytes.\n buffers = [];\n return read();\n }\n\n buffer = Buffer.allocUnsafe(size);\n read();\n };\n this.fstat(handle, tryStat);\n });\n }\n writeFile(path, data, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, mode: 0o666, flag: 'w' };\n else if (!options)\n options = { encoding: 'utf8', mode: 0o666, flag: 'w' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n if (options.encoding && !Buffer.isEncoding(options.encoding))\n throw new Error(`Unknown encoding: ${options.encoding}`);\n\n const flag = options.flag || 'w';\n this.open(path, flag, options.mode, (openErr, handle) => {\n if (openErr) {\n callback && callback(openErr);\n } else {\n const buffer = (Buffer.isBuffer(data)\n ? data\n : Buffer.from('' + data, options.encoding || 'utf8'));\n const position = (/a/.test(flag) ? null : 0);\n\n // SFTPv3 does not support the notion of 'current position'\n // (null position), so we just attempt to append to the end of the file\n // instead\n if (position === null) {\n const tryStat = (er, st) => {\n if (er) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.stat(path, (er_, st_) => {\n if (er_) {\n return this.close(handle, () => {\n callback && callback(er);\n });\n }\n tryStat(null, st_);\n });\n return;\n }\n writeAll(this, handle, buffer, 0, buffer.length, st.size, callback);\n };\n this.fstat(handle, tryStat);\n return;\n }\n writeAll(this, handle, buffer, 0, buffer.length, position, callback);\n }\n });\n }\n appendFile(path, data, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, mode: 0o666, flag: 'a' };\n else if (!options)\n options = { encoding: 'utf8', mode: 0o666, flag: 'a' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n if (!options.flag)\n options = Object.assign({ flag: 'a' }, options);\n this.writeFile(path, data, options, callback);\n }\n exists(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n this.stat(path, (err) => {\n cb && cb(err ? false : true);\n });\n }\n unlink(filename, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string filename\n */\n const fnameLen = Buffer.byteLength(filename);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + fnameLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.REMOVE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, fnameLen, p);\n buf.utf8Write(filename, p += 4, fnameLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REMOVE`\n );\n }\n rename(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.RENAME;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, oldLen, p);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RENAME`\n );\n }\n mkdir(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'function') {\n cb = attrs;\n attrs = undefined;\n }\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n }\n\n /*\n uint32 id\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.MKDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} MKDIR`\n );\n }\n rmdir(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.RMDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RMDIR`\n );\n }\n readdir(where, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n if (typeof opts !== 'object' || opts === null)\n opts = {};\n\n const doFilter = (opts && opts.full ? false : true);\n\n if (!Buffer.isBuffer(where) && typeof where !== 'string')\n throw new Error('missing directory handle or path');\n\n if (typeof where === 'string') {\n const entries = [];\n let e = 0;\n\n const reread = (err, handle) => {\n if (err)\n return cb(err);\n\n this.readdir(handle, opts, (err, list) => {\n const eof = (err && err.code === STATUS_CODE.EOF);\n\n if (err && !eof)\n return this.close(handle, () => cb(err));\n\n if (eof) {\n return this.close(handle, (err) => {\n if (err)\n return cb(err);\n cb(undefined, entries);\n });\n }\n\n for (let i = 0; i < list.length; ++i, ++e)\n entries[e] = list[i];\n\n reread(undefined, handle);\n });\n };\n return this.opendir(where, reread);\n }\n\n /*\n uint32 id\n string handle\n */\n const handleLen = where.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.READDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(where, p += 4);\n\n this._requests[reqid] = {\n cb: (doFilter\n ? (err, list) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n\n for (let i = list.length - 1; i >= 0; --i) {\n if (list[i].filename === '.' || list[i].filename === '..')\n list.splice(i, 1);\n }\n\n cb(undefined, list);\n }\n : cb)\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READDIR`\n );\n }\n fstat(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.FSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSTAT`\n );\n }\n stat(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.STAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STAT`\n );\n }\n lstat(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.LSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} LSTAT`\n );\n }\n opendir(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.OPENDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPENDIR`\n );\n }\n setstat(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.SETSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SETSTAT`\n );\n }\n fsetstat(handle, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string handle\n ATTRS attrs\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.FSETSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n writeUInt32BE(buf, flags, p += handleLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSETSTAT`\n );\n }\n futimes(handle, atime, mtime, cb) {\n return this.fsetstat(handle, {\n atime: toUnixTimestamp(atime),\n mtime: toUnixTimestamp(mtime)\n }, cb);\n }\n utimes(path, atime, mtime, cb) {\n return this.setstat(path, {\n atime: toUnixTimestamp(atime),\n mtime: toUnixTimestamp(mtime)\n }, cb);\n }\n fchown(handle, uid, gid, cb) {\n return this.fsetstat(handle, {\n uid: uid,\n gid: gid\n }, cb);\n }\n chown(path, uid, gid, cb) {\n return this.setstat(path, {\n uid: uid,\n gid: gid\n }, cb);\n }\n fchmod(handle, mode, cb) {\n return this.fsetstat(handle, {\n mode: mode\n }, cb);\n }\n chmod(path, mode, cb) {\n return this.setstat(path, {\n mode: mode\n }, cb);\n }\n readlink(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.READLINK;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = {\n cb: (err, names) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n if (!names || !names.length)\n return cb(new Error('Response missing link info'));\n cb(undefined, names[0].filename);\n }\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READLINK`\n );\n }\n symlink(targetPath, linkPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string linkpath\n string targetpath\n */\n const linkLen = Buffer.byteLength(linkPath);\n const targetLen = Buffer.byteLength(targetPath);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + linkLen + 4 + targetLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.SYMLINK;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n if (this._isOpenSSH) {\n // OpenSSH has linkpath and targetpath positions switched\n writeUInt32BE(buf, targetLen, p);\n buf.utf8Write(targetPath, p += 4, targetLen);\n writeUInt32BE(buf, linkLen, p += targetLen);\n buf.utf8Write(linkPath, p += 4, linkLen);\n } else {\n writeUInt32BE(buf, linkLen, p);\n buf.utf8Write(linkPath, p += 4, linkLen);\n writeUInt32BE(buf, targetLen, p += linkLen);\n buf.utf8Write(targetPath, p += 4, targetLen);\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SYMLINK`\n );\n }\n realpath(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.REALPATH;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = {\n cb: (err, names) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n if (!names || !names.length)\n return cb(new Error('Response missing path info'));\n cb(undefined, names[0].filename);\n }\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REALPATH`\n );\n }\n // extended requests\n ext_openssh_rename(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['posix-rename@openssh.com'];\n if (!ext || ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"posix-rename@openssh.com\"\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 24 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 24, p);\n buf.utf8Write('posix-rename@openssh.com', p += 4, 24);\n writeUInt32BE(buf, oldLen, p += 24);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} posix-rename@openssh.com`);\n }\n }\n ext_openssh_statvfs(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['statvfs@openssh.com'];\n if (!ext || ext !== '2')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"statvfs@openssh.com\"\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 19 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 19, p);\n buf.utf8Write('statvfs@openssh.com', p += 4, 19);\n writeUInt32BE(buf, pathLen, p += 19);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { extended: 'statvfs@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} statvfs@openssh.com`);\n }\n }\n ext_openssh_fstatvfs(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['fstatvfs@openssh.com'];\n if (!ext || ext !== '2')\n throw new Error('Server does not support this extended request');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string \"fstatvfs@openssh.com\"\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('fstatvfs@openssh.com', p += 4, 20);\n writeUInt32BE(buf, handleLen, p += 20);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { extended: 'fstatvfs@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} fstatvfs@openssh.com`);\n }\n }\n ext_openssh_hardlink(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['hardlink@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"hardlink@openssh.com\"\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('hardlink@openssh.com', p += 4, 20);\n writeUInt32BE(buf, oldLen, p += 20);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} hardlink@openssh.com`);\n }\n }\n ext_openssh_fsync(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['fsync@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string \"fsync@openssh.com\"\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 17 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 17, p);\n buf.utf8Write('fsync@openssh.com', p += 4, 17);\n writeUInt32BE(buf, handleLen, p += 17);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} fsync@openssh.com`\n );\n }\n ext_openssh_lsetstat(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['lsetstat@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string \"lsetstat@openssh.com\"\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('lsetstat@openssh.com', p += 4, 20);\n\n writeUInt32BE(buf, pathLen, p += 20);\n buf.utf8Write(path, p += 4, pathLen);\n\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const status = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${status} lsetstat@openssh.com`);\n }\n }\n ext_openssh_expandPath(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['expand-path@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"expand-path@openssh.com\"\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 23 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 23, p);\n buf.utf8Write('expand-path@openssh.com', p += 4, 23);\n\n writeUInt32BE(buf, pathLen, p += 20);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const status = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${status} expand-path@openssh.com`);\n }\n }\n // ===========================================================================\n // Server-specific ===========================================================\n // ===========================================================================\n handle(reqid, handle) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n const handleLen = handle.length;\n\n if (handleLen > 256)\n throw new Error('handle too large (> 256 bytes)');\n\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.HANDLE;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n if (handleLen)\n buf.set(handle, p += 4);\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} HANDLE`\n );\n }\n status(reqid, code, message) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!VALID_STATUS_CODES.has(code))\n throw new Error(`Bad status code: ${code}`);\n\n message || (message = '');\n\n const msgLen = Buffer.byteLength(message);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 4 + msgLen + 4);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.STATUS;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, code, p);\n\n writeUInt32BE(buf, msgLen, p += 4);\n p += 4;\n if (msgLen) {\n buf.utf8Write(message, p, msgLen);\n p += msgLen;\n }\n\n writeUInt32BE(buf, 0, p); // Empty language tag\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STATUS`\n );\n }\n data(reqid, data, encoding) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n const isBuffer = Buffer.isBuffer(data);\n\n if (!isBuffer && typeof data !== 'string')\n throw new Error('data is not a Buffer or string');\n\n let isUTF8;\n if (!isBuffer && !encoding) {\n encoding = undefined;\n isUTF8 = true;\n }\n\n const dataLen = (\n isBuffer\n ? data.length\n : Buffer.byteLength(data, encoding)\n );\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + dataLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.DATA;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, dataLen, p);\n if (dataLen) {\n if (isBuffer)\n buf.set(data, p += 4);\n else if (isUTF8)\n buf.utf8Write(data, p += 4, dataLen);\n else\n buf.write(data, p += 4, dataLen, encoding);\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} DATA`\n );\n }\n name(reqid, names) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!Array.isArray(names)) {\n if (typeof names !== 'object' || names === null)\n throw new Error('names is not an object or array');\n names = [ names ];\n }\n\n const count = names.length;\n let namesLen = 0;\n let nameAttrs;\n const attrs = [];\n\n for (let i = 0; i < count; ++i) {\n const name = names[i];\n const filename = (\n !name || !name.filename || typeof name.filename !== 'string'\n ? ''\n : name.filename\n );\n namesLen += 4 + Buffer.byteLength(filename);\n const longname = (\n !name || !name.longname || typeof name.longname !== 'string'\n ? ''\n : name.longname\n );\n namesLen += 4 + Buffer.byteLength(longname);\n\n if (typeof name.attrs === 'object' && name.attrs !== null) {\n nameAttrs = attrsToBytes(name.attrs);\n namesLen += 4 + nameAttrs.nb;\n\n if (nameAttrs.nb) {\n let bytes;\n\n if (nameAttrs.nb === ATTRS_BUF.length) {\n bytes = new Uint8Array(ATTRS_BUF);\n } else {\n bytes = new Uint8Array(nameAttrs.nb);\n bufferCopy(ATTRS_BUF, bytes, 0, nameAttrs.nb, 0);\n }\n\n nameAttrs.bytes = bytes;\n }\n\n attrs.push(nameAttrs);\n } else {\n namesLen += 4;\n attrs.push(null);\n }\n }\n\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + namesLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.NAME;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, count, p);\n\n p += 4;\n\n for (let i = 0; i < count; ++i) {\n const name = names[i];\n\n {\n const filename = (\n !name || !name.filename || typeof name.filename !== 'string'\n ? ''\n : name.filename\n );\n const len = Buffer.byteLength(filename);\n writeUInt32BE(buf, len, p);\n p += 4;\n if (len) {\n buf.utf8Write(filename, p, len);\n p += len;\n }\n }\n\n {\n const longname = (\n !name || !name.longname || typeof name.longname !== 'string'\n ? ''\n : name.longname\n );\n const len = Buffer.byteLength(longname);\n writeUInt32BE(buf, len, p);\n p += 4;\n if (len) {\n buf.utf8Write(longname, p, len);\n p += len;\n }\n }\n\n const attr = attrs[i];\n if (attr) {\n writeUInt32BE(buf, attr.flags, p);\n p += 4;\n if (attr.flags && attr.bytes) {\n buf.set(attr.bytes, p);\n p += attr.nb;\n }\n } else {\n writeUInt32BE(buf, 0, p);\n p += 4;\n }\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} NAME`\n );\n }\n attrs(reqid, attrs) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (typeof attrs !== 'object' || attrs === null)\n throw new Error('attrs is not an object');\n\n attrs = attrsToBytes(attrs);\n const flags = attrs.flags;\n const attrsLen = attrs.nb;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.ATTRS;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, flags, p);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} ATTRS`\n );\n }\n}\n\nfunction tryCreateBuffer(size) {\n try {\n return Buffer.allocUnsafe(size);\n } catch (ex) {\n return ex;\n }\n}\n\nfunction read_(self, handle, buf, off, len, position, cb, req_) {\n const maxDataLen = self._maxReadLen;\n const overflow = Math.max(len - maxDataLen, 0);\n\n if (overflow)\n len = maxDataLen;\n\n /*\n uint32 id\n string handle\n uint64 offset\n uint32 len\n */\n const handleLen = handle.length;\n let p = 9;\n let pos = position;\n const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4);\n\n writeUInt32BE(out, out.length - 4, 0);\n out[4] = REQUEST.READ;\n const reqid = self._writeReqid = (self._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(out, reqid, 5);\n\n writeUInt32BE(out, handleLen, p);\n out.set(handle, p += 4);\n p += handleLen;\n for (let i = 7; i >= 0; --i) {\n out[p + i] = pos & 0xFF;\n pos /= 256;\n }\n writeUInt32BE(out, len, p += 8);\n\n if (typeof cb !== 'function')\n cb = noop;\n\n const req = (req_ || {\n nb: 0,\n position,\n off,\n origOff: off,\n len: undefined,\n overflow: undefined,\n cb: (err, data, nb) => {\n const len = req.len;\n const overflow = req.overflow;\n\n if (err) {\n if (cb._wantEOFError || err.code !== STATUS_CODE.EOF)\n return cb(err);\n } else if (nb > len) {\n return cb(new Error('Received more data than requested'));\n } else if (nb === len && overflow) {\n req.nb += nb;\n req.position += nb;\n req.off += nb;\n read_(self, handle, buf, req.off, overflow, req.position, cb, req);\n return;\n }\n\n if (req.origOff === 0 && buf.length === req.nb)\n data = buf;\n else\n data = bufferSlice(buf, req.origOff, req.origOff + req.nb);\n cb(undefined, req.nb + (nb || 0), data, req.position);\n },\n buffer: undefined,\n });\n\n req.len = len;\n req.overflow = overflow;\n\n // TODO: avoid creating multiple buffer slices when we need to re-call read_()\n // because of overflow\n req.buffer = bufferSlice(buf, off, off + len);\n\n self._requests[reqid] = req;\n\n const isBuffered = sendOrBuffer(self, out);\n self._debug && self._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READ`\n );\n}\n\nfunction fastXfer(src, dst, srcPath, dstPath, opts, cb) {\n let concurrency = 64;\n let chunkSize = 32768;\n let onstep;\n let mode;\n let fileSize;\n\n if (typeof opts === 'function') {\n cb = opts;\n } else if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.concurrency === 'number'\n && opts.concurrency > 0\n && !isNaN(opts.concurrency)) {\n concurrency = opts.concurrency;\n }\n if (typeof opts.chunkSize === 'number'\n && opts.chunkSize > 0\n && !isNaN(opts.chunkSize)) {\n chunkSize = opts.chunkSize;\n }\n if (typeof opts.fileSize === 'number'\n && opts.fileSize > 0\n && !isNaN(opts.fileSize)) {\n fileSize = opts.fileSize;\n }\n if (typeof opts.step === 'function')\n onstep = opts.step;\n\n if (typeof opts.mode === 'string' || typeof opts.mode === 'number')\n mode = modeNum(opts.mode);\n }\n\n // Internal state variables\n let fsize;\n let pdst = 0;\n let total = 0;\n let hadError = false;\n let srcHandle;\n let dstHandle;\n let readbuf;\n let bufsize = chunkSize * concurrency;\n\n function onerror(err) {\n if (hadError)\n return;\n\n hadError = true;\n\n let left = 0;\n let cbfinal;\n\n if (srcHandle || dstHandle) {\n cbfinal = () => {\n if (--left === 0)\n cb(err);\n };\n if (srcHandle && (src === fs || src.outgoing.state === 'open'))\n ++left;\n if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))\n ++left;\n if (srcHandle && (src === fs || src.outgoing.state === 'open'))\n src.close(srcHandle, cbfinal);\n if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))\n dst.close(dstHandle, cbfinal);\n } else {\n cb(err);\n }\n }\n\n src.open(srcPath, 'r', (err, sourceHandle) => {\n if (err)\n return onerror(err);\n\n srcHandle = sourceHandle;\n\n if (fileSize === undefined)\n src.fstat(srcHandle, tryStat);\n else\n tryStat(null, { size: fileSize });\n\n function tryStat(err, attrs) {\n if (err) {\n if (src !== fs) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n src.stat(srcPath, (err_, attrs_) => {\n if (err_)\n return onerror(err);\n tryStat(null, attrs_);\n });\n return;\n }\n return onerror(err);\n }\n fsize = attrs.size;\n\n dst.open(dstPath, 'w', (err, destHandle) => {\n if (err)\n return onerror(err);\n\n dstHandle = destHandle;\n\n if (fsize <= 0)\n return onerror();\n\n // Use less memory where possible\n while (bufsize > fsize) {\n if (concurrency === 1) {\n bufsize = fsize;\n break;\n }\n bufsize -= chunkSize;\n --concurrency;\n }\n\n readbuf = tryCreateBuffer(bufsize);\n if (readbuf instanceof Error)\n return onerror(readbuf);\n\n if (mode !== undefined) {\n dst.fchmod(dstHandle, mode, function tryAgain(err) {\n if (err) {\n // Try chmod() for sftp servers that may not support fchmod()\n // for whatever reason\n dst.chmod(dstPath, mode, (err_) => tryAgain());\n return;\n }\n startReads();\n });\n } else {\n startReads();\n }\n\n function onread(err, nb, data, dstpos, datapos, origChunkLen) {\n if (err)\n return onerror(err);\n\n datapos = datapos || 0;\n\n dst.write(dstHandle, readbuf, datapos, nb, dstpos, writeCb);\n\n function writeCb(err) {\n if (err)\n return onerror(err);\n\n total += nb;\n onstep && onstep(total, nb, fsize);\n\n if (nb < origChunkLen)\n return singleRead(datapos, dstpos + nb, origChunkLen - nb);\n\n if (total === fsize) {\n dst.close(dstHandle, (err) => {\n dstHandle = undefined;\n if (err)\n return onerror(err);\n src.close(srcHandle, (err) => {\n srcHandle = undefined;\n if (err)\n return onerror(err);\n cb();\n });\n });\n return;\n }\n\n if (pdst >= fsize)\n return;\n\n const chunk =\n (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);\n singleRead(datapos, pdst, chunk);\n pdst += chunk;\n }\n }\n\n function makeCb(psrc, pdst, chunk) {\n return (err, nb, data) => {\n onread(err, nb, data, pdst, psrc, chunk);\n };\n }\n\n function singleRead(psrc, pdst, chunk) {\n src.read(srcHandle,\n readbuf,\n psrc,\n chunk,\n pdst,\n makeCb(psrc, pdst, chunk));\n }\n\n function startReads() {\n let reads = 0;\n let psrc = 0;\n while (pdst < fsize && reads < concurrency) {\n const chunk =\n (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);\n singleRead(psrc, pdst, chunk);\n psrc += chunk;\n pdst += chunk;\n ++reads;\n }\n }\n });\n }\n });\n}\n\nfunction writeAll(sftp, handle, buffer, offset, length, position, callback_) {\n const callback = (typeof callback_ === 'function' ? callback_ : undefined);\n\n sftp.write(handle,\n buffer,\n offset,\n length,\n position,\n (writeErr, written) => {\n if (writeErr) {\n return sftp.close(handle, () => {\n callback && callback(writeErr);\n });\n }\n if (written === length) {\n sftp.close(handle, callback);\n } else {\n offset += written;\n length -= written;\n position += written;\n writeAll(sftp, handle, buffer, offset, length, position, callback);\n }\n });\n}\n\nclass Stats {\n constructor(initial) {\n this.mode = (initial && initial.mode);\n this.uid = (initial && initial.uid);\n this.gid = (initial && initial.gid);\n this.size = (initial && initial.size);\n this.atime = (initial && initial.atime);\n this.mtime = (initial && initial.mtime);\n this.extended = (initial && initial.extended);\n }\n isDirectory() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFDIR);\n }\n isFile() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFREG);\n }\n isBlockDevice() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFBLK);\n }\n isCharacterDevice() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFCHR);\n }\n isSymbolicLink() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFLNK);\n }\n isFIFO() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFIFO);\n }\n isSocket() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFSOCK);\n }\n}\n\nfunction attrsToBytes(attrs) {\n let flags = 0;\n let nb = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n if (typeof attrs.size === 'number') {\n flags |= ATTR.SIZE;\n const val = attrs.size;\n // Big Endian\n ATTRS_BUF[nb++] = val / 72057594037927940; // 2**56\n ATTRS_BUF[nb++] = val / 281474976710656; // 2**48\n ATTRS_BUF[nb++] = val / 1099511627776; // 2**40\n ATTRS_BUF[nb++] = val / 4294967296; // 2**32\n ATTRS_BUF[nb++] = val / 16777216; // 2**24\n ATTRS_BUF[nb++] = val / 65536; // 2**16\n ATTRS_BUF[nb++] = val / 256; // 2**8\n ATTRS_BUF[nb++] = val;\n }\n if (typeof attrs.uid === 'number' && typeof attrs.gid === 'number') {\n flags |= ATTR.UIDGID;\n const uid = attrs.uid;\n const gid = attrs.gid;\n // Big Endian\n ATTRS_BUF[nb++] = uid >>> 24;\n ATTRS_BUF[nb++] = uid >>> 16;\n ATTRS_BUF[nb++] = uid >>> 8;\n ATTRS_BUF[nb++] = uid;\n ATTRS_BUF[nb++] = gid >>> 24;\n ATTRS_BUF[nb++] = gid >>> 16;\n ATTRS_BUF[nb++] = gid >>> 8;\n ATTRS_BUF[nb++] = gid;\n }\n if (typeof attrs.mode === 'number' || typeof attrs.mode === 'string') {\n const mode = modeNum(attrs.mode);\n flags |= ATTR.PERMISSIONS;\n // Big Endian\n ATTRS_BUF[nb++] = mode >>> 24;\n ATTRS_BUF[nb++] = mode >>> 16;\n ATTRS_BUF[nb++] = mode >>> 8;\n ATTRS_BUF[nb++] = mode;\n }\n if ((typeof attrs.atime === 'number' || isDate(attrs.atime))\n && (typeof attrs.mtime === 'number' || isDate(attrs.mtime))) {\n const atime = toUnixTimestamp(attrs.atime);\n const mtime = toUnixTimestamp(attrs.mtime);\n\n flags |= ATTR.ACMODTIME;\n // Big Endian\n ATTRS_BUF[nb++] = atime >>> 24;\n ATTRS_BUF[nb++] = atime >>> 16;\n ATTRS_BUF[nb++] = atime >>> 8;\n ATTRS_BUF[nb++] = atime;\n ATTRS_BUF[nb++] = mtime >>> 24;\n ATTRS_BUF[nb++] = mtime >>> 16;\n ATTRS_BUF[nb++] = mtime >>> 8;\n ATTRS_BUF[nb++] = mtime;\n }\n // TODO: extended attributes\n }\n\n return { flags, nb };\n}\n\nfunction toUnixTimestamp(time) {\n // eslint-disable-next-line no-self-compare\n if (typeof time === 'number' && time === time) // Valid, non-NaN number\n return time;\n if (isDate(time))\n return parseInt(time.getTime() / 1000, 10);\n throw new Error(`Cannot parse time: ${time}`);\n}\n\nfunction modeNum(mode) {\n // eslint-disable-next-line no-self-compare\n if (typeof mode === 'number' && mode === mode) // Valid, non-NaN number\n return mode;\n if (typeof mode === 'string')\n return modeNum(parseInt(mode, 8));\n throw new Error(`Cannot parse mode: ${mode}`);\n}\n\nconst stringFlagMap = {\n 'r': OPEN_MODE.READ,\n 'r+': OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'w': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE,\n 'wx': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'xw': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'w+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'wx+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'xw+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'a': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE,\n 'ax': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'xa': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'a+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'ax+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'xa+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL\n};\n\nfunction stringToFlags(str) {\n const flags = stringFlagMap[str];\n return (flags !== undefined ? flags : null);\n}\n\nconst flagsToString = (() => {\n const stringFlagMapKeys = Object.keys(stringFlagMap);\n return (flags) => {\n for (let i = 0; i < stringFlagMapKeys.length; ++i) {\n const key = stringFlagMapKeys[i];\n if (stringFlagMap[key] === flags)\n return key;\n }\n return null;\n };\n})();\n\nfunction readAttrs(biOpt) {\n /*\n uint32 flags\n uint64 size present only if flag SSH_FILEXFER_ATTR_SIZE\n uint32 uid present only if flag SSH_FILEXFER_ATTR_UIDGID\n uint32 gid present only if flag SSH_FILEXFER_ATTR_UIDGID\n uint32 permissions present only if flag SSH_FILEXFER_ATTR_PERMISSIONS\n uint32 atime present only if flag SSH_FILEXFER_ACMODTIME\n uint32 mtime present only if flag SSH_FILEXFER_ACMODTIME\n uint32 extended_count present only if flag SSH_FILEXFER_ATTR_EXTENDED\n string extended_type\n string extended_data\n ... more extended data (extended_type - extended_data pairs),\n so that number of pairs equals extended_count\n */\n const flags = bufferParser.readUInt32BE();\n if (flags === undefined)\n return;\n\n const attrs = new Stats();\n if (flags & ATTR.SIZE) {\n const size = bufferParser.readUInt64BE(biOpt);\n if (size === undefined)\n return;\n attrs.size = size;\n }\n\n if (flags & ATTR.UIDGID) {\n const uid = bufferParser.readUInt32BE();\n const gid = bufferParser.readUInt32BE();\n if (gid === undefined)\n return;\n attrs.uid = uid;\n attrs.gid = gid;\n }\n\n if (flags & ATTR.PERMISSIONS) {\n const mode = bufferParser.readUInt32BE();\n if (mode === undefined)\n return;\n attrs.mode = mode;\n }\n\n if (flags & ATTR.ACMODTIME) {\n const atime = bufferParser.readUInt32BE();\n const mtime = bufferParser.readUInt32BE();\n if (mtime === undefined)\n return;\n attrs.atime = atime;\n attrs.mtime = mtime;\n }\n\n if (flags & ATTR.EXTENDED) {\n const count = bufferParser.readUInt32BE();\n if (count === undefined)\n return;\n const extended = {};\n for (let i = 0; i < count; ++i) {\n const type = bufferParser.readString(true);\n const data = bufferParser.readString();\n if (data === undefined)\n return;\n extended[type] = data;\n }\n attrs.extended = extended;\n }\n\n return attrs;\n}\n\nfunction sendOrBuffer(sftp, payload) {\n const ret = tryWritePayload(sftp, payload);\n if (ret !== undefined) {\n sftp._buffer.push(ret);\n return false;\n }\n return true;\n}\n\nfunction tryWritePayload(sftp, payload) {\n const outgoing = sftp.outgoing;\n if (outgoing.state !== 'open')\n return;\n\n if (outgoing.window === 0) {\n sftp._waitWindow = true; // XXX: Unnecessary?\n return payload;\n }\n\n let ret;\n const len = payload.length;\n let p = 0;\n\n while (len - p > 0 && outgoing.window > 0) {\n const actualLen = Math.min(len - p, outgoing.window, outgoing.packetSize);\n outgoing.window -= actualLen;\n if (outgoing.window === 0) {\n sftp._waitWindow = true;\n sftp._chunkcb = drainBuffer;\n }\n\n if (p === 0 && actualLen === len) {\n sftp._protocol.channelData(sftp.outgoing.id, payload);\n } else {\n sftp._protocol.channelData(sftp.outgoing.id,\n bufferSlice(payload, p, p + actualLen));\n }\n\n p += actualLen;\n }\n\n if (len - p > 0) {\n if (p > 0)\n ret = bufferSlice(payload, p, len);\n else\n ret = payload; // XXX: should never get here?\n }\n\n return ret;\n}\n\nfunction drainBuffer() {\n this._chunkcb = undefined;\n const buffer = this._buffer;\n let i = 0;\n while (i < buffer.length) {\n const payload = buffer[i];\n const ret = tryWritePayload(this, payload);\n if (ret !== undefined) {\n if (ret !== payload)\n buffer[i] = ret;\n if (i > 0)\n this._buffer = buffer.slice(i);\n return;\n }\n ++i;\n }\n if (i > 0)\n this._buffer = [];\n}\n\nfunction doFatalSFTPError(sftp, msg, noDebug) {\n const err = new Error(msg);\n err.level = 'sftp-protocol';\n if (!noDebug && sftp._debug)\n sftp._debug(`SFTP: Inbound: ${msg}`);\n sftp.emit('error', err);\n sftp.destroy();\n cleanupRequests(sftp);\n return false;\n}\n\nfunction cleanupRequests(sftp) {\n const keys = Object.keys(sftp._requests);\n if (keys.length === 0)\n return;\n\n const reqs = sftp._requests;\n sftp._requests = {};\n const err = new Error('No response from server');\n for (let i = 0; i < keys.length; ++i) {\n const req = reqs[keys[i]];\n if (typeof req.cb === 'function')\n req.cb(err);\n }\n}\n\nfunction requestLimits(sftp, cb) {\n /*\n uint32 id\n string \"limits@openssh.com\"\n */\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 18);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = sftp._writeReqid = (sftp._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 18, p);\n buf.utf8Write('limits@openssh.com', p += 4, 18);\n\n sftp._requests[reqid] = { extended: 'limits@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(sftp, buf);\n if (sftp._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n sftp._debug(`SFTP: Outbound: ${which} limits@openssh.com`);\n }\n}\n\nconst CLIENT_HANDLERS = {\n [RESPONSE.VERSION]: (sftp, payload) => {\n if (sftp._version !== -1)\n return doFatalSFTPError(sftp, 'Duplicate VERSION packet');\n\n const extensions = {};\n\n /*\n uint32 version\n \n */\n bufferParser.init(payload, 1);\n let version = bufferParser.readUInt32BE();\n while (bufferParser.avail()) {\n const extName = bufferParser.readString(true);\n const extData = bufferParser.readString(true);\n if (extData === undefined) {\n version = undefined;\n break;\n }\n extensions[extName] = extData;\n }\n bufferParser.clear();\n\n if (version === undefined)\n return doFatalSFTPError(sftp, 'Malformed VERSION packet');\n\n if (sftp._debug) {\n const names = Object.keys(extensions);\n if (names.length) {\n sftp._debug(\n `SFTP: Inbound: Received VERSION (v${version}, exts:${names})`\n );\n } else {\n sftp._debug(`SFTP: Inbound: Received VERSION (v${version})`);\n }\n }\n\n sftp._version = version;\n sftp._extensions = extensions;\n\n if (extensions['limits@openssh.com'] === '1') {\n return requestLimits(sftp, (err, limits) => {\n if (!err) {\n if (limits.maxPktLen > 0)\n sftp._maxOutPktLen = limits.maxPktLen;\n if (limits.maxReadLen > 0)\n sftp._maxReadLen = limits.maxReadLen;\n if (limits.maxWriteLen > 0)\n sftp._maxWriteLen = limits.maxWriteLen;\n sftp.maxOpenHandles = (\n limits.maxOpenHandles > 0 ? limits.maxOpenHandles : Infinity\n );\n }\n sftp.emit('ready');\n });\n }\n\n sftp.emit('ready');\n },\n [RESPONSE.STATUS]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n uint32 error/status code\n string error message (ISO-10646 UTF-8)\n string language tag\n */\n const errorCode = bufferParser.readUInt32BE();\n const errorMsg = bufferParser.readString(true);\n const lang = bufferParser.skipString();\n bufferParser.clear();\n\n if (lang === undefined) {\n if (reqID !== undefined)\n delete sftp._requests[reqID];\n return doFatalSFTPError(sftp, 'Malformed STATUS packet');\n }\n\n if (sftp._debug) {\n const jsonMsg = JSON.stringify(errorMsg);\n sftp._debug(\n `SFTP: Inbound: Received STATUS (id:${reqID}, ${errorCode}, ${jsonMsg})`\n );\n }\n const req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n if (req && typeof req.cb === 'function') {\n if (errorCode === STATUS_CODE.OK) {\n req.cb();\n return;\n }\n const err = new Error(errorMsg\n || STATUS_CODE_STR[errorCode]\n || 'Unknown status');\n err.code = errorCode;\n req.cb(err);\n }\n },\n [RESPONSE.HANDLE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined) {\n if (reqID !== undefined)\n delete sftp._requests[reqID];\n return doFatalSFTPError(sftp, 'Malformed HANDLE packet');\n }\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received HANDLE (id:${reqID})`);\n\n const req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n if (req && typeof req.cb === 'function')\n req.cb(undefined, handle);\n },\n [RESPONSE.DATA]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n string data\n */\n if (req && typeof req.cb === 'function') {\n if (req.buffer) {\n // We have already pre-allocated space to store the data\n\n const nb = bufferParser.readString(req.buffer);\n bufferParser.clear();\n\n if (nb !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`\n );\n req.cb(undefined, req.buffer, nb);\n return;\n }\n } else {\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${data.length})`\n );\n req.cb(undefined, data);\n return;\n }\n }\n } else {\n const nb = bufferParser.skipString();\n bufferParser.clear();\n if (nb !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`\n );\n return;\n }\n }\n\n return doFatalSFTPError(sftp, 'Malformed DATA packet');\n },\n [RESPONSE.NAME]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n uint32 count\n repeats count times:\n string filename\n string longname\n ATTRS attrs\n */\n const count = bufferParser.readUInt32BE();\n if (count !== undefined) {\n let names = [];\n for (let i = 0; i < count; ++i) {\n // We are going to assume UTF-8 for filenames despite the SFTPv3\n // spec not specifying an encoding because the specs for newer\n // versions of the protocol all explicitly specify UTF-8 for\n // filenames\n const filename = bufferParser.readString(true);\n\n // `longname` only exists in SFTPv3 and since it typically will\n // contain the filename, we assume it is also UTF-8\n const longname = bufferParser.readString(true);\n\n const attrs = readAttrs(sftp._biOpt);\n if (attrs === undefined) {\n names = undefined;\n break;\n }\n names.push({ filename, longname, attrs });\n }\n if (names !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received NAME (id:${reqID}, ${names.length})`\n );\n bufferParser.clear();\n if (req && typeof req.cb === 'function')\n req.cb(undefined, names);\n return;\n }\n }\n\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed NAME packet');\n },\n [RESPONSE.ATTRS]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n ATTRS attrs\n */\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n if (attrs !== undefined) {\n sftp._debug && sftp._debug(`SFTP: Inbound: Received ATTRS (id:${reqID})`);\n if (req && typeof req.cb === 'function')\n req.cb(undefined, attrs);\n return;\n }\n\n return doFatalSFTPError(sftp, 'Malformed ATTRS packet');\n },\n [RESPONSE.EXTENDED]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n if (reqID !== undefined) {\n const req = sftp._requests[reqID];\n if (req) {\n delete sftp._requests[reqID];\n switch (req.extended) {\n case 'statvfs@openssh.com':\n case 'fstatvfs@openssh.com': {\n /*\n uint64 f_bsize // file system block size\n uint64 f_frsize // fundamental fs block size\n uint64 f_blocks // number of blocks (unit f_frsize)\n uint64 f_bfree // free blocks in file system\n uint64 f_bavail // free blocks for non-root\n uint64 f_files // total file inodes\n uint64 f_ffree // free file inodes\n uint64 f_favail // free file inodes for to non-root\n uint64 f_fsid // file system id\n uint64 f_flag // bit mask of f_flag values\n uint64 f_namemax // maximum filename length\n */\n const biOpt = sftp._biOpt;\n const stats = {\n f_bsize: bufferParser.readUInt64BE(biOpt),\n f_frsize: bufferParser.readUInt64BE(biOpt),\n f_blocks: bufferParser.readUInt64BE(biOpt),\n f_bfree: bufferParser.readUInt64BE(biOpt),\n f_bavail: bufferParser.readUInt64BE(biOpt),\n f_files: bufferParser.readUInt64BE(biOpt),\n f_ffree: bufferParser.readUInt64BE(biOpt),\n f_favail: bufferParser.readUInt64BE(biOpt),\n f_sid: bufferParser.readUInt64BE(biOpt),\n f_flag: bufferParser.readUInt64BE(biOpt),\n f_namemax: bufferParser.readUInt64BE(biOpt),\n };\n if (stats.f_namemax === undefined)\n break;\n if (sftp._debug) {\n sftp._debug(\n 'SFTP: Inbound: Received EXTENDED_REPLY '\n + `(id:${reqID}, ${req.extended})`\n );\n }\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb(undefined, stats);\n return;\n }\n case 'limits@openssh.com': {\n /*\n uint64 max-packet-length\n uint64 max-read-length\n uint64 max-write-length\n uint64 max-open-handles\n */\n const limits = {\n maxPktLen: bufferParser.readUInt64BE(),\n maxReadLen: bufferParser.readUInt64BE(),\n maxWriteLen: bufferParser.readUInt64BE(),\n maxOpenHandles: bufferParser.readUInt64BE(),\n };\n if (limits.maxOpenHandles === undefined)\n break;\n if (sftp._debug) {\n sftp._debug(\n 'SFTP: Inbound: Received EXTENDED_REPLY '\n + `(id:${reqID}, ${req.extended})`\n );\n }\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb(undefined, limits);\n return;\n }\n default:\n // Unknown extended request\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`\n );\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb();\n return;\n }\n } else {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`\n );\n bufferParser.clear();\n return;\n }\n }\n\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed EXTENDED_REPLY packet');\n },\n};\nconst SERVER_HANDLERS = {\n [REQUEST.INIT]: (sftp, payload) => {\n if (sftp._version !== -1)\n return doFatalSFTPError(sftp, 'Duplicate INIT packet');\n\n const extensions = {};\n\n /*\n uint32 version\n \n */\n bufferParser.init(payload, 1);\n let version = bufferParser.readUInt32BE();\n while (bufferParser.avail()) {\n const extName = bufferParser.readString(true);\n const extData = bufferParser.readString(true);\n if (extData === undefined) {\n version = undefined;\n break;\n }\n extensions[extName] = extData;\n }\n bufferParser.clear();\n\n if (version === undefined)\n return doFatalSFTPError(sftp, 'Malformed INIT packet');\n\n if (sftp._debug) {\n const names = Object.keys(extensions);\n if (names.length) {\n sftp._debug(\n `SFTP: Inbound: Received INIT (v${version}, exts:${names})`\n );\n } else {\n sftp._debug(`SFTP: Inbound: Received INIT (v${version})`);\n }\n }\n\n sendOrBuffer(sftp, SERVER_VERSION_BUFFER);\n\n sftp._version = version;\n sftp._extensions = extensions;\n sftp.emit('ready');\n },\n [REQUEST.OPEN]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string filename\n uint32 pflags\n ATTRS attrs\n */\n const filename = bufferParser.readString(true);\n const pflags = bufferParser.readUInt32BE();\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed OPEN packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received OPEN (id:${reqID})`);\n\n if (!sftp.emit('OPEN', reqID, filename, pflags, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.CLOSE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed CLOSE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received CLOSE (id:${reqID})`);\n\n if (!sftp.emit('CLOSE', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READ]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n uint64 offset\n uint32 len\n */\n const handle = bufferParser.readString();\n const offset = bufferParser.readUInt64BE(sftp._biOpt);\n const len = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (len === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed READ packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received READ (id:${reqID})`);\n\n if (!sftp.emit('READ', reqID, handle, offset, len)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.WRITE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n uint64 offset\n string data\n */\n const handle = bufferParser.readString();\n const offset = bufferParser.readUInt64BE(sftp._biOpt);\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed WRITE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received WRITE (id:${reqID})`);\n\n if (!sftp.emit('WRITE', reqID, handle, offset, data)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.LSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed LSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received LSTAT (id:${reqID})`);\n\n if (!sftp.emit('LSTAT', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.FSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed FSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received FSTAT (id:${reqID})`);\n\n if (!sftp.emit('FSTAT', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.SETSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n ATTRS attrs\n */\n const path = bufferParser.readString(true);\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed SETSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received SETSTAT (id:${reqID})`);\n\n if (!sftp.emit('SETSTAT', reqID, path, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.FSETSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n ATTRS attrs\n */\n const handle = bufferParser.readString();\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed FSETSTAT packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received FSETSTAT (id:${reqID})`\n );\n\n if (!sftp.emit('FSETSTAT', reqID, handle, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.OPENDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed OPENDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received OPENDIR (id:${reqID})`);\n\n if (!sftp.emit('OPENDIR', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed READDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received READDIR (id:${reqID})`);\n\n if (!sftp.emit('READDIR', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.REMOVE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed REMOVE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received REMOVE (id:${reqID})`);\n\n if (!sftp.emit('REMOVE', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.MKDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n ATTRS attrs\n */\n const path = bufferParser.readString(true);\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed MKDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received MKDIR (id:${reqID})`);\n\n if (!sftp.emit('MKDIR', reqID, path, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.RMDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed RMDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received RMDIR (id:${reqID})`);\n\n if (!sftp.emit('RMDIR', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.REALPATH]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed REALPATH packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received REALPATH (id:${reqID})`\n );\n\n if (!sftp.emit('REALPATH', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.STAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed STAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received STAT (id:${reqID})`);\n\n if (!sftp.emit('STAT', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.RENAME]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string oldpath\n string newpath\n */\n const oldPath = bufferParser.readString(true);\n const newPath = bufferParser.readString(true);\n bufferParser.clear();\n\n if (newPath === undefined)\n return doFatalSFTPError(sftp, 'Malformed RENAME packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received RENAME (id:${reqID})`);\n\n if (!sftp.emit('RENAME', reqID, oldPath, newPath)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READLINK]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed READLINK packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received READLINK (id:${reqID})`\n );\n\n if (!sftp.emit('READLINK', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.SYMLINK]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string linkpath\n string targetpath\n */\n const linkPath = bufferParser.readString(true);\n const targetPath = bufferParser.readString(true);\n bufferParser.clear();\n\n if (targetPath === undefined)\n return doFatalSFTPError(sftp, 'Malformed SYMLINK packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received SYMLINK (id:${reqID})`);\n\n let handled;\n if (sftp._isOpenSSH) {\n // OpenSSH has linkpath and targetpath positions switched\n handled = sftp.emit('SYMLINK', reqID, targetPath, linkPath);\n } else {\n handled = sftp.emit('SYMLINK', reqID, linkPath, targetPath);\n }\n if (!handled) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.EXTENDED]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string extended-request\n ... any request-specific data ...\n */\n const extName = bufferParser.readString(true);\n if (extName === undefined) {\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed EXTENDED packet');\n }\n\n let extData;\n if (bufferParser.avail())\n extData = bufferParser.readRaw();\n bufferParser.clear();\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED (id:${reqID})`\n );\n\n if (!sftp.emit('EXTENDED', reqID, extName, extData)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n};\n\n// =============================================================================\n// ReadStream/WriteStream-related ==============================================\n// =============================================================================\nconst {\n ERR_INVALID_ARG_TYPE,\n ERR_OUT_OF_RANGE,\n validateNumber\n} = require('./node-fs-compat');\n\nconst kMinPoolSpace = 128;\n\nlet pool;\n// It can happen that we expect to read a large chunk of data, and reserve\n// a large chunk of the pool accordingly, but the read() call only filled\n// a portion of it. If a concurrently executing read() then uses the same pool,\n// the \"reserved\" portion cannot be used, so we allow it to be re-used as a\n// new pool later.\nconst poolFragments = [];\n\nfunction allocNewPool(poolSize) {\n if (poolFragments.length > 0)\n pool = poolFragments.pop();\n else\n pool = Buffer.allocUnsafe(poolSize);\n pool.used = 0;\n}\n\n// Check the `this.start` and `this.end` of stream.\nfunction checkPosition(pos, name) {\n if (!Number.isSafeInteger(pos)) {\n validateNumber(pos, name);\n if (!Number.isInteger(pos))\n throw new ERR_OUT_OF_RANGE(name, 'an integer', pos);\n throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);\n }\n if (pos < 0)\n throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);\n}\n\nfunction roundUpToMultipleOf8(n) {\n return (n + 7) & ~7; // Align to 8 byte boundary.\n}\n\nfunction ReadStream(sftp, path, options) {\n if (options === undefined)\n options = {};\n else if (typeof options === 'string')\n options = { encoding: options };\n else if (options === null || typeof options !== 'object')\n throw new TypeError('\"options\" argument must be a string or an object');\n else\n options = Object.create(options);\n\n // A little bit bigger buffer and water marks by default\n if (options.highWaterMark === undefined)\n options.highWaterMark = 64 * 1024;\n\n // For backwards compat do not emit close on destroy.\n options.emitClose = false;\n options.autoDestroy = false; // Node 14 major change.\n\n ReadableStream.call(this, options);\n\n this.path = path;\n this.flags = options.flags === undefined ? 'r' : options.flags;\n this.mode = options.mode === undefined ? 0o666 : options.mode;\n\n this.start = options.start;\n this.end = options.end;\n this.autoClose = options.autoClose === undefined ? true : options.autoClose;\n this.pos = 0;\n this.bytesRead = 0;\n this.closed = false;\n\n this.handle = options.handle === undefined ? null : options.handle;\n this.sftp = sftp;\n this._opening = false;\n\n if (this.start !== undefined) {\n checkPosition(this.start, 'start');\n\n this.pos = this.start;\n }\n\n if (this.end === undefined) {\n this.end = Infinity;\n } else if (this.end !== Infinity) {\n checkPosition(this.end, 'end');\n\n if (this.start !== undefined && this.start > this.end) {\n throw new ERR_OUT_OF_RANGE(\n 'start',\n `<= \"end\" (here: ${this.end})`,\n this.start\n );\n }\n }\n\n this.on('end', function() {\n if (this.autoClose)\n this.destroy();\n });\n\n if (!Buffer.isBuffer(this.handle))\n this.open();\n}\ninherits(ReadStream, ReadableStream);\n\nReadStream.prototype.open = function() {\n if (this._opening)\n return;\n\n this._opening = true;\n\n this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {\n this._opening = false;\n\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n\n this.handle = handle;\n this.emit('open', handle);\n this.emit('ready');\n // Start the flow of data.\n this.read();\n });\n};\n\nReadStream.prototype._read = function(n) {\n if (!Buffer.isBuffer(this.handle))\n return this.once('open', () => this._read(n));\n\n // XXX: safe to remove this?\n if (this.destroyed)\n return;\n\n if (!pool || pool.length - pool.used < kMinPoolSpace) {\n // Discard the old pool.\n allocNewPool(this.readableHighWaterMark\n || this._readableState.highWaterMark);\n }\n\n // Grab another reference to the pool in the case that while we're\n // in the thread pool another read() finishes up the pool, and\n // allocates a new one.\n const thisPool = pool;\n let toRead = Math.min(pool.length - pool.used, n);\n const start = pool.used;\n\n if (this.end !== undefined)\n toRead = Math.min(this.end - this.pos + 1, toRead);\n\n // Already read everything we were supposed to read!\n // treat as EOF.\n if (toRead <= 0)\n return this.push(null);\n\n // the actual read.\n this.sftp.read(this.handle,\n pool,\n pool.used,\n toRead,\n this.pos,\n (er, bytesRead) => {\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n let b = null;\n\n // Now that we know how much data we have actually read, re-wind the\n // 'used' field if we can, and otherwise allow the remainder of our\n // reservation to be used as a new pool later.\n if (start + toRead === thisPool.used && thisPool === pool) {\n thisPool.used = roundUpToMultipleOf8(thisPool.used + bytesRead - toRead);\n } else {\n // Round down to the next lowest multiple of 8 to ensure the new pool\n // fragment start and end positions are aligned to an 8 byte boundary.\n const alignedEnd = (start + toRead) & ~7;\n const alignedStart = roundUpToMultipleOf8(start + bytesRead);\n if (alignedEnd - alignedStart >= kMinPoolSpace)\n poolFragments.push(thisPool.slice(alignedStart, alignedEnd));\n }\n\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n b = thisPool.slice(start, start + bytesRead);\n }\n\n // Move the pool positions, and internal position for reading.\n this.pos += bytesRead;\n\n this.push(b);\n });\n\n pool.used = roundUpToMultipleOf8(pool.used + toRead);\n};\n\nReadStream.prototype._destroy = function(err, cb) {\n if (this._opening && !Buffer.isBuffer(this.handle)) {\n this.once('open', closeStream.bind(null, this, cb, err));\n return;\n }\n\n closeStream(this, cb, err);\n this.handle = null;\n this._opening = false;\n};\n\nfunction closeStream(stream, cb, err) {\n if (!stream.handle)\n return onclose();\n\n stream.sftp.close(stream.handle, onclose);\n\n function onclose(er) {\n er = er || err;\n cb(er);\n stream.closed = true;\n if (!er)\n stream.emit('close');\n }\n}\n\nReadStream.prototype.close = function(cb) {\n this.destroy(null, cb);\n};\n\nObject.defineProperty(ReadStream.prototype, 'pending', {\n get() {\n return this.handle === null;\n },\n configurable: true\n});\n\n// TODO: add `concurrency` setting to allow more than one in-flight WRITE\n// request to server to improve throughput\nfunction WriteStream(sftp, path, options) {\n if (options === undefined)\n options = {};\n else if (typeof options === 'string')\n options = { encoding: options };\n else if (options === null || typeof options !== 'object')\n throw new TypeError('\"options\" argument must be a string or an object');\n else\n options = Object.create(options);\n\n // For backwards compat do not emit close on destroy.\n options.emitClose = false;\n options.autoDestroy = false; // Node 14 major change.\n\n WritableStream.call(this, options);\n\n this.path = path;\n this.flags = options.flags === undefined ? 'w' : options.flags;\n this.mode = options.mode === undefined ? 0o666 : options.mode;\n\n this.start = options.start;\n this.autoClose = options.autoClose === undefined ? true : options.autoClose;\n this.pos = 0;\n this.bytesWritten = 0;\n this.closed = false;\n\n this.handle = options.handle === undefined ? null : options.handle;\n this.sftp = sftp;\n this._opening = false;\n\n if (this.start !== undefined) {\n checkPosition(this.start, 'start');\n\n this.pos = this.start;\n }\n\n if (options.encoding)\n this.setDefaultEncoding(options.encoding);\n\n // Node v6.x only\n this.on('finish', function() {\n if (this._writableState.finalCalled)\n return;\n if (this.autoClose)\n this.destroy();\n });\n\n if (!Buffer.isBuffer(this.handle))\n this.open();\n}\ninherits(WriteStream, WritableStream);\n\nWriteStream.prototype._final = function(cb) {\n if (this.autoClose)\n this.destroy();\n cb();\n};\n\nWriteStream.prototype.open = function() {\n if (this._opening)\n return;\n\n this._opening = true;\n\n this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {\n this._opening = false;\n\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n\n this.handle = handle;\n\n const tryAgain = (err) => {\n if (err) {\n // Try chmod() for sftp servers that may not support fchmod() for\n // whatever reason\n this.sftp.chmod(this.path, this.mode, (err_) => tryAgain());\n return;\n }\n\n // SFTPv3 requires absolute offsets, no matter the open flag used\n if (this.flags[0] === 'a') {\n const tryStat = (err, st) => {\n if (err) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.sftp.stat(this.path, (err_, st_) => {\n if (err_) {\n this.destroy();\n this.emit('error', err);\n return;\n }\n tryStat(null, st_);\n });\n return;\n }\n\n this.pos = st.size;\n this.emit('open', handle);\n this.emit('ready');\n };\n\n this.sftp.fstat(handle, tryStat);\n return;\n }\n\n this.emit('open', handle);\n this.emit('ready');\n };\n\n this.sftp.fchmod(handle, this.mode, tryAgain);\n });\n};\n\nWriteStream.prototype._write = function(data, encoding, cb) {\n if (!Buffer.isBuffer(data)) {\n const err = new ERR_INVALID_ARG_TYPE('data', 'Buffer', data);\n return this.emit('error', err);\n }\n\n if (!Buffer.isBuffer(this.handle)) {\n return this.once('open', function() {\n this._write(data, encoding, cb);\n });\n }\n\n this.sftp.write(this.handle,\n data,\n 0,\n data.length,\n this.pos,\n (er, bytes) => {\n if (er) {\n if (this.autoClose)\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n cb();\n });\n\n this.pos += data.length;\n};\n\nWriteStream.prototype._writev = function(data, cb) {\n if (!Buffer.isBuffer(this.handle)) {\n return this.once('open', function() {\n this._writev(data, cb);\n });\n }\n\n const sftp = this.sftp;\n const handle = this.handle;\n let writesLeft = data.length;\n\n const onwrite = (er, bytes) => {\n if (er) {\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n if (--writesLeft === 0)\n cb();\n };\n\n // TODO: try to combine chunks to reduce number of requests to the server?\n for (let i = 0; i < data.length; ++i) {\n const chunk = data[i].chunk;\n\n sftp.write(handle, chunk, 0, chunk.length, this.pos, onwrite);\n this.pos += chunk.length;\n }\n};\n\nif (typeof WritableStream.prototype.destroy !== 'function')\n WriteStream.prototype.destroy = ReadStream.prototype.destroy;\n\nWriteStream.prototype._destroy = ReadStream.prototype._destroy;\nWriteStream.prototype.close = function(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on('close', cb);\n }\n\n // If we are not autoClosing, we should call\n // destroy on 'finish'.\n if (!this.autoClose)\n this.on('finish', this.destroy.bind(this));\n\n this.end();\n};\n\n// There is no shutdown() for files.\nWriteStream.prototype.destroySoon = WriteStream.prototype.end;\n\nObject.defineProperty(WriteStream.prototype, 'pending', {\n get() {\n return this.handle === null;\n },\n configurable: true\n});\n// =============================================================================\n\nmodule.exports = {\n flagsToString,\n OPEN_MODE,\n SFTP,\n Stats,\n STATUS_CODE,\n stringToFlags,\n};\n","'use strict';\n\nconst crypto = require('crypto');\n\nlet cpuInfo;\ntry {\n cpuInfo = require('cpu-features')();\n} catch {}\n\nconst { bindingAvailable } = require('./crypto.js');\n\nconst eddsaSupported = (() => {\n if (typeof crypto.sign === 'function'\n && typeof crypto.verify === 'function') {\n const key =\n '-----BEGIN PRIVATE KEY-----\\r\\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD'\n + '/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\\r\\n-----END PRIVATE KEY-----';\n const data = Buffer.from('a');\n let sig;\n let verified;\n try {\n sig = crypto.sign(null, data, key);\n verified = crypto.verify(null, data, key, sig);\n } catch {}\n return (Buffer.isBuffer(sig) && sig.length === 64 && verified === true);\n }\n\n return false;\n})();\n\nconst curve25519Supported = (typeof crypto.diffieHellman === 'function'\n && typeof crypto.generateKeyPairSync === 'function'\n && typeof crypto.createPublicKey === 'function');\n\nconst DEFAULT_KEX = [\n // https://tools.ietf.org/html/rfc5656#section-10.1\n 'ecdh-sha2-nistp256',\n 'ecdh-sha2-nistp384',\n 'ecdh-sha2-nistp521',\n\n // https://tools.ietf.org/html/rfc4419#section-4\n 'diffie-hellman-group-exchange-sha256',\n\n // https://tools.ietf.org/html/rfc8268\n 'diffie-hellman-group14-sha256',\n 'diffie-hellman-group15-sha512',\n 'diffie-hellman-group16-sha512',\n 'diffie-hellman-group17-sha512',\n 'diffie-hellman-group18-sha512',\n];\nif (curve25519Supported) {\n DEFAULT_KEX.unshift('curve25519-sha256');\n DEFAULT_KEX.unshift('curve25519-sha256@libssh.org');\n}\nconst SUPPORTED_KEX = DEFAULT_KEX.concat([\n // https://tools.ietf.org/html/rfc4419#section-4\n 'diffie-hellman-group-exchange-sha1',\n\n 'diffie-hellman-group14-sha1', // REQUIRED\n 'diffie-hellman-group1-sha1', // REQUIRED\n]);\n\n\nconst DEFAULT_SERVER_HOST_KEY = [\n 'ecdsa-sha2-nistp256',\n 'ecdsa-sha2-nistp384',\n 'ecdsa-sha2-nistp521',\n 'rsa-sha2-512', // RFC 8332\n 'rsa-sha2-256', // RFC 8332\n 'ssh-rsa',\n];\nif (eddsaSupported)\n DEFAULT_SERVER_HOST_KEY.unshift('ssh-ed25519');\nconst SUPPORTED_SERVER_HOST_KEY = DEFAULT_SERVER_HOST_KEY.concat([\n 'ssh-dss',\n]);\n\n\nconst DEFAULT_CIPHER = [\n // http://tools.ietf.org/html/rfc5647\n 'aes128-gcm@openssh.com',\n 'aes256-gcm@openssh.com',\n\n // http://tools.ietf.org/html/rfc4344#section-4\n 'aes128-ctr',\n 'aes192-ctr',\n 'aes256-ctr',\n];\nif (cpuInfo && cpuInfo.flags && !cpuInfo.flags.aes) {\n // We know for sure the CPU does not support AES acceleration\n if (bindingAvailable)\n DEFAULT_CIPHER.unshift('chacha20-poly1305@openssh.com');\n else\n DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');\n} else if (bindingAvailable && cpuInfo && cpuInfo.arch === 'x86') {\n // Places chacha20-poly1305 immediately after GCM ciphers since GCM ciphers\n // seem to outperform it on x86, but it seems to be faster than CTR ciphers\n DEFAULT_CIPHER.splice(4, 0, 'chacha20-poly1305@openssh.com');\n} else {\n DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');\n}\nconst SUPPORTED_CIPHER = DEFAULT_CIPHER.concat([\n 'aes256-cbc',\n 'aes192-cbc',\n 'aes128-cbc',\n 'blowfish-cbc',\n '3des-cbc',\n\n // http://tools.ietf.org/html/rfc4345#section-4:\n 'arcfour256',\n 'arcfour128',\n\n 'cast128-cbc',\n 'arcfour',\n]);\n\n\nconst DEFAULT_MAC = [\n 'hmac-sha2-256-etm@openssh.com',\n 'hmac-sha2-512-etm@openssh.com',\n 'hmac-sha1-etm@openssh.com',\n 'hmac-sha2-256',\n 'hmac-sha2-512',\n 'hmac-sha1',\n];\nconst SUPPORTED_MAC = DEFAULT_MAC.concat([\n 'hmac-md5',\n 'hmac-sha2-256-96', // first 96 bits of HMAC-SHA256\n 'hmac-sha2-512-96', // first 96 bits of HMAC-SHA512\n 'hmac-ripemd160',\n 'hmac-sha1-96', // first 96 bits of HMAC-SHA1\n 'hmac-md5-96', // first 96 bits of HMAC-MD5\n]);\n\nconst DEFAULT_COMPRESSION = [\n 'none',\n 'zlib@openssh.com', // ZLIB (LZ77) compression, except\n // compression/decompression does not start until after\n // successful user authentication\n 'zlib', // ZLIB (LZ77) compression\n];\nconst SUPPORTED_COMPRESSION = DEFAULT_COMPRESSION.concat([\n]);\n\n\nconst COMPAT = {\n BAD_DHGEX: 1 << 0,\n OLD_EXIT: 1 << 1,\n DYN_RPORT_BUG: 1 << 2,\n BUG_DHGEX_LARGE: 1 << 3,\n};\n\nmodule.exports = {\n MESSAGE: {\n // Transport layer protocol -- generic (1-19)\n DISCONNECT: 1,\n IGNORE: 2,\n UNIMPLEMENTED: 3,\n DEBUG: 4,\n SERVICE_REQUEST: 5,\n SERVICE_ACCEPT: 6,\n\n // Transport layer protocol -- algorithm negotiation (20-29)\n KEXINIT: 20,\n NEWKEYS: 21,\n\n // Transport layer protocol -- key exchange method-specific (30-49)\n KEXDH_INIT: 30,\n KEXDH_REPLY: 31,\n\n KEXDH_GEX_GROUP: 31,\n KEXDH_GEX_INIT: 32,\n KEXDH_GEX_REPLY: 33,\n KEXDH_GEX_REQUEST: 34,\n\n KEXECDH_INIT: 30,\n KEXECDH_REPLY: 31,\n\n // User auth protocol -- generic (50-59)\n USERAUTH_REQUEST: 50,\n USERAUTH_FAILURE: 51,\n USERAUTH_SUCCESS: 52,\n USERAUTH_BANNER: 53,\n\n // User auth protocol -- user auth method-specific (60-79)\n USERAUTH_PASSWD_CHANGEREQ: 60,\n\n USERAUTH_PK_OK: 60,\n\n USERAUTH_INFO_REQUEST: 60,\n USERAUTH_INFO_RESPONSE: 61,\n\n // Connection protocol -- generic (80-89)\n GLOBAL_REQUEST: 80,\n REQUEST_SUCCESS: 81,\n REQUEST_FAILURE: 82,\n\n // Connection protocol -- channel-related (90-127)\n CHANNEL_OPEN: 90,\n CHANNEL_OPEN_CONFIRMATION: 91,\n CHANNEL_OPEN_FAILURE: 92,\n CHANNEL_WINDOW_ADJUST: 93,\n CHANNEL_DATA: 94,\n CHANNEL_EXTENDED_DATA: 95,\n CHANNEL_EOF: 96,\n CHANNEL_CLOSE: 97,\n CHANNEL_REQUEST: 98,\n CHANNEL_SUCCESS: 99,\n CHANNEL_FAILURE: 100\n\n // Reserved for client protocols (128-191)\n\n // Local extensions (192-155)\n },\n DISCONNECT_REASON: {\n HOST_NOT_ALLOWED_TO_CONNECT: 1,\n PROTOCOL_ERROR: 2,\n KEY_EXCHANGE_FAILED: 3,\n RESERVED: 4,\n MAC_ERROR: 5,\n COMPRESSION_ERROR: 6,\n SERVICE_NOT_AVAILABLE: 7,\n PROTOCOL_VERSION_NOT_SUPPORTED: 8,\n HOST_KEY_NOT_VERIFIABLE: 9,\n CONNECTION_LOST: 10,\n BY_APPLICATION: 11,\n TOO_MANY_CONNECTIONS: 12,\n AUTH_CANCELED_BY_USER: 13,\n NO_MORE_AUTH_METHODS_AVAILABLE: 14,\n ILLEGAL_USER_NAME: 15,\n },\n DISCONNECT_REASON_STR: undefined,\n CHANNEL_OPEN_FAILURE: {\n ADMINISTRATIVELY_PROHIBITED: 1,\n CONNECT_FAILED: 2,\n UNKNOWN_CHANNEL_TYPE: 3,\n RESOURCE_SHORTAGE: 4\n },\n TERMINAL_MODE: {\n TTY_OP_END: 0, // Indicates end of options.\n VINTR: 1, // Interrupt character; 255 if none. Similarly for the\n // other characters. Not all of these characters are\n // supported on all systems.\n VQUIT: 2, // The quit character (sends SIGQUIT signal on POSIX\n // systems).\n VERASE: 3, // Erase the character to left of the cursor.\n VKILL: 4, // Kill the current input line.\n VEOF: 5, // End-of-file character (sends EOF from the\n // terminal).\n VEOL: 6, // End-of-line character in addition to carriage\n // return and/or linefeed.\n VEOL2: 7, // Additional end-of-line character.\n VSTART: 8, // Continues paused output (normally control-Q).\n VSTOP: 9, // Pauses output (normally control-S).\n VSUSP: 10, // Suspends the current program.\n VDSUSP: 11, // Another suspend character.\n VREPRINT: 12, // Reprints the current input line.\n VWERASE: 13, // Erases a word left of cursor.\n VLNEXT: 14, // Enter the next character typed literally, even if\n // it is a special character\n VFLUSH: 15, // Character to flush output.\n VSWTCH: 16, // Switch to a different shell layer.\n VSTATUS: 17, // Prints system status line (load, command, pid,\n // etc).\n VDISCARD: 18, // Toggles the flushing of terminal output.\n IGNPAR: 30, // The ignore parity flag. The parameter SHOULD be 0\n // if this flag is FALSE, and 1 if it is TRUE.\n PARMRK: 31, // Mark parity and framing errors.\n INPCK: 32, // Enable checking of parity errors.\n ISTRIP: 33, // Strip 8th bit off characters.\n INLCR: 34, // Map NL into CR on input.\n IGNCR: 35, // Ignore CR on input.\n ICRNL: 36, // Map CR to NL on input.\n IUCLC: 37, // Translate uppercase characters to lowercase.\n IXON: 38, // Enable output flow control.\n IXANY: 39, // Any char will restart after stop.\n IXOFF: 40, // Enable input flow control.\n IMAXBEL: 41, // Ring bell on input queue full.\n ISIG: 50, // Enable signals INTR, QUIT, [D]SUSP.\n ICANON: 51, // Canonicalize input lines.\n XCASE: 52, // Enable input and output of uppercase characters by\n // preceding their lowercase equivalents with \"\\\".\n ECHO: 53, // Enable echoing.\n ECHOE: 54, // Visually erase chars.\n ECHOK: 55, // Kill character discards current line.\n ECHONL: 56, // Echo NL even if ECHO is off.\n NOFLSH: 57, // Don't flush after interrupt.\n TOSTOP: 58, // Stop background jobs from output.\n IEXTEN: 59, // Enable extensions.\n ECHOCTL: 60, // Echo control characters as ^(Char).\n ECHOKE: 61, // Visual erase for line kill.\n PENDIN: 62, // Retype pending input.\n OPOST: 70, // Enable output processing.\n OLCUC: 71, // Convert lowercase to uppercase.\n ONLCR: 72, // Map NL to CR-NL.\n OCRNL: 73, // Translate carriage return to newline (output).\n ONOCR: 74, // Translate newline to carriage return-newline\n // (output).\n ONLRET: 75, // Newline performs a carriage return (output).\n CS7: 90, // 7 bit mode.\n CS8: 91, // 8 bit mode.\n PARENB: 92, // Parity enable.\n PARODD: 93, // Odd parity, else even.\n TTY_OP_ISPEED: 128, // Specifies the input baud rate in bits per second.\n TTY_OP_OSPEED: 129, // Specifies the output baud rate in bits per second.\n },\n CHANNEL_EXTENDED_DATATYPE: {\n STDERR: 1,\n },\n\n SIGNALS: [\n 'ABRT', 'ALRM', 'FPE', 'HUP', 'ILL', 'INT', 'QUIT', 'SEGV', 'TERM', 'USR1',\n 'USR2', 'KILL', 'PIPE'\n ].reduce((cur, val) => ({ ...cur, [val]: 1 }), {}),\n\n COMPAT,\n COMPAT_CHECKS: [\n [ 'Cisco-1.25', COMPAT.BAD_DHGEX ],\n [ /^Cisco-1\\./, COMPAT.BUG_DHGEX_LARGE ],\n [ /^[0-9.]+$/, COMPAT.OLD_EXIT ], // old SSH.com implementations\n [ /^OpenSSH_5\\.\\d+/, COMPAT.DYN_RPORT_BUG ],\n ],\n\n // KEX proposal-related\n DEFAULT_KEX,\n SUPPORTED_KEX,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER,\n DEFAULT_MAC,\n SUPPORTED_MAC,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION,\n\n curve25519Supported,\n eddsaSupported,\n};\n\nmodule.exports.DISCONNECT_REASON_BY_VALUE =\n Array.from(Object.entries(module.exports.DISCONNECT_REASON))\n .reduce((obj, [key, value]) => ({ ...obj, [value]: key }), {});\n","// TODO:\n// * make max packet size configurable\n// * if decompression is enabled, use `._packet` in decipher instances as\n// input to (sync) zlib inflater with appropriate offset and length to\n// avoid an additional copy of payload data before inflation\n// * factor decompression status into packet length checks\n'use strict';\n\nconst {\n createCipheriv, createDecipheriv, createHmac, randomFillSync, timingSafeEqual\n} = require('crypto');\n\nconst { readUInt32BE, writeUInt32BE } = require('./utils.js');\n\nconst FastBuffer = Buffer[Symbol.species];\nconst MAX_SEQNO = 2 ** 32 - 1;\nconst EMPTY_BUFFER = Buffer.alloc(0);\nconst BUF_INT = Buffer.alloc(4);\nconst DISCARD_CACHE = new Map();\nconst MAX_PACKET_SIZE = 35000;\n\nlet binding;\nlet AESGCMCipher;\nlet ChaChaPolyCipher;\nlet GenericCipher;\nlet AESGCMDecipher;\nlet ChaChaPolyDecipher;\nlet GenericDecipher;\ntry {\n binding = require('./crypto/build/Release/sshcrypto.node');\n ({ AESGCMCipher, ChaChaPolyCipher, GenericCipher,\n AESGCMDecipher, ChaChaPolyDecipher, GenericDecipher } = binding);\n} catch {}\n\nconst CIPHER_STREAM = 1 << 0;\nconst CIPHER_INFO = (() => {\n function info(sslName, blockLen, keyLen, ivLen, authLen, discardLen, flags) {\n return {\n sslName,\n blockLen,\n keyLen,\n ivLen: (ivLen !== 0 || (flags & CIPHER_STREAM)\n ? ivLen\n : blockLen),\n authLen,\n discardLen,\n stream: !!(flags & CIPHER_STREAM),\n };\n }\n\n return {\n 'chacha20-poly1305@openssh.com':\n info('chacha20', 8, 64, 0, 16, 0, CIPHER_STREAM),\n\n 'aes128-gcm': info('aes-128-gcm', 16, 16, 12, 16, 0, CIPHER_STREAM),\n 'aes256-gcm': info('aes-256-gcm', 16, 32, 12, 16, 0, CIPHER_STREAM),\n 'aes128-gcm@openssh.com':\n info('aes-128-gcm', 16, 16, 12, 16, 0, CIPHER_STREAM),\n 'aes256-gcm@openssh.com':\n info('aes-256-gcm', 16, 32, 12, 16, 0, CIPHER_STREAM),\n\n 'aes128-cbc': info('aes-128-cbc', 16, 16, 0, 0, 0, 0),\n 'aes192-cbc': info('aes-192-cbc', 16, 24, 0, 0, 0, 0),\n 'aes256-cbc': info('aes-256-cbc', 16, 32, 0, 0, 0, 0),\n 'rijndael-cbc@lysator.liu.se': info('aes-256-cbc', 16, 32, 0, 0, 0, 0),\n '3des-cbc': info('des-ede3-cbc', 8, 24, 0, 0, 0, 0),\n 'blowfish-cbc': info('bf-cbc', 8, 16, 0, 0, 0, 0),\n 'idea-cbc': info('idea-cbc', 8, 16, 0, 0, 0, 0),\n 'cast128-cbc': info('cast-cbc', 8, 16, 0, 0, 0, 0),\n\n 'aes128-ctr': info('aes-128-ctr', 16, 16, 16, 0, 0, CIPHER_STREAM),\n 'aes192-ctr': info('aes-192-ctr', 16, 24, 16, 0, 0, CIPHER_STREAM),\n 'aes256-ctr': info('aes-256-ctr', 16, 32, 16, 0, 0, CIPHER_STREAM),\n '3des-ctr': info('des-ede3', 8, 24, 8, 0, 0, CIPHER_STREAM),\n 'blowfish-ctr': info('bf-ecb', 8, 16, 8, 0, 0, CIPHER_STREAM),\n 'cast128-ctr': info('cast5-ecb', 8, 16, 8, 0, 0, CIPHER_STREAM),\n\n /* The \"arcfour128\" algorithm is the RC4 cipher, as described in\n [SCHNEIER], using a 128-bit key. The first 1536 bytes of keystream\n generated by the cipher MUST be discarded, and the first byte of the\n first encrypted packet MUST be encrypted using the 1537th byte of\n keystream.\n\n -- http://tools.ietf.org/html/rfc4345#section-4 */\n 'arcfour': info('rc4', 8, 16, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour128': info('rc4', 8, 16, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour256': info('rc4', 8, 32, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour512': info('rc4', 8, 64, 0, 0, 1536, CIPHER_STREAM),\n };\n})();\n\nconst MAC_INFO = (() => {\n function info(sslName, len, actualLen, isETM) {\n return {\n sslName,\n len,\n actualLen,\n isETM,\n };\n }\n\n return {\n 'hmac-md5': info('md5', 16, 16, false),\n 'hmac-md5-96': info('md5', 16, 12, false),\n 'hmac-ripemd160': info('ripemd160', 20, 20, false),\n 'hmac-sha1': info('sha1', 20, 20, false),\n 'hmac-sha1-etm@openssh.com': info('sha1', 20, 20, true),\n 'hmac-sha1-96': info('sha1', 20, 12, false),\n 'hmac-sha2-256': info('sha256', 32, 32, false),\n 'hmac-sha2-256-etm@openssh.com': info('sha256', 32, 32, true),\n 'hmac-sha2-256-96': info('sha256', 32, 12, false),\n 'hmac-sha2-512': info('sha512', 64, 64, false),\n 'hmac-sha2-512-etm@openssh.com': info('sha512', 64, 64, true),\n 'hmac-sha2-512-96': info('sha512', 64, 12, false),\n };\n})();\n\n\n// Should only_be used during the initial handshake\nclass NullCipher {\n constructor(seqno, onWrite) {\n this.outSeqno = seqno;\n this._onWrite = onWrite;\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - (pktLen & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nconst POLY1305_ZEROS = Buffer.alloc(32);\nconst POLY1305_OUT_COMPUTE = Buffer.alloc(16);\nlet POLY1305_WASM_MODULE;\nlet POLY1305_RESULT_MALLOC;\nlet poly1305_auth;\nclass ChaChaPolyCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encKeyMain = enc.cipherKey.slice(0, 32);\n this._encKeyPktLen = enc.cipherKey.slice(32);\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - ((pktLen - 4) & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Generate Poly1305 key\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.outSeqno, 12);\n const polyKey =\n createCipheriv('chacha20', this._encKeyMain, POLY1305_OUT_COMPUTE)\n .update(POLY1305_ZEROS);\n\n // Encrypt packet length\n const pktLenEnc =\n createCipheriv('chacha20', this._encKeyPktLen, POLY1305_OUT_COMPUTE)\n .update(packet.slice(0, 4));\n this._onWrite(pktLenEnc);\n\n // Encrypt rest of packet\n POLY1305_OUT_COMPUTE[0] = 1; // Set counter to 1 (little endian)\n const payloadEnc =\n createCipheriv('chacha20', this._encKeyMain, POLY1305_OUT_COMPUTE)\n .update(packet.slice(4));\n this._onWrite(payloadEnc);\n\n // Calculate Poly1305 MAC\n poly1305_auth(POLY1305_RESULT_MALLOC,\n pktLenEnc,\n pktLenEnc.length,\n payloadEnc,\n payloadEnc.length,\n polyKey);\n const mac = Buffer.allocUnsafe(16);\n mac.set(\n new Uint8Array(POLY1305_WASM_MODULE.HEAPU8.buffer,\n POLY1305_RESULT_MALLOC,\n 16),\n 0\n );\n this._onWrite(mac);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass ChaChaPolyCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._instance = new ChaChaPolyCipher(enc.cipherKey);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - ((pktLen - 4) & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + 16/* MAC */);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet, this.outSeqno);\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass AESGCMCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encSSLName = enc.cipherInfo.sslName;\n this._encKey = enc.cipherKey;\n this._encIV = enc.cipherIV;\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 16 - ((pktLen - 4) & (16 - 1));\n if (padLen < 4)\n padLen += 16;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n const cipher = createCipheriv(this._encSSLName, this._encKey, this._encIV);\n cipher.setAutoPadding(false);\n\n const lenData = packet.slice(0, 4);\n cipher.setAAD(lenData);\n this._onWrite(lenData);\n\n // Encrypt pad length, payload, and padding\n const encrypted = cipher.update(packet.slice(4));\n this._onWrite(encrypted);\n const final = cipher.final();\n // XXX: final.length === 0 always?\n if (final.length)\n this._onWrite(final);\n\n // Generate MAC\n const tag = cipher.getAuthTag();\n this._onWrite(tag);\n\n // Increment counter in IV by 1 for next packet\n ivIncrement(this._encIV);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass AESGCMCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._instance = new AESGCMCipher(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 16 - ((pktLen - 4) & (16 - 1));\n if (padLen < 4)\n padLen += 16;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + 16/* authTag */);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet);\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass GenericCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encBlockLen = enc.cipherInfo.blockLen;\n this._cipherInstance = createCipheriv(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV);\n this._macSSLName = enc.macInfo.sslName;\n this._macKey = enc.macKey;\n this._macActualLen = enc.macInfo.actualLen;\n this._macETM = enc.macInfo.isETM;\n this._aadLen = (this._macETM ? 4 : 0);\n this._dead = false;\n\n const discardLen = enc.cipherInfo.discardLen;\n if (discardLen) {\n let discard = DISCARD_CACHE.get(discardLen);\n if (discard === undefined) {\n discard = Buffer.alloc(discardLen);\n DISCARD_CACHE.set(discardLen, discard);\n }\n this._cipherInstance.update(discard);\n }\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n const blockLen = this._encBlockLen;\n\n let pktLen = 4 + 1 + payloadLen;\n let padLen = blockLen - ((pktLen - this._aadLen) & (blockLen - 1));\n if (padLen < 4)\n padLen += blockLen;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n let mac;\n if (this._macETM) {\n // Encrypt pad length, payload, and padding\n const lenBytes = new Uint8Array(packet.buffer, packet.byteOffset, 4);\n const encrypted = this._cipherInstance.update(\n new Uint8Array(packet.buffer,\n packet.byteOffset + 4,\n packet.length - 4)\n );\n\n this._onWrite(lenBytes);\n this._onWrite(encrypted);\n\n // TODO: look into storing seqno as 4-byte buffer and incrementing like we\n // do for AES-GCM IVs to avoid having to (re)write all 4 bytes every time\n mac = createHmac(this._macSSLName, this._macKey);\n writeUInt32BE(BUF_INT, this.outSeqno, 0);\n mac.update(BUF_INT);\n mac.update(lenBytes);\n mac.update(encrypted);\n } else {\n // Encrypt length field, pad length, payload, and padding\n const encrypted = this._cipherInstance.update(packet);\n this._onWrite(encrypted);\n\n // TODO: look into storing seqno as 4-byte buffer and incrementing like we\n // do for AES-GCM IVs to avoid having to (re)write all 4 bytes every time\n mac = createHmac(this._macSSLName, this._macKey);\n writeUInt32BE(BUF_INT, this.outSeqno, 0);\n mac.update(BUF_INT);\n mac.update(packet);\n }\n\n let digest = mac.digest();\n if (digest.length > this._macActualLen)\n digest = digest.slice(0, this._macActualLen);\n this._onWrite(digest);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass GenericCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encBlockLen = enc.cipherInfo.blockLen;\n this._macLen = enc.macInfo.len;\n this._macActualLen = enc.macInfo.actualLen;\n this._aadLen = (enc.macInfo.isETM ? 4 : 0);\n this._instance = new GenericCipher(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV,\n enc.macInfo.sslName,\n enc.macKey,\n enc.macInfo.isETM);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n const blockLen = this._encBlockLen;\n\n let pktLen = 4 + 1 + payloadLen;\n let padLen = blockLen - ((pktLen - this._aadLen) & (blockLen - 1));\n if (padLen < 4)\n padLen += blockLen;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + this._macLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet, this.outSeqno);\n\n if (this._macActualLen < this._macLen) {\n packet = new FastBuffer(packet.buffer,\n packet.byteOffset,\n (packet.length\n - (this._macLen - this._macActualLen)));\n }\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass NullDecipher {\n constructor(seqno, onPayload) {\n this.inSeqno = seqno;\n this._onPayload = onPayload;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n while (p < dataLen) {\n // Read packet length\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n\n if (this._lenBytes < 4)\n return;\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (4 + this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._packetPos < this._len) {\n const nb = Math.min(this._len - this._packetPos, dataLen - p);\n let chunk;\n if (p !== 0 || nb !== dataLen)\n chunk = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n chunk = data;\n if (nb === this._len) {\n this._packet = chunk;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(chunk, this._packetPos);\n }\n p += nb;\n this._packetPos += nb;\n if (this._packetPos < this._len)\n return;\n }\n\n const payload = (!this._packet\n ? EMPTY_BUFFER\n : new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length\n - this._packet[0] - 1));\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass ChaChaPolyDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decKeyMain = dec.decipherKey.slice(0, 32);\n this._decKeyPktLen = dec.decipherKey.slice(32);\n this._len = 0;\n this._lenBuf = Buffer.alloc(4);\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(16);\n this._calcMac = Buffer.allocUnsafe(16);\n this._macPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length\n if (this._lenPos < 4) {\n let nb = Math.min(4 - this._lenPos, dataLen - p);\n while (nb--)\n this._lenBuf[this._lenPos++] = data[p++];\n if (this._lenPos < 4)\n return;\n\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.inSeqno, 12);\n\n const decLenBytes =\n createDecipheriv('chacha20', this._decKeyPktLen, POLY1305_OUT_COMPUTE)\n .update(this._lenBuf);\n this._len = readUInt32BE(decLenBytes, 0);\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read Poly1305 MAC\n {\n const nb = Math.min(16 - this._macPos, dataLen - p);\n // TODO: avoid copying if entire MAC is in current chunk\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < 16)\n return;\n }\n\n // Generate Poly1305 key\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.inSeqno, 12);\n const polyKey =\n createCipheriv('chacha20', this._decKeyMain, POLY1305_OUT_COMPUTE)\n .update(POLY1305_ZEROS);\n\n // Calculate and compare Poly1305 MACs\n poly1305_auth(POLY1305_RESULT_MALLOC,\n this._lenBuf,\n 4,\n this._packet,\n this._packet.length,\n polyKey);\n\n this._calcMac.set(\n new Uint8Array(POLY1305_WASM_MODULE.HEAPU8.buffer,\n POLY1305_RESULT_MALLOC,\n 16),\n 0\n );\n if (!timingSafeEqual(this._calcMac, this._mac))\n throw new Error('Invalid MAC');\n\n // Decrypt packet\n POLY1305_OUT_COMPUTE[0] = 1; // Set counter to 1 (little endian)\n const packet =\n createDecipheriv('chacha20', this._decKeyMain, POLY1305_OUT_COMPUTE)\n .update(this._packet);\n\n const payload = new FastBuffer(packet.buffer,\n packet.byteOffset + 1,\n packet.length - packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass ChaChaPolyDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new ChaChaPolyDecipher(dec.decipherKey);\n this._len = 0;\n this._lenBuf = Buffer.alloc(4);\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(16);\n this._macPos = 0;\n }\n free() {\n this._instance.free();\n }\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length\n if (this._lenPos < 4) {\n let nb = Math.min(4 - this._lenPos, dataLen - p);\n while (nb--)\n this._lenBuf[this._lenPos++] = data[p++];\n if (this._lenPos < 4)\n return;\n\n this._len = this._instance.decryptLen(this._lenBuf, this.inSeqno);\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read Poly1305 MAC\n {\n const nb = Math.min(16 - this._macPos, dataLen - p);\n // TODO: avoid copying if entire MAC is in current chunk\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < 16)\n return;\n }\n\n this._instance.decrypt(this._packet, this._mac, this.inSeqno);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass AESGCMDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decipherInstance = null;\n this._decipherSSLName = dec.decipherInfo.sslName;\n this._decipherKey = dec.decipherKey;\n this._decipherIV = dec.decipherIV;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._tag = Buffer.allocUnsafe(16);\n this._tagPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length (unencrypted, but AAD)\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n if (this._lenBytes < 4)\n return;\n\n if ((this._len + 20) > MAX_PACKET_SIZE\n || this._len < 16\n || (this._len & 15) !== 0) {\n throw new Error('Bad packet length');\n }\n\n this._decipherInstance = createDecipheriv(\n this._decipherSSLName,\n this._decipherKey,\n this._decipherIV\n );\n this._decipherInstance.setAutoPadding(false);\n this._decipherInstance.setAAD(intToBytes(this._len));\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let decrypted;\n if (p !== 0 || nb !== dataLen) {\n decrypted = this._decipherInstance.update(\n new Uint8Array(data.buffer, data.byteOffset + p, nb)\n );\n } else {\n decrypted = this._decipherInstance.update(data);\n }\n if (decrypted.length) {\n if (nb === this._len) {\n this._packet = decrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(decrypted, this._packetPos);\n }\n this._packetPos += decrypted.length;\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read authentication tag\n {\n const nb = Math.min(16 - this._tagPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._tag.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._tagPos\n );\n } else {\n this._tag.set(data, this._tagPos);\n }\n p += nb;\n this._tagPos += nb;\n if (this._tagPos < 16)\n return;\n }\n\n {\n // Verify authentication tag\n this._decipherInstance.setAuthTag(this._tag);\n\n const decrypted = this._decipherInstance.final();\n\n // XXX: this should never output any data since stream ciphers always\n // return data from .update() and block ciphers must end on a multiple\n // of the block length, which would have caused an exception to be\n // thrown if the total input was not...\n if (decrypted.length) {\n if (this._packet)\n this._packet.set(decrypted, this._packetPos);\n else\n this._packet = decrypted;\n }\n }\n\n const payload = (!this._packet\n ? EMPTY_BUFFER\n : new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length\n - this._packet[0] - 1));\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n ivIncrement(this._decipherIV);\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._tagPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass AESGCMDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new AESGCMDecipher(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV);\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._pktLen = 0;\n this._tag = Buffer.allocUnsafe(16);\n this._tagPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length (unencrypted, but AAD)\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n if (this._lenBytes < 4)\n return;\n\n if ((this._len + 20) > MAX_PACKET_SIZE\n || this._len < 16\n || (this._len & 15) !== 0) {\n throw new Error(`Bad packet length: ${this._len}`);\n }\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read authentication tag\n {\n const nb = Math.min(16 - this._tagPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._tag.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._tagPos\n );\n } else {\n this._tag.set(data, this._tagPos);\n }\n p += nb;\n this._tagPos += nb;\n if (this._tagPos < 16)\n return;\n }\n\n this._instance.decrypt(this._packet, this._len, this._tag);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._pktLen = 0;\n this._tagPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\n// TODO: test incremental .update()s vs. copying to _packet and doing a single\n// .update() after entire packet read -- a single .update() would allow\n// verifying MAC before decrypting for ETM MACs\nclass GenericDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decipherInstance = createDecipheriv(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV);\n this._decipherInstance.setAutoPadding(false);\n this._block = Buffer.allocUnsafe(\n dec.macInfo.isETM ? 4 : dec.decipherInfo.blockLen\n );\n this._blockSize = dec.decipherInfo.blockLen;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(dec.macInfo.actualLen);\n this._macPos = 0;\n this._macSSLName = dec.macInfo.sslName;\n this._macKey = dec.macKey;\n this._macActualLen = dec.macInfo.actualLen;\n this._macETM = dec.macInfo.isETM;\n this._macInstance = null;\n\n const discardLen = dec.decipherInfo.discardLen;\n if (discardLen) {\n let discard = DISCARD_CACHE.get(discardLen);\n if (discard === undefined) {\n discard = Buffer.alloc(discardLen);\n DISCARD_CACHE.set(discardLen, discard);\n }\n this._decipherInstance.update(discard);\n }\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read first encrypted block\n if (this._blockPos < this._block.length) {\n const nb = Math.min(this._block.length - this._blockPos, dataLen - p);\n if (p !== 0 || nb !== dataLen || nb < data.length) {\n this._block.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._blockPos\n );\n } else {\n this._block.set(data, this._blockPos);\n }\n\n p += nb;\n this._blockPos += nb;\n if (this._blockPos < this._block.length)\n return;\n\n let decrypted;\n let need;\n if (this._macETM) {\n this._len = need = readUInt32BE(this._block, 0);\n } else {\n // Decrypt first block to get packet length\n decrypted = this._decipherInstance.update(this._block);\n this._len = readUInt32BE(decrypted, 0);\n need = 4 + this._len - this._blockSize;\n }\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 5\n || (need & (this._blockSize - 1)) !== 0) {\n throw new Error('Bad packet length');\n }\n\n // Create MAC up front to calculate in parallel with decryption\n this._macInstance = createHmac(this._macSSLName, this._macKey);\n\n writeUInt32BE(BUF_INT, this.inSeqno, 0);\n this._macInstance.update(BUF_INT);\n if (this._macETM) {\n this._macInstance.update(this._block);\n } else {\n this._macInstance.update(new Uint8Array(decrypted.buffer,\n decrypted.byteOffset,\n 4));\n this._pktLen = decrypted.length - 4;\n this._packetPos = this._pktLen;\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(\n new Uint8Array(decrypted.buffer,\n decrypted.byteOffset + 4,\n this._packetPos),\n 0\n );\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (this._macETM)\n this._macInstance.update(encrypted);\n const decrypted = this._decipherInstance.update(encrypted);\n if (decrypted.length) {\n if (nb === this._len) {\n this._packet = decrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(decrypted, this._packetPos);\n }\n this._packetPos += decrypted.length;\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read MAC\n {\n const nb = Math.min(this._macActualLen - this._macPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < this._macActualLen)\n return;\n }\n\n // Verify MAC\n if (!this._macETM)\n this._macInstance.update(this._packet);\n let calculated = this._macInstance.digest();\n if (this._macActualLen < calculated.length) {\n calculated = new Uint8Array(calculated.buffer,\n calculated.byteOffset,\n this._macActualLen);\n }\n if (!timingSafeEquals(calculated, this._mac))\n throw new Error('Invalid MAC');\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._macPos = 0;\n this._macInstance = null;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass GenericDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new GenericDecipher(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV,\n dec.macInfo.sslName,\n dec.macKey,\n dec.macInfo.isETM,\n dec.macInfo.actualLen);\n this._block = Buffer.allocUnsafe(\n dec.macInfo.isETM || dec.decipherInfo.stream\n ? 4\n : dec.decipherInfo.blockLen\n );\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(dec.macInfo.actualLen);\n this._macPos = 0;\n this._macActualLen = dec.macInfo.actualLen;\n this._macETM = dec.macInfo.isETM;\n }\n free() {\n this._instance.free();\n }\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read first encrypted block\n if (this._blockPos < this._block.length) {\n const nb = Math.min(this._block.length - this._blockPos, dataLen - p);\n if (p !== 0 || nb !== dataLen || nb < data.length) {\n this._block.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._blockPos\n );\n } else {\n this._block.set(data, this._blockPos);\n }\n\n p += nb;\n this._blockPos += nb;\n if (this._blockPos < this._block.length)\n return;\n\n let need;\n if (this._macETM) {\n this._len = need = readUInt32BE(this._block, 0);\n } else {\n // Decrypt first block to get packet length\n this._instance.decryptBlock(this._block);\n this._len = readUInt32BE(this._block, 0);\n need = 4 + this._len - this._block.length;\n }\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 5\n || (need & (this._block.length - 1)) !== 0) {\n throw new Error('Bad packet length');\n }\n\n if (!this._macETM) {\n this._pktLen = (this._block.length - 4);\n if (this._pktLen) {\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(\n new Uint8Array(this._block.buffer,\n this._block.byteOffset + 4,\n this._pktLen),\n 0\n );\n }\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read MAC\n {\n const nb = Math.min(this._macActualLen - this._macPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < this._macActualLen)\n return;\n }\n\n // Decrypt and verify MAC\n this._instance.decrypt(this._packet,\n this.inSeqno,\n this._block,\n this._mac);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n this._macInstance = null;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\n// Increments unsigned, big endian counter (last 8 bytes) of AES-GCM IV\nfunction ivIncrement(iv) {\n // eslint-disable-next-line no-unused-expressions\n ++iv[11] >>> 8\n && ++iv[10] >>> 8\n && ++iv[9] >>> 8\n && ++iv[8] >>> 8\n && ++iv[7] >>> 8\n && ++iv[6] >>> 8\n && ++iv[5] >>> 8\n && ++iv[4] >>> 8;\n}\n\nconst intToBytes = (() => {\n const ret = Buffer.alloc(4);\n return (n) => {\n ret[0] = (n >>> 24);\n ret[1] = (n >>> 16);\n ret[2] = (n >>> 8);\n ret[3] = n;\n return ret;\n };\n})();\n\nfunction timingSafeEquals(a, b) {\n if (a.length !== b.length) {\n timingSafeEqual(a, a);\n return false;\n }\n return timingSafeEqual(a, b);\n}\n\nfunction createCipher(config) {\n if (typeof config !== 'object' || config === null)\n throw new Error('Invalid config');\n\n if (typeof config.outbound !== 'object' || config.outbound === null)\n throw new Error('Invalid outbound');\n\n const outbound = config.outbound;\n\n if (typeof outbound.onWrite !== 'function')\n throw new Error('Invalid outbound.onWrite');\n\n if (typeof outbound.cipherInfo !== 'object' || outbound.cipherInfo === null)\n throw new Error('Invalid outbound.cipherInfo');\n\n if (!Buffer.isBuffer(outbound.cipherKey)\n || outbound.cipherKey.length !== outbound.cipherInfo.keyLen) {\n throw new Error('Invalid outbound.cipherKey');\n }\n\n if (outbound.cipherInfo.ivLen\n && (!Buffer.isBuffer(outbound.cipherIV)\n || outbound.cipherIV.length !== outbound.cipherInfo.ivLen)) {\n throw new Error('Invalid outbound.cipherIV');\n }\n\n if (typeof outbound.seqno !== 'number'\n || outbound.seqno < 0\n || outbound.seqno > MAX_SEQNO) {\n throw new Error('Invalid outbound.seqno');\n }\n\n const forceNative = !!outbound.forceNative;\n\n switch (outbound.cipherInfo.sslName) {\n case 'aes-128-gcm':\n case 'aes-256-gcm':\n return (AESGCMCipher && !forceNative\n ? new AESGCMCipherBinding(config)\n : new AESGCMCipherNative(config));\n case 'chacha20':\n return (ChaChaPolyCipher && !forceNative\n ? new ChaChaPolyCipherBinding(config)\n : new ChaChaPolyCipherNative(config));\n default: {\n if (typeof outbound.macInfo !== 'object' || outbound.macInfo === null)\n throw new Error('Invalid outbound.macInfo');\n if (!Buffer.isBuffer(outbound.macKey)\n || outbound.macKey.length !== outbound.macInfo.len) {\n throw new Error('Invalid outbound.macKey');\n }\n return (GenericCipher && !forceNative\n ? new GenericCipherBinding(config)\n : new GenericCipherNative(config));\n }\n }\n}\n\nfunction createDecipher(config) {\n if (typeof config !== 'object' || config === null)\n throw new Error('Invalid config');\n\n if (typeof config.inbound !== 'object' || config.inbound === null)\n throw new Error('Invalid inbound');\n\n const inbound = config.inbound;\n\n if (typeof inbound.onPayload !== 'function')\n throw new Error('Invalid inbound.onPayload');\n\n if (typeof inbound.decipherInfo !== 'object'\n || inbound.decipherInfo === null) {\n throw new Error('Invalid inbound.decipherInfo');\n }\n\n if (!Buffer.isBuffer(inbound.decipherKey)\n || inbound.decipherKey.length !== inbound.decipherInfo.keyLen) {\n throw new Error('Invalid inbound.decipherKey');\n }\n\n if (inbound.decipherInfo.ivLen\n && (!Buffer.isBuffer(inbound.decipherIV)\n || inbound.decipherIV.length !== inbound.decipherInfo.ivLen)) {\n throw new Error('Invalid inbound.decipherIV');\n }\n\n if (typeof inbound.seqno !== 'number'\n || inbound.seqno < 0\n || inbound.seqno > MAX_SEQNO) {\n throw new Error('Invalid inbound.seqno');\n }\n\n const forceNative = !!inbound.forceNative;\n\n switch (inbound.decipherInfo.sslName) {\n case 'aes-128-gcm':\n case 'aes-256-gcm':\n return (AESGCMDecipher && !forceNative\n ? new AESGCMDecipherBinding(config)\n : new AESGCMDecipherNative(config));\n case 'chacha20':\n return (ChaChaPolyDecipher && !forceNative\n ? new ChaChaPolyDecipherBinding(config)\n : new ChaChaPolyDecipherNative(config));\n default: {\n if (typeof inbound.macInfo !== 'object' || inbound.macInfo === null)\n throw new Error('Invalid inbound.macInfo');\n if (!Buffer.isBuffer(inbound.macKey)\n || inbound.macKey.length !== inbound.macInfo.len) {\n throw new Error('Invalid inbound.macKey');\n }\n return (GenericDecipher && !forceNative\n ? new GenericDecipherBinding(config)\n : new GenericDecipherNative(config));\n }\n }\n}\n\nmodule.exports = {\n CIPHER_INFO,\n MAC_INFO,\n bindingAvailable: !!binding,\n init: (() => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n try {\n POLY1305_WASM_MODULE = await require('./crypto/poly1305.js')();\n POLY1305_RESULT_MALLOC = POLY1305_WASM_MODULE._malloc(16);\n poly1305_auth = POLY1305_WASM_MODULE.cwrap(\n 'poly1305_auth',\n null,\n ['number', 'array', 'number', 'array', 'number', 'array']\n );\n } catch (ex) {\n return reject(ex);\n }\n resolve();\n });\n })(),\n\n NullCipher,\n createCipher,\n NullDecipher,\n createDecipher,\n};\n","\nvar createPoly1305 = (function() {\n var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;\n if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;\n return (\nfunction(createPoly1305) {\n createPoly1305 = createPoly1305 || {};\n\n\nvar b;b||(b=typeof createPoly1305 !== 'undefined' ? createPoly1305 : {});var q,r;b.ready=new Promise(function(a,c){q=a;r=c});var u={},w;for(w in b)b.hasOwnProperty(w)&&(u[w]=b[w]);var x=\"object\"===typeof window,y=\"function\"===typeof importScripts,z=\"object\"===typeof process&&\"object\"===typeof process.versions&&\"string\"===typeof process.versions.node,B=\"\",C,D,E,F,G;\nif(z)B=y?require(\"path\").dirname(B)+\"/\":__dirname+\"/\",C=function(a,c){var d=H(a);if(d)return c?d:d.toString();F||(F=require(\"fs\"));G||(G=require(\"path\"));a=G.normalize(a);return F.readFileSync(a,c?null:\"utf8\")},E=function(a){a=C(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},D=function(a,c,d){var e=H(a);e&&c(e);F||(F=require(\"fs\"));G||(G=require(\"path\"));a=G.normalize(a);F.readFile(a,function(f,l){f?d(f):c(l.buffer)})},1=m){var oa=g.charCodeAt(++v);m=65536+((m&1023)<<10)|oa&1023}if(127>=m){if(k>=n)break;h[k++]=m}else{if(2047>=m){if(k+1>=n)break;h[k++]=192|m>>6}else{if(65535>=m){if(k+2>=n)break;h[k++]=224|m>>12}else{if(k+3>=n)break;h[k++]=240|m>>18;h[k++]=128|m>>12&63}h[k++]=128|m>>6&63}h[k++]=128|m&63}}h[k]=\n0}}return p},array:function(g){var p=O(g.length);Q.set(g,p);return p}},l=N(a),A=[];a=0;if(e)for(var t=0;t=n);)++k;if(16h?n+=String.fromCharCode(h):(h-=65536,n+=String.fromCharCode(55296|h>>10,56320|h&1023))}}else n+=String.fromCharCode(h)}g=n}}else g=\"\";else g=\"boolean\"===c?!!g:g;return g}(d);0!==a&&fa(a);return d}var ea=\"undefined\"!==typeof TextDecoder?new TextDecoder(\"utf8\"):void 0,ha,Q,P;\nfunction ia(){var a=L.buffer;ha=a;b.HEAP8=Q=new Int8Array(a);b.HEAP16=new Int16Array(a);b.HEAP32=new Int32Array(a);b.HEAPU8=P=new Uint8Array(a);b.HEAPU16=new Uint16Array(a);b.HEAPU32=new Uint32Array(a);b.HEAPF32=new Float32Array(a);b.HEAPF64=new Float64Array(a)}var R,ja=[],ka=[],la=[];function ma(){var a=b.preRun.shift();ja.unshift(a)}var S=0,T=null,U=null;b.preloadedImages={};b.preloadedAudios={};\nfunction K(a){if(b.onAbort)b.onAbort(a);I(a);M=!0;a=new WebAssembly.RuntimeError(\"abort(\"+a+\"). Build with -s ASSERTIONS=1 for more info.\");r(a);throw a;}var V=\"data:application/octet-stream;base64,\",W;W=\"data:application/octet-stream;base64,AGFzbQEAAAABIAZgAX8Bf2ADf39/AGABfwBgAABgAAF/YAZ/f39/f38AAgcBAWEBYQAAAwsKAAEDAQAAAgQFAgQFAXABAQEFBwEBgAKAgAIGCQF/AUGAjMACCwclCQFiAgABYwADAWQACQFlAAgBZgAHAWcABgFoAAUBaQAKAWoBAAqGTQpPAQJ/QYAIKAIAIgEgAEEDakF8cSICaiEAAkAgAkEAIAAgAU0bDQAgAD8AQRB0SwRAIAAQAEUNAQtBgAggADYCACABDwtBhAhBMDYCAEF/C4wFAg5+Cn8gACgCJCEUIAAoAiAhFSAAKAIcIREgACgCGCESIAAoAhQhEyACQRBPBEAgAC0ATEVBGHQhFyAAKAIEIhZBBWytIQ8gACgCCCIYQQVsrSENIAAoAgwiGUEFbK0hCyAAKAIQIhpBBWytIQkgADUCACEIIBqtIRAgGa0hDiAYrSEMIBatIQoDQCASIAEtAAMiEiABLQAEQQh0ciABLQAFQRB0ciABLQAGIhZBGHRyQQJ2Qf///x9xaq0iAyAOfiABLwAAIAEtAAJBEHRyIBNqIBJBGHRBgICAGHFqrSIEIBB+fCARIAEtAAdBCHQgFnIgAS0ACEEQdHIgAS0ACSIRQRh0ckEEdkH///8fcWqtIgUgDH58IAEtAApBCHQgEXIgAS0AC0EQdHIgAS0ADEEYdHJBBnYgFWqtIgYgCn58IBQgF2ogAS8ADSABLQAPQRB0cmqtIgcgCH58IAMgDH4gBCAOfnwgBSAKfnwgBiAIfnwgByAJfnwgAyAKfiAEIAx+fCAFIAh+fCAGIAl+fCAHIAt+fCADIAh+IAQgCn58IAUgCX58IAYgC358IAcgDX58IAMgCX4gBCAIfnwgBSALfnwgBiANfnwgByAPfnwiA0IaiEL/////D4N8IgRCGohC/////w+DfCIFQhqIQv////8Pg3wiBkIaiEL/////D4N8IgdCGoinQQVsIAOnQf///x9xaiITQRp2IASnQf///x9xaiESIAWnQf///x9xIREgBqdB////H3EhFSAHp0H///8fcSEUIBNB////H3EhEyABQRBqIQEgAkEQayICQQ9LDQALCyAAIBQ2AiQgACAVNgIgIAAgETYCHCAAIBI2AhggACATNgIUCwMAAQu2BAEGfwJAIAAoAjgiBARAIABBPGohBQJAIAJBECAEayIDIAIgA0kbIgZFDQAgBkEDcSEHAkAgBkEBa0EDSQRAQQAhAwwBCyAGQXxxIQhBACEDA0AgBSADIARqaiABIANqLQAAOgAAIAUgA0EBciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0ECciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0EDciIEIAAoAjhqaiABIARqLQAAOgAAIANBBGohAyAAKAI4IQQgCEEEayIIDQALCyAHRQ0AA0AgBSADIARqaiABIANqLQAAOgAAIANBAWohAyAAKAI4IQQgB0EBayIHDQALCyAAIAQgBmoiAzYCOCADQRBJDQEgACAFQRAQAiAAQQA2AjggAiAGayECIAEgBmohAQsgAkEQTwRAIAAgASACQXBxIgMQAiACQQ9xIQIgASADaiEBCyACRQ0AIAJBA3EhBCAAQTxqIQVBACEDIAJBAWtBA08EQCACQXxxIQcDQCAFIAAoAjggA2pqIAEgA2otAAA6AAAgBSADQQFyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQJyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQNyIgYgACgCOGpqIAEgBmotAAA6AAAgA0EEaiEDIAdBBGsiBw0ACwsgBARAA0AgBSAAKAI4IANqaiABIANqLQAAOgAAIANBAWohAyAEQQFrIgQNAAsLIAAgACgCOCACajYCOAsLoS0BDH8jAEEQayIMJAACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAEH0AU0EQEGICCgCACIFQRAgAEELakF4cSAAQQtJGyIIQQN2IgJ2IgFBA3EEQCABQX9zQQFxIAJqIgNBA3QiAUG4CGooAgAiBEEIaiEAAkAgBCgCCCICIAFBsAhqIgFGBEBBiAggBUF+IAN3cTYCAAwBCyACIAE2AgwgASACNgIICyAEIANBA3QiAUEDcjYCBCABIARqIgEgASgCBEEBcjYCBAwNCyAIQZAIKAIAIgpNDQEgAQRAAkBBAiACdCIAQQAgAGtyIAEgAnRxIgBBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2aiIDQQN0IgBBuAhqKAIAIgQoAggiASAAQbAIaiIARgRAQYgIIAVBfiADd3EiBTYCAAwBCyABIAA2AgwgACABNgIICyAEQQhqIQAgBCAIQQNyNgIEIAQgCGoiAiADQQN0IgEgCGsiA0EBcjYCBCABIARqIAM2AgAgCgRAIApBA3YiAUEDdEGwCGohB0GcCCgCACEEAn8gBUEBIAF0IgFxRQRAQYgIIAEgBXI2AgAgBwwBCyAHKAIICyEBIAcgBDYCCCABIAQ2AgwgBCAHNgIMIAQgATYCCAtBnAggAjYCAEGQCCADNgIADA0LQYwIKAIAIgZFDQEgBkEAIAZrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QbgKaigCACIBKAIEQXhxIAhrIQMgASECA0ACQCACKAIQIgBFBEAgAigCFCIARQ0BCyAAKAIEQXhxIAhrIgIgAyACIANJIgIbIQMgACABIAIbIQEgACECDAELCyABIAhqIgkgAU0NAiABKAIYIQsgASABKAIMIgRHBEAgASgCCCIAQZgIKAIASRogACAENgIMIAQgADYCCAwMCyABQRRqIgIoAgAiAEUEQCABKAIQIgBFDQQgAUEQaiECCwNAIAIhByAAIgRBFGoiAigCACIADQAgBEEQaiECIAQoAhAiAA0ACyAHQQA2AgAMCwtBfyEIIABBv39LDQAgAEELaiIAQXhxIQhBjAgoAgAiCUUNAEEAIAhrIQMCQAJAAkACf0EAIAhBgAJJDQAaQR8gCEH///8HSw0AGiAAQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgCCAAQRVqdkEBcXJBHGoLIgVBAnRBuApqKAIAIgJFBEBBACEADAELQQAhACAIQQBBGSAFQQF2ayAFQR9GG3QhAQNAAkAgAigCBEF4cSAIayIHIANPDQAgAiEEIAciAw0AQQAhAyACIQAMAwsgACACKAIUIgcgByACIAFBHXZBBHFqKAIQIgJGGyAAIAcbIQAgAUEBdCEBIAINAAsLIAAgBHJFBEBBACEEQQIgBXQiAEEAIABrciAJcSIARQ0DIABBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2akECdEG4CmooAgAhAAsgAEUNAQsDQCAAKAIEQXhxIAhrIgEgA0khAiABIAMgAhshAyAAIAQgAhshBCAAKAIQIgEEfyABBSAAKAIUCyIADQALCyAERQ0AIANBkAgoAgAgCGtPDQAgBCAIaiIGIARNDQEgBCgCGCEFIAQgBCgCDCIBRwRAIAQoAggiAEGYCCgCAEkaIAAgATYCDCABIAA2AggMCgsgBEEUaiICKAIAIgBFBEAgBCgCECIARQ0EIARBEGohAgsDQCACIQcgACIBQRRqIgIoAgAiAA0AIAFBEGohAiABKAIQIgANAAsgB0EANgIADAkLIAhBkAgoAgAiAk0EQEGcCCgCACEDAkAgAiAIayIBQRBPBEBBkAggATYCAEGcCCADIAhqIgA2AgAgACABQQFyNgIEIAIgA2ogATYCACADIAhBA3I2AgQMAQtBnAhBADYCAEGQCEEANgIAIAMgAkEDcjYCBCACIANqIgAgACgCBEEBcjYCBAsgA0EIaiEADAsLIAhBlAgoAgAiBkkEQEGUCCAGIAhrIgE2AgBBoAhBoAgoAgAiAiAIaiIANgIAIAAgAUEBcjYCBCACIAhBA3I2AgQgAkEIaiEADAsLQQAhACAIQS9qIgkCf0HgCygCAARAQegLKAIADAELQewLQn83AgBB5AtCgKCAgICABDcCAEHgCyAMQQxqQXBxQdiq1aoFczYCAEH0C0EANgIAQcQLQQA2AgBBgCALIgFqIgVBACABayIHcSICIAhNDQpBwAsoAgAiBARAQbgLKAIAIgMgAmoiASADTQ0LIAEgBEsNCwtBxAstAABBBHENBQJAAkBBoAgoAgAiAwRAQcgLIQADQCADIAAoAgAiAU8EQCABIAAoAgRqIANLDQMLIAAoAggiAA0ACwtBABABIgFBf0YNBiACIQVB5AsoAgAiA0EBayIAIAFxBEAgAiABayAAIAFqQQAgA2txaiEFCyAFIAhNDQYgBUH+////B0sNBkHACygCACIEBEBBuAsoAgAiAyAFaiIAIANNDQcgACAESw0HCyAFEAEiACABRw0BDAgLIAUgBmsgB3EiBUH+////B0sNBSAFEAEiASAAKAIAIAAoAgRqRg0EIAEhAAsCQCAAQX9GDQAgCEEwaiAFTQ0AQegLKAIAIgEgCSAFa2pBACABa3EiAUH+////B0sEQCAAIQEMCAsgARABQX9HBEAgASAFaiEFIAAhAQwIC0EAIAVrEAEaDAULIAAiAUF/Rw0GDAQLAAtBACEEDAcLQQAhAQwFCyABQX9HDQILQcQLQcQLKAIAQQRyNgIACyACQf7///8HSw0BIAIQASEBQQAQASEAIAFBf0YNASAAQX9GDQEgACABTQ0BIAAgAWsiBSAIQShqTQ0BC0G4C0G4CygCACAFaiIANgIAQbwLKAIAIABJBEBBvAsgADYCAAsCQAJAAkBBoAgoAgAiBwRAQcgLIQADQCABIAAoAgAiAyAAKAIEIgJqRg0CIAAoAggiAA0ACwwCC0GYCCgCACIAQQAgACABTRtFBEBBmAggATYCAAtBACEAQcwLIAU2AgBByAsgATYCAEGoCEF/NgIAQawIQeALKAIANgIAQdQLQQA2AgADQCAAQQN0IgNBuAhqIANBsAhqIgI2AgAgA0G8CGogAjYCACAAQQFqIgBBIEcNAAtBlAggBUEoayIDQXggAWtBB3FBACABQQhqQQdxGyIAayICNgIAQaAIIAAgAWoiADYCACAAIAJBAXI2AgQgASADakEoNgIEQaQIQfALKAIANgIADAILIAAtAAxBCHENACADIAdLDQAgASAHTQ0AIAAgAiAFajYCBEGgCCAHQXggB2tBB3FBACAHQQhqQQdxGyIAaiICNgIAQZQIQZQIKAIAIAVqIgEgAGsiADYCACACIABBAXI2AgQgASAHakEoNgIEQaQIQfALKAIANgIADAELQZgIKAIAIAFLBEBBmAggATYCAAsgASAFaiECQcgLIQACQAJAAkACQAJAAkADQCACIAAoAgBHBEAgACgCCCIADQEMAgsLIAAtAAxBCHFFDQELQcgLIQADQCAHIAAoAgAiAk8EQCACIAAoAgRqIgQgB0sNAwsgACgCCCEADAALAAsgACABNgIAIAAgACgCBCAFajYCBCABQXggAWtBB3FBACABQQhqQQdxG2oiCSAIQQNyNgIEIAJBeCACa0EHcUEAIAJBCGpBB3EbaiIFIAggCWoiBmshAiAFIAdGBEBBoAggBjYCAEGUCEGUCCgCACACaiIANgIAIAYgAEEBcjYCBAwDCyAFQZwIKAIARgRAQZwIIAY2AgBBkAhBkAgoAgAgAmoiADYCACAGIABBAXI2AgQgACAGaiAANgIADAMLIAUoAgQiAEEDcUEBRgRAIABBeHEhBwJAIABB/wFNBEAgBSgCCCIDIABBA3YiAEEDdEGwCGpGGiADIAUoAgwiAUYEQEGICEGICCgCAEF+IAB3cTYCAAwCCyADIAE2AgwgASADNgIIDAELIAUoAhghCAJAIAUgBSgCDCIBRwRAIAUoAggiACABNgIMIAEgADYCCAwBCwJAIAVBFGoiACgCACIDDQAgBUEQaiIAKAIAIgMNAEEAIQEMAQsDQCAAIQQgAyIBQRRqIgAoAgAiAw0AIAFBEGohACABKAIQIgMNAAsgBEEANgIACyAIRQ0AAkAgBSAFKAIcIgNBAnRBuApqIgAoAgBGBEAgACABNgIAIAENAUGMCEGMCCgCAEF+IAN3cTYCAAwCCyAIQRBBFCAIKAIQIAVGG2ogATYCACABRQ0BCyABIAg2AhggBSgCECIABEAgASAANgIQIAAgATYCGAsgBSgCFCIARQ0AIAEgADYCFCAAIAE2AhgLIAUgB2ohBSACIAdqIQILIAUgBSgCBEF+cTYCBCAGIAJBAXI2AgQgAiAGaiACNgIAIAJB/wFNBEAgAkEDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwDC0EfIQAgAkH///8HTQRAIAJBCHYiACAAQYD+P2pBEHZBCHEiA3QiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASADciAAcmsiAEEBdCACIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQQCQEGMCCgCACIDQQEgAHQiAXFFBEBBjAggASADcjYCACAEIAY2AgAgBiAENgIYDAELIAJBAEEZIABBAXZrIABBH0YbdCEAIAQoAgAhAQNAIAEiAygCBEF4cSACRg0DIABBHXYhASAAQQF0IQAgAyABQQRxaiIEKAIQIgENAAsgBCAGNgIQIAYgAzYCGAsgBiAGNgIMIAYgBjYCCAwCC0GUCCAFQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBBoAggACABaiIANgIAIAAgAkEBcjYCBCABIANqQSg2AgRBpAhB8AsoAgA2AgAgByAEQScgBGtBB3FBACAEQSdrQQdxG2pBL2siACAAIAdBEGpJGyICQRs2AgQgAkHQCykCADcCECACQcgLKQIANwIIQdALIAJBCGo2AgBBzAsgBTYCAEHICyABNgIAQdQLQQA2AgAgAkEYaiEAA0AgAEEHNgIEIABBCGohASAAQQRqIQAgASAESQ0ACyACIAdGDQMgAiACKAIEQX5xNgIEIAcgAiAHayIEQQFyNgIEIAIgBDYCACAEQf8BTQRAIARBA3YiAEEDdEGwCGohAgJ/QYgIKAIAIgFBASAAdCIAcUUEQEGICCAAIAFyNgIAIAIMAQsgAigCCAshACACIAc2AgggACAHNgIMIAcgAjYCDCAHIAA2AggMBAtBHyEAIAdCADcCECAEQf///wdNBEAgBEEIdiIAIABBgP4/akEQdkEIcSICdCIAIABBgOAfakEQdkEEcSIBdCIAIABBgIAPakEQdkECcSIAdEEPdiABIAJyIAByayIAQQF0IAQgAEEVanZBAXFyQRxqIQALIAcgADYCHCAAQQJ0QbgKaiEDAkBBjAgoAgAiAkEBIAB0IgFxRQRAQYwIIAEgAnI2AgAgAyAHNgIAIAcgAzYCGAwBCyAEQQBBGSAAQQF2ayAAQR9GG3QhACADKAIAIQEDQCABIgIoAgRBeHEgBEYNBCAAQR12IQEgAEEBdCEAIAIgAUEEcWoiAygCECIBDQALIAMgBzYCECAHIAI2AhgLIAcgBzYCDCAHIAc2AggMAwsgAygCCCIAIAY2AgwgAyAGNgIIIAZBADYCGCAGIAM2AgwgBiAANgIICyAJQQhqIQAMBQsgAigCCCIAIAc2AgwgAiAHNgIIIAdBADYCGCAHIAI2AgwgByAANgIIC0GUCCgCACIAIAhNDQBBlAggACAIayIBNgIAQaAIQaAIKAIAIgIgCGoiADYCACAAIAFBAXI2AgQgAiAIQQNyNgIEIAJBCGohAAwDC0GECEEwNgIAQQAhAAwCCwJAIAVFDQACQCAEKAIcIgJBAnRBuApqIgAoAgAgBEYEQCAAIAE2AgAgAQ0BQYwIIAlBfiACd3EiCTYCAAwCCyAFQRBBFCAFKAIQIARGG2ogATYCACABRQ0BCyABIAU2AhggBCgCECIABEAgASAANgIQIAAgATYCGAsgBCgCFCIARQ0AIAEgADYCFCAAIAE2AhgLAkAgA0EPTQRAIAQgAyAIaiIAQQNyNgIEIAAgBGoiACAAKAIEQQFyNgIEDAELIAQgCEEDcjYCBCAGIANBAXI2AgQgAyAGaiADNgIAIANB/wFNBEAgA0EDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwBC0EfIQAgA0H///8HTQRAIANBCHYiACAAQYD+P2pBEHZBCHEiAnQiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASACciAAcmsiAEEBdCADIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQICQAJAIAlBASAAdCIBcUUEQEGMCCABIAlyNgIAIAIgBjYCACAGIAI2AhgMAQsgA0EAQRkgAEEBdmsgAEEfRht0IQAgAigCACEIA0AgCCIBKAIEQXhxIANGDQIgAEEddiECIABBAXQhACABIAJBBHFqIgIoAhAiCA0ACyACIAY2AhAgBiABNgIYCyAGIAY2AgwgBiAGNgIIDAELIAEoAggiACAGNgIMIAEgBjYCCCAGQQA2AhggBiABNgIMIAYgADYCCAsgBEEIaiEADAELAkAgC0UNAAJAIAEoAhwiAkECdEG4CmoiACgCACABRgRAIAAgBDYCACAEDQFBjAggBkF+IAJ3cTYCAAwCCyALQRBBFCALKAIQIAFGG2ogBDYCACAERQ0BCyAEIAs2AhggASgCECIABEAgBCAANgIQIAAgBDYCGAsgASgCFCIARQ0AIAQgADYCFCAAIAQ2AhgLAkAgA0EPTQRAIAEgAyAIaiIAQQNyNgIEIAAgAWoiACAAKAIEQQFyNgIEDAELIAEgCEEDcjYCBCAJIANBAXI2AgQgAyAJaiADNgIAIAoEQCAKQQN2IgBBA3RBsAhqIQRBnAgoAgAhAgJ/QQEgAHQiACAFcUUEQEGICCAAIAVyNgIAIAQMAQsgBCgCCAshACAEIAI2AgggACACNgIMIAIgBDYCDCACIAA2AggLQZwIIAk2AgBBkAggAzYCAAsgAUEIaiEACyAMQRBqJAAgAAsQACMAIABrQXBxIgAkACAACwYAIAAkAAsEACMAC4AJAgh/BH4jAEGQAWsiBiQAIAYgBS0AA0EYdEGAgIAYcSAFLwAAIAUtAAJBEHRycjYCACAGIAUoAANBAnZBg/7/H3E2AgQgBiAFKAAGQQR2Qf+B/x9xNgIIIAYgBSgACUEGdkH//8AfcTYCDCAFLwANIQggBS0ADyEJIAZCADcCFCAGQgA3AhwgBkEANgIkIAYgCCAJQRB0QYCAPHFyNgIQIAYgBSgAEDYCKCAGIAUoABQ2AiwgBiAFKAAYNgIwIAUoABwhBSAGQQA6AEwgBkEANgI4IAYgBTYCNCAGIAEgAhAEIAQEQCAGIAMgBBAECyAGKAI4IgEEQCAGQTxqIgIgAWpBAToAACABQQFqQQ9NBEAgASAGakE9aiEEAkBBDyABayIDRQ0AIAMgBGoiAUEBa0EAOgAAIARBADoAACADQQNJDQAgAUECa0EAOgAAIARBADoAASABQQNrQQA6AAAgBEEAOgACIANBB0kNACABQQRrQQA6AAAgBEEAOgADIANBCUkNACAEQQAgBGtBA3EiAWoiBEEANgIAIAQgAyABa0F8cSIBaiIDQQRrQQA2AgAgAUEJSQ0AIARBADYCCCAEQQA2AgQgA0EIa0EANgIAIANBDGtBADYCACABQRlJDQAgBEEANgIYIARBADYCFCAEQQA2AhAgBEEANgIMIANBEGtBADYCACADQRRrQQA2AgAgA0EYa0EANgIAIANBHGtBADYCACABIARBBHFBGHIiAWsiA0EgSQ0AIAEgBGohAQNAIAFCADcDGCABQgA3AxAgAUIANwMIIAFCADcDACABQSBqIQEgA0EgayIDQR9LDQALCwsgBkEBOgBMIAYgAkEQEAILIAY1AjQhECAGNQIwIREgBjUCLCEOIAAgBjUCKCAGKAIkIAYoAiAgBigCHCAGKAIYIgNBGnZqIgJBGnZqIgFBGnZqIgtBgICAYHIgAUH///8fcSINIAJB////H3EiCCAGKAIUIAtBGnZBBWxqIgFB////H3EiCUEFaiIFQRp2IANB////H3EgAUEadmoiA2oiAUEadmoiAkEadmoiBEEadmoiDEEfdSIHIANxIAEgDEEfdkEBayIDQf///x9xIgpxciIBQRp0IAUgCnEgByAJcXJyrXwiDzwAACAAIA9CGIg8AAMgACAPQhCIPAACIAAgD0IIiDwAASAAIA4gByAIcSACIApxciICQRR0IAFBBnZyrXwgD0IgiHwiDjwABCAAIA5CGIg8AAcgACAOQhCIPAAGIAAgDkIIiDwABSAAIBEgByANcSAEIApxciIBQQ50IAJBDHZyrXwgDkIgiHwiDjwACCAAIA5CGIg8AAsgACAOQhCIPAAKIAAgDkIIiDwACSAAIBAgAyAMcSAHIAtxckEIdCABQRJ2cq18IA5CIIh8Ig48AAwgACAOQhiIPAAPIAAgDkIQiDwADiAAIA5CCIg8AA0gBkIANwIwIAZCADcCKCAGQgA3AiAgBkIANwIYIAZCADcCECAGQgA3AgggBkIANwIAIAZBkAFqJAALpwwBB38CQCAARQ0AIABBCGsiAyAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQNxRQ0BIAMgAygCACIBayIDQZgIKAIASQ0BIAAgAWohACADQZwIKAIARwRAIAFB/wFNBEAgAygCCCICIAFBA3YiBEEDdEGwCGpGGiACIAMoAgwiAUYEQEGICEGICCgCAEF+IAR3cTYCAAwDCyACIAE2AgwgASACNgIIDAILIAMoAhghBgJAIAMgAygCDCIBRwRAIAMoAggiAiABNgIMIAEgAjYCCAwBCwJAIANBFGoiAigCACIEDQAgA0EQaiICKAIAIgQNAEEAIQEMAQsDQCACIQcgBCIBQRRqIgIoAgAiBA0AIAFBEGohAiABKAIQIgQNAAsgB0EANgIACyAGRQ0BAkAgAyADKAIcIgJBAnRBuApqIgQoAgBGBEAgBCABNgIAIAENAUGMCEGMCCgCAEF+IAJ3cTYCAAwDCyAGQRBBFCAGKAIQIANGG2ogATYCACABRQ0CCyABIAY2AhggAygCECICBEAgASACNgIQIAIgATYCGAsgAygCFCICRQ0BIAEgAjYCFCACIAE2AhgMAQsgBSgCBCIBQQNxQQNHDQBBkAggADYCACAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAA8LIAMgBU8NACAFKAIEIgFBAXFFDQACQCABQQJxRQRAIAVBoAgoAgBGBEBBoAggAzYCAEGUCEGUCCgCACAAaiIANgIAIAMgAEEBcjYCBCADQZwIKAIARw0DQZAIQQA2AgBBnAhBADYCAA8LIAVBnAgoAgBGBEBBnAggAzYCAEGQCEGQCCgCACAAaiIANgIAIAMgAEEBcjYCBCAAIANqIAA2AgAPCyABQXhxIABqIQACQCABQf8BTQRAIAUoAggiAiABQQN2IgRBA3RBsAhqRhogAiAFKAIMIgFGBEBBiAhBiAgoAgBBfiAEd3E2AgAMAgsgAiABNgIMIAEgAjYCCAwBCyAFKAIYIQYCQCAFIAUoAgwiAUcEQCAFKAIIIgJBmAgoAgBJGiACIAE2AgwgASACNgIIDAELAkAgBUEUaiICKAIAIgQNACAFQRBqIgIoAgAiBA0AQQAhAQwBCwNAIAIhByAEIgFBFGoiAigCACIEDQAgAUEQaiECIAEoAhAiBA0ACyAHQQA2AgALIAZFDQACQCAFIAUoAhwiAkECdEG4CmoiBCgCAEYEQCAEIAE2AgAgAQ0BQYwIQYwIKAIAQX4gAndxNgIADAILIAZBEEEUIAYoAhAgBUYbaiABNgIAIAFFDQELIAEgBjYCGCAFKAIQIgIEQCABIAI2AhAgAiABNgIYCyAFKAIUIgJFDQAgASACNgIUIAIgATYCGAsgAyAAQQFyNgIEIAAgA2ogADYCACADQZwIKAIARw0BQZAIIAA2AgAPCyAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAAsgAEH/AU0EQCAAQQN2IgFBA3RBsAhqIQACf0GICCgCACICQQEgAXQiAXFFBEBBiAggASACcjYCACAADAELIAAoAggLIQIgACADNgIIIAIgAzYCDCADIAA2AgwgAyACNgIIDwtBHyECIANCADcCECAAQf///wdNBEAgAEEIdiIBIAFBgP4/akEQdkEIcSIBdCICIAJBgOAfakEQdkEEcSICdCIEIARBgIAPakEQdkECcSIEdEEPdiABIAJyIARyayIBQQF0IAAgAUEVanZBAXFyQRxqIQILIAMgAjYCHCACQQJ0QbgKaiEBAkACQAJAQYwIKAIAIgRBASACdCIHcUUEQEGMCCAEIAdyNgIAIAEgAzYCACADIAE2AhgMAQsgAEEAQRkgAkEBdmsgAkEfRht0IQIgASgCACEBA0AgASIEKAIEQXhxIABGDQIgAkEddiEBIAJBAXQhAiAEIAFBBHFqIgdBEGooAgAiAQ0ACyAHIAM2AhAgAyAENgIYCyADIAM2AgwgAyADNgIIDAELIAQoAggiACADNgIMIAQgAzYCCCADQQA2AhggAyAENgIMIAMgADYCCAtBqAhBqAgoAgBBAWsiAEF/IAAbNgIACwsLCQEAQYEICwIGUA==\";if(!W.startsWith(V)){var na=W;W=b.locateFile?b.locateFile(na,B):B+na}function pa(){var a=W;try{if(a==W&&J)return new Uint8Array(J);var c=H(a);if(c)return c;if(E)return E(a);throw\"both async and sync fetching of the wasm failed\";}catch(d){K(d)}}\nfunction qa(){if(!J&&(x||y)){if(\"function\"===typeof fetch&&!W.startsWith(\"file://\"))return fetch(W,{credentials:\"same-origin\"}).then(function(a){if(!a.ok)throw\"failed to load wasm binary file at '\"+W+\"'\";return a.arrayBuffer()}).catch(function(){return pa()});if(D)return new Promise(function(a,c){D(W,function(d){a(new Uint8Array(d))},c)})}return Promise.resolve().then(function(){return pa()})}\nfunction X(a){for(;0>4;f=(f&15)<<4|l>>2;var t=(l&3)<<6|A;c+=String.fromCharCode(e);64!==l&&(c+=String.fromCharCode(f));64!==A&&(c+=String.fromCharCode(t))}while(d>>=0;if(2147483648=d;d*=2){var e=c*(1+.2/d);e=Math.min(e,a+100663296);e=Math.max(a,e);0>>16);ia();var f=1;break a}catch(l){}f=void 0}if(f)return!0}return!1}};\n(function(){function a(f){b.asm=f.exports;L=b.asm.b;ia();R=b.asm.j;ka.unshift(b.asm.c);S--;b.monitorRunDependencies&&b.monitorRunDependencies(S);0==S&&(null!==T&&(clearInterval(T),T=null),U&&(f=U,U=null,f()))}function c(f){a(f.instance)}function d(f){return qa().then(function(l){return WebAssembly.instantiate(l,e)}).then(f,function(l){I(\"failed to asynchronously prepare wasm: \"+l);K(l)})}var e={a:sa};S++;b.monitorRunDependencies&&b.monitorRunDependencies(S);if(b.instantiateWasm)try{return b.instantiateWasm(e,\na)}catch(f){return I(\"Module.instantiateWasm callback failed with error: \"+f),!1}(function(){return J||\"function\"!==typeof WebAssembly.instantiateStreaming||W.startsWith(V)||W.startsWith(\"file://\")||\"function\"!==typeof fetch?d(c):fetch(W,{credentials:\"same-origin\"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(c,function(l){I(\"wasm streaming compile failed: \"+l);I(\"falling back to ArrayBuffer instantiation\");return d(c)})})})().catch(r);return{}})();\nb.___wasm_call_ctors=function(){return(b.___wasm_call_ctors=b.asm.c).apply(null,arguments)};b._poly1305_auth=function(){return(b._poly1305_auth=b.asm.d).apply(null,arguments)};var da=b.stackSave=function(){return(da=b.stackSave=b.asm.e).apply(null,arguments)},fa=b.stackRestore=function(){return(fa=b.stackRestore=b.asm.f).apply(null,arguments)},O=b.stackAlloc=function(){return(O=b.stackAlloc=b.asm.g).apply(null,arguments)};b._malloc=function(){return(b._malloc=b.asm.h).apply(null,arguments)};\nb._free=function(){return(b._free=b.asm.i).apply(null,arguments)};b.cwrap=function(a,c,d,e){d=d||[];var f=d.every(function(l){return\"number\"===l});return\"string\"!==c&&f&&!e?N(a):function(){return ca(a,c,d,arguments)}};var Y;U=function ta(){Y||Z();Y||(U=ta)};\nfunction Z(){function a(){if(!Y&&(Y=!0,b.calledRun=!0,!M)){X(ka);q(b);if(b.onRuntimeInitialized)b.onRuntimeInitialized();if(b.postRun)for(\"function\"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var c=b.postRun.shift();la.unshift(c)}X(la)}}if(!(0 {\n // eslint-disable-next-line prefer-const\n for (let [type, handler] of Object.entries(handlers)) {\n type = +type;\n if (isFinite(type) && type >= 0 && type < MESSAGE_HANDLERS.length)\n MESSAGE_HANDLERS[type] = handler;\n }\n});\n\nmodule.exports = MESSAGE_HANDLERS;\n","'use strict';\n\nconst {\n bufferSlice,\n bufferParser,\n doFatalError,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst {\n CHANNEL_OPEN_FAILURE,\n COMPAT,\n MESSAGE,\n TERMINAL_MODE,\n} = require('./constants.js');\n\nconst {\n parseKey,\n} = require('./keyParser.js');\n\nconst TERMINAL_MODE_BY_VALUE =\n Array.from(Object.entries(TERMINAL_MODE))\n .reduce((obj, [key, value]) => ({ ...obj, [key]: value }), {});\n\nmodule.exports = {\n // Transport layer protocol ==================================================\n [MESSAGE.DISCONNECT]: (self, payload) => {\n /*\n byte SSH_MSG_DISCONNECT\n uint32 reason code\n string description in ISO-10646 UTF-8 encoding\n string language tag\n */\n bufferParser.init(payload, 1);\n const reason = bufferParser.readUInt32BE();\n const desc = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed DISCONNECT packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: Received DISCONNECT (${reason}, \"${desc}\")`\n );\n\n const handler = self._handlers.DISCONNECT;\n handler && handler(self, reason, desc);\n },\n [MESSAGE.IGNORE]: (self, payload) => {\n /*\n byte SSH_MSG_IGNORE\n string data\n */\n self._debug && self._debug('Inbound: Received IGNORE');\n },\n [MESSAGE.UNIMPLEMENTED]: (self, payload) => {\n /*\n byte SSH_MSG_UNIMPLEMENTED\n uint32 packet sequence number of rejected message\n */\n bufferParser.init(payload, 1);\n const seqno = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (seqno === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed UNIMPLEMENTED packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: Received UNIMPLEMENTED (seqno ${seqno})`);\n },\n [MESSAGE.DEBUG]: (self, payload) => {\n /*\n byte SSH_MSG_DEBUG\n boolean always_display\n string message in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const display = bufferParser.readBool();\n const msg = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed DEBUG packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received DEBUG');\n\n const handler = self._handlers.DEBUG;\n handler && handler(self, display, msg);\n },\n [MESSAGE.SERVICE_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_SERVICE_REQUEST\n string service name\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n bufferParser.clear();\n\n if (name === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed SERVICE_REQUEST packet'\n );\n }\n\n self._debug && self._debug(`Inbound: Received SERVICE_REQUEST (${name})`);\n\n const handler = self._handlers.SERVICE_REQUEST;\n handler && handler(self, name);\n },\n [MESSAGE.SERVICE_ACCEPT]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_SERVICE_ACCEPT\n string service name\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n bufferParser.clear();\n\n if (name === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed SERVICE_ACCEPT packet'\n );\n }\n\n self._debug && self._debug(`Inbound: Received SERVICE_ACCEPT (${name})`);\n\n const handler = self._handlers.SERVICE_ACCEPT;\n handler && handler(self, name);\n },\n\n // User auth protocol -- generic =============================================\n [MESSAGE.USERAUTH_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_USERAUTH_REQUEST\n string user name in ISO-10646 UTF-8 encoding [RFC3629]\n string service name in US-ASCII\n string method name in US-ASCII\n .... method specific fields\n */\n bufferParser.init(payload, 1);\n const user = bufferParser.readString(true);\n const service = bufferParser.readString(true);\n const method = bufferParser.readString(true);\n let methodData;\n let methodDesc;\n switch (method) {\n case 'none':\n methodData = null;\n break;\n case 'password': {\n /*\n boolean \n string plaintext password in ISO-10646 UTF-8 encoding [RFC3629]\n [string new password]\n */\n const isChange = bufferParser.readBool();\n if (isChange !== undefined) {\n methodData = bufferParser.readString(true);\n if (methodData !== undefined && isChange) {\n const newPassword = bufferParser.readString(true);\n if (newPassword !== undefined)\n methodData = { oldPassword: methodData, newPassword };\n else\n methodData = undefined;\n }\n }\n break;\n }\n case 'publickey': {\n /*\n boolean \n string public key algorithm name\n string public key blob\n [string signature]\n */\n const hasSig = bufferParser.readBool();\n if (hasSig !== undefined) {\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n if (hasSig) {\n const blobEnd = bufferParser.pos();\n let signature = bufferParser.readString();\n if (signature !== undefined) {\n if (signature.length > (4 + keyAlgo.length + 4)\n && signature.utf8Slice(4, 4 + keyAlgo.length) === keyAlgo) {\n // Skip algoLen + algo + sigLen\n signature = bufferSlice(signature, 4 + keyAlgo.length + 4);\n }\n\n signature = sigSSHToASN1(signature, keyAlgo);\n if (signature) {\n const sessionID = self._kex.sessionID;\n const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);\n writeUInt32BE(blob, sessionID.length, 0);\n blob.set(sessionID, 4);\n blob.set(\n new Uint8Array(payload.buffer, payload.byteOffset, blobEnd),\n 4 + sessionID.length\n );\n methodData = {\n keyAlgo,\n key,\n signature,\n blob,\n };\n }\n }\n } else {\n methodData = { keyAlgo, key };\n methodDesc = 'publickey -- check';\n }\n }\n break;\n }\n case 'hostbased': {\n /*\n string public key algorithm for host key\n string public host key and certificates for client host\n string client host name expressed as the FQDN in US-ASCII\n string user name on the client host in ISO-10646 UTF-8 encoding\n [RFC3629]\n string signature\n */\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n const localHostname = bufferParser.readString(true);\n const localUsername = bufferParser.readString(true);\n\n const blobEnd = bufferParser.pos();\n let signature = bufferParser.readString();\n if (signature !== undefined) {\n if (signature.length > (4 + keyAlgo.length + 4)\n && signature.utf8Slice(4, 4 + keyAlgo.length) === keyAlgo) {\n // Skip algoLen + algo + sigLen\n signature = bufferSlice(signature, 4 + keyAlgo.length + 4);\n }\n\n signature = sigSSHToASN1(signature, keyAlgo);\n if (signature !== undefined) {\n const sessionID = self._kex.sessionID;\n const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);\n writeUInt32BE(blob, sessionID.length, 0);\n blob.set(sessionID, 4);\n blob.set(\n new Uint8Array(payload.buffer, payload.byteOffset, blobEnd),\n 4 + sessionID.length\n );\n methodData = {\n keyAlgo,\n key,\n signature,\n blob,\n localHostname,\n localUsername,\n };\n }\n }\n break;\n }\n case 'keyboard-interactive':\n /*\n string language tag (as defined in [RFC-3066])\n string submethods (ISO-10646 UTF-8)\n */\n // Skip/ignore language field -- it's deprecated in RFC 4256\n bufferParser.skipString();\n\n methodData = bufferParser.readList();\n break;\n default:\n if (method !== undefined)\n methodData = bufferParser.readRaw();\n }\n bufferParser.clear();\n\n if (methodData === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_REQUEST packet'\n );\n }\n\n if (methodDesc === undefined)\n methodDesc = method;\n\n self._authsQueue.push(method);\n\n self._debug\n && self._debug(`Inbound: Received USERAUTH_REQUEST (${methodDesc})`);\n\n const handler = self._handlers.USERAUTH_REQUEST;\n handler && handler(self, user, service, method, methodData);\n },\n [MESSAGE.USERAUTH_FAILURE]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_FAILURE\n name-list authentications that can continue\n boolean partial success\n */\n bufferParser.init(payload, 1);\n const authMethods = bufferParser.readList();\n const partialSuccess = bufferParser.readBool();\n bufferParser.clear();\n\n if (partialSuccess === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_FAILURE packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: Received USERAUTH_FAILURE (${authMethods})`);\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_FAILURE;\n handler && handler(self, authMethods, partialSuccess);\n },\n [MESSAGE.USERAUTH_SUCCESS]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_SUCCESS\n */\n self._debug && self._debug('Inbound: Received USERAUTH_SUCCESS');\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_SUCCESS;\n handler && handler(self);\n },\n [MESSAGE.USERAUTH_BANNER]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_BANNER\n string message in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const msg = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_BANNER packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_BANNER');\n\n const handler = self._handlers.USERAUTH_BANNER;\n handler && handler(self, msg);\n },\n\n // User auth protocol -- method-specific =====================================\n 60: (self, payload) => {\n if (!self._authsQueue.length) {\n self._debug\n && self._debug('Inbound: Received payload type 60 without auth');\n return;\n }\n\n switch (self._authsQueue[0]) {\n case 'password': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_PASSWD_CHANGEREQ\n string prompt in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const prompt = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet'\n );\n }\n\n self._debug\n && self._debug('Inbound: Received USERAUTH_PASSWD_CHANGEREQ');\n\n const handler = self._handlers.USERAUTH_PASSWD_CHANGEREQ;\n handler && handler(self, prompt);\n break;\n }\n case 'publickey': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_PK_OK\n string public key algorithm name from the request\n string public key blob from the request\n */\n bufferParser.init(payload, 1);\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n bufferParser.clear();\n\n if (key === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_PK_OK packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_PK_OK');\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_PK_OK;\n handler && handler(self, keyAlgo, key);\n break;\n }\n case 'keyboard-interactive': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_INFO_REQUEST\n string name (ISO-10646 UTF-8)\n string instruction (ISO-10646 UTF-8)\n string language tag (as defined in [RFC-3066])\n int num-prompts\n string prompt[1] (ISO-10646 UTF-8)\n boolean echo[1]\n ...\n string prompt[num-prompts] (ISO-10646 UTF-8)\n boolean echo[num-prompts]\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n const instructions = bufferParser.readString(true);\n bufferParser.readString(); // skip lang\n const numPrompts = bufferParser.readUInt32BE();\n let prompts;\n if (numPrompts !== undefined) {\n prompts = new Array(numPrompts);\n let i;\n for (i = 0; i < numPrompts; ++i) {\n const prompt = bufferParser.readString(true);\n const echo = bufferParser.readBool();\n if (echo === undefined)\n break;\n prompts[i] = { prompt, echo };\n }\n if (i !== numPrompts)\n prompts = undefined;\n }\n bufferParser.clear();\n\n if (prompts === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_INFO_REQUEST packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_INFO_REQUEST');\n\n const handler = self._handlers.USERAUTH_INFO_REQUEST;\n handler && handler(self, name, instructions, prompts);\n break;\n }\n default:\n self._debug\n && self._debug('Inbound: Received unexpected payload type 60');\n }\n },\n 61: (self, payload) => {\n if (!self._authsQueue.length) {\n self._debug\n && self._debug('Inbound: Received payload type 61 without auth');\n return;\n }\n /*\n byte SSH_MSG_USERAUTH_INFO_RESPONSE\n int num-responses\n string response[1] (ISO-10646 UTF-8)\n ...\n string response[num-responses] (ISO-10646 UTF-8)\n */\n if (self._authsQueue[0] !== 'keyboard-interactive') {\n return doFatalError(\n self,\n 'Inbound: Received unexpected payload type 61'\n );\n }\n bufferParser.init(payload, 1);\n const numResponses = bufferParser.readUInt32BE();\n let responses;\n if (numResponses !== undefined) {\n responses = new Array(numResponses);\n let i;\n for (i = 0; i < numResponses; ++i) {\n const response = bufferParser.readString(true);\n if (response === undefined)\n break;\n responses[i] = response;\n }\n if (i !== numResponses)\n responses = undefined;\n }\n bufferParser.clear();\n\n if (responses === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_INFO_RESPONSE packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_INFO_RESPONSE');\n\n const handler = self._handlers.USERAUTH_INFO_RESPONSE;\n handler && handler(self, responses);\n },\n\n // Connection protocol -- generic ============================================\n [MESSAGE.GLOBAL_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_GLOBAL_REQUEST\n string request name in US-ASCII only\n boolean want reply\n .... request-specific data follows\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n const wantReply = bufferParser.readBool();\n let data;\n if (wantReply !== undefined) {\n switch (name) {\n case 'tcpip-forward':\n case 'cancel-tcpip-forward': {\n /*\n string address to bind (e.g., \"0.0.0.0\")\n uint32 port number to bind\n */\n const bindAddr = bufferParser.readString(true);\n const bindPort = bufferParser.readUInt32BE();\n if (bindPort !== undefined)\n data = { bindAddr, bindPort };\n break;\n }\n case 'streamlocal-forward@openssh.com':\n case 'cancel-streamlocal-forward@openssh.com': {\n /*\n string socket path\n */\n const socketPath = bufferParser.readString(true);\n if (socketPath !== undefined)\n data = { socketPath };\n break;\n }\n case 'no-more-sessions@openssh.com':\n data = null;\n break;\n case 'hostkeys-00@openssh.com': {\n data = [];\n while (bufferParser.avail() > 0) {\n const keyRaw = bufferParser.readString();\n if (keyRaw === undefined) {\n data = undefined;\n break;\n }\n const key = parseKey(keyRaw);\n if (!(key instanceof Error))\n data.push(key);\n }\n break;\n }\n default:\n data = bufferParser.readRaw();\n }\n }\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed GLOBAL_REQUEST packet'\n );\n }\n\n self._debug && self._debug(`Inbound: GLOBAL_REQUEST (${name})`);\n\n const handler = self._handlers.GLOBAL_REQUEST;\n if (handler)\n handler(self, name, wantReply, data);\n else\n self.requestFailure(); // Auto reject\n },\n [MESSAGE.REQUEST_SUCCESS]: (self, payload) => {\n /*\n byte SSH_MSG_REQUEST_SUCCESS\n .... response specific data\n */\n const data = (payload.length > 1 ? bufferSlice(payload, 1) : null);\n\n self._debug && self._debug('Inbound: REQUEST_SUCCESS');\n\n const handler = self._handlers.REQUEST_SUCCESS;\n handler && handler(self, data);\n },\n [MESSAGE.REQUEST_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_REQUEST_FAILURE\n */\n self._debug && self._debug('Inbound: Received REQUEST_FAILURE');\n\n const handler = self._handlers.REQUEST_FAILURE;\n handler && handler(self);\n },\n\n // Connection protocol -- channel-related ====================================\n [MESSAGE.CHANNEL_OPEN]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN\n string channel type in US-ASCII only\n uint32 sender channel\n uint32 initial window size\n uint32 maximum packet size\n .... channel type specific data follows\n */\n bufferParser.init(payload, 1);\n const type = bufferParser.readString(true);\n const sender = bufferParser.readUInt32BE();\n const window = bufferParser.readUInt32BE();\n const packetSize = bufferParser.readUInt32BE();\n let channelInfo;\n\n switch (type) {\n case 'forwarded-tcpip': // S->C\n case 'direct-tcpip': { // C->S\n /*\n string address that was connected / host to connect\n uint32 port that was connected / port to connect\n string originator IP address\n uint32 originator port\n */\n const destIP = bufferParser.readString(true);\n const destPort = bufferParser.readUInt32BE();\n const srcIP = bufferParser.readString(true);\n const srcPort = bufferParser.readUInt32BE();\n if (srcPort !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { destIP, destPort, srcIP, srcPort }\n };\n }\n break;\n }\n case 'forwarded-streamlocal@openssh.com': // S->C\n case 'direct-streamlocal@openssh.com': { // C->S\n /*\n string socket path\n string reserved for future use\n\n (direct-streamlocal@openssh.com additionally has:)\n uint32 reserved\n */\n const socketPath = bufferParser.readString(true);\n if (socketPath !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { socketPath }\n };\n }\n break;\n }\n case 'x11': { // S->C\n /*\n string originator address (e.g., \"192.168.7.38\")\n uint32 originator port\n */\n const srcIP = bufferParser.readString(true);\n const srcPort = bufferParser.readUInt32BE();\n if (srcPort !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { srcIP, srcPort }\n };\n }\n break;\n }\n default:\n // Includes:\n // 'session' (C->S)\n // 'auth-agent@openssh.com' (S->C)\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: {}\n };\n }\n bufferParser.clear();\n\n if (channelInfo === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_OPEN (s:${sender}, ${type})`);\n\n const handler = self._handlers.CHANNEL_OPEN;\n if (handler) {\n handler(self, channelInfo);\n } else {\n self.channelOpenFail(\n channelInfo.sender,\n CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED,\n '',\n ''\n );\n }\n },\n [MESSAGE.CHANNEL_OPEN_CONFIRMATION]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN_CONFIRMATION\n uint32 recipient channel\n uint32 sender channel\n uint32 initial window size\n uint32 maximum packet size\n .... channel type specific data follows\n */\n // \"The 'recipient channel' is the channel number given in the\n // original open request, and 'sender channel' is the channel number\n // allocated by the other side.\"\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const sender = bufferParser.readUInt32BE();\n const window = bufferParser.readUInt32BE();\n const packetSize = bufferParser.readUInt32BE();\n const data = (bufferParser.avail() ? bufferParser.readRaw() : undefined);\n bufferParser.clear();\n\n if (packetSize === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_OPEN_CONFIRMATION (r:${recipient}, s:${sender})`\n );\n\n const handler = self._handlers.CHANNEL_OPEN_CONFIRMATION;\n if (handler)\n handler(self, { recipient, sender, window, packetSize, data });\n },\n [MESSAGE.CHANNEL_OPEN_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN_FAILURE\n uint32 recipient channel\n uint32 reason code\n string description in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const reason = bufferParser.readUInt32BE();\n const description = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN_FAILURE packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_OPEN_FAILURE;\n handler && handler(self, recipient, reason, description);\n },\n [MESSAGE.CHANNEL_WINDOW_ADJUST]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_WINDOW_ADJUST\n uint32 recipient channel\n uint32 bytes to add\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const bytesToAdd = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (bytesToAdd === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_WINDOW_ADJUST packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_WINDOW_ADJUST (r:${recipient}, ${bytesToAdd})`\n );\n\n const handler = self._handlers.CHANNEL_WINDOW_ADJUST;\n handler && handler(self, recipient, bytesToAdd);\n },\n [MESSAGE.CHANNEL_DATA]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_DATA\n uint32 recipient channel\n string data\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_DATA packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: CHANNEL_DATA (r:${recipient}, ${data.length})`);\n\n const handler = self._handlers.CHANNEL_DATA;\n handler && handler(self, recipient, data);\n },\n [MESSAGE.CHANNEL_EXTENDED_DATA]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_EXTENDED_DATA\n uint32 recipient channel\n uint32 data_type_code\n string data\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const type = bufferParser.readUInt32BE();\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_EXTENDED_DATA packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_EXTENDED_DATA (r:${recipient}, ${data.length})`\n );\n\n const handler = self._handlers.CHANNEL_EXTENDED_DATA;\n handler && handler(self, recipient, data, type);\n },\n [MESSAGE.CHANNEL_EOF]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_EOF\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_EOF packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_EOF (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_EOF;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_CLOSE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_CLOSE\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_CLOSE packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_CLOSE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_CLOSE;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_REQUEST\n uint32 recipient channel\n string request type in US-ASCII characters only\n boolean want reply\n .... type-specific data follows\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const type = bufferParser.readString(true);\n const wantReply = bufferParser.readBool();\n let data;\n if (wantReply !== undefined) {\n switch (type) {\n case 'exit-status': // S->C\n /*\n uint32 exit_status\n */\n data = bufferParser.readUInt32BE();\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'exit-signal': { // S->C\n /*\n string signal name (without the \"SIG\" prefix)\n boolean core dumped\n string error message in ISO-10646 UTF-8 encoding\n string language tag\n */\n let signal;\n let coreDumped;\n if (self._compatFlags & COMPAT.OLD_EXIT) {\n /*\n Instead of `signal name` and `core dumped`, we have just:\n uint32 signal number\n */\n const num = bufferParser.readUInt32BE();\n switch (num) {\n case 1:\n signal = 'HUP';\n break;\n case 2:\n signal = 'INT';\n break;\n case 3:\n signal = 'QUIT';\n break;\n case 6:\n signal = 'ABRT';\n break;\n case 9:\n signal = 'KILL';\n break;\n case 14:\n signal = 'ALRM';\n break;\n case 15:\n signal = 'TERM';\n break;\n default:\n if (num !== undefined) {\n // Unknown or OS-specific\n signal = `UNKNOWN (${num})`;\n }\n }\n coreDumped = false;\n } else {\n signal = bufferParser.readString(true);\n coreDumped = bufferParser.readBool();\n if (coreDumped === undefined)\n signal = undefined;\n }\n const errorMessage = bufferParser.readString(true);\n if (bufferParser.skipString() !== undefined)\n data = { signal, coreDumped, errorMessage };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${signal})`\n );\n break;\n }\n case 'pty-req': { // C->S\n /*\n string TERM environment variable value (e.g., vt100)\n uint32 terminal width, characters (e.g., 80)\n uint32 terminal height, rows (e.g., 24)\n uint32 terminal width, pixels (e.g., 640)\n uint32 terminal height, pixels (e.g., 480)\n string encoded terminal modes\n */\n const term = bufferParser.readString(true);\n const cols = bufferParser.readUInt32BE();\n const rows = bufferParser.readUInt32BE();\n const width = bufferParser.readUInt32BE();\n const height = bufferParser.readUInt32BE();\n const modesBinary = bufferParser.readString();\n if (modesBinary !== undefined) {\n bufferParser.init(modesBinary, 1);\n let modes = {};\n while (bufferParser.avail()) {\n const opcode = bufferParser.readByte();\n if (opcode === TERMINAL_MODE.TTY_OP_END)\n break;\n const name = TERMINAL_MODE_BY_VALUE[opcode];\n const value = bufferParser.readUInt32BE();\n if (opcode === undefined\n || name === undefined\n || value === undefined) {\n modes = undefined;\n break;\n }\n modes[name] = value;\n }\n if (modes !== undefined)\n data = { term, cols, rows, width, height, modes };\n }\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'window-change': { // C->S\n /*\n uint32 terminal width, columns\n uint32 terminal height, rows\n uint32 terminal width, pixels\n uint32 terminal height, pixels\n */\n const cols = bufferParser.readUInt32BE();\n const rows = bufferParser.readUInt32BE();\n const width = bufferParser.readUInt32BE();\n const height = bufferParser.readUInt32BE();\n if (height !== undefined)\n data = { cols, rows, width, height };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'x11-req': { // C->S\n /*\n boolean single connection\n string x11 authentication protocol\n string x11 authentication cookie\n uint32 x11 screen number\n */\n const single = bufferParser.readBool();\n const protocol = bufferParser.readString(true);\n const cookie = bufferParser.readString();\n const screen = bufferParser.readUInt32BE();\n if (screen !== undefined)\n data = { single, protocol, cookie, screen };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'env': { // C->S\n /*\n string variable name\n string variable value\n */\n const name = bufferParser.readString(true);\n const value = bufferParser.readString(true);\n if (value !== undefined)\n data = { name, value };\n if (self._debug) {\n self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: `\n + `${name}=${value})`\n );\n }\n break;\n }\n case 'shell': // C->S\n data = null; // No extra data\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n case 'exec': // C->S\n /*\n string command\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'subsystem': // C->S\n /*\n string subsystem name\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'signal': // C->S\n /*\n string signal name (without the \"SIG\" prefix)\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'xon-xoff': // C->S\n /*\n boolean client can do\n */\n data = bufferParser.readBool();\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'auth-agent-req@openssh.com': // C-S\n data = null; // No extra data\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n default:\n data = (bufferParser.avail() ? bufferParser.readRaw() : null);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n }\n }\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_REQUEST packet'\n );\n }\n\n const handler = self._handlers.CHANNEL_REQUEST;\n handler && handler(self, recipient, type, wantReply, data);\n },\n [MESSAGE.CHANNEL_SUCCESS]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_SUCCESS\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_SUCCESS packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_SUCCESS (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_SUCCESS;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_FAILURE\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_FAILURE packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_FAILURE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_FAILURE;\n handler && handler(self, recipient);\n },\n};\n","'use strict';\n\nconst {\n createDiffieHellman,\n createDiffieHellmanGroup,\n createECDH,\n createHash,\n createPublicKey,\n diffieHellman,\n generateKeyPairSync,\n randomFillSync,\n} = require('crypto');\n\nconst { Ber } = require('asn1');\n\nconst {\n COMPAT,\n curve25519Supported,\n DEFAULT_KEX,\n DEFAULT_SERVER_HOST_KEY,\n DEFAULT_CIPHER,\n DEFAULT_MAC,\n DEFAULT_COMPRESSION,\n DISCONNECT_REASON,\n MESSAGE,\n} = require('./constants.js');\nconst {\n CIPHER_INFO,\n createCipher,\n createDecipher,\n MAC_INFO,\n} = require('./crypto.js');\nconst { parseDERKey } = require('./keyParser.js');\nconst {\n bufferFill,\n bufferParser,\n convertSignature,\n doFatalError,\n FastBuffer,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./utils.js');\nconst {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n} = require('./zlib.js');\n\nlet MESSAGE_HANDLERS;\n\nconst GEX_MIN_BITS = 2048; // RFC 8270\nconst GEX_MAX_BITS = 8192; // RFC 8270\n\nconst EMPTY_BUFFER = Buffer.alloc(0);\n\n// Client/Server\nfunction kexinit(self) {\n /*\n byte SSH_MSG_KEXINIT\n byte[16] cookie (random bytes)\n name-list kex_algorithms\n name-list server_host_key_algorithms\n name-list encryption_algorithms_client_to_server\n name-list encryption_algorithms_server_to_client\n name-list mac_algorithms_client_to_server\n name-list mac_algorithms_server_to_client\n name-list compression_algorithms_client_to_server\n name-list compression_algorithms_server_to_client\n name-list languages_client_to_server\n name-list languages_server_to_client\n boolean first_kex_packet_follows\n uint32 0 (reserved for future extension)\n */\n\n let payload;\n if (self._compatFlags & COMPAT.BAD_DHGEX) {\n const entry = self._offer.lists.kex;\n let kex = entry.array;\n let found = false;\n for (let i = 0; i < kex.length; ++i) {\n if (kex[i].includes('group-exchange')) {\n if (!found) {\n found = true;\n // Copy array lazily\n kex = kex.slice();\n }\n kex.splice(i--, 1);\n }\n }\n if (found) {\n let len = 1 + 16 + self._offer.totalSize + 1 + 4;\n const newKexBuf = Buffer.from(kex.join(','));\n len -= (entry.buffer.length - newKexBuf.length);\n\n const all = self._offer.lists.all;\n const rest = new Uint8Array(\n all.buffer,\n all.byteOffset + 4 + entry.buffer.length,\n all.length - (4 + entry.buffer.length)\n );\n\n payload = Buffer.allocUnsafe(len);\n writeUInt32BE(payload, newKexBuf.length, 17);\n payload.set(newKexBuf, 17 + 4);\n payload.set(rest, 17 + 4 + newKexBuf.length);\n }\n }\n\n if (payload === undefined) {\n payload = Buffer.allocUnsafe(1 + 16 + self._offer.totalSize + 1 + 4);\n self._offer.copyAllTo(payload, 17);\n }\n\n self._debug && self._debug('Outbound: Sending KEXINIT');\n\n payload[0] = MESSAGE.KEXINIT;\n randomFillSync(payload, 1, 16);\n\n // Zero-fill first_kex_packet_follows and reserved bytes\n bufferFill(payload, 0, payload.length - 5);\n\n self._kexinit = payload;\n\n // Needed to correct the starting position in allocated \"packets\" when packets\n // will be buffered due to active key exchange\n self._packetRW.write.allocStart = 0;\n\n // TODO: only create single buffer and set _kexinit as slice of packet instead\n {\n const p = self._packetRW.write.allocStartKEX;\n const packet = self._packetRW.write.alloc(payload.length, true);\n packet.set(payload, p);\n self._cipher.encrypt(self._packetRW.write.finalize(packet, true));\n }\n}\n\nfunction handleKexInit(self, payload) {\n /*\n byte SSH_MSG_KEXINIT\n byte[16] cookie (random bytes)\n name-list kex_algorithms\n name-list server_host_key_algorithms\n name-list encryption_algorithms_client_to_server\n name-list encryption_algorithms_server_to_client\n name-list mac_algorithms_client_to_server\n name-list mac_algorithms_server_to_client\n name-list compression_algorithms_client_to_server\n name-list compression_algorithms_server_to_client\n name-list languages_client_to_server\n name-list languages_server_to_client\n boolean first_kex_packet_follows\n uint32 0 (reserved for future extension)\n */\n const init = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n sc: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n };\n\n bufferParser.init(payload, 17);\n\n if ((init.kex = bufferParser.readList()) === undefined\n || (init.serverHostKey = bufferParser.readList()) === undefined\n || (init.cs.cipher = bufferParser.readList()) === undefined\n || (init.sc.cipher = bufferParser.readList()) === undefined\n || (init.cs.mac = bufferParser.readList()) === undefined\n || (init.sc.mac = bufferParser.readList()) === undefined\n || (init.cs.compress = bufferParser.readList()) === undefined\n || (init.sc.compress = bufferParser.readList()) === undefined\n || (init.cs.lang = bufferParser.readList()) === undefined\n || (init.sc.lang = bufferParser.readList()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n self,\n 'Received malformed KEXINIT',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n const pos = bufferParser.pos();\n const firstFollows = (pos < payload.length && payload[pos] === 1);\n bufferParser.clear();\n\n const local = self._offer;\n const remote = init;\n\n let localKex = local.lists.kex.array;\n if (self._compatFlags & COMPAT.BAD_DHGEX) {\n let found = false;\n for (let i = 0; i < localKex.length; ++i) {\n if (localKex[i].indexOf('group-exchange') !== -1) {\n if (!found) {\n found = true;\n // Copy array lazily\n localKex = localKex.slice();\n }\n localKex.splice(i--, 1);\n }\n }\n }\n\n let clientList;\n let serverList;\n let i;\n const debug = self._debug;\n\n debug && debug('Inbound: Handshake in progress');\n\n // Key exchange method =======================================================\n debug && debug(`Handshake: (local) KEX method: ${localKex}`);\n debug && debug(`Handshake: (remote) KEX method: ${remote.kex}`);\n if (self._server) {\n serverList = localKex;\n clientList = remote.kex;\n } else {\n serverList = remote.kex;\n clientList = localKex;\n }\n // Check for agreeable key exchange algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching key exchange algorithm');\n return doFatalError(\n self,\n 'Handshake failed: no matching key exchange algorithm',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.kex = clientList[i];\n debug && debug(`Handshake: KEX algorithm: ${clientList[i]}`);\n if (firstFollows && (!remote.kex.length || clientList[i] !== remote.kex[0])) {\n // Ignore next inbound packet, it was a wrong first guess at KEX algorithm\n self._skipNextInboundPacket = true;\n }\n\n\n // Server host key format ====================================================\n const localSrvHostKey = local.lists.serverHostKey.array;\n debug && debug(`Handshake: (local) Host key format: ${localSrvHostKey}`);\n debug && debug(\n `Handshake: (remote) Host key format: ${remote.serverHostKey}`\n );\n if (self._server) {\n serverList = localSrvHostKey;\n clientList = remote.serverHostKey;\n } else {\n serverList = remote.serverHostKey;\n clientList = localSrvHostKey;\n }\n // Check for agreeable server host key format\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching host key format');\n return doFatalError(\n self,\n 'Handshake failed: no matching host key format',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.serverHostKey = clientList[i];\n debug && debug(`Handshake: Host key format: ${clientList[i]}`);\n\n\n // Client->Server cipher =====================================================\n const localCSCipher = local.lists.cs.cipher.array;\n debug && debug(`Handshake: (local) C->S cipher: ${localCSCipher}`);\n debug && debug(`Handshake: (remote) C->S cipher: ${remote.cs.cipher}`);\n if (self._server) {\n serverList = localCSCipher;\n clientList = remote.cs.cipher;\n } else {\n serverList = remote.cs.cipher;\n clientList = localCSCipher;\n }\n // Check for agreeable client->server cipher\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S cipher');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S cipher',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.cipher = clientList[i];\n debug && debug(`Handshake: C->S Cipher: ${clientList[i]}`);\n\n\n // Server->Client cipher =====================================================\n const localSCCipher = local.lists.sc.cipher.array;\n debug && debug(`Handshake: (local) S->C cipher: ${localSCCipher}`);\n debug && debug(`Handshake: (remote) S->C cipher: ${remote.sc.cipher}`);\n if (self._server) {\n serverList = localSCCipher;\n clientList = remote.sc.cipher;\n } else {\n serverList = remote.sc.cipher;\n clientList = localSCCipher;\n }\n // Check for agreeable server->client cipher\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C cipher');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C cipher',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.cipher = clientList[i];\n debug && debug(`Handshake: S->C cipher: ${clientList[i]}`);\n\n\n // Client->Server MAC ========================================================\n const localCSMAC = local.lists.cs.mac.array;\n debug && debug(`Handshake: (local) C->S MAC: ${localCSMAC}`);\n debug && debug(`Handshake: (remote) C->S MAC: ${remote.cs.mac}`);\n if (CIPHER_INFO[init.cs.cipher].authLen > 0) {\n init.cs.mac = '';\n debug && debug('Handshake: C->S MAC: ');\n } else {\n if (self._server) {\n serverList = localCSMAC;\n clientList = remote.cs.mac;\n } else {\n serverList = remote.cs.mac;\n clientList = localCSMAC;\n }\n // Check for agreeable client->server hmac algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S MAC');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S MAC',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.mac = clientList[i];\n debug && debug(`Handshake: C->S MAC: ${clientList[i]}`);\n }\n\n\n // Server->Client MAC ========================================================\n const localSCMAC = local.lists.sc.mac.array;\n debug && debug(`Handshake: (local) S->C MAC: ${localSCMAC}`);\n debug && debug(`Handshake: (remote) S->C MAC: ${remote.sc.mac}`);\n if (CIPHER_INFO[init.sc.cipher].authLen > 0) {\n init.sc.mac = '';\n debug && debug('Handshake: S->C MAC: ');\n } else {\n if (self._server) {\n serverList = localSCMAC;\n clientList = remote.sc.mac;\n } else {\n serverList = remote.sc.mac;\n clientList = localSCMAC;\n }\n // Check for agreeable server->client hmac algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C MAC');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C MAC',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.mac = clientList[i];\n debug && debug(`Handshake: S->C MAC: ${clientList[i]}`);\n }\n\n\n // Client->Server compression ================================================\n const localCSCompress = local.lists.cs.compress.array;\n debug && debug(`Handshake: (local) C->S compression: ${localCSCompress}`);\n debug && debug(`Handshake: (remote) C->S compression: ${remote.cs.compress}`);\n if (self._server) {\n serverList = localCSCompress;\n clientList = remote.cs.compress;\n } else {\n serverList = remote.cs.compress;\n clientList = localCSCompress;\n }\n // Check for agreeable client->server compression algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S compression');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S compression',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.compress = clientList[i];\n debug && debug(`Handshake: C->S compression: ${clientList[i]}`);\n\n\n // Server->Client compression ================================================\n const localSCCompress = local.lists.sc.compress.array;\n debug && debug(`Handshake: (local) S->C compression: ${localSCCompress}`);\n debug && debug(`Handshake: (remote) S->C compression: ${remote.sc.compress}`);\n if (self._server) {\n serverList = localSCCompress;\n clientList = remote.sc.compress;\n } else {\n serverList = remote.sc.compress;\n clientList = localSCCompress;\n }\n // Check for agreeable server->client compression algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C compression');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C compression',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.compress = clientList[i];\n debug && debug(`Handshake: S->C compression: ${clientList[i]}`);\n\n init.cs.lang = '';\n init.sc.lang = '';\n\n // XXX: hack -- find a better way to do this\n if (self._kex) {\n if (!self._kexinit) {\n // We received a rekey request, but we haven't sent a KEXINIT in response\n // yet\n kexinit(self);\n }\n self._decipher._onPayload = onKEXPayload.bind(self, { firstPacket: false });\n }\n\n self._kex = createKeyExchange(init, self, payload);\n self._kex.start();\n}\n\nconst createKeyExchange = (() => {\n function convertToMpint(buf) {\n let idx = 0;\n let length = buf.length;\n while (buf[idx] === 0x00) {\n ++idx;\n --length;\n }\n let newBuf;\n if (buf[idx] & 0x80) {\n newBuf = Buffer.allocUnsafe(1 + length);\n newBuf[0] = 0;\n buf.copy(newBuf, 1, idx);\n buf = newBuf;\n } else if (length !== buf.length) {\n newBuf = Buffer.allocUnsafe(length);\n buf.copy(newBuf, 0, idx);\n buf = newBuf;\n }\n return buf;\n }\n\n class KeyExchange {\n constructor(negotiated, protocol, remoteKexinit) {\n this._protocol = protocol;\n\n this.sessionID = (protocol._kex ? protocol._kex.sessionID : undefined);\n this.negotiated = negotiated;\n this._step = 1;\n this._public = null;\n this._dh = null;\n this._sentNEWKEYS = false;\n this._receivedNEWKEYS = false;\n this._finished = false;\n this._hostVerified = false;\n\n // Data needed for initializing cipher/decipher/etc.\n this._kexinit = protocol._kexinit;\n this._remoteKexinit = remoteKexinit;\n this._identRaw = protocol._identRaw;\n this._remoteIdentRaw = protocol._remoteIdentRaw;\n this._hostKey = undefined;\n this._dhData = undefined;\n this._sig = undefined;\n }\n finish() {\n if (this._finished)\n return false;\n this._finished = true;\n\n const isServer = this._protocol._server;\n const negotiated = this.negotiated;\n\n const pubKey = this.convertPublicKey(this._dhData);\n let secret = this.computeSecret(this._dhData);\n if (secret instanceof Error) {\n secret.message =\n `Error while computing DH secret (${this.type}): ${secret.message}`;\n secret.level = 'handshake';\n return doFatalError(\n this._protocol,\n secret,\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n const hash = createHash(this.hashName);\n // V_C\n hashString(hash, (isServer ? this._remoteIdentRaw : this._identRaw));\n // \"V_S\"\n hashString(hash, (isServer ? this._identRaw : this._remoteIdentRaw));\n // \"I_C\"\n hashString(hash, (isServer ? this._remoteKexinit : this._kexinit));\n // \"I_S\"\n hashString(hash, (isServer ? this._kexinit : this._remoteKexinit));\n // \"K_S\"\n const serverPublicHostKey = (isServer\n ? this._hostKey.getPublicSSH()\n : this._hostKey);\n hashString(hash, serverPublicHostKey);\n\n if (this.type === 'groupex') {\n // Group exchange-specific\n const params = this.getDHParams();\n const num = Buffer.allocUnsafe(4);\n // min (uint32)\n writeUInt32BE(num, this._minBits, 0);\n hash.update(num);\n // preferred (uint32)\n writeUInt32BE(num, this._prefBits, 0);\n hash.update(num);\n // max (uint32)\n writeUInt32BE(num, this._maxBits, 0);\n hash.update(num);\n // prime\n hashString(hash, params.prime);\n // generator\n hashString(hash, params.generator);\n }\n\n // method-specific data sent by client\n hashString(hash, (isServer ? pubKey : this.getPublicKey()));\n // method-specific data sent by server\n const serverPublicKey = (isServer ? this.getPublicKey() : pubKey);\n hashString(hash, serverPublicKey);\n // shared secret (\"K\")\n hashString(hash, secret);\n\n // \"H\"\n const exchangeHash = hash.digest();\n\n if (!isServer) {\n bufferParser.init(this._sig, 0);\n const sigType = bufferParser.readString(true);\n\n if (!sigType) {\n return doFatalError(\n this._protocol,\n 'Malformed packet while reading signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (sigType !== negotiated.serverHostKey) {\n return doFatalError(\n this._protocol,\n `Wrong signature type: ${sigType}, `\n + `expected: ${negotiated.serverHostKey}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // \"s\"\n let sigValue = bufferParser.readString();\n\n bufferParser.clear();\n\n if (sigValue === undefined) {\n return doFatalError(\n this._protocol,\n 'Malformed packet while reading signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (!(sigValue = sigSSHToASN1(sigValue, sigType))) {\n return doFatalError(\n this._protocol,\n 'Malformed signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n let parsedHostKey;\n {\n bufferParser.init(this._hostKey, 0);\n const name = bufferParser.readString(true);\n const hostKey = this._hostKey.slice(bufferParser.pos());\n bufferParser.clear();\n parsedHostKey = parseDERKey(hostKey, name);\n if (parsedHostKey instanceof Error) {\n parsedHostKey.level = 'handshake';\n return doFatalError(\n this._protocol,\n parsedHostKey,\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n let hashAlgo;\n // Check if we need to override the default hash algorithm\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256': hashAlgo = 'sha256'; break;\n case 'rsa-sha2-512': hashAlgo = 'sha512'; break;\n }\n\n this._protocol._debug\n && this._protocol._debug('Verifying signature ...');\n\n const verified = parsedHostKey.verify(exchangeHash, sigValue, hashAlgo);\n if (verified !== true) {\n if (verified instanceof Error) {\n this._protocol._debug && this._protocol._debug(\n `Signature verification failed: ${verified.stack}`\n );\n } else {\n this._protocol._debug && this._protocol._debug(\n 'Signature verification failed'\n );\n }\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature verification failed',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug('Verified signature');\n } else {\n // Server\n\n let hashAlgo;\n // Check if we need to override the default hash algorithm\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256': hashAlgo = 'sha256'; break;\n case 'rsa-sha2-512': hashAlgo = 'sha512'; break;\n }\n\n this._protocol._debug && this._protocol._debug(\n 'Generating signature ...'\n );\n\n let signature = this._hostKey.sign(exchangeHash, hashAlgo);\n if (signature instanceof Error) {\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature generation failed for '\n + `${this._hostKey.type} host key: ${signature.message}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n signature = convertSignature(signature, this._hostKey.type);\n if (signature === false) {\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature conversion failed for '\n + `${this._hostKey.type} host key`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // Send KEX reply\n /*\n byte SSH_MSG_KEXDH_REPLY\n / SSH_MSG_KEX_DH_GEX_REPLY\n / SSH_MSG_KEX_ECDH_REPLY\n string server public host key and certificates (K_S)\n string \n string signature of H\n */\n const sigType = this.negotiated.serverHostKey;\n const sigTypeLen = Buffer.byteLength(sigType);\n const sigLen = 4 + sigTypeLen + 4 + signature.length;\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1\n + 4 + serverPublicHostKey.length\n + 4 + serverPublicKey.length\n + 4 + sigLen,\n true\n );\n\n packet[p] = MESSAGE.KEXDH_REPLY;\n\n writeUInt32BE(packet, serverPublicHostKey.length, ++p);\n packet.set(serverPublicHostKey, p += 4);\n\n writeUInt32BE(packet,\n serverPublicKey.length,\n p += serverPublicHostKey.length);\n packet.set(serverPublicKey, p += 4);\n\n writeUInt32BE(packet, sigLen, p += serverPublicKey.length);\n\n writeUInt32BE(packet, sigTypeLen, p += 4);\n packet.utf8Write(sigType, p += 4, sigTypeLen);\n\n writeUInt32BE(packet, signature.length, p += sigTypeLen);\n packet.set(signature, p += 4);\n\n if (this._protocol._debug) {\n let type;\n switch (this.type) {\n case 'group':\n type = 'KEXDH_REPLY';\n break;\n case 'groupex':\n type = 'KEXDH_GEX_REPLY';\n break;\n default:\n type = 'KEXECDH_REPLY';\n }\n this._protocol._debug(`Outbound: Sending ${type}`);\n }\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n trySendNEWKEYS(this);\n\n const completeHandshake = () => {\n if (!this.sessionID)\n this.sessionID = exchangeHash;\n\n {\n const newSecret = Buffer.allocUnsafe(4 + secret.length);\n writeUInt32BE(newSecret, secret.length, 0);\n newSecret.set(secret, 4);\n secret = newSecret;\n }\n\n // Initialize new ciphers, deciphers, etc.\n\n const csCipherInfo = CIPHER_INFO[negotiated.cs.cipher];\n const scCipherInfo = CIPHER_INFO[negotiated.sc.cipher];\n\n const csIV = generateKEXVal(csCipherInfo.ivLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'A');\n const scIV = generateKEXVal(scCipherInfo.ivLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'B');\n const csKey = generateKEXVal(csCipherInfo.keyLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'C');\n const scKey = generateKEXVal(scCipherInfo.keyLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'D');\n let csMacInfo;\n let csMacKey;\n if (!csCipherInfo.authLen) {\n csMacInfo = MAC_INFO[negotiated.cs.mac];\n csMacKey = generateKEXVal(csMacInfo.len,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'E');\n }\n let scMacInfo;\n let scMacKey;\n if (!scCipherInfo.authLen) {\n scMacInfo = MAC_INFO[negotiated.sc.mac];\n scMacKey = generateKEXVal(scMacInfo.len,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'F');\n }\n\n const config = {\n inbound: {\n onPayload: this._protocol._onPayload,\n seqno: this._protocol._decipher.inSeqno,\n decipherInfo: (!isServer ? scCipherInfo : csCipherInfo),\n decipherIV: (!isServer ? scIV : csIV),\n decipherKey: (!isServer ? scKey : csKey),\n macInfo: (!isServer ? scMacInfo : csMacInfo),\n macKey: (!isServer ? scMacKey : csMacKey),\n },\n outbound: {\n onWrite: this._protocol._onWrite,\n seqno: this._protocol._cipher.outSeqno,\n cipherInfo: (isServer ? scCipherInfo : csCipherInfo),\n cipherIV: (isServer ? scIV : csIV),\n cipherKey: (isServer ? scKey : csKey),\n macInfo: (isServer ? scMacInfo : csMacInfo),\n macKey: (isServer ? scMacKey : csMacKey),\n },\n };\n this._protocol._cipher && this._protocol._cipher.free();\n this._protocol._decipher && this._protocol._decipher.free();\n this._protocol._cipher = createCipher(config);\n this._protocol._decipher = createDecipher(config);\n\n const rw = {\n read: undefined,\n write: undefined,\n };\n switch (negotiated.cs.compress) {\n case 'zlib': // starts immediately\n if (isServer)\n rw.read = new ZlibPacketReader();\n else\n rw.write = new ZlibPacketWriter(this._protocol);\n break;\n case 'zlib@openssh.com':\n // Starts after successful user authentication\n\n if (this._protocol._authenticated) {\n // If a rekey happens and this compression method is selected and\n // we already authenticated successfully, we need to start\n // immediately instead\n if (isServer)\n rw.read = new ZlibPacketReader();\n else\n rw.write = new ZlibPacketWriter(this._protocol);\n break;\n }\n // FALLTHROUGH\n default:\n // none -- never any compression/decompression\n\n if (isServer)\n rw.read = new PacketReader();\n else\n rw.write = new PacketWriter(this._protocol);\n }\n switch (negotiated.sc.compress) {\n case 'zlib': // starts immediately\n if (isServer)\n rw.write = new ZlibPacketWriter(this._protocol);\n else\n rw.read = new ZlibPacketReader();\n break;\n case 'zlib@openssh.com':\n // Starts after successful user authentication\n\n if (this._protocol._authenticated) {\n // If a rekey happens and this compression method is selected and\n // we already authenticated successfully, we need to start\n // immediately instead\n if (isServer)\n rw.write = new ZlibPacketWriter(this._protocol);\n else\n rw.read = new ZlibPacketReader();\n break;\n }\n // FALLTHROUGH\n default:\n // none -- never any compression/decompression\n\n if (isServer)\n rw.write = new PacketWriter(this._protocol);\n else\n rw.read = new PacketReader();\n }\n this._protocol._packetRW.read.cleanup();\n this._protocol._packetRW.write.cleanup();\n this._protocol._packetRW = rw;\n\n // Cleanup/reset various state\n this._public = null;\n this._dh = null;\n this._kexinit = this._protocol._kexinit = undefined;\n this._remoteKexinit = undefined;\n this._identRaw = undefined;\n this._remoteIdentRaw = undefined;\n this._hostKey = undefined;\n this._dhData = undefined;\n this._sig = undefined;\n\n this._protocol._onHandshakeComplete(negotiated);\n\n return false;\n };\n if (!isServer)\n return completeHandshake();\n this.finish = completeHandshake;\n }\n\n start() {\n if (!this._protocol._server) {\n if (this._protocol._debug) {\n let type;\n switch (this.type) {\n case 'group':\n type = 'KEXDH_INIT';\n break;\n default:\n type = 'KEXECDH_INIT';\n }\n this._protocol._debug(`Outbound: Sending ${type}`);\n }\n\n const pubKey = this.getPublicKey();\n\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1 + 4 + pubKey.length,\n true\n );\n packet[p] = MESSAGE.KEXDH_INIT;\n writeUInt32BE(packet, pubKey.length, ++p);\n packet.set(pubKey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n }\n getPublicKey() {\n this.generateKeys();\n\n const key = this._public;\n\n if (key)\n return this.convertPublicKey(key);\n }\n convertPublicKey(key) {\n let newKey;\n let idx = 0;\n let len = key.length;\n while (key[idx] === 0x00) {\n ++idx;\n --len;\n }\n\n if (key[idx] & 0x80) {\n newKey = Buffer.allocUnsafe(1 + len);\n newKey[0] = 0;\n key.copy(newKey, 1, idx);\n return newKey;\n }\n\n if (len !== key.length) {\n newKey = Buffer.allocUnsafe(len);\n key.copy(newKey, 0, idx);\n key = newKey;\n }\n return key;\n }\n computeSecret(otherPublicKey) {\n this.generateKeys();\n\n try {\n return convertToMpint(this._dh.computeSecret(otherPublicKey));\n } catch (ex) {\n return ex;\n }\n }\n parse(payload) {\n const type = payload[0];\n switch (this._step) {\n case 1:\n if (this._protocol._server) {\n // Server\n if (type !== MESSAGE.KEXDH_INIT) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_INIT}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH Init'\n );\n /*\n byte SSH_MSG_KEXDH_INIT\n / SSH_MSG_KEX_ECDH_INIT\n string \n */\n bufferParser.init(payload, 1);\n const dhData = bufferParser.readString();\n bufferParser.clear();\n if (dhData === undefined) {\n return doFatalError(\n this._protocol,\n 'Received malformed KEX*_INIT',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // Client public key\n this._dhData = dhData;\n\n let hostKey =\n this._protocol._hostKeys[this.negotiated.serverHostKey];\n if (Array.isArray(hostKey))\n hostKey = hostKey[0];\n this._hostKey = hostKey;\n\n this.finish();\n } else {\n // Client\n if (type !== MESSAGE.KEXDH_REPLY) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_REPLY}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH Reply'\n );\n /*\n byte SSH_MSG_KEXDH_REPLY\n / SSH_MSG_KEX_DH_GEX_REPLY\n / SSH_MSG_KEX_ECDH_REPLY\n string server public host key and certificates (K_S)\n string \n string signature of H\n */\n bufferParser.init(payload, 1);\n let hostPubKey;\n let dhData;\n let sig;\n if ((hostPubKey = bufferParser.readString()) === undefined\n || (dhData = bufferParser.readString()) === undefined\n || (sig = bufferParser.readString()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n this._protocol,\n 'Received malformed KEX*_REPLY',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n bufferParser.clear();\n\n // Check that the host public key type matches what was negotiated\n // during KEXINIT swap\n bufferParser.init(hostPubKey, 0);\n const hostPubKeyType = bufferParser.readString(true);\n bufferParser.clear();\n if (hostPubKeyType === undefined) {\n return doFatalError(\n this._protocol,\n 'Received malformed host public key',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n if (hostPubKeyType !== this.negotiated.serverHostKey) {\n // Check if we need to make an exception\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256':\n case 'rsa-sha2-512':\n if (hostPubKeyType === 'ssh-rsa')\n break;\n // FALLTHROUGH\n default:\n return doFatalError(\n this._protocol,\n 'Host key does not match negotiated type',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n this._hostKey = hostPubKey;\n this._dhData = dhData;\n this._sig = sig;\n\n let checked = false;\n let ret;\n if (this._protocol._hostVerifier === undefined) {\n ret = true;\n this._protocol._debug && this._protocol._debug(\n 'Host accepted by default (no verification)'\n );\n } else {\n ret = this._protocol._hostVerifier(hostPubKey, (permitted) => {\n if (checked)\n return;\n checked = true;\n if (permitted === false) {\n this._protocol._debug && this._protocol._debug(\n 'Host denied (verification failed)'\n );\n return doFatalError(\n this._protocol,\n 'Host denied (verification failed)',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Host accepted (verified)'\n );\n this._hostVerified = true;\n if (this._receivedNEWKEYS)\n this.finish();\n else\n trySendNEWKEYS(this);\n });\n }\n if (ret === undefined) {\n // Async host verification\n ++this._step;\n return;\n }\n checked = true;\n if (ret === false) {\n this._protocol._debug && this._protocol._debug(\n 'Host denied (verification failed)'\n );\n return doFatalError(\n this._protocol,\n 'Host denied (verification failed)',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Host accepted (verified)'\n );\n this._hostVerified = true;\n trySendNEWKEYS(this);\n }\n ++this._step;\n break;\n case 2:\n if (type !== MESSAGE.NEWKEYS) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.NEWKEYS}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Inbound: NEWKEYS'\n );\n this._receivedNEWKEYS = true;\n ++this._step;\n if (this._protocol._server || this._hostVerified)\n return this.finish();\n\n // Signal to current decipher that we need to change to a new decipher\n // for the next packet\n return false;\n default:\n return doFatalError(\n this._protocol,\n `Received unexpected packet ${type} after NEWKEYS`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n }\n\n class Curve25519Exchange extends KeyExchange {\n constructor(hashName, ...args) {\n super(...args);\n\n this.type = '25519';\n this.hashName = hashName;\n this._keys = null;\n }\n generateKeys() {\n if (!this._keys)\n this._keys = generateKeyPairSync('x25519');\n }\n getPublicKey() {\n this.generateKeys();\n\n const key = this._keys.publicKey.export({ type: 'spki', format: 'der' });\n return key.slice(-32); // HACK: avoids parsing DER/BER header\n }\n convertPublicKey(key) {\n let newKey;\n let idx = 0;\n let len = key.length;\n while (key[idx] === 0x00) {\n ++idx;\n --len;\n }\n\n if (key.length === 32)\n return key;\n\n if (len !== key.length) {\n newKey = Buffer.allocUnsafe(len);\n key.copy(newKey, 0, idx);\n key = newKey;\n }\n return key;\n }\n computeSecret(otherPublicKey) {\n this.generateKeys();\n\n try {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.110'); // id-X25519\n asnWriter.endSequence();\n\n // PublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(otherPublicKey.length);\n otherPublicKey.copy(asnWriter._buf,\n asnWriter._offset,\n 0,\n otherPublicKey.length);\n asnWriter._offset += otherPublicKey.length;\n asnWriter.endSequence();\n asnWriter.endSequence();\n\n return convertToMpint(diffieHellman({\n privateKey: this._keys.privateKey,\n publicKey: createPublicKey({\n key: asnWriter.buffer,\n type: 'spki',\n format: 'der',\n }),\n }));\n } catch (ex) {\n return ex;\n }\n }\n }\n\n class ECDHExchange extends KeyExchange {\n constructor(curveName, hashName, ...args) {\n super(...args);\n\n this.type = 'ecdh';\n this.curveName = curveName;\n this.hashName = hashName;\n }\n generateKeys() {\n if (!this._dh) {\n this._dh = createECDH(this.curveName);\n this._public = this._dh.generateKeys();\n }\n }\n }\n\n class DHGroupExchange extends KeyExchange {\n constructor(hashName, ...args) {\n super(...args);\n\n this.type = 'groupex';\n this.hashName = hashName;\n this._prime = null;\n this._generator = null;\n this._minBits = GEX_MIN_BITS;\n this._prefBits = dhEstimate(this.negotiated);\n if (this._protocol._compatFlags & COMPAT.BUG_DHGEX_LARGE)\n this._prefBits = Math.min(this._prefBits, 4096);\n this._maxBits = GEX_MAX_BITS;\n }\n start() {\n if (this._protocol._server)\n return;\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_GEX_REQUEST'\n );\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1 + 4 + 4 + 4,\n true\n );\n packet[p] = MESSAGE.KEXDH_GEX_REQUEST;\n writeUInt32BE(packet, this._minBits, ++p);\n writeUInt32BE(packet, this._prefBits, p += 4);\n writeUInt32BE(packet, this._maxBits, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n generateKeys() {\n if (!this._dh && this._prime && this._generator) {\n this._dh = createDiffieHellman(this._prime, this._generator);\n this._public = this._dh.generateKeys();\n }\n }\n setDHParams(prime, generator) {\n if (!Buffer.isBuffer(prime))\n throw new Error('Invalid prime value');\n if (!Buffer.isBuffer(generator))\n throw new Error('Invalid generator value');\n this._prime = prime;\n this._generator = generator;\n }\n getDHParams() {\n if (this._dh) {\n return {\n prime: convertToMpint(this._dh.getPrime()),\n generator: convertToMpint(this._dh.getGenerator()),\n };\n }\n }\n parse(payload) {\n const type = payload[0];\n switch (this._step) {\n case 1:\n if (this._protocol._server) {\n if (type !== MESSAGE.KEXDH_GEX_REQUEST) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of `\n + MESSAGE.KEXDH_GEX_REQUEST,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n // TODO: allow user implementation to provide safe prime and\n // generator on demand to support group exchange on server side\n return doFatalError(\n this._protocol,\n 'Group exchange not implemented for server',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (type !== MESSAGE.KEXDH_GEX_GROUP) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_GROUP}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Group'\n );\n\n /*\n byte SSH_MSG_KEX_DH_GEX_GROUP\n mpint p, safe prime\n mpint g, generator for subgroup in GF(p)\n */\n bufferParser.init(payload, 1);\n let prime;\n let gen;\n if ((prime = bufferParser.readString()) === undefined\n || (gen = bufferParser.readString()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n this._protocol,\n 'Received malformed KEXDH_GEX_GROUP',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n bufferParser.clear();\n\n // TODO: validate prime\n this.setDHParams(prime, gen);\n this.generateKeys();\n const pubkey = this.getPublicKey();\n\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_GEX_INIT'\n );\n\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet =\n this._protocol._packetRW.write.alloc(1 + 4 + pubkey.length, true);\n packet[p] = MESSAGE.KEXDH_GEX_INIT;\n writeUInt32BE(packet, pubkey.length, ++p);\n packet.set(pubkey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n\n ++this._step;\n break;\n case 2:\n if (this._protocol._server) {\n if (type !== MESSAGE.KEXDH_GEX_INIT) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_INIT}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Init'\n );\n return doFatalError(\n this._protocol,\n 'Group exchange not implemented for server',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n } else if (type !== MESSAGE.KEXDH_GEX_REPLY) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_REPLY}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Reply'\n );\n this._step = 1;\n payload[0] = MESSAGE.KEXDH_REPLY;\n this.parse = KeyExchange.prototype.parse;\n this.parse(payload);\n }\n }\n }\n\n class DHExchange extends KeyExchange {\n constructor(groupName, hashName, ...args) {\n super(...args);\n\n this.type = 'group';\n this.groupName = groupName;\n this.hashName = hashName;\n }\n start() {\n if (!this._protocol._server) {\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_INIT'\n );\n const pubKey = this.getPublicKey();\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet =\n this._protocol._packetRW.write.alloc(1 + 4 + pubKey.length, true);\n packet[p] = MESSAGE.KEXDH_INIT;\n writeUInt32BE(packet, pubKey.length, ++p);\n packet.set(pubKey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n }\n generateKeys() {\n if (!this._dh) {\n this._dh = createDiffieHellmanGroup(this.groupName);\n this._public = this._dh.generateKeys();\n }\n }\n getDHParams() {\n if (this._dh) {\n return {\n prime: convertToMpint(this._dh.getPrime()),\n generator: convertToMpint(this._dh.getGenerator()),\n };\n }\n }\n }\n\n return (negotiated, ...args) => {\n if (typeof negotiated !== 'object' || negotiated === null)\n throw new Error('Invalid negotiated argument');\n const kexType = negotiated.kex;\n if (typeof kexType === 'string') {\n args = [negotiated, ...args];\n switch (kexType) {\n case 'curve25519-sha256':\n case 'curve25519-sha256@libssh.org':\n if (!curve25519Supported)\n break;\n return new Curve25519Exchange('sha256', ...args);\n\n case 'ecdh-sha2-nistp256':\n return new ECDHExchange('prime256v1', 'sha256', ...args);\n case 'ecdh-sha2-nistp384':\n return new ECDHExchange('secp384r1', 'sha384', ...args);\n case 'ecdh-sha2-nistp521':\n return new ECDHExchange('secp521r1', 'sha512', ...args);\n\n case 'diffie-hellman-group1-sha1':\n return new DHExchange('modp2', 'sha1', ...args);\n case 'diffie-hellman-group14-sha1':\n return new DHExchange('modp14', 'sha1', ...args);\n case 'diffie-hellman-group14-sha256':\n return new DHExchange('modp14', 'sha256', ...args);\n case 'diffie-hellman-group15-sha512':\n return new DHExchange('modp15', 'sha512', ...args);\n case 'diffie-hellman-group16-sha512':\n return new DHExchange('modp16', 'sha512', ...args);\n case 'diffie-hellman-group17-sha512':\n return new DHExchange('modp17', 'sha512', ...args);\n case 'diffie-hellman-group18-sha512':\n return new DHExchange('modp18', 'sha512', ...args);\n\n case 'diffie-hellman-group-exchange-sha1':\n return new DHGroupExchange('sha1', ...args);\n case 'diffie-hellman-group-exchange-sha256':\n return new DHGroupExchange('sha256', ...args);\n }\n throw new Error(`Unsupported key exchange algorithm: ${kexType}`);\n }\n throw new Error(`Invalid key exchange type: ${kexType}`);\n };\n})();\n\nconst KexInit = (() => {\n const KEX_PROPERTY_NAMES = [\n 'kex',\n 'serverHostKey',\n ['cs', 'cipher' ],\n ['sc', 'cipher' ],\n ['cs', 'mac' ],\n ['sc', 'mac' ],\n ['cs', 'compress' ],\n ['sc', 'compress' ],\n ['cs', 'lang' ],\n ['sc', 'lang' ],\n ];\n return class KexInit {\n constructor(obj) {\n if (typeof obj !== 'object' || obj === null)\n throw new TypeError('Argument must be an object');\n\n const lists = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n sc: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n\n all: undefined,\n };\n let totalSize = 0;\n for (const prop of KEX_PROPERTY_NAMES) {\n let base;\n let val;\n let desc;\n let key;\n if (typeof prop === 'string') {\n base = lists;\n val = obj[prop];\n desc = key = prop;\n } else {\n const parent = prop[0];\n base = lists[parent];\n key = prop[1];\n val = obj[parent][key];\n desc = `${parent}.${key}`;\n }\n const entry = { array: undefined, buffer: undefined };\n if (Buffer.isBuffer(val)) {\n entry.array = ('' + val).split(',');\n entry.buffer = val;\n totalSize += 4 + val.length;\n } else {\n if (typeof val === 'string')\n val = val.split(',');\n if (Array.isArray(val)) {\n entry.array = val;\n entry.buffer = Buffer.from(val.join(','));\n } else {\n throw new TypeError(`Invalid \\`${desc}\\` type: ${typeof val}`);\n }\n totalSize += 4 + entry.buffer.length;\n }\n base[key] = entry;\n }\n\n const all = Buffer.allocUnsafe(totalSize);\n lists.all = all;\n\n let allPos = 0;\n for (const prop of KEX_PROPERTY_NAMES) {\n let data;\n if (typeof prop === 'string')\n data = lists[prop].buffer;\n else\n data = lists[prop[0]][prop[1]].buffer;\n allPos = writeUInt32BE(all, data.length, allPos);\n all.set(data, allPos);\n allPos += data.length;\n }\n\n this.totalSize = totalSize;\n this.lists = lists;\n }\n copyAllTo(buf, offset) {\n const src = this.lists.all;\n if (typeof offset !== 'number')\n throw new TypeError(`Invalid offset value: ${typeof offset}`);\n if (buf.length - offset < src.length)\n throw new Error('Insufficient space to copy list');\n buf.set(src, offset);\n return src.length;\n }\n };\n})();\n\nconst hashString = (() => {\n const LEN = Buffer.allocUnsafe(4);\n return (hash, buf) => {\n writeUInt32BE(LEN, buf.length, 0);\n hash.update(LEN);\n hash.update(buf);\n };\n})();\n\nfunction generateKEXVal(len, hashName, secret, exchangeHash, sessionID, char) {\n let ret;\n if (len) {\n let digest = createHash(hashName)\n .update(secret)\n .update(exchangeHash)\n .update(char)\n .update(sessionID)\n .digest();\n while (digest.length < len) {\n const chunk = createHash(hashName)\n .update(secret)\n .update(exchangeHash)\n .update(digest)\n .digest();\n const extended = Buffer.allocUnsafe(digest.length + chunk.length);\n extended.set(digest, 0);\n extended.set(chunk, digest.length);\n digest = extended;\n }\n if (digest.length === len)\n ret = digest;\n else\n ret = new FastBuffer(digest.buffer, digest.byteOffset, len);\n } else {\n ret = EMPTY_BUFFER;\n }\n return ret;\n}\n\nfunction onKEXPayload(state, payload) {\n // XXX: move this to the Decipher implementations?\n if (payload.length === 0) {\n this._debug && this._debug('Inbound: Skipping empty packet payload');\n return;\n }\n\n if (this._skipNextInboundPacket) {\n this._skipNextInboundPacket = false;\n return;\n }\n\n payload = this._packetRW.read.read(payload);\n\n const type = payload[0];\n switch (type) {\n case MESSAGE.DISCONNECT:\n case MESSAGE.IGNORE:\n case MESSAGE.UNIMPLEMENTED:\n case MESSAGE.DEBUG:\n if (!MESSAGE_HANDLERS)\n MESSAGE_HANDLERS = require('./handlers.js');\n return MESSAGE_HANDLERS[type](this, payload);\n case MESSAGE.KEXINIT:\n if (!state.firstPacket) {\n return doFatalError(\n this,\n 'Received extra KEXINIT during handshake',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n state.firstPacket = false;\n return handleKexInit(this, payload);\n default:\n if (type < 20 || type > 49) {\n return doFatalError(\n this,\n `Received unexpected packet type ${type}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n return this._kex.parse(payload);\n}\n\nfunction dhEstimate(neg) {\n const csCipher = CIPHER_INFO[neg.cs.cipher];\n const scCipher = CIPHER_INFO[neg.sc.cipher];\n // XXX: if OpenSSH's `umac-*` MACs are ever supported, their key lengths will\n // also need to be considered when calculating `bits`\n const bits = Math.max(\n 0,\n (csCipher.sslName === 'des-ede3-cbc' ? 14 : csCipher.keyLen),\n csCipher.blockLen,\n csCipher.ivLen,\n (scCipher.sslName === 'des-ede3-cbc' ? 14 : scCipher.keyLen),\n scCipher.blockLen,\n scCipher.ivLen\n ) * 8;\n if (bits <= 112)\n return 2048;\n if (bits <= 128)\n return 3072;\n if (bits <= 192)\n return 7680;\n return 8192;\n}\n\nfunction trySendNEWKEYS(kex) {\n if (!kex._sentNEWKEYS) {\n kex._protocol._debug && kex._protocol._debug(\n 'Outbound: Sending NEWKEYS'\n );\n const p = kex._protocol._packetRW.write.allocStartKEX;\n const packet = kex._protocol._packetRW.write.alloc(1, true);\n packet[p] = MESSAGE.NEWKEYS;\n kex._protocol._cipher.encrypt(\n kex._protocol._packetRW.write.finalize(packet, true)\n );\n kex._sentNEWKEYS = true;\n }\n}\n\nmodule.exports = {\n KexInit,\n kexinit,\n onKEXPayload,\n DEFAULT_KEXINIT: new KexInit({\n kex: DEFAULT_KEX,\n serverHostKey: DEFAULT_SERVER_HOST_KEY,\n cs: {\n cipher: DEFAULT_CIPHER,\n mac: DEFAULT_MAC,\n compress: DEFAULT_COMPRESSION,\n lang: [],\n },\n sc: {\n cipher: DEFAULT_CIPHER,\n mac: DEFAULT_MAC,\n compress: DEFAULT_COMPRESSION,\n lang: [],\n },\n }),\n HANDLERS: {\n [MESSAGE.KEXINIT]: handleKexInit,\n },\n};\n","// TODO:\n// * utilize `crypto.create(Private|Public)Key()` and `keyObject.export()`\n// * handle multi-line header values (OpenSSH)?\n// * more thorough validation?\n'use strict';\n\nconst {\n createDecipheriv,\n createECDH,\n createHash,\n createHmac,\n createSign,\n createVerify,\n getCiphers,\n sign: sign_,\n verify: verify_,\n} = require('crypto');\nconst supportedOpenSSLCiphers = getCiphers();\n\nconst { Ber } = require('asn1');\nconst bcrypt_pbkdf = require('bcrypt-pbkdf').pbkdf;\n\nconst { CIPHER_INFO } = require('./crypto.js');\nconst { eddsaSupported, SUPPORTED_CIPHER } = require('./constants.js');\nconst {\n bufferSlice,\n makeBufferParser,\n readString,\n readUInt32BE,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst SYM_HASH_ALGO = Symbol('Hash Algorithm');\nconst SYM_PRIV_PEM = Symbol('Private key PEM');\nconst SYM_PUB_PEM = Symbol('Public key PEM');\nconst SYM_PUB_SSH = Symbol('Public key SSH');\nconst SYM_DECRYPTED = Symbol('Decrypted Key');\n\n// Create OpenSSL cipher name -> SSH cipher name conversion table\nconst CIPHER_INFO_OPENSSL = Object.create(null);\n{\n const keys = Object.keys(CIPHER_INFO);\n for (let i = 0; i < keys.length; ++i) {\n const cipherName = CIPHER_INFO[keys[i]].sslName;\n if (!cipherName || CIPHER_INFO_OPENSSL[cipherName])\n continue;\n CIPHER_INFO_OPENSSL[cipherName] = CIPHER_INFO[keys[i]];\n }\n}\n\nconst binaryKeyParser = makeBufferParser();\n\nfunction makePEM(type, data) {\n data = data.base64Slice(0, data.length);\n let formatted = data.replace(/.{64}/g, '$&\\n');\n if (data.length & 63)\n formatted += '\\n';\n return `-----BEGIN ${type} KEY-----\\n${formatted}-----END ${type} KEY-----`;\n}\n\nfunction combineBuffers(buf1, buf2) {\n const result = Buffer.allocUnsafe(buf1.length + buf2.length);\n result.set(buf1, 0);\n result.set(buf2, buf1.length);\n return result;\n}\n\nfunction skipFields(buf, nfields) {\n const bufLen = buf.length;\n let pos = (buf._pos || 0);\n for (let i = 0; i < nfields; ++i) {\n const left = (bufLen - pos);\n if (pos >= bufLen || left < 4)\n return false;\n const len = readUInt32BE(buf, pos);\n if (left < 4 + len)\n return false;\n pos += 4 + len;\n }\n buf._pos = pos;\n return true;\n}\n\nfunction genOpenSSLRSAPub(n, e) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.113549.1.1.1'); // rsaEncryption\n // algorithm parameters (RSA has none)\n asnWriter.writeNull();\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n asnWriter.startSequence();\n asnWriter.writeBuffer(n, Ber.Integer);\n asnWriter.writeBuffer(e, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHRSAPub(n, e) {\n const publicKey = Buffer.allocUnsafe(4 + 7 + 4 + e.length + 4 + n.length);\n\n writeUInt32BE(publicKey, 7, 0);\n publicKey.utf8Write('ssh-rsa', 4, 7);\n\n let i = 4 + 7;\n writeUInt32BE(publicKey, e.length, i);\n publicKey.set(e, i += 4);\n\n writeUInt32BE(publicKey, n.length, i += e.length);\n publicKey.set(n, i + 4);\n\n return publicKey;\n}\n\nconst genOpenSSLRSAPriv = (() => {\n function genRSAASN1Buf(n, e, d, p, q, dmp1, dmq1, iqmp) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeInt(0x00, Ber.Integer);\n asnWriter.writeBuffer(n, Ber.Integer);\n asnWriter.writeBuffer(e, Ber.Integer);\n asnWriter.writeBuffer(d, Ber.Integer);\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(dmp1, Ber.Integer);\n asnWriter.writeBuffer(dmq1, Ber.Integer);\n asnWriter.writeBuffer(iqmp, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n\n function bigIntFromBuffer(buf) {\n return BigInt(`0x${buf.hexSlice(0, buf.length)}`);\n }\n\n function bigIntToBuffer(bn) {\n let hex = bn.toString(16);\n if ((hex.length & 1) !== 0) {\n hex = `0${hex}`;\n } else {\n const sigbit = hex.charCodeAt(0);\n // BER/DER integers require leading zero byte to denote a positive value\n // when first byte >= 0x80\n if (sigbit === 56/* '8' */\n || sigbit === 57/* '9' */\n || (sigbit >= 97/* 'a' */ && sigbit <= 102/* 'f' */)) {\n hex = `00${hex}`;\n }\n }\n return Buffer.from(hex, 'hex');\n }\n\n return function genOpenSSLRSAPriv(n, e, d, iqmp, p, q) {\n const bn_d = bigIntFromBuffer(d);\n const dmp1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(p) - 1n));\n const dmq1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(q) - 1n));\n return makePEM('RSA PRIVATE',\n genRSAASN1Buf(n, e, d, p, q, dmp1, dmq1, iqmp));\n };\n})();\n\nfunction genOpenSSLDSAPub(p, q, g, y) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.10040.4.1'); // id-dsa\n // algorithm parameters\n asnWriter.startSequence();\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(g, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n asnWriter.writeBuffer(y, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHDSAPub(p, q, g, y) {\n const publicKey = Buffer.allocUnsafe(\n 4 + 7 + 4 + p.length + 4 + q.length + 4 + g.length + 4 + y.length\n );\n\n writeUInt32BE(publicKey, 7, 0);\n publicKey.utf8Write('ssh-dss', 4, 7);\n\n let i = 4 + 7;\n writeUInt32BE(publicKey, p.length, i);\n publicKey.set(p, i += 4);\n\n writeUInt32BE(publicKey, q.length, i += p.length);\n publicKey.set(q, i += 4);\n\n writeUInt32BE(publicKey, g.length, i += q.length);\n publicKey.set(g, i += 4);\n\n writeUInt32BE(publicKey, y.length, i += g.length);\n publicKey.set(y, i + 4);\n\n return publicKey;\n}\n\nfunction genOpenSSLDSAPriv(p, q, g, y, x) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeInt(0x00, Ber.Integer);\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(g, Ber.Integer);\n asnWriter.writeBuffer(y, Ber.Integer);\n asnWriter.writeBuffer(x, Ber.Integer);\n asnWriter.endSequence();\n return makePEM('DSA PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLEdPub(pub) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.112'); // id-Ed25519\n asnWriter.endSequence();\n\n // PublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(pub.length);\n asnWriter._buf.set(pub, asnWriter._offset);\n asnWriter._offset += pub.length;\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHEdPub(pub) {\n const publicKey = Buffer.allocUnsafe(4 + 11 + 4 + pub.length);\n\n writeUInt32BE(publicKey, 11, 0);\n publicKey.utf8Write('ssh-ed25519', 4, 11);\n\n writeUInt32BE(publicKey, pub.length, 15);\n publicKey.set(pub, 19);\n\n return publicKey;\n}\n\nfunction genOpenSSLEdPriv(priv) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // version\n asnWriter.writeInt(0x00, Ber.Integer);\n\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.112'); // id-Ed25519\n asnWriter.endSequence();\n\n // PrivateKey\n asnWriter.startSequence(Ber.OctetString);\n asnWriter.writeBuffer(priv, Ber.OctetString);\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLECDSAPub(oid, Q) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.10045.2.1'); // id-ecPublicKey\n // algorithm parameters (namedCurve)\n asnWriter.writeOID(oid);\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(Q.length);\n asnWriter._buf.set(Q, asnWriter._offset);\n asnWriter._offset += Q.length;\n // end hack\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHECDSAPub(oid, Q) {\n let curveName;\n switch (oid) {\n case '1.2.840.10045.3.1.7':\n // prime256v1/secp256r1\n curveName = 'nistp256';\n break;\n case '1.3.132.0.34':\n // secp384r1\n curveName = 'nistp384';\n break;\n case '1.3.132.0.35':\n // secp521r1\n curveName = 'nistp521';\n break;\n default:\n return;\n }\n\n const publicKey = Buffer.allocUnsafe(4 + 19 + 4 + 8 + 4 + Q.length);\n\n writeUInt32BE(publicKey, 19, 0);\n publicKey.utf8Write(`ecdsa-sha2-${curveName}`, 4, 19);\n\n writeUInt32BE(publicKey, 8, 23);\n publicKey.utf8Write(curveName, 27, 8);\n\n writeUInt32BE(publicKey, Q.length, 35);\n publicKey.set(Q, 39);\n\n return publicKey;\n}\n\nfunction genOpenSSLECDSAPriv(oid, pub, priv) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // version\n asnWriter.writeInt(0x01, Ber.Integer);\n // privateKey\n asnWriter.writeBuffer(priv, Ber.OctetString);\n // parameters (optional)\n asnWriter.startSequence(0xA0);\n asnWriter.writeOID(oid);\n asnWriter.endSequence();\n // publicKey (optional)\n asnWriter.startSequence(0xA1);\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(pub.length);\n asnWriter._buf.set(pub, asnWriter._offset);\n asnWriter._offset += pub.length;\n // end hack\n asnWriter.endSequence();\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('EC PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLECDSAPubFromPriv(curveName, priv) {\n const tempECDH = createECDH(curveName);\n tempECDH.setPrivateKey(priv);\n return tempECDH.getPublicKey();\n}\n\nconst BaseKey = {\n sign: (() => {\n if (typeof sign_ === 'function') {\n return function sign(data, algo) {\n const pem = this[SYM_PRIV_PEM];\n if (pem === null)\n return new Error('No private key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n try {\n return sign_(algo, data, pem);\n } catch (ex) {\n return ex;\n }\n };\n }\n return function sign(data, algo) {\n const pem = this[SYM_PRIV_PEM];\n if (pem === null)\n return new Error('No private key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n const signature = createSign(algo);\n signature.update(data);\n try {\n return signature.sign(pem);\n } catch (ex) {\n return ex;\n }\n };\n })(),\n verify: (() => {\n if (typeof verify_ === 'function') {\n return function verify(data, signature, algo) {\n const pem = this[SYM_PUB_PEM];\n if (pem === null)\n return new Error('No public key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n try {\n return verify_(algo, data, pem, signature);\n } catch (ex) {\n return ex;\n }\n };\n }\n return function verify(data, signature, algo) {\n const pem = this[SYM_PUB_PEM];\n if (pem === null)\n return new Error('No public key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n const verifier = createVerify(algo);\n verifier.update(data);\n try {\n return verifier.verify(pem, signature);\n } catch (ex) {\n return ex;\n }\n };\n })(),\n isPrivateKey: function isPrivateKey() {\n return (this[SYM_PRIV_PEM] !== null);\n },\n getPrivatePEM: function getPrivatePEM() {\n return this[SYM_PRIV_PEM];\n },\n getPublicPEM: function getPublicPEM() {\n return this[SYM_PUB_PEM];\n },\n getPublicSSH: function getPublicSSH() {\n return this[SYM_PUB_SSH];\n },\n equals: function equals(key) {\n const parsed = parseKey(key);\n if (parsed instanceof Error)\n return false;\n return (\n this.type === parsed.type\n && this[SYM_PRIV_PEM] === parsed[SYM_PRIV_PEM]\n && this[SYM_PUB_PEM] === parsed[SYM_PUB_PEM]\n && this[SYM_PUB_SSH] === parsed[SYM_PUB_SSH]\n );\n },\n};\n\n\nfunction OpenSSH_Private(type, comment, privPEM, pubPEM, pubSSH, algo,\n decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nOpenSSH_Private.prototype = BaseKey;\n{\n const regexp = /^-----BEGIN OPENSSH PRIVATE KEY-----(?:\\r\\n|\\n)([\\s\\S]+)(?:\\r\\n|\\n)-----END OPENSSH PRIVATE KEY-----$/;\n OpenSSH_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n let ret;\n const data = Buffer.from(m[1], 'base64');\n if (data.length < 31) // magic (+ magic null term.) + minimum field lengths\n return new Error('Malformed OpenSSH private key');\n const magic = data.utf8Slice(0, 15);\n if (magic !== 'openssh-key-v1\\0')\n return new Error(`Unsupported OpenSSH key magic: ${magic}`);\n\n const cipherName = readString(data, 15, true);\n if (cipherName === undefined)\n return new Error('Malformed OpenSSH private key');\n if (cipherName !== 'none' && SUPPORTED_CIPHER.indexOf(cipherName) === -1)\n return new Error(`Unsupported cipher for OpenSSH key: ${cipherName}`);\n\n const kdfName = readString(data, data._pos, true);\n if (kdfName === undefined)\n return new Error('Malformed OpenSSH private key');\n if (kdfName !== 'none') {\n if (cipherName === 'none')\n return new Error('Malformed OpenSSH private key');\n if (kdfName !== 'bcrypt')\n return new Error(`Unsupported kdf name for OpenSSH key: ${kdfName}`);\n if (!passphrase) {\n return new Error(\n 'Encrypted private OpenSSH key detected, but no passphrase given'\n );\n }\n } else if (cipherName !== 'none') {\n return new Error('Malformed OpenSSH private key');\n }\n\n let encInfo;\n let cipherKey;\n let cipherIV;\n if (cipherName !== 'none')\n encInfo = CIPHER_INFO[cipherName];\n const kdfOptions = readString(data, data._pos);\n if (kdfOptions === undefined)\n return new Error('Malformed OpenSSH private key');\n if (kdfOptions.length) {\n switch (kdfName) {\n case 'none':\n return new Error('Malformed OpenSSH private key');\n case 'bcrypt':\n /*\n string salt\n uint32 rounds\n */\n const salt = readString(kdfOptions, 0);\n if (salt === undefined || kdfOptions._pos + 4 > kdfOptions.length)\n return new Error('Malformed OpenSSH private key');\n const rounds = readUInt32BE(kdfOptions, kdfOptions._pos);\n const gen = Buffer.allocUnsafe(encInfo.keyLen + encInfo.ivLen);\n const r = bcrypt_pbkdf(passphrase,\n passphrase.length,\n salt,\n salt.length,\n gen,\n gen.length,\n rounds);\n if (r !== 0)\n return new Error('Failed to generate information to decrypt key');\n cipherKey = bufferSlice(gen, 0, encInfo.keyLen);\n cipherIV = bufferSlice(gen, encInfo.keyLen, gen.length);\n break;\n }\n } else if (kdfName !== 'none') {\n return new Error('Malformed OpenSSH private key');\n }\n\n if (data._pos + 3 >= data.length)\n return new Error('Malformed OpenSSH private key');\n const keyCount = readUInt32BE(data, data._pos);\n data._pos += 4;\n\n if (keyCount > 0) {\n // TODO: place sensible limit on max `keyCount`\n\n // Read public keys first\n for (let i = 0; i < keyCount; ++i) {\n const pubData = readString(data, data._pos);\n if (pubData === undefined)\n return new Error('Malformed OpenSSH private key');\n const type = readString(pubData, 0, true);\n if (type === undefined)\n return new Error('Malformed OpenSSH private key');\n }\n\n let privBlob = readString(data, data._pos);\n if (privBlob === undefined)\n return new Error('Malformed OpenSSH private key');\n\n if (cipherKey !== undefined) {\n // Encrypted private key(s)\n if (privBlob.length < encInfo.blockLen\n || (privBlob.length % encInfo.blockLen) !== 0) {\n return new Error('Malformed OpenSSH private key');\n }\n try {\n const options = { authTagLength: encInfo.authLen };\n const decipher = createDecipheriv(encInfo.sslName,\n cipherKey,\n cipherIV,\n options);\n if (encInfo.authLen > 0) {\n if (data.length - data._pos < encInfo.authLen)\n return new Error('Malformed OpenSSH private key');\n decipher.setAuthTag(\n bufferSlice(data, data._pos, data._pos += encInfo.authLen)\n );\n }\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n } catch (ex) {\n return ex;\n }\n }\n // Nothing should we follow the private key(s), except a possible\n // authentication tag for relevant ciphers\n if (data._pos !== data.length)\n return new Error('Malformed OpenSSH private key');\n\n ret = parseOpenSSHPrivKeys(privBlob, keyCount, cipherKey !== undefined);\n } else {\n ret = [];\n }\n // This will need to change if/when OpenSSH ever starts storing multiple\n // keys in their key files\n return ret[0];\n };\n\n function parseOpenSSHPrivKeys(data, nkeys, decrypted) {\n const keys = [];\n /*\n uint32 checkint\n uint32 checkint\n string privatekey1\n string comment1\n string privatekey2\n string comment2\n ...\n string privatekeyN\n string commentN\n char 1\n char 2\n char 3\n ...\n char padlen % 255\n */\n if (data.length < 8)\n return new Error('Malformed OpenSSH private key');\n const check1 = readUInt32BE(data, 0);\n const check2 = readUInt32BE(data, 4);\n if (check1 !== check2) {\n if (decrypted) {\n return new Error(\n 'OpenSSH key integrity check failed -- bad passphrase?'\n );\n }\n return new Error('OpenSSH key integrity check failed');\n }\n data._pos = 8;\n let i;\n let oid;\n for (i = 0; i < nkeys; ++i) {\n let algo;\n let privPEM;\n let pubPEM;\n let pubSSH;\n // The OpenSSH documentation for the key format actually lies, the\n // entirety of the private key content is not contained with a string\n // field, it's actually the literal contents of the private key, so to be\n // able to find the end of the key data you need to know the layout/format\n // of each key type ...\n const type = readString(data, data._pos, true);\n if (type === undefined)\n return new Error('Malformed OpenSSH private key');\n\n switch (type) {\n case 'ssh-rsa': {\n /*\n string n -- public\n string e -- public\n string d -- private\n string iqmp -- private\n string p -- private\n string q -- private\n */\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed OpenSSH private key');\n const e = readString(data, data._pos);\n if (e === undefined)\n return new Error('Malformed OpenSSH private key');\n const d = readString(data, data._pos);\n if (d === undefined)\n return new Error('Malformed OpenSSH private key');\n const iqmp = readString(data, data._pos);\n if (iqmp === undefined)\n return new Error('Malformed OpenSSH private key');\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed OpenSSH private key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n privPEM = genOpenSSLRSAPriv(n, e, d, iqmp, p, q);\n algo = 'sha1';\n break;\n }\n case 'ssh-dss': {\n /*\n string p -- public\n string q -- public\n string g -- public\n string y -- public\n string x -- private\n */\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed OpenSSH private key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH private key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed OpenSSH private key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed OpenSSH private key');\n const x = readString(data, data._pos);\n if (x === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n privPEM = genOpenSSLDSAPriv(p, q, g, y, x);\n algo = 'sha1';\n break;\n }\n case 'ssh-ed25519': {\n if (!eddsaSupported)\n return new Error(`Unsupported OpenSSH private key type: ${type}`);\n /*\n * string public key\n * string private key + public key\n */\n const edpub = readString(data, data._pos);\n if (edpub === undefined || edpub.length !== 32)\n return new Error('Malformed OpenSSH private key');\n const edpriv = readString(data, data._pos);\n if (edpriv === undefined || edpriv.length !== 64)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLEdPub(edpub);\n pubSSH = genOpenSSHEdPub(edpub);\n privPEM = genOpenSSLEdPriv(bufferSlice(edpriv, 0, 32));\n algo = null;\n break;\n }\n case 'ecdsa-sha2-nistp256':\n algo = 'sha256';\n oid = '1.2.840.10045.3.1.7';\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp384':\n if (algo === undefined) {\n algo = 'sha384';\n oid = '1.3.132.0.34';\n }\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp521': {\n if (algo === undefined) {\n algo = 'sha512';\n oid = '1.3.132.0.35';\n }\n /*\n string curve name\n string Q -- public\n string d -- private\n */\n // TODO: validate curve name against type\n if (!skipFields(data, 1)) // Skip curve name\n return new Error('Malformed OpenSSH private key');\n const ecpub = readString(data, data._pos);\n if (ecpub === undefined)\n return new Error('Malformed OpenSSH private key');\n const ecpriv = readString(data, data._pos);\n if (ecpriv === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLECDSAPub(oid, ecpub);\n pubSSH = genOpenSSHECDSAPub(oid, ecpub);\n privPEM = genOpenSSLECDSAPriv(oid, ecpub, ecpriv);\n break;\n }\n default:\n return new Error(`Unsupported OpenSSH private key type: ${type}`);\n }\n\n const privComment = readString(data, data._pos, true);\n if (privComment === undefined)\n return new Error('Malformed OpenSSH private key');\n\n keys.push(\n new OpenSSH_Private(type, privComment, privPEM, pubPEM, pubSSH, algo,\n decrypted)\n );\n }\n let cnt = 0;\n for (i = data._pos; i < data.length; ++i) {\n if (data[i] !== (++cnt % 255))\n return new Error('Malformed OpenSSH private key');\n }\n\n return keys;\n }\n}\n\n\nfunction OpenSSH_Old_Private(type, comment, privPEM, pubPEM, pubSSH, algo,\n decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nOpenSSH_Old_Private.prototype = BaseKey;\n{\n const regexp = /^-----BEGIN (RSA|DSA|EC) PRIVATE KEY-----(?:\\r\\n|\\n)((?:[^:]+:\\s*[\\S].*(?:\\r\\n|\\n))*)([\\s\\S]+)(?:\\r\\n|\\n)-----END (RSA|DSA|EC) PRIVATE KEY-----$/;\n OpenSSH_Old_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n let privBlob = Buffer.from(m[3], 'base64');\n let headers = m[2];\n let decrypted = false;\n if (headers !== undefined) {\n // encrypted key\n headers = headers.split(/\\r\\n|\\n/g);\n for (let i = 0; i < headers.length; ++i) {\n const header = headers[i];\n let sepIdx = header.indexOf(':');\n if (header.slice(0, sepIdx) === 'DEK-Info') {\n const val = header.slice(sepIdx + 2);\n sepIdx = val.indexOf(',');\n if (sepIdx === -1)\n continue;\n const cipherName = val.slice(0, sepIdx).toLowerCase();\n if (supportedOpenSSLCiphers.indexOf(cipherName) === -1) {\n return new Error(\n `Cipher (${cipherName}) not supported `\n + 'for encrypted OpenSSH private key'\n );\n }\n const encInfo = CIPHER_INFO_OPENSSL[cipherName];\n if (!encInfo) {\n return new Error(\n `Cipher (${cipherName}) not supported `\n + 'for encrypted OpenSSH private key'\n );\n }\n const cipherIV = Buffer.from(val.slice(sepIdx + 1), 'hex');\n if (cipherIV.length !== encInfo.ivLen)\n return new Error('Malformed encrypted OpenSSH private key');\n if (!passphrase) {\n return new Error(\n 'Encrypted OpenSSH private key detected, but no passphrase given'\n );\n }\n const ivSlice = bufferSlice(cipherIV, 0, 8);\n let cipherKey = createHash('md5')\n .update(passphrase)\n .update(ivSlice)\n .digest();\n while (cipherKey.length < encInfo.keyLen) {\n cipherKey = combineBuffers(\n cipherKey,\n createHash('md5')\n .update(cipherKey)\n .update(passphrase)\n .update(ivSlice)\n .digest()\n );\n }\n if (cipherKey.length > encInfo.keyLen)\n cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);\n try {\n const decipher = createDecipheriv(cipherName, cipherKey, cipherIV);\n decipher.setAutoPadding(false);\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n decrypted = true;\n } catch (ex) {\n return ex;\n }\n }\n }\n }\n\n let type;\n let privPEM;\n let pubPEM;\n let pubSSH;\n let algo;\n let reader;\n let errMsg = 'Malformed OpenSSH private key';\n if (decrypted)\n errMsg += '. Bad passphrase?';\n switch (m[1]) {\n case 'RSA':\n type = 'ssh-rsa';\n privPEM = makePEM('RSA PRIVATE', privBlob);\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n const n = reader.readString(Ber.Integer, true);\n if (n === null)\n return new Error(errMsg);\n const e = reader.readString(Ber.Integer, true);\n if (e === null)\n return new Error(errMsg);\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n } catch {\n return new Error(errMsg);\n }\n algo = 'sha1';\n break;\n case 'DSA':\n type = 'ssh-dss';\n privPEM = makePEM('DSA PRIVATE', privBlob);\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n const p = reader.readString(Ber.Integer, true);\n if (p === null)\n return new Error(errMsg);\n const q = reader.readString(Ber.Integer, true);\n if (q === null)\n return new Error(errMsg);\n const g = reader.readString(Ber.Integer, true);\n if (g === null)\n return new Error(errMsg);\n const y = reader.readString(Ber.Integer, true);\n if (y === null)\n return new Error(errMsg);\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n } catch {\n return new Error(errMsg);\n }\n algo = 'sha1';\n break;\n case 'EC':\n let ecSSLName;\n let ecPriv;\n let ecOID;\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n ecPriv = reader.readString(Ber.OctetString, true);\n reader.readByte(); // Skip \"complex\" context type byte\n const offset = reader.readLength(); // Skip context length\n if (offset !== null) {\n reader._offset = offset;\n ecOID = reader.readOID();\n if (ecOID === null)\n return new Error(errMsg);\n switch (ecOID) {\n case '1.2.840.10045.3.1.7':\n // prime256v1/secp256r1\n ecSSLName = 'prime256v1';\n type = 'ecdsa-sha2-nistp256';\n algo = 'sha256';\n break;\n case '1.3.132.0.34':\n // secp384r1\n ecSSLName = 'secp384r1';\n type = 'ecdsa-sha2-nistp384';\n algo = 'sha384';\n break;\n case '1.3.132.0.35':\n // secp521r1\n ecSSLName = 'secp521r1';\n type = 'ecdsa-sha2-nistp521';\n algo = 'sha512';\n break;\n default:\n return new Error(`Unsupported private key EC OID: ${ecOID}`);\n }\n } else {\n return new Error(errMsg);\n }\n } catch {\n return new Error(errMsg);\n }\n privPEM = makePEM('EC PRIVATE', privBlob);\n const pubBlob = genOpenSSLECDSAPubFromPriv(ecSSLName, ecPriv);\n pubPEM = genOpenSSLECDSAPub(ecOID, pubBlob);\n pubSSH = genOpenSSHECDSAPub(ecOID, pubBlob);\n break;\n }\n\n return new OpenSSH_Old_Private(type, '', privPEM, pubPEM, pubSSH, algo,\n decrypted);\n };\n}\n\n\nfunction PPK_Private(type, comment, privPEM, pubPEM, pubSSH, algo, decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nPPK_Private.prototype = BaseKey;\n{\n const EMPTY_PASSPHRASE = Buffer.alloc(0);\n const PPK_IV = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);\n const PPK_PP1 = Buffer.from([0, 0, 0, 0]);\n const PPK_PP2 = Buffer.from([0, 0, 0, 1]);\n const regexp = /^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\\r?\\nEncryption: (aes256-cbc|none)\\r?\\nComment: ([^\\r\\n]*)\\r?\\nPublic-Lines: \\d+\\r?\\n([\\s\\S]+?)\\r?\\nPrivate-Lines: \\d+\\r?\\n([\\s\\S]+?)\\r?\\nPrivate-MAC: ([^\\r\\n]+)/;\n PPK_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n // m[1] = key type\n // m[2] = encryption type\n // m[3] = comment\n // m[4] = base64-encoded public key data:\n // for \"ssh-rsa\":\n // string \"ssh-rsa\"\n // mpint e (public exponent)\n // mpint n (modulus)\n // for \"ssh-dss\":\n // string \"ssh-dss\"\n // mpint p (modulus)\n // mpint q (prime)\n // mpint g (base number)\n // mpint y (public key parameter: g^x mod p)\n // m[5] = base64-encoded private key data:\n // for \"ssh-rsa\":\n // mpint d (private exponent)\n // mpint p (prime 1)\n // mpint q (prime 2)\n // mpint iqmp ([inverse of q] mod p)\n // for \"ssh-dss\":\n // mpint x (private key parameter)\n // m[6] = SHA1 HMAC over:\n // string name of algorithm (\"ssh-dss\", \"ssh-rsa\")\n // string encryption type\n // string comment\n // string public key data\n // string private-plaintext (including the final padding)\n const cipherName = m[2];\n const encrypted = (cipherName !== 'none');\n if (encrypted && !passphrase) {\n return new Error(\n 'Encrypted PPK private key detected, but no passphrase given'\n );\n }\n\n let privBlob = Buffer.from(m[5], 'base64');\n\n if (encrypted) {\n const encInfo = CIPHER_INFO[cipherName];\n let cipherKey = combineBuffers(\n createHash('sha1').update(PPK_PP1).update(passphrase).digest(),\n createHash('sha1').update(PPK_PP2).update(passphrase).digest()\n );\n if (cipherKey.length > encInfo.keyLen)\n cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);\n try {\n const decipher = createDecipheriv(encInfo.sslName,\n cipherKey,\n PPK_IV);\n decipher.setAutoPadding(false);\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n } catch (ex) {\n return ex;\n }\n }\n\n const type = m[1];\n const comment = m[3];\n const pubBlob = Buffer.from(m[4], 'base64');\n\n const mac = m[6];\n const typeLen = type.length;\n const cipherNameLen = cipherName.length;\n const commentLen = Buffer.byteLength(comment);\n const pubLen = pubBlob.length;\n const privLen = privBlob.length;\n const macData = Buffer.allocUnsafe(4 + typeLen\n + 4 + cipherNameLen\n + 4 + commentLen\n + 4 + pubLen\n + 4 + privLen);\n let p = 0;\n\n writeUInt32BE(macData, typeLen, p);\n macData.utf8Write(type, p += 4, typeLen);\n writeUInt32BE(macData, cipherNameLen, p += typeLen);\n macData.utf8Write(cipherName, p += 4, cipherNameLen);\n writeUInt32BE(macData, commentLen, p += cipherNameLen);\n macData.utf8Write(comment, p += 4, commentLen);\n writeUInt32BE(macData, pubLen, p += commentLen);\n macData.set(pubBlob, p += 4);\n writeUInt32BE(macData, privLen, p += pubLen);\n macData.set(privBlob, p + 4);\n\n if (!passphrase)\n passphrase = EMPTY_PASSPHRASE;\n\n const calcMAC = createHmac(\n 'sha1',\n createHash('sha1')\n .update('putty-private-key-file-mac-key')\n .update(passphrase)\n .digest()\n ).update(macData).digest('hex');\n\n if (calcMAC !== mac) {\n if (encrypted) {\n return new Error(\n 'PPK private key integrity check failed -- bad passphrase?'\n );\n }\n return new Error('PPK private key integrity check failed');\n }\n\n let pubPEM;\n let pubSSH;\n let privPEM;\n pubBlob._pos = 0;\n skipFields(pubBlob, 1); // skip (duplicate) key type\n switch (type) {\n case 'ssh-rsa': {\n const e = readString(pubBlob, pubBlob._pos);\n if (e === undefined)\n return new Error('Malformed PPK public key');\n const n = readString(pubBlob, pubBlob._pos);\n if (n === undefined)\n return new Error('Malformed PPK public key');\n const d = readString(privBlob, 0);\n if (d === undefined)\n return new Error('Malformed PPK private key');\n const p = readString(privBlob, privBlob._pos);\n if (p === undefined)\n return new Error('Malformed PPK private key');\n const q = readString(privBlob, privBlob._pos);\n if (q === undefined)\n return new Error('Malformed PPK private key');\n const iqmp = readString(privBlob, privBlob._pos);\n if (iqmp === undefined)\n return new Error('Malformed PPK private key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n privPEM = genOpenSSLRSAPriv(n, e, d, iqmp, p, q);\n break;\n }\n case 'ssh-dss': {\n const p = readString(pubBlob, pubBlob._pos);\n if (p === undefined)\n return new Error('Malformed PPK public key');\n const q = readString(pubBlob, pubBlob._pos);\n if (q === undefined)\n return new Error('Malformed PPK public key');\n const g = readString(pubBlob, pubBlob._pos);\n if (g === undefined)\n return new Error('Malformed PPK public key');\n const y = readString(pubBlob, pubBlob._pos);\n if (y === undefined)\n return new Error('Malformed PPK public key');\n const x = readString(privBlob, 0);\n if (x === undefined)\n return new Error('Malformed PPK private key');\n\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n privPEM = genOpenSSLDSAPriv(p, q, g, y, x);\n break;\n }\n }\n\n return new PPK_Private(type, comment, privPEM, pubPEM, pubSSH, 'sha1',\n encrypted);\n };\n}\n\n\nfunction OpenSSH_Public(type, comment, pubPEM, pubSSH, algo) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = null;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = false;\n}\nOpenSSH_Public.prototype = BaseKey;\n{\n let regexp;\n if (eddsaSupported)\n regexp = /^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\\s+([\\S].*)?)$/;\n else\n regexp = /^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\\s+([\\S].*)?)$/;\n OpenSSH_Public.parse = (str) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n // m[1] = full type\n // m[2] = base type\n // m[3] = base64-encoded public key\n // m[4] = comment\n\n const fullType = m[1];\n const baseType = m[2];\n const data = Buffer.from(m[3], 'base64');\n const comment = (m[4] || '');\n\n const type = readString(data, data._pos, true);\n if (type === undefined || type.indexOf(baseType) !== 0)\n return new Error('Malformed OpenSSH public key');\n\n return parseDER(data, baseType, comment, fullType);\n };\n}\n\n\nfunction RFC4716_Public(type, comment, pubPEM, pubSSH, algo) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = null;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = false;\n}\nRFC4716_Public.prototype = BaseKey;\n{\n const regexp = /^---- BEGIN SSH2 PUBLIC KEY ----(?:\\r?\\n)((?:.{0,72}\\r?\\n)+)---- END SSH2 PUBLIC KEY ----$/;\n const RE_DATA = /^[A-Z0-9a-z/+=\\r\\n]+$/;\n const RE_HEADER = /^([\\x21-\\x39\\x3B-\\x7E]{1,64}): ((?:[^\\\\]*\\\\\\r?\\n)*[^\\r\\n]+)\\r?\\n/gm;\n const RE_HEADER_ENDS = /\\\\\\r?\\n/g;\n RFC4716_Public.parse = (str) => {\n let m = regexp.exec(str);\n if (m === null)\n return null;\n\n const body = m[1];\n let dataStart = 0;\n let comment = '';\n\n while (m = RE_HEADER.exec(body)) {\n const headerName = m[1];\n const headerValue = m[2].replace(RE_HEADER_ENDS, '');\n if (headerValue.length > 1024) {\n RE_HEADER.lastIndex = 0;\n return new Error('Malformed RFC4716 public key');\n }\n\n dataStart = RE_HEADER.lastIndex;\n\n if (headerName.toLowerCase() === 'comment') {\n comment = headerValue;\n if (comment.length > 1\n && comment.charCodeAt(0) === 34/* '\"' */\n && comment.charCodeAt(comment.length - 1) === 34/* '\"' */) {\n comment = comment.slice(1, -1);\n }\n }\n }\n\n let data = body.slice(dataStart);\n if (!RE_DATA.test(data))\n return new Error('Malformed RFC4716 public key');\n\n data = Buffer.from(data, 'base64');\n\n const type = readString(data, 0, true);\n if (type === undefined)\n return new Error('Malformed RFC4716 public key');\n\n let pubPEM = null;\n let pubSSH = null;\n switch (type) {\n case 'ssh-rsa': {\n const e = readString(data, data._pos);\n if (e === undefined)\n return new Error('Malformed RFC4716 public key');\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed RFC4716 public key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n break;\n }\n case 'ssh-dss': {\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed RFC4716 public key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed RFC4716 public key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed RFC4716 public key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed RFC4716 public key');\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n break;\n }\n default:\n return new Error('Malformed RFC4716 public key');\n }\n\n return new RFC4716_Public(type, comment, pubPEM, pubSSH, 'sha1');\n };\n}\n\n\nfunction parseDER(data, baseType, comment, fullType) {\n if (!isSupportedKeyType(baseType))\n return new Error(`Unsupported OpenSSH public key type: ${baseType}`);\n\n let algo;\n let oid;\n let pubPEM = null;\n let pubSSH = null;\n\n switch (baseType) {\n case 'ssh-rsa': {\n const e = readString(data, data._pos || 0);\n if (e === undefined)\n return new Error('Malformed OpenSSH public key');\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n algo = 'sha1';\n break;\n }\n case 'ssh-dss': {\n const p = readString(data, data._pos || 0);\n if (p === undefined)\n return new Error('Malformed OpenSSH public key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH public key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed OpenSSH public key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n algo = 'sha1';\n break;\n }\n case 'ssh-ed25519': {\n const edpub = readString(data, data._pos || 0);\n if (edpub === undefined || edpub.length !== 32)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLEdPub(edpub);\n pubSSH = genOpenSSHEdPub(edpub);\n algo = null;\n break;\n }\n case 'ecdsa-sha2-nistp256':\n algo = 'sha256';\n oid = '1.2.840.10045.3.1.7';\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp384':\n if (algo === undefined) {\n algo = 'sha384';\n oid = '1.3.132.0.34';\n }\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp521': {\n if (algo === undefined) {\n algo = 'sha512';\n oid = '1.3.132.0.35';\n }\n // TODO: validate curve name against type\n if (!skipFields(data, 1)) // Skip curve name\n return new Error('Malformed OpenSSH public key');\n const ecpub = readString(data, data._pos || 0);\n if (ecpub === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLECDSAPub(oid, ecpub);\n pubSSH = genOpenSSHECDSAPub(oid, ecpub);\n break;\n }\n default:\n return new Error(`Unsupported OpenSSH public key type: ${baseType}`);\n }\n\n return new OpenSSH_Public(fullType, comment, pubPEM, pubSSH, algo);\n}\n\nfunction isSupportedKeyType(type) {\n switch (type) {\n case 'ssh-rsa':\n case 'ssh-dss':\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521':\n return true;\n case 'ssh-ed25519':\n if (eddsaSupported)\n return true;\n // FALLTHROUGH\n default:\n return false;\n }\n}\n\nfunction isParsedKey(val) {\n if (!val)\n return false;\n return (typeof val[SYM_DECRYPTED] === 'boolean');\n}\n\nfunction parseKey(data, passphrase) {\n if (isParsedKey(data))\n return data;\n\n let origBuffer;\n if (Buffer.isBuffer(data)) {\n origBuffer = data;\n data = data.utf8Slice(0, data.length).trim();\n } else if (typeof data === 'string') {\n data = data.trim();\n } else {\n return new Error('Key data must be a Buffer or string');\n }\n\n // eslint-disable-next-line eqeqeq\n if (passphrase != undefined) {\n if (typeof passphrase === 'string')\n passphrase = Buffer.from(passphrase);\n else if (!Buffer.isBuffer(passphrase))\n return new Error('Passphrase must be a string or Buffer when supplied');\n }\n\n let ret;\n\n // First try as printable string format (e.g. PEM)\n\n // Private keys\n if ((ret = OpenSSH_Private.parse(data, passphrase)) !== null)\n return ret;\n if ((ret = OpenSSH_Old_Private.parse(data, passphrase)) !== null)\n return ret;\n if ((ret = PPK_Private.parse(data, passphrase)) !== null)\n return ret;\n\n // Public keys\n if ((ret = OpenSSH_Public.parse(data)) !== null)\n return ret;\n if ((ret = RFC4716_Public.parse(data)) !== null)\n return ret;\n\n // Finally try as a binary format if we were originally passed binary data\n if (origBuffer) {\n binaryKeyParser.init(origBuffer, 0);\n const type = binaryKeyParser.readString(true);\n if (type !== undefined) {\n data = binaryKeyParser.readRaw();\n if (data !== undefined) {\n ret = parseDER(data, type, '', type);\n // Ignore potentially useless errors in case the data was not actually\n // in the binary format\n if (ret instanceof Error)\n ret = null;\n }\n }\n binaryKeyParser.clear();\n }\n\n if (ret)\n return ret;\n\n return new Error('Unsupported key format');\n}\n\nmodule.exports = {\n isParsedKey,\n isSupportedKeyType,\n parseDERKey: (data, type) => parseDER(data, type, '', type),\n parseKey,\n};\n","'use strict';\n\nconst assert = require('assert');\nconst { inspect } = require('util');\n\n// Only use this for integers! Decimal numbers do not work with this function.\nfunction addNumericalSeparator(val) {\n let res = '';\n let i = val.length;\n const start = val[0] === '-' ? 1 : 0;\n for (; i >= start + 4; i -= 3)\n res = `_${val.slice(i - 3, i)}${res}`;\n return `${val.slice(0, i)}${res}`;\n}\n\nfunction oneOf(expected, thing) {\n assert(typeof thing === 'string', '`thing` has to be of type string');\n if (Array.isArray(expected)) {\n const len = expected.length;\n assert(len > 0, 'At least one expected value needs to be specified');\n expected = expected.map((i) => String(i));\n if (len > 2) {\n return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or `\n + expected[len - 1];\n } else if (len === 2) {\n return `one of ${thing} ${expected[0]} or ${expected[1]}`;\n }\n return `of ${thing} ${expected[0]}`;\n }\n return `of ${thing} ${String(expected)}`;\n}\n\n\nexports.ERR_INTERNAL_ASSERTION = class ERR_INTERNAL_ASSERTION extends Error {\n constructor(message) {\n super();\n Error.captureStackTrace(this, ERR_INTERNAL_ASSERTION);\n\n const suffix = 'This is caused by either a bug in ssh2 '\n + 'or incorrect usage of ssh2 internals.\\n'\n + 'Please open an issue with this stack trace at '\n + 'https://github.com/mscdex/ssh2/issues\\n';\n\n this.message = (message === undefined ? suffix : `${message}\\n${suffix}`);\n }\n};\n\nconst MAX_32BIT_INT = 2 ** 32;\nconst MAX_32BIT_BIGINT = (() => {\n try {\n return new Function('return 2n ** 32n')();\n } catch {}\n})();\nexports.ERR_OUT_OF_RANGE = class ERR_OUT_OF_RANGE extends RangeError {\n constructor(str, range, input, replaceDefaultBoolean) {\n super();\n Error.captureStackTrace(this, ERR_OUT_OF_RANGE);\n\n assert(range, 'Missing \"range\" argument');\n let msg = (replaceDefaultBoolean\n ? str\n : `The value of \"${str}\" is out of range.`);\n let received;\n if (Number.isInteger(input) && Math.abs(input) > MAX_32BIT_INT) {\n received = addNumericalSeparator(String(input));\n } else if (typeof input === 'bigint') {\n received = String(input);\n if (input > MAX_32BIT_BIGINT || input < -MAX_32BIT_BIGINT)\n received = addNumericalSeparator(received);\n received += 'n';\n } else {\n received = inspect(input);\n }\n msg += ` It must be ${range}. Received ${received}`;\n\n this.message = msg;\n }\n};\n\nclass ERR_INVALID_ARG_TYPE extends TypeError {\n constructor(name, expected, actual) {\n super();\n Error.captureStackTrace(this, ERR_INVALID_ARG_TYPE);\n\n assert(typeof name === 'string', `'name' must be a string`);\n\n // determiner: 'must be' or 'must not be'\n let determiner;\n if (typeof expected === 'string' && expected.startsWith('not ')) {\n determiner = 'must not be';\n expected = expected.replace(/^not /, '');\n } else {\n determiner = 'must be';\n }\n\n let msg;\n if (name.endsWith(' argument')) {\n // For cases like 'first argument'\n msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;\n } else {\n const type = (name.includes('.') ? 'property' : 'argument');\n msg = `The \"${name}\" ${type} ${determiner} ${oneOf(expected, 'type')}`;\n }\n\n msg += `. Received type ${typeof actual}`;\n\n this.message = msg;\n }\n}\nexports.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;\n\nexports.validateNumber = function validateNumber(value, name) {\n if (typeof value !== 'number')\n throw new ERR_INVALID_ARG_TYPE(name, 'number', value);\n};\n","'use strict';\n\nconst Ber = require('asn1').Ber;\n\nlet DISCONNECT_REASON;\n\nconst FastBuffer = Buffer[Symbol.species];\nconst TypedArrayFill = Object.getPrototypeOf(Uint8Array.prototype).fill;\n\nfunction readUInt32BE(buf, offset) {\n return (buf[offset++] * 16777216)\n + (buf[offset++] * 65536)\n + (buf[offset++] * 256)\n + buf[offset];\n}\n\nfunction bufferCopy(src, dest, srcStart, srcEnd, destStart) {\n if (!destStart)\n destStart = 0;\n if (srcEnd > src.length)\n srcEnd = src.length;\n let nb = srcEnd - srcStart;\n const destLeft = (dest.length - destStart);\n if (nb > destLeft)\n nb = destLeft;\n dest.set(new Uint8Array(src.buffer, src.byteOffset + srcStart, nb),\n destStart);\n return nb;\n}\n\nfunction bufferSlice(buf, start, end) {\n if (end === undefined)\n end = buf.length;\n return new FastBuffer(buf.buffer, buf.byteOffset + start, end - start);\n}\n\nfunction makeBufferParser() {\n let pos = 0;\n let buffer;\n\n const self = {\n init: (buf, start) => {\n buffer = buf;\n pos = (typeof start === 'number' ? start : 0);\n },\n pos: () => pos,\n length: () => (buffer ? buffer.length : 0),\n avail: () => (buffer && pos < buffer.length ? buffer.length - pos : 0),\n clear: () => {\n buffer = undefined;\n },\n readUInt32BE: () => {\n if (!buffer || pos + 3 >= buffer.length)\n return;\n return (buffer[pos++] * 16777216)\n + (buffer[pos++] * 65536)\n + (buffer[pos++] * 256)\n + buffer[pos++];\n },\n readUInt64BE: (behavior) => {\n if (!buffer || pos + 7 >= buffer.length)\n return;\n switch (behavior) {\n case 'always':\n return BigInt(`0x${buffer.hexSlice(pos, pos += 8)}`);\n case 'maybe':\n if (buffer[pos] > 0x1F)\n return BigInt(`0x${buffer.hexSlice(pos, pos += 8)}`);\n // FALLTHROUGH\n default:\n return (buffer[pos++] * 72057594037927940)\n + (buffer[pos++] * 281474976710656)\n + (buffer[pos++] * 1099511627776)\n + (buffer[pos++] * 4294967296)\n + (buffer[pos++] * 16777216)\n + (buffer[pos++] * 65536)\n + (buffer[pos++] * 256)\n + buffer[pos++];\n }\n },\n skip: (n) => {\n if (buffer && n > 0)\n pos += n;\n },\n skipString: () => {\n const len = self.readUInt32BE();\n if (len === undefined)\n return;\n pos += len;\n return (pos <= buffer.length ? len : undefined);\n },\n readByte: () => {\n if (buffer && pos < buffer.length)\n return buffer[pos++];\n },\n readBool: () => {\n if (buffer && pos < buffer.length)\n return !!buffer[pos++];\n },\n readList: () => {\n const list = self.readString(true);\n if (list === undefined)\n return;\n return (list ? list.split(',') : []);\n },\n readString: (dest, maxLen) => {\n if (typeof dest === 'number') {\n maxLen = dest;\n dest = undefined;\n }\n\n const len = self.readUInt32BE();\n if (len === undefined)\n return;\n\n if ((buffer.length - pos) < len\n || (typeof maxLen === 'number' && len > maxLen)) {\n return;\n }\n\n if (dest) {\n if (Buffer.isBuffer(dest))\n return bufferCopy(buffer, dest, pos, pos += len);\n return buffer.utf8Slice(pos, pos += len);\n }\n return bufferSlice(buffer, pos, pos += len);\n },\n readRaw: (len) => {\n if (!buffer)\n return;\n if (typeof len !== 'number')\n return bufferSlice(buffer, pos, pos += (buffer.length - pos));\n if ((buffer.length - pos) >= len)\n return bufferSlice(buffer, pos, pos += len);\n },\n };\n\n return self;\n}\n\nfunction makeError(msg, level, fatal) {\n const err = new Error(msg);\n if (typeof level === 'boolean') {\n fatal = level;\n err.level = 'protocol';\n } else {\n err.level = level || 'protocol';\n }\n err.fatal = !!fatal;\n return err;\n}\n\nfunction writeUInt32BE(buf, value, offset) {\n buf[offset++] = (value >>> 24);\n buf[offset++] = (value >>> 16);\n buf[offset++] = (value >>> 8);\n buf[offset++] = value;\n return offset;\n}\n\nconst utilBufferParser = makeBufferParser();\n\nmodule.exports = {\n bufferCopy,\n bufferSlice,\n FastBuffer,\n bufferFill: (buf, value, start, end) => {\n return TypedArrayFill.call(buf, value, start, end);\n },\n makeError,\n doFatalError: (protocol, msg, level, reason) => {\n let err;\n if (DISCONNECT_REASON === undefined)\n ({ DISCONNECT_REASON } = require('./utils.js'));\n if (msg instanceof Error) {\n // doFatalError(protocol, err[, reason])\n err = msg;\n if (typeof level !== 'number')\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n else\n reason = level;\n } else {\n // doFatalError(protocol, msg[, level[, reason]])\n err = makeError(msg, level, true);\n }\n if (typeof reason !== 'number')\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n protocol.disconnect(reason);\n protocol._destruct();\n protocol._onError(err);\n return Infinity;\n },\n readUInt32BE,\n writeUInt32BE,\n writeUInt32LE: (buf, value, offset) => {\n buf[offset++] = value;\n buf[offset++] = (value >>> 8);\n buf[offset++] = (value >>> 16);\n buf[offset++] = (value >>> 24);\n return offset;\n },\n makeBufferParser,\n bufferParser: makeBufferParser(),\n readString: (buffer, start, dest, maxLen) => {\n if (typeof dest === 'number') {\n maxLen = dest;\n dest = undefined;\n }\n\n if (start === undefined)\n start = 0;\n\n const left = (buffer.length - start);\n if (start < 0 || start >= buffer.length || left < 4)\n return;\n\n const len = readUInt32BE(buffer, start);\n if (left < (4 + len) || (typeof maxLen === 'number' && len > maxLen))\n return;\n\n start += 4;\n const end = start + len;\n buffer._pos = end;\n\n if (dest) {\n if (Buffer.isBuffer(dest))\n return bufferCopy(buffer, dest, start, end);\n return buffer.utf8Slice(start, end);\n }\n return bufferSlice(buffer, start, end);\n },\n sigSSHToASN1: (sig, type) => {\n switch (type) {\n case 'ssh-dss': {\n if (sig.length > 40)\n return sig;\n // Change bare signature r and s values to ASN.1 BER values for OpenSSL\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n let r = sig.slice(0, 20);\n let s = sig.slice(20);\n if (r[0] & 0x80) {\n const rNew = Buffer.allocUnsafe(21);\n rNew[0] = 0x00;\n r.copy(rNew, 1);\n r = rNew;\n } else if (r[0] === 0x00 && !(r[1] & 0x80)) {\n r = r.slice(1);\n }\n if (s[0] & 0x80) {\n const sNew = Buffer.allocUnsafe(21);\n sNew[0] = 0x00;\n s.copy(sNew, 1);\n s = sNew;\n } else if (s[0] === 0x00 && !(s[1] & 0x80)) {\n s = s.slice(1);\n }\n asnWriter.writeBuffer(r, Ber.Integer);\n asnWriter.writeBuffer(s, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521': {\n utilBufferParser.init(sig, 0);\n const r = utilBufferParser.readString();\n const s = utilBufferParser.readString();\n utilBufferParser.clear();\n if (r === undefined || s === undefined)\n return;\n\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeBuffer(r, Ber.Integer);\n asnWriter.writeBuffer(s, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n default:\n return sig;\n }\n },\n convertSignature: (signature, keyType) => {\n switch (keyType) {\n case 'ssh-dss': {\n if (signature.length <= 40)\n return signature;\n // This is a quick and dirty way to get from BER encoded r and s that\n // OpenSSL gives us, to just the bare values back to back (40 bytes\n // total) like OpenSSH (and possibly others) are expecting\n const asnReader = new Ber.Reader(signature);\n asnReader.readSequence();\n let r = asnReader.readString(Ber.Integer, true);\n let s = asnReader.readString(Ber.Integer, true);\n let rOffset = 0;\n let sOffset = 0;\n if (r.length < 20) {\n const rNew = Buffer.allocUnsafe(20);\n rNew.set(r, 1);\n r = rNew;\n r[0] = 0;\n }\n if (s.length < 20) {\n const sNew = Buffer.allocUnsafe(20);\n sNew.set(s, 1);\n s = sNew;\n s[0] = 0;\n }\n if (r.length > 20 && r[0] === 0)\n rOffset = 1;\n if (s.length > 20 && s[0] === 0)\n sOffset = 1;\n const newSig =\n Buffer.allocUnsafe((r.length - rOffset) + (s.length - sOffset));\n bufferCopy(r, newSig, rOffset, r.length, 0);\n bufferCopy(s, newSig, sOffset, s.length, r.length - rOffset);\n return newSig;\n }\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521': {\n if (signature[0] === 0)\n return signature;\n // Convert SSH signature parameters to ASN.1 BER values for OpenSSL\n const asnReader = new Ber.Reader(signature);\n asnReader.readSequence();\n const r = asnReader.readString(Ber.Integer, true);\n const s = asnReader.readString(Ber.Integer, true);\n if (r === null || s === null)\n return;\n const newSig = Buffer.allocUnsafe(4 + r.length + 4 + s.length);\n writeUInt32BE(newSig, r.length, 0);\n newSig.set(r, 4);\n writeUInt32BE(newSig, s.length, 4 + r.length);\n newSig.set(s, 4 + 4 + r.length);\n return newSig;\n }\n }\n\n return signature;\n },\n sendPacket: (proto, packet, bypass) => {\n if (!bypass && proto._kexinit !== undefined) {\n // We're currently in the middle of a handshake\n\n if (proto._queue === undefined)\n proto._queue = [];\n proto._queue.push(packet);\n proto._debug && proto._debug('Outbound: ... packet queued');\n return false;\n }\n proto._cipher.encrypt(packet);\n return true;\n },\n};\n","'use strict';\n\nconst { kMaxLength } = require('buffer');\nconst {\n createInflate,\n constants: {\n DEFLATE,\n INFLATE,\n Z_DEFAULT_CHUNK,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_MEMLEVEL,\n Z_DEFAULT_STRATEGY,\n Z_DEFAULT_WINDOWBITS,\n Z_PARTIAL_FLUSH,\n }\n} = require('zlib');\nconst ZlibHandle = createInflate()._handle.constructor;\n\nfunction processCallback() {\n throw new Error('Should not get here');\n}\n\nfunction zlibOnError(message, errno, code) {\n const self = this._owner;\n // There is no way to cleanly recover.\n // Continuing only obscures problems.\n\n const error = new Error(message);\n error.errno = errno;\n error.code = code;\n self._err = error;\n}\n\nfunction _close(engine) {\n // Caller may invoke .close after a zlib error (which will null _handle).\n if (!engine._handle)\n return;\n\n engine._handle.close();\n engine._handle = null;\n}\n\nclass Zlib {\n constructor(mode) {\n const windowBits = Z_DEFAULT_WINDOWBITS;\n const level = Z_DEFAULT_COMPRESSION;\n const memLevel = Z_DEFAULT_MEMLEVEL;\n const strategy = Z_DEFAULT_STRATEGY;\n const dictionary = undefined;\n\n this._err = undefined;\n this._writeState = new Uint32Array(2);\n this._chunkSize = Z_DEFAULT_CHUNK;\n this._maxOutputLength = kMaxLength;\n this._outBuffer = Buffer.allocUnsafe(this._chunkSize);\n this._outOffset = 0;\n\n this._handle = new ZlibHandle(mode);\n this._handle._owner = this;\n this._handle.onerror = zlibOnError;\n this._handle.init(windowBits,\n level,\n memLevel,\n strategy,\n this._writeState,\n processCallback,\n dictionary);\n }\n\n writeSync(chunk, retChunks) {\n const handle = this._handle;\n if (!handle)\n throw new Error('Invalid Zlib instance');\n\n let availInBefore = chunk.length;\n let availOutBefore = this._chunkSize - this._outOffset;\n let inOff = 0;\n let availOutAfter;\n let availInAfter;\n\n let buffers;\n let nread = 0;\n const state = this._writeState;\n let buffer = this._outBuffer;\n let offset = this._outOffset;\n const chunkSize = this._chunkSize;\n\n while (true) {\n handle.writeSync(Z_PARTIAL_FLUSH,\n chunk, // in\n inOff, // in_off\n availInBefore, // in_len\n buffer, // out\n offset, // out_off\n availOutBefore); // out_len\n if (this._err)\n throw this._err;\n\n availOutAfter = state[0];\n availInAfter = state[1];\n\n const inDelta = availInBefore - availInAfter;\n const have = availOutBefore - availOutAfter;\n\n if (have > 0) {\n const out = (offset === 0 && have === buffer.length\n ? buffer\n : buffer.slice(offset, offset + have));\n offset += have;\n if (!buffers)\n buffers = out;\n else if (buffers.push === undefined)\n buffers = [buffers, out];\n else\n buffers.push(out);\n nread += out.byteLength;\n\n if (nread > this._maxOutputLength) {\n _close(this);\n throw new Error(\n `Output length exceeded maximum of ${this._maxOutputLength}`\n );\n }\n } else if (have !== 0) {\n throw new Error('have should not go down');\n }\n\n // Exhausted the output buffer, or used all the input create a new one.\n if (availOutAfter === 0 || offset >= chunkSize) {\n availOutBefore = chunkSize;\n offset = 0;\n buffer = Buffer.allocUnsafe(chunkSize);\n }\n\n if (availOutAfter === 0) {\n // Not actually done. Need to reprocess.\n // Also, update the availInBefore to the availInAfter value,\n // so that if we have to hit it a third (fourth, etc.) time,\n // it'll have the correct byte counts.\n inOff += inDelta;\n availInBefore = availInAfter;\n } else {\n break;\n }\n }\n\n this._outBuffer = buffer;\n this._outOffset = offset;\n\n if (nread === 0)\n buffers = Buffer.alloc(0);\n\n if (retChunks) {\n buffers.totalLen = nread;\n return buffers;\n }\n\n if (buffers.push === undefined)\n return buffers;\n\n const output = Buffer.allocUnsafe(nread);\n for (let i = 0, p = 0; i < buffers.length; ++i) {\n const buf = buffers[i];\n output.set(buf, p);\n p += buf.length;\n }\n return output;\n }\n}\n\nclass ZlibPacketWriter {\n constructor(protocol) {\n this.allocStart = 0;\n this.allocStartKEX = 0;\n this._protocol = protocol;\n this._zlib = new Zlib(DEFLATE);\n }\n\n cleanup() {\n if (this._zlib)\n _close(this._zlib);\n }\n\n alloc(payloadSize, force) {\n return Buffer.allocUnsafe(payloadSize);\n }\n\n finalize(payload, force) {\n if (this._protocol._kexinit === undefined || force) {\n const output = this._zlib.writeSync(payload, true);\n const packet = this._protocol._cipher.allocPacket(output.totalLen);\n if (output.push === undefined) {\n packet.set(output, 5);\n } else {\n for (let i = 0, p = 5; i < output.length; ++i) {\n const chunk = output[i];\n packet.set(chunk, p);\n p += chunk.length;\n }\n }\n return packet;\n }\n return payload;\n }\n}\n\nclass PacketWriter {\n constructor(protocol) {\n this.allocStart = 5;\n this.allocStartKEX = 5;\n this._protocol = protocol;\n }\n\n cleanup() {}\n\n alloc(payloadSize, force) {\n if (this._protocol._kexinit === undefined || force)\n return this._protocol._cipher.allocPacket(payloadSize);\n return Buffer.allocUnsafe(payloadSize);\n }\n\n finalize(packet, force) {\n return packet;\n }\n}\n\nclass ZlibPacketReader {\n constructor() {\n this._zlib = new Zlib(INFLATE);\n }\n\n cleanup() {\n if (this._zlib)\n _close(this._zlib);\n }\n\n read(data) {\n return this._zlib.writeSync(data, false);\n }\n}\n\nclass PacketReader {\n cleanup() {}\n\n read(data) {\n return data;\n }\n}\n\nmodule.exports = {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n};\n","// TODO:\n// * convert listenerCount() usage to emit() return value checking?\n// * emit error when connection severed early (e.g. before handshake)\n// * add '.connected' or similar property to connection objects to allow\n// immediate connection status checking\n'use strict';\n\nconst { Server: netServer } = require('net');\nconst EventEmitter = require('events');\nconst { listenerCount } = EventEmitter;\n\nconst {\n CHANNEL_OPEN_FAILURE,\n DEFAULT_CIPHER,\n DEFAULT_COMPRESSION,\n DEFAULT_KEX,\n DEFAULT_MAC,\n DEFAULT_SERVER_HOST_KEY,\n DISCONNECT_REASON,\n DISCONNECT_REASON_BY_VALUE,\n SUPPORTED_CIPHER,\n SUPPORTED_COMPRESSION,\n SUPPORTED_KEX,\n SUPPORTED_MAC,\n SUPPORTED_SERVER_HOST_KEY,\n} = require('./protocol/constants.js');\nconst { init: cryptoInit } = require('./protocol/crypto.js');\nconst { KexInit } = require('./protocol/kex.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst Protocol = require('./protocol/Protocol.js');\nconst { SFTP } = require('./protocol/SFTP.js');\nconst { writeUInt32BE } = require('./protocol/utils.js');\n\nconst {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n} = require('./Channel.js');\n\nconst {\n ChannelManager,\n generateAlgorithmList,\n isWritable,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n} = require('./utils.js');\n\nconst MAX_PENDING_AUTHS = 10;\n\nclass AuthContext extends EventEmitter {\n constructor(protocol, username, service, method, cb) {\n super();\n\n this.username = this.user = username;\n this.service = service;\n this.method = method;\n this._initialResponse = false;\n this._finalResponse = false;\n this._multistep = false;\n this._cbfinal = (allowed, methodsLeft, isPartial) => {\n if (!this._finalResponse) {\n this._finalResponse = true;\n cb(this, allowed, methodsLeft, isPartial);\n }\n };\n this._protocol = protocol;\n }\n\n accept() {\n this._cleanup && this._cleanup();\n this._initialResponse = true;\n this._cbfinal(true);\n }\n reject(methodsLeft, isPartial) {\n this._cleanup && this._cleanup();\n this._initialResponse = true;\n this._cbfinal(false, methodsLeft, isPartial);\n }\n}\n\n\nclass KeyboardAuthContext extends AuthContext {\n constructor(protocol, username, service, method, submethods, cb) {\n super(protocol, username, service, method, cb);\n\n this._multistep = true;\n\n this._cb = undefined;\n this._onInfoResponse = (responses) => {\n const callback = this._cb;\n if (callback) {\n this._cb = undefined;\n callback(responses);\n }\n };\n this.submethods = submethods;\n this.on('abort', () => {\n this._cb && this._cb(new Error('Authentication request aborted'));\n });\n }\n\n prompt(prompts, title, instructions, cb) {\n if (!Array.isArray(prompts))\n prompts = [ prompts ];\n\n if (typeof title === 'function') {\n cb = title;\n title = instructions = undefined;\n } else if (typeof instructions === 'function') {\n cb = instructions;\n instructions = undefined;\n } else if (typeof cb !== 'function') {\n cb = undefined;\n }\n\n for (let i = 0; i < prompts.length; ++i) {\n if (typeof prompts[i] === 'string') {\n prompts[i] = {\n prompt: prompts[i],\n echo: true\n };\n }\n }\n\n this._cb = cb;\n this._initialResponse = true;\n\n this._protocol.authInfoReq(title, instructions, prompts);\n }\n}\n\nclass PKAuthContext extends AuthContext {\n constructor(protocol, username, service, method, pkInfo, cb) {\n super(protocol, username, service, method, cb);\n\n this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };\n this.signature = pkInfo.signature;\n this.blob = pkInfo.blob;\n }\n\n accept() {\n if (!this.signature) {\n this._initialResponse = true;\n this._protocol.authPKOK(this.key.algo, this.key.data);\n } else {\n AuthContext.prototype.accept.call(this);\n }\n }\n}\n\nclass HostbasedAuthContext extends AuthContext {\n constructor(protocol, username, service, method, pkInfo, cb) {\n super(protocol, username, service, method, cb);\n\n this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };\n this.signature = pkInfo.signature;\n this.blob = pkInfo.blob;\n this.localHostname = pkInfo.localHostname;\n this.localUsername = pkInfo.localUsername;\n }\n}\n\nclass PwdAuthContext extends AuthContext {\n constructor(protocol, username, service, method, password, cb) {\n super(protocol, username, service, method, cb);\n\n this.password = password;\n this._changeCb = undefined;\n }\n\n requestChange(prompt, cb) {\n if (this._changeCb)\n throw new Error('Change request already in progress');\n if (typeof prompt !== 'string')\n throw new Error('prompt argument must be a string');\n if (typeof cb !== 'function')\n throw new Error('Callback argument must be a function');\n this._changeCb = cb;\n this._protocol.authPasswdChg(prompt);\n }\n}\n\n\nclass Session extends EventEmitter {\n constructor(client, info, localChan) {\n super();\n\n this.type = 'session';\n this.subtype = undefined;\n this.server = true;\n this._ending = false;\n this._channel = undefined;\n this._chanInfo = {\n type: 'session',\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n }\n}\n\n\nclass Server extends EventEmitter {\n constructor(cfg, listener) {\n super();\n\n if (typeof cfg !== 'object' || cfg === null)\n throw new Error('Missing configuration object');\n\n const hostKeys = Object.create(null);\n const hostKeyAlgoOrder = [];\n\n const hostKeys_ = cfg.hostKeys;\n if (!Array.isArray(hostKeys_))\n throw new Error('hostKeys must be an array');\n\n const cfgAlgos = (\n typeof cfg.algorithms === 'object' && cfg.algorithms !== null\n ? cfg.algorithms\n : {}\n );\n\n const hostKeyAlgos = generateAlgorithmList(\n cfgAlgos.serverHostKey,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY\n );\n for (let i = 0; i < hostKeys_.length; ++i) {\n let privateKey;\n if (Buffer.isBuffer(hostKeys_[i]) || typeof hostKeys_[i] === 'string')\n privateKey = parseKey(hostKeys_[i]);\n else\n privateKey = parseKey(hostKeys_[i].key, hostKeys_[i].passphrase);\n\n if (privateKey instanceof Error)\n throw new Error(`Cannot parse privateKey: ${privateKey.message}`);\n\n if (Array.isArray(privateKey)) {\n // OpenSSH's newer format only stores 1 key for now\n privateKey = privateKey[0];\n }\n\n if (privateKey.getPrivatePEM() === null)\n throw new Error('privateKey value contains an invalid private key');\n\n // Discard key if we already found a key of the same type\n if (hostKeyAlgoOrder.includes(privateKey.type))\n continue;\n\n if (privateKey.type === 'ssh-rsa') {\n // SSH supports multiple signature hashing algorithms for RSA, so we add\n // the algorithms in the desired order\n let sha1Pos = hostKeyAlgos.indexOf('ssh-rsa');\n const sha256Pos = hostKeyAlgos.indexOf('rsa-sha2-256');\n const sha512Pos = hostKeyAlgos.indexOf('rsa-sha2-512');\n if (sha1Pos === -1) {\n // Fall back to giving SHA1 the lowest priority\n sha1Pos = Infinity;\n }\n [sha1Pos, sha256Pos, sha512Pos].sort(compareNumbers).forEach((pos) => {\n if (pos === -1)\n return;\n\n let type;\n switch (pos) {\n case sha1Pos: type = 'ssh-rsa'; break;\n case sha256Pos: type = 'rsa-sha2-256'; break;\n case sha512Pos: type = 'rsa-sha2-512'; break;\n default: return;\n }\n\n // Store same RSA key under each hash algorithm name for convenience\n hostKeys[type] = privateKey;\n\n hostKeyAlgoOrder.push(type);\n });\n } else {\n hostKeys[privateKey.type] = privateKey;\n hostKeyAlgoOrder.push(privateKey.type);\n }\n }\n\n const algorithms = {\n kex: generateAlgorithmList(cfgAlgos.kex, DEFAULT_KEX, SUPPORTED_KEX),\n serverHostKey: hostKeyAlgoOrder,\n cs: {\n cipher: generateAlgorithmList(\n cfgAlgos.cipher,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER\n ),\n mac: generateAlgorithmList(cfgAlgos.hmac, DEFAULT_MAC, SUPPORTED_MAC),\n compress: generateAlgorithmList(\n cfgAlgos.compress,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION\n ),\n lang: [],\n },\n sc: undefined,\n };\n algorithms.sc = algorithms.cs;\n\n if (typeof listener === 'function')\n this.on('connection', listener);\n\n const origDebug = (typeof cfg.debug === 'function' ? cfg.debug : undefined);\n const ident = (cfg.ident ? Buffer.from(cfg.ident) : undefined);\n const offer = new KexInit(algorithms);\n\n this._srv = new netServer((socket) => {\n if (this._connections >= this.maxConnections) {\n socket.destroy();\n return;\n }\n ++this._connections;\n socket.once('close', () => {\n --this._connections;\n });\n\n let debug;\n if (origDebug) {\n // Prepend debug output with a unique identifier in case there are\n // multiple clients connected at the same time\n const debugPrefix = `[${process.hrtime().join('.')}] `;\n debug = (msg) => {\n origDebug(`${debugPrefix}${msg}`);\n };\n }\n\n // eslint-disable-next-line no-use-before-define\n new Client(socket, hostKeys, ident, offer, debug, this, cfg);\n }).on('error', (err) => {\n this.emit('error', err);\n }).on('listening', () => {\n this.emit('listening');\n }).on('close', () => {\n this.emit('close');\n });\n this._connections = 0;\n this.maxConnections = Infinity;\n }\n\n injectSocket(socket) {\n this._srv.emit('connection', socket);\n }\n\n listen(...args) {\n this._srv.listen(...args);\n return this;\n }\n\n address() {\n return this._srv.address();\n }\n\n getConnections(cb) {\n this._srv.getConnections(cb);\n return this;\n }\n\n close(cb) {\n this._srv.close(cb);\n return this;\n }\n\n ref() {\n this._srv.ref();\n return this;\n }\n\n unref() {\n this._srv.unref();\n return this;\n }\n}\nServer.KEEPALIVE_CLIENT_INTERVAL = 15000;\nServer.KEEPALIVE_CLIENT_COUNT_MAX = 3;\n\n\nclass Client extends EventEmitter {\n constructor(socket, hostKeys, ident, offer, debug, server, srvCfg) {\n super();\n\n let exchanges = 0;\n let acceptedAuthSvc = false;\n let pendingAuths = [];\n let authCtx;\n let kaTimer;\n let onPacket;\n const unsentGlobalRequestsReplies = [];\n this._sock = socket;\n this._chanMgr = new ChannelManager(this);\n this._debug = debug;\n this.noMoreSessions = false;\n this.authenticated = false;\n\n // Silence pre-header errors\n function onClientPreHeaderError(err) {}\n this.on('error', onClientPreHeaderError);\n\n const DEBUG_HANDLER = (!debug ? undefined : (p, display, msg) => {\n debug(`Debug output from client: ${JSON.stringify(msg)}`);\n });\n\n const kaIntvl = (\n typeof srvCfg.keepaliveInterval === 'number'\n && isFinite(srvCfg.keepaliveInterval)\n && srvCfg.keepaliveInterval > 0\n ? srvCfg.keepaliveInterval\n : (\n typeof Server.KEEPALIVE_CLIENT_INTERVAL === 'number'\n && isFinite(Server.KEEPALIVE_CLIENT_INTERVAL)\n && Server.KEEPALIVE_CLIENT_INTERVAL > 0\n ? Server.KEEPALIVE_CLIENT_INTERVAL\n : -1\n )\n );\n const kaCountMax = (\n typeof srvCfg.keepaliveCountMax === 'number'\n && isFinite(srvCfg.keepaliveCountMax)\n && srvCfg.keepaliveCountMax >= 0\n ? srvCfg.keepaliveCountMax\n : (\n typeof Server.KEEPALIVE_CLIENT_COUNT_MAX === 'number'\n && isFinite(Server.KEEPALIVE_CLIENT_COUNT_MAX)\n && Server.KEEPALIVE_CLIENT_COUNT_MAX >= 0\n ? Server.KEEPALIVE_CLIENT_COUNT_MAX\n : -1\n )\n );\n let kaCurCount = 0;\n if (kaIntvl !== -1 && kaCountMax !== -1) {\n this.once('ready', () => {\n const onClose = () => {\n clearInterval(kaTimer);\n };\n this.on('close', onClose).on('end', onClose);\n kaTimer = setInterval(() => {\n if (++kaCurCount > kaCountMax) {\n clearInterval(kaTimer);\n const err = new Error('Keepalive timeout');\n err.level = 'client-timeout';\n this.emit('error', err);\n this.end();\n } else {\n // XXX: if the server ever starts sending real global requests to\n // the client, we will need to add a dummy callback here to\n // keep the correct reply order\n proto.ping();\n }\n }, kaIntvl);\n });\n // TODO: re-verify keepalive behavior with OpenSSH\n onPacket = () => {\n kaTimer && kaTimer.refresh();\n kaCurCount = 0;\n };\n }\n\n const proto = this._protocol = new Protocol({\n server: true,\n hostKeys,\n ident,\n offer,\n onPacket,\n greeting: srvCfg.greeting,\n banner: srvCfg.banner,\n onWrite: (data) => {\n if (isWritable(socket))\n socket.write(data);\n },\n onError: (err) => {\n if (!proto._destruct)\n socket.removeAllListeners('data');\n this.emit('error', err);\n try {\n socket.end();\n } catch {}\n },\n onHeader: (header) => {\n this.removeListener('error', onClientPreHeaderError);\n\n const info = {\n ip: socket.remoteAddress,\n family: socket.remoteFamily,\n port: socket.remotePort,\n header,\n };\n if (!server.emit('connection', this, info)) {\n // auto reject\n proto.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n socket.end();\n return;\n }\n\n if (header.greeting)\n this.emit('greeting', header.greeting);\n },\n onHandshakeComplete: (negotiated) => {\n if (++exchanges > 1)\n this.emit('rekey');\n this.emit('handshake', negotiated);\n },\n debug,\n messageHandlers: {\n DEBUG: DEBUG_HANDLER,\n DISCONNECT: (p, reason, desc) => {\n if (reason !== DISCONNECT_REASON.BY_APPLICATION) {\n if (!desc) {\n desc = DISCONNECT_REASON_BY_VALUE[reason];\n if (desc === undefined)\n desc = `Unexpected disconnection reason: ${reason}`;\n }\n const err = new Error(desc);\n err.code = reason;\n this.emit('error', err);\n }\n socket.end();\n },\n CHANNEL_OPEN: (p, info) => {\n // Handle incoming requests from client\n\n // Do early reject in some cases to prevent wasteful channel\n // allocation\n if ((info.type === 'session' && this.noMoreSessions)\n || !this.authenticated) {\n const reasonCode = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n return proto.channelOpenFail(info.sender, reasonCode);\n }\n\n let localChan = -1;\n let reason;\n let replied = false;\n\n let accept;\n const reject = () => {\n if (replied)\n return;\n replied = true;\n\n if (reason === undefined) {\n if (localChan === -1)\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n else\n reason = CHANNEL_OPEN_FAILURE.CONNECT_FAILED;\n }\n\n if (localChan !== -1)\n this._chanMgr.remove(localChan);\n proto.channelOpenFail(info.sender, reason, '');\n };\n const reserveChannel = () => {\n localChan = this._chanMgr.add();\n\n if (localChan === -1) {\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n if (debug) {\n debug('Automatic rejection of incoming channel open: '\n + 'no channels available');\n }\n }\n\n return (localChan !== -1);\n };\n\n const data = info.data;\n switch (info.type) {\n case 'session':\n if (listenerCount(this, 'session') && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const instance = new Session(this, info, localChan);\n this._chanMgr.update(localChan, instance);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return instance;\n };\n\n this.emit('session', accept, reject);\n return;\n }\n break;\n case 'direct-tcpip':\n if (listenerCount(this, 'tcpip') && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const chanInfo = {\n type: undefined,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const stream = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(localChan, stream);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return stream;\n };\n\n this.emit('tcpip', accept, reject, data);\n return;\n }\n break;\n case 'direct-streamlocal@openssh.com':\n if (listenerCount(this, 'openssh.streamlocal')\n && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const chanInfo = {\n type: undefined,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const stream = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(localChan, stream);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return stream;\n };\n\n this.emit('openssh.streamlocal', accept, reject, data);\n return;\n }\n break;\n default:\n // Automatically reject any unsupported channel open requests\n reason = CHANNEL_OPEN_FAILURE.UNKNOWN_CHANNEL_TYPE;\n if (debug) {\n debug('Automatic rejection of unsupported incoming channel open'\n + ` type: ${info.type}`);\n }\n }\n\n if (reason === undefined) {\n reason = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n if (debug) {\n debug('Automatic rejection of unexpected incoming channel open'\n + ` for: ${info.type}`);\n }\n }\n\n reject();\n },\n CHANNEL_OPEN_CONFIRMATION: (p, info) => {\n const channel = this._chanMgr.get(info.recipient);\n if (typeof channel !== 'function')\n return;\n\n const chanInfo = {\n type: channel.type,\n incoming: {\n id: info.recipient,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const instance = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(info.recipient, instance);\n channel(undefined, instance);\n },\n CHANNEL_OPEN_FAILURE: (p, recipient, reason, description) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'function')\n return;\n\n const info = { reason, description };\n onChannelOpenFailure(this, recipient, info, channel);\n },\n CHANNEL_DATA: (p, recipient, data) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (channel.push(data) === false) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_EXTENDED_DATA: (p, recipient, data, type) => {\n // NOOP -- should not be sent by client\n },\n CHANNEL_WINDOW_ADJUST: (p, recipient, amount) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n // The other side is allowing us to send `amount` more bytes of data\n channel.outgoing.window += amount;\n\n if (channel._waitWindow) {\n channel._waitWindow = false;\n\n if (channel._chunk) {\n channel._write(channel._chunk, null, channel._chunkcb);\n } else if (channel._chunkcb) {\n channel._chunkcb();\n } else if (channel._chunkErr) {\n channel.stderr._write(channel._chunkErr,\n null,\n channel._chunkcbErr);\n } else if (channel._chunkcbErr) {\n channel._chunkcbErr();\n }\n }\n },\n CHANNEL_SUCCESS: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(false);\n },\n CHANNEL_FAILURE: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(true);\n },\n CHANNEL_REQUEST: (p, recipient, type, wantReply, data) => {\n const session = this._chanMgr.get(recipient);\n if (typeof session !== 'object' || session === null)\n return;\n\n let replied = false;\n let accept;\n let reject;\n\n if (session.constructor !== Session) {\n // normal Channel instance\n if (wantReply)\n proto.channelFailure(session.outgoing.id);\n return;\n }\n\n if (wantReply) {\n // \"real session\" requests will have custom accept behaviors\n if (type !== 'shell'\n && type !== 'exec'\n && type !== 'subsystem') {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n proto.channelSuccess(session._chanInfo.outgoing.id);\n };\n }\n\n reject = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n proto.channelFailure(session._chanInfo.outgoing.id);\n };\n }\n\n if (session._ending) {\n reject && reject();\n return;\n }\n\n switch (type) {\n // \"pre-real session start\" requests\n case 'env':\n if (listenerCount(session, 'env')) {\n session.emit('env', accept, reject, {\n key: data.name,\n val: data.value\n });\n return;\n }\n break;\n case 'pty-req':\n if (listenerCount(session, 'pty')) {\n session.emit('pty', accept, reject, data);\n return;\n }\n break;\n case 'window-change':\n if (listenerCount(session, 'window-change'))\n session.emit('window-change', accept, reject, data);\n else\n reject && reject();\n break;\n case 'x11-req':\n if (listenerCount(session, 'x11')) {\n session.emit('x11', accept, reject, data);\n return;\n }\n break;\n // \"post-real session start\" requests\n case 'signal':\n if (listenerCount(session, 'signal')) {\n session.emit('signal', accept, reject, {\n name: data\n });\n return;\n }\n break;\n // XXX: is `auth-agent-req@openssh.com` really \"post-real session\n // start\"?\n case 'auth-agent-req@openssh.com':\n if (listenerCount(session, 'auth-agent')) {\n session.emit('auth-agent', accept, reject);\n return;\n }\n break;\n // \"real session start\" requests\n case 'shell':\n if (listenerCount(session, 'shell')) {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n const channel = new Channel(\n this, session._chanInfo, { server: true }\n );\n\n channel.subtype = session.subtype = type;\n session._channel = channel;\n\n return channel;\n };\n\n session.emit('shell', accept, reject);\n return;\n }\n break;\n case 'exec':\n if (listenerCount(session, 'exec')) {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n const channel = new Channel(\n this, session._chanInfo, { server: true }\n );\n\n channel.subtype = session.subtype = type;\n session._channel = channel;\n\n return channel;\n };\n\n session.emit('exec', accept, reject, {\n command: data\n });\n return;\n }\n break;\n case 'subsystem': {\n let useSFTP = (data === 'sftp');\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n let instance;\n if (useSFTP) {\n instance = new SFTP(this, session._chanInfo, {\n server: true,\n debug,\n });\n } else {\n instance = new Channel(\n this, session._chanInfo, { server: true }\n );\n instance.subtype =\n session.subtype = `${type}:${data}`;\n }\n session._channel = instance;\n\n return instance;\n };\n\n if (data === 'sftp') {\n if (listenerCount(session, 'sftp')) {\n session.emit('sftp', accept, reject);\n return;\n }\n useSFTP = false;\n }\n if (listenerCount(session, 'subsystem')) {\n session.emit('subsystem', accept, reject, {\n name: data\n });\n return;\n }\n break;\n }\n }\n debug && debug(\n `Automatic rejection of incoming channel request: ${type}`\n );\n reject && reject();\n },\n CHANNEL_EOF: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n if (!channel._ending) {\n channel._ending = true;\n channel.emit('eof');\n channel.emit('end');\n }\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel.incoming.state !== 'open')\n return;\n channel.incoming.state = 'eof';\n\n if (channel.readable)\n channel.push(null);\n },\n CHANNEL_CLOSE: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel._ending = true;\n channel.emit('close');\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n onCHANNEL_CLOSE(this, recipient, channel);\n },\n // Begin service/auth-related ==========================================\n SERVICE_REQUEST: (p, service) => {\n if (exchanges === 0\n || acceptedAuthSvc\n || this.authenticated\n || service !== 'ssh-userauth') {\n proto.disconnect(DISCONNECT_REASON.SERVICE_NOT_AVAILABLE);\n socket.end();\n return;\n }\n\n acceptedAuthSvc = true;\n proto.serviceAccept(service);\n },\n USERAUTH_REQUEST: (p, username, service, method, methodData) => {\n if (exchanges === 0\n || this.authenticated\n || (authCtx\n && (authCtx.username !== username\n || authCtx.service !== service))\n // TODO: support hostbased auth\n || (method !== 'password'\n && method !== 'publickey'\n && method !== 'hostbased'\n && method !== 'keyboard-interactive'\n && method !== 'none')\n || pendingAuths.length === MAX_PENDING_AUTHS) {\n proto.disconnect(DISCONNECT_REASON.PROTOCOL_ERROR);\n socket.end();\n return;\n } else if (service !== 'ssh-connection') {\n proto.disconnect(DISCONNECT_REASON.SERVICE_NOT_AVAILABLE);\n socket.end();\n return;\n }\n\n let ctx;\n switch (method) {\n case 'keyboard-interactive':\n ctx = new KeyboardAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'publickey':\n ctx = new PKAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'hostbased':\n ctx = new HostbasedAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'password':\n if (authCtx\n && authCtx instanceof PwdAuthContext\n && authCtx._changeCb) {\n const cb = authCtx._changeCb;\n authCtx._changeCb = undefined;\n cb(methodData.newPassword);\n return;\n }\n ctx = new PwdAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'none':\n ctx = new AuthContext(proto, username, service, method,\n onAuthDecide);\n break;\n }\n\n if (authCtx) {\n if (!authCtx._initialResponse) {\n return pendingAuths.push(ctx);\n } else if (authCtx._multistep && !authCtx._finalResponse) {\n // RFC 4252 says to silently abort the current auth request if a\n // new auth request comes in before the final response from an\n // auth method that requires additional request/response exchanges\n // -- this means keyboard-interactive for now ...\n authCtx._cleanup && authCtx._cleanup();\n authCtx.emit('abort');\n }\n }\n\n authCtx = ctx;\n\n if (listenerCount(this, 'authentication'))\n this.emit('authentication', authCtx);\n else\n authCtx.reject();\n },\n USERAUTH_INFO_RESPONSE: (p, responses) => {\n if (authCtx && authCtx instanceof KeyboardAuthContext)\n authCtx._onInfoResponse(responses);\n },\n // End service/auth-related ============================================\n GLOBAL_REQUEST: (p, name, wantReply, data) => {\n const reply = {\n type: null,\n buf: null\n };\n\n function setReply(type, buf) {\n reply.type = type;\n reply.buf = buf;\n sendReplies();\n }\n\n if (wantReply)\n unsentGlobalRequestsReplies.push(reply);\n\n if ((name === 'tcpip-forward'\n || name === 'cancel-tcpip-forward'\n || name === 'no-more-sessions@openssh.com'\n || name === 'streamlocal-forward@openssh.com'\n || name === 'cancel-streamlocal-forward@openssh.com')\n && listenerCount(this, 'request')\n && this.authenticated) {\n let accept;\n let reject;\n\n if (wantReply) {\n let replied = false;\n accept = (chosenPort) => {\n if (replied)\n return;\n replied = true;\n let bufPort;\n if (name === 'tcpip-forward'\n && data.bindPort === 0\n && typeof chosenPort === 'number') {\n bufPort = Buffer.allocUnsafe(4);\n writeUInt32BE(bufPort, chosenPort, 0);\n }\n setReply('SUCCESS', bufPort);\n };\n reject = () => {\n if (replied)\n return;\n replied = true;\n setReply('FAILURE');\n };\n }\n\n if (name === 'no-more-sessions@openssh.com') {\n this.noMoreSessions = true;\n accept && accept();\n return;\n }\n\n this.emit('request', accept, reject, name, data);\n } else if (wantReply) {\n setReply('FAILURE');\n }\n },\n },\n });\n\n socket.pause();\n cryptoInit.then(() => {\n proto.start();\n socket.on('data', (data) => {\n try {\n proto.parse(data, 0, data.length);\n } catch (ex) {\n this.emit('error', ex);\n try {\n if (isWritable(socket))\n socket.end();\n } catch {}\n }\n });\n socket.resume();\n }).catch((err) => {\n this.emit('error', err);\n try {\n if (isWritable(socket))\n socket.end();\n } catch {}\n });\n socket.on('error', (err) => {\n err.level = 'socket';\n this.emit('error', err);\n }).once('end', () => {\n debug && debug('Socket ended');\n proto.cleanup();\n this.emit('end');\n }).once('close', () => {\n debug && debug('Socket closed');\n proto.cleanup();\n this.emit('close');\n\n const err = new Error('No response from server');\n\n // Simulate error for pending channels and close any open channels\n this._chanMgr.cleanup(err);\n });\n\n const onAuthDecide = (ctx, allowed, methodsLeft, isPartial) => {\n if (authCtx === ctx && !this.authenticated) {\n if (allowed) {\n authCtx = undefined;\n this.authenticated = true;\n proto.authSuccess();\n pendingAuths = [];\n this.emit('ready');\n } else {\n proto.authFailure(methodsLeft, isPartial);\n if (pendingAuths.length) {\n authCtx = pendingAuths.pop();\n if (listenerCount(this, 'authentication'))\n this.emit('authentication', authCtx);\n else\n authCtx.reject();\n }\n }\n }\n };\n\n function sendReplies() {\n while (unsentGlobalRequestsReplies.length > 0\n && unsentGlobalRequestsReplies[0].type) {\n const reply = unsentGlobalRequestsReplies.shift();\n if (reply.type === 'SUCCESS')\n proto.requestSuccess(reply.buf);\n if (reply.type === 'FAILURE')\n proto.requestFailure();\n }\n }\n }\n\n end() {\n if (this._sock && isWritable(this._sock)) {\n this._protocol.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n this._sock.end();\n }\n return this;\n }\n\n x11(originAddr, originPort, cb) {\n const opts = { originAddr, originPort };\n openChannel(this, 'x11', opts, cb);\n return this;\n }\n\n forwardOut(boundAddr, boundPort, remoteAddr, remotePort, cb) {\n const opts = { boundAddr, boundPort, remoteAddr, remotePort };\n openChannel(this, 'forwarded-tcpip', opts, cb);\n return this;\n }\n\n openssh_forwardOutStreamLocal(socketPath, cb) {\n const opts = { socketPath };\n openChannel(this, 'forwarded-streamlocal@openssh.com', opts, cb);\n return this;\n }\n\n rekey(cb) {\n let error;\n\n try {\n this._protocol.rekey();\n } catch (ex) {\n error = ex;\n }\n\n // TODO: re-throw error if no callback?\n\n if (typeof cb === 'function') {\n if (error)\n process.nextTick(cb, error);\n else\n this.once('rekey', cb);\n }\n }\n}\n\n\nfunction openChannel(self, type, opts, cb) {\n // Ask the client to open a channel for some purpose (e.g. a forwarded TCP\n // connection)\n const initWindow = MAX_WINDOW;\n const maxPacket = PACKET_SIZE;\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const wrapper = (err, stream) => {\n cb(err, stream);\n };\n wrapper.type = type;\n\n const localChan = self._chanMgr.add(wrapper);\n\n if (localChan === -1) {\n cb(new Error('No free channels available'));\n return;\n }\n\n switch (type) {\n case 'forwarded-tcpip':\n self._protocol.forwardedTcpip(localChan, initWindow, maxPacket, opts);\n break;\n case 'x11':\n self._protocol.x11(localChan, initWindow, maxPacket, opts);\n break;\n case 'forwarded-streamlocal@openssh.com':\n self._protocol.openssh_forwardedStreamLocal(\n localChan, initWindow, maxPacket, opts\n );\n break;\n default:\n throw new Error(`Unsupported channel type: ${type}`);\n }\n}\n\nfunction compareNumbers(a, b) {\n return a - b;\n}\n\nmodule.exports = Server;\nmodule.exports.IncomingClient = Client;\n","'use strict';\n\nconst { SFTP } = require('./protocol/SFTP.js');\n\nconst MAX_CHANNEL = 2 ** 32 - 1;\n\nfunction onChannelOpenFailure(self, recipient, info, cb) {\n self._chanMgr.remove(recipient);\n if (typeof cb !== 'function')\n return;\n\n let err;\n if (info instanceof Error) {\n err = info;\n } else if (typeof info === 'object' && info !== null) {\n err = new Error(`(SSH) Channel open failure: ${info.description}`);\n err.reason = info.reason;\n } else {\n err = new Error(\n '(SSH) Channel open failure: server closed channel unexpectedly'\n );\n err.reason = '';\n }\n\n cb(err);\n}\n\nfunction onCHANNEL_CLOSE(self, recipient, channel, err, dead) {\n if (typeof channel === 'function') {\n // We got CHANNEL_CLOSE instead of CHANNEL_OPEN_FAILURE when\n // requesting to open a channel\n onChannelOpenFailure(self, recipient, err, channel);\n return;\n }\n\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.incoming && channel.incoming.state === 'closed')\n return;\n\n self._chanMgr.remove(recipient);\n\n if (channel.server && channel.constructor.name === 'Session')\n return;\n\n channel.incoming.state = 'closed';\n\n if (channel.readable)\n channel.push(null);\n if (channel.server) {\n if (channel.stderr.writable)\n channel.stderr.end();\n } else if (channel.stderr.readable) {\n channel.stderr.push(null);\n }\n\n if (channel.constructor !== SFTP\n && (channel.outgoing.state === 'open'\n || channel.outgoing.state === 'eof')\n && !dead) {\n channel.close();\n }\n if (channel.outgoing.state === 'closing')\n channel.outgoing.state = 'closed';\n\n const readState = channel._readableState;\n const writeState = channel._writableState;\n if (writeState && !writeState.ending && !writeState.finished && !dead)\n channel.end();\n\n // Take care of any outstanding channel requests\n const chanCallbacks = channel._callbacks;\n channel._callbacks = [];\n for (let i = 0; i < chanCallbacks.length; ++i)\n chanCallbacks[i](true);\n\n if (channel.server) {\n if (!channel.readable\n || channel.destroyed\n || (readState && readState.endEmitted)) {\n channel.emit('close');\n } else {\n channel.once('end', () => channel.emit('close'));\n }\n } else {\n let doClose;\n switch (channel.type) {\n case 'direct-streamlocal@openssh.com':\n case 'direct-tcpip':\n doClose = () => channel.emit('close');\n break;\n default: {\n // Align more with node child processes, where the close event gets\n // the same arguments as the exit event\n const exit = channel._exit;\n doClose = () => {\n if (exit.code === null)\n channel.emit('close', exit.code, exit.signal, exit.dump, exit.desc);\n else\n channel.emit('close', exit.code);\n };\n }\n }\n if (!channel.readable\n || channel.destroyed\n || (readState && readState.endEmitted)) {\n doClose();\n } else {\n channel.once('end', doClose);\n }\n\n const errReadState = channel.stderr._readableState;\n if (!channel.stderr.readable\n || channel.stderr.destroyed\n || (errReadState && errReadState.endEmitted)) {\n channel.stderr.emit('close');\n } else {\n channel.stderr.once('end', () => channel.stderr.emit('close'));\n }\n }\n}\n\nclass ChannelManager {\n constructor(client) {\n this._client = client;\n this._channels = {};\n this._cur = -1;\n this._count = 0;\n }\n add(val) {\n // Attempt to reserve an id\n\n let id;\n // Optimized paths\n if (this._cur < MAX_CHANNEL) {\n id = ++this._cur;\n } else if (this._count === 0) {\n // Revert and reset back to fast path once we no longer have any channels\n // open\n this._cur = 0;\n id = 0;\n } else {\n // Slower lookup path\n\n // This path is triggered we have opened at least MAX_CHANNEL channels\n // while having at least one channel open at any given time, so we have\n // to search for a free id.\n const channels = this._channels;\n for (let i = 0; i < MAX_CHANNEL; ++i) {\n if (channels[i] === undefined) {\n id = i;\n break;\n }\n }\n }\n\n if (id === undefined)\n return -1;\n\n this._channels[id] = (val || true);\n ++this._count;\n\n return id;\n }\n update(id, val) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n if (val && this._channels[id])\n this._channels[id] = val;\n }\n get(id) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n return this._channels[id];\n }\n remove(id) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n if (this._channels[id]) {\n delete this._channels[id];\n if (this._count)\n --this._count;\n }\n }\n cleanup(err) {\n const channels = this._channels;\n this._channels = {};\n this._cur = -1;\n this._count = 0;\n\n const chanIDs = Object.keys(channels);\n const client = this._client;\n for (let i = 0; i < chanIDs.length; ++i) {\n const id = +chanIDs[i];\n const channel = channels[id];\n onCHANNEL_CLOSE(client, id, channel._channel || channel, err, true);\n }\n }\n}\n\nconst isRegExp = (() => {\n const toString = Object.prototype.toString;\n return (val) => toString.call(val) === '[object RegExp]';\n})();\n\nfunction generateAlgorithmList(algoList, defaultList, supportedList) {\n if (Array.isArray(algoList) && algoList.length > 0) {\n // Exact list\n for (let i = 0; i < algoList.length; ++i) {\n if (supportedList.indexOf(algoList[i]) === -1)\n throw new Error(`Unsupported algorithm: ${algoList[i]}`);\n }\n return algoList;\n }\n\n if (typeof algoList === 'object' && algoList !== null) {\n // Operations based on the default list\n const keys = Object.keys(algoList);\n let list = defaultList;\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n let val = algoList[key];\n switch (key) {\n case 'append':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = 0; j < val.length; ++j) {\n const append = val[j];\n if (typeof append === 'string') {\n if (!append || list.indexOf(append) !== -1)\n continue;\n if (supportedList.indexOf(append) === -1)\n throw new Error(`Unsupported algorithm: ${append}`);\n if (list === defaultList)\n list = list.slice();\n list.push(append);\n } else if (isRegExp(append)) {\n for (let k = 0; k < supportedList.length; ++k) {\n const algo = supportedList[k];\n if (append.test(algo)) {\n if (list.indexOf(algo) !== -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.push(algo);\n }\n }\n }\n }\n }\n break;\n case 'prepend':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = val.length; j >= 0; --j) {\n const prepend = val[j];\n if (typeof prepend === 'string') {\n if (!prepend || list.indexOf(prepend) !== -1)\n continue;\n if (supportedList.indexOf(prepend) === -1)\n throw new Error(`Unsupported algorithm: ${prepend}`);\n if (list === defaultList)\n list = list.slice();\n list.unshift(prepend);\n } else if (isRegExp(prepend)) {\n for (let k = supportedList.length; k >= 0; --k) {\n const algo = supportedList[k];\n if (prepend.test(algo)) {\n if (list.indexOf(algo) !== -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.unshift(algo);\n }\n }\n }\n }\n }\n break;\n case 'remove':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = 0; j < val.length; ++j) {\n const search = val[j];\n if (typeof search === 'string') {\n if (!search)\n continue;\n const idx = list.indexOf(search);\n if (idx === -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.splice(idx, 1);\n } else if (isRegExp(search)) {\n for (let k = 0; k < list.length; ++k) {\n if (search.test(list[k])) {\n if (list === defaultList)\n list = list.slice();\n list.splice(k, 1);\n --k;\n }\n }\n }\n }\n }\n break;\n }\n }\n\n return list;\n }\n\n return defaultList;\n}\n\nmodule.exports = {\n ChannelManager,\n generateAlgorithmList,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n isWritable: (stream) => {\n // XXX: hack to workaround regression in node\n // See: https://github.com/nodejs/node/issues/36029\n return (stream\n && stream.writable\n && stream._readableState\n && stream._readableState.ended === false);\n },\n};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\n/**/\n\nvar isEncoding = Buffer.isEncoding || function (encoding) {\n encoding = '' + encoding;\n switch (encoding && encoding.toLowerCase()) {\n case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':\n return true;\n default:\n return false;\n }\n};\n\nfunction _normalizeEncoding(enc) {\n if (!enc) return 'utf8';\n var retried;\n while (true) {\n switch (enc) {\n case 'utf8':\n case 'utf-8':\n return 'utf8';\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return 'utf16le';\n case 'latin1':\n case 'binary':\n return 'latin1';\n case 'base64':\n case 'ascii':\n case 'hex':\n return enc;\n default:\n if (retried) return; // undefined\n enc = ('' + enc).toLowerCase();\n retried = true;\n }\n }\n};\n\n// Do not cache `Buffer.isEncoding` when checking encoding names as some\n// modules monkey-patch it to support additional encodings\nfunction normalizeEncoding(enc) {\n var nenc = _normalizeEncoding(enc);\n if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);\n return nenc || enc;\n}\n\n// StringDecoder provides an interface for efficiently splitting a series of\n// buffers into a series of JS strings without breaking apart multi-byte\n// characters.\nexports.StringDecoder = StringDecoder;\nfunction StringDecoder(encoding) {\n this.encoding = normalizeEncoding(encoding);\n var nb;\n switch (this.encoding) {\n case 'utf16le':\n this.text = utf16Text;\n this.end = utf16End;\n nb = 4;\n break;\n case 'utf8':\n this.fillLast = utf8FillLast;\n nb = 4;\n break;\n case 'base64':\n this.text = base64Text;\n this.end = base64End;\n nb = 3;\n break;\n default:\n this.write = simpleWrite;\n this.end = simpleEnd;\n return;\n }\n this.lastNeed = 0;\n this.lastTotal = 0;\n this.lastChar = Buffer.allocUnsafe(nb);\n}\n\nStringDecoder.prototype.write = function (buf) {\n if (buf.length === 0) return '';\n var r;\n var i;\n if (this.lastNeed) {\n r = this.fillLast(buf);\n if (r === undefined) return '';\n i = this.lastNeed;\n this.lastNeed = 0;\n } else {\n i = 0;\n }\n if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);\n return r || '';\n};\n\nStringDecoder.prototype.end = utf8End;\n\n// Returns only complete characters in a Buffer\nStringDecoder.prototype.text = utf8Text;\n\n// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer\nStringDecoder.prototype.fillLast = function (buf) {\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);\n this.lastNeed -= buf.length;\n};\n\n// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a\n// continuation byte. If an invalid byte is detected, -2 is returned.\nfunction utf8CheckByte(byte) {\n if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;\n return byte >> 6 === 0x02 ? -1 : -2;\n}\n\n// Checks at most 3 bytes at the end of a Buffer in order to detect an\n// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)\n// needed to complete the UTF-8 character (if applicable) are returned.\nfunction utf8CheckIncomplete(self, buf, i) {\n var j = buf.length - 1;\n if (j < i) return 0;\n var nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 1;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 2;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) {\n if (nb === 2) nb = 0;else self.lastNeed = nb - 3;\n }\n return nb;\n }\n return 0;\n}\n\n// Validates as many continuation bytes for a multi-byte UTF-8 character as\n// needed or are available. If we see a non-continuation byte where we expect\n// one, we \"replace\" the validated continuation bytes we've seen so far with\n// a single UTF-8 replacement character ('\\ufffd'), to match v8's UTF-8 decoding\n// behavior. The continuation byte check is included three times in the case\n// where all of the continuation bytes for a character exist in the same buffer.\n// It is also done this way as a slight performance increase instead of using a\n// loop.\nfunction utf8CheckExtraBytes(self, buf, p) {\n if ((buf[0] & 0xC0) !== 0x80) {\n self.lastNeed = 0;\n return '\\ufffd';\n }\n if (self.lastNeed > 1 && buf.length > 1) {\n if ((buf[1] & 0xC0) !== 0x80) {\n self.lastNeed = 1;\n return '\\ufffd';\n }\n if (self.lastNeed > 2 && buf.length > 2) {\n if ((buf[2] & 0xC0) !== 0x80) {\n self.lastNeed = 2;\n return '\\ufffd';\n }\n }\n }\n}\n\n// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.\nfunction utf8FillLast(buf) {\n var p = this.lastTotal - this.lastNeed;\n var r = utf8CheckExtraBytes(this, buf, p);\n if (r !== undefined) return r;\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, p, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, p, 0, buf.length);\n this.lastNeed -= buf.length;\n}\n\n// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a\n// partial character, the character's bytes are buffered until the required\n// number of bytes are available.\nfunction utf8Text(buf, i) {\n var total = utf8CheckIncomplete(this, buf, i);\n if (!this.lastNeed) return buf.toString('utf8', i);\n this.lastTotal = total;\n var end = buf.length - (total - this.lastNeed);\n buf.copy(this.lastChar, 0, end);\n return buf.toString('utf8', i, end);\n}\n\n// For UTF-8, a replacement character is added when ending on a partial\n// character.\nfunction utf8End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + '\\ufffd';\n return r;\n}\n\n// UTF-16LE typically needs two bytes per character, but even if we have an even\n// number of bytes available, we need to check if we end on a leading/high\n// surrogate. In that case, we need to wait for the next two bytes in order to\n// decode the last character properly.\nfunction utf16Text(buf, i) {\n if ((buf.length - i) % 2 === 0) {\n var r = buf.toString('utf16le', i);\n if (r) {\n var c = r.charCodeAt(r.length - 1);\n if (c >= 0xD800 && c <= 0xDBFF) {\n this.lastNeed = 2;\n this.lastTotal = 4;\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n return r.slice(0, -1);\n }\n }\n return r;\n }\n this.lastNeed = 1;\n this.lastTotal = 2;\n this.lastChar[0] = buf[buf.length - 1];\n return buf.toString('utf16le', i, buf.length - 1);\n}\n\n// For UTF-16LE we do not explicitly append special replacement characters if we\n// end on a partial character, we simply let v8 handle that.\nfunction utf16End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) {\n var end = this.lastTotal - this.lastNeed;\n return r + this.lastChar.toString('utf16le', 0, end);\n }\n return r;\n}\n\nfunction base64Text(buf, i) {\n var n = (buf.length - i) % 3;\n if (n === 0) return buf.toString('base64', i);\n this.lastNeed = 3 - n;\n this.lastTotal = 3;\n if (n === 1) {\n this.lastChar[0] = buf[buf.length - 1];\n } else {\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n }\n return buf.toString('base64', i, buf.length - n);\n}\n\nfunction base64End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);\n return r;\n}\n\n// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)\nfunction simpleWrite(buf) {\n return buf.toString(this.encoding);\n}\n\nfunction simpleEnd(buf) {\n return buf && buf.length ? this.write(buf) : '';\n}","/*! safe-buffer. MIT License. Feross Aboukhadijeh */\n/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.prototype = Object.create(Buffer.prototype)\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\nconst os = require('os');\nconst tty = require('tty');\nconst hasFlag = require('has-flag');\n\nconst {env} = process;\n\nlet forceColor;\nif (hasFlag('no-color') ||\n\thasFlag('no-colors') ||\n\thasFlag('color=false') ||\n\thasFlag('color=never')) {\n\tforceColor = 0;\n} else if (hasFlag('color') ||\n\thasFlag('colors') ||\n\thasFlag('color=true') ||\n\thasFlag('color=always')) {\n\tforceColor = 1;\n}\n\nif ('FORCE_COLOR' in env) {\n\tif (env.FORCE_COLOR === 'true') {\n\t\tforceColor = 1;\n\t} else if (env.FORCE_COLOR === 'false') {\n\t\tforceColor = 0;\n\t} else {\n\t\tforceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);\n\t}\n}\n\nfunction translateLevel(level) {\n\tif (level === 0) {\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tlevel,\n\t\thasBasic: true,\n\t\thas256: level >= 2,\n\t\thas16m: level >= 3\n\t};\n}\n\nfunction supportsColor(haveStream, streamIsTTY) {\n\tif (forceColor === 0) {\n\t\treturn 0;\n\t}\n\n\tif (hasFlag('color=16m') ||\n\t\thasFlag('color=full') ||\n\t\thasFlag('color=truecolor')) {\n\t\treturn 3;\n\t}\n\n\tif (hasFlag('color=256')) {\n\t\treturn 2;\n\t}\n\n\tif (haveStream && !streamIsTTY && forceColor === undefined) {\n\t\treturn 0;\n\t}\n\n\tconst min = forceColor || 0;\n\n\tif (env.TERM === 'dumb') {\n\t\treturn min;\n\t}\n\n\tif (process.platform === 'win32') {\n\t\t// Windows 10 build 10586 is the first Windows release that supports 256 colors.\n\t\t// Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n\t\tconst osRelease = os.release().split('.');\n\t\tif (\n\t\t\tNumber(osRelease[0]) >= 10 &&\n\t\t\tNumber(osRelease[2]) >= 10586\n\t\t) {\n\t\t\treturn Number(osRelease[2]) >= 14931 ? 3 : 2;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif ('CI' in env) {\n\t\tif (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn min;\n\t}\n\n\tif ('TEAMCITY_VERSION' in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;\n\t}\n\n\tif (env.COLORTERM === 'truecolor') {\n\t\treturn 3;\n\t}\n\n\tif ('TERM_PROGRAM' in env) {\n\t\tconst version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);\n\n\t\tswitch (env.TERM_PROGRAM) {\n\t\t\tcase 'iTerm.app':\n\t\t\t\treturn version >= 3 ? 3 : 2;\n\t\t\tcase 'Apple_Terminal':\n\t\t\t\treturn 2;\n\t\t\t// No default\n\t\t}\n\t}\n\n\tif (/-256(color)?$/i.test(env.TERM)) {\n\t\treturn 2;\n\t}\n\n\tif (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {\n\t\treturn 1;\n\t}\n\n\tif ('COLORTERM' in env) {\n\t\treturn 1;\n\t}\n\n\treturn min;\n}\n\nfunction getSupportLevel(stream) {\n\tconst level = supportsColor(stream, stream && stream.isTTY);\n\treturn translateLevel(level);\n}\n\nmodule.exports = {\n\tsupportsColor: getSupportLevel,\n\tstdout: translateLevel(supportsColor(true, tty.isatty(1))),\n\tstderr: translateLevel(supportsColor(true, tty.isatty(2)))\n};\n","var chownr = require('chownr')\nvar tar = require('tar-stream')\nvar pump = require('pump')\nvar mkdirp = require('mkdirp-classic')\nvar fs = require('fs')\nvar path = require('path')\nvar os = require('os')\n\nvar win32 = os.platform() === 'win32'\n\nvar noop = function () {}\n\nvar echo = function (name) {\n return name\n}\n\nvar normalize = !win32 ? echo : function (name) {\n return name.replace(/\\\\/g, '/').replace(/[:?<>|]/g, '_')\n}\n\nvar statAll = function (fs, stat, cwd, ignore, entries, sort) {\n var queue = entries || ['.']\n\n return function loop (callback) {\n if (!queue.length) return callback()\n var next = queue.shift()\n var nextAbs = path.join(cwd, next)\n\n stat(nextAbs, function (err, stat) {\n if (err) return callback(err)\n\n if (!stat.isDirectory()) return callback(null, next, stat)\n\n fs.readdir(nextAbs, function (err, files) {\n if (err) return callback(err)\n\n if (sort) files.sort()\n for (var i = 0; i < files.length; i++) {\n if (!ignore(path.join(cwd, next, files[i]))) queue.push(path.join(next, files[i]))\n }\n\n callback(null, next, stat)\n })\n })\n }\n}\n\nvar strip = function (map, level) {\n return function (header) {\n header.name = header.name.split('/').slice(level).join('/')\n\n var linkname = header.linkname\n if (linkname && (header.type === 'link' || path.isAbsolute(linkname))) {\n header.linkname = linkname.split('/').slice(level).join('/')\n }\n\n return map(header)\n }\n}\n\nexports.pack = function (cwd, opts) {\n if (!cwd) cwd = '.'\n if (!opts) opts = {}\n\n var xfs = opts.fs || fs\n var ignore = opts.ignore || opts.filter || noop\n var map = opts.map || noop\n var mapStream = opts.mapStream || echo\n var statNext = statAll(xfs, opts.dereference ? xfs.stat : xfs.lstat, cwd, ignore, opts.entries, opts.sort)\n var strict = opts.strict !== false\n var umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()\n var dmode = typeof opts.dmode === 'number' ? opts.dmode : 0\n var fmode = typeof opts.fmode === 'number' ? opts.fmode : 0\n var pack = opts.pack || tar.pack()\n var finish = opts.finish || noop\n\n if (opts.strip) map = strip(map, opts.strip)\n\n if (opts.readable) {\n dmode |= parseInt(555, 8)\n fmode |= parseInt(444, 8)\n }\n if (opts.writable) {\n dmode |= parseInt(333, 8)\n fmode |= parseInt(222, 8)\n }\n\n var onsymlink = function (filename, header) {\n xfs.readlink(path.join(cwd, filename), function (err, linkname) {\n if (err) return pack.destroy(err)\n header.linkname = normalize(linkname)\n pack.entry(header, onnextentry)\n })\n }\n\n var onstat = function (err, filename, stat) {\n if (err) return pack.destroy(err)\n if (!filename) {\n if (opts.finalize !== false) pack.finalize()\n return finish(pack)\n }\n\n if (stat.isSocket()) return onnextentry() // tar does not support sockets...\n\n var header = {\n name: normalize(filename),\n mode: (stat.mode | (stat.isDirectory() ? dmode : fmode)) & umask,\n mtime: stat.mtime,\n size: stat.size,\n type: 'file',\n uid: stat.uid,\n gid: stat.gid\n }\n\n if (stat.isDirectory()) {\n header.size = 0\n header.type = 'directory'\n header = map(header) || header\n return pack.entry(header, onnextentry)\n }\n\n if (stat.isSymbolicLink()) {\n header.size = 0\n header.type = 'symlink'\n header = map(header) || header\n return onsymlink(filename, header)\n }\n\n // TODO: add fifo etc...\n\n header = map(header) || header\n\n if (!stat.isFile()) {\n if (strict) return pack.destroy(new Error('unsupported type for ' + filename))\n return onnextentry()\n }\n\n var entry = pack.entry(header, onnextentry)\n if (!entry) return\n\n var rs = mapStream(xfs.createReadStream(path.join(cwd, filename)), header)\n\n rs.on('error', function (err) { // always forward errors on destroy\n entry.destroy(err)\n })\n\n pump(rs, entry)\n }\n\n var onnextentry = function (err) {\n if (err) return pack.destroy(err)\n statNext(onstat)\n }\n\n onnextentry()\n\n return pack\n}\n\nvar head = function (list) {\n return list.length ? list[list.length - 1] : null\n}\n\nvar processGetuid = function () {\n return process.getuid ? process.getuid() : -1\n}\n\nvar processUmask = function () {\n return process.umask ? process.umask() : 0\n}\n\nexports.extract = function (cwd, opts) {\n if (!cwd) cwd = '.'\n if (!opts) opts = {}\n\n var xfs = opts.fs || fs\n var ignore = opts.ignore || opts.filter || noop\n var map = opts.map || noop\n var mapStream = opts.mapStream || echo\n var own = opts.chown !== false && !win32 && processGetuid() === 0\n var extract = opts.extract || tar.extract()\n var stack = []\n var now = new Date()\n var umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()\n var dmode = typeof opts.dmode === 'number' ? opts.dmode : 0\n var fmode = typeof opts.fmode === 'number' ? opts.fmode : 0\n var strict = opts.strict !== false\n\n if (opts.strip) map = strip(map, opts.strip)\n\n if (opts.readable) {\n dmode |= parseInt(555, 8)\n fmode |= parseInt(444, 8)\n }\n if (opts.writable) {\n dmode |= parseInt(333, 8)\n fmode |= parseInt(222, 8)\n }\n\n var utimesParent = function (name, cb) { // we just set the mtime on the parent dir again everytime we write an entry\n var top\n while ((top = head(stack)) && name.slice(0, top[0].length) !== top[0]) stack.pop()\n if (!top) return cb()\n xfs.utimes(top[0], now, top[1], cb)\n }\n\n var utimes = function (name, header, cb) {\n if (opts.utimes === false) return cb()\n\n if (header.type === 'directory') return xfs.utimes(name, now, header.mtime, cb)\n if (header.type === 'symlink') return utimesParent(name, cb) // TODO: how to set mtime on link?\n\n xfs.utimes(name, now, header.mtime, function (err) {\n if (err) return cb(err)\n utimesParent(name, cb)\n })\n }\n\n var chperm = function (name, header, cb) {\n var link = header.type === 'symlink'\n\n /* eslint-disable node/no-deprecated-api */\n var chmod = link ? xfs.lchmod : xfs.chmod\n var chown = link ? xfs.lchown : xfs.chown\n /* eslint-enable node/no-deprecated-api */\n\n if (!chmod) return cb()\n\n var mode = (header.mode | (header.type === 'directory' ? dmode : fmode)) & umask\n chmod(name, mode, function (err) {\n if (err) return cb(err)\n if (!own) return cb()\n if (!chown) return cb()\n chown(name, header.uid, header.gid, cb)\n })\n }\n\n extract.on('entry', function (header, stream, next) {\n header = map(header) || header\n header.name = normalize(header.name)\n var name = path.join(cwd, path.join('/', header.name))\n\n if (ignore(name, header)) {\n stream.resume()\n return next()\n }\n\n var stat = function (err) {\n if (err) return next(err)\n utimes(name, header, function (err) {\n if (err) return next(err)\n if (win32) return next()\n chperm(name, header, next)\n })\n }\n\n var onsymlink = function () {\n if (win32) return next() // skip symlinks on win for now before it can be tested\n xfs.unlink(name, function () {\n xfs.symlink(header.linkname, name, stat)\n })\n }\n\n var onlink = function () {\n if (win32) return next() // skip links on win for now before it can be tested\n xfs.unlink(name, function () {\n var srcpath = path.join(cwd, path.join('/', header.linkname))\n\n xfs.link(srcpath, name, function (err) {\n if (err && err.code === 'EPERM' && opts.hardlinkAsFilesFallback) {\n stream = xfs.createReadStream(srcpath)\n return onfile()\n }\n\n stat(err)\n })\n })\n }\n\n var onfile = function () {\n var ws = xfs.createWriteStream(name)\n var rs = mapStream(stream, header)\n\n ws.on('error', function (err) { // always forward errors on destroy\n rs.destroy(err)\n })\n\n pump(rs, ws, function (err) {\n if (err) return next(err)\n ws.on('close', stat)\n })\n }\n\n if (header.type === 'directory') {\n stack.push([name, header.mtime])\n return mkdirfix(name, {\n fs: xfs, own: own, uid: header.uid, gid: header.gid\n }, stat)\n }\n\n var dir = path.dirname(name)\n\n validate(xfs, dir, path.join(cwd, '.'), function (err, valid) {\n if (err) return next(err)\n if (!valid) return next(new Error(dir + ' is not a valid path'))\n\n mkdirfix(dir, {\n fs: xfs, own: own, uid: header.uid, gid: header.gid\n }, function (err) {\n if (err) return next(err)\n\n switch (header.type) {\n case 'file': return onfile()\n case 'link': return onlink()\n case 'symlink': return onsymlink()\n }\n\n if (strict) return next(new Error('unsupported type for ' + name + ' (' + header.type + ')'))\n\n stream.resume()\n next()\n })\n })\n })\n\n if (opts.finish) extract.on('finish', opts.finish)\n\n return extract\n}\n\nfunction validate (fs, name, root, cb) {\n if (name === root) return cb(null, true)\n fs.lstat(name, function (err, st) {\n if (err && err.code !== 'ENOENT') return cb(err)\n if (err || st.isDirectory()) return validate(fs, path.join(name, '..'), root, cb)\n cb(null, false)\n })\n}\n\nfunction mkdirfix (name, opts, cb) {\n mkdirp(name, { fs: opts.fs }, function (err, made) {\n if (!err && made && opts.own) {\n chownr(made, opts.uid, opts.gid, cb)\n } else {\n cb(err)\n }\n })\n}\n","var util = require('util')\nvar bl = require('bl')\nvar headers = require('./headers')\n\nvar Writable = require('readable-stream').Writable\nvar PassThrough = require('readable-stream').PassThrough\n\nvar noop = function () {}\n\nvar overflow = function (size) {\n size &= 511\n return size && 512 - size\n}\n\nvar emptyStream = function (self, offset) {\n var s = new Source(self, offset)\n s.end()\n return s\n}\n\nvar mixinPax = function (header, pax) {\n if (pax.path) header.name = pax.path\n if (pax.linkpath) header.linkname = pax.linkpath\n if (pax.size) header.size = parseInt(pax.size, 10)\n header.pax = pax\n return header\n}\n\nvar Source = function (self, offset) {\n this._parent = self\n this.offset = offset\n PassThrough.call(this, { autoDestroy: false })\n}\n\nutil.inherits(Source, PassThrough)\n\nSource.prototype.destroy = function (err) {\n this._parent.destroy(err)\n}\n\nvar Extract = function (opts) {\n if (!(this instanceof Extract)) return new Extract(opts)\n Writable.call(this, opts)\n\n opts = opts || {}\n\n this._offset = 0\n this._buffer = bl()\n this._missing = 0\n this._partial = false\n this._onparse = noop\n this._header = null\n this._stream = null\n this._overflow = null\n this._cb = null\n this._locked = false\n this._destroyed = false\n this._pax = null\n this._paxGlobal = null\n this._gnuLongPath = null\n this._gnuLongLinkPath = null\n\n var self = this\n var b = self._buffer\n\n var oncontinue = function () {\n self._continue()\n }\n\n var onunlock = function (err) {\n self._locked = false\n if (err) return self.destroy(err)\n if (!self._stream) oncontinue()\n }\n\n var onstreamend = function () {\n self._stream = null\n var drain = overflow(self._header.size)\n if (drain) self._parse(drain, ondrain)\n else self._parse(512, onheader)\n if (!self._locked) oncontinue()\n }\n\n var ondrain = function () {\n self._buffer.consume(overflow(self._header.size))\n self._parse(512, onheader)\n oncontinue()\n }\n\n var onpaxglobalheader = function () {\n var size = self._header.size\n self._paxGlobal = headers.decodePax(b.slice(0, size))\n b.consume(size)\n onstreamend()\n }\n\n var onpaxheader = function () {\n var size = self._header.size\n self._pax = headers.decodePax(b.slice(0, size))\n if (self._paxGlobal) self._pax = Object.assign({}, self._paxGlobal, self._pax)\n b.consume(size)\n onstreamend()\n }\n\n var ongnulongpath = function () {\n var size = self._header.size\n this._gnuLongPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)\n b.consume(size)\n onstreamend()\n }\n\n var ongnulonglinkpath = function () {\n var size = self._header.size\n this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)\n b.consume(size)\n onstreamend()\n }\n\n var onheader = function () {\n var offset = self._offset\n var header\n try {\n header = self._header = headers.decode(b.slice(0, 512), opts.filenameEncoding, opts.allowUnknownFormat)\n } catch (err) {\n self.emit('error', err)\n }\n b.consume(512)\n\n if (!header) {\n self._parse(512, onheader)\n oncontinue()\n return\n }\n if (header.type === 'gnu-long-path') {\n self._parse(header.size, ongnulongpath)\n oncontinue()\n return\n }\n if (header.type === 'gnu-long-link-path') {\n self._parse(header.size, ongnulonglinkpath)\n oncontinue()\n return\n }\n if (header.type === 'pax-global-header') {\n self._parse(header.size, onpaxglobalheader)\n oncontinue()\n return\n }\n if (header.type === 'pax-header') {\n self._parse(header.size, onpaxheader)\n oncontinue()\n return\n }\n\n if (self._gnuLongPath) {\n header.name = self._gnuLongPath\n self._gnuLongPath = null\n }\n\n if (self._gnuLongLinkPath) {\n header.linkname = self._gnuLongLinkPath\n self._gnuLongLinkPath = null\n }\n\n if (self._pax) {\n self._header = header = mixinPax(header, self._pax)\n self._pax = null\n }\n\n self._locked = true\n\n if (!header.size || header.type === 'directory') {\n self._parse(512, onheader)\n self.emit('entry', header, emptyStream(self, offset), onunlock)\n return\n }\n\n self._stream = new Source(self, offset)\n\n self.emit('entry', header, self._stream, onunlock)\n self._parse(header.size, onstreamend)\n oncontinue()\n }\n\n this._onheader = onheader\n this._parse(512, onheader)\n}\n\nutil.inherits(Extract, Writable)\n\nExtract.prototype.destroy = function (err) {\n if (this._destroyed) return\n this._destroyed = true\n\n if (err) this.emit('error', err)\n this.emit('close')\n if (this._stream) this._stream.emit('close')\n}\n\nExtract.prototype._parse = function (size, onparse) {\n if (this._destroyed) return\n this._offset += size\n this._missing = size\n if (onparse === this._onheader) this._partial = false\n this._onparse = onparse\n}\n\nExtract.prototype._continue = function () {\n if (this._destroyed) return\n var cb = this._cb\n this._cb = noop\n if (this._overflow) this._write(this._overflow, undefined, cb)\n else cb()\n}\n\nExtract.prototype._write = function (data, enc, cb) {\n if (this._destroyed) return\n\n var s = this._stream\n var b = this._buffer\n var missing = this._missing\n if (data.length) this._partial = true\n\n // we do not reach end-of-chunk now. just forward it\n\n if (data.length < missing) {\n this._missing -= data.length\n this._overflow = null\n if (s) return s.write(data, cb)\n b.append(data)\n return cb()\n }\n\n // end-of-chunk. the parser should call cb.\n\n this._cb = cb\n this._missing = 0\n\n var overflow = null\n if (data.length > missing) {\n overflow = data.slice(missing)\n data = data.slice(0, missing)\n }\n\n if (s) s.end(data)\n else b.append(data)\n\n this._overflow = overflow\n this._onparse()\n}\n\nExtract.prototype._final = function (cb) {\n if (this._partial) return this.destroy(new Error('Unexpected end of data'))\n cb()\n}\n\nmodule.exports = Extract\n","var alloc = Buffer.alloc\n\nvar ZEROS = '0000000000000000000'\nvar SEVENS = '7777777777777777777'\nvar ZERO_OFFSET = '0'.charCodeAt(0)\nvar USTAR_MAGIC = Buffer.from('ustar\\x00', 'binary')\nvar USTAR_VER = Buffer.from('00', 'binary')\nvar GNU_MAGIC = Buffer.from('ustar\\x20', 'binary')\nvar GNU_VER = Buffer.from('\\x20\\x00', 'binary')\nvar MASK = parseInt('7777', 8)\nvar MAGIC_OFFSET = 257\nvar VERSION_OFFSET = 263\n\nvar clamp = function (index, len, defaultValue) {\n if (typeof index !== 'number') return defaultValue\n index = ~~index // Coerce to integer.\n if (index >= len) return len\n if (index >= 0) return index\n index += len\n if (index >= 0) return index\n return 0\n}\n\nvar toType = function (flag) {\n switch (flag) {\n case 0:\n return 'file'\n case 1:\n return 'link'\n case 2:\n return 'symlink'\n case 3:\n return 'character-device'\n case 4:\n return 'block-device'\n case 5:\n return 'directory'\n case 6:\n return 'fifo'\n case 7:\n return 'contiguous-file'\n case 72:\n return 'pax-header'\n case 55:\n return 'pax-global-header'\n case 27:\n return 'gnu-long-link-path'\n case 28:\n case 30:\n return 'gnu-long-path'\n }\n\n return null\n}\n\nvar toTypeflag = function (flag) {\n switch (flag) {\n case 'file':\n return 0\n case 'link':\n return 1\n case 'symlink':\n return 2\n case 'character-device':\n return 3\n case 'block-device':\n return 4\n case 'directory':\n return 5\n case 'fifo':\n return 6\n case 'contiguous-file':\n return 7\n case 'pax-header':\n return 72\n }\n\n return 0\n}\n\nvar indexOf = function (block, num, offset, end) {\n for (; offset < end; offset++) {\n if (block[offset] === num) return offset\n }\n return end\n}\n\nvar cksum = function (block) {\n var sum = 8 * 32\n for (var i = 0; i < 148; i++) sum += block[i]\n for (var j = 156; j < 512; j++) sum += block[j]\n return sum\n}\n\nvar encodeOct = function (val, n) {\n val = val.toString(8)\n if (val.length > n) return SEVENS.slice(0, n) + ' '\n else return ZEROS.slice(0, n - val.length) + val + ' '\n}\n\n/* Copied from the node-tar repo and modified to meet\n * tar-stream coding standard.\n *\n * Source: https://github.com/npm/node-tar/blob/51b6627a1f357d2eb433e7378e5f05e83b7aa6cd/lib/header.js#L349\n */\nfunction parse256 (buf) {\n // first byte MUST be either 80 or FF\n // 80 for positive, FF for 2's comp\n var positive\n if (buf[0] === 0x80) positive = true\n else if (buf[0] === 0xFF) positive = false\n else return null\n\n // build up a base-256 tuple from the least sig to the highest\n var tuple = []\n for (var i = buf.length - 1; i > 0; i--) {\n var byte = buf[i]\n if (positive) tuple.push(byte)\n else tuple.push(0xFF - byte)\n }\n\n var sum = 0\n var l = tuple.length\n for (i = 0; i < l; i++) {\n sum += tuple[i] * Math.pow(256, i)\n }\n\n return positive ? sum : -1 * sum\n}\n\nvar decodeOct = function (val, offset, length) {\n val = val.slice(offset, offset + length)\n offset = 0\n\n // If prefixed with 0x80 then parse as a base-256 integer\n if (val[offset] & 0x80) {\n return parse256(val)\n } else {\n // Older versions of tar can prefix with spaces\n while (offset < val.length && val[offset] === 32) offset++\n var end = clamp(indexOf(val, 32, offset, val.length), val.length, val.length)\n while (offset < end && val[offset] === 0) offset++\n if (end === offset) return 0\n return parseInt(val.slice(offset, end).toString(), 8)\n }\n}\n\nvar decodeStr = function (val, offset, length, encoding) {\n return val.slice(offset, indexOf(val, 0, offset, offset + length)).toString(encoding)\n}\n\nvar addLength = function (str) {\n var len = Buffer.byteLength(str)\n var digits = Math.floor(Math.log(len) / Math.log(10)) + 1\n if (len + digits >= Math.pow(10, digits)) digits++\n\n return (len + digits) + str\n}\n\nexports.decodeLongPath = function (buf, encoding) {\n return decodeStr(buf, 0, buf.length, encoding)\n}\n\nexports.encodePax = function (opts) { // TODO: encode more stuff in pax\n var result = ''\n if (opts.name) result += addLength(' path=' + opts.name + '\\n')\n if (opts.linkname) result += addLength(' linkpath=' + opts.linkname + '\\n')\n var pax = opts.pax\n if (pax) {\n for (var key in pax) {\n result += addLength(' ' + key + '=' + pax[key] + '\\n')\n }\n }\n return Buffer.from(result)\n}\n\nexports.decodePax = function (buf) {\n var result = {}\n\n while (buf.length) {\n var i = 0\n while (i < buf.length && buf[i] !== 32) i++\n var len = parseInt(buf.slice(0, i).toString(), 10)\n if (!len) return result\n\n var b = buf.slice(i + 1, len - 1).toString()\n var keyIndex = b.indexOf('=')\n if (keyIndex === -1) return result\n result[b.slice(0, keyIndex)] = b.slice(keyIndex + 1)\n\n buf = buf.slice(len)\n }\n\n return result\n}\n\nexports.encode = function (opts) {\n var buf = alloc(512)\n var name = opts.name\n var prefix = ''\n\n if (opts.typeflag === 5 && name[name.length - 1] !== '/') name += '/'\n if (Buffer.byteLength(name) !== name.length) return null // utf-8\n\n while (Buffer.byteLength(name) > 100) {\n var i = name.indexOf('/')\n if (i === -1) return null\n prefix += prefix ? '/' + name.slice(0, i) : name.slice(0, i)\n name = name.slice(i + 1)\n }\n\n if (Buffer.byteLength(name) > 100 || Buffer.byteLength(prefix) > 155) return null\n if (opts.linkname && Buffer.byteLength(opts.linkname) > 100) return null\n\n buf.write(name)\n buf.write(encodeOct(opts.mode & MASK, 6), 100)\n buf.write(encodeOct(opts.uid, 6), 108)\n buf.write(encodeOct(opts.gid, 6), 116)\n buf.write(encodeOct(opts.size, 11), 124)\n buf.write(encodeOct((opts.mtime.getTime() / 1000) | 0, 11), 136)\n\n buf[156] = ZERO_OFFSET + toTypeflag(opts.type)\n\n if (opts.linkname) buf.write(opts.linkname, 157)\n\n USTAR_MAGIC.copy(buf, MAGIC_OFFSET)\n USTAR_VER.copy(buf, VERSION_OFFSET)\n if (opts.uname) buf.write(opts.uname, 265)\n if (opts.gname) buf.write(opts.gname, 297)\n buf.write(encodeOct(opts.devmajor || 0, 6), 329)\n buf.write(encodeOct(opts.devminor || 0, 6), 337)\n\n if (prefix) buf.write(prefix, 345)\n\n buf.write(encodeOct(cksum(buf), 6), 148)\n\n return buf\n}\n\nexports.decode = function (buf, filenameEncoding, allowUnknownFormat) {\n var typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET\n\n var name = decodeStr(buf, 0, 100, filenameEncoding)\n var mode = decodeOct(buf, 100, 8)\n var uid = decodeOct(buf, 108, 8)\n var gid = decodeOct(buf, 116, 8)\n var size = decodeOct(buf, 124, 12)\n var mtime = decodeOct(buf, 136, 12)\n var type = toType(typeflag)\n var linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100, filenameEncoding)\n var uname = decodeStr(buf, 265, 32)\n var gname = decodeStr(buf, 297, 32)\n var devmajor = decodeOct(buf, 329, 8)\n var devminor = decodeOct(buf, 337, 8)\n\n var c = cksum(buf)\n\n // checksum is still initial value if header was null.\n if (c === 8 * 32) return null\n\n // valid checksum\n if (c !== decodeOct(buf, 148, 8)) throw new Error('Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?')\n\n if (USTAR_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0) {\n // ustar (posix) format.\n // prepend prefix, if present.\n if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + '/' + name\n } else if (GNU_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0 &&\n GNU_VER.compare(buf, VERSION_OFFSET, VERSION_OFFSET + 2) === 0) {\n // 'gnu'/'oldgnu' format. Similar to ustar, but has support for incremental and\n // multi-volume tarballs.\n } else {\n if (!allowUnknownFormat) {\n throw new Error('Invalid tar header: unknown format.')\n }\n }\n\n // to support old tar versions that use trailing / to indicate dirs\n if (typeflag === 0 && name && name[name.length - 1] === '/') typeflag = 5\n\n return {\n name,\n mode,\n uid,\n gid,\n size,\n mtime: new Date(1000 * mtime),\n type,\n linkname,\n uname,\n gname,\n devmajor,\n devminor\n }\n}\n","exports.extract = require('./extract')\nexports.pack = require('./pack')\n","var constants = require('fs-constants')\nvar eos = require('end-of-stream')\nvar inherits = require('inherits')\nvar alloc = Buffer.alloc\n\nvar Readable = require('readable-stream').Readable\nvar Writable = require('readable-stream').Writable\nvar StringDecoder = require('string_decoder').StringDecoder\n\nvar headers = require('./headers')\n\nvar DMODE = parseInt('755', 8)\nvar FMODE = parseInt('644', 8)\n\nvar END_OF_TAR = alloc(1024)\n\nvar noop = function () {}\n\nvar overflow = function (self, size) {\n size &= 511\n if (size) self.push(END_OF_TAR.slice(0, 512 - size))\n}\n\nfunction modeToType (mode) {\n switch (mode & constants.S_IFMT) {\n case constants.S_IFBLK: return 'block-device'\n case constants.S_IFCHR: return 'character-device'\n case constants.S_IFDIR: return 'directory'\n case constants.S_IFIFO: return 'fifo'\n case constants.S_IFLNK: return 'symlink'\n }\n\n return 'file'\n}\n\nvar Sink = function (to) {\n Writable.call(this)\n this.written = 0\n this._to = to\n this._destroyed = false\n}\n\ninherits(Sink, Writable)\n\nSink.prototype._write = function (data, enc, cb) {\n this.written += data.length\n if (this._to.push(data)) return cb()\n this._to._drain = cb\n}\n\nSink.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar LinkSink = function () {\n Writable.call(this)\n this.linkname = ''\n this._decoder = new StringDecoder('utf-8')\n this._destroyed = false\n}\n\ninherits(LinkSink, Writable)\n\nLinkSink.prototype._write = function (data, enc, cb) {\n this.linkname += this._decoder.write(data)\n cb()\n}\n\nLinkSink.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar Void = function () {\n Writable.call(this)\n this._destroyed = false\n}\n\ninherits(Void, Writable)\n\nVoid.prototype._write = function (data, enc, cb) {\n cb(new Error('No body allowed for this entry'))\n}\n\nVoid.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar Pack = function (opts) {\n if (!(this instanceof Pack)) return new Pack(opts)\n Readable.call(this, opts)\n\n this._drain = noop\n this._finalized = false\n this._finalizing = false\n this._destroyed = false\n this._stream = null\n}\n\ninherits(Pack, Readable)\n\nPack.prototype.entry = function (header, buffer, callback) {\n if (this._stream) throw new Error('already piping an entry')\n if (this._finalized || this._destroyed) return\n\n if (typeof buffer === 'function') {\n callback = buffer\n buffer = null\n }\n\n if (!callback) callback = noop\n\n var self = this\n\n if (!header.size || header.type === 'symlink') header.size = 0\n if (!header.type) header.type = modeToType(header.mode)\n if (!header.mode) header.mode = header.type === 'directory' ? DMODE : FMODE\n if (!header.uid) header.uid = 0\n if (!header.gid) header.gid = 0\n if (!header.mtime) header.mtime = new Date()\n\n if (typeof buffer === 'string') buffer = Buffer.from(buffer)\n if (Buffer.isBuffer(buffer)) {\n header.size = buffer.length\n this._encode(header)\n var ok = this.push(buffer)\n overflow(self, header.size)\n if (ok) process.nextTick(callback)\n else this._drain = callback\n return new Void()\n }\n\n if (header.type === 'symlink' && !header.linkname) {\n var linkSink = new LinkSink()\n eos(linkSink, function (err) {\n if (err) { // stream was closed\n self.destroy()\n return callback(err)\n }\n\n header.linkname = linkSink.linkname\n self._encode(header)\n callback()\n })\n\n return linkSink\n }\n\n this._encode(header)\n\n if (header.type !== 'file' && header.type !== 'contiguous-file') {\n process.nextTick(callback)\n return new Void()\n }\n\n var sink = new Sink(this)\n\n this._stream = sink\n\n eos(sink, function (err) {\n self._stream = null\n\n if (err) { // stream was closed\n self.destroy()\n return callback(err)\n }\n\n if (sink.written !== header.size) { // corrupting tar\n self.destroy()\n return callback(new Error('size mismatch'))\n }\n\n overflow(self, header.size)\n if (self._finalizing) self.finalize()\n callback()\n })\n\n return sink\n}\n\nPack.prototype.finalize = function () {\n if (this._stream) {\n this._finalizing = true\n return\n }\n\n if (this._finalized) return\n this._finalized = true\n this.push(END_OF_TAR)\n this.push(null)\n}\n\nPack.prototype.destroy = function (err) {\n if (this._destroyed) return\n this._destroyed = true\n\n if (err) this.emit('error', err)\n this.emit('close')\n if (this._stream && this._stream.destroy) this._stream.destroy()\n}\n\nPack.prototype._encode = function (header) {\n if (!header.pax) {\n var buf = headers.encode(header)\n if (buf) {\n this.push(buf)\n return\n }\n }\n this._encodePax(header)\n}\n\nPack.prototype._encodePax = function (header) {\n var paxHeader = headers.encodePax({\n name: header.name,\n linkname: header.linkname,\n pax: header.pax\n })\n\n var newHeader = {\n name: 'PaxHeader',\n mode: header.mode,\n uid: header.uid,\n gid: header.gid,\n size: paxHeader.length,\n mtime: header.mtime,\n type: 'pax-header',\n linkname: header.linkname && 'PaxHeader',\n uname: header.uname,\n gname: header.gname,\n devmajor: header.devmajor,\n devminor: header.devminor\n }\n\n this.push(headers.encode(newHeader))\n this.push(paxHeader)\n overflow(this, paxHeader.length)\n\n newHeader.size = header.size\n newHeader.type = header.type\n this.push(headers.encode(newHeader))\n}\n\nPack.prototype._read = function (n) {\n var drain = this._drain\n this._drain = noop\n drain()\n}\n\nmodule.exports = Pack\n","module.exports = require('./lib/tunnel');\n","'use strict';\n\nvar net = require('net');\nvar tls = require('tls');\nvar http = require('http');\nvar https = require('https');\nvar events = require('events');\nvar assert = require('assert');\nvar util = require('util');\n\n\nexports.httpOverHttp = httpOverHttp;\nexports.httpsOverHttp = httpsOverHttp;\nexports.httpOverHttps = httpOverHttps;\nexports.httpsOverHttps = httpsOverHttps;\n\n\nfunction httpOverHttp(options) {\n var agent = new TunnelingAgent(options);\n agent.request = http.request;\n return agent;\n}\n\nfunction httpsOverHttp(options) {\n var agent = new TunnelingAgent(options);\n agent.request = http.request;\n agent.createSocket = createSecureSocket;\n agent.defaultPort = 443;\n return agent;\n}\n\nfunction httpOverHttps(options) {\n var agent = new TunnelingAgent(options);\n agent.request = https.request;\n return agent;\n}\n\nfunction httpsOverHttps(options) {\n var agent = new TunnelingAgent(options);\n agent.request = https.request;\n agent.createSocket = createSecureSocket;\n agent.defaultPort = 443;\n return agent;\n}\n\n\nfunction TunnelingAgent(options) {\n var self = this;\n self.options = options || {};\n self.proxyOptions = self.options.proxy || {};\n self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets;\n self.requests = [];\n self.sockets = [];\n\n self.on('free', function onFree(socket, host, port, localAddress) {\n var options = toOptions(host, port, localAddress);\n for (var i = 0, len = self.requests.length; i < len; ++i) {\n var pending = self.requests[i];\n if (pending.host === options.host && pending.port === options.port) {\n // Detect the request to connect same origin server,\n // reuse the connection.\n self.requests.splice(i, 1);\n pending.request.onSocket(socket);\n return;\n }\n }\n socket.destroy();\n self.removeSocket(socket);\n });\n}\nutil.inherits(TunnelingAgent, events.EventEmitter);\n\nTunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) {\n var self = this;\n var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress));\n\n if (self.sockets.length >= this.maxSockets) {\n // We are over limit so we'll add it to the queue.\n self.requests.push(options);\n return;\n }\n\n // If we are under maxSockets create a new one.\n self.createSocket(options, function(socket) {\n socket.on('free', onFree);\n socket.on('close', onCloseOrRemove);\n socket.on('agentRemove', onCloseOrRemove);\n req.onSocket(socket);\n\n function onFree() {\n self.emit('free', socket, options);\n }\n\n function onCloseOrRemove(err) {\n self.removeSocket(socket);\n socket.removeListener('free', onFree);\n socket.removeListener('close', onCloseOrRemove);\n socket.removeListener('agentRemove', onCloseOrRemove);\n }\n });\n};\n\nTunnelingAgent.prototype.createSocket = function createSocket(options, cb) {\n var self = this;\n var placeholder = {};\n self.sockets.push(placeholder);\n\n var connectOptions = mergeOptions({}, self.proxyOptions, {\n method: 'CONNECT',\n path: options.host + ':' + options.port,\n agent: false,\n headers: {\n host: options.host + ':' + options.port\n }\n });\n if (options.localAddress) {\n connectOptions.localAddress = options.localAddress;\n }\n if (connectOptions.proxyAuth) {\n connectOptions.headers = connectOptions.headers || {};\n connectOptions.headers['Proxy-Authorization'] = 'Basic ' +\n new Buffer(connectOptions.proxyAuth).toString('base64');\n }\n\n debug('making CONNECT request');\n var connectReq = self.request(connectOptions);\n connectReq.useChunkedEncodingByDefault = false; // for v0.6\n connectReq.once('response', onResponse); // for v0.6\n connectReq.once('upgrade', onUpgrade); // for v0.6\n connectReq.once('connect', onConnect); // for v0.7 or later\n connectReq.once('error', onError);\n connectReq.end();\n\n function onResponse(res) {\n // Very hacky. This is necessary to avoid http-parser leaks.\n res.upgrade = true;\n }\n\n function onUpgrade(res, socket, head) {\n // Hacky.\n process.nextTick(function() {\n onConnect(res, socket, head);\n });\n }\n\n function onConnect(res, socket, head) {\n connectReq.removeAllListeners();\n socket.removeAllListeners();\n\n if (res.statusCode !== 200) {\n debug('tunneling socket could not be established, statusCode=%d',\n res.statusCode);\n socket.destroy();\n var error = new Error('tunneling socket could not be established, ' +\n 'statusCode=' + res.statusCode);\n error.code = 'ECONNRESET';\n options.request.emit('error', error);\n self.removeSocket(placeholder);\n return;\n }\n if (head.length > 0) {\n debug('got illegal response body from proxy');\n socket.destroy();\n var error = new Error('got illegal response body from proxy');\n error.code = 'ECONNRESET';\n options.request.emit('error', error);\n self.removeSocket(placeholder);\n return;\n }\n debug('tunneling connection has established');\n self.sockets[self.sockets.indexOf(placeholder)] = socket;\n return cb(socket);\n }\n\n function onError(cause) {\n connectReq.removeAllListeners();\n\n debug('tunneling socket could not be established, cause=%s\\n',\n cause.message, cause.stack);\n var error = new Error('tunneling socket could not be established, ' +\n 'cause=' + cause.message);\n error.code = 'ECONNRESET';\n options.request.emit('error', error);\n self.removeSocket(placeholder);\n }\n};\n\nTunnelingAgent.prototype.removeSocket = function removeSocket(socket) {\n var pos = this.sockets.indexOf(socket)\n if (pos === -1) {\n return;\n }\n this.sockets.splice(pos, 1);\n\n var pending = this.requests.shift();\n if (pending) {\n // If we have pending requests and a socket gets closed a new one\n // needs to be created to take over in the pool for the one that closed.\n this.createSocket(pending, function(socket) {\n pending.request.onSocket(socket);\n });\n }\n};\n\nfunction createSecureSocket(options, cb) {\n var self = this;\n TunnelingAgent.prototype.createSocket.call(self, options, function(socket) {\n var hostHeader = options.request.getHeader('host');\n var tlsOptions = mergeOptions({}, self.options, {\n socket: socket,\n servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host\n });\n\n // 0 is dummy port for v0.6\n var secureSocket = tls.connect(0, tlsOptions);\n self.sockets[self.sockets.indexOf(socket)] = secureSocket;\n cb(secureSocket);\n });\n}\n\n\nfunction toOptions(host, port, localAddress) {\n if (typeof host === 'string') { // since v0.10\n return {\n host: host,\n port: port,\n localAddress: localAddress\n };\n }\n return host; // for v0.11 or later\n}\n\nfunction mergeOptions(target) {\n for (var i = 1, len = arguments.length; i < len; ++i) {\n var overrides = arguments[i];\n if (typeof overrides === 'object') {\n var keys = Object.keys(overrides);\n for (var j = 0, keyLen = keys.length; j < keyLen; ++j) {\n var k = keys[j];\n if (overrides[k] !== undefined) {\n target[k] = overrides[k];\n }\n }\n }\n }\n return target;\n}\n\n\nvar debug;\nif (process.env.NODE_DEBUG && /\\btunnel\\b/.test(process.env.NODE_DEBUG)) {\n debug = function() {\n var args = Array.prototype.slice.call(arguments);\n if (typeof args[0] === 'string') {\n args[0] = 'TUNNEL: ' + args[0];\n } else {\n args.unshift('TUNNEL:');\n }\n console.error.apply(console, args);\n }\n} else {\n debug = function() {};\n}\nexports.debug = debug; // for test\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = (x[j] + 128) >> 8;\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i, mlen;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n mlen = -1;\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n mlen = n;\n return mlen;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n var t, i;\n for (i = 0; i < arguments.length; i++) {\n if ((t = Object.prototype.toString.call(arguments[i])) !== '[object Uint8Array]')\n throw new TypeError('unexpected type ' + t + ', use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\n// TODO: Completely remove this in v0.15.\nif (!nacl.util) {\n nacl.util = {};\n nacl.util.decodeUTF8 = nacl.util.encodeUTF8 = nacl.util.encodeBase64 = nacl.util.decodeBase64 = function() {\n throw new Error('nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js');\n };\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return false;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return false;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n if (arguments.length !== 2)\n throw new Error('nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?');\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction getUserAgent() {\n if (typeof navigator === \"object\" && \"userAgent\" in navigator) {\n return navigator.userAgent;\n }\n\n if (typeof process === \"object\" && \"version\" in process) {\n return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`;\n }\n\n return \"\";\n}\n\nexports.getUserAgent = getUserAgent;\n//# sourceMappingURL=index.js.map\n","\n/**\n * For Node.js, simply re-export the core `util.deprecate` function.\n */\n\nmodule.exports = require('util').deprecate;\n","// Returns a wrapper function that returns a wrapped callback\n// The wrapper function should do some stuff, and return a\n// presumably different callback function.\n// This makes sure that own properties are retained, so that\n// decorations and such are not lost along the way.\nmodule.exports = wrappy\nfunction wrappy (fn, cb) {\n if (fn && cb) return wrappy(fn)(cb)\n\n if (typeof fn !== 'function')\n throw new TypeError('need wrapper function')\n\n Object.keys(fn).forEach(function (k) {\n wrapper[k] = fn[k]\n })\n\n return wrapper\n\n function wrapper() {\n var args = new Array(arguments.length)\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i]\n }\n var ret = fn.apply(this, args)\n var cb = args[args.length-1]\n if (typeof ret === 'function' && ret !== cb) {\n Object.keys(cb).forEach(function (k) {\n ret[k] = cb[k]\n })\n }\n return ret\n }\n}\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ApiClient = exports.CredentialFetchingError = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst axios_1 = __importDefault(require(\"axios\"));\nclass CredentialFetchingError extends Error {\n}\nexports.CredentialFetchingError = CredentialFetchingError;\nclass ApiClient {\n constructor(client, params) {\n this.client = client;\n this.params = params;\n // We use a static unknown SHA when marking a job as complete from the action\n // to remain in parity with the existing runner.\n this.UnknownSha = {\n 'base-commit-sha': 'unknown'\n };\n }\n getJobDetails() {\n return __awaiter(this, void 0, void 0, function* () {\n const detailsURL = `/update_jobs/${this.params.jobId}/details`;\n const res = yield this.client.get(detailsURL, {\n headers: { Authorization: this.params.jobToken }\n });\n if (res.status !== 200) {\n throw new Error(`Unexpected status code: ${res.status}`);\n }\n return res.data.data.attributes;\n });\n }\n getCredentials() {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n const credentialsURL = `/update_jobs/${this.params.jobId}/credentials`;\n try {\n const res = yield this.client.get(credentialsURL, {\n headers: { Authorization: this.params.credentialsToken }\n });\n // Mask any secrets we've just retrieved from Actions logs\n for (const credential of res.data.data.attributes.credentials) {\n if (credential.password) {\n core.setSecret(credential.password);\n }\n if (credential.token) {\n core.setSecret(credential.token);\n }\n }\n return res.data.data.attributes.credentials;\n }\n catch (error) {\n if (axios_1.default.isAxiosError(error)) {\n const err = error;\n throw new CredentialFetchingError(`fetching credentials: received code ${(_a = err.response) === null || _a === void 0 ? void 0 : _a.status}: ${JSON.stringify((_b = err.response) === null || _b === void 0 ? void 0 : _b.data)}`);\n }\n else {\n throw error;\n }\n }\n });\n }\n reportJobError(error) {\n return __awaiter(this, void 0, void 0, function* () {\n const recordErrorURL = `/update_jobs/${this.params.jobId}/record_update_job_error`;\n const res = yield this.client.post(recordErrorURL, { data: error }, {\n headers: { Authorization: this.params.jobToken }\n });\n if (res.status !== 204) {\n throw new Error(`Unexpected status code: ${res.status}`);\n }\n });\n }\n markJobAsProcessed() {\n return __awaiter(this, void 0, void 0, function* () {\n const markAsProcessedURL = `/update_jobs/${this.params.jobId}/mark_as_processed`;\n const res = yield this.client.patch(markAsProcessedURL, { data: this.UnknownSha }, {\n headers: { Authorization: this.params.jobToken }\n });\n if (res.status !== 204) {\n throw new Error(`Unexpected status code: ${res.status}`);\n }\n });\n }\n}\nexports.ApiClient = ApiClient;\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ContainerService = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst tar_stream_1 = require(\"tar-stream\");\nconst utils_1 = require(\"./utils\");\nclass ContainerRuntimeError extends Error {\n}\nexports.ContainerService = {\n storeInput(name, path, container, input) {\n return __awaiter(this, void 0, void 0, function* () {\n const tar = tar_stream_1.pack();\n tar.entry({ name }, JSON.stringify(input));\n tar.finalize();\n yield container.putArchive(tar, { path });\n });\n },\n storeCert(name, path, container, cert) {\n return __awaiter(this, void 0, void 0, function* () {\n const tar = tar_stream_1.pack();\n tar.entry({ name }, cert);\n tar.finalize();\n yield container.putArchive(tar, { path });\n });\n },\n run(container) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n const stream = yield container.attach({\n stream: true,\n stdout: true,\n stderr: true\n });\n container.modem.demuxStream(stream, utils_1.outStream('updater'), utils_1.errStream('updater'));\n yield container.start();\n const outcome = yield container.wait();\n if (outcome.StatusCode === 0) {\n return true;\n }\n else {\n throw new ContainerRuntimeError(`Failure running container ${container.id}`);\n }\n }\n finally {\n yield container.remove({ v: true });\n core.info(`Cleaned up container ${container.id}`);\n }\n });\n }\n};\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ImageService = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst dockerode_1 = __importDefault(require(\"dockerode\"));\nconst endOfStream = (docker, stream) => __awaiter(void 0, void 0, void 0, function* () {\n return new Promise((resolve, reject) => {\n docker.modem.followProgress(stream, (err) => err ? reject(err) : resolve(undefined));\n });\n});\nexports.ImageService = {\n /** Fetch the configured updater image, if it isn't already available. */\n pull(imageName, force = false) {\n return __awaiter(this, void 0, void 0, function* () {\n const docker = new dockerode_1.default();\n try {\n const image = yield docker.getImage(imageName).inspect();\n if (!force) {\n core.info(`Resolved ${imageName} to existing ${image.Id}`);\n return;\n } // else fallthrough to pull\n }\n catch (e) {\n if (!e.message.includes('no such image')) {\n throw e;\n } // else fallthrough to pull\n }\n core.info(`Pulling image ${imageName}...`);\n const auth = {\n username: 'x',\n password: process.env.GITHUB_TOKEN\n };\n const stream = yield docker.pull(imageName, { authconfig: auth });\n yield endOfStream(docker, stream);\n core.info(`Pulled image ${imageName}`);\n });\n }\n};\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getJobParameters = exports.JobParameters = void 0;\nconst fs_1 = __importDefault(require(\"fs\"));\nconst path_1 = __importDefault(require(\"path\"));\nconst core = __importStar(require(\"@actions/core\"));\nconst DYNAMIC = 'dynamic';\nconst DEPENDABOT_ACTOR = 'dependabot[bot]';\n// JobParameters are the Action inputs required to execute the job\nclass JobParameters {\n constructor(jobId, jobToken, credentialsToken, dependabotApiUrl, dependabotApiDockerUrl, workingDirectory) {\n this.jobId = jobId;\n this.jobToken = jobToken;\n this.credentialsToken = credentialsToken;\n this.dependabotApiUrl = dependabotApiUrl;\n this.dependabotApiDockerUrl = dependabotApiDockerUrl;\n this.workingDirectory = workingDirectory;\n }\n}\nexports.JobParameters = JobParameters;\nfunction getJobParameters(ctx) {\n checkEnvironmentAndContext(ctx);\n if (ctx.actor !== DEPENDABOT_ACTOR) {\n core.warning('This workflow can only be triggered by Dependabot.');\n return null;\n }\n if (ctx.eventName === DYNAMIC) {\n return fromWorkflowInputs(ctx);\n }\n else {\n core.warning(`Dependabot Updater Action does not support '${ctx.eventName}' events.`);\n return null;\n }\n}\nexports.getJobParameters = getJobParameters;\nfunction checkEnvironmentAndContext(ctx) {\n let valid = true;\n if (!ctx.actor) {\n core.error('GITHUB_ACTOR is not defined');\n valid = false;\n }\n if (!ctx.eventName) {\n core.error('GITHUB_EVENT_NAME is not defined');\n valid = false;\n }\n if (!process.env.GITHUB_WORKSPACE) {\n core.error('GITHUB_WORKSPACE is not defined');\n valid = false;\n }\n if (!valid) {\n throw new Error('Required Actions environment variables missing.');\n }\n else {\n return valid;\n }\n}\nfunction fromWorkflowInputs(ctx) {\n const evt = ctx.payload;\n if (!evt.inputs) {\n throw new Error('Event payload has no inputs');\n }\n const dependabotApiDockerUrl = evt.inputs.dependabotApiDockerUrl || evt.inputs.dependabotApiUrl;\n const workingDirectory = absoluteWorkingDirectory(evt.inputs.workingDirectory);\n return new JobParameters(parseInt(evt.inputs.jobId, 10), evt.inputs.jobToken, evt.inputs.credentialsToken, evt.inputs.dependabotApiUrl, dependabotApiDockerUrl, workingDirectory);\n}\nfunction absoluteWorkingDirectory(workingDirectory) {\n const workspace = process.env.GITHUB_WORKSPACE;\n if (!workingDirectory) {\n throw new Error('The workingDirectory input must not be blank.');\n }\n if (!directoryExistsSync(workspace)) {\n throw new Error('The GITHUB_WORKSPACE directory does not exist.');\n }\n const fullPath = path_1.default.join(workspace, workingDirectory);\n if (!directoryExistsSync(fullPath)) {\n throw new Error(`The workingDirectory '${workingDirectory}' does not exist in GITHUB_WORKSPACE`);\n }\n return fullPath;\n}\nfunction directoryExistsSync(directoryPath) {\n let stats;\n try {\n stats = fs_1.default.statSync(directoryPath);\n }\n catch (error) {\n if (error.code === 'ENOENT') {\n return false;\n }\n throw new Error(`Encountered an error when checking whether path '${directoryPath}' exists: ${error.message}`);\n }\n return stats.isDirectory();\n}\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.run = exports.DependabotErrorType = exports.PROXY_IMAGE_NAME = exports.UPDATER_IMAGE_NAME = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst github = __importStar(require(\"@actions/github\"));\nconst inputs_1 = require(\"./inputs\");\nconst image_service_1 = require(\"./image-service\");\nconst updater_1 = require(\"./updater\");\nconst api_client_1 = require(\"./api-client\");\nconst axios_1 = __importDefault(require(\"axios\"));\nexports.UPDATER_IMAGE_NAME = 'docker.pkg.github.com/dependabot/dependabot-updater:v1';\nexports.PROXY_IMAGE_NAME = 'docker.pkg.github.com/github/dependabot-update-job-proxy:v1';\nvar DependabotErrorType;\n(function (DependabotErrorType) {\n DependabotErrorType[\"Unknown\"] = \"actions_workflow_unknown\";\n DependabotErrorType[\"Image\"] = \"actions_workflow_image\";\n DependabotErrorType[\"UpdateRun\"] = \"actions_workflow_updater\";\n})(DependabotErrorType = exports.DependabotErrorType || (exports.DependabotErrorType = {}));\nlet jobId;\nfunction run(context) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n botSay('starting update');\n // Retrieve JobParameters from the Actions environment\n const params = inputs_1.getJobParameters(context);\n // The parameters will be null if the Action environment\n // is not a valid Dependabot-triggered dynamic event.\n if (params === null) {\n botSay('finished: nothing to do');\n return; // TODO: This should be setNeutral in future\n }\n jobId = params.jobId;\n core.setSecret(params.jobToken);\n core.setSecret(params.credentialsToken);\n const client = axios_1.default.create({ baseURL: params.dependabotApiUrl });\n const apiClient = new api_client_1.ApiClient(client, params);\n core.info('Fetching job details');\n // If we fail to succeed in fetching the job details, we cannot be sure the job has entered a 'processing' state,\n // so we do not try attempt to report back an exception if this fails and instead rely on the the workflow run\n // webhook as it anticipates scenarios where jobs have failed while 'enqueued'.\n const details = yield apiClient.getJobDetails();\n try {\n const credentials = yield apiClient.getCredentials();\n const updater = new updater_1.Updater(exports.UPDATER_IMAGE_NAME, exports.PROXY_IMAGE_NAME, apiClient, details, credentials, params.workingDirectory);\n core.startGroup('Pulling updater images');\n try {\n yield image_service_1.ImageService.pull(exports.UPDATER_IMAGE_NAME);\n yield image_service_1.ImageService.pull(exports.PROXY_IMAGE_NAME);\n }\n catch (error) {\n core.error('Error fetching updater images');\n yield failJob(apiClient, error, DependabotErrorType.Image);\n return;\n }\n core.endGroup();\n try {\n core.info('Starting update process');\n yield updater.runUpdater();\n }\n catch (error) {\n // If we have encountered a UpdaterFetchError, the Updater will already have\n // reported the error and marked the job as processed, so we only need to\n // set an exit status.\n if (error instanceof updater_1.UpdaterFetchError) {\n setFailed('Dependabot was unable to retrieve the files required to perform the update');\n botSay('finished: unable to fetch files');\n return;\n }\n else {\n core.error('Error performing update');\n yield failJob(apiClient, error, DependabotErrorType.UpdateRun);\n return;\n }\n }\n botSay('finished');\n }\n catch (error) {\n if (error instanceof api_client_1.CredentialFetchingError) {\n core.error('Error retrieving update job credentials');\n yield failJob(apiClient, error, DependabotErrorType.UpdateRun);\n }\n else {\n yield failJob(apiClient, error);\n }\n return;\n }\n }\n catch (error) {\n // If we've reached this point, we do not have a viable\n // API client to report back to Dependabot API.\n //\n // We output the raw error in the Action logs and defer\n // to workflow_run monitoring to detect the job failure.\n setFailed(error);\n botSay('finished: unexpected error');\n }\n });\n}\nexports.run = run;\nfunction failJob(apiClient, error, errorType = DependabotErrorType.Unknown) {\n return __awaiter(this, void 0, void 0, function* () {\n yield apiClient.reportJobError({\n 'error-type': errorType,\n 'error-details': {\n 'action-error': error.message\n }\n });\n yield apiClient.markJobAsProcessed();\n setFailed(error.message);\n botSay('finished: error reported to Dependabot');\n });\n}\nfunction botSay(message) {\n core.info(`🤖 ~ ${message} ~`);\n}\nfunction setFailed(message) {\n core.setFailed(message);\n if (jobId) {\n core.error(`For more information see: ${dependabotJobUrl(jobId)} (write access required)`);\n }\n}\nfunction dependabotJobUrl(id) {\n const url_parts = [\n process.env.GITHUB_SERVER_URL,\n process.env.GITHUB_REPOSITORY,\n 'network/updates',\n id\n ];\n return url_parts.filter(Boolean).join('/');\n}\nrun(github.context);\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ProxyBuilder = void 0;\nconst fs_1 = __importDefault(require(\"fs\"));\nconst core = __importStar(require(\"@actions/core\"));\nconst crypto_1 = __importDefault(require(\"crypto\"));\nconst container_service_1 = require(\"./container-service\");\nconst node_forge_1 = require(\"node-forge\");\nconst utils_1 = require(\"./utils\");\nconst KEY_SIZE = 2048;\nconst KEY_EXPIRY_YEARS = 2;\nconst CONFIG_FILE_PATH = '/';\nconst CONFIG_FILE_NAME = 'config.json';\nconst CA_CERT_INPUT_PATH = '/usr/local/share/ca-certificates';\nconst CUSTOM_CA_CERT_NAME = 'custom-ca-cert.crt';\nconst CERT_SUBJECT = [\n {\n name: 'commonName',\n value: 'Dependabot Internal CA'\n },\n {\n name: 'organizationName',\n value: 'GitHub ic.'\n },\n {\n shortName: 'OU',\n value: 'Dependabot'\n },\n {\n name: 'countryName',\n value: 'US'\n },\n {\n shortName: 'ST',\n value: 'California'\n },\n {\n name: 'localityName',\n value: 'San Francisco'\n }\n];\nclass ProxyBuilder {\n constructor(docker, proxyImage) {\n this.docker = docker;\n this.proxyImage = proxyImage;\n }\n run(jobId, credentials) {\n return __awaiter(this, void 0, void 0, function* () {\n const name = `dependabot-job-${jobId}-proxy`;\n const config = this.buildProxyConfig(credentials, jobId);\n const cert = config.ca.cert;\n const externalNetworkName = `dependabot-job-${jobId}-external-network`;\n const externalNetwork = yield this.ensureNetwork(externalNetworkName, false);\n const internalNetworkName = `dependabot-job-${jobId}-internal-network`;\n const internalNetwork = yield this.ensureNetwork(internalNetworkName, true);\n const container = yield this.createContainer(jobId, name, externalNetwork, internalNetwork, internalNetworkName);\n yield container_service_1.ContainerService.storeInput(CONFIG_FILE_NAME, CONFIG_FILE_PATH, container, config);\n if (process.env.CUSTOM_CA_PATH) {\n core.info('Detected custom CA certificate, adding to proxy');\n const customCert = fs_1.default\n .readFileSync(process.env.CUSTOM_CA_PATH, 'utf8')\n .toString();\n yield container_service_1.ContainerService.storeCert(CUSTOM_CA_CERT_NAME, CA_CERT_INPUT_PATH, container, customCert);\n }\n const stream = yield container.attach({\n stream: true,\n stdout: true,\n stderr: true\n });\n container.modem.demuxStream(stream, utils_1.outStream(' proxy'), utils_1.errStream(' proxy'));\n const url = `http://${config.proxy_auth.username}:${config.proxy_auth.password}@${name}:1080`;\n return {\n container,\n network: internalNetwork,\n networkName: internalNetworkName,\n url,\n cert,\n shutdown: () => __awaiter(this, void 0, void 0, function* () {\n yield container.stop();\n yield container.remove();\n yield externalNetwork.remove();\n yield internalNetwork.remove();\n })\n };\n });\n }\n ensureNetwork(name, internal = true) {\n return __awaiter(this, void 0, void 0, function* () {\n const networks = yield this.docker.listNetworks({\n filters: JSON.stringify({ name: [name] })\n });\n if (networks.length > 0) {\n return this.docker.getNetwork(networks[0].Id);\n }\n else {\n return yield this.docker.createNetwork({ Name: name, Internal: internal });\n }\n });\n }\n buildProxyConfig(credentials, jobId) {\n const ca = this.generateCertificateAuthority();\n const password = crypto_1.default.randomBytes(20).toString('hex');\n const proxy_auth = {\n username: `${jobId}`,\n password\n };\n const config = { all_credentials: credentials, ca, proxy_auth };\n return config;\n }\n generateCertificateAuthority() {\n const keys = node_forge_1.pki.rsa.generateKeyPair(KEY_SIZE);\n const cert = node_forge_1.pki.createCertificate();\n cert.publicKey = keys.publicKey;\n cert.serialNumber = '01';\n cert.validity.notBefore = new Date();\n cert.validity.notAfter = new Date();\n cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + KEY_EXPIRY_YEARS);\n cert.setSubject(CERT_SUBJECT);\n cert.setIssuer(CERT_SUBJECT);\n cert.setExtensions([{ name: 'basicConstraints', cA: true }]);\n cert.sign(keys.privateKey);\n const pem = node_forge_1.pki.certificateToPem(cert);\n const key = node_forge_1.pki.privateKeyToPem(keys.privateKey);\n return { cert: pem, key };\n }\n createContainer(jobId, containerName, externalNetwork, internalNetwork, internalNetworkName) {\n return __awaiter(this, void 0, void 0, function* () {\n const container = yield this.docker.createContainer({\n Image: this.proxyImage,\n name: containerName,\n AttachStdout: true,\n AttachStderr: true,\n Env: [`JOB_ID=${jobId}`],\n Entrypoint: [\n 'sh',\n '-c',\n '/usr/sbin/update-ca-certificates && /update-job-proxy'\n ],\n HostConfig: {\n NetworkMode: internalNetworkName\n }\n });\n yield externalNetwork.connect({ Container: container.id });\n core.info(`Created proxy container: ${container.id}`);\n return container;\n });\n }\n}\nexports.ProxyBuilder = ProxyBuilder;\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.UpdaterBuilder = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst container_service_1 = require(\"./container-service\");\nconst JOB_OUTPUT_FILENAME = 'output.json';\nconst JOB_OUTPUT_PATH = '/home/dependabot/dependabot-updater/output';\nconst JOB_INPUT_FILENAME = 'job.json';\nconst JOB_INPUT_PATH = `/home/dependabot/dependabot-updater`;\nconst REPO_CONTENTS_PATH = '/home/dependabot/dependabot-updater/repo';\nconst CA_CERT_INPUT_PATH = '/usr/local/share/ca-certificates';\nconst CA_CERT_FILENAME = 'dbot-ca.crt';\nconst UPDATER_MAX_MEMORY = 8 * 1024 * 1024 * 1024; // 8GB in bytes\nclass UpdaterBuilder {\n constructor(docker, jobParams, input, outputHostPath, proxy, repoHostPath, updaterImage) {\n this.docker = docker;\n this.jobParams = jobParams;\n this.input = input;\n this.outputHostPath = outputHostPath;\n this.proxy = proxy;\n this.repoHostPath = repoHostPath;\n this.updaterImage = updaterImage;\n }\n run(containerName, updaterCommand) {\n return __awaiter(this, void 0, void 0, function* () {\n const cmd = `(echo > /etc/ca-certificates.conf) &&\\\n rm -Rf /usr/share/ca-certificates/ &&\\\n /usr/sbin/update-ca-certificates &&\\\n $DEPENDABOT_HOME/dependabot-updater/bin/run ${updaterCommand}`;\n const container = yield this.docker.createContainer({\n Image: this.updaterImage,\n name: containerName,\n AttachStdout: true,\n AttachStderr: true,\n Env: [\n `GITHUB_ACTIONS=${process.env.GITHUB_ACTIONS}`,\n `DEPENDABOT_JOB_ID=${this.jobParams.jobId}`,\n `DEPENDABOT_JOB_TOKEN=${this.jobParams.jobToken}`,\n `DEPENDABOT_JOB_PATH=${JOB_INPUT_PATH}/${JOB_INPUT_FILENAME}`,\n `DEPENDABOT_OUTPUT_PATH=${JOB_OUTPUT_PATH}/${JOB_OUTPUT_FILENAME}`,\n `DEPENDABOT_REPO_CONTENTS_PATH=${REPO_CONTENTS_PATH}`,\n `DEPENDABOT_API_URL=${this.jobParams.dependabotApiDockerUrl}`,\n `SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt`,\n `http_proxy=${this.proxy.url}`,\n `HTTP_PROXY=${this.proxy.url}`,\n `https_proxy=${this.proxy.url}`,\n `HTTPS_PROXY=${this.proxy.url}`\n ],\n Cmd: ['sh', '-c', cmd],\n HostConfig: {\n Memory: UPDATER_MAX_MEMORY,\n NetworkMode: this.proxy.networkName,\n Binds: [\n `${this.outputHostPath}:${JOB_OUTPUT_PATH}:rw`,\n `${this.repoHostPath}:${REPO_CONTENTS_PATH}:rw`\n ]\n }\n });\n yield container_service_1.ContainerService.storeCert(CA_CERT_FILENAME, CA_CERT_INPUT_PATH, container, this.proxy.cert);\n yield container_service_1.ContainerService.storeInput(JOB_INPUT_FILENAME, JOB_INPUT_PATH, container, this.input);\n core.info(`Created ${updaterCommand} container: ${container.id}`);\n return container;\n });\n }\n}\nexports.UpdaterBuilder = UpdaterBuilder;\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Updater = exports.UpdaterFetchError = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst dockerode_1 = __importDefault(require(\"dockerode\"));\nconst path_1 = __importDefault(require(\"path\"));\nconst fs_1 = __importDefault(require(\"fs\"));\nconst container_service_1 = require(\"./container-service\");\nconst utils_1 = require(\"./utils\");\nconst proxy_1 = require(\"./proxy\");\nconst updater_builder_1 = require(\"./updater-builder\");\nclass UpdaterFetchError extends Error {\n constructor(msg) {\n super(msg);\n Object.setPrototypeOf(this, UpdaterFetchError.prototype);\n }\n}\nexports.UpdaterFetchError = UpdaterFetchError;\nclass Updater {\n constructor(updaterImage, proxyImage, apiClient, details, credentials, workingDirectory) {\n this.updaterImage = updaterImage;\n this.proxyImage = proxyImage;\n this.apiClient = apiClient;\n this.details = details;\n this.credentials = credentials;\n this.workingDirectory = workingDirectory;\n this.docker = new dockerode_1.default();\n this.outputHostPath = path_1.default.join(workingDirectory, 'output');\n this.repoHostPath = path_1.default.join(workingDirectory, 'repo');\n }\n /**\n * Execute an update job and report the result to Dependabot API.\n */\n runUpdater() {\n return __awaiter(this, void 0, void 0, function* () {\n // Create required folders in the workingDirectory\n fs_1.default.mkdirSync(this.outputHostPath);\n fs_1.default.mkdirSync(this.repoHostPath);\n const proxy = yield new proxy_1.ProxyBuilder(this.docker, this.proxyImage).run(this.apiClient.params.jobId, this.credentials);\n proxy.container.start();\n try {\n const files = yield this.runFileFetcher(proxy);\n yield this.runFileUpdater(proxy, files);\n return true;\n }\n finally {\n yield this.cleanup(proxy);\n }\n });\n }\n runFileFetcher(proxy) {\n return __awaiter(this, void 0, void 0, function* () {\n const name = `dependabot-job-${this.apiClient.params.jobId}-file-fetcher`;\n const container = yield this.createContainer(proxy, name, 'fetch_files', {\n job: this.details\n });\n yield container_service_1.ContainerService.run(container);\n const outputPath = path_1.default.join(this.outputHostPath, 'output.json');\n if (!fs_1.default.existsSync(outputPath)) {\n throw new UpdaterFetchError('No output.json created by the fetcher container');\n }\n const fileFetcherSync = fs_1.default.readFileSync(outputPath).toString();\n const fileFetcherOutput = JSON.parse(fileFetcherSync);\n const fetchedFiles = {\n base_commit_sha: fileFetcherOutput.base_commit_sha,\n base64_dependency_files: fileFetcherOutput.base64_dependency_files,\n dependency_files: fileFetcherOutput.base64_dependency_files.map((file) => utils_1.base64DecodeDependencyFile(file))\n };\n return fetchedFiles;\n });\n }\n runFileUpdater(proxy, files) {\n return __awaiter(this, void 0, void 0, function* () {\n core.info(`Running update job ${this.apiClient.params.jobId}`);\n const name = `dependabot-job-${this.apiClient.params.jobId}-updater`;\n const containerInput = {\n base_commit_sha: files.base_commit_sha,\n base64_dependency_files: files.base64_dependency_files,\n dependency_files: files.dependency_files,\n job: this.details\n };\n const container = yield this.createContainer(proxy, name, 'update_files', containerInput);\n yield container_service_1.ContainerService.run(container);\n });\n }\n createContainer(proxy, containerName, updaterCommand, input) {\n return __awaiter(this, void 0, void 0, function* () {\n return new updater_builder_1.UpdaterBuilder(this.docker, this.apiClient.params, input, this.outputHostPath, proxy, this.repoHostPath, this.updaterImage).run(containerName, updaterCommand);\n });\n }\n cleanup(proxy) {\n return __awaiter(this, void 0, void 0, function* () {\n yield proxy.shutdown();\n if (fs_1.default.existsSync(this.outputHostPath)) {\n fs_1.default.rmdirSync(this.outputHostPath, { recursive: true });\n }\n if (fs_1.default.existsSync(this.repoHostPath)) {\n fs_1.default.rmdirSync(this.repoHostPath, { recursive: true });\n }\n });\n }\n}\nexports.Updater = Updater;\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.errStream = exports.outStream = exports.base64DecodeDependencyFile = void 0;\nconst stream_1 = __importDefault(require(\"stream\"));\nconst base64Decode = (str) => Buffer.from(str, 'base64').toString('binary');\nconst base64DecodeDependencyFile = (file) => {\n const fileCopy = JSON.parse(JSON.stringify(file));\n fileCopy.content = base64Decode(fileCopy.content);\n return fileCopy;\n};\nexports.base64DecodeDependencyFile = base64DecodeDependencyFile;\nconst outStream = (prefix) => {\n return new stream_1.default.Writable({\n write(chunk, _, next) {\n process.stderr.write(`${prefix} | ${chunk.toString()}`);\n next();\n }\n });\n};\nexports.outStream = outStream;\nconst errStream = (prefix) => {\n return new stream_1.default.Writable({\n write(chunk, _, next) {\n process.stderr.write(`${prefix} | ${chunk.toString()}`);\n next();\n }\n });\n};\nexports.errStream = errStream;\n","module.exports = __non_webpack_require__(__webpack_require__.ab + \"build/Release/cpufeatures.node\")","module.exports = __non_webpack_require__(__webpack_require__.ab + \"lib/protocol/crypto/build/Release/sshcrypto.node\")",null,"module.exports = require(\"assert\");","module.exports = require(\"buffer\");","module.exports = require(\"child_process\");","module.exports = require(\"constants\");","module.exports = require(\"crypto\");","module.exports = require(\"dns\");","module.exports = require(\"events\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","module.exports = require(\"net\");","module.exports = require(\"os\");","module.exports = require(\"path\");","module.exports = require(\"querystring\");","module.exports = require(\"stream\");","module.exports = require(\"string_decoder\");","module.exports = require(\"tls\");","module.exports = require(\"tty\");","module.exports = require(\"url\");","module.exports = require(\"util\");","module.exports = require(\"zlib\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\tvar threw = true;\n\ttry {\n\t\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\t\tthrew = false;\n\t} finally {\n\t\tif(threw) delete __webpack_module_cache__[moduleId];\n\t}\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","\nif (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = __dirname + \"/\";","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(399);\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AChTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC9KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC/IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxuCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5TA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnBA;;A;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1WA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtHA;AACA;AACA;AACA;AACA;;;A;;;;;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrIA;AACA;AACA;;A;;;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC5VA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3iBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC3YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtKA;AACA;AACA;;;A;;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5QA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACpQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1dA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3hCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClvDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzhBA;;;A;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChnDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClkCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/3CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACt+BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/eA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/iCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/uCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5TA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxuCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACj0DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9TA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3OA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACptBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzrIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC11FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACpwGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACnmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxrBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC9MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACjNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACvGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC/DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AChGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;AC1BA;;;A;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrSA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;ACzNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC79DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC5hEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjsHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjkDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAGA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC7rCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtyDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACx8CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACt1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC/UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;ACvSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3VA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtSA;AACA;;;A;;;;;ACDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9PA;;;A;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACn1EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjBA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC7EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACpEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC7FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/BA;;A;;;;;ACAA;;A;;;;;ACAA;;;A;;;;;;A;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7BA;AACA;;;;ACDA;AACA;AACA;AACA;;;;A","sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/command.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/core.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/file-command.js","../webpack://dependabot-updater-action/./node_modules/@actions/core/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/@actions/github/lib/context.js","../webpack://dependabot-updater-action/./node_modules/@actions/github/lib/github.js","../webpack://dependabot-updater-action/./node_modules/@actions/github/lib/internal/utils.js","../webpack://dependabot-updater-action/./node_modules/@actions/github/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/@actions/http-client/index.js","../webpack://dependabot-updater-action/./node_modules/@actions/http-client/proxy.js","../webpack://dependabot-updater-action/./node_modules/@octokit/auth-token/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/core/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/endpoint/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/graphql/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/plugin-paginate-rest/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/request-error/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/@octokit/request/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/errors.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/index.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/reader.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/types.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/ber/writer.js","../webpack://dependabot-updater-action/./node_modules/asn1/lib/index.js","../webpack://dependabot-updater-action/./node_modules/axios/index.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/adapters/http.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/adapters/xhr.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/axios.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/cancel/Cancel.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/cancel/CancelToken.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/cancel/isCancel.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/Axios.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/InterceptorManager.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/buildFullPath.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/createError.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/dispatchRequest.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/enhanceError.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/mergeConfig.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/settle.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/core/transformData.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/defaults.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/env/data.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/bind.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/buildURL.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/combineURLs.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/cookies.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/isAbsoluteURL.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/isAxiosError.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/isURLSameOrigin.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/normalizeHeaderName.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/parseHeaders.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/spread.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/helpers/validator.js","../webpack://dependabot-updater-action/./node_modules/axios/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/bcrypt-pbkdf/index.js","../webpack://dependabot-updater-action/./node_modules/before-after-hook/index.js","../webpack://dependabot-updater-action/./node_modules/before-after-hook/lib/add.js","../webpack://dependabot-updater-action/./node_modules/before-after-hook/lib/register.js","../webpack://dependabot-updater-action/./node_modules/before-after-hook/lib/remove.js","../webpack://dependabot-updater-action/./node_modules/bl/BufferList.js","../webpack://dependabot-updater-action/./node_modules/bl/bl.js","../webpack://dependabot-updater-action/./node_modules/chownr/chownr.js","../webpack://dependabot-updater-action/./node_modules/cpu-features/lib/index.js","../webpack://dependabot-updater-action/./node_modules/debug/src/browser.js","../webpack://dependabot-updater-action/./node_modules/debug/src/common.js","../webpack://dependabot-updater-action/./node_modules/debug/src/index.js","../webpack://dependabot-updater-action/./node_modules/debug/src/node.js","../webpack://dependabot-updater-action/./node_modules/deprecation/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/http.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/http_duplex.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/modem.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/ssh.js","../webpack://dependabot-updater-action/./node_modules/docker-modem/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/config.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/container.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/docker.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/exec.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/image.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/network.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/node.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/plugin.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/secret.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/service.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/task.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/util.js","../webpack://dependabot-updater-action/./node_modules/dockerode/lib/volume.js","../webpack://dependabot-updater-action/./node_modules/end-of-stream/index.js","../webpack://dependabot-updater-action/./node_modules/follow-redirects/debug.js","../webpack://dependabot-updater-action/./node_modules/follow-redirects/index.js","../webpack://dependabot-updater-action/./node_modules/fs-constants/index.js","../webpack://dependabot-updater-action/./node_modules/has-flag/index.js","../webpack://dependabot-updater-action/./node_modules/inherits/inherits.js","../webpack://dependabot-updater-action/./node_modules/inherits/inherits_browser.js","../webpack://dependabot-updater-action/./node_modules/is-plain-object/dist/is-plain-object.js","../webpack://dependabot-updater-action/./node_modules/mkdirp-classic/index.js","../webpack://dependabot-updater-action/./node_modules/ms/index.js","../webpack://dependabot-updater-action/./node_modules/node-fetch/lib/index.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/aes.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/aesCipherSuites.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/asn1-validator.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/asn1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/baseN.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/cipher.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/cipherModes.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/debug.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/des.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/ed25519.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/forge.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/hmac.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/index.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/jsbn.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/kem.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/log.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/md.all.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/md.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/md5.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/mgf.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/mgf1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/oids.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pbe.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pbkdf2.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pem.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pkcs1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pkcs12.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pkcs7.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pkcs7asn1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pki.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/prime.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/prng.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/pss.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/random.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/rc2.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/rsa.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/sha1.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/sha256.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/sha512.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/ssh.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/task.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/tls.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/util.js","../webpack://dependabot-updater-action/./node_modules/node-forge/lib/x509.js","../webpack://dependabot-updater-action/./node_modules/once/once.js","../webpack://dependabot-updater-action/./node_modules/pump/index.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/errors.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_duplex.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_passthrough.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_readable.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_transform.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/_stream_writable.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/async_iterator.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/buffer_list.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/destroy.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/end-of-stream.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/from.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/pipeline.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/state.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/lib/internal/streams/stream.js","../webpack://dependabot-updater-action/./node_modules/readable-stream/readable.js","../webpack://dependabot-updater-action/./node_modules/safer-buffer/safer.js","../webpack://dependabot-updater-action/./node_modules/split-ca/index.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/Channel.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/agent.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/client.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/http-agents.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/index.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/Protocol.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/SFTP.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/constants.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto/poly1305.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/handlers.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/handlers.misc.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/kex.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/keyParser.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/node-fs-compat.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/utils.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/zlib.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/server.js","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/utils.js","../webpack://dependabot-updater-action/./node_modules/string_decoder/lib/string_decoder.js","../webpack://dependabot-updater-action/./node_modules/string_decoder/node_modules/safe-buffer/index.js","../webpack://dependabot-updater-action/./node_modules/supports-color/index.js","../webpack://dependabot-updater-action/./node_modules/tar-fs/index.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/extract.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/headers.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/index.js","../webpack://dependabot-updater-action/./node_modules/tar-stream/pack.js","../webpack://dependabot-updater-action/./node_modules/tunnel/index.js","../webpack://dependabot-updater-action/./node_modules/tunnel/lib/tunnel.js","../webpack://dependabot-updater-action/./node_modules/tweetnacl/nacl-fast.js","../webpack://dependabot-updater-action/./node_modules/universal-user-agent/dist-node/index.js","../webpack://dependabot-updater-action/./node_modules/util-deprecate/node.js","../webpack://dependabot-updater-action/./node_modules/wrappy/wrappy.js","../webpack://dependabot-updater-action/./src/api-client.ts","../webpack://dependabot-updater-action/./src/container-service.ts","../webpack://dependabot-updater-action/./src/image-service.ts","../webpack://dependabot-updater-action/./src/inputs.ts","../webpack://dependabot-updater-action/./src/main.ts","../webpack://dependabot-updater-action/./src/proxy.ts","../webpack://dependabot-updater-action/./src/updater-builder.ts","../webpack://dependabot-updater-action/./src/updater.ts","../webpack://dependabot-updater-action/./src/utils.ts","../webpack://dependabot-updater-action/./node_modules/cpu-features/build/Release/cpufeatures.node","../webpack://dependabot-updater-action/./node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node","../webpack://dependabot-updater-action/./node_modules/@vercel/ncc/dist/ncc/@@notfound.js","../webpack://dependabot-updater-action/external \"assert\"","../webpack://dependabot-updater-action/external \"buffer\"","../webpack://dependabot-updater-action/external \"child_process\"","../webpack://dependabot-updater-action/external \"constants\"","../webpack://dependabot-updater-action/external \"crypto\"","../webpack://dependabot-updater-action/external \"dns\"","../webpack://dependabot-updater-action/external \"events\"","../webpack://dependabot-updater-action/external \"fs\"","../webpack://dependabot-updater-action/external \"http\"","../webpack://dependabot-updater-action/external \"https\"","../webpack://dependabot-updater-action/external \"net\"","../webpack://dependabot-updater-action/external \"os\"","../webpack://dependabot-updater-action/external \"path\"","../webpack://dependabot-updater-action/external \"querystring\"","../webpack://dependabot-updater-action/external \"stream\"","../webpack://dependabot-updater-action/external \"string_decoder\"","../webpack://dependabot-updater-action/external \"tls\"","../webpack://dependabot-updater-action/external \"tty\"","../webpack://dependabot-updater-action/external \"url\"","../webpack://dependabot-updater-action/external \"util\"","../webpack://dependabot-updater-action/external \"zlib\"","../webpack://dependabot-updater-action/webpack/bootstrap","../webpack://dependabot-updater-action/webpack/runtime/compat","../webpack://dependabot-updater-action/webpack/startup"],"sourcesContent":["\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.issue = exports.issueCommand = void 0;\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\n/**\n * Commands\n *\n * Command Format:\n * ::name key=value,key=value::message\n *\n * Examples:\n * ::warning::This is the message\n * ::set-env name=MY_VAR::some value\n */\nfunction issueCommand(command, properties, message) {\n const cmd = new Command(command, properties, message);\n process.stdout.write(cmd.toString() + os.EOL);\n}\nexports.issueCommand = issueCommand;\nfunction issue(name, message = '') {\n issueCommand(name, {}, message);\n}\nexports.issue = issue;\nconst CMD_STRING = '::';\nclass Command {\n constructor(command, properties, message) {\n if (!command) {\n command = 'missing.command';\n }\n this.command = command;\n this.properties = properties;\n this.message = message;\n }\n toString() {\n let cmdStr = CMD_STRING + this.command;\n if (this.properties && Object.keys(this.properties).length > 0) {\n cmdStr += ' ';\n let first = true;\n for (const key in this.properties) {\n if (this.properties.hasOwnProperty(key)) {\n const val = this.properties[key];\n if (val) {\n if (first) {\n first = false;\n }\n else {\n cmdStr += ',';\n }\n cmdStr += `${key}=${escapeProperty(val)}`;\n }\n }\n }\n }\n cmdStr += `${CMD_STRING}${escapeData(this.message)}`;\n return cmdStr;\n }\n}\nfunction escapeData(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A');\n}\nfunction escapeProperty(s) {\n return utils_1.toCommandValue(s)\n .replace(/%/g, '%25')\n .replace(/\\r/g, '%0D')\n .replace(/\\n/g, '%0A')\n .replace(/:/g, '%3A')\n .replace(/,/g, '%2C');\n}\n//# sourceMappingURL=command.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;\nconst command_1 = require(\"./command\");\nconst file_command_1 = require(\"./file-command\");\nconst utils_1 = require(\"./utils\");\nconst os = __importStar(require(\"os\"));\nconst path = __importStar(require(\"path\"));\n/**\n * The code to exit an action\n */\nvar ExitCode;\n(function (ExitCode) {\n /**\n * A code indicating that the action was successful\n */\n ExitCode[ExitCode[\"Success\"] = 0] = \"Success\";\n /**\n * A code indicating that the action was a failure\n */\n ExitCode[ExitCode[\"Failure\"] = 1] = \"Failure\";\n})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));\n//-----------------------------------------------------------------------\n// Variables\n//-----------------------------------------------------------------------\n/**\n * Sets env variable for this action and future actions in the job\n * @param name the name of the variable to set\n * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction exportVariable(name, val) {\n const convertedVal = utils_1.toCommandValue(val);\n process.env[name] = convertedVal;\n const filePath = process.env['GITHUB_ENV'] || '';\n if (filePath) {\n const delimiter = '_GitHubActionsFileCommandDelimeter_';\n const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;\n file_command_1.issueCommand('ENV', commandValue);\n }\n else {\n command_1.issueCommand('set-env', { name }, convertedVal);\n }\n}\nexports.exportVariable = exportVariable;\n/**\n * Registers a secret which will get masked from logs\n * @param secret value of the secret\n */\nfunction setSecret(secret) {\n command_1.issueCommand('add-mask', {}, secret);\n}\nexports.setSecret = setSecret;\n/**\n * Prepends inputPath to the PATH (for this action and future actions)\n * @param inputPath\n */\nfunction addPath(inputPath) {\n const filePath = process.env['GITHUB_PATH'] || '';\n if (filePath) {\n file_command_1.issueCommand('PATH', inputPath);\n }\n else {\n command_1.issueCommand('add-path', {}, inputPath);\n }\n process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;\n}\nexports.addPath = addPath;\n/**\n * Gets the value of an input.\n * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.\n * Returns an empty string if the value is not defined.\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns string\n */\nfunction getInput(name, options) {\n const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';\n if (options && options.required && !val) {\n throw new Error(`Input required and not supplied: ${name}`);\n }\n if (options && options.trimWhitespace === false) {\n return val;\n }\n return val.trim();\n}\nexports.getInput = getInput;\n/**\n * Gets the values of an multiline input. Each value is also trimmed.\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns string[]\n *\n */\nfunction getMultilineInput(name, options) {\n const inputs = getInput(name, options)\n .split('\\n')\n .filter(x => x !== '');\n return inputs;\n}\nexports.getMultilineInput = getMultilineInput;\n/**\n * Gets the input value of the boolean type in the YAML 1.2 \"core schema\" specification.\n * Support boolean input list: `true | True | TRUE | false | False | FALSE` .\n * The return value is also in boolean type.\n * ref: https://yaml.org/spec/1.2/spec.html#id2804923\n *\n * @param name name of the input to get\n * @param options optional. See InputOptions.\n * @returns boolean\n */\nfunction getBooleanInput(name, options) {\n const trueValue = ['true', 'True', 'TRUE'];\n const falseValue = ['false', 'False', 'FALSE'];\n const val = getInput(name, options);\n if (trueValue.includes(val))\n return true;\n if (falseValue.includes(val))\n return false;\n throw new TypeError(`Input does not meet YAML 1.2 \"Core Schema\" specification: ${name}\\n` +\n `Support boolean input list: \\`true | True | TRUE | false | False | FALSE\\``);\n}\nexports.getBooleanInput = getBooleanInput;\n/**\n * Sets the value of an output.\n *\n * @param name name of the output to set\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction setOutput(name, value) {\n process.stdout.write(os.EOL);\n command_1.issueCommand('set-output', { name }, value);\n}\nexports.setOutput = setOutput;\n/**\n * Enables or disables the echoing of commands into stdout for the rest of the step.\n * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.\n *\n */\nfunction setCommandEcho(enabled) {\n command_1.issue('echo', enabled ? 'on' : 'off');\n}\nexports.setCommandEcho = setCommandEcho;\n//-----------------------------------------------------------------------\n// Results\n//-----------------------------------------------------------------------\n/**\n * Sets the action status to failed.\n * When the action exits it will be with an exit code of 1\n * @param message add error issue message\n */\nfunction setFailed(message) {\n process.exitCode = ExitCode.Failure;\n error(message);\n}\nexports.setFailed = setFailed;\n//-----------------------------------------------------------------------\n// Logging Commands\n//-----------------------------------------------------------------------\n/**\n * Gets whether Actions Step Debug is on or not\n */\nfunction isDebug() {\n return process.env['RUNNER_DEBUG'] === '1';\n}\nexports.isDebug = isDebug;\n/**\n * Writes debug message to user log\n * @param message debug message\n */\nfunction debug(message) {\n command_1.issueCommand('debug', {}, message);\n}\nexports.debug = debug;\n/**\n * Adds an error issue\n * @param message error issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction error(message, properties = {}) {\n command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.error = error;\n/**\n * Adds a warning issue\n * @param message warning issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction warning(message, properties = {}) {\n command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.warning = warning;\n/**\n * Adds a notice issue\n * @param message notice issue message. Errors will be converted to string via toString()\n * @param properties optional properties to add to the annotation.\n */\nfunction notice(message, properties = {}) {\n command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);\n}\nexports.notice = notice;\n/**\n * Writes info to log with console.log.\n * @param message info message\n */\nfunction info(message) {\n process.stdout.write(message + os.EOL);\n}\nexports.info = info;\n/**\n * Begin an output group.\n *\n * Output until the next `groupEnd` will be foldable in this group\n *\n * @param name The name of the output group\n */\nfunction startGroup(name) {\n command_1.issue('group', name);\n}\nexports.startGroup = startGroup;\n/**\n * End an output group.\n */\nfunction endGroup() {\n command_1.issue('endgroup');\n}\nexports.endGroup = endGroup;\n/**\n * Wrap an asynchronous function call in a group.\n *\n * Returns the same type as the function itself.\n *\n * @param name The name of the group\n * @param fn The function to wrap in the group\n */\nfunction group(name, fn) {\n return __awaiter(this, void 0, void 0, function* () {\n startGroup(name);\n let result;\n try {\n result = yield fn();\n }\n finally {\n endGroup();\n }\n return result;\n });\n}\nexports.group = group;\n//-----------------------------------------------------------------------\n// Wrapper action state\n//-----------------------------------------------------------------------\n/**\n * Saves state for current action, the state can only be retrieved by this action's post job execution.\n *\n * @param name name of the state to store\n * @param value value to store. Non-string values will be converted to a string via JSON.stringify\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction saveState(name, value) {\n command_1.issueCommand('save-state', { name }, value);\n}\nexports.saveState = saveState;\n/**\n * Gets the value of an state set by this action's main execution.\n *\n * @param name name of the state to get\n * @returns string\n */\nfunction getState(name) {\n return process.env[`STATE_${name}`] || '';\n}\nexports.getState = getState;\n//# sourceMappingURL=core.js.map","\"use strict\";\n// For internal use, subject to change.\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.issueCommand = void 0;\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst fs = __importStar(require(\"fs\"));\nconst os = __importStar(require(\"os\"));\nconst utils_1 = require(\"./utils\");\nfunction issueCommand(command, message) {\n const filePath = process.env[`GITHUB_${command}`];\n if (!filePath) {\n throw new Error(`Unable to find environment variable for file command ${command}`);\n }\n if (!fs.existsSync(filePath)) {\n throw new Error(`Missing file at path: ${filePath}`);\n }\n fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {\n encoding: 'utf8'\n });\n}\nexports.issueCommand = issueCommand;\n//# sourceMappingURL=file-command.js.map","\"use strict\";\n// We use any as a valid input type\n/* eslint-disable @typescript-eslint/no-explicit-any */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.toCommandProperties = exports.toCommandValue = void 0;\n/**\n * Sanitizes an input into a string so it can be passed into issueCommand safely\n * @param input input to sanitize into a string\n */\nfunction toCommandValue(input) {\n if (input === null || input === undefined) {\n return '';\n }\n else if (typeof input === 'string' || input instanceof String) {\n return input;\n }\n return JSON.stringify(input);\n}\nexports.toCommandValue = toCommandValue;\n/**\n *\n * @param annotationProperties\n * @returns The command properties to send with the actual annotation command\n * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646\n */\nfunction toCommandProperties(annotationProperties) {\n if (!Object.keys(annotationProperties).length) {\n return {};\n }\n return {\n title: annotationProperties.title,\n line: annotationProperties.startLine,\n endLine: annotationProperties.endLine,\n col: annotationProperties.startColumn,\n endColumn: annotationProperties.endColumn\n };\n}\nexports.toCommandProperties = toCommandProperties;\n//# sourceMappingURL=utils.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Context = void 0;\nconst fs_1 = require(\"fs\");\nconst os_1 = require(\"os\");\nclass Context {\n /**\n * Hydrate the context from the environment\n */\n constructor() {\n var _a, _b, _c;\n this.payload = {};\n if (process.env.GITHUB_EVENT_PATH) {\n if (fs_1.existsSync(process.env.GITHUB_EVENT_PATH)) {\n this.payload = JSON.parse(fs_1.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' }));\n }\n else {\n const path = process.env.GITHUB_EVENT_PATH;\n process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${os_1.EOL}`);\n }\n }\n this.eventName = process.env.GITHUB_EVENT_NAME;\n this.sha = process.env.GITHUB_SHA;\n this.ref = process.env.GITHUB_REF;\n this.workflow = process.env.GITHUB_WORKFLOW;\n this.action = process.env.GITHUB_ACTION;\n this.actor = process.env.GITHUB_ACTOR;\n this.job = process.env.GITHUB_JOB;\n this.runNumber = parseInt(process.env.GITHUB_RUN_NUMBER, 10);\n this.runId = parseInt(process.env.GITHUB_RUN_ID, 10);\n this.apiUrl = (_a = process.env.GITHUB_API_URL) !== null && _a !== void 0 ? _a : `https://api.github.com`;\n this.serverUrl = (_b = process.env.GITHUB_SERVER_URL) !== null && _b !== void 0 ? _b : `https://github.com`;\n this.graphqlUrl = (_c = process.env.GITHUB_GRAPHQL_URL) !== null && _c !== void 0 ? _c : `https://api.github.com/graphql`;\n }\n get issue() {\n const payload = this.payload;\n return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pull_request || payload).number });\n }\n get repo() {\n if (process.env.GITHUB_REPOSITORY) {\n const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');\n return { owner, repo };\n }\n if (this.payload.repository) {\n return {\n owner: this.payload.repository.owner.login,\n repo: this.payload.repository.name\n };\n }\n throw new Error(\"context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'\");\n }\n}\nexports.Context = Context;\n//# sourceMappingURL=context.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getOctokit = exports.context = void 0;\nconst Context = __importStar(require(\"./context\"));\nconst utils_1 = require(\"./utils\");\nexports.context = new Context.Context();\n/**\n * Returns a hydrated octokit ready to use for GitHub Actions\n *\n * @param token the repo PAT or GITHUB_TOKEN\n * @param options other options to set\n */\nfunction getOctokit(token, options) {\n return new utils_1.GitHub(utils_1.getOctokitOptions(token, options));\n}\nexports.getOctokit = getOctokit;\n//# sourceMappingURL=github.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getApiBaseUrl = exports.getProxyAgent = exports.getAuthString = void 0;\nconst httpClient = __importStar(require(\"@actions/http-client\"));\nfunction getAuthString(token, options) {\n if (!token && !options.auth) {\n throw new Error('Parameter token or opts.auth is required');\n }\n else if (token && options.auth) {\n throw new Error('Parameters token and opts.auth may not both be specified');\n }\n return typeof options.auth === 'string' ? options.auth : `token ${token}`;\n}\nexports.getAuthString = getAuthString;\nfunction getProxyAgent(destinationUrl) {\n const hc = new httpClient.HttpClient();\n return hc.getAgent(destinationUrl);\n}\nexports.getProxyAgent = getProxyAgent;\nfunction getApiBaseUrl() {\n return process.env['GITHUB_API_URL'] || 'https://api.github.com';\n}\nexports.getApiBaseUrl = getApiBaseUrl;\n//# sourceMappingURL=utils.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getOctokitOptions = exports.GitHub = exports.context = void 0;\nconst Context = __importStar(require(\"./context\"));\nconst Utils = __importStar(require(\"./internal/utils\"));\n// octokit + plugins\nconst core_1 = require(\"@octokit/core\");\nconst plugin_rest_endpoint_methods_1 = require(\"@octokit/plugin-rest-endpoint-methods\");\nconst plugin_paginate_rest_1 = require(\"@octokit/plugin-paginate-rest\");\nexports.context = new Context.Context();\nconst baseUrl = Utils.getApiBaseUrl();\nconst defaults = {\n baseUrl,\n request: {\n agent: Utils.getProxyAgent(baseUrl)\n }\n};\nexports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults);\n/**\n * Convience function to correctly format Octokit Options to pass into the constructor.\n *\n * @param token the repo PAT or GITHUB_TOKEN\n * @param options other options to set\n */\nfunction getOctokitOptions(token, options) {\n const opts = Object.assign({}, options || {}); // Shallow clone - don't mutate the object provided by the caller\n // Auth\n const auth = Utils.getAuthString(token, opts);\n if (auth) {\n opts.auth = auth;\n }\n return opts;\n}\nexports.getOctokitOptions = getOctokitOptions;\n//# sourceMappingURL=utils.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst http = require(\"http\");\nconst https = require(\"https\");\nconst pm = require(\"./proxy\");\nlet tunnel;\nvar HttpCodes;\n(function (HttpCodes) {\n HttpCodes[HttpCodes[\"OK\"] = 200] = \"OK\";\n HttpCodes[HttpCodes[\"MultipleChoices\"] = 300] = \"MultipleChoices\";\n HttpCodes[HttpCodes[\"MovedPermanently\"] = 301] = \"MovedPermanently\";\n HttpCodes[HttpCodes[\"ResourceMoved\"] = 302] = \"ResourceMoved\";\n HttpCodes[HttpCodes[\"SeeOther\"] = 303] = \"SeeOther\";\n HttpCodes[HttpCodes[\"NotModified\"] = 304] = \"NotModified\";\n HttpCodes[HttpCodes[\"UseProxy\"] = 305] = \"UseProxy\";\n HttpCodes[HttpCodes[\"SwitchProxy\"] = 306] = \"SwitchProxy\";\n HttpCodes[HttpCodes[\"TemporaryRedirect\"] = 307] = \"TemporaryRedirect\";\n HttpCodes[HttpCodes[\"PermanentRedirect\"] = 308] = \"PermanentRedirect\";\n HttpCodes[HttpCodes[\"BadRequest\"] = 400] = \"BadRequest\";\n HttpCodes[HttpCodes[\"Unauthorized\"] = 401] = \"Unauthorized\";\n HttpCodes[HttpCodes[\"PaymentRequired\"] = 402] = \"PaymentRequired\";\n HttpCodes[HttpCodes[\"Forbidden\"] = 403] = \"Forbidden\";\n HttpCodes[HttpCodes[\"NotFound\"] = 404] = \"NotFound\";\n HttpCodes[HttpCodes[\"MethodNotAllowed\"] = 405] = \"MethodNotAllowed\";\n HttpCodes[HttpCodes[\"NotAcceptable\"] = 406] = \"NotAcceptable\";\n HttpCodes[HttpCodes[\"ProxyAuthenticationRequired\"] = 407] = \"ProxyAuthenticationRequired\";\n HttpCodes[HttpCodes[\"RequestTimeout\"] = 408] = \"RequestTimeout\";\n HttpCodes[HttpCodes[\"Conflict\"] = 409] = \"Conflict\";\n HttpCodes[HttpCodes[\"Gone\"] = 410] = \"Gone\";\n HttpCodes[HttpCodes[\"TooManyRequests\"] = 429] = \"TooManyRequests\";\n HttpCodes[HttpCodes[\"InternalServerError\"] = 500] = \"InternalServerError\";\n HttpCodes[HttpCodes[\"NotImplemented\"] = 501] = \"NotImplemented\";\n HttpCodes[HttpCodes[\"BadGateway\"] = 502] = \"BadGateway\";\n HttpCodes[HttpCodes[\"ServiceUnavailable\"] = 503] = \"ServiceUnavailable\";\n HttpCodes[HttpCodes[\"GatewayTimeout\"] = 504] = \"GatewayTimeout\";\n})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));\nvar Headers;\n(function (Headers) {\n Headers[\"Accept\"] = \"accept\";\n Headers[\"ContentType\"] = \"content-type\";\n})(Headers = exports.Headers || (exports.Headers = {}));\nvar MediaTypes;\n(function (MediaTypes) {\n MediaTypes[\"ApplicationJson\"] = \"application/json\";\n})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));\n/**\n * Returns the proxy URL, depending upon the supplied url and proxy environment variables.\n * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com\n */\nfunction getProxyUrl(serverUrl) {\n let proxyUrl = pm.getProxyUrl(new URL(serverUrl));\n return proxyUrl ? proxyUrl.href : '';\n}\nexports.getProxyUrl = getProxyUrl;\nconst HttpRedirectCodes = [\n HttpCodes.MovedPermanently,\n HttpCodes.ResourceMoved,\n HttpCodes.SeeOther,\n HttpCodes.TemporaryRedirect,\n HttpCodes.PermanentRedirect\n];\nconst HttpResponseRetryCodes = [\n HttpCodes.BadGateway,\n HttpCodes.ServiceUnavailable,\n HttpCodes.GatewayTimeout\n];\nconst RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];\nconst ExponentialBackoffCeiling = 10;\nconst ExponentialBackoffTimeSlice = 5;\nclass HttpClientError extends Error {\n constructor(message, statusCode) {\n super(message);\n this.name = 'HttpClientError';\n this.statusCode = statusCode;\n Object.setPrototypeOf(this, HttpClientError.prototype);\n }\n}\nexports.HttpClientError = HttpClientError;\nclass HttpClientResponse {\n constructor(message) {\n this.message = message;\n }\n readBody() {\n return new Promise(async (resolve, reject) => {\n let output = Buffer.alloc(0);\n this.message.on('data', (chunk) => {\n output = Buffer.concat([output, chunk]);\n });\n this.message.on('end', () => {\n resolve(output.toString());\n });\n });\n }\n}\nexports.HttpClientResponse = HttpClientResponse;\nfunction isHttps(requestUrl) {\n let parsedUrl = new URL(requestUrl);\n return parsedUrl.protocol === 'https:';\n}\nexports.isHttps = isHttps;\nclass HttpClient {\n constructor(userAgent, handlers, requestOptions) {\n this._ignoreSslError = false;\n this._allowRedirects = true;\n this._allowRedirectDowngrade = false;\n this._maxRedirects = 50;\n this._allowRetries = false;\n this._maxRetries = 1;\n this._keepAlive = false;\n this._disposed = false;\n this.userAgent = userAgent;\n this.handlers = handlers || [];\n this.requestOptions = requestOptions;\n if (requestOptions) {\n if (requestOptions.ignoreSslError != null) {\n this._ignoreSslError = requestOptions.ignoreSslError;\n }\n this._socketTimeout = requestOptions.socketTimeout;\n if (requestOptions.allowRedirects != null) {\n this._allowRedirects = requestOptions.allowRedirects;\n }\n if (requestOptions.allowRedirectDowngrade != null) {\n this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;\n }\n if (requestOptions.maxRedirects != null) {\n this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);\n }\n if (requestOptions.keepAlive != null) {\n this._keepAlive = requestOptions.keepAlive;\n }\n if (requestOptions.allowRetries != null) {\n this._allowRetries = requestOptions.allowRetries;\n }\n if (requestOptions.maxRetries != null) {\n this._maxRetries = requestOptions.maxRetries;\n }\n }\n }\n options(requestUrl, additionalHeaders) {\n return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});\n }\n get(requestUrl, additionalHeaders) {\n return this.request('GET', requestUrl, null, additionalHeaders || {});\n }\n del(requestUrl, additionalHeaders) {\n return this.request('DELETE', requestUrl, null, additionalHeaders || {});\n }\n post(requestUrl, data, additionalHeaders) {\n return this.request('POST', requestUrl, data, additionalHeaders || {});\n }\n patch(requestUrl, data, additionalHeaders) {\n return this.request('PATCH', requestUrl, data, additionalHeaders || {});\n }\n put(requestUrl, data, additionalHeaders) {\n return this.request('PUT', requestUrl, data, additionalHeaders || {});\n }\n head(requestUrl, additionalHeaders) {\n return this.request('HEAD', requestUrl, null, additionalHeaders || {});\n }\n sendStream(verb, requestUrl, stream, additionalHeaders) {\n return this.request(verb, requestUrl, stream, additionalHeaders);\n }\n /**\n * Gets a typed object from an endpoint\n * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise\n */\n async getJson(requestUrl, additionalHeaders = {}) {\n additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);\n let res = await this.get(requestUrl, additionalHeaders);\n return this._processResponse(res, this.requestOptions);\n }\n async postJson(requestUrl, obj, additionalHeaders = {}) {\n let data = JSON.stringify(obj, null, 2);\n additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);\n additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);\n let res = await this.post(requestUrl, data, additionalHeaders);\n return this._processResponse(res, this.requestOptions);\n }\n async putJson(requestUrl, obj, additionalHeaders = {}) {\n let data = JSON.stringify(obj, null, 2);\n additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);\n additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);\n let res = await this.put(requestUrl, data, additionalHeaders);\n return this._processResponse(res, this.requestOptions);\n }\n async patchJson(requestUrl, obj, additionalHeaders = {}) {\n let data = JSON.stringify(obj, null, 2);\n additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);\n additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);\n let res = await this.patch(requestUrl, data, additionalHeaders);\n return this._processResponse(res, this.requestOptions);\n }\n /**\n * Makes a raw http request.\n * All other methods such as get, post, patch, and request ultimately call this.\n * Prefer get, del, post and patch\n */\n async request(verb, requestUrl, data, headers) {\n if (this._disposed) {\n throw new Error('Client has already been disposed.');\n }\n let parsedUrl = new URL(requestUrl);\n let info = this._prepareRequest(verb, parsedUrl, headers);\n // Only perform retries on reads since writes may not be idempotent.\n let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1\n ? this._maxRetries + 1\n : 1;\n let numTries = 0;\n let response;\n while (numTries < maxTries) {\n response = await this.requestRaw(info, data);\n // Check if it's an authentication challenge\n if (response &&\n response.message &&\n response.message.statusCode === HttpCodes.Unauthorized) {\n let authenticationHandler;\n for (let i = 0; i < this.handlers.length; i++) {\n if (this.handlers[i].canHandleAuthentication(response)) {\n authenticationHandler = this.handlers[i];\n break;\n }\n }\n if (authenticationHandler) {\n return authenticationHandler.handleAuthentication(this, info, data);\n }\n else {\n // We have received an unauthorized response but have no handlers to handle it.\n // Let the response return to the caller.\n return response;\n }\n }\n let redirectsRemaining = this._maxRedirects;\n while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&\n this._allowRedirects &&\n redirectsRemaining > 0) {\n const redirectUrl = response.message.headers['location'];\n if (!redirectUrl) {\n // if there's no location to redirect to, we won't\n break;\n }\n let parsedRedirectUrl = new URL(redirectUrl);\n if (parsedUrl.protocol == 'https:' &&\n parsedUrl.protocol != parsedRedirectUrl.protocol &&\n !this._allowRedirectDowngrade) {\n throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');\n }\n // we need to finish reading the response before reassigning response\n // which will leak the open socket.\n await response.readBody();\n // strip authorization header if redirected to a different hostname\n if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {\n for (let header in headers) {\n // header names are case insensitive\n if (header.toLowerCase() === 'authorization') {\n delete headers[header];\n }\n }\n }\n // let's make the request with the new redirectUrl\n info = this._prepareRequest(verb, parsedRedirectUrl, headers);\n response = await this.requestRaw(info, data);\n redirectsRemaining--;\n }\n if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) {\n // If not a retry code, return immediately instead of retrying\n return response;\n }\n numTries += 1;\n if (numTries < maxTries) {\n await response.readBody();\n await this._performExponentialBackoff(numTries);\n }\n }\n return response;\n }\n /**\n * Needs to be called if keepAlive is set to true in request options.\n */\n dispose() {\n if (this._agent) {\n this._agent.destroy();\n }\n this._disposed = true;\n }\n /**\n * Raw request.\n * @param info\n * @param data\n */\n requestRaw(info, data) {\n return new Promise((resolve, reject) => {\n let callbackForResult = function (err, res) {\n if (err) {\n reject(err);\n }\n resolve(res);\n };\n this.requestRawWithCallback(info, data, callbackForResult);\n });\n }\n /**\n * Raw request with callback.\n * @param info\n * @param data\n * @param onResult\n */\n requestRawWithCallback(info, data, onResult) {\n let socket;\n if (typeof data === 'string') {\n info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');\n }\n let callbackCalled = false;\n let handleResult = (err, res) => {\n if (!callbackCalled) {\n callbackCalled = true;\n onResult(err, res);\n }\n };\n let req = info.httpModule.request(info.options, (msg) => {\n let res = new HttpClientResponse(msg);\n handleResult(null, res);\n });\n req.on('socket', sock => {\n socket = sock;\n });\n // If we ever get disconnected, we want the socket to timeout eventually\n req.setTimeout(this._socketTimeout || 3 * 60000, () => {\n if (socket) {\n socket.end();\n }\n handleResult(new Error('Request timeout: ' + info.options.path), null);\n });\n req.on('error', function (err) {\n // err has statusCode property\n // res should have headers\n handleResult(err, null);\n });\n if (data && typeof data === 'string') {\n req.write(data, 'utf8');\n }\n if (data && typeof data !== 'string') {\n data.on('close', function () {\n req.end();\n });\n data.pipe(req);\n }\n else {\n req.end();\n }\n }\n /**\n * Gets an http agent. This function is useful when you need an http agent that handles\n * routing through a proxy server - depending upon the url and proxy environment variables.\n * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com\n */\n getAgent(serverUrl) {\n let parsedUrl = new URL(serverUrl);\n return this._getAgent(parsedUrl);\n }\n _prepareRequest(method, requestUrl, headers) {\n const info = {};\n info.parsedUrl = requestUrl;\n const usingSsl = info.parsedUrl.protocol === 'https:';\n info.httpModule = usingSsl ? https : http;\n const defaultPort = usingSsl ? 443 : 80;\n info.options = {};\n info.options.host = info.parsedUrl.hostname;\n info.options.port = info.parsedUrl.port\n ? parseInt(info.parsedUrl.port)\n : defaultPort;\n info.options.path =\n (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');\n info.options.method = method;\n info.options.headers = this._mergeHeaders(headers);\n if (this.userAgent != null) {\n info.options.headers['user-agent'] = this.userAgent;\n }\n info.options.agent = this._getAgent(info.parsedUrl);\n // gives handlers an opportunity to participate\n if (this.handlers) {\n this.handlers.forEach(handler => {\n handler.prepareRequest(info.options);\n });\n }\n return info;\n }\n _mergeHeaders(headers) {\n const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});\n if (this.requestOptions && this.requestOptions.headers) {\n return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));\n }\n return lowercaseKeys(headers || {});\n }\n _getExistingOrDefaultHeader(additionalHeaders, header, _default) {\n const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});\n let clientHeader;\n if (this.requestOptions && this.requestOptions.headers) {\n clientHeader = lowercaseKeys(this.requestOptions.headers)[header];\n }\n return additionalHeaders[header] || clientHeader || _default;\n }\n _getAgent(parsedUrl) {\n let agent;\n let proxyUrl = pm.getProxyUrl(parsedUrl);\n let useProxy = proxyUrl && proxyUrl.hostname;\n if (this._keepAlive && useProxy) {\n agent = this._proxyAgent;\n }\n if (this._keepAlive && !useProxy) {\n agent = this._agent;\n }\n // if agent is already assigned use that agent.\n if (!!agent) {\n return agent;\n }\n const usingSsl = parsedUrl.protocol === 'https:';\n let maxSockets = 100;\n if (!!this.requestOptions) {\n maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;\n }\n if (useProxy) {\n // If using proxy, need tunnel\n if (!tunnel) {\n tunnel = require('tunnel');\n }\n const agentOptions = {\n maxSockets: maxSockets,\n keepAlive: this._keepAlive,\n proxy: {\n ...((proxyUrl.username || proxyUrl.password) && {\n proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`\n }),\n host: proxyUrl.hostname,\n port: proxyUrl.port\n }\n };\n let tunnelAgent;\n const overHttps = proxyUrl.protocol === 'https:';\n if (usingSsl) {\n tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;\n }\n else {\n tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;\n }\n agent = tunnelAgent(agentOptions);\n this._proxyAgent = agent;\n }\n // if reusing agent across request and tunneling agent isn't assigned create a new agent\n if (this._keepAlive && !agent) {\n const options = { keepAlive: this._keepAlive, maxSockets: maxSockets };\n agent = usingSsl ? new https.Agent(options) : new http.Agent(options);\n this._agent = agent;\n }\n // if not using private agent and tunnel agent isn't setup then use global agent\n if (!agent) {\n agent = usingSsl ? https.globalAgent : http.globalAgent;\n }\n if (usingSsl && this._ignoreSslError) {\n // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process\n // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options\n // we have to cast it to any and change it directly\n agent.options = Object.assign(agent.options || {}, {\n rejectUnauthorized: false\n });\n }\n return agent;\n }\n _performExponentialBackoff(retryNumber) {\n retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);\n const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);\n return new Promise(resolve => setTimeout(() => resolve(), ms));\n }\n static dateTimeDeserializer(key, value) {\n if (typeof value === 'string') {\n let a = new Date(value);\n if (!isNaN(a.valueOf())) {\n return a;\n }\n }\n return value;\n }\n async _processResponse(res, options) {\n return new Promise(async (resolve, reject) => {\n const statusCode = res.message.statusCode;\n const response = {\n statusCode: statusCode,\n result: null,\n headers: {}\n };\n // not found leads to null obj returned\n if (statusCode == HttpCodes.NotFound) {\n resolve(response);\n }\n let obj;\n let contents;\n // get the result from the body\n try {\n contents = await res.readBody();\n if (contents && contents.length > 0) {\n if (options && options.deserializeDates) {\n obj = JSON.parse(contents, HttpClient.dateTimeDeserializer);\n }\n else {\n obj = JSON.parse(contents);\n }\n response.result = obj;\n }\n response.headers = res.message.headers;\n }\n catch (err) {\n // Invalid resource (contents not json); leaving result obj null\n }\n // note that 3xx redirects are handled by the http layer.\n if (statusCode > 299) {\n let msg;\n // if exception/error in body, attempt to get better error\n if (obj && obj.message) {\n msg = obj.message;\n }\n else if (contents && contents.length > 0) {\n // it may be the case that the exception is in the body message as string\n msg = contents;\n }\n else {\n msg = 'Failed request: (' + statusCode + ')';\n }\n let err = new HttpClientError(msg, statusCode);\n err.result = response.result;\n reject(err);\n }\n else {\n resolve(response);\n }\n });\n }\n}\nexports.HttpClient = HttpClient;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction getProxyUrl(reqUrl) {\n let usingSsl = reqUrl.protocol === 'https:';\n let proxyUrl;\n if (checkBypass(reqUrl)) {\n return proxyUrl;\n }\n let proxyVar;\n if (usingSsl) {\n proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];\n }\n else {\n proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];\n }\n if (proxyVar) {\n proxyUrl = new URL(proxyVar);\n }\n return proxyUrl;\n}\nexports.getProxyUrl = getProxyUrl;\nfunction checkBypass(reqUrl) {\n if (!reqUrl.hostname) {\n return false;\n }\n let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';\n if (!noProxy) {\n return false;\n }\n // Determine the request port\n let reqPort;\n if (reqUrl.port) {\n reqPort = Number(reqUrl.port);\n }\n else if (reqUrl.protocol === 'http:') {\n reqPort = 80;\n }\n else if (reqUrl.protocol === 'https:') {\n reqPort = 443;\n }\n // Format the request hostname and hostname with port\n let upperReqHosts = [reqUrl.hostname.toUpperCase()];\n if (typeof reqPort === 'number') {\n upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);\n }\n // Compare request host against noproxy\n for (let upperNoProxyItem of noProxy\n .split(',')\n .map(x => x.trim().toUpperCase())\n .filter(x => x)) {\n if (upperReqHosts.some(x => x === upperNoProxyItem)) {\n return true;\n }\n }\n return false;\n}\nexports.checkBypass = checkBypass;\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nasync function auth(token) {\n const tokenType = token.split(/\\./).length === 3 ? \"app\" : /^v\\d+\\./.test(token) ? \"installation\" : \"oauth\";\n return {\n type: \"token\",\n token: token,\n tokenType\n };\n}\n\n/**\n * Prefix token for usage in the Authorization header\n *\n * @param token OAuth token or JSON Web Token\n */\nfunction withAuthorizationPrefix(token) {\n if (token.split(/\\./).length === 3) {\n return `bearer ${token}`;\n }\n\n return `token ${token}`;\n}\n\nasync function hook(token, request, route, parameters) {\n const endpoint = request.endpoint.merge(route, parameters);\n endpoint.headers.authorization = withAuthorizationPrefix(token);\n return request(endpoint);\n}\n\nconst createTokenAuth = function createTokenAuth(token) {\n if (!token) {\n throw new Error(\"[@octokit/auth-token] No token passed to createTokenAuth\");\n }\n\n if (typeof token !== \"string\") {\n throw new Error(\"[@octokit/auth-token] Token passed to createTokenAuth is not a string\");\n }\n\n token = token.replace(/^(token|bearer) +/i, \"\");\n return Object.assign(auth.bind(null, token), {\n hook: hook.bind(null, token)\n });\n};\n\nexports.createTokenAuth = createTokenAuth;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar universalUserAgent = require('universal-user-agent');\nvar beforeAfterHook = require('before-after-hook');\nvar request = require('@octokit/request');\nvar graphql = require('@octokit/graphql');\nvar authToken = require('@octokit/auth-token');\n\nfunction _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n\n return target;\n}\n\nfunction _objectWithoutProperties(source, excluded) {\n if (source == null) return {};\n\n var target = _objectWithoutPropertiesLoose(source, excluded);\n\n var key, i;\n\n if (Object.getOwnPropertySymbols) {\n var sourceSymbolKeys = Object.getOwnPropertySymbols(source);\n\n for (i = 0; i < sourceSymbolKeys.length; i++) {\n key = sourceSymbolKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;\n target[key] = source[key];\n }\n }\n\n return target;\n}\n\nconst VERSION = \"3.4.0\";\n\nclass Octokit {\n constructor(options = {}) {\n const hook = new beforeAfterHook.Collection();\n const requestDefaults = {\n baseUrl: request.request.endpoint.DEFAULTS.baseUrl,\n headers: {},\n request: Object.assign({}, options.request, {\n // @ts-ignore internal usage only, no need to type\n hook: hook.bind(null, \"request\")\n }),\n mediaType: {\n previews: [],\n format: \"\"\n }\n }; // prepend default user agent with `options.userAgent` if set\n\n requestDefaults.headers[\"user-agent\"] = [options.userAgent, `octokit-core.js/${VERSION} ${universalUserAgent.getUserAgent()}`].filter(Boolean).join(\" \");\n\n if (options.baseUrl) {\n requestDefaults.baseUrl = options.baseUrl;\n }\n\n if (options.previews) {\n requestDefaults.mediaType.previews = options.previews;\n }\n\n if (options.timeZone) {\n requestDefaults.headers[\"time-zone\"] = options.timeZone;\n }\n\n this.request = request.request.defaults(requestDefaults);\n this.graphql = graphql.withCustomRequest(this.request).defaults(requestDefaults);\n this.log = Object.assign({\n debug: () => {},\n info: () => {},\n warn: console.warn.bind(console),\n error: console.error.bind(console)\n }, options.log);\n this.hook = hook; // (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance\n // is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered.\n // (2) If only `options.auth` is set, use the default token authentication strategy.\n // (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance.\n // TODO: type `options.auth` based on `options.authStrategy`.\n\n if (!options.authStrategy) {\n if (!options.auth) {\n // (1)\n this.auth = async () => ({\n type: \"unauthenticated\"\n });\n } else {\n // (2)\n const auth = authToken.createTokenAuth(options.auth); // @ts-ignore ¯\\_(ツ)_/¯\n\n hook.wrap(\"request\", auth.hook);\n this.auth = auth;\n }\n } else {\n const {\n authStrategy\n } = options,\n otherOptions = _objectWithoutProperties(options, [\"authStrategy\"]);\n\n const auth = authStrategy(Object.assign({\n request: this.request,\n log: this.log,\n // we pass the current octokit instance as well as its constructor options\n // to allow for authentication strategies that return a new octokit instance\n // that shares the same internal state as the current one. The original\n // requirement for this was the \"event-octokit\" authentication strategy\n // of https://github.com/probot/octokit-auth-probot.\n octokit: this,\n octokitOptions: otherOptions\n }, options.auth)); // @ts-ignore ¯\\_(ツ)_/¯\n\n hook.wrap(\"request\", auth.hook);\n this.auth = auth;\n } // apply plugins\n // https://stackoverflow.com/a/16345172\n\n\n const classConstructor = this.constructor;\n classConstructor.plugins.forEach(plugin => {\n Object.assign(this, plugin(this, options));\n });\n }\n\n static defaults(defaults) {\n const OctokitWithDefaults = class extends this {\n constructor(...args) {\n const options = args[0] || {};\n\n if (typeof defaults === \"function\") {\n super(defaults(options));\n return;\n }\n\n super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent ? {\n userAgent: `${options.userAgent} ${defaults.userAgent}`\n } : null));\n }\n\n };\n return OctokitWithDefaults;\n }\n /**\n * Attach a plugin (or many) to your Octokit instance.\n *\n * @example\n * const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)\n */\n\n\n static plugin(...newPlugins) {\n var _a;\n\n const currentPlugins = this.plugins;\n const NewOctokit = (_a = class extends this {}, _a.plugins = currentPlugins.concat(newPlugins.filter(plugin => !currentPlugins.includes(plugin))), _a);\n return NewOctokit;\n }\n\n}\nOctokit.VERSION = VERSION;\nOctokit.plugins = [];\n\nexports.Octokit = Octokit;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar isPlainObject = require('is-plain-object');\nvar universalUserAgent = require('universal-user-agent');\n\nfunction lowercaseKeys(object) {\n if (!object) {\n return {};\n }\n\n return Object.keys(object).reduce((newObj, key) => {\n newObj[key.toLowerCase()] = object[key];\n return newObj;\n }, {});\n}\n\nfunction mergeDeep(defaults, options) {\n const result = Object.assign({}, defaults);\n Object.keys(options).forEach(key => {\n if (isPlainObject.isPlainObject(options[key])) {\n if (!(key in defaults)) Object.assign(result, {\n [key]: options[key]\n });else result[key] = mergeDeep(defaults[key], options[key]);\n } else {\n Object.assign(result, {\n [key]: options[key]\n });\n }\n });\n return result;\n}\n\nfunction removeUndefinedProperties(obj) {\n for (const key in obj) {\n if (obj[key] === undefined) {\n delete obj[key];\n }\n }\n\n return obj;\n}\n\nfunction merge(defaults, route, options) {\n if (typeof route === \"string\") {\n let [method, url] = route.split(\" \");\n options = Object.assign(url ? {\n method,\n url\n } : {\n url: method\n }, options);\n } else {\n options = Object.assign({}, route);\n } // lowercase header names before merging with defaults to avoid duplicates\n\n\n options.headers = lowercaseKeys(options.headers); // remove properties with undefined values before merging\n\n removeUndefinedProperties(options);\n removeUndefinedProperties(options.headers);\n const mergedOptions = mergeDeep(defaults || {}, options); // mediaType.previews arrays are merged, instead of overwritten\n\n if (defaults && defaults.mediaType.previews.length) {\n mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(preview => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews);\n }\n\n mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map(preview => preview.replace(/-preview/, \"\"));\n return mergedOptions;\n}\n\nfunction addQueryParameters(url, parameters) {\n const separator = /\\?/.test(url) ? \"&\" : \"?\";\n const names = Object.keys(parameters);\n\n if (names.length === 0) {\n return url;\n }\n\n return url + separator + names.map(name => {\n if (name === \"q\") {\n return \"q=\" + parameters.q.split(\"+\").map(encodeURIComponent).join(\"+\");\n }\n\n return `${name}=${encodeURIComponent(parameters[name])}`;\n }).join(\"&\");\n}\n\nconst urlVariableRegex = /\\{[^}]+\\}/g;\n\nfunction removeNonChars(variableName) {\n return variableName.replace(/^\\W+|\\W+$/g, \"\").split(/,/);\n}\n\nfunction extractUrlVariableNames(url) {\n const matches = url.match(urlVariableRegex);\n\n if (!matches) {\n return [];\n }\n\n return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);\n}\n\nfunction omit(object, keysToOmit) {\n return Object.keys(object).filter(option => !keysToOmit.includes(option)).reduce((obj, key) => {\n obj[key] = object[key];\n return obj;\n }, {});\n}\n\n// Based on https://github.com/bramstein/url-template, licensed under BSD\n// TODO: create separate package.\n//\n// Copyright (c) 2012-2014, Bram Stein\n// All rights reserved.\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions\n// are met:\n// 1. Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n// 3. The name of the author may not be used to endorse or promote products\n// derived from this software without specific prior written permission.\n// THIS SOFTWARE IS PROVIDED BY THE AUTHOR \"AS IS\" AND ANY EXPRESS OR IMPLIED\n// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n/* istanbul ignore file */\nfunction encodeReserved(str) {\n return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) {\n if (!/%[0-9A-Fa-f]/.test(part)) {\n part = encodeURI(part).replace(/%5B/g, \"[\").replace(/%5D/g, \"]\");\n }\n\n return part;\n }).join(\"\");\n}\n\nfunction encodeUnreserved(str) {\n return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {\n return \"%\" + c.charCodeAt(0).toString(16).toUpperCase();\n });\n}\n\nfunction encodeValue(operator, value, key) {\n value = operator === \"+\" || operator === \"#\" ? encodeReserved(value) : encodeUnreserved(value);\n\n if (key) {\n return encodeUnreserved(key) + \"=\" + value;\n } else {\n return value;\n }\n}\n\nfunction isDefined(value) {\n return value !== undefined && value !== null;\n}\n\nfunction isKeyOperator(operator) {\n return operator === \";\" || operator === \"&\" || operator === \"?\";\n}\n\nfunction getValues(context, operator, key, modifier) {\n var value = context[key],\n result = [];\n\n if (isDefined(value) && value !== \"\") {\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n value = value.toString();\n\n if (modifier && modifier !== \"*\") {\n value = value.substring(0, parseInt(modifier, 10));\n }\n\n result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : \"\"));\n } else {\n if (modifier === \"*\") {\n if (Array.isArray(value)) {\n value.filter(isDefined).forEach(function (value) {\n result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : \"\"));\n });\n } else {\n Object.keys(value).forEach(function (k) {\n if (isDefined(value[k])) {\n result.push(encodeValue(operator, value[k], k));\n }\n });\n }\n } else {\n const tmp = [];\n\n if (Array.isArray(value)) {\n value.filter(isDefined).forEach(function (value) {\n tmp.push(encodeValue(operator, value));\n });\n } else {\n Object.keys(value).forEach(function (k) {\n if (isDefined(value[k])) {\n tmp.push(encodeUnreserved(k));\n tmp.push(encodeValue(operator, value[k].toString()));\n }\n });\n }\n\n if (isKeyOperator(operator)) {\n result.push(encodeUnreserved(key) + \"=\" + tmp.join(\",\"));\n } else if (tmp.length !== 0) {\n result.push(tmp.join(\",\"));\n }\n }\n }\n } else {\n if (operator === \";\") {\n if (isDefined(value)) {\n result.push(encodeUnreserved(key));\n }\n } else if (value === \"\" && (operator === \"&\" || operator === \"?\")) {\n result.push(encodeUnreserved(key) + \"=\");\n } else if (value === \"\") {\n result.push(\"\");\n }\n }\n\n return result;\n}\n\nfunction parseUrl(template) {\n return {\n expand: expand.bind(null, template)\n };\n}\n\nfunction expand(template, context) {\n var operators = [\"+\", \"#\", \".\", \"/\", \";\", \"?\", \"&\"];\n return template.replace(/\\{([^\\{\\}]+)\\}|([^\\{\\}]+)/g, function (_, expression, literal) {\n if (expression) {\n let operator = \"\";\n const values = [];\n\n if (operators.indexOf(expression.charAt(0)) !== -1) {\n operator = expression.charAt(0);\n expression = expression.substr(1);\n }\n\n expression.split(/,/g).forEach(function (variable) {\n var tmp = /([^:\\*]*)(?::(\\d+)|(\\*))?/.exec(variable);\n values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));\n });\n\n if (operator && operator !== \"+\") {\n var separator = \",\";\n\n if (operator === \"?\") {\n separator = \"&\";\n } else if (operator !== \"#\") {\n separator = operator;\n }\n\n return (values.length !== 0 ? operator : \"\") + values.join(separator);\n } else {\n return values.join(\",\");\n }\n } else {\n return encodeReserved(literal);\n }\n });\n}\n\nfunction parse(options) {\n // https://fetch.spec.whatwg.org/#methods\n let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible\n\n let url = (options.url || \"/\").replace(/:([a-z]\\w+)/g, \"{$1}\");\n let headers = Object.assign({}, options.headers);\n let body;\n let parameters = omit(options, [\"method\", \"baseUrl\", \"url\", \"headers\", \"request\", \"mediaType\"]); // extract variable names from URL to calculate remaining variables later\n\n const urlVariableNames = extractUrlVariableNames(url);\n url = parseUrl(url).expand(parameters);\n\n if (!/^http/.test(url)) {\n url = options.baseUrl + url;\n }\n\n const omittedParameters = Object.keys(options).filter(option => urlVariableNames.includes(option)).concat(\"baseUrl\");\n const remainingParameters = omit(parameters, omittedParameters);\n const isBinaryRequest = /application\\/octet-stream/i.test(headers.accept);\n\n if (!isBinaryRequest) {\n if (options.mediaType.format) {\n // e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw\n headers.accept = headers.accept.split(/,/).map(preview => preview.replace(/application\\/vnd(\\.\\w+)(\\.v3)?(\\.\\w+)?(\\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)).join(\",\");\n }\n\n if (options.mediaType.previews.length) {\n const previewsFromAcceptHeader = headers.accept.match(/[\\w-]+(?=-preview)/g) || [];\n headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map(preview => {\n const format = options.mediaType.format ? `.${options.mediaType.format}` : \"+json\";\n return `application/vnd.github.${preview}-preview${format}`;\n }).join(\",\");\n }\n } // for GET/HEAD requests, set URL query parameters from remaining parameters\n // for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters\n\n\n if ([\"GET\", \"HEAD\"].includes(method)) {\n url = addQueryParameters(url, remainingParameters);\n } else {\n if (\"data\" in remainingParameters) {\n body = remainingParameters.data;\n } else {\n if (Object.keys(remainingParameters).length) {\n body = remainingParameters;\n } else {\n headers[\"content-length\"] = 0;\n }\n }\n } // default content-type for JSON if body is set\n\n\n if (!headers[\"content-type\"] && typeof body !== \"undefined\") {\n headers[\"content-type\"] = \"application/json; charset=utf-8\";\n } // GitHub expects 'content-length: 0' header for PUT/PATCH requests without body.\n // fetch does not allow to set `content-length` header, but we can set body to an empty string\n\n\n if ([\"PATCH\", \"PUT\"].includes(method) && typeof body === \"undefined\") {\n body = \"\";\n } // Only return body/request keys if present\n\n\n return Object.assign({\n method,\n url,\n headers\n }, typeof body !== \"undefined\" ? {\n body\n } : null, options.request ? {\n request: options.request\n } : null);\n}\n\nfunction endpointWithDefaults(defaults, route, options) {\n return parse(merge(defaults, route, options));\n}\n\nfunction withDefaults(oldDefaults, newDefaults) {\n const DEFAULTS = merge(oldDefaults, newDefaults);\n const endpoint = endpointWithDefaults.bind(null, DEFAULTS);\n return Object.assign(endpoint, {\n DEFAULTS,\n defaults: withDefaults.bind(null, DEFAULTS),\n merge: merge.bind(null, DEFAULTS),\n parse\n });\n}\n\nconst VERSION = \"6.0.11\";\n\nconst userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}`; // DEFAULTS has all properties set that EndpointOptions has, except url.\n// So we use RequestParameters and add method as additional required property.\n\nconst DEFAULTS = {\n method: \"GET\",\n baseUrl: \"https://api.github.com\",\n headers: {\n accept: \"application/vnd.github.v3+json\",\n \"user-agent\": userAgent\n },\n mediaType: {\n format: \"\",\n previews: []\n }\n};\n\nconst endpoint = withDefaults(null, DEFAULTS);\n\nexports.endpoint = endpoint;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar request = require('@octokit/request');\nvar universalUserAgent = require('universal-user-agent');\n\nconst VERSION = \"4.6.2\";\n\nclass GraphqlError extends Error {\n constructor(request, response) {\n const message = response.data.errors[0].message;\n super(message);\n Object.assign(this, response.data);\n Object.assign(this, {\n headers: response.headers\n });\n this.name = \"GraphqlError\";\n this.request = request; // Maintains proper stack trace (only available on V8)\n\n /* istanbul ignore next */\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n\n}\n\nconst NON_VARIABLE_OPTIONS = [\"method\", \"baseUrl\", \"url\", \"headers\", \"request\", \"query\", \"mediaType\"];\nconst FORBIDDEN_VARIABLE_OPTIONS = [\"query\", \"method\", \"url\"];\nconst GHES_V3_SUFFIX_REGEX = /\\/api\\/v3\\/?$/;\nfunction graphql(request, query, options) {\n if (options) {\n if (typeof query === \"string\" && \"query\" in options) {\n return Promise.reject(new Error(`[@octokit/graphql] \"query\" cannot be used as variable name`));\n }\n\n for (const key in options) {\n if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) continue;\n return Promise.reject(new Error(`[@octokit/graphql] \"${key}\" cannot be used as variable name`));\n }\n }\n\n const parsedOptions = typeof query === \"string\" ? Object.assign({\n query\n }, options) : query;\n const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {\n if (NON_VARIABLE_OPTIONS.includes(key)) {\n result[key] = parsedOptions[key];\n return result;\n }\n\n if (!result.variables) {\n result.variables = {};\n }\n\n result.variables[key] = parsedOptions[key];\n return result;\n }, {}); // workaround for GitHub Enterprise baseUrl set with /api/v3 suffix\n // https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451\n\n const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;\n\n if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {\n requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, \"/api/graphql\");\n }\n\n return request(requestOptions).then(response => {\n if (response.data.errors) {\n const headers = {};\n\n for (const key of Object.keys(response.headers)) {\n headers[key] = response.headers[key];\n }\n\n throw new GraphqlError(requestOptions, {\n headers,\n data: response.data\n });\n }\n\n return response.data.data;\n });\n}\n\nfunction withDefaults(request$1, newDefaults) {\n const newRequest = request$1.defaults(newDefaults);\n\n const newApi = (query, options) => {\n return graphql(newRequest, query, options);\n };\n\n return Object.assign(newApi, {\n defaults: withDefaults.bind(null, newRequest),\n endpoint: request.request.endpoint\n });\n}\n\nconst graphql$1 = withDefaults(request.request, {\n headers: {\n \"user-agent\": `octokit-graphql.js/${VERSION} ${universalUserAgent.getUserAgent()}`\n },\n method: \"POST\",\n url: \"/graphql\"\n});\nfunction withCustomRequest(customRequest) {\n return withDefaults(customRequest, {\n method: \"POST\",\n url: \"/graphql\"\n });\n}\n\nexports.graphql = graphql$1;\nexports.withCustomRequest = withCustomRequest;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst VERSION = \"2.13.3\";\n\n/**\n * Some “list” response that can be paginated have a different response structure\n *\n * They have a `total_count` key in the response (search also has `incomplete_results`,\n * /installation/repositories also has `repository_selection`), as well as a key with\n * the list of the items which name varies from endpoint to endpoint.\n *\n * Octokit normalizes these responses so that paginated results are always returned following\n * the same structure. One challenge is that if the list response has only one page, no Link\n * header is provided, so this header alone is not sufficient to check wether a response is\n * paginated or not.\n *\n * We check if a \"total_count\" key is present in the response data, but also make sure that\n * a \"url\" property is not, as the \"Get the combined status for a specific ref\" endpoint would\n * otherwise match: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref\n */\nfunction normalizePaginatedListResponse(response) {\n const responseNeedsNormalization = \"total_count\" in response.data && !(\"url\" in response.data);\n if (!responseNeedsNormalization) return response; // keep the additional properties intact as there is currently no other way\n // to retrieve the same information.\n\n const incompleteResults = response.data.incomplete_results;\n const repositorySelection = response.data.repository_selection;\n const totalCount = response.data.total_count;\n delete response.data.incomplete_results;\n delete response.data.repository_selection;\n delete response.data.total_count;\n const namespaceKey = Object.keys(response.data)[0];\n const data = response.data[namespaceKey];\n response.data = data;\n\n if (typeof incompleteResults !== \"undefined\") {\n response.data.incomplete_results = incompleteResults;\n }\n\n if (typeof repositorySelection !== \"undefined\") {\n response.data.repository_selection = repositorySelection;\n }\n\n response.data.total_count = totalCount;\n return response;\n}\n\nfunction iterator(octokit, route, parameters) {\n const options = typeof route === \"function\" ? route.endpoint(parameters) : octokit.request.endpoint(route, parameters);\n const requestMethod = typeof route === \"function\" ? route : octokit.request;\n const method = options.method;\n const headers = options.headers;\n let url = options.url;\n return {\n [Symbol.asyncIterator]: () => ({\n async next() {\n if (!url) return {\n done: true\n };\n const response = await requestMethod({\n method,\n url,\n headers\n });\n const normalizedResponse = normalizePaginatedListResponse(response); // `response.headers.link` format:\n // '; rel=\"next\", ; rel=\"last\"'\n // sets `url` to undefined if \"next\" URL is not present or `link` header is not set\n\n url = ((normalizedResponse.headers.link || \"\").match(/<([^>]+)>;\\s*rel=\"next\"/) || [])[1];\n return {\n value: normalizedResponse\n };\n }\n\n })\n };\n}\n\nfunction paginate(octokit, route, parameters, mapFn) {\n if (typeof parameters === \"function\") {\n mapFn = parameters;\n parameters = undefined;\n }\n\n return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn);\n}\n\nfunction gather(octokit, results, iterator, mapFn) {\n return iterator.next().then(result => {\n if (result.done) {\n return results;\n }\n\n let earlyExit = false;\n\n function done() {\n earlyExit = true;\n }\n\n results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data);\n\n if (earlyExit) {\n return results;\n }\n\n return gather(octokit, results, iterator, mapFn);\n });\n}\n\nconst composePaginateRest = Object.assign(paginate, {\n iterator\n});\n\nconst paginatingEndpoints = [\"GET /app/installations\", \"GET /applications/grants\", \"GET /authorizations\", \"GET /enterprises/{enterprise}/actions/permissions/organizations\", \"GET /enterprises/{enterprise}/actions/runner-groups\", \"GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations\", \"GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners\", \"GET /enterprises/{enterprise}/actions/runners\", \"GET /enterprises/{enterprise}/actions/runners/downloads\", \"GET /events\", \"GET /gists\", \"GET /gists/public\", \"GET /gists/starred\", \"GET /gists/{gist_id}/comments\", \"GET /gists/{gist_id}/commits\", \"GET /gists/{gist_id}/forks\", \"GET /installation/repositories\", \"GET /issues\", \"GET /marketplace_listing/plans\", \"GET /marketplace_listing/plans/{plan_id}/accounts\", \"GET /marketplace_listing/stubbed/plans\", \"GET /marketplace_listing/stubbed/plans/{plan_id}/accounts\", \"GET /networks/{owner}/{repo}/events\", \"GET /notifications\", \"GET /organizations\", \"GET /orgs/{org}/actions/permissions/repositories\", \"GET /orgs/{org}/actions/runner-groups\", \"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories\", \"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/runners\", \"GET /orgs/{org}/actions/runners\", \"GET /orgs/{org}/actions/runners/downloads\", \"GET /orgs/{org}/actions/secrets\", \"GET /orgs/{org}/actions/secrets/{secret_name}/repositories\", \"GET /orgs/{org}/blocks\", \"GET /orgs/{org}/credential-authorizations\", \"GET /orgs/{org}/events\", \"GET /orgs/{org}/failed_invitations\", \"GET /orgs/{org}/hooks\", \"GET /orgs/{org}/installations\", \"GET /orgs/{org}/invitations\", \"GET /orgs/{org}/invitations/{invitation_id}/teams\", \"GET /orgs/{org}/issues\", \"GET /orgs/{org}/members\", \"GET /orgs/{org}/migrations\", \"GET /orgs/{org}/migrations/{migration_id}/repositories\", \"GET /orgs/{org}/outside_collaborators\", \"GET /orgs/{org}/projects\", \"GET /orgs/{org}/public_members\", \"GET /orgs/{org}/repos\", \"GET /orgs/{org}/team-sync/groups\", \"GET /orgs/{org}/teams\", \"GET /orgs/{org}/teams/{team_slug}/discussions\", \"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments\", \"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions\", \"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions\", \"GET /orgs/{org}/teams/{team_slug}/invitations\", \"GET /orgs/{org}/teams/{team_slug}/members\", \"GET /orgs/{org}/teams/{team_slug}/projects\", \"GET /orgs/{org}/teams/{team_slug}/repos\", \"GET /orgs/{org}/teams/{team_slug}/team-sync/group-mappings\", \"GET /orgs/{org}/teams/{team_slug}/teams\", \"GET /projects/columns/{column_id}/cards\", \"GET /projects/{project_id}/collaborators\", \"GET /projects/{project_id}/columns\", \"GET /repos/{owner}/{repo}/actions/artifacts\", \"GET /repos/{owner}/{repo}/actions/runners\", \"GET /repos/{owner}/{repo}/actions/runners/downloads\", \"GET /repos/{owner}/{repo}/actions/runs\", \"GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts\", \"GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs\", \"GET /repos/{owner}/{repo}/actions/secrets\", \"GET /repos/{owner}/{repo}/actions/workflows\", \"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs\", \"GET /repos/{owner}/{repo}/assignees\", \"GET /repos/{owner}/{repo}/branches\", \"GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations\", \"GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs\", \"GET /repos/{owner}/{repo}/code-scanning/alerts\", \"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances\", \"GET /repos/{owner}/{repo}/code-scanning/analyses\", \"GET /repos/{owner}/{repo}/collaborators\", \"GET /repos/{owner}/{repo}/comments\", \"GET /repos/{owner}/{repo}/comments/{comment_id}/reactions\", \"GET /repos/{owner}/{repo}/commits\", \"GET /repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head\", \"GET /repos/{owner}/{repo}/commits/{commit_sha}/comments\", \"GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls\", \"GET /repos/{owner}/{repo}/commits/{ref}/check-runs\", \"GET /repos/{owner}/{repo}/commits/{ref}/check-suites\", \"GET /repos/{owner}/{repo}/commits/{ref}/statuses\", \"GET /repos/{owner}/{repo}/contributors\", \"GET /repos/{owner}/{repo}/deployments\", \"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses\", \"GET /repos/{owner}/{repo}/events\", \"GET /repos/{owner}/{repo}/forks\", \"GET /repos/{owner}/{repo}/git/matching-refs/{ref}\", \"GET /repos/{owner}/{repo}/hooks\", \"GET /repos/{owner}/{repo}/invitations\", \"GET /repos/{owner}/{repo}/issues\", \"GET /repos/{owner}/{repo}/issues/comments\", \"GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions\", \"GET /repos/{owner}/{repo}/issues/events\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/comments\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/events\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/labels\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/reactions\", \"GET /repos/{owner}/{repo}/issues/{issue_number}/timeline\", \"GET /repos/{owner}/{repo}/keys\", \"GET /repos/{owner}/{repo}/labels\", \"GET /repos/{owner}/{repo}/milestones\", \"GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels\", \"GET /repos/{owner}/{repo}/notifications\", \"GET /repos/{owner}/{repo}/pages/builds\", \"GET /repos/{owner}/{repo}/projects\", \"GET /repos/{owner}/{repo}/pulls\", \"GET /repos/{owner}/{repo}/pulls/comments\", \"GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/comments\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/commits\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/files\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews\", \"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments\", \"GET /repos/{owner}/{repo}/releases\", \"GET /repos/{owner}/{repo}/releases/{release_id}/assets\", \"GET /repos/{owner}/{repo}/secret-scanning/alerts\", \"GET /repos/{owner}/{repo}/stargazers\", \"GET /repos/{owner}/{repo}/subscribers\", \"GET /repos/{owner}/{repo}/tags\", \"GET /repos/{owner}/{repo}/teams\", \"GET /repositories\", \"GET /repositories/{repository_id}/environments/{environment_name}/secrets\", \"GET /scim/v2/enterprises/{enterprise}/Groups\", \"GET /scim/v2/enterprises/{enterprise}/Users\", \"GET /scim/v2/organizations/{org}/Users\", \"GET /search/code\", \"GET /search/commits\", \"GET /search/issues\", \"GET /search/labels\", \"GET /search/repositories\", \"GET /search/topics\", \"GET /search/users\", \"GET /teams/{team_id}/discussions\", \"GET /teams/{team_id}/discussions/{discussion_number}/comments\", \"GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions\", \"GET /teams/{team_id}/discussions/{discussion_number}/reactions\", \"GET /teams/{team_id}/invitations\", \"GET /teams/{team_id}/members\", \"GET /teams/{team_id}/projects\", \"GET /teams/{team_id}/repos\", \"GET /teams/{team_id}/team-sync/group-mappings\", \"GET /teams/{team_id}/teams\", \"GET /user/blocks\", \"GET /user/emails\", \"GET /user/followers\", \"GET /user/following\", \"GET /user/gpg_keys\", \"GET /user/installations\", \"GET /user/installations/{installation_id}/repositories\", \"GET /user/issues\", \"GET /user/keys\", \"GET /user/marketplace_purchases\", \"GET /user/marketplace_purchases/stubbed\", \"GET /user/memberships/orgs\", \"GET /user/migrations\", \"GET /user/migrations/{migration_id}/repositories\", \"GET /user/orgs\", \"GET /user/public_emails\", \"GET /user/repos\", \"GET /user/repository_invitations\", \"GET /user/starred\", \"GET /user/subscriptions\", \"GET /user/teams\", \"GET /users\", \"GET /users/{username}/events\", \"GET /users/{username}/events/orgs/{org}\", \"GET /users/{username}/events/public\", \"GET /users/{username}/followers\", \"GET /users/{username}/following\", \"GET /users/{username}/gists\", \"GET /users/{username}/gpg_keys\", \"GET /users/{username}/keys\", \"GET /users/{username}/orgs\", \"GET /users/{username}/projects\", \"GET /users/{username}/received_events\", \"GET /users/{username}/received_events/public\", \"GET /users/{username}/repos\", \"GET /users/{username}/starred\", \"GET /users/{username}/subscriptions\"];\n\nfunction isPaginatingEndpoint(arg) {\n if (typeof arg === \"string\") {\n return paginatingEndpoints.includes(arg);\n } else {\n return false;\n }\n}\n\n/**\n * @param octokit Octokit instance\n * @param options Options passed to Octokit constructor\n */\n\nfunction paginateRest(octokit) {\n return {\n paginate: Object.assign(paginate.bind(null, octokit), {\n iterator: iterator.bind(null, octokit)\n })\n };\n}\npaginateRest.VERSION = VERSION;\n\nexports.composePaginateRest = composePaginateRest;\nexports.isPaginatingEndpoint = isPaginatingEndpoint;\nexports.paginateRest = paginateRest;\nexports.paginatingEndpoints = paginatingEndpoints;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction ownKeys(object, enumerableOnly) {\n var keys = Object.keys(object);\n\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(object);\n\n if (enumerableOnly) {\n symbols = symbols.filter(function (sym) {\n return Object.getOwnPropertyDescriptor(object, sym).enumerable;\n });\n }\n\n keys.push.apply(keys, symbols);\n }\n\n return keys;\n}\n\nfunction _objectSpread2(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n\n if (i % 2) {\n ownKeys(Object(source), true).forEach(function (key) {\n _defineProperty(target, key, source[key]);\n });\n } else if (Object.getOwnPropertyDescriptors) {\n Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));\n } else {\n ownKeys(Object(source)).forEach(function (key) {\n Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));\n });\n }\n }\n\n return target;\n}\n\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nconst Endpoints = {\n actions: {\n addSelectedRepoToOrgSecret: [\"PUT /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}\"],\n approveWorkflowRun: [\"POST /repos/{owner}/{repo}/actions/runs/{run_id}/approve\"],\n cancelWorkflowRun: [\"POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel\"],\n createOrUpdateEnvironmentSecret: [\"PUT /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}\"],\n createOrUpdateOrgSecret: [\"PUT /orgs/{org}/actions/secrets/{secret_name}\"],\n createOrUpdateRepoSecret: [\"PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}\"],\n createRegistrationTokenForOrg: [\"POST /orgs/{org}/actions/runners/registration-token\"],\n createRegistrationTokenForRepo: [\"POST /repos/{owner}/{repo}/actions/runners/registration-token\"],\n createRemoveTokenForOrg: [\"POST /orgs/{org}/actions/runners/remove-token\"],\n createRemoveTokenForRepo: [\"POST /repos/{owner}/{repo}/actions/runners/remove-token\"],\n createWorkflowDispatch: [\"POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches\"],\n deleteArtifact: [\"DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id}\"],\n deleteEnvironmentSecret: [\"DELETE /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}\"],\n deleteOrgSecret: [\"DELETE /orgs/{org}/actions/secrets/{secret_name}\"],\n deleteRepoSecret: [\"DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name}\"],\n deleteSelfHostedRunnerFromOrg: [\"DELETE /orgs/{org}/actions/runners/{runner_id}\"],\n deleteSelfHostedRunnerFromRepo: [\"DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}\"],\n deleteWorkflowRun: [\"DELETE /repos/{owner}/{repo}/actions/runs/{run_id}\"],\n deleteWorkflowRunLogs: [\"DELETE /repos/{owner}/{repo}/actions/runs/{run_id}/logs\"],\n disableSelectedRepositoryGithubActionsOrganization: [\"DELETE /orgs/{org}/actions/permissions/repositories/{repository_id}\"],\n disableWorkflow: [\"PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable\"],\n downloadArtifact: [\"GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}\"],\n downloadJobLogsForWorkflowRun: [\"GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs\"],\n downloadWorkflowRunLogs: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs\"],\n enableSelectedRepositoryGithubActionsOrganization: [\"PUT /orgs/{org}/actions/permissions/repositories/{repository_id}\"],\n enableWorkflow: [\"PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable\"],\n getAllowedActionsOrganization: [\"GET /orgs/{org}/actions/permissions/selected-actions\"],\n getAllowedActionsRepository: [\"GET /repos/{owner}/{repo}/actions/permissions/selected-actions\"],\n getArtifact: [\"GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}\"],\n getEnvironmentPublicKey: [\"GET /repositories/{repository_id}/environments/{environment_name}/secrets/public-key\"],\n getEnvironmentSecret: [\"GET /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}\"],\n getGithubActionsPermissionsOrganization: [\"GET /orgs/{org}/actions/permissions\"],\n getGithubActionsPermissionsRepository: [\"GET /repos/{owner}/{repo}/actions/permissions\"],\n getJobForWorkflowRun: [\"GET /repos/{owner}/{repo}/actions/jobs/{job_id}\"],\n getOrgPublicKey: [\"GET /orgs/{org}/actions/secrets/public-key\"],\n getOrgSecret: [\"GET /orgs/{org}/actions/secrets/{secret_name}\"],\n getPendingDeploymentsForRun: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments\"],\n getRepoPermissions: [\"GET /repos/{owner}/{repo}/actions/permissions\", {}, {\n renamed: [\"actions\", \"getGithubActionsPermissionsRepository\"]\n }],\n getRepoPublicKey: [\"GET /repos/{owner}/{repo}/actions/secrets/public-key\"],\n getRepoSecret: [\"GET /repos/{owner}/{repo}/actions/secrets/{secret_name}\"],\n getReviewsForRun: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/approvals\"],\n getSelfHostedRunnerForOrg: [\"GET /orgs/{org}/actions/runners/{runner_id}\"],\n getSelfHostedRunnerForRepo: [\"GET /repos/{owner}/{repo}/actions/runners/{runner_id}\"],\n getWorkflow: [\"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}\"],\n getWorkflowRun: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}\"],\n getWorkflowRunUsage: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing\"],\n getWorkflowUsage: [\"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing\"],\n listArtifactsForRepo: [\"GET /repos/{owner}/{repo}/actions/artifacts\"],\n listEnvironmentSecrets: [\"GET /repositories/{repository_id}/environments/{environment_name}/secrets\"],\n listJobsForWorkflowRun: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs\"],\n listOrgSecrets: [\"GET /orgs/{org}/actions/secrets\"],\n listRepoSecrets: [\"GET /repos/{owner}/{repo}/actions/secrets\"],\n listRepoWorkflows: [\"GET /repos/{owner}/{repo}/actions/workflows\"],\n listRunnerApplicationsForOrg: [\"GET /orgs/{org}/actions/runners/downloads\"],\n listRunnerApplicationsForRepo: [\"GET /repos/{owner}/{repo}/actions/runners/downloads\"],\n listSelectedReposForOrgSecret: [\"GET /orgs/{org}/actions/secrets/{secret_name}/repositories\"],\n listSelectedRepositoriesEnabledGithubActionsOrganization: [\"GET /orgs/{org}/actions/permissions/repositories\"],\n listSelfHostedRunnersForOrg: [\"GET /orgs/{org}/actions/runners\"],\n listSelfHostedRunnersForRepo: [\"GET /repos/{owner}/{repo}/actions/runners\"],\n listWorkflowRunArtifacts: [\"GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts\"],\n listWorkflowRuns: [\"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs\"],\n listWorkflowRunsForRepo: [\"GET /repos/{owner}/{repo}/actions/runs\"],\n reRunWorkflow: [\"POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun\"],\n removeSelectedRepoFromOrgSecret: [\"DELETE /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}\"],\n reviewPendingDeploymentsForRun: [\"POST /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments\"],\n setAllowedActionsOrganization: [\"PUT /orgs/{org}/actions/permissions/selected-actions\"],\n setAllowedActionsRepository: [\"PUT /repos/{owner}/{repo}/actions/permissions/selected-actions\"],\n setGithubActionsPermissionsOrganization: [\"PUT /orgs/{org}/actions/permissions\"],\n setGithubActionsPermissionsRepository: [\"PUT /repos/{owner}/{repo}/actions/permissions\"],\n setSelectedReposForOrgSecret: [\"PUT /orgs/{org}/actions/secrets/{secret_name}/repositories\"],\n setSelectedRepositoriesEnabledGithubActionsOrganization: [\"PUT /orgs/{org}/actions/permissions/repositories\"]\n },\n activity: {\n checkRepoIsStarredByAuthenticatedUser: [\"GET /user/starred/{owner}/{repo}\"],\n deleteRepoSubscription: [\"DELETE /repos/{owner}/{repo}/subscription\"],\n deleteThreadSubscription: [\"DELETE /notifications/threads/{thread_id}/subscription\"],\n getFeeds: [\"GET /feeds\"],\n getRepoSubscription: [\"GET /repos/{owner}/{repo}/subscription\"],\n getThread: [\"GET /notifications/threads/{thread_id}\"],\n getThreadSubscriptionForAuthenticatedUser: [\"GET /notifications/threads/{thread_id}/subscription\"],\n listEventsForAuthenticatedUser: [\"GET /users/{username}/events\"],\n listNotificationsForAuthenticatedUser: [\"GET /notifications\"],\n listOrgEventsForAuthenticatedUser: [\"GET /users/{username}/events/orgs/{org}\"],\n listPublicEvents: [\"GET /events\"],\n listPublicEventsForRepoNetwork: [\"GET /networks/{owner}/{repo}/events\"],\n listPublicEventsForUser: [\"GET /users/{username}/events/public\"],\n listPublicOrgEvents: [\"GET /orgs/{org}/events\"],\n listReceivedEventsForUser: [\"GET /users/{username}/received_events\"],\n listReceivedPublicEventsForUser: [\"GET /users/{username}/received_events/public\"],\n listRepoEvents: [\"GET /repos/{owner}/{repo}/events\"],\n listRepoNotificationsForAuthenticatedUser: [\"GET /repos/{owner}/{repo}/notifications\"],\n listReposStarredByAuthenticatedUser: [\"GET /user/starred\"],\n listReposStarredByUser: [\"GET /users/{username}/starred\"],\n listReposWatchedByUser: [\"GET /users/{username}/subscriptions\"],\n listStargazersForRepo: [\"GET /repos/{owner}/{repo}/stargazers\"],\n listWatchedReposForAuthenticatedUser: [\"GET /user/subscriptions\"],\n listWatchersForRepo: [\"GET /repos/{owner}/{repo}/subscribers\"],\n markNotificationsAsRead: [\"PUT /notifications\"],\n markRepoNotificationsAsRead: [\"PUT /repos/{owner}/{repo}/notifications\"],\n markThreadAsRead: [\"PATCH /notifications/threads/{thread_id}\"],\n setRepoSubscription: [\"PUT /repos/{owner}/{repo}/subscription\"],\n setThreadSubscription: [\"PUT /notifications/threads/{thread_id}/subscription\"],\n starRepoForAuthenticatedUser: [\"PUT /user/starred/{owner}/{repo}\"],\n unstarRepoForAuthenticatedUser: [\"DELETE /user/starred/{owner}/{repo}\"]\n },\n apps: {\n addRepoToInstallation: [\"PUT /user/installations/{installation_id}/repositories/{repository_id}\"],\n checkToken: [\"POST /applications/{client_id}/token\"],\n createContentAttachment: [\"POST /content_references/{content_reference_id}/attachments\", {\n mediaType: {\n previews: [\"corsair\"]\n }\n }],\n createContentAttachmentForRepo: [\"POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments\", {\n mediaType: {\n previews: [\"corsair\"]\n }\n }],\n createFromManifest: [\"POST /app-manifests/{code}/conversions\"],\n createInstallationAccessToken: [\"POST /app/installations/{installation_id}/access_tokens\"],\n deleteAuthorization: [\"DELETE /applications/{client_id}/grant\"],\n deleteInstallation: [\"DELETE /app/installations/{installation_id}\"],\n deleteToken: [\"DELETE /applications/{client_id}/token\"],\n getAuthenticated: [\"GET /app\"],\n getBySlug: [\"GET /apps/{app_slug}\"],\n getInstallation: [\"GET /app/installations/{installation_id}\"],\n getOrgInstallation: [\"GET /orgs/{org}/installation\"],\n getRepoInstallation: [\"GET /repos/{owner}/{repo}/installation\"],\n getSubscriptionPlanForAccount: [\"GET /marketplace_listing/accounts/{account_id}\"],\n getSubscriptionPlanForAccountStubbed: [\"GET /marketplace_listing/stubbed/accounts/{account_id}\"],\n getUserInstallation: [\"GET /users/{username}/installation\"],\n getWebhookConfigForApp: [\"GET /app/hook/config\"],\n listAccountsForPlan: [\"GET /marketplace_listing/plans/{plan_id}/accounts\"],\n listAccountsForPlanStubbed: [\"GET /marketplace_listing/stubbed/plans/{plan_id}/accounts\"],\n listInstallationReposForAuthenticatedUser: [\"GET /user/installations/{installation_id}/repositories\"],\n listInstallations: [\"GET /app/installations\"],\n listInstallationsForAuthenticatedUser: [\"GET /user/installations\"],\n listPlans: [\"GET /marketplace_listing/plans\"],\n listPlansStubbed: [\"GET /marketplace_listing/stubbed/plans\"],\n listReposAccessibleToInstallation: [\"GET /installation/repositories\"],\n listSubscriptionsForAuthenticatedUser: [\"GET /user/marketplace_purchases\"],\n listSubscriptionsForAuthenticatedUserStubbed: [\"GET /user/marketplace_purchases/stubbed\"],\n removeRepoFromInstallation: [\"DELETE /user/installations/{installation_id}/repositories/{repository_id}\"],\n resetToken: [\"PATCH /applications/{client_id}/token\"],\n revokeInstallationAccessToken: [\"DELETE /installation/token\"],\n scopeToken: [\"POST /applications/{client_id}/token/scoped\"],\n suspendInstallation: [\"PUT /app/installations/{installation_id}/suspended\"],\n unsuspendInstallation: [\"DELETE /app/installations/{installation_id}/suspended\"],\n updateWebhookConfigForApp: [\"PATCH /app/hook/config\"]\n },\n billing: {\n getGithubActionsBillingOrg: [\"GET /orgs/{org}/settings/billing/actions\"],\n getGithubActionsBillingUser: [\"GET /users/{username}/settings/billing/actions\"],\n getGithubPackagesBillingOrg: [\"GET /orgs/{org}/settings/billing/packages\"],\n getGithubPackagesBillingUser: [\"GET /users/{username}/settings/billing/packages\"],\n getSharedStorageBillingOrg: [\"GET /orgs/{org}/settings/billing/shared-storage\"],\n getSharedStorageBillingUser: [\"GET /users/{username}/settings/billing/shared-storage\"]\n },\n checks: {\n create: [\"POST /repos/{owner}/{repo}/check-runs\"],\n createSuite: [\"POST /repos/{owner}/{repo}/check-suites\"],\n get: [\"GET /repos/{owner}/{repo}/check-runs/{check_run_id}\"],\n getSuite: [\"GET /repos/{owner}/{repo}/check-suites/{check_suite_id}\"],\n listAnnotations: [\"GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations\"],\n listForRef: [\"GET /repos/{owner}/{repo}/commits/{ref}/check-runs\"],\n listForSuite: [\"GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs\"],\n listSuitesForRef: [\"GET /repos/{owner}/{repo}/commits/{ref}/check-suites\"],\n rerequestSuite: [\"POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest\"],\n setSuitesPreferences: [\"PATCH /repos/{owner}/{repo}/check-suites/preferences\"],\n update: [\"PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}\"]\n },\n codeScanning: {\n deleteAnalysis: [\"DELETE /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}{?confirm_delete}\"],\n getAlert: [\"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}\", {}, {\n renamedParameters: {\n alert_id: \"alert_number\"\n }\n }],\n getAnalysis: [\"GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}\"],\n getSarif: [\"GET /repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}\"],\n listAlertInstances: [\"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances\"],\n listAlertsForRepo: [\"GET /repos/{owner}/{repo}/code-scanning/alerts\"],\n listAlertsInstances: [\"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances\", {}, {\n renamed: [\"codeScanning\", \"listAlertInstances\"]\n }],\n listRecentAnalyses: [\"GET /repos/{owner}/{repo}/code-scanning/analyses\"],\n updateAlert: [\"PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}\"],\n uploadSarif: [\"POST /repos/{owner}/{repo}/code-scanning/sarifs\"]\n },\n codesOfConduct: {\n getAllCodesOfConduct: [\"GET /codes_of_conduct\", {\n mediaType: {\n previews: [\"scarlet-witch\"]\n }\n }],\n getConductCode: [\"GET /codes_of_conduct/{key}\", {\n mediaType: {\n previews: [\"scarlet-witch\"]\n }\n }],\n getForRepo: [\"GET /repos/{owner}/{repo}/community/code_of_conduct\", {\n mediaType: {\n previews: [\"scarlet-witch\"]\n }\n }]\n },\n emojis: {\n get: [\"GET /emojis\"]\n },\n enterpriseAdmin: {\n disableSelectedOrganizationGithubActionsEnterprise: [\"DELETE /enterprises/{enterprise}/actions/permissions/organizations/{org_id}\"],\n enableSelectedOrganizationGithubActionsEnterprise: [\"PUT /enterprises/{enterprise}/actions/permissions/organizations/{org_id}\"],\n getAllowedActionsEnterprise: [\"GET /enterprises/{enterprise}/actions/permissions/selected-actions\"],\n getGithubActionsPermissionsEnterprise: [\"GET /enterprises/{enterprise}/actions/permissions\"],\n listSelectedOrganizationsEnabledGithubActionsEnterprise: [\"GET /enterprises/{enterprise}/actions/permissions/organizations\"],\n setAllowedActionsEnterprise: [\"PUT /enterprises/{enterprise}/actions/permissions/selected-actions\"],\n setGithubActionsPermissionsEnterprise: [\"PUT /enterprises/{enterprise}/actions/permissions\"],\n setSelectedOrganizationsEnabledGithubActionsEnterprise: [\"PUT /enterprises/{enterprise}/actions/permissions/organizations\"]\n },\n gists: {\n checkIsStarred: [\"GET /gists/{gist_id}/star\"],\n create: [\"POST /gists\"],\n createComment: [\"POST /gists/{gist_id}/comments\"],\n delete: [\"DELETE /gists/{gist_id}\"],\n deleteComment: [\"DELETE /gists/{gist_id}/comments/{comment_id}\"],\n fork: [\"POST /gists/{gist_id}/forks\"],\n get: [\"GET /gists/{gist_id}\"],\n getComment: [\"GET /gists/{gist_id}/comments/{comment_id}\"],\n getRevision: [\"GET /gists/{gist_id}/{sha}\"],\n list: [\"GET /gists\"],\n listComments: [\"GET /gists/{gist_id}/comments\"],\n listCommits: [\"GET /gists/{gist_id}/commits\"],\n listForUser: [\"GET /users/{username}/gists\"],\n listForks: [\"GET /gists/{gist_id}/forks\"],\n listPublic: [\"GET /gists/public\"],\n listStarred: [\"GET /gists/starred\"],\n star: [\"PUT /gists/{gist_id}/star\"],\n unstar: [\"DELETE /gists/{gist_id}/star\"],\n update: [\"PATCH /gists/{gist_id}\"],\n updateComment: [\"PATCH /gists/{gist_id}/comments/{comment_id}\"]\n },\n git: {\n createBlob: [\"POST /repos/{owner}/{repo}/git/blobs\"],\n createCommit: [\"POST /repos/{owner}/{repo}/git/commits\"],\n createRef: [\"POST /repos/{owner}/{repo}/git/refs\"],\n createTag: [\"POST /repos/{owner}/{repo}/git/tags\"],\n createTree: [\"POST /repos/{owner}/{repo}/git/trees\"],\n deleteRef: [\"DELETE /repos/{owner}/{repo}/git/refs/{ref}\"],\n getBlob: [\"GET /repos/{owner}/{repo}/git/blobs/{file_sha}\"],\n getCommit: [\"GET /repos/{owner}/{repo}/git/commits/{commit_sha}\"],\n getRef: [\"GET /repos/{owner}/{repo}/git/ref/{ref}\"],\n getTag: [\"GET /repos/{owner}/{repo}/git/tags/{tag_sha}\"],\n getTree: [\"GET /repos/{owner}/{repo}/git/trees/{tree_sha}\"],\n listMatchingRefs: [\"GET /repos/{owner}/{repo}/git/matching-refs/{ref}\"],\n updateRef: [\"PATCH /repos/{owner}/{repo}/git/refs/{ref}\"]\n },\n gitignore: {\n getAllTemplates: [\"GET /gitignore/templates\"],\n getTemplate: [\"GET /gitignore/templates/{name}\"]\n },\n interactions: {\n getRestrictionsForAuthenticatedUser: [\"GET /user/interaction-limits\"],\n getRestrictionsForOrg: [\"GET /orgs/{org}/interaction-limits\"],\n getRestrictionsForRepo: [\"GET /repos/{owner}/{repo}/interaction-limits\"],\n getRestrictionsForYourPublicRepos: [\"GET /user/interaction-limits\", {}, {\n renamed: [\"interactions\", \"getRestrictionsForAuthenticatedUser\"]\n }],\n removeRestrictionsForAuthenticatedUser: [\"DELETE /user/interaction-limits\"],\n removeRestrictionsForOrg: [\"DELETE /orgs/{org}/interaction-limits\"],\n removeRestrictionsForRepo: [\"DELETE /repos/{owner}/{repo}/interaction-limits\"],\n removeRestrictionsForYourPublicRepos: [\"DELETE /user/interaction-limits\", {}, {\n renamed: [\"interactions\", \"removeRestrictionsForAuthenticatedUser\"]\n }],\n setRestrictionsForAuthenticatedUser: [\"PUT /user/interaction-limits\"],\n setRestrictionsForOrg: [\"PUT /orgs/{org}/interaction-limits\"],\n setRestrictionsForRepo: [\"PUT /repos/{owner}/{repo}/interaction-limits\"],\n setRestrictionsForYourPublicRepos: [\"PUT /user/interaction-limits\", {}, {\n renamed: [\"interactions\", \"setRestrictionsForAuthenticatedUser\"]\n }]\n },\n issues: {\n addAssignees: [\"POST /repos/{owner}/{repo}/issues/{issue_number}/assignees\"],\n addLabels: [\"POST /repos/{owner}/{repo}/issues/{issue_number}/labels\"],\n checkUserCanBeAssigned: [\"GET /repos/{owner}/{repo}/assignees/{assignee}\"],\n create: [\"POST /repos/{owner}/{repo}/issues\"],\n createComment: [\"POST /repos/{owner}/{repo}/issues/{issue_number}/comments\"],\n createLabel: [\"POST /repos/{owner}/{repo}/labels\"],\n createMilestone: [\"POST /repos/{owner}/{repo}/milestones\"],\n deleteComment: [\"DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}\"],\n deleteLabel: [\"DELETE /repos/{owner}/{repo}/labels/{name}\"],\n deleteMilestone: [\"DELETE /repos/{owner}/{repo}/milestones/{milestone_number}\"],\n get: [\"GET /repos/{owner}/{repo}/issues/{issue_number}\"],\n getComment: [\"GET /repos/{owner}/{repo}/issues/comments/{comment_id}\"],\n getEvent: [\"GET /repos/{owner}/{repo}/issues/events/{event_id}\"],\n getLabel: [\"GET /repos/{owner}/{repo}/labels/{name}\"],\n getMilestone: [\"GET /repos/{owner}/{repo}/milestones/{milestone_number}\"],\n list: [\"GET /issues\"],\n listAssignees: [\"GET /repos/{owner}/{repo}/assignees\"],\n listComments: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/comments\"],\n listCommentsForRepo: [\"GET /repos/{owner}/{repo}/issues/comments\"],\n listEvents: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/events\"],\n listEventsForRepo: [\"GET /repos/{owner}/{repo}/issues/events\"],\n listEventsForTimeline: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/timeline\", {\n mediaType: {\n previews: [\"mockingbird\"]\n }\n }],\n listForAuthenticatedUser: [\"GET /user/issues\"],\n listForOrg: [\"GET /orgs/{org}/issues\"],\n listForRepo: [\"GET /repos/{owner}/{repo}/issues\"],\n listLabelsForMilestone: [\"GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels\"],\n listLabelsForRepo: [\"GET /repos/{owner}/{repo}/labels\"],\n listLabelsOnIssue: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/labels\"],\n listMilestones: [\"GET /repos/{owner}/{repo}/milestones\"],\n lock: [\"PUT /repos/{owner}/{repo}/issues/{issue_number}/lock\"],\n removeAllLabels: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels\"],\n removeAssignees: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/assignees\"],\n removeLabel: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}\"],\n setLabels: [\"PUT /repos/{owner}/{repo}/issues/{issue_number}/labels\"],\n unlock: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock\"],\n update: [\"PATCH /repos/{owner}/{repo}/issues/{issue_number}\"],\n updateComment: [\"PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}\"],\n updateLabel: [\"PATCH /repos/{owner}/{repo}/labels/{name}\"],\n updateMilestone: [\"PATCH /repos/{owner}/{repo}/milestones/{milestone_number}\"]\n },\n licenses: {\n get: [\"GET /licenses/{license}\"],\n getAllCommonlyUsed: [\"GET /licenses\"],\n getForRepo: [\"GET /repos/{owner}/{repo}/license\"]\n },\n markdown: {\n render: [\"POST /markdown\"],\n renderRaw: [\"POST /markdown/raw\", {\n headers: {\n \"content-type\": \"text/plain; charset=utf-8\"\n }\n }]\n },\n meta: {\n get: [\"GET /meta\"],\n getOctocat: [\"GET /octocat\"],\n getZen: [\"GET /zen\"],\n root: [\"GET /\"]\n },\n migrations: {\n cancelImport: [\"DELETE /repos/{owner}/{repo}/import\"],\n deleteArchiveForAuthenticatedUser: [\"DELETE /user/migrations/{migration_id}/archive\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n deleteArchiveForOrg: [\"DELETE /orgs/{org}/migrations/{migration_id}/archive\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n downloadArchiveForOrg: [\"GET /orgs/{org}/migrations/{migration_id}/archive\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n getArchiveForAuthenticatedUser: [\"GET /user/migrations/{migration_id}/archive\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n getCommitAuthors: [\"GET /repos/{owner}/{repo}/import/authors\"],\n getImportStatus: [\"GET /repos/{owner}/{repo}/import\"],\n getLargeFiles: [\"GET /repos/{owner}/{repo}/import/large_files\"],\n getStatusForAuthenticatedUser: [\"GET /user/migrations/{migration_id}\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n getStatusForOrg: [\"GET /orgs/{org}/migrations/{migration_id}\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n listForAuthenticatedUser: [\"GET /user/migrations\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n listForOrg: [\"GET /orgs/{org}/migrations\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n listReposForOrg: [\"GET /orgs/{org}/migrations/{migration_id}/repositories\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n listReposForUser: [\"GET /user/migrations/{migration_id}/repositories\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n mapCommitAuthor: [\"PATCH /repos/{owner}/{repo}/import/authors/{author_id}\"],\n setLfsPreference: [\"PATCH /repos/{owner}/{repo}/import/lfs\"],\n startForAuthenticatedUser: [\"POST /user/migrations\"],\n startForOrg: [\"POST /orgs/{org}/migrations\"],\n startImport: [\"PUT /repos/{owner}/{repo}/import\"],\n unlockRepoForAuthenticatedUser: [\"DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n unlockRepoForOrg: [\"DELETE /orgs/{org}/migrations/{migration_id}/repos/{repo_name}/lock\", {\n mediaType: {\n previews: [\"wyandotte\"]\n }\n }],\n updateImport: [\"PATCH /repos/{owner}/{repo}/import\"]\n },\n orgs: {\n blockUser: [\"PUT /orgs/{org}/blocks/{username}\"],\n cancelInvitation: [\"DELETE /orgs/{org}/invitations/{invitation_id}\"],\n checkBlockedUser: [\"GET /orgs/{org}/blocks/{username}\"],\n checkMembershipForUser: [\"GET /orgs/{org}/members/{username}\"],\n checkPublicMembershipForUser: [\"GET /orgs/{org}/public_members/{username}\"],\n convertMemberToOutsideCollaborator: [\"PUT /orgs/{org}/outside_collaborators/{username}\"],\n createInvitation: [\"POST /orgs/{org}/invitations\"],\n createWebhook: [\"POST /orgs/{org}/hooks\"],\n deleteWebhook: [\"DELETE /orgs/{org}/hooks/{hook_id}\"],\n get: [\"GET /orgs/{org}\"],\n getMembershipForAuthenticatedUser: [\"GET /user/memberships/orgs/{org}\"],\n getMembershipForUser: [\"GET /orgs/{org}/memberships/{username}\"],\n getWebhook: [\"GET /orgs/{org}/hooks/{hook_id}\"],\n getWebhookConfigForOrg: [\"GET /orgs/{org}/hooks/{hook_id}/config\"],\n list: [\"GET /organizations\"],\n listAppInstallations: [\"GET /orgs/{org}/installations\"],\n listBlockedUsers: [\"GET /orgs/{org}/blocks\"],\n listFailedInvitations: [\"GET /orgs/{org}/failed_invitations\"],\n listForAuthenticatedUser: [\"GET /user/orgs\"],\n listForUser: [\"GET /users/{username}/orgs\"],\n listInvitationTeams: [\"GET /orgs/{org}/invitations/{invitation_id}/teams\"],\n listMembers: [\"GET /orgs/{org}/members\"],\n listMembershipsForAuthenticatedUser: [\"GET /user/memberships/orgs\"],\n listOutsideCollaborators: [\"GET /orgs/{org}/outside_collaborators\"],\n listPendingInvitations: [\"GET /orgs/{org}/invitations\"],\n listPublicMembers: [\"GET /orgs/{org}/public_members\"],\n listWebhooks: [\"GET /orgs/{org}/hooks\"],\n pingWebhook: [\"POST /orgs/{org}/hooks/{hook_id}/pings\"],\n removeMember: [\"DELETE /orgs/{org}/members/{username}\"],\n removeMembershipForUser: [\"DELETE /orgs/{org}/memberships/{username}\"],\n removeOutsideCollaborator: [\"DELETE /orgs/{org}/outside_collaborators/{username}\"],\n removePublicMembershipForAuthenticatedUser: [\"DELETE /orgs/{org}/public_members/{username}\"],\n setMembershipForUser: [\"PUT /orgs/{org}/memberships/{username}\"],\n setPublicMembershipForAuthenticatedUser: [\"PUT /orgs/{org}/public_members/{username}\"],\n unblockUser: [\"DELETE /orgs/{org}/blocks/{username}\"],\n update: [\"PATCH /orgs/{org}\"],\n updateMembershipForAuthenticatedUser: [\"PATCH /user/memberships/orgs/{org}\"],\n updateWebhook: [\"PATCH /orgs/{org}/hooks/{hook_id}\"],\n updateWebhookConfigForOrg: [\"PATCH /orgs/{org}/hooks/{hook_id}/config\"]\n },\n packages: {\n deletePackageForAuthenticatedUser: [\"DELETE /user/packages/{package_type}/{package_name}\"],\n deletePackageForOrg: [\"DELETE /orgs/{org}/packages/{package_type}/{package_name}\"],\n deletePackageVersionForAuthenticatedUser: [\"DELETE /user/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n deletePackageVersionForOrg: [\"DELETE /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n getAllPackageVersionsForAPackageOwnedByAnOrg: [\"GET /orgs/{org}/packages/{package_type}/{package_name}/versions\", {}, {\n renamed: [\"packages\", \"getAllPackageVersionsForPackageOwnedByOrg\"]\n }],\n getAllPackageVersionsForAPackageOwnedByTheAuthenticatedUser: [\"GET /user/packages/{package_type}/{package_name}/versions\", {}, {\n renamed: [\"packages\", \"getAllPackageVersionsForPackageOwnedByAuthenticatedUser\"]\n }],\n getAllPackageVersionsForPackageOwnedByAuthenticatedUser: [\"GET /user/packages/{package_type}/{package_name}/versions\"],\n getAllPackageVersionsForPackageOwnedByOrg: [\"GET /orgs/{org}/packages/{package_type}/{package_name}/versions\"],\n getAllPackageVersionsForPackageOwnedByUser: [\"GET /users/{username}/packages/{package_type}/{package_name}/versions\"],\n getPackageForAuthenticatedUser: [\"GET /user/packages/{package_type}/{package_name}\"],\n getPackageForOrganization: [\"GET /orgs/{org}/packages/{package_type}/{package_name}\"],\n getPackageForUser: [\"GET /users/{username}/packages/{package_type}/{package_name}\"],\n getPackageVersionForAuthenticatedUser: [\"GET /user/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n getPackageVersionForOrganization: [\"GET /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n getPackageVersionForUser: [\"GET /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}\"],\n restorePackageForAuthenticatedUser: [\"POST /user/packages/{package_type}/{package_name}/restore{?token}\"],\n restorePackageForOrg: [\"POST /orgs/{org}/packages/{package_type}/{package_name}/restore{?token}\"],\n restorePackageVersionForAuthenticatedUser: [\"POST /user/packages/{package_type}/{package_name}/versions/{package_version_id}/restore\"],\n restorePackageVersionForOrg: [\"POST /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore\"]\n },\n projects: {\n addCollaborator: [\"PUT /projects/{project_id}/collaborators/{username}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createCard: [\"POST /projects/columns/{column_id}/cards\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createColumn: [\"POST /projects/{project_id}/columns\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createForAuthenticatedUser: [\"POST /user/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createForOrg: [\"POST /orgs/{org}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n createForRepo: [\"POST /repos/{owner}/{repo}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n delete: [\"DELETE /projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n deleteCard: [\"DELETE /projects/columns/cards/{card_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n deleteColumn: [\"DELETE /projects/columns/{column_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n get: [\"GET /projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n getCard: [\"GET /projects/columns/cards/{card_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n getColumn: [\"GET /projects/columns/{column_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n getPermissionForUser: [\"GET /projects/{project_id}/collaborators/{username}/permission\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listCards: [\"GET /projects/columns/{column_id}/cards\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listCollaborators: [\"GET /projects/{project_id}/collaborators\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listColumns: [\"GET /projects/{project_id}/columns\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listForOrg: [\"GET /orgs/{org}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listForRepo: [\"GET /repos/{owner}/{repo}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listForUser: [\"GET /users/{username}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n moveCard: [\"POST /projects/columns/cards/{card_id}/moves\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n moveColumn: [\"POST /projects/columns/{column_id}/moves\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n removeCollaborator: [\"DELETE /projects/{project_id}/collaborators/{username}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n update: [\"PATCH /projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n updateCard: [\"PATCH /projects/columns/cards/{card_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n updateColumn: [\"PATCH /projects/columns/{column_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }]\n },\n pulls: {\n checkIfMerged: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/merge\"],\n create: [\"POST /repos/{owner}/{repo}/pulls\"],\n createReplyForReviewComment: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies\"],\n createReview: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews\"],\n createReviewComment: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/comments\"],\n deletePendingReview: [\"DELETE /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}\"],\n deleteReviewComment: [\"DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}\"],\n dismissReview: [\"PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals\"],\n get: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}\"],\n getReview: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}\"],\n getReviewComment: [\"GET /repos/{owner}/{repo}/pulls/comments/{comment_id}\"],\n list: [\"GET /repos/{owner}/{repo}/pulls\"],\n listCommentsForReview: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments\"],\n listCommits: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/commits\"],\n listFiles: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/files\"],\n listRequestedReviewers: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers\"],\n listReviewComments: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/comments\"],\n listReviewCommentsForRepo: [\"GET /repos/{owner}/{repo}/pulls/comments\"],\n listReviews: [\"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews\"],\n merge: [\"PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge\"],\n removeRequestedReviewers: [\"DELETE /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers\"],\n requestReviewers: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers\"],\n submitReview: [\"POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events\"],\n update: [\"PATCH /repos/{owner}/{repo}/pulls/{pull_number}\"],\n updateBranch: [\"PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch\", {\n mediaType: {\n previews: [\"lydian\"]\n }\n }],\n updateReview: [\"PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}\"],\n updateReviewComment: [\"PATCH /repos/{owner}/{repo}/pulls/comments/{comment_id}\"]\n },\n rateLimit: {\n get: [\"GET /rate_limit\"]\n },\n reactions: {\n createForCommitComment: [\"POST /repos/{owner}/{repo}/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForIssue: [\"POST /repos/{owner}/{repo}/issues/{issue_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForIssueComment: [\"POST /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForPullRequestReviewComment: [\"POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForRelease: [\"POST /repos/{owner}/{repo}/releases/{release_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForTeamDiscussionCommentInOrg: [\"POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n createForTeamDiscussionInOrg: [\"POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForCommitComment: [\"DELETE /repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForIssue: [\"DELETE /repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForIssueComment: [\"DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForPullRequestComment: [\"DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForTeamDiscussion: [\"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteForTeamDiscussionComment: [\"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n deleteLegacy: [\"DELETE /reactions/{reaction_id}\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }, {\n deprecated: \"octokit.rest.reactions.deleteLegacy() is deprecated, see https://docs.github.com/rest/reference/reactions/#delete-a-reaction-legacy\"\n }],\n listForCommitComment: [\"GET /repos/{owner}/{repo}/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForIssue: [\"GET /repos/{owner}/{repo}/issues/{issue_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForIssueComment: [\"GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForPullRequestReviewComment: [\"GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForTeamDiscussionCommentInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }],\n listForTeamDiscussionInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions\", {\n mediaType: {\n previews: [\"squirrel-girl\"]\n }\n }]\n },\n repos: {\n acceptInvitation: [\"PATCH /user/repository_invitations/{invitation_id}\"],\n addAppAccessRestrictions: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps\", {}, {\n mapToData: \"apps\"\n }],\n addCollaborator: [\"PUT /repos/{owner}/{repo}/collaborators/{username}\"],\n addStatusCheckContexts: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts\", {}, {\n mapToData: \"contexts\"\n }],\n addTeamAccessRestrictions: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams\", {}, {\n mapToData: \"teams\"\n }],\n addUserAccessRestrictions: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users\", {}, {\n mapToData: \"users\"\n }],\n checkCollaborator: [\"GET /repos/{owner}/{repo}/collaborators/{username}\"],\n checkVulnerabilityAlerts: [\"GET /repos/{owner}/{repo}/vulnerability-alerts\", {\n mediaType: {\n previews: [\"dorian\"]\n }\n }],\n compareCommits: [\"GET /repos/{owner}/{repo}/compare/{base}...{head}\"],\n compareCommitsWithBasehead: [\"GET /repos/{owner}/{repo}/compare/{basehead}\"],\n createCommitComment: [\"POST /repos/{owner}/{repo}/commits/{commit_sha}/comments\"],\n createCommitSignatureProtection: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures\", {\n mediaType: {\n previews: [\"zzzax\"]\n }\n }],\n createCommitStatus: [\"POST /repos/{owner}/{repo}/statuses/{sha}\"],\n createDeployKey: [\"POST /repos/{owner}/{repo}/keys\"],\n createDeployment: [\"POST /repos/{owner}/{repo}/deployments\"],\n createDeploymentStatus: [\"POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses\"],\n createDispatchEvent: [\"POST /repos/{owner}/{repo}/dispatches\"],\n createForAuthenticatedUser: [\"POST /user/repos\"],\n createFork: [\"POST /repos/{owner}/{repo}/forks\"],\n createInOrg: [\"POST /orgs/{org}/repos\"],\n createOrUpdateEnvironment: [\"PUT /repos/{owner}/{repo}/environments/{environment_name}\"],\n createOrUpdateFileContents: [\"PUT /repos/{owner}/{repo}/contents/{path}\"],\n createPagesSite: [\"POST /repos/{owner}/{repo}/pages\", {\n mediaType: {\n previews: [\"switcheroo\"]\n }\n }],\n createRelease: [\"POST /repos/{owner}/{repo}/releases\"],\n createUsingTemplate: [\"POST /repos/{template_owner}/{template_repo}/generate\", {\n mediaType: {\n previews: [\"baptiste\"]\n }\n }],\n createWebhook: [\"POST /repos/{owner}/{repo}/hooks\"],\n declineInvitation: [\"DELETE /user/repository_invitations/{invitation_id}\"],\n delete: [\"DELETE /repos/{owner}/{repo}\"],\n deleteAccessRestrictions: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions\"],\n deleteAdminBranchProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins\"],\n deleteAnEnvironment: [\"DELETE /repos/{owner}/{repo}/environments/{environment_name}\"],\n deleteBranchProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection\"],\n deleteCommitComment: [\"DELETE /repos/{owner}/{repo}/comments/{comment_id}\"],\n deleteCommitSignatureProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures\", {\n mediaType: {\n previews: [\"zzzax\"]\n }\n }],\n deleteDeployKey: [\"DELETE /repos/{owner}/{repo}/keys/{key_id}\"],\n deleteDeployment: [\"DELETE /repos/{owner}/{repo}/deployments/{deployment_id}\"],\n deleteFile: [\"DELETE /repos/{owner}/{repo}/contents/{path}\"],\n deleteInvitation: [\"DELETE /repos/{owner}/{repo}/invitations/{invitation_id}\"],\n deletePagesSite: [\"DELETE /repos/{owner}/{repo}/pages\", {\n mediaType: {\n previews: [\"switcheroo\"]\n }\n }],\n deletePullRequestReviewProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews\"],\n deleteRelease: [\"DELETE /repos/{owner}/{repo}/releases/{release_id}\"],\n deleteReleaseAsset: [\"DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}\"],\n deleteWebhook: [\"DELETE /repos/{owner}/{repo}/hooks/{hook_id}\"],\n disableAutomatedSecurityFixes: [\"DELETE /repos/{owner}/{repo}/automated-security-fixes\", {\n mediaType: {\n previews: [\"london\"]\n }\n }],\n disableVulnerabilityAlerts: [\"DELETE /repos/{owner}/{repo}/vulnerability-alerts\", {\n mediaType: {\n previews: [\"dorian\"]\n }\n }],\n downloadArchive: [\"GET /repos/{owner}/{repo}/zipball/{ref}\", {}, {\n renamed: [\"repos\", \"downloadZipballArchive\"]\n }],\n downloadTarballArchive: [\"GET /repos/{owner}/{repo}/tarball/{ref}\"],\n downloadZipballArchive: [\"GET /repos/{owner}/{repo}/zipball/{ref}\"],\n enableAutomatedSecurityFixes: [\"PUT /repos/{owner}/{repo}/automated-security-fixes\", {\n mediaType: {\n previews: [\"london\"]\n }\n }],\n enableVulnerabilityAlerts: [\"PUT /repos/{owner}/{repo}/vulnerability-alerts\", {\n mediaType: {\n previews: [\"dorian\"]\n }\n }],\n get: [\"GET /repos/{owner}/{repo}\"],\n getAccessRestrictions: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions\"],\n getAdminBranchProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins\"],\n getAllEnvironments: [\"GET /repos/{owner}/{repo}/environments\"],\n getAllStatusCheckContexts: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts\"],\n getAllTopics: [\"GET /repos/{owner}/{repo}/topics\", {\n mediaType: {\n previews: [\"mercy\"]\n }\n }],\n getAppsWithAccessToProtectedBranch: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps\"],\n getBranch: [\"GET /repos/{owner}/{repo}/branches/{branch}\"],\n getBranchProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection\"],\n getClones: [\"GET /repos/{owner}/{repo}/traffic/clones\"],\n getCodeFrequencyStats: [\"GET /repos/{owner}/{repo}/stats/code_frequency\"],\n getCollaboratorPermissionLevel: [\"GET /repos/{owner}/{repo}/collaborators/{username}/permission\"],\n getCombinedStatusForRef: [\"GET /repos/{owner}/{repo}/commits/{ref}/status\"],\n getCommit: [\"GET /repos/{owner}/{repo}/commits/{ref}\"],\n getCommitActivityStats: [\"GET /repos/{owner}/{repo}/stats/commit_activity\"],\n getCommitComment: [\"GET /repos/{owner}/{repo}/comments/{comment_id}\"],\n getCommitSignatureProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures\", {\n mediaType: {\n previews: [\"zzzax\"]\n }\n }],\n getCommunityProfileMetrics: [\"GET /repos/{owner}/{repo}/community/profile\"],\n getContent: [\"GET /repos/{owner}/{repo}/contents/{path}\"],\n getContributorsStats: [\"GET /repos/{owner}/{repo}/stats/contributors\"],\n getDeployKey: [\"GET /repos/{owner}/{repo}/keys/{key_id}\"],\n getDeployment: [\"GET /repos/{owner}/{repo}/deployments/{deployment_id}\"],\n getDeploymentStatus: [\"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}\"],\n getEnvironment: [\"GET /repos/{owner}/{repo}/environments/{environment_name}\"],\n getLatestPagesBuild: [\"GET /repos/{owner}/{repo}/pages/builds/latest\"],\n getLatestRelease: [\"GET /repos/{owner}/{repo}/releases/latest\"],\n getPages: [\"GET /repos/{owner}/{repo}/pages\"],\n getPagesBuild: [\"GET /repos/{owner}/{repo}/pages/builds/{build_id}\"],\n getPagesHealthCheck: [\"GET /repos/{owner}/{repo}/pages/health\"],\n getParticipationStats: [\"GET /repos/{owner}/{repo}/stats/participation\"],\n getPullRequestReviewProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews\"],\n getPunchCardStats: [\"GET /repos/{owner}/{repo}/stats/punch_card\"],\n getReadme: [\"GET /repos/{owner}/{repo}/readme\"],\n getReadmeInDirectory: [\"GET /repos/{owner}/{repo}/readme/{dir}\"],\n getRelease: [\"GET /repos/{owner}/{repo}/releases/{release_id}\"],\n getReleaseAsset: [\"GET /repos/{owner}/{repo}/releases/assets/{asset_id}\"],\n getReleaseByTag: [\"GET /repos/{owner}/{repo}/releases/tags/{tag}\"],\n getStatusChecksProtection: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks\"],\n getTeamsWithAccessToProtectedBranch: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams\"],\n getTopPaths: [\"GET /repos/{owner}/{repo}/traffic/popular/paths\"],\n getTopReferrers: [\"GET /repos/{owner}/{repo}/traffic/popular/referrers\"],\n getUsersWithAccessToProtectedBranch: [\"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users\"],\n getViews: [\"GET /repos/{owner}/{repo}/traffic/views\"],\n getWebhook: [\"GET /repos/{owner}/{repo}/hooks/{hook_id}\"],\n getWebhookConfigForRepo: [\"GET /repos/{owner}/{repo}/hooks/{hook_id}/config\"],\n listBranches: [\"GET /repos/{owner}/{repo}/branches\"],\n listBranchesForHeadCommit: [\"GET /repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head\", {\n mediaType: {\n previews: [\"groot\"]\n }\n }],\n listCollaborators: [\"GET /repos/{owner}/{repo}/collaborators\"],\n listCommentsForCommit: [\"GET /repos/{owner}/{repo}/commits/{commit_sha}/comments\"],\n listCommitCommentsForRepo: [\"GET /repos/{owner}/{repo}/comments\"],\n listCommitStatusesForRef: [\"GET /repos/{owner}/{repo}/commits/{ref}/statuses\"],\n listCommits: [\"GET /repos/{owner}/{repo}/commits\"],\n listContributors: [\"GET /repos/{owner}/{repo}/contributors\"],\n listDeployKeys: [\"GET /repos/{owner}/{repo}/keys\"],\n listDeploymentStatuses: [\"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses\"],\n listDeployments: [\"GET /repos/{owner}/{repo}/deployments\"],\n listForAuthenticatedUser: [\"GET /user/repos\"],\n listForOrg: [\"GET /orgs/{org}/repos\"],\n listForUser: [\"GET /users/{username}/repos\"],\n listForks: [\"GET /repos/{owner}/{repo}/forks\"],\n listInvitations: [\"GET /repos/{owner}/{repo}/invitations\"],\n listInvitationsForAuthenticatedUser: [\"GET /user/repository_invitations\"],\n listLanguages: [\"GET /repos/{owner}/{repo}/languages\"],\n listPagesBuilds: [\"GET /repos/{owner}/{repo}/pages/builds\"],\n listPublic: [\"GET /repositories\"],\n listPullRequestsAssociatedWithCommit: [\"GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls\", {\n mediaType: {\n previews: [\"groot\"]\n }\n }],\n listReleaseAssets: [\"GET /repos/{owner}/{repo}/releases/{release_id}/assets\"],\n listReleases: [\"GET /repos/{owner}/{repo}/releases\"],\n listTags: [\"GET /repos/{owner}/{repo}/tags\"],\n listTeams: [\"GET /repos/{owner}/{repo}/teams\"],\n listWebhooks: [\"GET /repos/{owner}/{repo}/hooks\"],\n merge: [\"POST /repos/{owner}/{repo}/merges\"],\n pingWebhook: [\"POST /repos/{owner}/{repo}/hooks/{hook_id}/pings\"],\n removeAppAccessRestrictions: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps\", {}, {\n mapToData: \"apps\"\n }],\n removeCollaborator: [\"DELETE /repos/{owner}/{repo}/collaborators/{username}\"],\n removeStatusCheckContexts: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts\", {}, {\n mapToData: \"contexts\"\n }],\n removeStatusCheckProtection: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks\"],\n removeTeamAccessRestrictions: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams\", {}, {\n mapToData: \"teams\"\n }],\n removeUserAccessRestrictions: [\"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users\", {}, {\n mapToData: \"users\"\n }],\n renameBranch: [\"POST /repos/{owner}/{repo}/branches/{branch}/rename\"],\n replaceAllTopics: [\"PUT /repos/{owner}/{repo}/topics\", {\n mediaType: {\n previews: [\"mercy\"]\n }\n }],\n requestPagesBuild: [\"POST /repos/{owner}/{repo}/pages/builds\"],\n setAdminBranchProtection: [\"POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins\"],\n setAppAccessRestrictions: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps\", {}, {\n mapToData: \"apps\"\n }],\n setStatusCheckContexts: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts\", {}, {\n mapToData: \"contexts\"\n }],\n setTeamAccessRestrictions: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams\", {}, {\n mapToData: \"teams\"\n }],\n setUserAccessRestrictions: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users\", {}, {\n mapToData: \"users\"\n }],\n testPushWebhook: [\"POST /repos/{owner}/{repo}/hooks/{hook_id}/tests\"],\n transfer: [\"POST /repos/{owner}/{repo}/transfer\"],\n update: [\"PATCH /repos/{owner}/{repo}\"],\n updateBranchProtection: [\"PUT /repos/{owner}/{repo}/branches/{branch}/protection\"],\n updateCommitComment: [\"PATCH /repos/{owner}/{repo}/comments/{comment_id}\"],\n updateInformationAboutPagesSite: [\"PUT /repos/{owner}/{repo}/pages\"],\n updateInvitation: [\"PATCH /repos/{owner}/{repo}/invitations/{invitation_id}\"],\n updatePullRequestReviewProtection: [\"PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews\"],\n updateRelease: [\"PATCH /repos/{owner}/{repo}/releases/{release_id}\"],\n updateReleaseAsset: [\"PATCH /repos/{owner}/{repo}/releases/assets/{asset_id}\"],\n updateStatusCheckPotection: [\"PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks\", {}, {\n renamed: [\"repos\", \"updateStatusCheckProtection\"]\n }],\n updateStatusCheckProtection: [\"PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks\"],\n updateWebhook: [\"PATCH /repos/{owner}/{repo}/hooks/{hook_id}\"],\n updateWebhookConfigForRepo: [\"PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config\"],\n uploadReleaseAsset: [\"POST /repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}\", {\n baseUrl: \"https://uploads.github.com\"\n }]\n },\n search: {\n code: [\"GET /search/code\"],\n commits: [\"GET /search/commits\", {\n mediaType: {\n previews: [\"cloak\"]\n }\n }],\n issuesAndPullRequests: [\"GET /search/issues\"],\n labels: [\"GET /search/labels\"],\n repos: [\"GET /search/repositories\"],\n topics: [\"GET /search/topics\", {\n mediaType: {\n previews: [\"mercy\"]\n }\n }],\n users: [\"GET /search/users\"]\n },\n secretScanning: {\n getAlert: [\"GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}\"],\n listAlertsForRepo: [\"GET /repos/{owner}/{repo}/secret-scanning/alerts\"],\n updateAlert: [\"PATCH /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}\"]\n },\n teams: {\n addOrUpdateMembershipForUserInOrg: [\"PUT /orgs/{org}/teams/{team_slug}/memberships/{username}\"],\n addOrUpdateProjectPermissionsInOrg: [\"PUT /orgs/{org}/teams/{team_slug}/projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n addOrUpdateRepoPermissionsInOrg: [\"PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}\"],\n checkPermissionsForProjectInOrg: [\"GET /orgs/{org}/teams/{team_slug}/projects/{project_id}\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n checkPermissionsForRepoInOrg: [\"GET /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}\"],\n create: [\"POST /orgs/{org}/teams\"],\n createDiscussionCommentInOrg: [\"POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments\"],\n createDiscussionInOrg: [\"POST /orgs/{org}/teams/{team_slug}/discussions\"],\n deleteDiscussionCommentInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}\"],\n deleteDiscussionInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}\"],\n deleteInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}\"],\n getByName: [\"GET /orgs/{org}/teams/{team_slug}\"],\n getDiscussionCommentInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}\"],\n getDiscussionInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}\"],\n getMembershipForUserInOrg: [\"GET /orgs/{org}/teams/{team_slug}/memberships/{username}\"],\n list: [\"GET /orgs/{org}/teams\"],\n listChildInOrg: [\"GET /orgs/{org}/teams/{team_slug}/teams\"],\n listDiscussionCommentsInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments\"],\n listDiscussionsInOrg: [\"GET /orgs/{org}/teams/{team_slug}/discussions\"],\n listForAuthenticatedUser: [\"GET /user/teams\"],\n listMembersInOrg: [\"GET /orgs/{org}/teams/{team_slug}/members\"],\n listPendingInvitationsInOrg: [\"GET /orgs/{org}/teams/{team_slug}/invitations\"],\n listProjectsInOrg: [\"GET /orgs/{org}/teams/{team_slug}/projects\", {\n mediaType: {\n previews: [\"inertia\"]\n }\n }],\n listReposInOrg: [\"GET /orgs/{org}/teams/{team_slug}/repos\"],\n removeMembershipForUserInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/memberships/{username}\"],\n removeProjectInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/projects/{project_id}\"],\n removeRepoInOrg: [\"DELETE /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}\"],\n updateDiscussionCommentInOrg: [\"PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}\"],\n updateDiscussionInOrg: [\"PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}\"],\n updateInOrg: [\"PATCH /orgs/{org}/teams/{team_slug}\"]\n },\n users: {\n addEmailForAuthenticated: [\"POST /user/emails\"],\n block: [\"PUT /user/blocks/{username}\"],\n checkBlocked: [\"GET /user/blocks/{username}\"],\n checkFollowingForUser: [\"GET /users/{username}/following/{target_user}\"],\n checkPersonIsFollowedByAuthenticated: [\"GET /user/following/{username}\"],\n createGpgKeyForAuthenticated: [\"POST /user/gpg_keys\"],\n createPublicSshKeyForAuthenticated: [\"POST /user/keys\"],\n deleteEmailForAuthenticated: [\"DELETE /user/emails\"],\n deleteGpgKeyForAuthenticated: [\"DELETE /user/gpg_keys/{gpg_key_id}\"],\n deletePublicSshKeyForAuthenticated: [\"DELETE /user/keys/{key_id}\"],\n follow: [\"PUT /user/following/{username}\"],\n getAuthenticated: [\"GET /user\"],\n getByUsername: [\"GET /users/{username}\"],\n getContextForUser: [\"GET /users/{username}/hovercard\"],\n getGpgKeyForAuthenticated: [\"GET /user/gpg_keys/{gpg_key_id}\"],\n getPublicSshKeyForAuthenticated: [\"GET /user/keys/{key_id}\"],\n list: [\"GET /users\"],\n listBlockedByAuthenticated: [\"GET /user/blocks\"],\n listEmailsForAuthenticated: [\"GET /user/emails\"],\n listFollowedByAuthenticated: [\"GET /user/following\"],\n listFollowersForAuthenticatedUser: [\"GET /user/followers\"],\n listFollowersForUser: [\"GET /users/{username}/followers\"],\n listFollowingForUser: [\"GET /users/{username}/following\"],\n listGpgKeysForAuthenticated: [\"GET /user/gpg_keys\"],\n listGpgKeysForUser: [\"GET /users/{username}/gpg_keys\"],\n listPublicEmailsForAuthenticated: [\"GET /user/public_emails\"],\n listPublicKeysForUser: [\"GET /users/{username}/keys\"],\n listPublicSshKeysForAuthenticated: [\"GET /user/keys\"],\n setPrimaryEmailVisibilityForAuthenticated: [\"PATCH /user/email/visibility\"],\n unblock: [\"DELETE /user/blocks/{username}\"],\n unfollow: [\"DELETE /user/following/{username}\"],\n updateAuthenticated: [\"PATCH /user\"]\n }\n};\n\nconst VERSION = \"5.3.1\";\n\nfunction endpointsToMethods(octokit, endpointsMap) {\n const newMethods = {};\n\n for (const [scope, endpoints] of Object.entries(endpointsMap)) {\n for (const [methodName, endpoint] of Object.entries(endpoints)) {\n const [route, defaults, decorations] = endpoint;\n const [method, url] = route.split(/ /);\n const endpointDefaults = Object.assign({\n method,\n url\n }, defaults);\n\n if (!newMethods[scope]) {\n newMethods[scope] = {};\n }\n\n const scopeMethods = newMethods[scope];\n\n if (decorations) {\n scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations);\n continue;\n }\n\n scopeMethods[methodName] = octokit.request.defaults(endpointDefaults);\n }\n }\n\n return newMethods;\n}\n\nfunction decorate(octokit, scope, methodName, defaults, decorations) {\n const requestWithDefaults = octokit.request.defaults(defaults);\n /* istanbul ignore next */\n\n function withDecorations(...args) {\n // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488\n let options = requestWithDefaults.endpoint.merge(...args); // There are currently no other decorations than `.mapToData`\n\n if (decorations.mapToData) {\n options = Object.assign({}, options, {\n data: options[decorations.mapToData],\n [decorations.mapToData]: undefined\n });\n return requestWithDefaults(options);\n }\n\n if (decorations.renamed) {\n const [newScope, newMethodName] = decorations.renamed;\n octokit.log.warn(`octokit.${scope}.${methodName}() has been renamed to octokit.${newScope}.${newMethodName}()`);\n }\n\n if (decorations.deprecated) {\n octokit.log.warn(decorations.deprecated);\n }\n\n if (decorations.renamedParameters) {\n // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488\n const options = requestWithDefaults.endpoint.merge(...args);\n\n for (const [name, alias] of Object.entries(decorations.renamedParameters)) {\n if (name in options) {\n octokit.log.warn(`\"${name}\" parameter is deprecated for \"octokit.${scope}.${methodName}()\". Use \"${alias}\" instead`);\n\n if (!(alias in options)) {\n options[alias] = options[name];\n }\n\n delete options[name];\n }\n }\n\n return requestWithDefaults(options);\n } // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488\n\n\n return requestWithDefaults(...args);\n }\n\n return Object.assign(withDecorations, requestWithDefaults);\n}\n\nfunction restEndpointMethods(octokit) {\n const api = endpointsToMethods(octokit, Endpoints);\n return {\n rest: api\n };\n}\nrestEndpointMethods.VERSION = VERSION;\nfunction legacyRestEndpointMethods(octokit) {\n const api = endpointsToMethods(octokit, Endpoints);\n return _objectSpread2(_objectSpread2({}, api), {}, {\n rest: api\n });\n}\nlegacyRestEndpointMethods.VERSION = VERSION;\n\nexports.legacyRestEndpointMethods = legacyRestEndpointMethods;\nexports.restEndpointMethods = restEndpointMethods;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar deprecation = require('deprecation');\nvar once = _interopDefault(require('once'));\n\nconst logOnce = once(deprecation => console.warn(deprecation));\n/**\n * Error with extra properties to help with debugging\n */\n\nclass RequestError extends Error {\n constructor(message, statusCode, options) {\n super(message); // Maintains proper stack trace (only available on V8)\n\n /* istanbul ignore next */\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n\n this.name = \"HttpError\";\n this.status = statusCode;\n Object.defineProperty(this, \"code\", {\n get() {\n logOnce(new deprecation.Deprecation(\"[@octokit/request-error] `error.code` is deprecated, use `error.status`.\"));\n return statusCode;\n }\n\n });\n this.headers = options.headers || {}; // redact request credentials without mutating original request options\n\n const requestCopy = Object.assign({}, options.request);\n\n if (options.request.headers.authorization) {\n requestCopy.headers = Object.assign({}, options.request.headers, {\n authorization: options.request.headers.authorization.replace(/ .*$/, \" [REDACTED]\")\n });\n }\n\n requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit\n // see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications\n .replace(/\\bclient_secret=\\w+/g, \"client_secret=[REDACTED]\") // OAuth tokens can be passed as URL query parameters, although it is not recommended\n // see https://developer.github.com/v3/#oauth2-token-sent-in-a-header\n .replace(/\\baccess_token=\\w+/g, \"access_token=[REDACTED]\");\n this.request = requestCopy;\n }\n\n}\n\nexports.RequestError = RequestError;\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar endpoint = require('@octokit/endpoint');\nvar universalUserAgent = require('universal-user-agent');\nvar isPlainObject = require('is-plain-object');\nvar nodeFetch = _interopDefault(require('node-fetch'));\nvar requestError = require('@octokit/request-error');\n\nconst VERSION = \"5.4.15\";\n\nfunction getBufferResponse(response) {\n return response.arrayBuffer();\n}\n\nfunction fetchWrapper(requestOptions) {\n if (isPlainObject.isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {\n requestOptions.body = JSON.stringify(requestOptions.body);\n }\n\n let headers = {};\n let status;\n let url;\n const fetch = requestOptions.request && requestOptions.request.fetch || nodeFetch;\n return fetch(requestOptions.url, Object.assign({\n method: requestOptions.method,\n body: requestOptions.body,\n headers: requestOptions.headers,\n redirect: requestOptions.redirect\n }, // `requestOptions.request.agent` type is incompatible\n // see https://github.com/octokit/types.ts/pull/264\n requestOptions.request)).then(response => {\n url = response.url;\n status = response.status;\n\n for (const keyAndValue of response.headers) {\n headers[keyAndValue[0]] = keyAndValue[1];\n }\n\n if (status === 204 || status === 205) {\n return;\n } // GitHub API returns 200 for HEAD requests\n\n\n if (requestOptions.method === \"HEAD\") {\n if (status < 400) {\n return;\n }\n\n throw new requestError.RequestError(response.statusText, status, {\n headers,\n request: requestOptions\n });\n }\n\n if (status === 304) {\n throw new requestError.RequestError(\"Not modified\", status, {\n headers,\n request: requestOptions\n });\n }\n\n if (status >= 400) {\n return response.text().then(message => {\n const error = new requestError.RequestError(message, status, {\n headers,\n request: requestOptions\n });\n\n try {\n let responseBody = JSON.parse(error.message);\n Object.assign(error, responseBody);\n let errors = responseBody.errors; // Assumption `errors` would always be in Array format\n\n error.message = error.message + \": \" + errors.map(JSON.stringify).join(\", \");\n } catch (e) {// ignore, see octokit/rest.js#684\n }\n\n throw error;\n });\n }\n\n const contentType = response.headers.get(\"content-type\");\n\n if (/application\\/json/.test(contentType)) {\n return response.json();\n }\n\n if (!contentType || /^text\\/|charset=utf-8$/.test(contentType)) {\n return response.text();\n }\n\n return getBufferResponse(response);\n }).then(data => {\n return {\n status,\n url,\n headers,\n data\n };\n }).catch(error => {\n if (error instanceof requestError.RequestError) {\n throw error;\n }\n\n throw new requestError.RequestError(error.message, 500, {\n headers,\n request: requestOptions\n });\n });\n}\n\nfunction withDefaults(oldEndpoint, newDefaults) {\n const endpoint = oldEndpoint.defaults(newDefaults);\n\n const newApi = function (route, parameters) {\n const endpointOptions = endpoint.merge(route, parameters);\n\n if (!endpointOptions.request || !endpointOptions.request.hook) {\n return fetchWrapper(endpoint.parse(endpointOptions));\n }\n\n const request = (route, parameters) => {\n return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters)));\n };\n\n Object.assign(request, {\n endpoint,\n defaults: withDefaults.bind(null, endpoint)\n });\n return endpointOptions.request.hook(request, endpointOptions);\n };\n\n return Object.assign(newApi, {\n endpoint,\n defaults: withDefaults.bind(null, endpoint)\n });\n}\n\nconst request = withDefaults(endpoint.endpoint, {\n headers: {\n \"user-agent\": `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}`\n }\n});\n\nexports.request = request;\n//# sourceMappingURL=index.js.map\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n\nmodule.exports = {\n\n newInvalidAsn1Error: function (msg) {\n var e = new Error();\n e.name = 'InvalidAsn1Error';\n e.message = msg || '';\n return e;\n }\n\n};\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar errors = require('./errors');\nvar types = require('./types');\n\nvar Reader = require('./reader');\nvar Writer = require('./writer');\n\n\n// --- Exports\n\nmodule.exports = {\n\n Reader: Reader,\n\n Writer: Writer\n\n};\n\nfor (var t in types) {\n if (types.hasOwnProperty(t))\n module.exports[t] = types[t];\n}\nfor (var e in errors) {\n if (errors.hasOwnProperty(e))\n module.exports[e] = errors[e];\n}\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar assert = require('assert');\nvar Buffer = require('safer-buffer').Buffer;\n\nvar ASN1 = require('./types');\nvar errors = require('./errors');\n\n\n// --- Globals\n\nvar newInvalidAsn1Error = errors.newInvalidAsn1Error;\n\n\n\n// --- API\n\nfunction Reader(data) {\n if (!data || !Buffer.isBuffer(data))\n throw new TypeError('data must be a node Buffer');\n\n this._buf = data;\n this._size = data.length;\n\n // These hold the \"current\" state\n this._len = 0;\n this._offset = 0;\n}\n\nObject.defineProperty(Reader.prototype, 'length', {\n enumerable: true,\n get: function () { return (this._len); }\n});\n\nObject.defineProperty(Reader.prototype, 'offset', {\n enumerable: true,\n get: function () { return (this._offset); }\n});\n\nObject.defineProperty(Reader.prototype, 'remain', {\n get: function () { return (this._size - this._offset); }\n});\n\nObject.defineProperty(Reader.prototype, 'buffer', {\n get: function () { return (this._buf.slice(this._offset)); }\n});\n\n\n/**\n * Reads a single byte and advances offset; you can pass in `true` to make this\n * a \"peek\" operation (i.e., get the byte, but don't advance the offset).\n *\n * @param {Boolean} peek true means don't move offset.\n * @return {Number} the next byte, null if not enough data.\n */\nReader.prototype.readByte = function (peek) {\n if (this._size - this._offset < 1)\n return null;\n\n var b = this._buf[this._offset] & 0xff;\n\n if (!peek)\n this._offset += 1;\n\n return b;\n};\n\n\nReader.prototype.peek = function () {\n return this.readByte(true);\n};\n\n\n/**\n * Reads a (potentially) variable length off the BER buffer. This call is\n * not really meant to be called directly, as callers have to manipulate\n * the internal buffer afterwards.\n *\n * As a result of this call, you can call `Reader.length`, until the\n * next thing called that does a readLength.\n *\n * @return {Number} the amount of offset to advance the buffer.\n * @throws {InvalidAsn1Error} on bad ASN.1\n */\nReader.prototype.readLength = function (offset) {\n if (offset === undefined)\n offset = this._offset;\n\n if (offset >= this._size)\n return null;\n\n var lenB = this._buf[offset++] & 0xff;\n if (lenB === null)\n return null;\n\n if ((lenB & 0x80) === 0x80) {\n lenB &= 0x7f;\n\n if (lenB === 0)\n throw newInvalidAsn1Error('Indefinite length not supported');\n\n if (lenB > 4)\n throw newInvalidAsn1Error('encoding too long');\n\n if (this._size - offset < lenB)\n return null;\n\n this._len = 0;\n for (var i = 0; i < lenB; i++)\n this._len = (this._len << 8) + (this._buf[offset++] & 0xff);\n\n } else {\n // Wasn't a variable length\n this._len = lenB;\n }\n\n return offset;\n};\n\n\n/**\n * Parses the next sequence in this BER buffer.\n *\n * To get the length of the sequence, call `Reader.length`.\n *\n * @return {Number} the sequence's tag.\n */\nReader.prototype.readSequence = function (tag) {\n var seq = this.peek();\n if (seq === null)\n return null;\n if (tag !== undefined && tag !== seq)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + seq.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n if (o === null)\n return null;\n\n this._offset = o;\n return seq;\n};\n\n\nReader.prototype.readInt = function () {\n return this._readTag(ASN1.Integer);\n};\n\n\nReader.prototype.readBoolean = function () {\n return (this._readTag(ASN1.Boolean) === 0 ? false : true);\n};\n\n\nReader.prototype.readEnumeration = function () {\n return this._readTag(ASN1.Enumeration);\n};\n\n\nReader.prototype.readString = function (tag, retbuf) {\n if (!tag)\n tag = ASN1.OctetString;\n\n var b = this.peek();\n if (b === null)\n return null;\n\n if (b !== tag)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + b.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n\n if (o === null)\n return null;\n\n if (this.length > this._size - o)\n return null;\n\n this._offset = o;\n\n if (this.length === 0)\n return retbuf ? Buffer.alloc(0) : '';\n\n var str = this._buf.slice(this._offset, this._offset + this.length);\n this._offset += this.length;\n\n return retbuf ? str : str.toString('utf8');\n};\n\nReader.prototype.readOID = function (tag) {\n if (!tag)\n tag = ASN1.OID;\n\n var b = this.readString(tag, true);\n if (b === null)\n return null;\n\n var values = [];\n var value = 0;\n\n for (var i = 0; i < b.length; i++) {\n var byte = b[i] & 0xff;\n\n value <<= 7;\n value += byte & 0x7f;\n if ((byte & 0x80) === 0) {\n values.push(value);\n value = 0;\n }\n }\n\n value = values.shift();\n values.unshift(value % 40);\n values.unshift((value / 40) >> 0);\n\n return values.join('.');\n};\n\n\nReader.prototype._readTag = function (tag) {\n assert.ok(tag !== undefined);\n\n var b = this.peek();\n\n if (b === null)\n return null;\n\n if (b !== tag)\n throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +\n ': got 0x' + b.toString(16));\n\n var o = this.readLength(this._offset + 1); // stored in `length`\n if (o === null)\n return null;\n\n if (this.length > 4)\n throw newInvalidAsn1Error('Integer too long: ' + this.length);\n\n if (this.length > this._size - o)\n return null;\n this._offset = o;\n\n var fb = this._buf[this._offset];\n var value = 0;\n\n for (var i = 0; i < this.length; i++) {\n value <<= 8;\n value |= (this._buf[this._offset++] & 0xff);\n }\n\n if ((fb & 0x80) === 0x80 && i !== 4)\n value -= (1 << (i * 8));\n\n return value >> 0;\n};\n\n\n\n// --- Exported API\n\nmodule.exports = Reader;\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n\nmodule.exports = {\n EOC: 0,\n Boolean: 1,\n Integer: 2,\n BitString: 3,\n OctetString: 4,\n Null: 5,\n OID: 6,\n ObjectDescriptor: 7,\n External: 8,\n Real: 9, // float\n Enumeration: 10,\n PDV: 11,\n Utf8String: 12,\n RelativeOID: 13,\n Sequence: 16,\n Set: 17,\n NumericString: 18,\n PrintableString: 19,\n T61String: 20,\n VideotexString: 21,\n IA5String: 22,\n UTCTime: 23,\n GeneralizedTime: 24,\n GraphicString: 25,\n VisibleString: 26,\n GeneralString: 28,\n UniversalString: 29,\n CharacterString: 30,\n BMPString: 31,\n Constructor: 32,\n Context: 128\n};\n","// Copyright 2011 Mark Cavage All rights reserved.\n\nvar assert = require('assert');\nvar Buffer = require('safer-buffer').Buffer;\nvar ASN1 = require('./types');\nvar errors = require('./errors');\n\n\n// --- Globals\n\nvar newInvalidAsn1Error = errors.newInvalidAsn1Error;\n\nvar DEFAULT_OPTS = {\n size: 1024,\n growthFactor: 8\n};\n\n\n// --- Helpers\n\nfunction merge(from, to) {\n assert.ok(from);\n assert.equal(typeof (from), 'object');\n assert.ok(to);\n assert.equal(typeof (to), 'object');\n\n var keys = Object.getOwnPropertyNames(from);\n keys.forEach(function (key) {\n if (to[key])\n return;\n\n var value = Object.getOwnPropertyDescriptor(from, key);\n Object.defineProperty(to, key, value);\n });\n\n return to;\n}\n\n\n\n// --- API\n\nfunction Writer(options) {\n options = merge(DEFAULT_OPTS, options || {});\n\n this._buf = Buffer.alloc(options.size || 1024);\n this._size = this._buf.length;\n this._offset = 0;\n this._options = options;\n\n // A list of offsets in the buffer where we need to insert\n // sequence tag/len pairs.\n this._seq = [];\n}\n\nObject.defineProperty(Writer.prototype, 'buffer', {\n get: function () {\n if (this._seq.length)\n throw newInvalidAsn1Error(this._seq.length + ' unended sequence(s)');\n\n return (this._buf.slice(0, this._offset));\n }\n});\n\nWriter.prototype.writeByte = function (b) {\n if (typeof (b) !== 'number')\n throw new TypeError('argument must be a Number');\n\n this._ensure(1);\n this._buf[this._offset++] = b;\n};\n\n\nWriter.prototype.writeInt = function (i, tag) {\n if (typeof (i) !== 'number')\n throw new TypeError('argument must be a Number');\n if (typeof (tag) !== 'number')\n tag = ASN1.Integer;\n\n var sz = 4;\n\n while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&\n (sz > 1)) {\n sz--;\n i <<= 8;\n }\n\n if (sz > 4)\n throw newInvalidAsn1Error('BER ints cannot be > 0xffffffff');\n\n this._ensure(2 + sz);\n this._buf[this._offset++] = tag;\n this._buf[this._offset++] = sz;\n\n while (sz-- > 0) {\n this._buf[this._offset++] = ((i & 0xff000000) >>> 24);\n i <<= 8;\n }\n\n};\n\n\nWriter.prototype.writeNull = function () {\n this.writeByte(ASN1.Null);\n this.writeByte(0x00);\n};\n\n\nWriter.prototype.writeEnumeration = function (i, tag) {\n if (typeof (i) !== 'number')\n throw new TypeError('argument must be a Number');\n if (typeof (tag) !== 'number')\n tag = ASN1.Enumeration;\n\n return this.writeInt(i, tag);\n};\n\n\nWriter.prototype.writeBoolean = function (b, tag) {\n if (typeof (b) !== 'boolean')\n throw new TypeError('argument must be a Boolean');\n if (typeof (tag) !== 'number')\n tag = ASN1.Boolean;\n\n this._ensure(3);\n this._buf[this._offset++] = tag;\n this._buf[this._offset++] = 0x01;\n this._buf[this._offset++] = b ? 0xff : 0x00;\n};\n\n\nWriter.prototype.writeString = function (s, tag) {\n if (typeof (s) !== 'string')\n throw new TypeError('argument must be a string (was: ' + typeof (s) + ')');\n if (typeof (tag) !== 'number')\n tag = ASN1.OctetString;\n\n var len = Buffer.byteLength(s);\n this.writeByte(tag);\n this.writeLength(len);\n if (len) {\n this._ensure(len);\n this._buf.write(s, this._offset);\n this._offset += len;\n }\n};\n\n\nWriter.prototype.writeBuffer = function (buf, tag) {\n if (typeof (tag) !== 'number')\n throw new TypeError('tag must be a number');\n if (!Buffer.isBuffer(buf))\n throw new TypeError('argument must be a buffer');\n\n this.writeByte(tag);\n this.writeLength(buf.length);\n this._ensure(buf.length);\n buf.copy(this._buf, this._offset, 0, buf.length);\n this._offset += buf.length;\n};\n\n\nWriter.prototype.writeStringArray = function (strings) {\n if ((!strings instanceof Array))\n throw new TypeError('argument must be an Array[String]');\n\n var self = this;\n strings.forEach(function (s) {\n self.writeString(s);\n });\n};\n\n// This is really to solve DER cases, but whatever for now\nWriter.prototype.writeOID = function (s, tag) {\n if (typeof (s) !== 'string')\n throw new TypeError('argument must be a string');\n if (typeof (tag) !== 'number')\n tag = ASN1.OID;\n\n if (!/^([0-9]+\\.){3,}[0-9]+$/.test(s))\n throw new Error('argument is not a valid OID string');\n\n function encodeOctet(bytes, octet) {\n if (octet < 128) {\n bytes.push(octet);\n } else if (octet < 16384) {\n bytes.push((octet >>> 7) | 0x80);\n bytes.push(octet & 0x7F);\n } else if (octet < 2097152) {\n bytes.push((octet >>> 14) | 0x80);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n } else if (octet < 268435456) {\n bytes.push((octet >>> 21) | 0x80);\n bytes.push(((octet >>> 14) | 0x80) & 0xFF);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n } else {\n bytes.push(((octet >>> 28) | 0x80) & 0xFF);\n bytes.push(((octet >>> 21) | 0x80) & 0xFF);\n bytes.push(((octet >>> 14) | 0x80) & 0xFF);\n bytes.push(((octet >>> 7) | 0x80) & 0xFF);\n bytes.push(octet & 0x7F);\n }\n }\n\n var tmp = s.split('.');\n var bytes = [];\n bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));\n tmp.slice(2).forEach(function (b) {\n encodeOctet(bytes, parseInt(b, 10));\n });\n\n var self = this;\n this._ensure(2 + bytes.length);\n this.writeByte(tag);\n this.writeLength(bytes.length);\n bytes.forEach(function (b) {\n self.writeByte(b);\n });\n};\n\n\nWriter.prototype.writeLength = function (len) {\n if (typeof (len) !== 'number')\n throw new TypeError('argument must be a Number');\n\n this._ensure(4);\n\n if (len <= 0x7f) {\n this._buf[this._offset++] = len;\n } else if (len <= 0xff) {\n this._buf[this._offset++] = 0x81;\n this._buf[this._offset++] = len;\n } else if (len <= 0xffff) {\n this._buf[this._offset++] = 0x82;\n this._buf[this._offset++] = len >> 8;\n this._buf[this._offset++] = len;\n } else if (len <= 0xffffff) {\n this._buf[this._offset++] = 0x83;\n this._buf[this._offset++] = len >> 16;\n this._buf[this._offset++] = len >> 8;\n this._buf[this._offset++] = len;\n } else {\n throw newInvalidAsn1Error('Length too long (> 4 bytes)');\n }\n};\n\nWriter.prototype.startSequence = function (tag) {\n if (typeof (tag) !== 'number')\n tag = ASN1.Sequence | ASN1.Constructor;\n\n this.writeByte(tag);\n this._seq.push(this._offset);\n this._ensure(3);\n this._offset += 3;\n};\n\n\nWriter.prototype.endSequence = function () {\n var seq = this._seq.pop();\n var start = seq + 3;\n var len = this._offset - start;\n\n if (len <= 0x7f) {\n this._shift(start, len, -2);\n this._buf[seq] = len;\n } else if (len <= 0xff) {\n this._shift(start, len, -1);\n this._buf[seq] = 0x81;\n this._buf[seq + 1] = len;\n } else if (len <= 0xffff) {\n this._buf[seq] = 0x82;\n this._buf[seq + 1] = len >> 8;\n this._buf[seq + 2] = len;\n } else if (len <= 0xffffff) {\n this._shift(start, len, 1);\n this._buf[seq] = 0x83;\n this._buf[seq + 1] = len >> 16;\n this._buf[seq + 2] = len >> 8;\n this._buf[seq + 3] = len;\n } else {\n throw newInvalidAsn1Error('Sequence too long');\n }\n};\n\n\nWriter.prototype._shift = function (start, len, shift) {\n assert.ok(start !== undefined);\n assert.ok(len !== undefined);\n assert.ok(shift);\n\n this._buf.copy(this._buf, start + shift, start, start + len);\n this._offset += shift;\n};\n\nWriter.prototype._ensure = function (len) {\n assert.ok(len);\n\n if (this._size - this._offset < len) {\n var sz = this._size * this._options.growthFactor;\n if (sz - this._offset < len)\n sz += len;\n\n var buf = Buffer.alloc(sz);\n\n this._buf.copy(buf, 0, 0, this._offset);\n this._buf = buf;\n this._size = sz;\n }\n};\n\n\n\n// --- Exported API\n\nmodule.exports = Writer;\n","// Copyright 2011 Mark Cavage All rights reserved.\n\n// If you have no idea what ASN.1 or BER is, see this:\n// ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc\n\nvar Ber = require('./ber/index');\n\n\n\n// --- Exported API\n\nmodule.exports = {\n\n Ber: Ber,\n\n BerReader: Ber.Reader,\n\n BerWriter: Ber.Writer\n\n};\n","module.exports = require('./lib/axios');","'use strict';\n\nvar utils = require('./../utils');\nvar settle = require('./../core/settle');\nvar buildFullPath = require('../core/buildFullPath');\nvar buildURL = require('./../helpers/buildURL');\nvar http = require('http');\nvar https = require('https');\nvar httpFollow = require('follow-redirects').http;\nvar httpsFollow = require('follow-redirects').https;\nvar url = require('url');\nvar zlib = require('zlib');\nvar VERSION = require('./../env/data').version;\nvar createError = require('../core/createError');\nvar enhanceError = require('../core/enhanceError');\nvar defaults = require('../defaults');\nvar Cancel = require('../cancel/Cancel');\n\nvar isHttps = /https:?/;\n\n/**\n *\n * @param {http.ClientRequestArgs} options\n * @param {AxiosProxyConfig} proxy\n * @param {string} location\n */\nfunction setProxy(options, proxy, location) {\n options.hostname = proxy.host;\n options.host = proxy.host;\n options.port = proxy.port;\n options.path = location;\n\n // Basic proxy authorization\n if (proxy.auth) {\n var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');\n options.headers['Proxy-Authorization'] = 'Basic ' + base64;\n }\n\n // If a proxy is used, any redirects must also pass through the proxy\n options.beforeRedirect = function beforeRedirect(redirection) {\n redirection.headers.host = redirection.host;\n setProxy(redirection, proxy, redirection.href);\n };\n}\n\n/*eslint consistent-return:0*/\nmodule.exports = function httpAdapter(config) {\n return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {\n var onCanceled;\n function done() {\n if (config.cancelToken) {\n config.cancelToken.unsubscribe(onCanceled);\n }\n\n if (config.signal) {\n config.signal.removeEventListener('abort', onCanceled);\n }\n }\n var resolve = function resolve(value) {\n done();\n resolvePromise(value);\n };\n var reject = function reject(value) {\n done();\n rejectPromise(value);\n };\n var data = config.data;\n var headers = config.headers;\n var headerNames = {};\n\n Object.keys(headers).forEach(function storeLowerName(name) {\n headerNames[name.toLowerCase()] = name;\n });\n\n // Set User-Agent (required by some servers)\n // See https://github.com/axios/axios/issues/69\n if ('user-agent' in headerNames) {\n // User-Agent is specified; handle case where no UA header is desired\n if (!headers[headerNames['user-agent']]) {\n delete headers[headerNames['user-agent']];\n }\n // Otherwise, use specified value\n } else {\n // Only set header if it hasn't been set in config\n headers['User-Agent'] = 'axios/' + VERSION;\n }\n\n if (data && !utils.isStream(data)) {\n if (Buffer.isBuffer(data)) {\n // Nothing to do...\n } else if (utils.isArrayBuffer(data)) {\n data = Buffer.from(new Uint8Array(data));\n } else if (utils.isString(data)) {\n data = Buffer.from(data, 'utf-8');\n } else {\n return reject(createError(\n 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',\n config\n ));\n }\n\n // Add Content-Length header if data exists\n if (!headerNames['content-length']) {\n headers['Content-Length'] = data.length;\n }\n }\n\n // HTTP basic authentication\n var auth = undefined;\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password || '';\n auth = username + ':' + password;\n }\n\n // Parse url\n var fullPath = buildFullPath(config.baseURL, config.url);\n var parsed = url.parse(fullPath);\n var protocol = parsed.protocol || 'http:';\n\n if (!auth && parsed.auth) {\n var urlAuth = parsed.auth.split(':');\n var urlUsername = urlAuth[0] || '';\n var urlPassword = urlAuth[1] || '';\n auth = urlUsername + ':' + urlPassword;\n }\n\n if (auth && headerNames.authorization) {\n delete headers[headerNames.authorization];\n }\n\n var isHttpsRequest = isHttps.test(protocol);\n var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;\n\n var options = {\n path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\\?/, ''),\n method: config.method.toUpperCase(),\n headers: headers,\n agent: agent,\n agents: { http: config.httpAgent, https: config.httpsAgent },\n auth: auth\n };\n\n if (config.socketPath) {\n options.socketPath = config.socketPath;\n } else {\n options.hostname = parsed.hostname;\n options.port = parsed.port;\n }\n\n var proxy = config.proxy;\n if (!proxy && proxy !== false) {\n var proxyEnv = protocol.slice(0, -1) + '_proxy';\n var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];\n if (proxyUrl) {\n var parsedProxyUrl = url.parse(proxyUrl);\n var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;\n var shouldProxy = true;\n\n if (noProxyEnv) {\n var noProxy = noProxyEnv.split(',').map(function trim(s) {\n return s.trim();\n });\n\n shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {\n if (!proxyElement) {\n return false;\n }\n if (proxyElement === '*') {\n return true;\n }\n if (proxyElement[0] === '.' &&\n parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {\n return true;\n }\n\n return parsed.hostname === proxyElement;\n });\n }\n\n if (shouldProxy) {\n proxy = {\n host: parsedProxyUrl.hostname,\n port: parsedProxyUrl.port,\n protocol: parsedProxyUrl.protocol\n };\n\n if (parsedProxyUrl.auth) {\n var proxyUrlAuth = parsedProxyUrl.auth.split(':');\n proxy.auth = {\n username: proxyUrlAuth[0],\n password: proxyUrlAuth[1]\n };\n }\n }\n }\n }\n\n if (proxy) {\n options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');\n setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);\n }\n\n var transport;\n var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);\n if (config.transport) {\n transport = config.transport;\n } else if (config.maxRedirects === 0) {\n transport = isHttpsProxy ? https : http;\n } else {\n if (config.maxRedirects) {\n options.maxRedirects = config.maxRedirects;\n }\n transport = isHttpsProxy ? httpsFollow : httpFollow;\n }\n\n if (config.maxBodyLength > -1) {\n options.maxBodyLength = config.maxBodyLength;\n }\n\n if (config.insecureHTTPParser) {\n options.insecureHTTPParser = config.insecureHTTPParser;\n }\n\n // Create the request\n var req = transport.request(options, function handleResponse(res) {\n if (req.aborted) return;\n\n // uncompress the response body transparently if required\n var stream = res;\n\n // return the last request in case of redirects\n var lastRequest = res.req || req;\n\n\n // if no content, is HEAD request or decompress disabled we should not decompress\n if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {\n switch (res.headers['content-encoding']) {\n /*eslint default-case:0*/\n case 'gzip':\n case 'compress':\n case 'deflate':\n // add the unzipper to the body stream processing pipeline\n stream = stream.pipe(zlib.createUnzip());\n\n // remove the content-encoding in order to not confuse downstream operations\n delete res.headers['content-encoding'];\n break;\n }\n }\n\n var response = {\n status: res.statusCode,\n statusText: res.statusMessage,\n headers: res.headers,\n config: config,\n request: lastRequest\n };\n\n if (config.responseType === 'stream') {\n response.data = stream;\n settle(resolve, reject, response);\n } else {\n var responseBuffer = [];\n var totalResponseBytes = 0;\n stream.on('data', function handleStreamData(chunk) {\n responseBuffer.push(chunk);\n totalResponseBytes += chunk.length;\n\n // make sure the content length is not over the maxContentLength if specified\n if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {\n stream.destroy();\n reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',\n config, null, lastRequest));\n }\n });\n\n stream.on('error', function handleStreamError(err) {\n if (req.aborted) return;\n reject(enhanceError(err, config, null, lastRequest));\n });\n\n stream.on('end', function handleStreamEnd() {\n var responseData = Buffer.concat(responseBuffer);\n if (config.responseType !== 'arraybuffer') {\n responseData = responseData.toString(config.responseEncoding);\n if (!config.responseEncoding || config.responseEncoding === 'utf8') {\n responseData = utils.stripBOM(responseData);\n }\n }\n\n response.data = responseData;\n settle(resolve, reject, response);\n });\n }\n });\n\n // Handle errors\n req.on('error', function handleRequestError(err) {\n if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;\n reject(enhanceError(err, config, null, req));\n });\n\n // Handle request timeout\n if (config.timeout) {\n // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.\n var timeout = parseInt(config.timeout, 10);\n\n if (isNaN(timeout)) {\n reject(createError(\n 'error trying to parse `config.timeout` to int',\n config,\n 'ERR_PARSE_TIMEOUT',\n req\n ));\n\n return;\n }\n\n // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.\n // And timer callback will be fired, and abort() will be invoked before connection, then get \"socket hang up\" and code ECONNRESET.\n // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.\n // And then these socket which be hang up will devoring CPU little by little.\n // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.\n req.setTimeout(timeout, function handleRequestTimeout() {\n req.abort();\n var transitional = config.transitional || defaults.transitional;\n reject(createError(\n 'timeout of ' + timeout + 'ms exceeded',\n config,\n transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',\n req\n ));\n });\n }\n\n if (config.cancelToken || config.signal) {\n // Handle cancellation\n // eslint-disable-next-line func-names\n onCanceled = function(cancel) {\n if (req.aborted) return;\n\n req.abort();\n reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);\n };\n\n config.cancelToken && config.cancelToken.subscribe(onCanceled);\n if (config.signal) {\n config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);\n }\n }\n\n\n // Send the request\n if (utils.isStream(data)) {\n data.on('error', function handleStreamError(err) {\n reject(enhanceError(err, config, null, req));\n }).pipe(req);\n } else {\n req.end(data);\n }\n });\n};\n","'use strict';\n\nvar utils = require('./../utils');\nvar settle = require('./../core/settle');\nvar cookies = require('./../helpers/cookies');\nvar buildURL = require('./../helpers/buildURL');\nvar buildFullPath = require('../core/buildFullPath');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar createError = require('../core/createError');\nvar defaults = require('../defaults');\nvar Cancel = require('../cancel/Cancel');\n\nmodule.exports = function xhrAdapter(config) {\n return new Promise(function dispatchXhrRequest(resolve, reject) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n var responseType = config.responseType;\n var onCanceled;\n function done() {\n if (config.cancelToken) {\n config.cancelToken.unsubscribe(onCanceled);\n }\n\n if (config.signal) {\n config.signal.removeEventListener('abort', onCanceled);\n }\n }\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n var fullPath = buildFullPath(config.baseURL, config.url);\n request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n function onloadend() {\n if (!request) {\n return;\n }\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = !responseType || responseType === 'text' || responseType === 'json' ?\n request.responseText : request.response;\n var response = {\n data: responseData,\n status: request.status,\n statusText: request.statusText,\n headers: responseHeaders,\n config: config,\n request: request\n };\n\n settle(function _resolve(value) {\n resolve(value);\n done();\n }, function _reject(err) {\n reject(err);\n done();\n }, response);\n\n // Clean up request\n request = null;\n }\n\n if ('onloadend' in request) {\n // Use onloadend if available\n request.onloadend = onloadend;\n } else {\n // Listen for ready state to emulate onloadend\n request.onreadystatechange = function handleLoad() {\n if (!request || request.readyState !== 4) {\n return;\n }\n\n // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n // With one exception: request that using file: protocol, most browsers\n // will return status as 0 even though it's a successful request\n if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n return;\n }\n // readystate handler is calling before onerror or ontimeout handlers,\n // so we should call onloadend on the next 'tick'\n setTimeout(onloadend);\n };\n }\n\n // Handle browser request cancellation (as opposed to a manual cancellation)\n request.onabort = function handleAbort() {\n if (!request) {\n return;\n }\n\n reject(createError('Request aborted', config, 'ECONNABORTED', request));\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(createError('Network Error', config, null, request));\n\n // Clean up request\n request = null;\n };\n\n // Handle timeout\n request.ontimeout = function handleTimeout() {\n var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';\n var transitional = config.transitional || defaults.transitional;\n if (config.timeoutErrorMessage) {\n timeoutErrorMessage = config.timeoutErrorMessage;\n }\n reject(createError(\n timeoutErrorMessage,\n config,\n transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',\n request));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n // Add xsrf header\n var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (!utils.isUndefined(config.withCredentials)) {\n request.withCredentials = !!config.withCredentials;\n }\n\n // Add responseType to request if needed\n if (responseType && responseType !== 'json') {\n request.responseType = config.responseType;\n }\n\n // Handle progress if needed\n if (typeof config.onDownloadProgress === 'function') {\n request.addEventListener('progress', config.onDownloadProgress);\n }\n\n // Not all browsers support upload events\n if (typeof config.onUploadProgress === 'function' && request.upload) {\n request.upload.addEventListener('progress', config.onUploadProgress);\n }\n\n if (config.cancelToken || config.signal) {\n // Handle cancellation\n // eslint-disable-next-line func-names\n onCanceled = function(cancel) {\n if (!request) {\n return;\n }\n reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);\n request.abort();\n request = null;\n };\n\n config.cancelToken && config.cancelToken.subscribe(onCanceled);\n if (config.signal) {\n config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);\n }\n }\n\n if (!requestData) {\n requestData = null;\n }\n\n // Send the request\n request.send(requestData);\n });\n};\n","'use strict';\n\nvar utils = require('./utils');\nvar bind = require('./helpers/bind');\nvar Axios = require('./core/Axios');\nvar mergeConfig = require('./core/mergeConfig');\nvar defaults = require('./defaults');\n\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n * @return {Axios} A new instance of Axios\n */\nfunction createInstance(defaultConfig) {\n var context = new Axios(defaultConfig);\n var instance = bind(Axios.prototype.request, context);\n\n // Copy axios.prototype to instance\n utils.extend(instance, Axios.prototype, context);\n\n // Copy context to instance\n utils.extend(instance, context);\n\n // Factory for creating new instances\n instance.create = function create(instanceConfig) {\n return createInstance(mergeConfig(defaultConfig, instanceConfig));\n };\n\n return instance;\n}\n\n// Create the default instance to be exported\nvar axios = createInstance(defaults);\n\n// Expose Axios class to allow class inheritance\naxios.Axios = Axios;\n\n// Expose Cancel & CancelToken\naxios.Cancel = require('./cancel/Cancel');\naxios.CancelToken = require('./cancel/CancelToken');\naxios.isCancel = require('./cancel/isCancel');\naxios.VERSION = require('./env/data').version;\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\n// Expose isAxiosError\naxios.isAxiosError = require('./helpers/isAxiosError');\n\nmodule.exports = axios;\n\n// Allow use of default import syntax in TypeScript\nmodule.exports.default = axios;\n","'use strict';\n\n/**\n * A `Cancel` is an object that is thrown when an operation is canceled.\n *\n * @class\n * @param {string=} message The message.\n */\nfunction Cancel(message) {\n this.message = message;\n}\n\nCancel.prototype.toString = function toString() {\n return 'Cancel' + (this.message ? ': ' + this.message : '');\n};\n\nCancel.prototype.__CANCEL__ = true;\n\nmodule.exports = Cancel;\n","'use strict';\n\nvar Cancel = require('./Cancel');\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @class\n * @param {Function} executor The executor function.\n */\nfunction CancelToken(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n var resolvePromise;\n\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n\n var token = this;\n\n // eslint-disable-next-line func-names\n this.promise.then(function(cancel) {\n if (!token._listeners) return;\n\n var i;\n var l = token._listeners.length;\n\n for (i = 0; i < l; i++) {\n token._listeners[i](cancel);\n }\n token._listeners = null;\n });\n\n // eslint-disable-next-line func-names\n this.promise.then = function(onfulfilled) {\n var _resolve;\n // eslint-disable-next-line func-names\n var promise = new Promise(function(resolve) {\n token.subscribe(resolve);\n _resolve = resolve;\n }).then(onfulfilled);\n\n promise.cancel = function reject() {\n token.unsubscribe(_resolve);\n };\n\n return promise;\n };\n\n executor(function cancel(message) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new Cancel(message);\n resolvePromise(token.reason);\n });\n}\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n};\n\n/**\n * Subscribe to the cancel signal\n */\n\nCancelToken.prototype.subscribe = function subscribe(listener) {\n if (this.reason) {\n listener(this.reason);\n return;\n }\n\n if (this._listeners) {\n this._listeners.push(listener);\n } else {\n this._listeners = [listener];\n }\n};\n\n/**\n * Unsubscribe from the cancel signal\n */\n\nCancelToken.prototype.unsubscribe = function unsubscribe(listener) {\n if (!this._listeners) {\n return;\n }\n var index = this._listeners.indexOf(listener);\n if (index !== -1) {\n this._listeners.splice(index, 1);\n }\n};\n\n/**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\nCancelToken.source = function source() {\n var cancel;\n var token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token: token,\n cancel: cancel\n };\n};\n\nmodule.exports = CancelToken;\n","'use strict';\n\nmodule.exports = function isCancel(value) {\n return !!(value && value.__CANCEL__);\n};\n","'use strict';\n\nvar utils = require('./../utils');\nvar buildURL = require('../helpers/buildURL');\nvar InterceptorManager = require('./InterceptorManager');\nvar dispatchRequest = require('./dispatchRequest');\nvar mergeConfig = require('./mergeConfig');\nvar validator = require('../helpers/validator');\n\nvar validators = validator.validators;\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n */\nfunction Axios(instanceConfig) {\n this.defaults = instanceConfig;\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\n/**\n * Dispatch a request\n *\n * @param {Object} config The config specific for this request (merged with this.defaults)\n */\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = arguments[1] || {};\n config.url = arguments[0];\n } else {\n config = config || {};\n }\n\n config = mergeConfig(this.defaults, config);\n\n // Set config.method\n if (config.method) {\n config.method = config.method.toLowerCase();\n } else if (this.defaults.method) {\n config.method = this.defaults.method.toLowerCase();\n } else {\n config.method = 'get';\n }\n\n var transitional = config.transitional;\n\n if (transitional !== undefined) {\n validator.assertOptions(transitional, {\n silentJSONParsing: validators.transitional(validators.boolean),\n forcedJSONParsing: validators.transitional(validators.boolean),\n clarifyTimeoutError: validators.transitional(validators.boolean)\n }, false);\n }\n\n // filter out skipped interceptors\n var requestInterceptorChain = [];\n var synchronousRequestInterceptors = true;\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {\n return;\n }\n\n synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;\n\n requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n var responseInterceptorChain = [];\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n var promise;\n\n if (!synchronousRequestInterceptors) {\n var chain = [dispatchRequest, undefined];\n\n Array.prototype.unshift.apply(chain, requestInterceptorChain);\n chain = chain.concat(responseInterceptorChain);\n\n promise = Promise.resolve(config);\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n }\n\n\n var newConfig = config;\n while (requestInterceptorChain.length) {\n var onFulfilled = requestInterceptorChain.shift();\n var onRejected = requestInterceptorChain.shift();\n try {\n newConfig = onFulfilled(newConfig);\n } catch (error) {\n onRejected(error);\n break;\n }\n }\n\n try {\n promise = dispatchRequest(newConfig);\n } catch (error) {\n return Promise.reject(error);\n }\n\n while (responseInterceptorChain.length) {\n promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());\n }\n\n return promise;\n};\n\nAxios.prototype.getUri = function getUri(config) {\n config = mergeConfig(this.defaults, config);\n return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\\?/, '');\n};\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: (config || {}).data\n }));\n };\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n});\n\nmodule.exports = Axios;\n","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected, options) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected,\n synchronous: options ? options.synchronous : false,\n runWhen: options ? options.runWhen : null\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n","'use strict';\n\nvar isAbsoluteURL = require('../helpers/isAbsoluteURL');\nvar combineURLs = require('../helpers/combineURLs');\n\n/**\n * Creates a new URL by combining the baseURL with the requestedURL,\n * only when the requestedURL is not already an absolute URL.\n * If the requestURL is absolute, this function returns the requestedURL untouched.\n *\n * @param {string} baseURL The base URL\n * @param {string} requestedURL Absolute or relative URL to combine\n * @returns {string} The combined full path\n */\nmodule.exports = function buildFullPath(baseURL, requestedURL) {\n if (baseURL && !isAbsoluteURL(requestedURL)) {\n return combineURLs(baseURL, requestedURL);\n }\n return requestedURL;\n};\n","'use strict';\n\nvar enhanceError = require('./enhanceError');\n\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The created error.\n */\nmodule.exports = function createError(message, config, code, request, response) {\n var error = new Error(message);\n return enhanceError(error, config, code, request, response);\n};\n","'use strict';\n\nvar utils = require('./../utils');\nvar transformData = require('./transformData');\nvar isCancel = require('../cancel/isCancel');\nvar defaults = require('../defaults');\nvar Cancel = require('../cancel/Cancel');\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nfunction throwIfCancellationRequested(config) {\n if (config.cancelToken) {\n config.cancelToken.throwIfRequested();\n }\n\n if (config.signal && config.signal.aborted) {\n throw new Cancel('canceled');\n }\n}\n\n/**\n * Dispatch a request to the server using the configured adapter.\n *\n * @param {object} config The config that is to be used for the request\n * @returns {Promise} The Promise to be fulfilled\n */\nmodule.exports = function dispatchRequest(config) {\n throwIfCancellationRequested(config);\n\n // Ensure headers exist\n config.headers = config.headers || {};\n\n // Transform request data\n config.data = transformData.call(\n config,\n config.data,\n config.headers,\n config.transformRequest\n );\n\n // Flatten headers\n config.headers = utils.merge(\n config.headers.common || {},\n config.headers[config.method] || {},\n config.headers\n );\n\n utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n function cleanHeaderConfig(method) {\n delete config.headers[method];\n }\n );\n\n var adapter = config.adapter || defaults.adapter;\n\n return adapter(config).then(function onAdapterResolution(response) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n response.data = transformData.call(\n config,\n response.data,\n response.headers,\n config.transformResponse\n );\n\n return response;\n }, function onAdapterRejection(reason) {\n if (!isCancel(reason)) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n if (reason && reason.response) {\n reason.response.data = transformData.call(\n config,\n reason.response.data,\n reason.response.headers,\n config.transformResponse\n );\n }\n }\n\n return Promise.reject(reason);\n });\n};\n","'use strict';\n\n/**\n * Update an Error with the specified config, error code, and response.\n *\n * @param {Error} error The error to update.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The error.\n */\nmodule.exports = function enhanceError(error, config, code, request, response) {\n error.config = config;\n if (code) {\n error.code = code;\n }\n\n error.request = request;\n error.response = response;\n error.isAxiosError = true;\n\n error.toJSON = function toJSON() {\n return {\n // Standard\n message: this.message,\n name: this.name,\n // Microsoft\n description: this.description,\n number: this.number,\n // Mozilla\n fileName: this.fileName,\n lineNumber: this.lineNumber,\n columnNumber: this.columnNumber,\n stack: this.stack,\n // Axios\n config: this.config,\n code: this.code,\n status: this.response && this.response.status ? this.response.status : null\n };\n };\n return error;\n};\n","'use strict';\n\nvar utils = require('../utils');\n\n/**\n * Config-specific merge-function which creates a new config-object\n * by merging two configuration objects together.\n *\n * @param {Object} config1\n * @param {Object} config2\n * @returns {Object} New object resulting from merging config2 to config1\n */\nmodule.exports = function mergeConfig(config1, config2) {\n // eslint-disable-next-line no-param-reassign\n config2 = config2 || {};\n var config = {};\n\n function getMergedValue(target, source) {\n if (utils.isPlainObject(target) && utils.isPlainObject(source)) {\n return utils.merge(target, source);\n } else if (utils.isPlainObject(source)) {\n return utils.merge({}, source);\n } else if (utils.isArray(source)) {\n return source.slice();\n }\n return source;\n }\n\n // eslint-disable-next-line consistent-return\n function mergeDeepProperties(prop) {\n if (!utils.isUndefined(config2[prop])) {\n return getMergedValue(config1[prop], config2[prop]);\n } else if (!utils.isUndefined(config1[prop])) {\n return getMergedValue(undefined, config1[prop]);\n }\n }\n\n // eslint-disable-next-line consistent-return\n function valueFromConfig2(prop) {\n if (!utils.isUndefined(config2[prop])) {\n return getMergedValue(undefined, config2[prop]);\n }\n }\n\n // eslint-disable-next-line consistent-return\n function defaultToConfig2(prop) {\n if (!utils.isUndefined(config2[prop])) {\n return getMergedValue(undefined, config2[prop]);\n } else if (!utils.isUndefined(config1[prop])) {\n return getMergedValue(undefined, config1[prop]);\n }\n }\n\n // eslint-disable-next-line consistent-return\n function mergeDirectKeys(prop) {\n if (prop in config2) {\n return getMergedValue(config1[prop], config2[prop]);\n } else if (prop in config1) {\n return getMergedValue(undefined, config1[prop]);\n }\n }\n\n var mergeMap = {\n 'url': valueFromConfig2,\n 'method': valueFromConfig2,\n 'data': valueFromConfig2,\n 'baseURL': defaultToConfig2,\n 'transformRequest': defaultToConfig2,\n 'transformResponse': defaultToConfig2,\n 'paramsSerializer': defaultToConfig2,\n 'timeout': defaultToConfig2,\n 'timeoutMessage': defaultToConfig2,\n 'withCredentials': defaultToConfig2,\n 'adapter': defaultToConfig2,\n 'responseType': defaultToConfig2,\n 'xsrfCookieName': defaultToConfig2,\n 'xsrfHeaderName': defaultToConfig2,\n 'onUploadProgress': defaultToConfig2,\n 'onDownloadProgress': defaultToConfig2,\n 'decompress': defaultToConfig2,\n 'maxContentLength': defaultToConfig2,\n 'maxBodyLength': defaultToConfig2,\n 'transport': defaultToConfig2,\n 'httpAgent': defaultToConfig2,\n 'httpsAgent': defaultToConfig2,\n 'cancelToken': defaultToConfig2,\n 'socketPath': defaultToConfig2,\n 'responseEncoding': defaultToConfig2,\n 'validateStatus': mergeDirectKeys\n };\n\n utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {\n var merge = mergeMap[prop] || mergeDeepProperties;\n var configValue = merge(prop);\n (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);\n });\n\n return config;\n};\n","'use strict';\n\nvar createError = require('./createError');\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n */\nmodule.exports = function settle(resolve, reject, response) {\n var validateStatus = response.config.validateStatus;\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(createError(\n 'Request failed with status code ' + response.status,\n response.config,\n null,\n response.request,\n response\n ));\n }\n};\n","'use strict';\n\nvar utils = require('./../utils');\nvar defaults = require('./../defaults');\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Object|String} data The data to be transformed\n * @param {Array} headers The headers for the request or response\n * @param {Array|Function} fns A single function or Array of functions\n * @returns {*} The resulting transformed data\n */\nmodule.exports = function transformData(data, headers, fns) {\n var context = this || defaults;\n /*eslint no-param-reassign:0*/\n utils.forEach(fns, function transform(fn) {\n data = fn.call(context, data, headers);\n });\n\n return data;\n};\n","'use strict';\n\nvar utils = require('./utils');\nvar normalizeHeaderName = require('./helpers/normalizeHeaderName');\nvar enhanceError = require('./core/enhanceError');\n\nvar DEFAULT_CONTENT_TYPE = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nfunction setContentTypeIfUnset(headers, value) {\n if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n headers['Content-Type'] = value;\n }\n}\n\nfunction getDefaultAdapter() {\n var adapter;\n if (typeof XMLHttpRequest !== 'undefined') {\n // For browsers use XHR adapter\n adapter = require('./adapters/xhr');\n } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {\n // For node use HTTP adapter\n adapter = require('./adapters/http');\n }\n return adapter;\n}\n\nfunction stringifySafely(rawValue, parser, encoder) {\n if (utils.isString(rawValue)) {\n try {\n (parser || JSON.parse)(rawValue);\n return utils.trim(rawValue);\n } catch (e) {\n if (e.name !== 'SyntaxError') {\n throw e;\n }\n }\n }\n\n return (encoder || JSON.stringify)(rawValue);\n}\n\nvar defaults = {\n\n transitional: {\n silentJSONParsing: true,\n forcedJSONParsing: true,\n clarifyTimeoutError: false\n },\n\n adapter: getDefaultAdapter(),\n\n transformRequest: [function transformRequest(data, headers) {\n normalizeHeaderName(headers, 'Accept');\n normalizeHeaderName(headers, 'Content-Type');\n\n if (utils.isFormData(data) ||\n utils.isArrayBuffer(data) ||\n utils.isBuffer(data) ||\n utils.isStream(data) ||\n utils.isFile(data) ||\n utils.isBlob(data)\n ) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isURLSearchParams(data)) {\n setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n return data.toString();\n }\n if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {\n setContentTypeIfUnset(headers, 'application/json');\n return stringifySafely(data);\n }\n return data;\n }],\n\n transformResponse: [function transformResponse(data) {\n var transitional = this.transitional || defaults.transitional;\n var silentJSONParsing = transitional && transitional.silentJSONParsing;\n var forcedJSONParsing = transitional && transitional.forcedJSONParsing;\n var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';\n\n if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {\n try {\n return JSON.parse(data);\n } catch (e) {\n if (strictJSONParsing) {\n if (e.name === 'SyntaxError') {\n throw enhanceError(e, this, 'E_JSON_PARSE');\n }\n throw e;\n }\n }\n }\n\n return data;\n }],\n\n /**\n * A timeout in milliseconds to abort a request. If set to 0 (default) a\n * timeout is not created.\n */\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n\n maxContentLength: -1,\n maxBodyLength: -1,\n\n validateStatus: function validateStatus(status) {\n return status >= 200 && status < 300;\n },\n\n headers: {\n common: {\n 'Accept': 'application/json, text/plain, */*'\n }\n }\n};\n\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n defaults.headers[method] = {};\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n});\n\nmodule.exports = defaults;\n","module.exports = {\n \"version\": \"0.23.0\"\n};","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n","'use strict';\n\nvar utils = require('./../utils');\n\nfunction encode(val) {\n return encodeURIComponent(val).\n replace(/%3A/gi, ':').\n replace(/%24/g, '$').\n replace(/%2C/gi, ',').\n replace(/%20/g, '+').\n replace(/%5B/gi, '[').\n replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @returns {string} The formatted url\n */\nmodule.exports = function buildURL(url, params, paramsSerializer) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n\n var serializedParams;\n if (paramsSerializer) {\n serializedParams = paramsSerializer(params);\n } else if (utils.isURLSearchParams(params)) {\n serializedParams = params.toString();\n } else {\n var parts = [];\n\n utils.forEach(params, function serialize(val, key) {\n if (val === null || typeof val === 'undefined') {\n return;\n }\n\n if (utils.isArray(val)) {\n key = key + '[]';\n } else {\n val = [val];\n }\n\n utils.forEach(val, function parseValue(v) {\n if (utils.isDate(v)) {\n v = v.toISOString();\n } else if (utils.isObject(v)) {\n v = JSON.stringify(v);\n }\n parts.push(encode(key) + '=' + encode(v));\n });\n });\n\n serializedParams = parts.join('&');\n }\n\n if (serializedParams) {\n var hashmarkIndex = url.indexOf('#');\n if (hashmarkIndex !== -1) {\n url = url.slice(0, hashmarkIndex);\n }\n\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n};\n","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n * @returns {string} The combined URL\n */\nmodule.exports = function combineURLs(baseURL, relativeURL) {\n return relativeURL\n ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n : baseURL;\n};\n","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs support document.cookie\n (function standardBrowserEnv() {\n return {\n write: function write(name, value, expires, path, domain, secure) {\n var cookie = [];\n cookie.push(name + '=' + encodeURIComponent(value));\n\n if (utils.isNumber(expires)) {\n cookie.push('expires=' + new Date(expires).toGMTString());\n }\n\n if (utils.isString(path)) {\n cookie.push('path=' + path);\n }\n\n if (utils.isString(domain)) {\n cookie.push('domain=' + domain);\n }\n\n if (secure === true) {\n cookie.push('secure');\n }\n\n document.cookie = cookie.join('; ');\n },\n\n read: function read(name) {\n var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove: function remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n };\n })() :\n\n // Non standard browser env (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return {\n write: function write() {},\n read: function read() { return null; },\n remove: function remove() {}\n };\n })()\n);\n","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nmodule.exports = function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n};\n","'use strict';\n\n/**\n * Determines whether the payload is an error thrown by Axios\n *\n * @param {*} payload The value to test\n * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false\n */\nmodule.exports = function isAxiosError(payload) {\n return (typeof payload === 'object') && (payload.isAxiosError === true);\n};\n","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n","'use strict';\n\nvar utils = require('../utils');\n\nmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n utils.forEach(headers, function processHeader(value, name) {\n if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n headers[normalizedName] = value;\n delete headers[name];\n }\n });\n};\n","'use strict';\n\nvar utils = require('./../utils');\n\n// Headers whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\nvar ignoreDuplicateOf = [\n 'age', 'authorization', 'content-length', 'content-type', 'etag',\n 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n 'referer', 'retry-after', 'user-agent'\n];\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n return;\n }\n if (key === 'set-cookie') {\n parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n } else {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n }\n });\n\n return parsed;\n};\n","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n * @returns {Function}\n */\nmodule.exports = function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n};\n","'use strict';\n\nvar VERSION = require('../env/data').version;\n\nvar validators = {};\n\n// eslint-disable-next-line func-names\n['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {\n validators[type] = function validator(thing) {\n return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;\n };\n});\n\nvar deprecatedWarnings = {};\n\n/**\n * Transitional option validator\n * @param {function|boolean?} validator - set to false if the transitional option has been removed\n * @param {string?} version - deprecated version / removed since version\n * @param {string?} message - some message with additional info\n * @returns {function}\n */\nvalidators.transitional = function transitional(validator, version, message) {\n function formatMessage(opt, desc) {\n return '[Axios v' + VERSION + '] Transitional option \\'' + opt + '\\'' + desc + (message ? '. ' + message : '');\n }\n\n // eslint-disable-next-line func-names\n return function(value, opt, opts) {\n if (validator === false) {\n throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));\n }\n\n if (version && !deprecatedWarnings[opt]) {\n deprecatedWarnings[opt] = true;\n // eslint-disable-next-line no-console\n console.warn(\n formatMessage(\n opt,\n ' has been deprecated since v' + version + ' and will be removed in the near future'\n )\n );\n }\n\n return validator ? validator(value, opt, opts) : true;\n };\n};\n\n/**\n * Assert object's properties type\n * @param {object} options\n * @param {object} schema\n * @param {boolean?} allowUnknown\n */\n\nfunction assertOptions(options, schema, allowUnknown) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n var keys = Object.keys(options);\n var i = keys.length;\n while (i-- > 0) {\n var opt = keys[i];\n var validator = schema[opt];\n if (validator) {\n var value = options[opt];\n var result = value === undefined || validator(value, opt, options);\n if (result !== true) {\n throw new TypeError('option ' + opt + ' must be ' + result);\n }\n continue;\n }\n if (allowUnknown !== true) {\n throw Error('Unknown option ' + opt);\n }\n }\n}\n\nmodule.exports = {\n assertOptions: assertOptions,\n validators: validators\n};\n","'use strict';\n\nvar bind = require('./helpers/bind');\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is a Buffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Buffer, otherwise false\n */\nfunction isBuffer(val) {\n return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)\n && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return (typeof FormData !== 'undefined') && (val instanceof FormData);\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a plain Object\n *\n * @param {Object} val The value to test\n * @return {boolean} True if value is a plain Object, otherwise false\n */\nfunction isPlainObject(val) {\n if (toString.call(val) !== '[object Object]') {\n return false;\n }\n\n var prototype = Object.getPrototypeOf(val);\n return prototype === null || prototype === Object.prototype;\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Determine if a value is a Function\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\nfunction isFunction(val) {\n return toString.call(val) === '[object Function]';\n}\n\n/**\n * Determine if a value is a Stream\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Stream, otherwise false\n */\nfunction isStream(val) {\n return isObject(val) && isFunction(val.pipe);\n}\n\n/**\n * Determine if a value is a URLSearchParams object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n */\nfunction isURLSearchParams(val) {\n return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.trim ? str.trim() : str.replace(/^\\s+|\\s+$/g, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * navigator.product -> 'ReactNative'\n * nativescript\n * navigator.product -> 'NativeScript' or 'NS'\n */\nfunction isStandardBrowserEnv() {\n if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||\n navigator.product === 'NativeScript' ||\n navigator.product === 'NS')) {\n return false;\n }\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object') {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (isPlainObject(result[key]) && isPlainObject(val)) {\n result[key] = merge(result[key], val);\n } else if (isPlainObject(val)) {\n result[key] = merge({}, val);\n } else if (isArray(val)) {\n result[key] = val.slice();\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\n/**\n * Extends object a by mutably adding to it the properties of object b.\n *\n * @param {Object} a The object to be extended\n * @param {Object} b The object to copy properties from\n * @param {Object} thisArg The object to bind function to\n * @return {Object} The resulting value of object a\n */\nfunction extend(a, b, thisArg) {\n forEach(b, function assignValue(val, key) {\n if (thisArg && typeof val === 'function') {\n a[key] = bind(val, thisArg);\n } else {\n a[key] = val;\n }\n });\n return a;\n}\n\n/**\n * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)\n *\n * @param {string} content with BOM\n * @return {string} content value without BOM\n */\nfunction stripBOM(content) {\n if (content.charCodeAt(0) === 0xFEFF) {\n content = content.slice(1);\n }\n return content;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isBuffer: isBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isPlainObject: isPlainObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isFunction: isFunction,\n isStream: isStream,\n isURLSearchParams: isURLSearchParams,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n extend: extend,\n trim: trim,\n stripBOM: stripBOM\n};\n","'use strict';\n\nvar crypto_hash_sha512 = require('tweetnacl').lowlevel.crypto_hash;\n\n/*\n * This file is a 1:1 port from the OpenBSD blowfish.c and bcrypt_pbkdf.c. As a\n * result, it retains the original copyright and license. The two files are\n * under slightly different (but compatible) licenses, and are here combined in\n * one file.\n *\n * Credit for the actual porting work goes to:\n * Devi Mandiri \n */\n\n/*\n * The Blowfish portions are under the following license:\n *\n * Blowfish block cipher for OpenBSD\n * Copyright 1997 Niels Provos \n * All rights reserved.\n *\n * Implementation advice by David Mazieres .\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. The name of the author may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*\n * The bcrypt_pbkdf portions are under the following license:\n *\n * Copyright (c) 2013 Ted Unangst \n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n/*\n * Performance improvements (Javascript-specific):\n *\n * Copyright 2016, Joyent Inc\n * Author: Alex Wilson \n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n// Ported from OpenBSD bcrypt_pbkdf.c v1.9\n\nvar BLF_J = 0;\n\nvar Blowfish = function() {\n this.S = [\n new Uint32Array([\n 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,\n 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,\n 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,\n 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,\n 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,\n 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,\n 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,\n 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,\n 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,\n 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,\n 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,\n 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,\n 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,\n 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,\n 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,\n 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,\n 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,\n 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,\n 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,\n 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,\n 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,\n 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,\n 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,\n 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,\n 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,\n 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,\n 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,\n 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,\n 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,\n 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,\n 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,\n 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,\n 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,\n 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,\n 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,\n 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,\n 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,\n 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,\n 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,\n 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,\n 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,\n 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,\n 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,\n 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,\n 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,\n 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,\n 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,\n 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,\n 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,\n 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,\n 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,\n 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,\n 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,\n 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,\n 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,\n 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,\n 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,\n 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,\n 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,\n 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,\n 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,\n 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,\n 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,\n 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a]),\n new Uint32Array([\n 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,\n 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,\n 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,\n 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,\n 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,\n 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,\n 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,\n 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,\n 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,\n 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,\n 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,\n 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,\n 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,\n 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,\n 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,\n 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,\n 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,\n 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,\n 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,\n 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,\n 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,\n 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,\n 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,\n 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,\n 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,\n 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,\n 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,\n 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,\n 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,\n 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,\n 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,\n 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,\n 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,\n 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,\n 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,\n 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,\n 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,\n 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,\n 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,\n 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,\n 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,\n 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,\n 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,\n 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,\n 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,\n 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,\n 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,\n 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,\n 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,\n 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,\n 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,\n 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,\n 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,\n 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,\n 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,\n 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,\n 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,\n 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,\n 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,\n 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,\n 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,\n 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,\n 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,\n 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7]),\n new Uint32Array([\n 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,\n 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,\n 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,\n 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,\n 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,\n 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,\n 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,\n 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,\n 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,\n 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,\n 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,\n 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,\n 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,\n 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,\n 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,\n 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,\n 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,\n 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,\n 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,\n 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,\n 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,\n 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,\n 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,\n 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,\n 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,\n 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,\n 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,\n 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,\n 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,\n 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,\n 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,\n 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,\n 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,\n 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,\n 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,\n 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,\n 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,\n 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,\n 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,\n 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,\n 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,\n 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,\n 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,\n 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,\n 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,\n 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,\n 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,\n 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,\n 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,\n 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,\n 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,\n 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,\n 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,\n 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,\n 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,\n 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,\n 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,\n 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,\n 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,\n 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,\n 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,\n 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,\n 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,\n 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0]),\n new Uint32Array([\n 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,\n 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,\n 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,\n 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,\n 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,\n 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,\n 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,\n 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,\n 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,\n 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,\n 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,\n 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,\n 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,\n 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,\n 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,\n 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,\n 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,\n 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,\n 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,\n 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,\n 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,\n 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,\n 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,\n 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,\n 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,\n 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,\n 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,\n 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,\n 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,\n 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,\n 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,\n 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,\n 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,\n 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,\n 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,\n 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,\n 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,\n 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,\n 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,\n 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,\n 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,\n 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,\n 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,\n 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,\n 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,\n 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,\n 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,\n 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,\n 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,\n 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,\n 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,\n 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,\n 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,\n 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,\n 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,\n 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,\n 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,\n 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,\n 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,\n 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,\n 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,\n 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,\n 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,\n 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6])\n ];\n this.P = new Uint32Array([\n 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,\n 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,\n 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,\n 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,\n 0x9216d5d9, 0x8979fb1b]);\n};\n\nfunction F(S, x8, i) {\n return (((S[0][x8[i+3]] +\n S[1][x8[i+2]]) ^\n S[2][x8[i+1]]) +\n S[3][x8[i]]);\n};\n\nBlowfish.prototype.encipher = function(x, x8) {\n if (x8 === undefined) {\n x8 = new Uint8Array(x.buffer);\n if (x.byteOffset !== 0)\n x8 = x8.subarray(x.byteOffset);\n }\n x[0] ^= this.P[0];\n for (var i = 1; i < 16; i += 2) {\n x[1] ^= F(this.S, x8, 0) ^ this.P[i];\n x[0] ^= F(this.S, x8, 4) ^ this.P[i+1];\n }\n var t = x[0];\n x[0] = x[1] ^ this.P[17];\n x[1] = t;\n};\n\nBlowfish.prototype.decipher = function(x) {\n var x8 = new Uint8Array(x.buffer);\n if (x.byteOffset !== 0)\n x8 = x8.subarray(x.byteOffset);\n x[0] ^= this.P[17];\n for (var i = 16; i > 0; i -= 2) {\n x[1] ^= F(this.S, x8, 0) ^ this.P[i];\n x[0] ^= F(this.S, x8, 4) ^ this.P[i-1];\n }\n var t = x[0];\n x[0] = x[1] ^ this.P[0];\n x[1] = t;\n};\n\nfunction stream2word(data, databytes){\n var i, temp = 0;\n for (i = 0; i < 4; i++, BLF_J++) {\n if (BLF_J >= databytes) BLF_J = 0;\n temp = (temp << 8) | data[BLF_J];\n }\n return temp;\n};\n\nBlowfish.prototype.expand0state = function(key, keybytes) {\n var d = new Uint32Array(2), i, k;\n var d8 = new Uint8Array(d.buffer);\n\n for (i = 0, BLF_J = 0; i < 18; i++) {\n this.P[i] ^= stream2word(key, keybytes);\n }\n BLF_J = 0;\n\n for (i = 0; i < 18; i += 2) {\n this.encipher(d, d8);\n this.P[i] = d[0];\n this.P[i+1] = d[1];\n }\n\n for (i = 0; i < 4; i++) {\n for (k = 0; k < 256; k += 2) {\n this.encipher(d, d8);\n this.S[i][k] = d[0];\n this.S[i][k+1] = d[1];\n }\n }\n};\n\nBlowfish.prototype.expandstate = function(data, databytes, key, keybytes) {\n var d = new Uint32Array(2), i, k;\n\n for (i = 0, BLF_J = 0; i < 18; i++) {\n this.P[i] ^= stream2word(key, keybytes);\n }\n\n for (i = 0, BLF_J = 0; i < 18; i += 2) {\n d[0] ^= stream2word(data, databytes);\n d[1] ^= stream2word(data, databytes);\n this.encipher(d);\n this.P[i] = d[0];\n this.P[i+1] = d[1];\n }\n\n for (i = 0; i < 4; i++) {\n for (k = 0; k < 256; k += 2) {\n d[0] ^= stream2word(data, databytes);\n d[1] ^= stream2word(data, databytes);\n this.encipher(d);\n this.S[i][k] = d[0];\n this.S[i][k+1] = d[1];\n }\n }\n BLF_J = 0;\n};\n\nBlowfish.prototype.enc = function(data, blocks) {\n for (var i = 0; i < blocks; i++) {\n this.encipher(data.subarray(i*2));\n }\n};\n\nBlowfish.prototype.dec = function(data, blocks) {\n for (var i = 0; i < blocks; i++) {\n this.decipher(data.subarray(i*2));\n }\n};\n\nvar BCRYPT_BLOCKS = 8,\n BCRYPT_HASHSIZE = 32;\n\nfunction bcrypt_hash(sha2pass, sha2salt, out) {\n var state = new Blowfish(),\n cdata = new Uint32Array(BCRYPT_BLOCKS), i,\n ciphertext = new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,\n 99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,\n 105,116,101]); //\"OxychromaticBlowfishSwatDynamite\"\n\n state.expandstate(sha2salt, 64, sha2pass, 64);\n for (i = 0; i < 64; i++) {\n state.expand0state(sha2salt, 64);\n state.expand0state(sha2pass, 64);\n }\n\n for (i = 0; i < BCRYPT_BLOCKS; i++)\n cdata[i] = stream2word(ciphertext, ciphertext.byteLength);\n for (i = 0; i < 64; i++)\n state.enc(cdata, cdata.byteLength / 8);\n\n for (i = 0; i < BCRYPT_BLOCKS; i++) {\n out[4*i+3] = cdata[i] >>> 24;\n out[4*i+2] = cdata[i] >>> 16;\n out[4*i+1] = cdata[i] >>> 8;\n out[4*i+0] = cdata[i];\n }\n};\n\nfunction bcrypt_pbkdf(pass, passlen, salt, saltlen, key, keylen, rounds) {\n var sha2pass = new Uint8Array(64),\n sha2salt = new Uint8Array(64),\n out = new Uint8Array(BCRYPT_HASHSIZE),\n tmpout = new Uint8Array(BCRYPT_HASHSIZE),\n countsalt = new Uint8Array(saltlen+4),\n i, j, amt, stride, dest, count,\n origkeylen = keylen;\n\n if (rounds < 1)\n return -1;\n if (passlen === 0 || saltlen === 0 || keylen === 0 ||\n keylen > (out.byteLength * out.byteLength) || saltlen > (1<<20))\n return -1;\n\n stride = Math.floor((keylen + out.byteLength - 1) / out.byteLength);\n amt = Math.floor((keylen + stride - 1) / stride);\n\n for (i = 0; i < saltlen; i++)\n countsalt[i] = salt[i];\n\n crypto_hash_sha512(sha2pass, pass, passlen);\n\n for (count = 1; keylen > 0; count++) {\n countsalt[saltlen+0] = count >>> 24;\n countsalt[saltlen+1] = count >>> 16;\n countsalt[saltlen+2] = count >>> 8;\n countsalt[saltlen+3] = count;\n\n crypto_hash_sha512(sha2salt, countsalt, saltlen + 4);\n bcrypt_hash(sha2pass, sha2salt, tmpout);\n for (i = out.byteLength; i--;)\n out[i] = tmpout[i];\n\n for (i = 1; i < rounds; i++) {\n crypto_hash_sha512(sha2salt, tmpout, tmpout.byteLength);\n bcrypt_hash(sha2pass, sha2salt, tmpout);\n for (j = 0; j < out.byteLength; j++)\n out[j] ^= tmpout[j];\n }\n\n amt = Math.min(amt, keylen);\n for (i = 0; i < amt; i++) {\n dest = i * stride + (count - 1);\n if (dest >= origkeylen)\n break;\n key[dest] = out[i];\n }\n keylen -= i;\n }\n\n return 0;\n};\n\nmodule.exports = {\n BLOCKS: BCRYPT_BLOCKS,\n HASHSIZE: BCRYPT_HASHSIZE,\n hash: bcrypt_hash,\n pbkdf: bcrypt_pbkdf\n};\n","var register = require('./lib/register')\nvar addHook = require('./lib/add')\nvar removeHook = require('./lib/remove')\n\n// bind with array of arguments: https://stackoverflow.com/a/21792913\nvar bind = Function.bind\nvar bindable = bind.bind(bind)\n\nfunction bindApi (hook, state, name) {\n var removeHookRef = bindable(removeHook, null).apply(null, name ? [state, name] : [state])\n hook.api = { remove: removeHookRef }\n hook.remove = removeHookRef\n\n ;['before', 'error', 'after', 'wrap'].forEach(function (kind) {\n var args = name ? [state, kind, name] : [state, kind]\n hook[kind] = hook.api[kind] = bindable(addHook, null).apply(null, args)\n })\n}\n\nfunction HookSingular () {\n var singularHookName = 'h'\n var singularHookState = {\n registry: {}\n }\n var singularHook = register.bind(null, singularHookState, singularHookName)\n bindApi(singularHook, singularHookState, singularHookName)\n return singularHook\n}\n\nfunction HookCollection () {\n var state = {\n registry: {}\n }\n\n var hook = register.bind(null, state)\n bindApi(hook, state)\n\n return hook\n}\n\nvar collectionHookDeprecationMessageDisplayed = false\nfunction Hook () {\n if (!collectionHookDeprecationMessageDisplayed) {\n console.warn('[before-after-hook]: \"Hook()\" repurposing warning, use \"Hook.Collection()\". Read more: https://git.io/upgrade-before-after-hook-to-1.4')\n collectionHookDeprecationMessageDisplayed = true\n }\n return HookCollection()\n}\n\nHook.Singular = HookSingular.bind()\nHook.Collection = HookCollection.bind()\n\nmodule.exports = Hook\n// expose constructors as a named property for TypeScript\nmodule.exports.Hook = Hook\nmodule.exports.Singular = Hook.Singular\nmodule.exports.Collection = Hook.Collection\n","module.exports = addHook;\n\nfunction addHook(state, kind, name, hook) {\n var orig = hook;\n if (!state.registry[name]) {\n state.registry[name] = [];\n }\n\n if (kind === \"before\") {\n hook = function (method, options) {\n return Promise.resolve()\n .then(orig.bind(null, options))\n .then(method.bind(null, options));\n };\n }\n\n if (kind === \"after\") {\n hook = function (method, options) {\n var result;\n return Promise.resolve()\n .then(method.bind(null, options))\n .then(function (result_) {\n result = result_;\n return orig(result, options);\n })\n .then(function () {\n return result;\n });\n };\n }\n\n if (kind === \"error\") {\n hook = function (method, options) {\n return Promise.resolve()\n .then(method.bind(null, options))\n .catch(function (error) {\n return orig(error, options);\n });\n };\n }\n\n state.registry[name].push({\n hook: hook,\n orig: orig,\n });\n}\n","module.exports = register;\n\nfunction register(state, name, method, options) {\n if (typeof method !== \"function\") {\n throw new Error(\"method for before hook must be a function\");\n }\n\n if (!options) {\n options = {};\n }\n\n if (Array.isArray(name)) {\n return name.reverse().reduce(function (callback, name) {\n return register.bind(null, state, name, callback, options);\n }, method)();\n }\n\n return Promise.resolve().then(function () {\n if (!state.registry[name]) {\n return method(options);\n }\n\n return state.registry[name].reduce(function (method, registered) {\n return registered.hook.bind(null, method, options);\n }, method)();\n });\n}\n","module.exports = removeHook;\n\nfunction removeHook(state, name, method) {\n if (!state.registry[name]) {\n return;\n }\n\n var index = state.registry[name]\n .map(function (registered) {\n return registered.orig;\n })\n .indexOf(method);\n\n if (index === -1) {\n return;\n }\n\n state.registry[name].splice(index, 1);\n}\n","'use strict'\n\nconst { Buffer } = require('buffer')\nconst symbol = Symbol.for('BufferList')\n\nfunction BufferList (buf) {\n if (!(this instanceof BufferList)) {\n return new BufferList(buf)\n }\n\n BufferList._init.call(this, buf)\n}\n\nBufferList._init = function _init (buf) {\n Object.defineProperty(this, symbol, { value: true })\n\n this._bufs = []\n this.length = 0\n\n if (buf) {\n this.append(buf)\n }\n}\n\nBufferList.prototype._new = function _new (buf) {\n return new BufferList(buf)\n}\n\nBufferList.prototype._offset = function _offset (offset) {\n if (offset === 0) {\n return [0, 0]\n }\n\n let tot = 0\n\n for (let i = 0; i < this._bufs.length; i++) {\n const _t = tot + this._bufs[i].length\n if (offset < _t || i === this._bufs.length - 1) {\n return [i, offset - tot]\n }\n tot = _t\n }\n}\n\nBufferList.prototype._reverseOffset = function (blOffset) {\n const bufferId = blOffset[0]\n let offset = blOffset[1]\n\n for (let i = 0; i < bufferId; i++) {\n offset += this._bufs[i].length\n }\n\n return offset\n}\n\nBufferList.prototype.get = function get (index) {\n if (index > this.length || index < 0) {\n return undefined\n }\n\n const offset = this._offset(index)\n\n return this._bufs[offset[0]][offset[1]]\n}\n\nBufferList.prototype.slice = function slice (start, end) {\n if (typeof start === 'number' && start < 0) {\n start += this.length\n }\n\n if (typeof end === 'number' && end < 0) {\n end += this.length\n }\n\n return this.copy(null, 0, start, end)\n}\n\nBufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {\n if (typeof srcStart !== 'number' || srcStart < 0) {\n srcStart = 0\n }\n\n if (typeof srcEnd !== 'number' || srcEnd > this.length) {\n srcEnd = this.length\n }\n\n if (srcStart >= this.length) {\n return dst || Buffer.alloc(0)\n }\n\n if (srcEnd <= 0) {\n return dst || Buffer.alloc(0)\n }\n\n const copy = !!dst\n const off = this._offset(srcStart)\n const len = srcEnd - srcStart\n let bytes = len\n let bufoff = (copy && dstStart) || 0\n let start = off[1]\n\n // copy/slice everything\n if (srcStart === 0 && srcEnd === this.length) {\n if (!copy) {\n // slice, but full concat if multiple buffers\n return this._bufs.length === 1\n ? this._bufs[0]\n : Buffer.concat(this._bufs, this.length)\n }\n\n // copy, need to copy individual buffers\n for (let i = 0; i < this._bufs.length; i++) {\n this._bufs[i].copy(dst, bufoff)\n bufoff += this._bufs[i].length\n }\n\n return dst\n }\n\n // easy, cheap case where it's a subset of one of the buffers\n if (bytes <= this._bufs[off[0]].length - start) {\n return copy\n ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)\n : this._bufs[off[0]].slice(start, start + bytes)\n }\n\n if (!copy) {\n // a slice, we need something to copy in to\n dst = Buffer.allocUnsafe(len)\n }\n\n for (let i = off[0]; i < this._bufs.length; i++) {\n const l = this._bufs[i].length - start\n\n if (bytes > l) {\n this._bufs[i].copy(dst, bufoff, start)\n bufoff += l\n } else {\n this._bufs[i].copy(dst, bufoff, start, start + bytes)\n bufoff += l\n break\n }\n\n bytes -= l\n\n if (start) {\n start = 0\n }\n }\n\n // safeguard so that we don't return uninitialized memory\n if (dst.length > bufoff) return dst.slice(0, bufoff)\n\n return dst\n}\n\nBufferList.prototype.shallowSlice = function shallowSlice (start, end) {\n start = start || 0\n end = typeof end !== 'number' ? this.length : end\n\n if (start < 0) {\n start += this.length\n }\n\n if (end < 0) {\n end += this.length\n }\n\n if (start === end) {\n return this._new()\n }\n\n const startOffset = this._offset(start)\n const endOffset = this._offset(end)\n const buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)\n\n if (endOffset[1] === 0) {\n buffers.pop()\n } else {\n buffers[buffers.length - 1] = buffers[buffers.length - 1].slice(0, endOffset[1])\n }\n\n if (startOffset[1] !== 0) {\n buffers[0] = buffers[0].slice(startOffset[1])\n }\n\n return this._new(buffers)\n}\n\nBufferList.prototype.toString = function toString (encoding, start, end) {\n return this.slice(start, end).toString(encoding)\n}\n\nBufferList.prototype.consume = function consume (bytes) {\n // first, normalize the argument, in accordance with how Buffer does it\n bytes = Math.trunc(bytes)\n // do nothing if not a positive number\n if (Number.isNaN(bytes) || bytes <= 0) return this\n\n while (this._bufs.length) {\n if (bytes >= this._bufs[0].length) {\n bytes -= this._bufs[0].length\n this.length -= this._bufs[0].length\n this._bufs.shift()\n } else {\n this._bufs[0] = this._bufs[0].slice(bytes)\n this.length -= bytes\n break\n }\n }\n\n return this\n}\n\nBufferList.prototype.duplicate = function duplicate () {\n const copy = this._new()\n\n for (let i = 0; i < this._bufs.length; i++) {\n copy.append(this._bufs[i])\n }\n\n return copy\n}\n\nBufferList.prototype.append = function append (buf) {\n if (buf == null) {\n return this\n }\n\n if (buf.buffer) {\n // append a view of the underlying ArrayBuffer\n this._appendBuffer(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength))\n } else if (Array.isArray(buf)) {\n for (let i = 0; i < buf.length; i++) {\n this.append(buf[i])\n }\n } else if (this._isBufferList(buf)) {\n // unwrap argument into individual BufferLists\n for (let i = 0; i < buf._bufs.length; i++) {\n this.append(buf._bufs[i])\n }\n } else {\n // coerce number arguments to strings, since Buffer(number) does\n // uninitialized memory allocation\n if (typeof buf === 'number') {\n buf = buf.toString()\n }\n\n this._appendBuffer(Buffer.from(buf))\n }\n\n return this\n}\n\nBufferList.prototype._appendBuffer = function appendBuffer (buf) {\n this._bufs.push(buf)\n this.length += buf.length\n}\n\nBufferList.prototype.indexOf = function (search, offset, encoding) {\n if (encoding === undefined && typeof offset === 'string') {\n encoding = offset\n offset = undefined\n }\n\n if (typeof search === 'function' || Array.isArray(search)) {\n throw new TypeError('The \"value\" argument must be one of type string, Buffer, BufferList, or Uint8Array.')\n } else if (typeof search === 'number') {\n search = Buffer.from([search])\n } else if (typeof search === 'string') {\n search = Buffer.from(search, encoding)\n } else if (this._isBufferList(search)) {\n search = search.slice()\n } else if (Array.isArray(search.buffer)) {\n search = Buffer.from(search.buffer, search.byteOffset, search.byteLength)\n } else if (!Buffer.isBuffer(search)) {\n search = Buffer.from(search)\n }\n\n offset = Number(offset || 0)\n\n if (isNaN(offset)) {\n offset = 0\n }\n\n if (offset < 0) {\n offset = this.length + offset\n }\n\n if (offset < 0) {\n offset = 0\n }\n\n if (search.length === 0) {\n return offset > this.length ? this.length : offset\n }\n\n const blOffset = this._offset(offset)\n let blIndex = blOffset[0] // index of which internal buffer we're working on\n let buffOffset = blOffset[1] // offset of the internal buffer we're working on\n\n // scan over each buffer\n for (; blIndex < this._bufs.length; blIndex++) {\n const buff = this._bufs[blIndex]\n\n while (buffOffset < buff.length) {\n const availableWindow = buff.length - buffOffset\n\n if (availableWindow >= search.length) {\n const nativeSearchResult = buff.indexOf(search, buffOffset)\n\n if (nativeSearchResult !== -1) {\n return this._reverseOffset([blIndex, nativeSearchResult])\n }\n\n buffOffset = buff.length - search.length + 1 // end of native search window\n } else {\n const revOffset = this._reverseOffset([blIndex, buffOffset])\n\n if (this._match(revOffset, search)) {\n return revOffset\n }\n\n buffOffset++\n }\n }\n\n buffOffset = 0\n }\n\n return -1\n}\n\nBufferList.prototype._match = function (offset, search) {\n if (this.length - offset < search.length) {\n return false\n }\n\n for (let searchOffset = 0; searchOffset < search.length; searchOffset++) {\n if (this.get(offset + searchOffset) !== search[searchOffset]) {\n return false\n }\n }\n return true\n}\n\n;(function () {\n const methods = {\n readDoubleBE: 8,\n readDoubleLE: 8,\n readFloatBE: 4,\n readFloatLE: 4,\n readInt32BE: 4,\n readInt32LE: 4,\n readUInt32BE: 4,\n readUInt32LE: 4,\n readInt16BE: 2,\n readInt16LE: 2,\n readUInt16BE: 2,\n readUInt16LE: 2,\n readInt8: 1,\n readUInt8: 1,\n readIntBE: null,\n readIntLE: null,\n readUIntBE: null,\n readUIntLE: null\n }\n\n for (const m in methods) {\n (function (m) {\n if (methods[m] === null) {\n BufferList.prototype[m] = function (offset, byteLength) {\n return this.slice(offset, offset + byteLength)[m](0, byteLength)\n }\n } else {\n BufferList.prototype[m] = function (offset = 0) {\n return this.slice(offset, offset + methods[m])[m](0)\n }\n }\n }(m))\n }\n}())\n\n// Used internally by the class and also as an indicator of this object being\n// a `BufferList`. It's not possible to use `instanceof BufferList` in a browser\n// environment because there could be multiple different copies of the\n// BufferList class and some `BufferList`s might be `BufferList`s.\nBufferList.prototype._isBufferList = function _isBufferList (b) {\n return b instanceof BufferList || BufferList.isBufferList(b)\n}\n\nBufferList.isBufferList = function isBufferList (b) {\n return b != null && b[symbol]\n}\n\nmodule.exports = BufferList\n","'use strict'\n\nconst DuplexStream = require('readable-stream').Duplex\nconst inherits = require('inherits')\nconst BufferList = require('./BufferList')\n\nfunction BufferListStream (callback) {\n if (!(this instanceof BufferListStream)) {\n return new BufferListStream(callback)\n }\n\n if (typeof callback === 'function') {\n this._callback = callback\n\n const piper = function piper (err) {\n if (this._callback) {\n this._callback(err)\n this._callback = null\n }\n }.bind(this)\n\n this.on('pipe', function onPipe (src) {\n src.on('error', piper)\n })\n this.on('unpipe', function onUnpipe (src) {\n src.removeListener('error', piper)\n })\n\n callback = null\n }\n\n BufferList._init.call(this, callback)\n DuplexStream.call(this)\n}\n\ninherits(BufferListStream, DuplexStream)\nObject.assign(BufferListStream.prototype, BufferList.prototype)\n\nBufferListStream.prototype._new = function _new (callback) {\n return new BufferListStream(callback)\n}\n\nBufferListStream.prototype._write = function _write (buf, encoding, callback) {\n this._appendBuffer(buf)\n\n if (typeof callback === 'function') {\n callback()\n }\n}\n\nBufferListStream.prototype._read = function _read (size) {\n if (!this.length) {\n return this.push(null)\n }\n\n size = Math.min(size, this.length)\n this.push(this.slice(0, size))\n this.consume(size)\n}\n\nBufferListStream.prototype.end = function end (chunk) {\n DuplexStream.prototype.end.call(this, chunk)\n\n if (this._callback) {\n this._callback(null, this.slice())\n this._callback = null\n }\n}\n\nBufferListStream.prototype._destroy = function _destroy (err, cb) {\n this._bufs.length = 0\n this.length = 0\n cb(err)\n}\n\nBufferListStream.prototype._isBufferList = function _isBufferList (b) {\n return b instanceof BufferListStream || b instanceof BufferList || BufferListStream.isBufferList(b)\n}\n\nBufferListStream.isBufferList = BufferList.isBufferList\n\nmodule.exports = BufferListStream\nmodule.exports.BufferListStream = BufferListStream\nmodule.exports.BufferList = BufferList\n","'use strict'\nconst fs = require('fs')\nconst path = require('path')\n\n/* istanbul ignore next */\nconst LCHOWN = fs.lchown ? 'lchown' : 'chown'\n/* istanbul ignore next */\nconst LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'\n\n/* istanbul ignore next */\nconst needEISDIRHandled = fs.lchown &&\n !process.version.match(/v1[1-9]+\\./) &&\n !process.version.match(/v10\\.[6-9]/)\n\nconst lchownSync = (path, uid, gid) => {\n try {\n return fs[LCHOWNSYNC](path, uid, gid)\n } catch (er) {\n if (er.code !== 'ENOENT')\n throw er\n }\n}\n\n/* istanbul ignore next */\nconst chownSync = (path, uid, gid) => {\n try {\n return fs.chownSync(path, uid, gid)\n } catch (er) {\n if (er.code !== 'ENOENT')\n throw er\n }\n}\n\n/* istanbul ignore next */\nconst handleEISDIR =\n needEISDIRHandled ? (path, uid, gid, cb) => er => {\n // Node prior to v10 had a very questionable implementation of\n // fs.lchown, which would always try to call fs.open on a directory\n // Fall back to fs.chown in those cases.\n if (!er || er.code !== 'EISDIR')\n cb(er)\n else\n fs.chown(path, uid, gid, cb)\n }\n : (_, __, ___, cb) => cb\n\n/* istanbul ignore next */\nconst handleEISDirSync =\n needEISDIRHandled ? (path, uid, gid) => {\n try {\n return lchownSync(path, uid, gid)\n } catch (er) {\n if (er.code !== 'EISDIR')\n throw er\n chownSync(path, uid, gid)\n }\n }\n : (path, uid, gid) => lchownSync(path, uid, gid)\n\n// fs.readdir could only accept an options object as of node v6\nconst nodeVersion = process.version\nlet readdir = (path, options, cb) => fs.readdir(path, options, cb)\nlet readdirSync = (path, options) => fs.readdirSync(path, options)\n/* istanbul ignore next */\nif (/^v4\\./.test(nodeVersion))\n readdir = (path, options, cb) => fs.readdir(path, cb)\n\nconst chown = (cpath, uid, gid, cb) => {\n fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, er => {\n // Skip ENOENT error\n cb(er && er.code !== 'ENOENT' ? er : null)\n }))\n}\n\nconst chownrKid = (p, child, uid, gid, cb) => {\n if (typeof child === 'string')\n return fs.lstat(path.resolve(p, child), (er, stats) => {\n // Skip ENOENT error\n if (er)\n return cb(er.code !== 'ENOENT' ? er : null)\n stats.name = child\n chownrKid(p, stats, uid, gid, cb)\n })\n\n if (child.isDirectory()) {\n chownr(path.resolve(p, child.name), uid, gid, er => {\n if (er)\n return cb(er)\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n })\n } else {\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n }\n}\n\n\nconst chownr = (p, uid, gid, cb) => {\n readdir(p, { withFileTypes: true }, (er, children) => {\n // any error other than ENOTDIR or ENOTSUP means it's not readable,\n // or doesn't exist. give up.\n if (er) {\n if (er.code === 'ENOENT')\n return cb()\n else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')\n return cb(er)\n }\n if (er || !children.length)\n return chown(p, uid, gid, cb)\n\n let len = children.length\n let errState = null\n const then = er => {\n if (errState)\n return\n if (er)\n return cb(errState = er)\n if (-- len === 0)\n return chown(p, uid, gid, cb)\n }\n\n children.forEach(child => chownrKid(p, child, uid, gid, then))\n })\n}\n\nconst chownrKidSync = (p, child, uid, gid) => {\n if (typeof child === 'string') {\n try {\n const stats = fs.lstatSync(path.resolve(p, child))\n stats.name = child\n child = stats\n } catch (er) {\n if (er.code === 'ENOENT')\n return\n else\n throw er\n }\n }\n\n if (child.isDirectory())\n chownrSync(path.resolve(p, child.name), uid, gid)\n\n handleEISDirSync(path.resolve(p, child.name), uid, gid)\n}\n\nconst chownrSync = (p, uid, gid) => {\n let children\n try {\n children = readdirSync(p, { withFileTypes: true })\n } catch (er) {\n if (er.code === 'ENOENT')\n return\n else if (er.code === 'ENOTDIR' || er.code === 'ENOTSUP')\n return handleEISDirSync(p, uid, gid)\n else\n throw er\n }\n\n if (children && children.length)\n children.forEach(child => chownrKidSync(p, child, uid, gid))\n\n return handleEISDirSync(p, uid, gid)\n}\n\nmodule.exports = chownr\nchownr.sync = chownrSync\n","const binding = require('../build/Release/cpufeatures.node');\n\nmodule.exports = binding.getCPUInfo;\n","/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug');\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tlet i;\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n\t\tconst len = split.length;\n\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tif (!split[i]) {\n\t\t\t\t// ignore empty strings\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tnamespaces = split[i].replace(/\\*/g, '.*?');\n\n\t\t\tif (namespaces[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(new RegExp('^' + namespaces + '$'));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names.map(toNamespace),\n\t\t\t...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tif (name[name.length - 1] === '*') {\n\t\t\treturn true;\n\t\t}\n\n\t\tlet i;\n\t\tlet len;\n\n\t\tfor (i = 0, len = createDebug.skips.length; i < len; i++) {\n\t\t\tif (createDebug.skips[i].test(name)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0, len = createDebug.names.length; i < len; i++) {\n\t\t\tif (createDebug.names[i].test(name)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Convert regexp to namespace\n\t*\n\t* @param {RegExp} regxep\n\t* @return {String} namespace\n\t* @api private\n\t*/\n\tfunction toNamespace(regexp) {\n\t\treturn regexp.toString()\n\t\t\t.substring(2, regexp.toString().length - 2)\n\t\t\t.replace(/\\.\\*\\?$/, '*');\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n","/**\n * Detect Electron renderer / nwjs process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {\n\tmodule.exports = require('./browser.js');\n} else {\n\tmodule.exports = require('./node.js');\n}\n","/**\n * Module dependencies.\n */\n\nconst tty = require('tty');\nconst util = require('util');\n\n/**\n * This is the Node.js implementation of `debug()`.\n */\n\nexports.init = init;\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.destroy = util.deprecate(\n\t() => {},\n\t'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'\n);\n\n/**\n * Colors.\n */\n\nexports.colors = [6, 2, 3, 4, 5, 1];\n\ntry {\n\t// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)\n\t// eslint-disable-next-line import/no-extraneous-dependencies\n\tconst supportsColor = require('supports-color');\n\n\tif (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {\n\t\texports.colors = [\n\t\t\t20,\n\t\t\t21,\n\t\t\t26,\n\t\t\t27,\n\t\t\t32,\n\t\t\t33,\n\t\t\t38,\n\t\t\t39,\n\t\t\t40,\n\t\t\t41,\n\t\t\t42,\n\t\t\t43,\n\t\t\t44,\n\t\t\t45,\n\t\t\t56,\n\t\t\t57,\n\t\t\t62,\n\t\t\t63,\n\t\t\t68,\n\t\t\t69,\n\t\t\t74,\n\t\t\t75,\n\t\t\t76,\n\t\t\t77,\n\t\t\t78,\n\t\t\t79,\n\t\t\t80,\n\t\t\t81,\n\t\t\t92,\n\t\t\t93,\n\t\t\t98,\n\t\t\t99,\n\t\t\t112,\n\t\t\t113,\n\t\t\t128,\n\t\t\t129,\n\t\t\t134,\n\t\t\t135,\n\t\t\t148,\n\t\t\t149,\n\t\t\t160,\n\t\t\t161,\n\t\t\t162,\n\t\t\t163,\n\t\t\t164,\n\t\t\t165,\n\t\t\t166,\n\t\t\t167,\n\t\t\t168,\n\t\t\t169,\n\t\t\t170,\n\t\t\t171,\n\t\t\t172,\n\t\t\t173,\n\t\t\t178,\n\t\t\t179,\n\t\t\t184,\n\t\t\t185,\n\t\t\t196,\n\t\t\t197,\n\t\t\t198,\n\t\t\t199,\n\t\t\t200,\n\t\t\t201,\n\t\t\t202,\n\t\t\t203,\n\t\t\t204,\n\t\t\t205,\n\t\t\t206,\n\t\t\t207,\n\t\t\t208,\n\t\t\t209,\n\t\t\t214,\n\t\t\t215,\n\t\t\t220,\n\t\t\t221\n\t\t];\n\t}\n} catch (error) {\n\t// Swallow - we only care if `supports-color` is available; it doesn't have to be.\n}\n\n/**\n * Build up the default `inspectOpts` object from the environment variables.\n *\n * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js\n */\n\nexports.inspectOpts = Object.keys(process.env).filter(key => {\n\treturn /^debug_/i.test(key);\n}).reduce((obj, key) => {\n\t// Camel-case\n\tconst prop = key\n\t\t.substring(6)\n\t\t.toLowerCase()\n\t\t.replace(/_([a-z])/g, (_, k) => {\n\t\t\treturn k.toUpperCase();\n\t\t});\n\n\t// Coerce string value into JS value\n\tlet val = process.env[key];\n\tif (/^(yes|on|true|enabled)$/i.test(val)) {\n\t\tval = true;\n\t} else if (/^(no|off|false|disabled)$/i.test(val)) {\n\t\tval = false;\n\t} else if (val === 'null') {\n\t\tval = null;\n\t} else {\n\t\tval = Number(val);\n\t}\n\n\tobj[prop] = val;\n\treturn obj;\n}, {});\n\n/**\n * Is stdout a TTY? Colored output is enabled when `true`.\n */\n\nfunction useColors() {\n\treturn 'colors' in exports.inspectOpts ?\n\t\tBoolean(exports.inspectOpts.colors) :\n\t\ttty.isatty(process.stderr.fd);\n}\n\n/**\n * Adds ANSI color escape codes if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\tconst {namespace: name, useColors} = this;\n\n\tif (useColors) {\n\t\tconst c = this.color;\n\t\tconst colorCode = '\\u001B[3' + (c < 8 ? c : '8;5;' + c);\n\t\tconst prefix = ` ${colorCode};1m${name} \\u001B[0m`;\n\n\t\targs[0] = prefix + args[0].split('\\n').join('\\n' + prefix);\n\t\targs.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\\u001B[0m');\n\t} else {\n\t\targs[0] = getDate() + name + ' ' + args[0];\n\t}\n}\n\nfunction getDate() {\n\tif (exports.inspectOpts.hideDate) {\n\t\treturn '';\n\t}\n\treturn new Date().toISOString() + ' ';\n}\n\n/**\n * Invokes `util.format()` with the specified arguments and writes to stderr.\n */\n\nfunction log(...args) {\n\treturn process.stderr.write(util.format(...args) + '\\n');\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\tif (namespaces) {\n\t\tprocess.env.DEBUG = namespaces;\n\t} else {\n\t\t// If you set a process.env field to null or undefined, it gets cast to the\n\t\t// string 'null' or 'undefined'. Just delete instead.\n\t\tdelete process.env.DEBUG;\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n\treturn process.env.DEBUG;\n}\n\n/**\n * Init logic for `debug` instances.\n *\n * Create a new `inspectOpts` object in case `useColors` is set\n * differently for a particular `debug` instance.\n */\n\nfunction init(debug) {\n\tdebug.inspectOpts = {};\n\n\tconst keys = Object.keys(exports.inspectOpts);\n\tfor (let i = 0; i < keys.length; i++) {\n\t\tdebug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %o to `util.inspect()`, all on a single line.\n */\n\nformatters.o = function (v) {\n\tthis.inspectOpts.colors = this.useColors;\n\treturn util.inspect(v, this.inspectOpts)\n\t\t.split('\\n')\n\t\t.map(str => str.trim())\n\t\t.join(' ');\n};\n\n/**\n * Map %O to `util.inspect()`, allowing multiple lines if needed.\n */\n\nformatters.O = function (v) {\n\tthis.inspectOpts.colors = this.useColors;\n\treturn util.inspect(v, this.inspectOpts);\n};\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nclass Deprecation extends Error {\n constructor(message) {\n super(message); // Maintains proper stack trace (only available on V8)\n\n /* istanbul ignore next */\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n\n this.name = 'Deprecation';\n }\n\n}\n\nexports.Deprecation = Deprecation;\n","//Based on follow-redirects v0.0.x\n\nvar nativeHttps = require('https'),\n nativeHttp = require('http'),\n url = require('url'),\n utils = require('./utils');\n\nvar maxRedirects = module.exports.maxRedirects = 5;\n\nvar protocols = {\n https: nativeHttps,\n http: nativeHttp\n};\n\nfor (var protocol in protocols) {\n var h = function() {};\n h.prototype = protocols[protocol];\n h = new h();\n\n h.request = function(h) {\n return function(options, callback, redirectOptions) {\n\n redirectOptions = redirectOptions || {};\n\n var max = (typeof options === 'object' && 'maxRedirects' in options) ? options.maxRedirects : exports.maxRedirects;\n\n var redirect = utils.extend({\n count: 0,\n max: max,\n clientRequest: null,\n userCallback: callback\n }, redirectOptions);\n\n if (redirect.count > redirect.max) {\n var err = new Error('Max redirects exceeded. To allow more redirects, pass options.maxRedirects property.');\n redirect.clientRequest.emit('error', err);\n return redirect.clientRequest;\n }\n\n redirect.count++;\n\n var reqUrl;\n if (typeof options === 'string') {\n reqUrl = options;\n } else {\n reqUrl = url.format(utils.extend({\n protocol: protocol\n }, options));\n }\n\n var clientRequest = Object.getPrototypeOf(h).request(options, redirectCallback(reqUrl, redirect));\n\n if (!redirect.clientRequest) redirect.clientRequest = clientRequest;\n\n function redirectCallback(reqUrl, redirect) {\n return function(res) {\n if (res.statusCode < 300 || res.statusCode > 399) {\n return redirect.userCallback(res);\n }\n\n if (!('location' in res.headers)) {\n return redirect.userCallback(res);\n }\n\n var redirectUrl = url.resolve(reqUrl, res.headers.location);\n\n var proto = url.parse(redirectUrl).protocol;\n proto = proto.substr(0, proto.length - 1);\n return module.exports[proto].get(redirectUrl, redirectCallback(reqUrl, redirect), redirect);\n };\n }\n\n return clientRequest;\n };\n }(h);\n\n // see https://github.com/joyent/node/blob/master/lib/http.js#L1623\n h.get = function(h) {\n return function(options, cb, redirectOptions) {\n var req = h.request(options, cb, redirectOptions);\n req.end();\n return req;\n };\n }(h);\n\n module.exports[protocol] = h;\n}\n","module.exports = HttpDuplex;\n\nvar util = require('util'),\n stream = require('readable-stream');\n\nutil.inherits(HttpDuplex, stream.Duplex);\n\nfunction HttpDuplex(req, res, options) {\n var self = this;\n\n if (!(self instanceof HttpDuplex)) return new HttpDuplex(req, res, options);\n\n stream.Duplex.call(self, options);\n self._output = null;\n\n self.connect(req, res);\n}\n\nHttpDuplex.prototype.connect = function(req, res) {\n var self = this;\n self.req = req;\n self._output = res;\n self.emit('response', res);\n\n res.on('data', function(c) {\n if (!self.push(c)) self._output.pause();\n });\n res.on('end', function() {\n self.push(null);\n });\n};\n\nHttpDuplex.prototype._read = function(n) {\n if (this._output) this._output.resume();\n};\n\nHttpDuplex.prototype._write = function(chunk, encoding, cb) {\n this.req.write(chunk, encoding);\n cb();\n};\n\nHttpDuplex.prototype.end = function(chunk, encoding, cb) {\n this._output.socket.destroy();\n return this.req.end(chunk, encoding, cb);\n};\n\nHttpDuplex.prototype.destroy = function() {\n this.req.destroy();\n this._output.socket.destroy();\n};\n","var querystring = require('querystring'),\n http = require('./http'),\n fs = require('fs'),\n path = require('path'),\n url = require('url'),\n ssh = require('./ssh'),\n HttpDuplex = require('./http_duplex'),\n debug = require('debug')('modem'),\n utils = require('./utils'),\n util = require('util'),\n url = require('url'),\n splitca = require('split-ca'),\n isWin = require('os').type() === 'Windows_NT';\n\nvar defaultOpts = function () {\n var host;\n var opts = {};\n\n if (!process.env.DOCKER_HOST) {\n // Windows socket path: //./pipe/docker_engine ( Windows 10 )\n // Linux & Darwin socket path: /var/run/docker.sock\n opts.socketPath = isWin ? '//./pipe/docker_engine' : '/var/run/docker.sock';\n } else if (process.env.DOCKER_HOST.indexOf('unix://') === 0) {\n // Strip off unix://, fall back to default of /var/run/docker.sock if\n // unix:// was passed without a path\n opts.socketPath = process.env.DOCKER_HOST.substring(7) || '/var/run/docker.sock';\n } else if (process.env.DOCKER_HOST.indexOf('npipe://') === 0) {\n // Strip off npipe://, fall back to default of //./pipe/docker_engine if\n // npipe:// was passed without a path\n opts.socketPath = process.env.DOCKER_HOST.substring(8) || '//./pipe/docker_engine';\n } else {\n var hostStr = process.env.DOCKER_HOST;\n if (hostStr.indexOf('\\/\\/') < 0) {\n hostStr = 'tcp://' + hostStr;\n }\n try {\n host = new url.URL(hostStr);\n } catch (err) {\n throw new Error('DOCKER_HOST env variable should be something like tcp://localhost:1234');\n }\n\n opts.port = host.port;\n\n if (process.env.DOCKER_TLS_VERIFY === '1' || opts.port === '2376') {\n opts.protocol = 'https';\n } else if (host.protocol === 'ssh:') {\n opts.protocol = 'ssh';\n opts.username = host.username;\n opts.sshOptions = {\n agent: process.env.SSH_AUTH_SOCK,\n }\n } else {\n opts.protocol = 'http';\n }\n\n opts.host = host.hostname;\n\n if (process.env.DOCKER_CERT_PATH) {\n opts.ca = splitca(path.join(process.env.DOCKER_CERT_PATH, 'ca.pem'));\n opts.cert = fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'cert.pem'));\n opts.key = fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'key.pem'));\n }\n\n if (process.env.DOCKER_CLIENT_TIMEOUT) {\n opts.timeout = parseInt(process.env.DOCKER_CLIENT_TIMEOUT, 10);\n }\n }\n\n return opts;\n};\n\n\nvar Modem = function (options) {\n var optDefaults = defaultOpts();\n var opts = Object.assign({}, optDefaults, options);\n\n this.host = opts.host;\n\n if(!this.host) {\n this.socketPath = opts.socketPath;\n }\n\n this.port = opts.port;\n this.username = opts.username;\n this.password = opts.password;\n this.version = opts.version;\n this.key = opts.key;\n this.cert = opts.cert;\n this.ca = opts.ca;\n this.timeout = opts.timeout;\n this.connectionTimeout = opts.connectionTimeout;\n this.checkServerIdentity = opts.checkServerIdentity;\n this.agent = opts.agent;\n this.headers = opts.headers || {};\n this.sshOptions = Object.assign({}, options ? options.sshOptions : {}, optDefaults.sshOptions);\n //retrocompabitlity\n if(this.sshOptions.agentForward === undefined) {\n this.sshOptions.agentForward = opts.agentForward;\n }\n\n if (this.key && this.cert && this.ca) {\n this.protocol = 'https';\n }\n this.protocol = opts.protocol || this.protocol || 'http';\n};\n\nModem.prototype.dial = function (options, callback) {\n var opts, address, data;\n var self = this;\n\n if (options.options) {\n opts = options.options;\n }\n\n // Prevent credentials from showing up in URL\n if (opts && opts.authconfig) {\n delete opts.authconfig;\n }\n\n // Prevent abortsignal from showing up in the URL\n if (opts && opts.abortSignal) {\n delete opts.abortSignal;\n }\n\n if (this.version) {\n options.path = '/' + this.version + options.path;\n }\n\n if (this.host) {\n var parsed = url.parse(self.host);\n address = url.format({\n 'protocol': parsed.protocol || self.protocol,\n 'hostname': parsed.hostname || self.host,\n 'port': self.port\n });\n address = url.resolve(address, options.path);\n } else {\n address = options.path;\n }\n\n if (options.path.indexOf('?') !== -1) {\n if (opts && Object.keys(opts).length > 0) {\n address += this.buildQuerystring(opts._query || opts);\n } else {\n address = address.substring(0, address.length - 1);\n }\n }\n\n var optionsf = {\n path: address,\n method: options.method,\n headers: options.headers || Object.assign({}, self.headers),\n key: self.key,\n cert: self.cert,\n ca: self.ca\n };\n\n if (this.checkServerIdentity) {\n optionsf.checkServerIdentity = this.checkServerIdentity;\n }\n\n if (this.agent) {\n optionsf.agent = this.agent;\n }\n\n if (options.authconfig) {\n optionsf.headers['X-Registry-Auth'] = options.authconfig.key || options.authconfig.base64 ||\n Buffer.from(JSON.stringify(options.authconfig)).toString('base64');\n }\n\n if (options.registryconfig) {\n optionsf.headers['X-Registry-Config'] = options.registryconfig.base64 ||\n Buffer.from(JSON.stringify(options.registryconfig)).toString('base64');\n }\n\n if (options.abortSignal) {\n optionsf.signal = options.abortSignal;\n }\n\n if (options.file) {\n if (typeof options.file === 'string') {\n data = fs.createReadStream(path.resolve(options.file));\n } else {\n data = options.file;\n }\n optionsf.headers['Content-Type'] = 'application/tar';\n } else if (opts && options.method === 'POST') {\n data = JSON.stringify(opts._body || opts);\n if (options.allowEmpty) {\n optionsf.headers['Content-Type'] = 'application/json';\n } else {\n if (data !== '{}' && data !== '\"\"') {\n optionsf.headers['Content-Type'] = 'application/json';\n } else {\n data = undefined;\n }\n }\n }\n\n if (typeof data === 'string') {\n optionsf.headers['Content-Length'] = Buffer.byteLength(data);\n } else if (Buffer.isBuffer(data) === true) {\n optionsf.headers['Content-Length'] = data.length;\n } else if (optionsf.method === 'PUT' || options.hijack || options.openStdin) {\n optionsf.headers['Transfer-Encoding'] = 'chunked';\n }\n\n if (options.hijack) {\n optionsf.headers.Connection = 'Upgrade';\n optionsf.headers.Upgrade = 'tcp';\n }\n\n if (this.socketPath) {\n optionsf.socketPath = this.socketPath;\n } else {\n var urlp = url.parse(address);\n optionsf.hostname = urlp.hostname;\n optionsf.port = urlp.port;\n optionsf.path = urlp.path;\n }\n\n this.buildRequest(optionsf, options, data, callback);\n};\n\nModem.prototype.buildRequest = function (options, context, data, callback) {\n var self = this;\n var connectionTimeoutTimer;\n\n var opts = self.protocol === 'ssh' ? Object.assign(options, {\n agent: ssh(Object.assign({}, self.sshOptions, {\n 'host': self.host,\n 'port': self.port,\n 'username': self.username,\n 'password': self.password,\n })),\n protocol: 'http:',\n }) : options;\n\n var req = http[self.protocol === 'ssh' ? 'http' : self.protocol].request(opts, function () { });\n\n debug('Sending: %s', util.inspect(options, {\n showHidden: true,\n depth: null\n }));\n\n if (self.connectionTimeout) {\n connectionTimeoutTimer = setTimeout(function () {\n debug('Connection Timeout of %s ms exceeded', self.connectionTimeout);\n req.abort();\n }, self.connectionTimeout);\n }\n\n if (self.timeout) {\n req.on('socket', function (socket) {\n socket.setTimeout(self.timeout);\n socket.on('timeout', function () {\n debug('Timeout of %s ms exceeded', self.timeout);\n req.abort();\n });\n });\n }\n\n if (context.hijack === true) {\n clearTimeout(connectionTimeoutTimer);\n req.on('upgrade', function (res, sock, head) {\n return callback(null, sock);\n });\n }\n\n req.on('connect', function () {\n clearTimeout(connectionTimeoutTimer);\n });\n\n req.on('disconnect', function () {\n clearTimeout(connectionTimeoutTimer);\n });\n\n req.on('response', function (res) {\n clearTimeout(connectionTimeoutTimer);\n if (context.isStream === true) {\n self.buildPayload(null, context.isStream, context.statusCodes, context.openStdin, req, res, null, callback);\n } else {\n var chunks = [];\n res.on('data', function (chunk) {\n chunks.push(chunk);\n });\n\n res.on('end', function () {\n var buffer = Buffer.concat(chunks);\n var result = buffer.toString();\n\n debug('Received: %s', result);\n\n var json = utils.parseJSON(result) || buffer;\n self.buildPayload(null, context.isStream, context.statusCodes, false, req, res, json, callback);\n });\n }\n });\n\n req.on('error', function (error) {\n clearTimeout(connectionTimeoutTimer);\n self.buildPayload(error, context.isStream, context.statusCodes, false, {}, {}, null, callback);\n });\n\n if (typeof data === 'string' || Buffer.isBuffer(data)) {\n req.write(data);\n } else if (data) {\n data.on('error', function (error) {\n req.destroy(error);\n });\n data.pipe(req);\n }\n\n if (!context.hijack && !context.openStdin && (typeof data === 'string' || data === undefined || Buffer.isBuffer(data))) {\n req.end();\n }\n};\n\nModem.prototype.buildPayload = function (err, isStream, statusCodes, openStdin, req, res, json, cb) {\n if (err) return cb(err, null);\n\n if (statusCodes[res.statusCode] !== true) {\n getCause(isStream, res, json, function (err, cause) {\n var msg = new Error(\n '(HTTP code ' + res.statusCode + ') ' +\n (statusCodes[res.statusCode] || 'unexpected') + ' - ' +\n (cause.message || cause) + ' '\n );\n msg.reason = statusCodes[res.statusCode];\n msg.statusCode = res.statusCode;\n msg.json = json;\n cb(msg, null);\n });\n } else {\n if (openStdin) {\n cb(null, new HttpDuplex(req, res));\n } else if (isStream) {\n cb(null, res);\n } else {\n cb(null, json);\n }\n }\n\n function getCause(isStream, res, json, callback) {\n var chunks = '';\n if (isStream) {\n res.on('data', function (chunk) {\n chunks += chunk;\n });\n res.on('end', function () {\n callback(null, utils.parseJSON(chunks) || chunks);\n });\n } else {\n callback(null, json);\n }\n }\n};\n\nModem.prototype.demuxStream = function (stream, stdout, stderr) {\n var nextDataType = null;\n var nextDataLength = null;\n var buffer = Buffer.from('');\n function processData(data) {\n if (data) {\n buffer = Buffer.concat([buffer, data]);\n }\n if (!nextDataType) {\n if (buffer.length >= 8) {\n var header = bufferSlice(8);\n nextDataType = header.readUInt8(0);\n nextDataLength = header.readUInt32BE(4);\n // It's possible we got a \"data\" that contains multiple messages\n // Process the next one\n processData();\n }\n } else {\n if (buffer.length >= nextDataLength) {\n var content = bufferSlice(nextDataLength);\n if (nextDataType === 1) {\n stdout.write(content);\n } else {\n stderr.write(content);\n }\n nextDataType = null;\n // It's possible we got a \"data\" that contains multiple messages\n // Process the next one\n processData();\n }\n }\n }\n\n function bufferSlice(end) {\n var out = buffer.slice(0, end);\n buffer = Buffer.from(buffer.slice(end, buffer.length));\n return out;\n }\n\n stream.on('data', processData);\n};\n\nModem.prototype.followProgress = function (stream, onFinished, onProgress) {\n var buf = '';\n var output = [];\n var finished = false;\n\n stream.on('data', onStreamEvent);\n stream.on('error', onStreamError);\n stream.on('end', onStreamEnd);\n stream.on('close', onStreamEnd);\n\n function onStreamEvent(data) {\n buf += data.toString();\n pump();\n\n function pump() {\n var pos;\n while ((pos = buf.indexOf('\\n')) >= 0) {\n if (pos == 0) {\n buf = buf.slice(1);\n continue;\n }\n processLine(buf.slice(0, pos));\n buf = buf.slice(pos + 1);\n }\n }\n\n function processLine(line) {\n if (line[line.length - 1] == '\\r') line = line.substr(0, line.length - 1);\n if (line.length > 0) {\n var obj = JSON.parse(line);\n output.push(obj);\n if (onProgress) {\n onProgress(obj);\n }\n }\n }\n };\n\n function onStreamError(err) {\n finished = true;\n stream.removeListener('data', onStreamEvent);\n stream.removeListener('error', onStreamError);\n stream.removeListener('end', onStreamEnd);\n stream.removeListener('close', onStreamEnd);\n onFinished(err, output);\n }\n\n function onStreamEnd() {\n if(!finished) onFinished(null, output);\n finished = true;\n }\n};\n\nModem.prototype.buildQuerystring = function (opts) {\n var clone = {};\n\n // serialize map values as JSON strings, else querystring truncates.\n Object.keys(opts).map(function (key, i) {\n if (opts[key]\n && typeof opts[key] === 'object'\n && !Array.isArray(opts[key])\n // Ref: https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild\n // > cachefrom (string) JSON array of images used for build cache resolution.\n || key === 'cachefrom'\n ) {\n clone[key] = JSON.stringify(opts[key]);\n } else {\n clone[key] = opts[key];\n }\n });\n\n return querystring.stringify(clone);\n};\n\nmodule.exports = Modem;\n","var Client = require('ssh2').Client,\n http = require('http');\n\nmodule.exports = function(opt) {\n var conn = new Client();\n var agent = new http.Agent();\n\n agent.createConnection = function(options, fn) {\n conn.once('ready', function() {\n conn.exec('docker system dial-stdio', function(err, stream) {\n if (err) {\n conn.end();\n agent.destroy();\n return;\n }\n\n fn(null, stream);\n\n stream.once('close', () => {\n conn.end();\n agent.destroy();\n });\n });\n }).connect(opt);\n\n conn.once('end', () => agent.destroy());\n };\n\n return agent;\n};\n","// https://github.com/HenrikJoreteg/extend-object/blob/v0.1.0/extend-object.js\n\nvar arr = [];\nvar each = arr.forEach;\nvar slice = arr.slice;\n\nmodule.exports.extend = function(obj) {\n each.call(slice.call(arguments, 1), function(source) {\n if (source) {\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n });\n return obj;\n};\n\nmodule.exports.parseJSON = function(s) {\n try {\n return JSON.parse(s);\n } catch (e) {\n return null;\n }\n};\n","var util = require('./util');\n\n/**\n * Represents a config\n * @param {Object} modem docker-modem\n * @param {String} id Config's id\n */\nvar Config = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nConfig.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n *\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nConfig.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs/' + this.id,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update a config.\n *\n * @param {object} opts\n * @param {function} callback\n */\nConfig.prototype.update = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs/' + this.id + '/update?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Removes the config\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nConfig.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs/' + this.id,\n method: 'DELETE',\n abortSignal: opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'config not found',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Config;\n","var extend = require('./util').extend,\n Exec = require('./exec'),\n util = require('./util');\n\n/**\n * Represents a Container\n * @param {Object} modem docker-modem\n * @param {String} id Container's ID\n */\nvar Container = function(modem, id) {\n this.modem = modem;\n this.id = id;\n\n this.defaultOptions = {\n top: {},\n start: {},\n commit: {},\n stop: {},\n pause: {},\n unpause: {},\n restart: {},\n resize: {},\n attach: {},\n remove: {},\n copy: {},\n kill: {},\n exec: {},\n rename: {},\n log: {},\n stats: {},\n getArchive: {},\n infoArchive: {},\n putArchive: {},\n update: {},\n wait: {}\n };\n};\n\nContainer.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if supplied will query Docker.\n * @return {Object} ID only and only if callback isn't supplied.\n */\nContainer.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/json?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Rename\n * @param {Object} opts Rename options\n * @param {Function} callback Callback\n */\nContainer.prototype.rename = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.rename);\n\n var optsf = {\n path: '/containers/' + this.id + '/rename?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update\n * @param {Object} opts Update options\n * @param {Function} callback Callback\n */\nContainer.prototype.update = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.update);\n\n var optsf = {\n path: '/containers/' + this.id + '/update',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Top\n * @param {Object} opts like 'ps_args' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.top = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.top);\n\n var optsf = {\n path: '/containers/' + this.id + '/top?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Containers changes\n * @param {Object} Options\n * @param {Function} callback Callback\n */\nContainer.prototype.changes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/changes',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Checkpoints list\n * @param {Object} opts List checkpoints options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.listCheckpoint = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Delete checkpoint\n * @param {Object} opts Delete checkpoint options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.deleteCheckpoint = function(checkpoint, opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints/' + checkpoint + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Create checkpoint\n * @param {Object} opts Create checkpoint options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.createCheckpoint = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/checkpoints',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n allowEmpty: true,\n statusCodes: {\n 200: true, //unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Export\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback with the octet-stream.\n */\nContainer.prototype.export = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/' + this.id + '/export',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Start\n * @param {Object} opts Container start options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.start = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.start);\n\n var optsf = {\n path: '/containers/' + this.id + '/start?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 304: 'container already started',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Pause\n * @param {Object} opts Pause options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.pause = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.pause);\n\n var optsf = {\n path: '/containers/' + this.id + '/pause',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Unpause\n * @param {Object} opts Unpause options (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.unpause = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.unpause);\n\n var optsf = {\n path: '/containers/' + this.id + '/unpause',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Setup an exec call to a running container\n *\n * @param {object} opts\n * @param {function} callback\n */\nContainer.prototype.exec = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.exec);\n\n var optsf = {\n path: '/containers/' + this.id + '/exec',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 409: 'container stopped/paused',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(new Exec(self.modem, data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, new Exec(self.modem, data.Id));\n });\n }\n};\n\n/**\n * Commit\n * @param {Object} opts Commit options like 'Hostname' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.commit = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.commit);\n\n args.opts.container = this.id;\n\n var optsf = {\n path: '/commit?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Stop\n * @param {Object} opts Container stop options, like 't' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.stop = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.stop);\n\n var optsf = {\n path: '/containers/' + this.id + '/stop?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 304: 'container already stopped',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Restart\n * @param {Object} opts Container restart options, like 't' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.restart = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.restart);\n\n var optsf = {\n path: '/containers/' + this.id + '/restart?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Kill\n * @param {Object} opts Container kill options, like 'signal' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.kill = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.kill);\n\n var optsf = {\n path: '/containers/' + this.id + '/kill?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container resize\n * @param {[type]} opts Resize options. (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.resize = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.resize);\n\n var optsf = {\n path: '/containers/' + this.id + '/resize?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Attach\n * @param {Object} opts Attach options, like 'logs' (optional)\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.attach = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.attach);\n\n var optsf = {\n path: '/containers/' + this.id + '/attach?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n hijack: args.opts.hijack,\n openStdin: args.opts.stdin,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, stream) {\n if (err) {\n return reject(err);\n }\n resolve(stream);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, stream) {\n args.callback(err, stream);\n });\n }\n};\n\n/**\n * Waits for a container to end.\n * @param {[type]} opts Container wait options, like condition. (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.wait = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.wait);\n\n var optsf = {\n path: '/containers/' + this.id + '/wait?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes a container\n * @param {Object} opts Remove options, like 'force' (optional)\n * @param {Function} callback Callback\n */\nContainer.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.remove);\n\n var optsf = {\n path: '/containers/' + this.id + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 400: 'bad parameter',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Copy (WARNING: DEPRECATED since RAPI v1.20)\n * @param {Object} opts Copy options, like 'Resource' (optional)\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.copy = function(opts, callback) {\n var self = this;\n console.log('container.copy is deprecated since Docker v1.8.x');\n var args = util.processArgs(opts, callback, this.defaultOptions.copy);\n\n var optsf = {\n path: '/containers/' + this.id + '/copy',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * getArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.getArchive = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.getArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * infoArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.infoArchive = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.infoArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'HEAD',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * putArchive\n * @param {Object} opts Archive options, like 'path'\n * @param {Function} callback Callback with stream.\n */\nContainer.prototype.putArchive = function(file, opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.putArchive);\n\n var optsf = {\n path: '/containers/' + this.id + '/archive?',\n method: 'PUT',\n file: file,\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'client error, bad parameters',\n 403: 'client error, permission denied',\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nContainer.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.log);\n\n var optsf = {\n path: '/containers/' + this.id + '/logs?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: args.opts.follow || false,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Container stats\n * @param {Object} opts Stats options. (optional)\n * @param {Function} callback Callback with data\n */\nContainer.prototype.stats = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.stats);\n var isStream = true;\n if (args.opts.stream === false) {\n isStream = false;\n }\n var optsf = {\n path: '/containers/' + this.id + '/stats?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: isStream,\n statusCodes: {\n 200: true,\n 404: 'no such container',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Container;\n","var EventEmitter = require('events').EventEmitter,\n Modem = require('docker-modem'),\n tar = require('tar-fs'),\n zlib = require('zlib'),\n Container = require('./container'),\n Image = require('./image'),\n Volume = require('./volume'),\n Network = require('./network'),\n Service = require('./service'),\n Plugin = require('./plugin'),\n Secret = require('./secret'),\n Config = require('./config'),\n Task = require('./task'),\n Node = require('./node'),\n Exec = require('./exec'),\n util = require('./util'),\n extend = util.extend;\n\nvar Docker = function(opts) {\n if (!(this instanceof Docker)) return new Docker(opts);\n\n var plibrary = global.Promise;\n\n if (opts && opts.Promise) {\n plibrary = opts.Promise;\n\n if (Object.keys(opts).length === 1) {\n opts = undefined;\n }\n }\n\n this.modem = new Modem(opts);\n this.modem.Promise = plibrary;\n};\n\n/**\n * Creates a new container\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createContainer = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/containers/create?',\n method: 'POST',\n options: opts,\n authconfig: opts.authconfig,\n abortSignal: opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'no such container',\n 406: 'impossible to attach',\n 500: 'server error'\n }\n };\n\n delete opts.authconfig;\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getContainer(data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, self.getContainer(data.Id));\n });\n }\n};\n\n/**\n * Creates a new image\n * @param {Object} auth Authentication (optional)\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createImage = function(auth, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (!callback && !opts) {\n opts = auth;\n auth = opts.authconfig;\n }\n\n var optsf = {\n path: '/images/create?',\n method: 'POST',\n options: opts,\n authconfig: auth,\n abortSignal: opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Load image\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.loadImage = function(file, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n\n var optsf = {\n path: '/images/load?',\n method: 'POST',\n options: opts,\n file: file,\n abortSignal: opts && opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Import image from a tar archive\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.importImage = function(file, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = undefined;\n }\n\n if (!opts)\n opts = {};\n\n opts.fromSrc = '-';\n\n var optsf = {\n path: '/images/create?',\n method: 'POST',\n options: opts,\n file: file,\n abortSignal: opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Verifies auth\n * @param {Object} opts Options\n * @param {Function} callback Callback\n */\nDocker.prototype.checkAuth = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/auth',\n method: 'POST',\n options: opts,\n abortSignal: opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Builds an image\n * @param {String} file File\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.buildImage = function(file, opts, callback) {\n var self = this;\n\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n\n function build(file) {\n var optsf = {\n path: '/build?',\n method: 'POST',\n file: file,\n options: opts,\n abortSignal: opts && opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (opts) {\n if (opts.registryconfig) {\n optsf.registryconfig = optsf.options.registryconfig;\n delete optsf.options.registryconfig;\n }\n\n //undocumented?\n if (opts.authconfig) {\n optsf.authconfig = optsf.options.authconfig;\n delete optsf.options.authconfig;\n }\n }\n\n if (callback === undefined) {\n return new self.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n self.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n }\n\n if (file && file.context) {\n var pack = tar.pack(file.context, {\n entries: file.src\n });\n return build(pack.pipe(zlib.createGzip()));\n } else {\n return build(file);\n }\n};\n\n/**\n * Fetches a Container by ID\n * @param {String} id Container's ID\n */\nDocker.prototype.getContainer = function(id) {\n return new Container(this.modem, id);\n};\n\n/**\n * Fetches an Image by name\n * @param {String} name Image's name\n */\nDocker.prototype.getImage = function(name) {\n return new Image(this.modem, name);\n};\n\n/**\n * Fetches a Volume by name\n * @param {String} name Volume's name\n */\nDocker.prototype.getVolume = function(name) {\n return new Volume(this.modem, name);\n};\n\n/**\n * Fetches a Plugin by name\n * @param {String} name Volume's name\n */\nDocker.prototype.getPlugin = function(name, remote) {\n return new Plugin(this.modem, name, remote);\n};\n\n/**\n * Fetches a Service by id\n * @param {String} id Services's id\n */\nDocker.prototype.getService = function(id) {\n return new Service(this.modem, id);\n};\n\n/**\n * Fetches a Task by id\n * @param {String} id Task's id\n */\nDocker.prototype.getTask = function(id) {\n return new Task(this.modem, id);\n};\n\n/**\n * Fetches Node by id\n * @param {String} id Node's id\n */\nDocker.prototype.getNode = function(id) {\n return new Node(this.modem, id);\n};\n\n/**\n * Fetches a Network by id\n * @param {String} id network's id\n */\nDocker.prototype.getNetwork = function(id) {\n return new Network(this.modem, id);\n};\n\n/**\n * Fetches a Secret by id\n * @param {String} id network's id\n */\nDocker.prototype.getSecret = function(id) {\n return new Secret(this.modem, id);\n};\n\n/**\n * Fetches a Config by id\n * @param {String} id network's id\n */\nDocker.prototype.getConfig = function(id) {\n return new Config(this.modem, id);\n};\n\n/**\n * Fetches an Exec instance by ID\n * @param {String} id Exec instance's ID\n */\nDocker.prototype.getExec = function(id) {\n return new Exec(this.modem, id);\n};\n\n/**\n * Lists containers\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listContainers = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/json?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/json?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Get images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.getImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/get?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Services\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listServices = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/services?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Nodes\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listNodes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 404: 'no such node',\n 500: 'server error',\n 503: 'node is not part of a swarm',\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists Tasks\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listTasks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/tasks?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new secret\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createSecret = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n var optsf = {\n path: '/secrets/create?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 406: 'server error or node is not part of a swarm',\n 409: 'name conflicts with an existing object',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getSecret(data.ID));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getSecret(data.ID));\n });\n }\n};\n\n\n/**\n * Creates a new config\n * @param {Object} opts Config options\n * @param {Function} callback Callback\n */\nDocker.prototype.createConfig = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n var optsf = {\n path: '/configs/create?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 406: 'server error or node is not part of a swarm',\n 409: 'name conflicts with an existing object',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getConfig(data.ID));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getConfig(data.ID));\n });\n }\n};\n\n\n/**\n * Lists secrets\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listSecrets = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Lists configs\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listConfigs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/configs?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new plugin\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createPlugin = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/plugins/create?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getPlugin(args.opts.name));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getPlugin(args.opts.name));\n });\n }\n};\n\n\n/**\n * Lists plugins\n * @param {Object} opts\n * @param {Function} callback Callback\n */\nDocker.prototype.listPlugins = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune images\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneImages = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/prune?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune builder\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneBuilder = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/build/prune',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune containers\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneContainers = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/containers/prune?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune volumes\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneVolumes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/prune?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Prune networks\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.pruneNetworks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/prune?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Creates a new volume\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createVolume = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/volumes/create?',\n method: 'POST',\n allowEmpty: true,\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getVolume(data.Name));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getVolume(data.Name));\n });\n }\n};\n\n/**\n * Creates a new service\n * @param {Object} auth\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createService = function(auth, opts, callback) {\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (!opts && !callback) {\n opts = auth;\n }\n\n\n var self = this;\n var optsf = {\n path: '/services/create',\n method: 'POST',\n options: opts,\n authconfig: auth,\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 201: true,\n 500: 'server error'\n }\n };\n\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getService(data.ID || data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n callback(err, self.getService(data.ID || data.Id));\n });\n }\n};\n\n/**\n * Lists volumes\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listVolumes = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Creates a new network\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nDocker.prototype.createNetwork = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var optsf = {\n path: '/networks/create?',\n method: 'POST',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 404: 'driver not found',\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(self.getNetwork(data.Id));\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, self.getNetwork(data.Id));\n });\n }\n};\n\n/**\n * Lists networks\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.listNetworks = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Search images\n * @param {Object} opts Options\n * @param {Function} callback Callback\n */\nDocker.prototype.searchImages = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/images/search?',\n method: 'GET',\n options: opts,\n authconfig: opts.authconfig,\n abortSignal: opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Info\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback with info\n */\nDocker.prototype.info = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var opts = {\n path: '/info',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Version\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.version = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var opts = {\n path: '/version',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Ping\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.ping = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/_ping',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * SystemDf \tequivalent to system/df API Engine\n *\t\tget usage data information\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.df = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/system/df',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Events\n * @param {Object} opts Events options, like 'since' (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.getEvents = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/events?',\n method: 'GET',\n options: args.opts,\n abortSignal: args.opts.abortSignal,\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Pull is a wrapper around createImage, parsing image's tags.\n * @param {String} repoTag Repository tag\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n * @param {Object} auth Authentication (optional)\n * @return {Object} Image\n */\nDocker.prototype.pull = function(repoTag, opts, callback, auth) {\n var args = util.processArgs(opts, callback);\n\n var imageSrc = util.parseRepositoryTag(repoTag);\n args.opts.fromImage = imageSrc.repository;\n args.opts.tag = imageSrc.tag || 'latest';\n\n var argsf = [args.opts, args.callback];\n if (auth) {\n argsf = [auth, args.opts, args.callback];\n }\n return this.createImage.apply(this, argsf);\n};\n\n/**\n * Like run command from Docker's CLI\n * @param {String} image Image name to be used.\n * @param {Array} cmd Command to run in array format.\n * @param {Object} streamo Output stream\n * @param {Object} createOptions Container create options (optional)\n * @param {Object} startOptions Container start options (optional)\n * @param {Function} callback Callback\n * @return {Object} EventEmitter\n */\nDocker.prototype.run = function(image, cmd, streamo, createOptions, startOptions, callback) {\n if (typeof arguments[arguments.length - 1] === 'function') {\n return this.runCallback(image, cmd, streamo, createOptions, startOptions, callback);\n } else {\n return this.runPromise(image, cmd, streamo, createOptions, startOptions);\n }\n};\n\n\nDocker.prototype.runCallback = function(image, cmd, streamo, createOptions, startOptions, callback) {\n if (!callback && typeof createOptions === 'function') {\n callback = createOptions;\n createOptions = {};\n startOptions = {};\n } else if (!callback && typeof startOptions === 'function') {\n callback = startOptions;\n startOptions = {};\n }\n\n var hub = new EventEmitter();\n\n function handler(err, container) {\n if (err) return callback(err, null, container);\n\n hub.emit('container', container);\n\n container.attach({\n stream: true,\n stdout: true,\n stderr: true\n }, function handler(err, stream) {\n if (err) return callback(err, null, container);\n\n hub.emit('stream', stream);\n\n if (streamo) {\n if (streamo instanceof Array) {\n stream.on('end', function() {\n try {\n streamo[0].end();\n } catch (e) {}\n try {\n streamo[1].end();\n } catch (e) {}\n });\n container.modem.demuxStream(stream, streamo[0], streamo[1]);\n } else {\n stream.setEncoding('utf8');\n stream.pipe(streamo, {\n end: true\n });\n }\n }\n\n container.start(startOptions, function(err, data) {\n if (err) return callback(err, data, container);\n hub.emit('start', container);\n\n container.wait(function(err, data) {\n hub.emit('data', data);\n callback(err, data, container);\n });\n });\n });\n }\n\n var optsc = {\n 'Hostname': '',\n 'User': '',\n 'AttachStdin': false,\n 'AttachStdout': true,\n 'AttachStderr': true,\n 'Tty': true,\n 'OpenStdin': false,\n 'StdinOnce': false,\n 'Env': null,\n 'Cmd': cmd,\n 'Image': image,\n 'Volumes': {},\n 'VolumesFrom': []\n };\n\n extend(optsc, createOptions);\n\n this.createContainer(optsc, handler);\n\n return hub;\n};\n\nDocker.prototype.runPromise = function(image, cmd, streamo, createOptions, startOptions) {\n var self = this;\n\n createOptions = createOptions || {};\n startOptions = startOptions || {};\n\n var optsc = {\n 'Hostname': '',\n 'User': '',\n 'AttachStdin': false,\n 'AttachStdout': true,\n 'AttachStderr': true,\n 'Tty': true,\n 'OpenStdin': false,\n 'StdinOnce': false,\n 'Env': null,\n 'Cmd': cmd,\n 'Image': image,\n 'Volumes': {},\n 'VolumesFrom': []\n };\n\n extend(optsc, createOptions);\n\n var containero;\n\n return new this.modem.Promise(function(resolve, reject) {\n self.createContainer(optsc).then(function(container) {\n containero = container;\n return container.attach({\n stream: true,\n stdout: true,\n stderr: true\n });\n }).then(function(stream) {\n if (streamo) {\n if (streamo instanceof Array) {\n stream.on('end', function() {\n try {\n streamo[0].end();\n } catch (e) {}\n try {\n streamo[1].end();\n } catch (e) {}\n });\n containero.modem.demuxStream(stream, streamo[0], streamo[1]);\n } else {\n stream.setEncoding('utf8');\n stream.pipe(streamo, {\n end: true\n });\n }\n }\n return containero.start(startOptions);\n }).then(function(data) {\n return containero.wait();\n }).then(function(data) {\n resolve([data, containero]);\n }).catch(function(err) {\n reject(err);\n });\n });\n};\n\n/**\n * Init swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmInit = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/init',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Join swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmJoin = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/join',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Leave swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmLeave = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/leave?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 406: 'node is not part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update swarm.\n *\n * @param {object} opts\n * @param {function} callback\n */\nDocker.prototype.swarmUpdate = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm/update?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 400: 'bad parameter',\n 406: 'node is already part of a Swarm'\n },\n options: args.opts\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Inspect a Swarm.\n * Warning: This method is not documented in the API\n *\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n */\nDocker.prototype.swarmInspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/swarm',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 406: 'This node is not a swarm manager',\n 500: 'server error'\n }\n };\n\n if (args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nDocker.Container = Container;\nDocker.Image = Image;\nDocker.Volume = Volume;\nDocker.Network = Network;\nDocker.Service = Service;\nDocker.Plugin = Plugin;\nDocker.Secret = Secret;\nDocker.Task = Task;\nDocker.Node = Node;\nDocker.Exec = Exec;\n\nmodule.exports = Docker;\n","var util = require('./util');\n\n/**\n * Represents an Exec\n * @param {Object} modem docker-modem\n * @param {String} id Exec's ID\n */\nvar Exec = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nExec.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Start the exec call that was setup.\n *\n * @param {object} opts\n * @param {function} callback\n */\nExec.prototype.start = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/start',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n allowEmpty: true,\n hijack: args.opts.hijack,\n openStdin: args.opts.stdin,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such exec',\n 409: 'container stopped/paused',\n 500: 'container not running'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Resize the exec call that was setup.\n *\n * @param {object} opts\n * @param {function} callback\n */\nExec.prototype.resize = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/resize?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such exec',\n 500: 'container not running'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Get low-level information about the exec call.\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nExec.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/exec/' + this.id + '/json',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such exec',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Exec;\n","var util = require('./util');\n\n/**\n * Represents an image\n * @param {Object} modem docker-modem\n * @param {String} name Image's name\n */\nvar Image = function(modem, name) {\n this.modem = modem;\n this.name = name;\n};\n\nImage.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nImage.prototype.inspect = function(callback) {\n var self = this;\n\n var opts = {\n path: '/images/' + this.name + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Distribution\n * @param {Object} opts\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nImage.prototype.distribution = function(opts, callback) {\n var args = util.processArgs(opts, callback);\n var self = this;\n\n var fopts = {\n path: '/distribution/' + this.name + '/json',\n method: 'GET',\n statusCodes: {\n 200: true,\n 401: 'no such image',\n 500: 'server error'\n },\n authconfig: (args.opts) ? args.opts.authconfig : undefined\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(fopts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(fopts, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * History\n * @param {Function} callback Callback\n */\nImage.prototype.history = function(callback) {\n var self = this;\n var opts = {\n path: '/images/' + this.name + '/history',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Get\n * @param {Function} callback Callback with data stream.\n */\nImage.prototype.get = function(callback) {\n var self = this;\n var opts = {\n path: '/images/' + this.name + '/get',\n method: 'GET',\n isStream: true,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n if (err) return callback(err, data);\n callback(err, data);\n });\n }\n};\n\n/**\n * Push\n * @param {Object} opts Push options, like 'registry' (optional)\n * @param {Function} callback Callback with stream.\n * @param {Object} auth Registry authentication\n */\nImage.prototype.push = function(opts, callback, auth) {\n var self = this;\n var args = util.processArgs(opts, callback);\n var isStream = true;\n if (args.opts.stream === false) {\n isStream = false;\n }\n var optsf = {\n path: '/images/' + this.name + '/push?',\n method: 'POST',\n options: args.opts,\n authconfig: args.opts.authconfig || auth,\n abortSignal: args.opts.abortSignal,\n isStream: isStream,\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 500: 'server error'\n }\n };\n\n delete optsf.options.authconfig;\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Tag\n * @param {Object} opts Tag options, like 'repo' (optional)\n * @param {Function} callback Callback\n */\nImage.prototype.tag = function(opts, callback) {\n var self = this;\n var optsf = {\n path: '/images/' + this.name + '/tag?',\n method: 'POST',\n options: opts,\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 201: true,\n 400: 'bad parameter',\n 404: 'no such image',\n 409: 'conflict',\n 500: 'server error'\n }\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n/**\n * Removes the image\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nImage.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/images/' + this.name + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such image',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Image;\n","var util = require('./util');\n\n/**\n * Represents an network\n * @param {Object} modem docker-modem\n * @param {String} id Network's id\n */\nvar Network = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nNetwork.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Id only if callback isn't specified.\n */\nNetwork.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var opts = {\n path: '/networks/' + this.id + '?',\n method: 'GET',\n statusCodes: {\n 200: true,\n 404: 'no such network',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(opts, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(opts, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes the network\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id,\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such network',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Connects a container to a network\n * @param {[Object]} opts Connect options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.connect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id + '/connect',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 201: true,\n 404: 'network or container is not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Disconnects a container from a network\n * @param {[Object]} opts Disconnect options (optional)\n * @param {Function} callback Callback\n */\nNetwork.prototype.disconnect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/networks/' + this.id + '/disconnect',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 201: true,\n 404: 'network or container is not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\n\nmodule.exports = Network;\n","var util = require('./util');\n\n/**\n * Represents an Node\n * @param {Object} modem docker-modem\n * @param {String} id Node's ID\n */\nvar Node = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nNode.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for Node details.\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nNode.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes/' + this.id,\n method: 'GET',\n abortSignal: args.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Update a node.\n *\n * @param {object} opts\n * @param {function} callback\n */\nNode.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/nodes/' + this.id + '/update?',\n method: 'POST',\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 406: 'node is not part of a swarm',\n 500: 'server error'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Remove a Node.\n * Warning: This method is not documented in the API.\n *\n * @param {object} opts\n * @param {function} callback\n */\nNode.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/nodes/' + this.id + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such node',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Node;\n","var util = require('./util');\n\n/**\n * Represents a plugin\n * @param {Object} modem docker-modem\n * @param {String} name Plugin's name\n */\nvar Plugin = function(modem, name, remote) {\n this.modem = modem;\n this.name = name;\n this.remote = remote || name;\n};\n\nPlugin.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n *\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nPlugin.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'plugin is not installed',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes the plugin\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '?',\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'plugin is not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n if (err) return args.callback(err, data);\n args.callback(err, data);\n });\n }\n};\n\n/**\n * get privileges\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback\n * @return {Object} Name only if callback isn't specified.\n */\nPlugin.prototype.privileges = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/privileges?',\n method: 'GET',\n options: {\n 'remote': this.remote\n },\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Installs a new plugin\n * @param {Object} opts Create options\n * @param {Function} callback Callback\n */\nPlugin.prototype.pull = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n if(args.opts._query && !args.opts._query.name) {\n args.opts._query.name = this.name;\n }\n if(args.opts._query && !args.opts._query.remote) {\n args.opts._query.remote = this.remote;\n }\n\n var optsf = {\n path: '/plugins/pull?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n isStream: true,\n options: args.opts,\n statusCodes: {\n 200: true, // unofficial, but proxies may return it\n 204: true,\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Enable\n * @param {Object} opts Plugin enable options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.enable = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/enable?',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Disable\n * @param {Object} opts Plugin disable options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.disable = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/disable',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Push\n * @param {Object} opts Plugin push options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.push = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/push',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * COnfigure\n * @param {Object} opts Plugin configure options (optional)\n * @param {Function} callback Callback\n */\nPlugin.prototype.configure = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/plugins/' + this.name + '/set',\n method: 'POST',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n/**\n * Upgrade plugin\n *\n * @param {object} auth\n * @param {object} opts\n * @param {function} callback\n */\nPlugin.prototype.upgrade = function(auth, opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n }\n\n var optsf = {\n path: '/plugins/' + this.name + '/upgrade?',\n method: 'POST',\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'plugin not installed',\n 500: 'server error'\n },\n authconfig: auth,\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Plugin;\n","var util = require('./util');\n\n/**\n * Represents a secret\n * @param {Object} modem docker-modem\n * @param {String} id Secret's id\n */\nvar Secret = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nSecret.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nSecret.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets/' + this.id,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'secret not found',\n 406: 'node is not part of a swarm',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update a secret.\n *\n * @param {object} opts\n * @param {function} callback\n */\nSecret.prototype.update = function(opts, callback) {\n var self = this;\n if (!callback && typeof opts === 'function') {\n callback = opts;\n }\n\n var optsf = {\n path: '/secrets/' + this.id + '/update?',\n method: 'POST',\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'secret not found',\n 500: 'server error'\n },\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n/**\n * Removes the secret\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nSecret.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/secrets/' + this.id,\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'secret not found',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Secret;\n","var util = require('./util');\n\n/**\n * Represents an Service\n * @param {Object} modem docker-modem\n * @param {String} id Service's ID\n */\nvar Service = function(modem, id) {\n this.modem = modem;\n this.id = id;\n};\n\nService.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for service details.\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nService.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/services/' + this.id,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Delete Service\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nService.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/services/' + this.id,\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 204: true,\n 404: 'no such service',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Update service\n *\n * @param {object} auth\n * @param {object} opts\n * @param {function} callback\n */\nService.prototype.update = function(auth, opts, callback) {\n var self = this;\n if (!callback) {\n var t = typeof opts;\n if(t === 'function'){\n callback = opts;\n opts = auth;\n auth = opts.authconfig || undefined;\n } else if (t === 'undefined'){\n opts = auth;\n auth = opts.authconfig || undefined;\n }\n }\n\n var optsf = {\n path: '/services/' + this.id + '/update?',\n method: 'POST',\n abortSignal: opts && opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error'\n },\n authconfig: auth,\n options: opts\n };\n\n if(callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n callback(err, data);\n });\n }\n};\n\n\n\n/**\n * Service logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nService.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, {});\n\n var optsf = {\n path: '/services/' + this.id + '/logs?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: args.opts.follow || false,\n statusCodes: {\n 200: true,\n 404: 'no such service',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\n\nmodule.exports = Service;\n","var util = require('./util');\n\n/**\n * Represents an Task\n * @param {Object} modem docker-modem\n * @param {String} id Task's ID\n */\nvar Task = function(modem, id) {\n this.modem = modem;\n this.id = id;\n\n this.defaultOptions = {\n log: {}\n };\n};\n\nTask.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Query Docker for Task details.\n *\n * @param {Object} opts Options (optional)\n * @param {function} callback\n */\nTask.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/tasks/' + this.id,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'unknown task',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Task logs\n * @param {Object} opts Logs options. (optional)\n * @param {Function} callback Callback with data\n */\nTask.prototype.logs = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback, this.defaultOptions.log);\n\n var optsf = {\n path: '/tasks/' + this.id + '/logs?',\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n isStream: args.opts.follow || false,\n statusCodes: {\n 101: true,\n 200: true,\n 404: 'no such container',\n 500: 'server error',\n 503: 'node is not part of a swarm'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n\nmodule.exports = Task;\n","// https://github.com/HenrikJoreteg/extend-object/blob/v0.1.0/extend-object.js\n\nvar arr = [];\nvar each = arr.forEach;\nvar slice = arr.slice;\n\nmodule.exports.extend = function(obj) {\n each.call(slice.call(arguments, 1), function(source) {\n if (source) {\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n });\n return obj;\n};\n\nmodule.exports.processArgs = function(opts, callback, defaultOpts) {\n if (!callback && typeof opts === 'function') {\n callback = opts;\n opts = null;\n }\n return {\n callback: callback,\n opts: module.exports.extend({}, defaultOpts, opts)\n };\n};\n\n\n/**\n * Parse the given repo tag name (as a string) and break it out into repo/tag pair.\n * // if given the input http://localhost:8080/woot:latest\n * {\n * repository: 'http://localhost:8080/woot',\n * tag: 'latest'\n * }\n * @param {String} input Input e.g: 'repo/foo', 'ubuntu', 'ubuntu:latest'\n * @return {Object} input parsed into the repo and tag.\n */\nmodule.exports.parseRepositoryTag = function(input) {\n var separatorPos;\n var digestPos = input.indexOf('@');\n var colonPos = input.lastIndexOf(':');\n // @ symbol is more important\n if (digestPos >= 0) {\n separatorPos = digestPos;\n } else if (colonPos >= 0) {\n separatorPos = colonPos;\n } else {\n // no colon nor @\n return {\n repository: input\n };\n }\n\n // last colon is either the tag (or part of a port designation)\n var tag = input.slice(separatorPos + 1);\n\n // if it contains a / its not a tag and is part of the url\n if (tag.indexOf('/') === -1) {\n return {\n repository: input.slice(0, separatorPos),\n tag: tag\n };\n }\n\n return {\n repository: input\n };\n};\n","var util = require('./util');\n\n/**\n * Represents a volume\n * @param {Object} modem docker-modem\n * @param {String} name Volume's name\n */\nvar Volume = function(modem, name) {\n this.modem = modem;\n this.name = name;\n};\n\nVolume.prototype[require('util').inspect.custom] = function() { return this; };\n\n/**\n * Inspect\n * @param {Object} opts Options (optional)\n * @param {Function} callback Callback, if specified Docker will be queried.\n * @return {Object} Name only if callback isn't specified.\n */\nVolume.prototype.inspect = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/' + this.name,\n method: 'GET',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 200: true,\n 404: 'no such volume',\n 500: 'server error'\n }\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\n/**\n * Removes the volume\n * @param {[Object]} opts Remove options (optional)\n * @param {Function} callback Callback\n */\nVolume.prototype.remove = function(opts, callback) {\n var self = this;\n var args = util.processArgs(opts, callback);\n\n var optsf = {\n path: '/volumes/' + this.name,\n method: 'DELETE',\n abortSignal: args.opts.abortSignal,\n statusCodes: {\n 204: true,\n 404: 'no such volume',\n 409: 'conflict',\n 500: 'server error'\n },\n options: args.opts\n };\n\n if(args.callback === undefined) {\n return new this.modem.Promise(function(resolve, reject) {\n self.modem.dial(optsf, function(err, data) {\n if (err) {\n return reject(err);\n }\n resolve(data);\n });\n });\n } else {\n this.modem.dial(optsf, function(err, data) {\n args.callback(err, data);\n });\n }\n};\n\nmodule.exports = Volume;\n","var once = require('once');\n\nvar noop = function() {};\n\nvar isRequest = function(stream) {\n\treturn stream.setHeader && typeof stream.abort === 'function';\n};\n\nvar isChildProcess = function(stream) {\n\treturn stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3\n};\n\nvar eos = function(stream, opts, callback) {\n\tif (typeof opts === 'function') return eos(stream, null, opts);\n\tif (!opts) opts = {};\n\n\tcallback = once(callback || noop);\n\n\tvar ws = stream._writableState;\n\tvar rs = stream._readableState;\n\tvar readable = opts.readable || (opts.readable !== false && stream.readable);\n\tvar writable = opts.writable || (opts.writable !== false && stream.writable);\n\tvar cancelled = false;\n\n\tvar onlegacyfinish = function() {\n\t\tif (!stream.writable) onfinish();\n\t};\n\n\tvar onfinish = function() {\n\t\twritable = false;\n\t\tif (!readable) callback.call(stream);\n\t};\n\n\tvar onend = function() {\n\t\treadable = false;\n\t\tif (!writable) callback.call(stream);\n\t};\n\n\tvar onexit = function(exitCode) {\n\t\tcallback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);\n\t};\n\n\tvar onerror = function(err) {\n\t\tcallback.call(stream, err);\n\t};\n\n\tvar onclose = function() {\n\t\tprocess.nextTick(onclosenexttick);\n\t};\n\n\tvar onclosenexttick = function() {\n\t\tif (cancelled) return;\n\t\tif (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close'));\n\t\tif (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close'));\n\t};\n\n\tvar onrequest = function() {\n\t\tstream.req.on('finish', onfinish);\n\t};\n\n\tif (isRequest(stream)) {\n\t\tstream.on('complete', onfinish);\n\t\tstream.on('abort', onclose);\n\t\tif (stream.req) onrequest();\n\t\telse stream.on('request', onrequest);\n\t} else if (writable && !ws) { // legacy streams\n\t\tstream.on('end', onlegacyfinish);\n\t\tstream.on('close', onlegacyfinish);\n\t}\n\n\tif (isChildProcess(stream)) stream.on('exit', onexit);\n\n\tstream.on('end', onend);\n\tstream.on('finish', onfinish);\n\tif (opts.error !== false) stream.on('error', onerror);\n\tstream.on('close', onclose);\n\n\treturn function() {\n\t\tcancelled = true;\n\t\tstream.removeListener('complete', onfinish);\n\t\tstream.removeListener('abort', onclose);\n\t\tstream.removeListener('request', onrequest);\n\t\tif (stream.req) stream.req.removeListener('finish', onfinish);\n\t\tstream.removeListener('end', onlegacyfinish);\n\t\tstream.removeListener('close', onlegacyfinish);\n\t\tstream.removeListener('finish', onfinish);\n\t\tstream.removeListener('exit', onexit);\n\t\tstream.removeListener('end', onend);\n\t\tstream.removeListener('error', onerror);\n\t\tstream.removeListener('close', onclose);\n\t};\n};\n\nmodule.exports = eos;\n","var debug;\n\nmodule.exports = function () {\n if (!debug) {\n try {\n /* eslint global-require: off */\n debug = require(\"debug\")(\"follow-redirects\");\n }\n catch (error) { /* */ }\n if (typeof debug !== \"function\") {\n debug = function () { /* */ };\n }\n }\n debug.apply(null, arguments);\n};\n","var url = require(\"url\");\nvar URL = url.URL;\nvar http = require(\"http\");\nvar https = require(\"https\");\nvar Writable = require(\"stream\").Writable;\nvar assert = require(\"assert\");\nvar debug = require(\"./debug\");\n\n// Create handlers that pass events from native requests\nvar events = [\"abort\", \"aborted\", \"connect\", \"error\", \"socket\", \"timeout\"];\nvar eventHandlers = Object.create(null);\nevents.forEach(function (event) {\n eventHandlers[event] = function (arg1, arg2, arg3) {\n this._redirectable.emit(event, arg1, arg2, arg3);\n };\n});\n\n// Error types with codes\nvar RedirectionError = createErrorType(\n \"ERR_FR_REDIRECTION_FAILURE\",\n \"\"\n);\nvar TooManyRedirectsError = createErrorType(\n \"ERR_FR_TOO_MANY_REDIRECTS\",\n \"Maximum number of redirects exceeded\"\n);\nvar MaxBodyLengthExceededError = createErrorType(\n \"ERR_FR_MAX_BODY_LENGTH_EXCEEDED\",\n \"Request body larger than maxBodyLength limit\"\n);\nvar WriteAfterEndError = createErrorType(\n \"ERR_STREAM_WRITE_AFTER_END\",\n \"write after end\"\n);\n\n// An HTTP(S) request that can be redirected\nfunction RedirectableRequest(options, responseCallback) {\n // Initialize the request\n Writable.call(this);\n this._sanitizeOptions(options);\n this._options = options;\n this._ended = false;\n this._ending = false;\n this._redirectCount = 0;\n this._redirects = [];\n this._requestBodyLength = 0;\n this._requestBodyBuffers = [];\n\n // Attach a callback if passed\n if (responseCallback) {\n this.on(\"response\", responseCallback);\n }\n\n // React to responses of native requests\n var self = this;\n this._onNativeResponse = function (response) {\n self._processResponse(response);\n };\n\n // Perform the first request\n this._performRequest();\n}\nRedirectableRequest.prototype = Object.create(Writable.prototype);\n\nRedirectableRequest.prototype.abort = function () {\n abortRequest(this._currentRequest);\n this.emit(\"abort\");\n};\n\n// Writes buffered data to the current native request\nRedirectableRequest.prototype.write = function (data, encoding, callback) {\n // Writing is not allowed if end has been called\n if (this._ending) {\n throw new WriteAfterEndError();\n }\n\n // Validate input and shift parameters if necessary\n if (!(typeof data === \"string\" || typeof data === \"object\" && (\"length\" in data))) {\n throw new TypeError(\"data should be a string, Buffer or Uint8Array\");\n }\n if (typeof encoding === \"function\") {\n callback = encoding;\n encoding = null;\n }\n\n // Ignore empty buffers, since writing them doesn't invoke the callback\n // https://github.com/nodejs/node/issues/22066\n if (data.length === 0) {\n if (callback) {\n callback();\n }\n return;\n }\n // Only write when we don't exceed the maximum body length\n if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {\n this._requestBodyLength += data.length;\n this._requestBodyBuffers.push({ data: data, encoding: encoding });\n this._currentRequest.write(data, encoding, callback);\n }\n // Error when we exceed the maximum body length\n else {\n this.emit(\"error\", new MaxBodyLengthExceededError());\n this.abort();\n }\n};\n\n// Ends the current native request\nRedirectableRequest.prototype.end = function (data, encoding, callback) {\n // Shift parameters if necessary\n if (typeof data === \"function\") {\n callback = data;\n data = encoding = null;\n }\n else if (typeof encoding === \"function\") {\n callback = encoding;\n encoding = null;\n }\n\n // Write data if needed and end\n if (!data) {\n this._ended = this._ending = true;\n this._currentRequest.end(null, null, callback);\n }\n else {\n var self = this;\n var currentRequest = this._currentRequest;\n this.write(data, encoding, function () {\n self._ended = true;\n currentRequest.end(null, null, callback);\n });\n this._ending = true;\n }\n};\n\n// Sets a header value on the current native request\nRedirectableRequest.prototype.setHeader = function (name, value) {\n this._options.headers[name] = value;\n this._currentRequest.setHeader(name, value);\n};\n\n// Clears a header value on the current native request\nRedirectableRequest.prototype.removeHeader = function (name) {\n delete this._options.headers[name];\n this._currentRequest.removeHeader(name);\n};\n\n// Global timeout for all underlying requests\nRedirectableRequest.prototype.setTimeout = function (msecs, callback) {\n var self = this;\n\n // Destroys the socket on timeout\n function destroyOnTimeout(socket) {\n socket.setTimeout(msecs);\n socket.removeListener(\"timeout\", socket.destroy);\n socket.addListener(\"timeout\", socket.destroy);\n }\n\n // Sets up a timer to trigger a timeout event\n function startTimer(socket) {\n if (self._timeout) {\n clearTimeout(self._timeout);\n }\n self._timeout = setTimeout(function () {\n self.emit(\"timeout\");\n clearTimer();\n }, msecs);\n destroyOnTimeout(socket);\n }\n\n // Stops a timeout from triggering\n function clearTimer() {\n if (self._timeout) {\n clearTimeout(self._timeout);\n self._timeout = null;\n }\n if (callback) {\n self.removeListener(\"timeout\", callback);\n }\n if (!self.socket) {\n self._currentRequest.removeListener(\"socket\", startTimer);\n }\n }\n\n // Attach callback if passed\n if (callback) {\n this.on(\"timeout\", callback);\n }\n\n // Start the timer if or when the socket is opened\n if (this.socket) {\n startTimer(this.socket);\n }\n else {\n this._currentRequest.once(\"socket\", startTimer);\n }\n\n // Clean up on events\n this.on(\"socket\", destroyOnTimeout);\n this.once(\"response\", clearTimer);\n this.once(\"error\", clearTimer);\n\n return this;\n};\n\n// Proxy all other public ClientRequest methods\n[\n \"flushHeaders\", \"getHeader\",\n \"setNoDelay\", \"setSocketKeepAlive\",\n].forEach(function (method) {\n RedirectableRequest.prototype[method] = function (a, b) {\n return this._currentRequest[method](a, b);\n };\n});\n\n// Proxy all public ClientRequest properties\n[\"aborted\", \"connection\", \"socket\"].forEach(function (property) {\n Object.defineProperty(RedirectableRequest.prototype, property, {\n get: function () { return this._currentRequest[property]; },\n });\n});\n\nRedirectableRequest.prototype._sanitizeOptions = function (options) {\n // Ensure headers are always present\n if (!options.headers) {\n options.headers = {};\n }\n\n // Since http.request treats host as an alias of hostname,\n // but the url module interprets host as hostname plus port,\n // eliminate the host property to avoid confusion.\n if (options.host) {\n // Use hostname if set, because it has precedence\n if (!options.hostname) {\n options.hostname = options.host;\n }\n delete options.host;\n }\n\n // Complete the URL object when necessary\n if (!options.pathname && options.path) {\n var searchPos = options.path.indexOf(\"?\");\n if (searchPos < 0) {\n options.pathname = options.path;\n }\n else {\n options.pathname = options.path.substring(0, searchPos);\n options.search = options.path.substring(searchPos);\n }\n }\n};\n\n\n// Executes the next native request (initial or redirect)\nRedirectableRequest.prototype._performRequest = function () {\n // Load the native protocol\n var protocol = this._options.protocol;\n var nativeProtocol = this._options.nativeProtocols[protocol];\n if (!nativeProtocol) {\n this.emit(\"error\", new TypeError(\"Unsupported protocol \" + protocol));\n return;\n }\n\n // If specified, use the agent corresponding to the protocol\n // (HTTP and HTTPS use different types of agents)\n if (this._options.agents) {\n var scheme = protocol.substr(0, protocol.length - 1);\n this._options.agent = this._options.agents[scheme];\n }\n\n // Create the native request\n var request = this._currentRequest =\n nativeProtocol.request(this._options, this._onNativeResponse);\n this._currentUrl = url.format(this._options);\n\n // Set up event handlers\n request._redirectable = this;\n for (var e = 0; e < events.length; e++) {\n request.on(events[e], eventHandlers[events[e]]);\n }\n\n // End a redirected request\n // (The first request must be ended explicitly with RedirectableRequest#end)\n if (this._isRedirect) {\n // Write the request entity and end.\n var i = 0;\n var self = this;\n var buffers = this._requestBodyBuffers;\n (function writeNext(error) {\n // Only write if this request has not been redirected yet\n /* istanbul ignore else */\n if (request === self._currentRequest) {\n // Report any write errors\n /* istanbul ignore if */\n if (error) {\n self.emit(\"error\", error);\n }\n // Write the next buffer if there are still left\n else if (i < buffers.length) {\n var buffer = buffers[i++];\n /* istanbul ignore else */\n if (!request.finished) {\n request.write(buffer.data, buffer.encoding, writeNext);\n }\n }\n // End the request if `end` has been called on us\n else if (self._ended) {\n request.end();\n }\n }\n }());\n }\n};\n\n// Processes a response from the current native request\nRedirectableRequest.prototype._processResponse = function (response) {\n // Store the redirected response\n var statusCode = response.statusCode;\n if (this._options.trackRedirects) {\n this._redirects.push({\n url: this._currentUrl,\n headers: response.headers,\n statusCode: statusCode,\n });\n }\n\n // RFC7231§6.4: The 3xx (Redirection) class of status code indicates\n // that further action needs to be taken by the user agent in order to\n // fulfill the request. If a Location header field is provided,\n // the user agent MAY automatically redirect its request to the URI\n // referenced by the Location field value,\n // even if the specific status code is not understood.\n var location = response.headers.location;\n if (location && this._options.followRedirects !== false &&\n statusCode >= 300 && statusCode < 400) {\n // Abort the current request\n abortRequest(this._currentRequest);\n // Discard the remainder of the response to avoid waiting for data\n response.destroy();\n\n // RFC7231§6.4: A client SHOULD detect and intervene\n // in cyclical redirections (i.e., \"infinite\" redirection loops).\n if (++this._redirectCount > this._options.maxRedirects) {\n this.emit(\"error\", new TooManyRedirectsError());\n return;\n }\n\n // RFC7231§6.4: Automatic redirection needs to done with\n // care for methods not known to be safe, […]\n // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change\n // the request method from POST to GET for the subsequent request.\n if ((statusCode === 301 || statusCode === 302) && this._options.method === \"POST\" ||\n // RFC7231§6.4.4: The 303 (See Other) status code indicates that\n // the server is redirecting the user agent to a different resource […]\n // A user agent can perform a retrieval request targeting that URI\n // (a GET or HEAD request if using HTTP) […]\n (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {\n this._options.method = \"GET\";\n // Drop a possible entity and headers related to it\n this._requestBodyBuffers = [];\n removeMatchingHeaders(/^content-/i, this._options.headers);\n }\n\n // Drop the Host header, as the redirect might lead to a different host\n var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) ||\n url.parse(this._currentUrl).hostname;\n\n // Create the redirected request\n var redirectUrl = url.resolve(this._currentUrl, location);\n debug(\"redirecting to\", redirectUrl);\n this._isRedirect = true;\n var redirectUrlParts = url.parse(redirectUrl);\n Object.assign(this._options, redirectUrlParts);\n\n // Drop the Authorization header if redirecting to another host\n if (redirectUrlParts.hostname !== previousHostName) {\n removeMatchingHeaders(/^authorization$/i, this._options.headers);\n }\n\n // Evaluate the beforeRedirect callback\n if (typeof this._options.beforeRedirect === \"function\") {\n var responseDetails = { headers: response.headers };\n try {\n this._options.beforeRedirect.call(null, this._options, responseDetails);\n }\n catch (err) {\n this.emit(\"error\", err);\n return;\n }\n this._sanitizeOptions(this._options);\n }\n\n // Perform the redirected request\n try {\n this._performRequest();\n }\n catch (cause) {\n var error = new RedirectionError(\"Redirected request failed: \" + cause.message);\n error.cause = cause;\n this.emit(\"error\", error);\n }\n }\n else {\n // The response is not a redirect; return it as-is\n response.responseUrl = this._currentUrl;\n response.redirects = this._redirects;\n this.emit(\"response\", response);\n\n // Clean up\n this._requestBodyBuffers = [];\n }\n};\n\n// Wraps the key/value object of protocols with redirect functionality\nfunction wrap(protocols) {\n // Default settings\n var exports = {\n maxRedirects: 21,\n maxBodyLength: 10 * 1024 * 1024,\n };\n\n // Wrap each protocol\n var nativeProtocols = {};\n Object.keys(protocols).forEach(function (scheme) {\n var protocol = scheme + \":\";\n var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];\n var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);\n\n // Executes a request, following redirects\n function request(input, options, callback) {\n // Parse parameters\n if (typeof input === \"string\") {\n var urlStr = input;\n try {\n input = urlToOptions(new URL(urlStr));\n }\n catch (err) {\n /* istanbul ignore next */\n input = url.parse(urlStr);\n }\n }\n else if (URL && (input instanceof URL)) {\n input = urlToOptions(input);\n }\n else {\n callback = options;\n options = input;\n input = { protocol: protocol };\n }\n if (typeof options === \"function\") {\n callback = options;\n options = null;\n }\n\n // Set defaults\n options = Object.assign({\n maxRedirects: exports.maxRedirects,\n maxBodyLength: exports.maxBodyLength,\n }, input, options);\n options.nativeProtocols = nativeProtocols;\n\n assert.equal(options.protocol, protocol, \"protocol mismatch\");\n debug(\"options\", options);\n return new RedirectableRequest(options, callback);\n }\n\n // Executes a GET request, following redirects\n function get(input, options, callback) {\n var wrappedRequest = wrappedProtocol.request(input, options, callback);\n wrappedRequest.end();\n return wrappedRequest;\n }\n\n // Expose the properties on the wrapped protocol\n Object.defineProperties(wrappedProtocol, {\n request: { value: request, configurable: true, enumerable: true, writable: true },\n get: { value: get, configurable: true, enumerable: true, writable: true },\n });\n });\n return exports;\n}\n\n/* istanbul ignore next */\nfunction noop() { /* empty */ }\n\n// from https://github.com/nodejs/node/blob/master/lib/internal/url.js\nfunction urlToOptions(urlObject) {\n var options = {\n protocol: urlObject.protocol,\n hostname: urlObject.hostname.startsWith(\"[\") ?\n /* istanbul ignore next */\n urlObject.hostname.slice(1, -1) :\n urlObject.hostname,\n hash: urlObject.hash,\n search: urlObject.search,\n pathname: urlObject.pathname,\n path: urlObject.pathname + urlObject.search,\n href: urlObject.href,\n };\n if (urlObject.port !== \"\") {\n options.port = Number(urlObject.port);\n }\n return options;\n}\n\nfunction removeMatchingHeaders(regex, headers) {\n var lastValue;\n for (var header in headers) {\n if (regex.test(header)) {\n lastValue = headers[header];\n delete headers[header];\n }\n }\n return lastValue;\n}\n\nfunction createErrorType(code, defaultMessage) {\n function CustomError(message) {\n Error.captureStackTrace(this, this.constructor);\n this.message = message || defaultMessage;\n }\n CustomError.prototype = new Error();\n CustomError.prototype.constructor = CustomError;\n CustomError.prototype.name = \"Error [\" + code + \"]\";\n CustomError.prototype.code = code;\n return CustomError;\n}\n\nfunction abortRequest(request) {\n for (var e = 0; e < events.length; e++) {\n request.removeListener(events[e], eventHandlers[events[e]]);\n }\n request.on(\"error\", noop);\n request.abort();\n}\n\n// Exports\nmodule.exports = wrap({ http: http, https: https });\nmodule.exports.wrap = wrap;\n","module.exports = require('fs').constants || require('constants')\n","'use strict';\n\nmodule.exports = (flag, argv = process.argv) => {\n\tconst prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');\n\tconst position = argv.indexOf(prefix + flag);\n\tconst terminatorPosition = argv.indexOf('--');\n\treturn position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n};\n","try {\n var util = require('util');\n /* istanbul ignore next */\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n /* istanbul ignore next */\n module.exports = require('./inherits_browser.js');\n}\n","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n }\n}\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\n/*!\n * is-plain-object \n *\n * Copyright (c) 2014-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\n\nfunction isObject(o) {\n return Object.prototype.toString.call(o) === '[object Object]';\n}\n\nfunction isPlainObject(o) {\n var ctor,prot;\n\n if (isObject(o) === false) return false;\n\n // If has modified constructor\n ctor = o.constructor;\n if (ctor === undefined) return true;\n\n // If has modified prototype\n prot = ctor.prototype;\n if (isObject(prot) === false) return false;\n\n // If constructor does not have an Object-specific method\n if (prot.hasOwnProperty('isPrototypeOf') === false) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n\nexports.isPlainObject = isPlainObject;\n","var path = require('path');\nvar fs = require('fs');\nvar _0777 = parseInt('0777', 8);\n\nmodule.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;\n\nfunction mkdirP (p, opts, f, made) {\n if (typeof opts === 'function') {\n f = opts;\n opts = {};\n }\n else if (!opts || typeof opts !== 'object') {\n opts = { mode: opts };\n }\n \n var mode = opts.mode;\n var xfs = opts.fs || fs;\n \n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n \n var cb = f || function () {};\n p = path.resolve(p);\n \n xfs.mkdir(p, mode, function (er) {\n if (!er) {\n made = made || p;\n return cb(null, made);\n }\n switch (er.code) {\n case 'ENOENT':\n mkdirP(path.dirname(p), opts, function (er, made) {\n if (er) cb(er, made);\n else mkdirP(p, opts, cb, made);\n });\n break;\n\n // In the case of any other error, just see if there's a dir\n // there already. If so, then hooray! If not, then something\n // is borked.\n default:\n xfs.stat(p, function (er2, stat) {\n // if the stat fails, then that's super weird.\n // let the original error be the failure reason.\n if (er2 || !stat.isDirectory()) cb(er, made)\n else cb(null, made);\n });\n break;\n }\n });\n}\n\nmkdirP.sync = function sync (p, opts, made) {\n if (!opts || typeof opts !== 'object') {\n opts = { mode: opts };\n }\n \n var mode = opts.mode;\n var xfs = opts.fs || fs;\n \n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n\n p = path.resolve(p);\n\n try {\n xfs.mkdirSync(p, mode);\n made = made || p;\n }\n catch (err0) {\n switch (err0.code) {\n case 'ENOENT' :\n made = sync(path.dirname(p), opts, made);\n sync(p, opts, made);\n break;\n\n // In the case of any other error, just see if there's a dir\n // there already. If so, then hooray! If not, then something\n // is borked.\n default:\n var stat;\n try {\n stat = xfs.statSync(p);\n }\n catch (err1) {\n throw err0;\n }\n if (!stat.isDirectory()) throw err0;\n break;\n }\n }\n\n return made;\n};\n","/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar Stream = _interopDefault(require('stream'));\nvar http = _interopDefault(require('http'));\nvar Url = _interopDefault(require('url'));\nvar https = _interopDefault(require('https'));\nvar zlib = _interopDefault(require('zlib'));\n\n// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js\n\n// fix for \"Readable\" isn't a named export issue\nconst Readable = Stream.Readable;\n\nconst BUFFER = Symbol('buffer');\nconst TYPE = Symbol('type');\n\nclass Blob {\n\tconstructor() {\n\t\tthis[TYPE] = '';\n\n\t\tconst blobParts = arguments[0];\n\t\tconst options = arguments[1];\n\n\t\tconst buffers = [];\n\t\tlet size = 0;\n\n\t\tif (blobParts) {\n\t\t\tconst a = blobParts;\n\t\t\tconst length = Number(a.length);\n\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\tconst element = a[i];\n\t\t\t\tlet buffer;\n\t\t\t\tif (element instanceof Buffer) {\n\t\t\t\t\tbuffer = element;\n\t\t\t\t} else if (ArrayBuffer.isView(element)) {\n\t\t\t\t\tbuffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength);\n\t\t\t\t} else if (element instanceof ArrayBuffer) {\n\t\t\t\t\tbuffer = Buffer.from(element);\n\t\t\t\t} else if (element instanceof Blob) {\n\t\t\t\t\tbuffer = element[BUFFER];\n\t\t\t\t} else {\n\t\t\t\t\tbuffer = Buffer.from(typeof element === 'string' ? element : String(element));\n\t\t\t\t}\n\t\t\t\tsize += buffer.length;\n\t\t\t\tbuffers.push(buffer);\n\t\t\t}\n\t\t}\n\n\t\tthis[BUFFER] = Buffer.concat(buffers);\n\n\t\tlet type = options && options.type !== undefined && String(options.type).toLowerCase();\n\t\tif (type && !/[^\\u0020-\\u007E]/.test(type)) {\n\t\t\tthis[TYPE] = type;\n\t\t}\n\t}\n\tget size() {\n\t\treturn this[BUFFER].length;\n\t}\n\tget type() {\n\t\treturn this[TYPE];\n\t}\n\ttext() {\n\t\treturn Promise.resolve(this[BUFFER].toString());\n\t}\n\tarrayBuffer() {\n\t\tconst buf = this[BUFFER];\n\t\tconst ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n\t\treturn Promise.resolve(ab);\n\t}\n\tstream() {\n\t\tconst readable = new Readable();\n\t\treadable._read = function () {};\n\t\treadable.push(this[BUFFER]);\n\t\treadable.push(null);\n\t\treturn readable;\n\t}\n\ttoString() {\n\t\treturn '[object Blob]';\n\t}\n\tslice() {\n\t\tconst size = this.size;\n\n\t\tconst start = arguments[0];\n\t\tconst end = arguments[1];\n\t\tlet relativeStart, relativeEnd;\n\t\tif (start === undefined) {\n\t\t\trelativeStart = 0;\n\t\t} else if (start < 0) {\n\t\t\trelativeStart = Math.max(size + start, 0);\n\t\t} else {\n\t\t\trelativeStart = Math.min(start, size);\n\t\t}\n\t\tif (end === undefined) {\n\t\t\trelativeEnd = size;\n\t\t} else if (end < 0) {\n\t\t\trelativeEnd = Math.max(size + end, 0);\n\t\t} else {\n\t\t\trelativeEnd = Math.min(end, size);\n\t\t}\n\t\tconst span = Math.max(relativeEnd - relativeStart, 0);\n\n\t\tconst buffer = this[BUFFER];\n\t\tconst slicedBuffer = buffer.slice(relativeStart, relativeStart + span);\n\t\tconst blob = new Blob([], { type: arguments[2] });\n\t\tblob[BUFFER] = slicedBuffer;\n\t\treturn blob;\n\t}\n}\n\nObject.defineProperties(Blob.prototype, {\n\tsize: { enumerable: true },\n\ttype: { enumerable: true },\n\tslice: { enumerable: true }\n});\n\nObject.defineProperty(Blob.prototype, Symbol.toStringTag, {\n\tvalue: 'Blob',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\n/**\n * fetch-error.js\n *\n * FetchError interface for operational errors\n */\n\n/**\n * Create FetchError instance\n *\n * @param String message Error message for human\n * @param String type Error type for machine\n * @param String systemError For Node.js system error\n * @return FetchError\n */\nfunction FetchError(message, type, systemError) {\n Error.call(this, message);\n\n this.message = message;\n this.type = type;\n\n // when err.type is `system`, err.code contains system error code\n if (systemError) {\n this.code = this.errno = systemError.code;\n }\n\n // hide custom error implementation details from end-users\n Error.captureStackTrace(this, this.constructor);\n}\n\nFetchError.prototype = Object.create(Error.prototype);\nFetchError.prototype.constructor = FetchError;\nFetchError.prototype.name = 'FetchError';\n\nlet convert;\ntry {\n\tconvert = require('encoding').convert;\n} catch (e) {}\n\nconst INTERNALS = Symbol('Body internals');\n\n// fix an issue where \"PassThrough\" isn't a named export for node <10\nconst PassThrough = Stream.PassThrough;\n\n/**\n * Body mixin\n *\n * Ref: https://fetch.spec.whatwg.org/#body\n *\n * @param Stream body Readable stream\n * @param Object opts Response options\n * @return Void\n */\nfunction Body(body) {\n\tvar _this = this;\n\n\tvar _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n\t _ref$size = _ref.size;\n\n\tlet size = _ref$size === undefined ? 0 : _ref$size;\n\tvar _ref$timeout = _ref.timeout;\n\tlet timeout = _ref$timeout === undefined ? 0 : _ref$timeout;\n\n\tif (body == null) {\n\t\t// body is undefined or null\n\t\tbody = null;\n\t} else if (isURLSearchParams(body)) {\n\t\t// body is a URLSearchParams\n\t\tbody = Buffer.from(body.toString());\n\t} else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {\n\t\t// body is ArrayBuffer\n\t\tbody = Buffer.from(body);\n\t} else if (ArrayBuffer.isView(body)) {\n\t\t// body is ArrayBufferView\n\t\tbody = Buffer.from(body.buffer, body.byteOffset, body.byteLength);\n\t} else if (body instanceof Stream) ; else {\n\t\t// none of the above\n\t\t// coerce to string then buffer\n\t\tbody = Buffer.from(String(body));\n\t}\n\tthis[INTERNALS] = {\n\t\tbody,\n\t\tdisturbed: false,\n\t\terror: null\n\t};\n\tthis.size = size;\n\tthis.timeout = timeout;\n\n\tif (body instanceof Stream) {\n\t\tbody.on('error', function (err) {\n\t\t\tconst error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err);\n\t\t\t_this[INTERNALS].error = error;\n\t\t});\n\t}\n}\n\nBody.prototype = {\n\tget body() {\n\t\treturn this[INTERNALS].body;\n\t},\n\n\tget bodyUsed() {\n\t\treturn this[INTERNALS].disturbed;\n\t},\n\n\t/**\n * Decode response as ArrayBuffer\n *\n * @return Promise\n */\n\tarrayBuffer() {\n\t\treturn consumeBody.call(this).then(function (buf) {\n\t\t\treturn buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n\t\t});\n\t},\n\n\t/**\n * Return raw response as Blob\n *\n * @return Promise\n */\n\tblob() {\n\t\tlet ct = this.headers && this.headers.get('content-type') || '';\n\t\treturn consumeBody.call(this).then(function (buf) {\n\t\t\treturn Object.assign(\n\t\t\t// Prevent copying\n\t\t\tnew Blob([], {\n\t\t\t\ttype: ct.toLowerCase()\n\t\t\t}), {\n\t\t\t\t[BUFFER]: buf\n\t\t\t});\n\t\t});\n\t},\n\n\t/**\n * Decode response as json\n *\n * @return Promise\n */\n\tjson() {\n\t\tvar _this2 = this;\n\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(buffer.toString());\n\t\t\t} catch (err) {\n\t\t\t\treturn Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));\n\t\t\t}\n\t\t});\n\t},\n\n\t/**\n * Decode response as text\n *\n * @return Promise\n */\n\ttext() {\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\treturn buffer.toString();\n\t\t});\n\t},\n\n\t/**\n * Decode response as buffer (non-spec api)\n *\n * @return Promise\n */\n\tbuffer() {\n\t\treturn consumeBody.call(this);\n\t},\n\n\t/**\n * Decode response as text, while automatically detecting the encoding and\n * trying to decode to UTF-8 (non-spec api)\n *\n * @return Promise\n */\n\ttextConverted() {\n\t\tvar _this3 = this;\n\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\treturn convertBody(buffer, _this3.headers);\n\t\t});\n\t}\n};\n\n// In browsers, all properties are enumerable.\nObject.defineProperties(Body.prototype, {\n\tbody: { enumerable: true },\n\tbodyUsed: { enumerable: true },\n\tarrayBuffer: { enumerable: true },\n\tblob: { enumerable: true },\n\tjson: { enumerable: true },\n\ttext: { enumerable: true }\n});\n\nBody.mixIn = function (proto) {\n\tfor (const name of Object.getOwnPropertyNames(Body.prototype)) {\n\t\t// istanbul ignore else: future proof\n\t\tif (!(name in proto)) {\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(Body.prototype, name);\n\t\t\tObject.defineProperty(proto, name, desc);\n\t\t}\n\t}\n};\n\n/**\n * Consume and convert an entire Body to a Buffer.\n *\n * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body\n *\n * @return Promise\n */\nfunction consumeBody() {\n\tvar _this4 = this;\n\n\tif (this[INTERNALS].disturbed) {\n\t\treturn Body.Promise.reject(new TypeError(`body used already for: ${this.url}`));\n\t}\n\n\tthis[INTERNALS].disturbed = true;\n\n\tif (this[INTERNALS].error) {\n\t\treturn Body.Promise.reject(this[INTERNALS].error);\n\t}\n\n\tlet body = this.body;\n\n\t// body is null\n\tif (body === null) {\n\t\treturn Body.Promise.resolve(Buffer.alloc(0));\n\t}\n\n\t// body is blob\n\tif (isBlob(body)) {\n\t\tbody = body.stream();\n\t}\n\n\t// body is buffer\n\tif (Buffer.isBuffer(body)) {\n\t\treturn Body.Promise.resolve(body);\n\t}\n\n\t// istanbul ignore if: should never happen\n\tif (!(body instanceof Stream)) {\n\t\treturn Body.Promise.resolve(Buffer.alloc(0));\n\t}\n\n\t// body is stream\n\t// get ready to actually consume the body\n\tlet accum = [];\n\tlet accumBytes = 0;\n\tlet abort = false;\n\n\treturn new Body.Promise(function (resolve, reject) {\n\t\tlet resTimeout;\n\n\t\t// allow timeout on slow response body\n\t\tif (_this4.timeout) {\n\t\t\tresTimeout = setTimeout(function () {\n\t\t\t\tabort = true;\n\t\t\t\treject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout'));\n\t\t\t}, _this4.timeout);\n\t\t}\n\n\t\t// handle stream errors\n\t\tbody.on('error', function (err) {\n\t\t\tif (err.name === 'AbortError') {\n\t\t\t\t// if the request was aborted, reject with this Error\n\t\t\t\tabort = true;\n\t\t\t\treject(err);\n\t\t\t} else {\n\t\t\t\t// other errors, such as incorrect content-encoding\n\t\t\t\treject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));\n\t\t\t}\n\t\t});\n\n\t\tbody.on('data', function (chunk) {\n\t\t\tif (abort || chunk === null) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (_this4.size && accumBytes + chunk.length > _this4.size) {\n\t\t\t\tabort = true;\n\t\t\t\treject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size'));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\taccumBytes += chunk.length;\n\t\t\taccum.push(chunk);\n\t\t});\n\n\t\tbody.on('end', function () {\n\t\t\tif (abort) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tclearTimeout(resTimeout);\n\n\t\t\ttry {\n\t\t\t\tresolve(Buffer.concat(accum, accumBytes));\n\t\t\t} catch (err) {\n\t\t\t\t// handle streams that have accumulated too much data (issue #414)\n\t\t\t\treject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err));\n\t\t\t}\n\t\t});\n\t});\n}\n\n/**\n * Detect buffer encoding and convert to target encoding\n * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding\n *\n * @param Buffer buffer Incoming buffer\n * @param String encoding Target encoding\n * @return String\n */\nfunction convertBody(buffer, headers) {\n\tif (typeof convert !== 'function') {\n\t\tthrow new Error('The package `encoding` must be installed to use the textConverted() function');\n\t}\n\n\tconst ct = headers.get('content-type');\n\tlet charset = 'utf-8';\n\tlet res, str;\n\n\t// header\n\tif (ct) {\n\t\tres = /charset=([^;]*)/i.exec(ct);\n\t}\n\n\t// no charset in content type, peek at response body for at most 1024 bytes\n\tstr = buffer.slice(0, 1024).toString();\n\n\t// html5\n\tif (!res && str) {\n\t\tres = / 0 && arguments[0] !== undefined ? arguments[0] : undefined;\n\n\t\tthis[MAP] = Object.create(null);\n\n\t\tif (init instanceof Headers) {\n\t\t\tconst rawHeaders = init.raw();\n\t\t\tconst headerNames = Object.keys(rawHeaders);\n\n\t\t\tfor (const headerName of headerNames) {\n\t\t\t\tfor (const value of rawHeaders[headerName]) {\n\t\t\t\t\tthis.append(headerName, value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't worry about converting prop to ByteString here as append()\n\t\t// will handle it.\n\t\tif (init == null) ; else if (typeof init === 'object') {\n\t\t\tconst method = init[Symbol.iterator];\n\t\t\tif (method != null) {\n\t\t\t\tif (typeof method !== 'function') {\n\t\t\t\t\tthrow new TypeError('Header pairs must be iterable');\n\t\t\t\t}\n\n\t\t\t\t// sequence>\n\t\t\t\t// Note: per spec we have to first exhaust the lists then process them\n\t\t\t\tconst pairs = [];\n\t\t\t\tfor (const pair of init) {\n\t\t\t\t\tif (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') {\n\t\t\t\t\t\tthrow new TypeError('Each header pair must be iterable');\n\t\t\t\t\t}\n\t\t\t\t\tpairs.push(Array.from(pair));\n\t\t\t\t}\n\n\t\t\t\tfor (const pair of pairs) {\n\t\t\t\t\tif (pair.length !== 2) {\n\t\t\t\t\t\tthrow new TypeError('Each header pair must be a name/value tuple');\n\t\t\t\t\t}\n\t\t\t\t\tthis.append(pair[0], pair[1]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// record\n\t\t\t\tfor (const key of Object.keys(init)) {\n\t\t\t\t\tconst value = init[key];\n\t\t\t\t\tthis.append(key, value);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Provided initializer must be an object');\n\t\t}\n\t}\n\n\t/**\n * Return combined header value given name\n *\n * @param String name Header name\n * @return Mixed\n */\n\tget(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key === undefined) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this[MAP][key].join(', ');\n\t}\n\n\t/**\n * Iterate over all headers\n *\n * @param Function callback Executed for each item with parameters (value, name, thisArg)\n * @param Boolean thisArg `this` context for callback function\n * @return Void\n */\n\tforEach(callback) {\n\t\tlet thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;\n\n\t\tlet pairs = getHeaders(this);\n\t\tlet i = 0;\n\t\twhile (i < pairs.length) {\n\t\t\tvar _pairs$i = pairs[i];\n\t\t\tconst name = _pairs$i[0],\n\t\t\t value = _pairs$i[1];\n\n\t\t\tcallback.call(thisArg, value, name, this);\n\t\t\tpairs = getHeaders(this);\n\t\t\ti++;\n\t\t}\n\t}\n\n\t/**\n * Overwrite header values given name\n *\n * @param String name Header name\n * @param String value Header value\n * @return Void\n */\n\tset(name, value) {\n\t\tname = `${name}`;\n\t\tvalue = `${value}`;\n\t\tvalidateName(name);\n\t\tvalidateValue(value);\n\t\tconst key = find(this[MAP], name);\n\t\tthis[MAP][key !== undefined ? key : name] = [value];\n\t}\n\n\t/**\n * Append a value onto existing header\n *\n * @param String name Header name\n * @param String value Header value\n * @return Void\n */\n\tappend(name, value) {\n\t\tname = `${name}`;\n\t\tvalue = `${value}`;\n\t\tvalidateName(name);\n\t\tvalidateValue(value);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tthis[MAP][key].push(value);\n\t\t} else {\n\t\t\tthis[MAP][name] = [value];\n\t\t}\n\t}\n\n\t/**\n * Check for header name existence\n *\n * @param String name Header name\n * @return Boolean\n */\n\thas(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\treturn find(this[MAP], name) !== undefined;\n\t}\n\n\t/**\n * Delete all header values given name\n *\n * @param String name Header name\n * @return Void\n */\n\tdelete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}\n\n\t/**\n * Return raw headers (non-spec api)\n *\n * @return Object\n */\n\traw() {\n\t\treturn this[MAP];\n\t}\n\n\t/**\n * Get an iterator on keys.\n *\n * @return Iterator\n */\n\tkeys() {\n\t\treturn createHeadersIterator(this, 'key');\n\t}\n\n\t/**\n * Get an iterator on values.\n *\n * @return Iterator\n */\n\tvalues() {\n\t\treturn createHeadersIterator(this, 'value');\n\t}\n\n\t/**\n * Get an iterator on entries.\n *\n * This is the default iterator of the Headers object.\n *\n * @return Iterator\n */\n\t[Symbol.iterator]() {\n\t\treturn createHeadersIterator(this, 'key+value');\n\t}\n}\nHeaders.prototype.entries = Headers.prototype[Symbol.iterator];\n\nObject.defineProperty(Headers.prototype, Symbol.toStringTag, {\n\tvalue: 'Headers',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nObject.defineProperties(Headers.prototype, {\n\tget: { enumerable: true },\n\tforEach: { enumerable: true },\n\tset: { enumerable: true },\n\tappend: { enumerable: true },\n\thas: { enumerable: true },\n\tdelete: { enumerable: true },\n\tkeys: { enumerable: true },\n\tvalues: { enumerable: true },\n\tentries: { enumerable: true }\n});\n\nfunction getHeaders(headers) {\n\tlet kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value';\n\n\tconst keys = Object.keys(headers[MAP]).sort();\n\treturn keys.map(kind === 'key' ? function (k) {\n\t\treturn k.toLowerCase();\n\t} : kind === 'value' ? function (k) {\n\t\treturn headers[MAP][k].join(', ');\n\t} : function (k) {\n\t\treturn [k.toLowerCase(), headers[MAP][k].join(', ')];\n\t});\n}\n\nconst INTERNAL = Symbol('internal');\n\nfunction createHeadersIterator(target, kind) {\n\tconst iterator = Object.create(HeadersIteratorPrototype);\n\titerator[INTERNAL] = {\n\t\ttarget,\n\t\tkind,\n\t\tindex: 0\n\t};\n\treturn iterator;\n}\n\nconst HeadersIteratorPrototype = Object.setPrototypeOf({\n\tnext() {\n\t\t// istanbul ignore if\n\t\tif (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) {\n\t\t\tthrow new TypeError('Value of `this` is not a HeadersIterator');\n\t\t}\n\n\t\tvar _INTERNAL = this[INTERNAL];\n\t\tconst target = _INTERNAL.target,\n\t\t kind = _INTERNAL.kind,\n\t\t index = _INTERNAL.index;\n\n\t\tconst values = getHeaders(target, kind);\n\t\tconst len = values.length;\n\t\tif (index >= len) {\n\t\t\treturn {\n\t\t\t\tvalue: undefined,\n\t\t\t\tdone: true\n\t\t\t};\n\t\t}\n\n\t\tthis[INTERNAL].index = index + 1;\n\n\t\treturn {\n\t\t\tvalue: values[index],\n\t\t\tdone: false\n\t\t};\n\t}\n}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));\n\nObject.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, {\n\tvalue: 'HeadersIterator',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\n/**\n * Export the Headers object in a form that Node.js can consume.\n *\n * @param Headers headers\n * @return Object\n */\nfunction exportNodeCompatibleHeaders(headers) {\n\tconst obj = Object.assign({ __proto__: null }, headers[MAP]);\n\n\t// http.request() only supports string as Host header. This hack makes\n\t// specifying custom Host header possible.\n\tconst hostHeaderKey = find(headers[MAP], 'Host');\n\tif (hostHeaderKey !== undefined) {\n\t\tobj[hostHeaderKey] = obj[hostHeaderKey][0];\n\t}\n\n\treturn obj;\n}\n\n/**\n * Create a Headers object from an object of headers, ignoring those that do\n * not conform to HTTP grammar productions.\n *\n * @param Object obj Object of headers\n * @return Headers\n */\nfunction createHeadersLenient(obj) {\n\tconst headers = new Headers();\n\tfor (const name of Object.keys(obj)) {\n\t\tif (invalidTokenRegex.test(name)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (Array.isArray(obj[name])) {\n\t\t\tfor (const val of obj[name]) {\n\t\t\t\tif (invalidHeaderCharRegex.test(val)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (headers[MAP][name] === undefined) {\n\t\t\t\t\theaders[MAP][name] = [val];\n\t\t\t\t} else {\n\t\t\t\t\theaders[MAP][name].push(val);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!invalidHeaderCharRegex.test(obj[name])) {\n\t\t\theaders[MAP][name] = [obj[name]];\n\t\t}\n\t}\n\treturn headers;\n}\n\nconst INTERNALS$1 = Symbol('Response internals');\n\n// fix an issue where \"STATUS_CODES\" aren't a named export for node <10\nconst STATUS_CODES = http.STATUS_CODES;\n\n/**\n * Response class\n *\n * @param Stream body Readable stream\n * @param Object opts Response options\n * @return Void\n */\nclass Response {\n\tconstructor() {\n\t\tlet body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\t\tlet opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\t\tBody.call(this, body, opts);\n\n\t\tconst status = opts.status || 200;\n\t\tconst headers = new Headers(opts.headers);\n\n\t\tif (body != null && !headers.has('Content-Type')) {\n\t\t\tconst contentType = extractContentType(body);\n\t\t\tif (contentType) {\n\t\t\t\theaders.append('Content-Type', contentType);\n\t\t\t}\n\t\t}\n\n\t\tthis[INTERNALS$1] = {\n\t\t\turl: opts.url,\n\t\t\tstatus,\n\t\t\tstatusText: opts.statusText || STATUS_CODES[status],\n\t\t\theaders,\n\t\t\tcounter: opts.counter\n\t\t};\n\t}\n\n\tget url() {\n\t\treturn this[INTERNALS$1].url || '';\n\t}\n\n\tget status() {\n\t\treturn this[INTERNALS$1].status;\n\t}\n\n\t/**\n * Convenience property representing if the request ended normally\n */\n\tget ok() {\n\t\treturn this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;\n\t}\n\n\tget redirected() {\n\t\treturn this[INTERNALS$1].counter > 0;\n\t}\n\n\tget statusText() {\n\t\treturn this[INTERNALS$1].statusText;\n\t}\n\n\tget headers() {\n\t\treturn this[INTERNALS$1].headers;\n\t}\n\n\t/**\n * Clone this response\n *\n * @return Response\n */\n\tclone() {\n\t\treturn new Response(clone(this), {\n\t\t\turl: this.url,\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t\theaders: this.headers,\n\t\t\tok: this.ok,\n\t\t\tredirected: this.redirected\n\t\t});\n\t}\n}\n\nBody.mixIn(Response.prototype);\n\nObject.defineProperties(Response.prototype, {\n\turl: { enumerable: true },\n\tstatus: { enumerable: true },\n\tok: { enumerable: true },\n\tredirected: { enumerable: true },\n\tstatusText: { enumerable: true },\n\theaders: { enumerable: true },\n\tclone: { enumerable: true }\n});\n\nObject.defineProperty(Response.prototype, Symbol.toStringTag, {\n\tvalue: 'Response',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nconst INTERNALS$2 = Symbol('Request internals');\n\n// fix an issue where \"format\", \"parse\" aren't a named export for node <10\nconst parse_url = Url.parse;\nconst format_url = Url.format;\n\nconst streamDestructionSupported = 'destroy' in Stream.Readable.prototype;\n\n/**\n * Check if a value is an instance of Request.\n *\n * @param Mixed input\n * @return Boolean\n */\nfunction isRequest(input) {\n\treturn typeof input === 'object' && typeof input[INTERNALS$2] === 'object';\n}\n\nfunction isAbortSignal(signal) {\n\tconst proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal);\n\treturn !!(proto && proto.constructor.name === 'AbortSignal');\n}\n\n/**\n * Request class\n *\n * @param Mixed input Url or Request instance\n * @param Object init Custom options\n * @return Void\n */\nclass Request {\n\tconstructor(input) {\n\t\tlet init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\t\tlet parsedURL;\n\n\t\t// normalize input\n\t\tif (!isRequest(input)) {\n\t\t\tif (input && input.href) {\n\t\t\t\t// in order to support Node.js' Url objects; though WHATWG's URL objects\n\t\t\t\t// will fall into this branch also (since their `toString()` will return\n\t\t\t\t// `href` property anyway)\n\t\t\t\tparsedURL = parse_url(input.href);\n\t\t\t} else {\n\t\t\t\t// coerce input to a string before attempting to parse\n\t\t\t\tparsedURL = parse_url(`${input}`);\n\t\t\t}\n\t\t\tinput = {};\n\t\t} else {\n\t\t\tparsedURL = parse_url(input.url);\n\t\t}\n\n\t\tlet method = init.method || input.method || 'GET';\n\t\tmethod = method.toUpperCase();\n\n\t\tif ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) {\n\t\t\tthrow new TypeError('Request with GET/HEAD method cannot have body');\n\t\t}\n\n\t\tlet inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;\n\n\t\tBody.call(this, inputBody, {\n\t\t\ttimeout: init.timeout || input.timeout || 0,\n\t\t\tsize: init.size || input.size || 0\n\t\t});\n\n\t\tconst headers = new Headers(init.headers || input.headers || {});\n\n\t\tif (inputBody != null && !headers.has('Content-Type')) {\n\t\t\tconst contentType = extractContentType(inputBody);\n\t\t\tif (contentType) {\n\t\t\t\theaders.append('Content-Type', contentType);\n\t\t\t}\n\t\t}\n\n\t\tlet signal = isRequest(input) ? input.signal : null;\n\t\tif ('signal' in init) signal = init.signal;\n\n\t\tif (signal != null && !isAbortSignal(signal)) {\n\t\t\tthrow new TypeError('Expected signal to be an instanceof AbortSignal');\n\t\t}\n\n\t\tthis[INTERNALS$2] = {\n\t\t\tmethod,\n\t\t\tredirect: init.redirect || input.redirect || 'follow',\n\t\t\theaders,\n\t\t\tparsedURL,\n\t\t\tsignal\n\t\t};\n\n\t\t// node-fetch-only options\n\t\tthis.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20;\n\t\tthis.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true;\n\t\tthis.counter = init.counter || input.counter || 0;\n\t\tthis.agent = init.agent || input.agent;\n\t}\n\n\tget method() {\n\t\treturn this[INTERNALS$2].method;\n\t}\n\n\tget url() {\n\t\treturn format_url(this[INTERNALS$2].parsedURL);\n\t}\n\n\tget headers() {\n\t\treturn this[INTERNALS$2].headers;\n\t}\n\n\tget redirect() {\n\t\treturn this[INTERNALS$2].redirect;\n\t}\n\n\tget signal() {\n\t\treturn this[INTERNALS$2].signal;\n\t}\n\n\t/**\n * Clone this request\n *\n * @return Request\n */\n\tclone() {\n\t\treturn new Request(this);\n\t}\n}\n\nBody.mixIn(Request.prototype);\n\nObject.defineProperty(Request.prototype, Symbol.toStringTag, {\n\tvalue: 'Request',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nObject.defineProperties(Request.prototype, {\n\tmethod: { enumerable: true },\n\turl: { enumerable: true },\n\theaders: { enumerable: true },\n\tredirect: { enumerable: true },\n\tclone: { enumerable: true },\n\tsignal: { enumerable: true }\n});\n\n/**\n * Convert a Request to Node.js http request options.\n *\n * @param Request A Request instance\n * @return Object The options object to be passed to http.request\n */\nfunction getNodeRequestOptions(request) {\n\tconst parsedURL = request[INTERNALS$2].parsedURL;\n\tconst headers = new Headers(request[INTERNALS$2].headers);\n\n\t// fetch step 1.3\n\tif (!headers.has('Accept')) {\n\t\theaders.set('Accept', '*/*');\n\t}\n\n\t// Basic fetch\n\tif (!parsedURL.protocol || !parsedURL.hostname) {\n\t\tthrow new TypeError('Only absolute URLs are supported');\n\t}\n\n\tif (!/^https?:$/.test(parsedURL.protocol)) {\n\t\tthrow new TypeError('Only HTTP(S) protocols are supported');\n\t}\n\n\tif (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) {\n\t\tthrow new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8');\n\t}\n\n\t// HTTP-network-or-cache fetch steps 2.4-2.7\n\tlet contentLengthValue = null;\n\tif (request.body == null && /^(POST|PUT)$/i.test(request.method)) {\n\t\tcontentLengthValue = '0';\n\t}\n\tif (request.body != null) {\n\t\tconst totalBytes = getTotalBytes(request);\n\t\tif (typeof totalBytes === 'number') {\n\t\t\tcontentLengthValue = String(totalBytes);\n\t\t}\n\t}\n\tif (contentLengthValue) {\n\t\theaders.set('Content-Length', contentLengthValue);\n\t}\n\n\t// HTTP-network-or-cache fetch step 2.11\n\tif (!headers.has('User-Agent')) {\n\t\theaders.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)');\n\t}\n\n\t// HTTP-network-or-cache fetch step 2.15\n\tif (request.compress && !headers.has('Accept-Encoding')) {\n\t\theaders.set('Accept-Encoding', 'gzip,deflate');\n\t}\n\n\tlet agent = request.agent;\n\tif (typeof agent === 'function') {\n\t\tagent = agent(parsedURL);\n\t}\n\n\tif (!headers.has('Connection') && !agent) {\n\t\theaders.set('Connection', 'close');\n\t}\n\n\t// HTTP-network fetch step 4.2\n\t// chunked encoding is handled by Node.js\n\n\treturn Object.assign({}, parsedURL, {\n\t\tmethod: request.method,\n\t\theaders: exportNodeCompatibleHeaders(headers),\n\t\tagent\n\t});\n}\n\n/**\n * abort-error.js\n *\n * AbortError interface for cancelled requests\n */\n\n/**\n * Create AbortError instance\n *\n * @param String message Error message for human\n * @return AbortError\n */\nfunction AbortError(message) {\n Error.call(this, message);\n\n this.type = 'aborted';\n this.message = message;\n\n // hide custom error implementation details from end-users\n Error.captureStackTrace(this, this.constructor);\n}\n\nAbortError.prototype = Object.create(Error.prototype);\nAbortError.prototype.constructor = AbortError;\nAbortError.prototype.name = 'AbortError';\n\n// fix an issue where \"PassThrough\", \"resolve\" aren't a named export for node <10\nconst PassThrough$1 = Stream.PassThrough;\nconst resolve_url = Url.resolve;\n\n/**\n * Fetch function\n *\n * @param Mixed url Absolute url or Request instance\n * @param Object opts Fetch options\n * @return Promise\n */\nfunction fetch(url, opts) {\n\n\t// allow custom promise\n\tif (!fetch.Promise) {\n\t\tthrow new Error('native promise missing, set fetch.Promise to your favorite alternative');\n\t}\n\n\tBody.Promise = fetch.Promise;\n\n\t// wrap http.request into fetch\n\treturn new fetch.Promise(function (resolve, reject) {\n\t\t// build request object\n\t\tconst request = new Request(url, opts);\n\t\tconst options = getNodeRequestOptions(request);\n\n\t\tconst send = (options.protocol === 'https:' ? https : http).request;\n\t\tconst signal = request.signal;\n\n\t\tlet response = null;\n\n\t\tconst abort = function abort() {\n\t\t\tlet error = new AbortError('The user aborted a request.');\n\t\t\treject(error);\n\t\t\tif (request.body && request.body instanceof Stream.Readable) {\n\t\t\t\trequest.body.destroy(error);\n\t\t\t}\n\t\t\tif (!response || !response.body) return;\n\t\t\tresponse.body.emit('error', error);\n\t\t};\n\n\t\tif (signal && signal.aborted) {\n\t\t\tabort();\n\t\t\treturn;\n\t\t}\n\n\t\tconst abortAndFinalize = function abortAndFinalize() {\n\t\t\tabort();\n\t\t\tfinalize();\n\t\t};\n\n\t\t// send request\n\t\tconst req = send(options);\n\t\tlet reqTimeout;\n\n\t\tif (signal) {\n\t\t\tsignal.addEventListener('abort', abortAndFinalize);\n\t\t}\n\n\t\tfunction finalize() {\n\t\t\treq.abort();\n\t\t\tif (signal) signal.removeEventListener('abort', abortAndFinalize);\n\t\t\tclearTimeout(reqTimeout);\n\t\t}\n\n\t\tif (request.timeout) {\n\t\t\treq.once('socket', function (socket) {\n\t\t\t\treqTimeout = setTimeout(function () {\n\t\t\t\t\treject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout'));\n\t\t\t\t\tfinalize();\n\t\t\t\t}, request.timeout);\n\t\t\t});\n\t\t}\n\n\t\treq.on('error', function (err) {\n\t\t\treject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));\n\t\t\tfinalize();\n\t\t});\n\n\t\treq.on('response', function (res) {\n\t\t\tclearTimeout(reqTimeout);\n\n\t\t\tconst headers = createHeadersLenient(res.headers);\n\n\t\t\t// HTTP fetch step 5\n\t\t\tif (fetch.isRedirect(res.statusCode)) {\n\t\t\t\t// HTTP fetch step 5.2\n\t\t\t\tconst location = headers.get('Location');\n\n\t\t\t\t// HTTP fetch step 5.3\n\t\t\t\tconst locationURL = location === null ? null : resolve_url(request.url, location);\n\n\t\t\t\t// HTTP fetch step 5.5\n\t\t\t\tswitch (request.redirect) {\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\treject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));\n\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase 'manual':\n\t\t\t\t\t\t// node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL.\n\t\t\t\t\t\tif (locationURL !== null) {\n\t\t\t\t\t\t\t// handle corrupted header\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\theaders.set('Location', locationURL);\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\t// istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request\n\t\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'follow':\n\t\t\t\t\t\t// HTTP-redirect fetch step 2\n\t\t\t\t\t\tif (locationURL === null) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 5\n\t\t\t\t\t\tif (request.counter >= request.follow) {\n\t\t\t\t\t\t\treject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect'));\n\t\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 6 (counter increment)\n\t\t\t\t\t\t// Create a new Request object.\n\t\t\t\t\t\tconst requestOpts = {\n\t\t\t\t\t\t\theaders: new Headers(request.headers),\n\t\t\t\t\t\t\tfollow: request.follow,\n\t\t\t\t\t\t\tcounter: request.counter + 1,\n\t\t\t\t\t\t\tagent: request.agent,\n\t\t\t\t\t\t\tcompress: request.compress,\n\t\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\t\tbody: request.body,\n\t\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\t\ttimeout: request.timeout,\n\t\t\t\t\t\t\tsize: request.size\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 9\n\t\t\t\t\t\tif (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {\n\t\t\t\t\t\t\treject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));\n\t\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 11\n\t\t\t\t\t\tif (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') {\n\t\t\t\t\t\t\trequestOpts.method = 'GET';\n\t\t\t\t\t\t\trequestOpts.body = undefined;\n\t\t\t\t\t\t\trequestOpts.headers.delete('content-length');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 15\n\t\t\t\t\t\tresolve(fetch(new Request(locationURL, requestOpts)));\n\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// prepare response\n\t\t\tres.once('end', function () {\n\t\t\t\tif (signal) signal.removeEventListener('abort', abortAndFinalize);\n\t\t\t});\n\t\t\tlet body = res.pipe(new PassThrough$1());\n\n\t\t\tconst response_options = {\n\t\t\t\turl: request.url,\n\t\t\t\tstatus: res.statusCode,\n\t\t\t\tstatusText: res.statusMessage,\n\t\t\t\theaders: headers,\n\t\t\t\tsize: request.size,\n\t\t\t\ttimeout: request.timeout,\n\t\t\t\tcounter: request.counter\n\t\t\t};\n\n\t\t\t// HTTP-network fetch step 12.1.1.3\n\t\t\tconst codings = headers.get('Content-Encoding');\n\n\t\t\t// HTTP-network fetch step 12.1.1.4: handle content codings\n\n\t\t\t// in following scenarios we ignore compression support\n\t\t\t// 1. compression support is disabled\n\t\t\t// 2. HEAD request\n\t\t\t// 3. no Content-Encoding header\n\t\t\t// 4. no content response (204)\n\t\t\t// 5. content not modified response (304)\n\t\t\tif (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) {\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For Node v6+\n\t\t\t// Be less strict when decoding compressed responses, since sometimes\n\t\t\t// servers send slightly invalid responses that are still accepted\n\t\t\t// by common browsers.\n\t\t\t// Always using Z_SYNC_FLUSH is what cURL does.\n\t\t\tconst zlibOptions = {\n\t\t\t\tflush: zlib.Z_SYNC_FLUSH,\n\t\t\t\tfinishFlush: zlib.Z_SYNC_FLUSH\n\t\t\t};\n\n\t\t\t// for gzip\n\t\t\tif (codings == 'gzip' || codings == 'x-gzip') {\n\t\t\t\tbody = body.pipe(zlib.createGunzip(zlibOptions));\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// for deflate\n\t\t\tif (codings == 'deflate' || codings == 'x-deflate') {\n\t\t\t\t// handle the infamous raw deflate response from old servers\n\t\t\t\t// a hack for old IIS and Apache servers\n\t\t\t\tconst raw = res.pipe(new PassThrough$1());\n\t\t\t\traw.once('data', function (chunk) {\n\t\t\t\t\t// see http://stackoverflow.com/questions/37519828\n\t\t\t\t\tif ((chunk[0] & 0x0F) === 0x08) {\n\t\t\t\t\t\tbody = body.pipe(zlib.createInflate());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbody = body.pipe(zlib.createInflateRaw());\n\t\t\t\t\t}\n\t\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\t\tresolve(response);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// for br\n\t\t\tif (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') {\n\t\t\t\tbody = body.pipe(zlib.createBrotliDecompress());\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// otherwise, use response as-is\n\t\t\tresponse = new Response(body, response_options);\n\t\t\tresolve(response);\n\t\t});\n\n\t\twriteToStream(req, request);\n\t});\n}\n/**\n * Redirect code matching\n *\n * @param Number code Status code\n * @return Boolean\n */\nfetch.isRedirect = function (code) {\n\treturn code === 301 || code === 302 || code === 303 || code === 307 || code === 308;\n};\n\n// expose Promise\nfetch.Promise = global.Promise;\n\nmodule.exports = exports = fetch;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = exports;\nexports.Headers = Headers;\nexports.Request = Request;\nexports.Response = Response;\nexports.FetchError = FetchError;\n","/**\n * Advanced Encryption Standard (AES) implementation.\n *\n * This implementation is based on the public domain library 'jscrypto' which\n * was written by:\n *\n * Emily Stark (estark@stanford.edu)\n * Mike Hamburg (mhamburg@stanford.edu)\n * Dan Boneh (dabo@cs.stanford.edu)\n *\n * Parts of this code are based on the OpenSSL implementation of AES:\n * http://www.openssl.org\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./cipher');\nrequire('./cipherModes');\nrequire('./util');\n\n/* AES API */\nmodule.exports = forge.aes = forge.aes || {};\n\n/**\n * Deprecated. Instead, use:\n *\n * var cipher = forge.cipher.createCipher('AES-', key);\n * cipher.start({iv: iv});\n *\n * Creates an AES cipher object to encrypt data using the given symmetric key.\n * The output will be stored in the 'output' member of the returned cipher.\n *\n * The key and iv may be given as a string of bytes, an array of bytes,\n * a byte buffer, or an array of 32-bit words.\n *\n * @param key the symmetric key to use.\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.aes.startEncrypting = function(key, iv, output, mode) {\n var cipher = _createCipher({\n key: key,\n output: output,\n decrypt: false,\n mode: mode\n });\n cipher.start(iv);\n return cipher;\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var cipher = forge.cipher.createCipher('AES-', key);\n *\n * Creates an AES cipher object to encrypt data using the given symmetric key.\n *\n * The key may be given as a string of bytes, an array of bytes, a\n * byte buffer, or an array of 32-bit words.\n *\n * @param key the symmetric key to use.\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.aes.createEncryptionCipher = function(key, mode) {\n return _createCipher({\n key: key,\n output: null,\n decrypt: false,\n mode: mode\n });\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var decipher = forge.cipher.createDecipher('AES-', key);\n * decipher.start({iv: iv});\n *\n * Creates an AES cipher object to decrypt data using the given symmetric key.\n * The output will be stored in the 'output' member of the returned cipher.\n *\n * The key and iv may be given as a string of bytes, an array of bytes,\n * a byte buffer, or an array of 32-bit words.\n *\n * @param key the symmetric key to use.\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.aes.startDecrypting = function(key, iv, output, mode) {\n var cipher = _createCipher({\n key: key,\n output: output,\n decrypt: true,\n mode: mode\n });\n cipher.start(iv);\n return cipher;\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var decipher = forge.cipher.createDecipher('AES-', key);\n *\n * Creates an AES cipher object to decrypt data using the given symmetric key.\n *\n * The key may be given as a string of bytes, an array of bytes, a\n * byte buffer, or an array of 32-bit words.\n *\n * @param key the symmetric key to use.\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.aes.createDecryptionCipher = function(key, mode) {\n return _createCipher({\n key: key,\n output: null,\n decrypt: true,\n mode: mode\n });\n};\n\n/**\n * Creates a new AES cipher algorithm object.\n *\n * @param name the name of the algorithm.\n * @param mode the mode factory function.\n *\n * @return the AES algorithm object.\n */\nforge.aes.Algorithm = function(name, mode) {\n if(!init) {\n initialize();\n }\n var self = this;\n self.name = name;\n self.mode = new mode({\n blockSize: 16,\n cipher: {\n encrypt: function(inBlock, outBlock) {\n return _updateBlock(self._w, inBlock, outBlock, false);\n },\n decrypt: function(inBlock, outBlock) {\n return _updateBlock(self._w, inBlock, outBlock, true);\n }\n }\n });\n self._init = false;\n};\n\n/**\n * Initializes this AES algorithm by expanding its key.\n *\n * @param options the options to use.\n * key the key to use with this algorithm.\n * decrypt true if the algorithm should be initialized for decryption,\n * false for encryption.\n */\nforge.aes.Algorithm.prototype.initialize = function(options) {\n if(this._init) {\n return;\n }\n\n var key = options.key;\n var tmp;\n\n /* Note: The key may be a string of bytes, an array of bytes, a byte\n buffer, or an array of 32-bit integers. If the key is in bytes, then\n it must be 16, 24, or 32 bytes in length. If it is in 32-bit\n integers, it must be 4, 6, or 8 integers long. */\n\n if(typeof key === 'string' &&\n (key.length === 16 || key.length === 24 || key.length === 32)) {\n // convert key string into byte buffer\n key = forge.util.createBuffer(key);\n } else if(forge.util.isArray(key) &&\n (key.length === 16 || key.length === 24 || key.length === 32)) {\n // convert key integer array into byte buffer\n tmp = key;\n key = forge.util.createBuffer();\n for(var i = 0; i < tmp.length; ++i) {\n key.putByte(tmp[i]);\n }\n }\n\n // convert key byte buffer into 32-bit integer array\n if(!forge.util.isArray(key)) {\n tmp = key;\n key = [];\n\n // key lengths of 16, 24, 32 bytes allowed\n var len = tmp.length();\n if(len === 16 || len === 24 || len === 32) {\n len = len >>> 2;\n for(var i = 0; i < len; ++i) {\n key.push(tmp.getInt32());\n }\n }\n }\n\n // key must be an array of 32-bit integers by now\n if(!forge.util.isArray(key) ||\n !(key.length === 4 || key.length === 6 || key.length === 8)) {\n throw new Error('Invalid key parameter.');\n }\n\n // encryption operation is always used for these modes\n var mode = this.mode.name;\n var encryptOp = (['CFB', 'OFB', 'CTR', 'GCM'].indexOf(mode) !== -1);\n\n // do key expansion\n this._w = _expandKey(key, options.decrypt && !encryptOp);\n this._init = true;\n};\n\n/**\n * Expands a key. Typically only used for testing.\n *\n * @param key the symmetric key to expand, as an array of 32-bit words.\n * @param decrypt true to expand for decryption, false for encryption.\n *\n * @return the expanded key.\n */\nforge.aes._expandKey = function(key, decrypt) {\n if(!init) {\n initialize();\n }\n return _expandKey(key, decrypt);\n};\n\n/**\n * Updates a single block. Typically only used for testing.\n *\n * @param w the expanded key to use.\n * @param input an array of block-size 32-bit words.\n * @param output an array of block-size 32-bit words.\n * @param decrypt true to decrypt, false to encrypt.\n */\nforge.aes._updateBlock = _updateBlock;\n\n/** Register AES algorithms **/\n\nregisterAlgorithm('AES-ECB', forge.cipher.modes.ecb);\nregisterAlgorithm('AES-CBC', forge.cipher.modes.cbc);\nregisterAlgorithm('AES-CFB', forge.cipher.modes.cfb);\nregisterAlgorithm('AES-OFB', forge.cipher.modes.ofb);\nregisterAlgorithm('AES-CTR', forge.cipher.modes.ctr);\nregisterAlgorithm('AES-GCM', forge.cipher.modes.gcm);\n\nfunction registerAlgorithm(name, mode) {\n var factory = function() {\n return new forge.aes.Algorithm(name, mode);\n };\n forge.cipher.registerAlgorithm(name, factory);\n}\n\n/** AES implementation **/\n\nvar init = false; // not yet initialized\nvar Nb = 4; // number of words comprising the state (AES = 4)\nvar sbox; // non-linear substitution table used in key expansion\nvar isbox; // inversion of sbox\nvar rcon; // round constant word array\nvar mix; // mix-columns table\nvar imix; // inverse mix-columns table\n\n/**\n * Performs initialization, ie: precomputes tables to optimize for speed.\n *\n * One way to understand how AES works is to imagine that 'addition' and\n * 'multiplication' are interfaces that require certain mathematical\n * properties to hold true (ie: they are associative) but they might have\n * different implementations and produce different kinds of results ...\n * provided that their mathematical properties remain true. AES defines\n * its own methods of addition and multiplication but keeps some important\n * properties the same, ie: associativity and distributivity. The\n * explanation below tries to shed some light on how AES defines addition\n * and multiplication of bytes and 32-bit words in order to perform its\n * encryption and decryption algorithms.\n *\n * The basics:\n *\n * The AES algorithm views bytes as binary representations of polynomials\n * that have either 1 or 0 as the coefficients. It defines the addition\n * or subtraction of two bytes as the XOR operation. It also defines the\n * multiplication of two bytes as a finite field referred to as GF(2^8)\n * (Note: 'GF' means \"Galois Field\" which is a field that contains a finite\n * number of elements so GF(2^8) has 256 elements).\n *\n * This means that any two bytes can be represented as binary polynomials;\n * when they multiplied together and modularly reduced by an irreducible\n * polynomial of the 8th degree, the results are the field GF(2^8). The\n * specific irreducible polynomial that AES uses in hexadecimal is 0x11b.\n * This multiplication is associative with 0x01 as the identity:\n *\n * (b * 0x01 = GF(b, 0x01) = b).\n *\n * The operation GF(b, 0x02) can be performed at the byte level by left\n * shifting b once and then XOR'ing it (to perform the modular reduction)\n * with 0x11b if b is >= 128. Repeated application of the multiplication\n * of 0x02 can be used to implement the multiplication of any two bytes.\n *\n * For instance, multiplying 0x57 and 0x13, denoted as GF(0x57, 0x13), can\n * be performed by factoring 0x13 into 0x01, 0x02, and 0x10. Then these\n * factors can each be multiplied by 0x57 and then added together. To do\n * the multiplication, values for 0x57 multiplied by each of these 3 factors\n * can be precomputed and stored in a table. To add them, the values from\n * the table are XOR'd together.\n *\n * AES also defines addition and multiplication of words, that is 4-byte\n * numbers represented as polynomials of 3 degrees where the coefficients\n * are the values of the bytes.\n *\n * The word [a0, a1, a2, a3] is a polynomial a3x^3 + a2x^2 + a1x + a0.\n *\n * Addition is performed by XOR'ing like powers of x. Multiplication\n * is performed in two steps, the first is an algebriac expansion as\n * you would do normally (where addition is XOR). But the result is\n * a polynomial larger than 3 degrees and thus it cannot fit in a word. So\n * next the result is modularly reduced by an AES-specific polynomial of\n * degree 4 which will always produce a polynomial of less than 4 degrees\n * such that it will fit in a word. In AES, this polynomial is x^4 + 1.\n *\n * The modular product of two polynomials 'a' and 'b' is thus:\n *\n * d(x) = d3x^3 + d2x^2 + d1x + d0\n * with\n * d0 = GF(a0, b0) ^ GF(a3, b1) ^ GF(a2, b2) ^ GF(a1, b3)\n * d1 = GF(a1, b0) ^ GF(a0, b1) ^ GF(a3, b2) ^ GF(a2, b3)\n * d2 = GF(a2, b0) ^ GF(a1, b1) ^ GF(a0, b2) ^ GF(a3, b3)\n * d3 = GF(a3, b0) ^ GF(a2, b1) ^ GF(a1, b2) ^ GF(a0, b3)\n *\n * As a matrix:\n *\n * [d0] = [a0 a3 a2 a1][b0]\n * [d1] [a1 a0 a3 a2][b1]\n * [d2] [a2 a1 a0 a3][b2]\n * [d3] [a3 a2 a1 a0][b3]\n *\n * Special polynomials defined by AES (0x02 == {02}):\n * a(x) = {03}x^3 + {01}x^2 + {01}x + {02}\n * a^-1(x) = {0b}x^3 + {0d}x^2 + {09}x + {0e}.\n *\n * These polynomials are used in the MixColumns() and InverseMixColumns()\n * operations, respectively, to cause each element in the state to affect\n * the output (referred to as diffusing).\n *\n * RotWord() uses: a0 = a1 = a2 = {00} and a3 = {01}, which is the\n * polynomial x3.\n *\n * The ShiftRows() method modifies the last 3 rows in the state (where\n * the state is 4 words with 4 bytes per word) by shifting bytes cyclically.\n * The 1st byte in the second row is moved to the end of the row. The 1st\n * and 2nd bytes in the third row are moved to the end of the row. The 1st,\n * 2nd, and 3rd bytes are moved in the fourth row.\n *\n * More details on how AES arithmetic works:\n *\n * In the polynomial representation of binary numbers, XOR performs addition\n * and subtraction and multiplication in GF(2^8) denoted as GF(a, b)\n * corresponds with the multiplication of polynomials modulo an irreducible\n * polynomial of degree 8. In other words, for AES, GF(a, b) will multiply\n * polynomial 'a' with polynomial 'b' and then do a modular reduction by\n * an AES-specific irreducible polynomial of degree 8.\n *\n * A polynomial is irreducible if its only divisors are one and itself. For\n * the AES algorithm, this irreducible polynomial is:\n *\n * m(x) = x^8 + x^4 + x^3 + x + 1,\n *\n * or {01}{1b} in hexadecimal notation, where each coefficient is a bit:\n * 100011011 = 283 = 0x11b.\n *\n * For example, GF(0x57, 0x83) = 0xc1 because\n *\n * 0x57 = 87 = 01010111 = x^6 + x^4 + x^2 + x + 1\n * 0x85 = 131 = 10000101 = x^7 + x + 1\n *\n * (x^6 + x^4 + x^2 + x + 1) * (x^7 + x + 1)\n * = x^13 + x^11 + x^9 + x^8 + x^7 +\n * x^7 + x^5 + x^3 + x^2 + x +\n * x^6 + x^4 + x^2 + x + 1\n * = x^13 + x^11 + x^9 + x^8 + x^6 + x^5 + x^4 + x^3 + 1 = y\n * y modulo (x^8 + x^4 + x^3 + x + 1)\n * = x^7 + x^6 + 1.\n *\n * The modular reduction by m(x) guarantees the result will be a binary\n * polynomial of less than degree 8, so that it can fit in a byte.\n *\n * The operation to multiply a binary polynomial b with x (the polynomial\n * x in binary representation is 00000010) is:\n *\n * b_7x^8 + b_6x^7 + b_5x^6 + b_4x^5 + b_3x^4 + b_2x^3 + b_1x^2 + b_0x^1\n *\n * To get GF(b, x) we must reduce that by m(x). If b_7 is 0 (that is the\n * most significant bit is 0 in b) then the result is already reduced. If\n * it is 1, then we can reduce it by subtracting m(x) via an XOR.\n *\n * It follows that multiplication by x (00000010 or 0x02) can be implemented\n * by performing a left shift followed by a conditional bitwise XOR with\n * 0x1b. This operation on bytes is denoted by xtime(). Multiplication by\n * higher powers of x can be implemented by repeated application of xtime().\n *\n * By adding intermediate results, multiplication by any constant can be\n * implemented. For instance:\n *\n * GF(0x57, 0x13) = 0xfe because:\n *\n * xtime(b) = (b & 128) ? (b << 1 ^ 0x11b) : (b << 1)\n *\n * Note: We XOR with 0x11b instead of 0x1b because in javascript our\n * datatype for b can be larger than 1 byte, so a left shift will not\n * automatically eliminate bits that overflow a byte ... by XOR'ing the\n * overflow bit with 1 (the extra one from 0x11b) we zero it out.\n *\n * GF(0x57, 0x02) = xtime(0x57) = 0xae\n * GF(0x57, 0x04) = xtime(0xae) = 0x47\n * GF(0x57, 0x08) = xtime(0x47) = 0x8e\n * GF(0x57, 0x10) = xtime(0x8e) = 0x07\n *\n * GF(0x57, 0x13) = GF(0x57, (0x01 ^ 0x02 ^ 0x10))\n *\n * And by the distributive property (since XOR is addition and GF() is\n * multiplication):\n *\n * = GF(0x57, 0x01) ^ GF(0x57, 0x02) ^ GF(0x57, 0x10)\n * = 0x57 ^ 0xae ^ 0x07\n * = 0xfe.\n */\nfunction initialize() {\n init = true;\n\n /* Populate the Rcon table. These are the values given by\n [x^(i-1),{00},{00},{00}] where x^(i-1) are powers of x (and x = 0x02)\n in the field of GF(2^8), where i starts at 1.\n\n rcon[0] = [0x00, 0x00, 0x00, 0x00]\n rcon[1] = [0x01, 0x00, 0x00, 0x00] 2^(1-1) = 2^0 = 1\n rcon[2] = [0x02, 0x00, 0x00, 0x00] 2^(2-1) = 2^1 = 2\n ...\n rcon[9] = [0x1B, 0x00, 0x00, 0x00] 2^(9-1) = 2^8 = 0x1B\n rcon[10] = [0x36, 0x00, 0x00, 0x00] 2^(10-1) = 2^9 = 0x36\n\n We only store the first byte because it is the only one used.\n */\n rcon = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36];\n\n // compute xtime table which maps i onto GF(i, 0x02)\n var xtime = new Array(256);\n for(var i = 0; i < 128; ++i) {\n xtime[i] = i << 1;\n xtime[i + 128] = (i + 128) << 1 ^ 0x11B;\n }\n\n // compute all other tables\n sbox = new Array(256);\n isbox = new Array(256);\n mix = new Array(4);\n imix = new Array(4);\n for(var i = 0; i < 4; ++i) {\n mix[i] = new Array(256);\n imix[i] = new Array(256);\n }\n var e = 0, ei = 0, e2, e4, e8, sx, sx2, me, ime;\n for(var i = 0; i < 256; ++i) {\n /* We need to generate the SubBytes() sbox and isbox tables so that\n we can perform byte substitutions. This requires us to traverse\n all of the elements in GF, find their multiplicative inverses,\n and apply to each the following affine transformation:\n\n bi' = bi ^ b(i + 4) mod 8 ^ b(i + 5) mod 8 ^ b(i + 6) mod 8 ^\n b(i + 7) mod 8 ^ ci\n for 0 <= i < 8, where bi is the ith bit of the byte, and ci is the\n ith bit of a byte c with the value {63} or {01100011}.\n\n It is possible to traverse every possible value in a Galois field\n using what is referred to as a 'generator'. There are many\n generators (128 out of 256): 3,5,6,9,11,82 to name a few. To fully\n traverse GF we iterate 255 times, multiplying by our generator\n each time.\n\n On each iteration we can determine the multiplicative inverse for\n the current element.\n\n Suppose there is an element in GF 'e'. For a given generator 'g',\n e = g^x. The multiplicative inverse of e is g^(255 - x). It turns\n out that if use the inverse of a generator as another generator\n it will produce all of the corresponding multiplicative inverses\n at the same time. For this reason, we choose 5 as our inverse\n generator because it only requires 2 multiplies and 1 add and its\n inverse, 82, requires relatively few operations as well.\n\n In order to apply the affine transformation, the multiplicative\n inverse 'ei' of 'e' can be repeatedly XOR'd (4 times) with a\n bit-cycling of 'ei'. To do this 'ei' is first stored in 's' and\n 'x'. Then 's' is left shifted and the high bit of 's' is made the\n low bit. The resulting value is stored in 's'. Then 'x' is XOR'd\n with 's' and stored in 'x'. On each subsequent iteration the same\n operation is performed. When 4 iterations are complete, 'x' is\n XOR'd with 'c' (0x63) and the transformed value is stored in 'x'.\n For example:\n\n s = 01000001\n x = 01000001\n\n iteration 1: s = 10000010, x ^= s\n iteration 2: s = 00000101, x ^= s\n iteration 3: s = 00001010, x ^= s\n iteration 4: s = 00010100, x ^= s\n x ^= 0x63\n\n This can be done with a loop where s = (s << 1) | (s >> 7). However,\n it can also be done by using a single 16-bit (in this case 32-bit)\n number 'sx'. Since XOR is an associative operation, we can set 'sx'\n to 'ei' and then XOR it with 'sx' left-shifted 1,2,3, and 4 times.\n The most significant bits will flow into the high 8 bit positions\n and be correctly XOR'd with one another. All that remains will be\n to cycle the high 8 bits by XOR'ing them all with the lower 8 bits\n afterwards.\n\n At the same time we're populating sbox and isbox we can precompute\n the multiplication we'll need to do to do MixColumns() later.\n */\n\n // apply affine transformation\n sx = ei ^ (ei << 1) ^ (ei << 2) ^ (ei << 3) ^ (ei << 4);\n sx = (sx >> 8) ^ (sx & 255) ^ 0x63;\n\n // update tables\n sbox[e] = sx;\n isbox[sx] = e;\n\n /* Mixing columns is done using matrix multiplication. The columns\n that are to be mixed are each a single word in the current state.\n The state has Nb columns (4 columns). Therefore each column is a\n 4 byte word. So to mix the columns in a single column 'c' where\n its rows are r0, r1, r2, and r3, we use the following matrix\n multiplication:\n\n [2 3 1 1]*[r0,c]=[r'0,c]\n [1 2 3 1] [r1,c] [r'1,c]\n [1 1 2 3] [r2,c] [r'2,c]\n [3 1 1 2] [r3,c] [r'3,c]\n\n r0, r1, r2, and r3 are each 1 byte of one of the words in the\n state (a column). To do matrix multiplication for each mixed\n column c' we multiply the corresponding row from the left matrix\n with the corresponding column from the right matrix. In total, we\n get 4 equations:\n\n r0,c' = 2*r0,c + 3*r1,c + 1*r2,c + 1*r3,c\n r1,c' = 1*r0,c + 2*r1,c + 3*r2,c + 1*r3,c\n r2,c' = 1*r0,c + 1*r1,c + 2*r2,c + 3*r3,c\n r3,c' = 3*r0,c + 1*r1,c + 1*r2,c + 2*r3,c\n\n As usual, the multiplication is as previously defined and the\n addition is XOR. In order to optimize mixing columns we can store\n the multiplication results in tables. If you think of the whole\n column as a word (it might help to visualize by mentally rotating\n the equations above by counterclockwise 90 degrees) then you can\n see that it would be useful to map the multiplications performed on\n each byte (r0, r1, r2, r3) onto a word as well. For instance, we\n could map 2*r0,1*r0,1*r0,3*r0 onto a word by storing 2*r0 in the\n highest 8 bits and 3*r0 in the lowest 8 bits (with the other two\n respectively in the middle). This means that a table can be\n constructed that uses r0 as an index to the word. We can do the\n same with r1, r2, and r3, creating a total of 4 tables.\n\n To construct a full c', we can just look up each byte of c in\n their respective tables and XOR the results together.\n\n Also, to build each table we only have to calculate the word\n for 2,1,1,3 for every byte ... which we can do on each iteration\n of this loop since we will iterate over every byte. After we have\n calculated 2,1,1,3 we can get the results for the other tables\n by cycling the byte at the end to the beginning. For instance\n we can take the result of table 2,1,1,3 and produce table 3,2,1,1\n by moving the right most byte to the left most position just like\n how you can imagine the 3 moved out of 2,1,1,3 and to the front\n to produce 3,2,1,1.\n\n There is another optimization in that the same multiples of\n the current element we need in order to advance our generator\n to the next iteration can be reused in performing the 2,1,1,3\n calculation. We also calculate the inverse mix column tables,\n with e,9,d,b being the inverse of 2,1,1,3.\n\n When we're done, and we need to actually mix columns, the first\n byte of each state word should be put through mix[0] (2,1,1,3),\n the second through mix[1] (3,2,1,1) and so forth. Then they should\n be XOR'd together to produce the fully mixed column.\n */\n\n // calculate mix and imix table values\n sx2 = xtime[sx];\n e2 = xtime[e];\n e4 = xtime[e2];\n e8 = xtime[e4];\n me =\n (sx2 << 24) ^ // 2\n (sx << 16) ^ // 1\n (sx << 8) ^ // 1\n (sx ^ sx2); // 3\n ime =\n (e2 ^ e4 ^ e8) << 24 ^ // E (14)\n (e ^ e8) << 16 ^ // 9\n (e ^ e4 ^ e8) << 8 ^ // D (13)\n (e ^ e2 ^ e8); // B (11)\n // produce each of the mix tables by rotating the 2,1,1,3 value\n for(var n = 0; n < 4; ++n) {\n mix[n][e] = me;\n imix[n][sx] = ime;\n // cycle the right most byte to the left most position\n // ie: 2,1,1,3 becomes 3,2,1,1\n me = me << 24 | me >>> 8;\n ime = ime << 24 | ime >>> 8;\n }\n\n // get next element and inverse\n if(e === 0) {\n // 1 is the inverse of 1\n e = ei = 1;\n } else {\n // e = 2e + 2*2*2*(10e)) = multiply e by 82 (chosen generator)\n // ei = ei + 2*2*ei = multiply ei by 5 (inverse generator)\n e = e2 ^ xtime[xtime[xtime[e2 ^ e8]]];\n ei ^= xtime[xtime[ei]];\n }\n }\n}\n\n/**\n * Generates a key schedule using the AES key expansion algorithm.\n *\n * The AES algorithm takes the Cipher Key, K, and performs a Key Expansion\n * routine to generate a key schedule. The Key Expansion generates a total\n * of Nb*(Nr + 1) words: the algorithm requires an initial set of Nb words,\n * and each of the Nr rounds requires Nb words of key data. The resulting\n * key schedule consists of a linear array of 4-byte words, denoted [wi ],\n * with i in the range 0 <= i < Nb(Nr + 1).\n *\n * KeyExpansion(byte key[4*Nk], word w[Nb*(Nr+1)], Nk)\n * AES-128 (Nb=4, Nk=4, Nr=10)\n * AES-192 (Nb=4, Nk=6, Nr=12)\n * AES-256 (Nb=4, Nk=8, Nr=14)\n * Note: Nr=Nk+6.\n *\n * Nb is the number of columns (32-bit words) comprising the State (or\n * number of bytes in a block). For AES, Nb=4.\n *\n * @param key the key to schedule (as an array of 32-bit words).\n * @param decrypt true to modify the key schedule to decrypt, false not to.\n *\n * @return the generated key schedule.\n */\nfunction _expandKey(key, decrypt) {\n // copy the key's words to initialize the key schedule\n var w = key.slice(0);\n\n /* RotWord() will rotate a word, moving the first byte to the last\n byte's position (shifting the other bytes left).\n\n We will be getting the value of Rcon at i / Nk. 'i' will iterate\n from Nk to (Nb * Nr+1). Nk = 4 (4 byte key), Nb = 4 (4 words in\n a block), Nr = Nk + 6 (10). Therefore 'i' will iterate from\n 4 to 44 (exclusive). Each time we iterate 4 times, i / Nk will\n increase by 1. We use a counter iNk to keep track of this.\n */\n\n // go through the rounds expanding the key\n var temp, iNk = 1;\n var Nk = w.length;\n var Nr1 = Nk + 6 + 1;\n var end = Nb * Nr1;\n for(var i = Nk; i < end; ++i) {\n temp = w[i - 1];\n if(i % Nk === 0) {\n // temp = SubWord(RotWord(temp)) ^ Rcon[i / Nk]\n temp =\n sbox[temp >>> 16 & 255] << 24 ^\n sbox[temp >>> 8 & 255] << 16 ^\n sbox[temp & 255] << 8 ^\n sbox[temp >>> 24] ^ (rcon[iNk] << 24);\n iNk++;\n } else if(Nk > 6 && (i % Nk === 4)) {\n // temp = SubWord(temp)\n temp =\n sbox[temp >>> 24] << 24 ^\n sbox[temp >>> 16 & 255] << 16 ^\n sbox[temp >>> 8 & 255] << 8 ^\n sbox[temp & 255];\n }\n w[i] = w[i - Nk] ^ temp;\n }\n\n /* When we are updating a cipher block we always use the code path for\n encryption whether we are decrypting or not (to shorten code and\n simplify the generation of look up tables). However, because there\n are differences in the decryption algorithm, other than just swapping\n in different look up tables, we must transform our key schedule to\n account for these changes:\n\n 1. The decryption algorithm gets its key rounds in reverse order.\n 2. The decryption algorithm adds the round key before mixing columns\n instead of afterwards.\n\n We don't need to modify our key schedule to handle the first case,\n we can just traverse the key schedule in reverse order when decrypting.\n\n The second case requires a little work.\n\n The tables we built for performing rounds will take an input and then\n perform SubBytes() and MixColumns() or, for the decrypt version,\n InvSubBytes() and InvMixColumns(). But the decrypt algorithm requires\n us to AddRoundKey() before InvMixColumns(). This means we'll need to\n apply some transformations to the round key to inverse-mix its columns\n so they'll be correct for moving AddRoundKey() to after the state has\n had its columns inverse-mixed.\n\n To inverse-mix the columns of the state when we're decrypting we use a\n lookup table that will apply InvSubBytes() and InvMixColumns() at the\n same time. However, the round key's bytes are not inverse-substituted\n in the decryption algorithm. To get around this problem, we can first\n substitute the bytes in the round key so that when we apply the\n transformation via the InvSubBytes()+InvMixColumns() table, it will\n undo our substitution leaving us with the original value that we\n want -- and then inverse-mix that value.\n\n This change will correctly alter our key schedule so that we can XOR\n each round key with our already transformed decryption state. This\n allows us to use the same code path as the encryption algorithm.\n\n We make one more change to the decryption key. Since the decryption\n algorithm runs in reverse from the encryption algorithm, we reverse\n the order of the round keys to avoid having to iterate over the key\n schedule backwards when running the encryption algorithm later in\n decryption mode. In addition to reversing the order of the round keys,\n we also swap each round key's 2nd and 4th rows. See the comments\n section where rounds are performed for more details about why this is\n done. These changes are done inline with the other substitution\n described above.\n */\n if(decrypt) {\n var tmp;\n var m0 = imix[0];\n var m1 = imix[1];\n var m2 = imix[2];\n var m3 = imix[3];\n var wnew = w.slice(0);\n end = w.length;\n for(var i = 0, wi = end - Nb; i < end; i += Nb, wi -= Nb) {\n // do not sub the first or last round key (round keys are Nb\n // words) as no column mixing is performed before they are added,\n // but do change the key order\n if(i === 0 || i === (end - Nb)) {\n wnew[i] = w[wi];\n wnew[i + 1] = w[wi + 3];\n wnew[i + 2] = w[wi + 2];\n wnew[i + 3] = w[wi + 1];\n } else {\n // substitute each round key byte because the inverse-mix\n // table will inverse-substitute it (effectively cancel the\n // substitution because round key bytes aren't sub'd in\n // decryption mode) and swap indexes 3 and 1\n for(var n = 0; n < Nb; ++n) {\n tmp = w[wi + n];\n wnew[i + (3&-n)] =\n m0[sbox[tmp >>> 24]] ^\n m1[sbox[tmp >>> 16 & 255]] ^\n m2[sbox[tmp >>> 8 & 255]] ^\n m3[sbox[tmp & 255]];\n }\n }\n }\n w = wnew;\n }\n\n return w;\n}\n\n/**\n * Updates a single block (16 bytes) using AES. The update will either\n * encrypt or decrypt the block.\n *\n * @param w the key schedule.\n * @param input the input block (an array of 32-bit words).\n * @param output the updated output block.\n * @param decrypt true to decrypt the block, false to encrypt it.\n */\nfunction _updateBlock(w, input, output, decrypt) {\n /*\n Cipher(byte in[4*Nb], byte out[4*Nb], word w[Nb*(Nr+1)])\n begin\n byte state[4,Nb]\n state = in\n AddRoundKey(state, w[0, Nb-1])\n for round = 1 step 1 to Nr-1\n SubBytes(state)\n ShiftRows(state)\n MixColumns(state)\n AddRoundKey(state, w[round*Nb, (round+1)*Nb-1])\n end for\n SubBytes(state)\n ShiftRows(state)\n AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])\n out = state\n end\n\n InvCipher(byte in[4*Nb], byte out[4*Nb], word w[Nb*(Nr+1)])\n begin\n byte state[4,Nb]\n state = in\n AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])\n for round = Nr-1 step -1 downto 1\n InvShiftRows(state)\n InvSubBytes(state)\n AddRoundKey(state, w[round*Nb, (round+1)*Nb-1])\n InvMixColumns(state)\n end for\n InvShiftRows(state)\n InvSubBytes(state)\n AddRoundKey(state, w[0, Nb-1])\n out = state\n end\n */\n\n // Encrypt: AddRoundKey(state, w[0, Nb-1])\n // Decrypt: AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])\n var Nr = w.length / 4 - 1;\n var m0, m1, m2, m3, sub;\n if(decrypt) {\n m0 = imix[0];\n m1 = imix[1];\n m2 = imix[2];\n m3 = imix[3];\n sub = isbox;\n } else {\n m0 = mix[0];\n m1 = mix[1];\n m2 = mix[2];\n m3 = mix[3];\n sub = sbox;\n }\n var a, b, c, d, a2, b2, c2;\n a = input[0] ^ w[0];\n b = input[decrypt ? 3 : 1] ^ w[1];\n c = input[2] ^ w[2];\n d = input[decrypt ? 1 : 3] ^ w[3];\n var i = 3;\n\n /* In order to share code we follow the encryption algorithm when both\n encrypting and decrypting. To account for the changes required in the\n decryption algorithm, we use different lookup tables when decrypting\n and use a modified key schedule to account for the difference in the\n order of transformations applied when performing rounds. We also get\n key rounds in reverse order (relative to encryption). */\n for(var round = 1; round < Nr; ++round) {\n /* As described above, we'll be using table lookups to perform the\n column mixing. Each column is stored as a word in the state (the\n array 'input' has one column as a word at each index). In order to\n mix a column, we perform these transformations on each row in c,\n which is 1 byte in each word. The new column for c0 is c'0:\n\n m0 m1 m2 m3\n r0,c'0 = 2*r0,c0 + 3*r1,c0 + 1*r2,c0 + 1*r3,c0\n r1,c'0 = 1*r0,c0 + 2*r1,c0 + 3*r2,c0 + 1*r3,c0\n r2,c'0 = 1*r0,c0 + 1*r1,c0 + 2*r2,c0 + 3*r3,c0\n r3,c'0 = 3*r0,c0 + 1*r1,c0 + 1*r2,c0 + 2*r3,c0\n\n So using mix tables where c0 is a word with r0 being its upper\n 8 bits and r3 being its lower 8 bits:\n\n m0[c0 >> 24] will yield this word: [2*r0,1*r0,1*r0,3*r0]\n ...\n m3[c0 & 255] will yield this word: [1*r3,1*r3,3*r3,2*r3]\n\n Therefore to mix the columns in each word in the state we\n do the following (& 255 omitted for brevity):\n c'0,r0 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]\n c'0,r1 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]\n c'0,r2 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]\n c'0,r3 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]\n\n However, before mixing, the algorithm requires us to perform\n ShiftRows(). The ShiftRows() transformation cyclically shifts the\n last 3 rows of the state over different offsets. The first row\n (r = 0) is not shifted.\n\n s'_r,c = s_r,(c + shift(r, Nb) mod Nb\n for 0 < r < 4 and 0 <= c < Nb and\n shift(1, 4) = 1\n shift(2, 4) = 2\n shift(3, 4) = 3.\n\n This causes the first byte in r = 1 to be moved to the end of\n the row, the first 2 bytes in r = 2 to be moved to the end of\n the row, the first 3 bytes in r = 3 to be moved to the end of\n the row:\n\n r1: [c0 c1 c2 c3] => [c1 c2 c3 c0]\n r2: [c0 c1 c2 c3] [c2 c3 c0 c1]\n r3: [c0 c1 c2 c3] [c3 c0 c1 c2]\n\n We can make these substitutions inline with our column mixing to\n generate an updated set of equations to produce each word in the\n state (note the columns have changed positions):\n\n c0 c1 c2 c3 => c0 c1 c2 c3\n c0 c1 c2 c3 c1 c2 c3 c0 (cycled 1 byte)\n c0 c1 c2 c3 c2 c3 c0 c1 (cycled 2 bytes)\n c0 c1 c2 c3 c3 c0 c1 c2 (cycled 3 bytes)\n\n Therefore:\n\n c'0 = 2*r0,c0 + 3*r1,c1 + 1*r2,c2 + 1*r3,c3\n c'0 = 1*r0,c0 + 2*r1,c1 + 3*r2,c2 + 1*r3,c3\n c'0 = 1*r0,c0 + 1*r1,c1 + 2*r2,c2 + 3*r3,c3\n c'0 = 3*r0,c0 + 1*r1,c1 + 1*r2,c2 + 2*r3,c3\n\n c'1 = 2*r0,c1 + 3*r1,c2 + 1*r2,c3 + 1*r3,c0\n c'1 = 1*r0,c1 + 2*r1,c2 + 3*r2,c3 + 1*r3,c0\n c'1 = 1*r0,c1 + 1*r1,c2 + 2*r2,c3 + 3*r3,c0\n c'1 = 3*r0,c1 + 1*r1,c2 + 1*r2,c3 + 2*r3,c0\n\n ... and so forth for c'2 and c'3. The important distinction is\n that the columns are cycling, with c0 being used with the m0\n map when calculating c0, but c1 being used with the m0 map when\n calculating c1 ... and so forth.\n\n When performing the inverse we transform the mirror image and\n skip the bottom row, instead of the top one, and move upwards:\n\n c3 c2 c1 c0 => c0 c3 c2 c1 (cycled 3 bytes) *same as encryption\n c3 c2 c1 c0 c1 c0 c3 c2 (cycled 2 bytes)\n c3 c2 c1 c0 c2 c1 c0 c3 (cycled 1 byte) *same as encryption\n c3 c2 c1 c0 c3 c2 c1 c0\n\n If you compare the resulting matrices for ShiftRows()+MixColumns()\n and for InvShiftRows()+InvMixColumns() the 2nd and 4th columns are\n different (in encrypt mode vs. decrypt mode). So in order to use\n the same code to handle both encryption and decryption, we will\n need to do some mapping.\n\n If in encryption mode we let a=c0, b=c1, c=c2, d=c3, and r be\n a row number in the state, then the resulting matrix in encryption\n mode for applying the above transformations would be:\n\n r1: a b c d\n r2: b c d a\n r3: c d a b\n r4: d a b c\n\n If we did the same in decryption mode we would get:\n\n r1: a d c b\n r2: b a d c\n r3: c b a d\n r4: d c b a\n\n If instead we swap d and b (set b=c3 and d=c1), then we get:\n\n r1: a b c d\n r2: d a b c\n r3: c d a b\n r4: b c d a\n\n Now the 1st and 3rd rows are the same as the encryption matrix. All\n we need to do then to make the mapping exactly the same is to swap\n the 2nd and 4th rows when in decryption mode. To do this without\n having to do it on each iteration, we swapped the 2nd and 4th rows\n in the decryption key schedule. We also have to do the swap above\n when we first pull in the input and when we set the final output. */\n a2 =\n m0[a >>> 24] ^\n m1[b >>> 16 & 255] ^\n m2[c >>> 8 & 255] ^\n m3[d & 255] ^ w[++i];\n b2 =\n m0[b >>> 24] ^\n m1[c >>> 16 & 255] ^\n m2[d >>> 8 & 255] ^\n m3[a & 255] ^ w[++i];\n c2 =\n m0[c >>> 24] ^\n m1[d >>> 16 & 255] ^\n m2[a >>> 8 & 255] ^\n m3[b & 255] ^ w[++i];\n d =\n m0[d >>> 24] ^\n m1[a >>> 16 & 255] ^\n m2[b >>> 8 & 255] ^\n m3[c & 255] ^ w[++i];\n a = a2;\n b = b2;\n c = c2;\n }\n\n /*\n Encrypt:\n SubBytes(state)\n ShiftRows(state)\n AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])\n\n Decrypt:\n InvShiftRows(state)\n InvSubBytes(state)\n AddRoundKey(state, w[0, Nb-1])\n */\n // Note: rows are shifted inline\n output[0] =\n (sub[a >>> 24] << 24) ^\n (sub[b >>> 16 & 255] << 16) ^\n (sub[c >>> 8 & 255] << 8) ^\n (sub[d & 255]) ^ w[++i];\n output[decrypt ? 3 : 1] =\n (sub[b >>> 24] << 24) ^\n (sub[c >>> 16 & 255] << 16) ^\n (sub[d >>> 8 & 255] << 8) ^\n (sub[a & 255]) ^ w[++i];\n output[2] =\n (sub[c >>> 24] << 24) ^\n (sub[d >>> 16 & 255] << 16) ^\n (sub[a >>> 8 & 255] << 8) ^\n (sub[b & 255]) ^ w[++i];\n output[decrypt ? 1 : 3] =\n (sub[d >>> 24] << 24) ^\n (sub[a >>> 16 & 255] << 16) ^\n (sub[b >>> 8 & 255] << 8) ^\n (sub[c & 255]) ^ w[++i];\n}\n\n/**\n * Deprecated. Instead, use:\n *\n * forge.cipher.createCipher('AES-', key);\n * forge.cipher.createDecipher('AES-', key);\n *\n * Creates a deprecated AES cipher object. This object's mode will default to\n * CBC (cipher-block-chaining).\n *\n * The key and iv may be given as a string of bytes, an array of bytes, a\n * byte buffer, or an array of 32-bit words.\n *\n * @param options the options to use.\n * key the symmetric key to use.\n * output the buffer to write to.\n * decrypt true for decryption, false for encryption.\n * mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nfunction _createCipher(options) {\n options = options || {};\n var mode = (options.mode || 'CBC').toUpperCase();\n var algorithm = 'AES-' + mode;\n\n var cipher;\n if(options.decrypt) {\n cipher = forge.cipher.createDecipher(algorithm, options.key);\n } else {\n cipher = forge.cipher.createCipher(algorithm, options.key);\n }\n\n // backwards compatible start API\n var start = cipher.start;\n cipher.start = function(iv, options) {\n // backwards compatibility: support second arg as output buffer\n var output = null;\n if(options instanceof forge.util.ByteBuffer) {\n output = options;\n options = {};\n }\n options = options || {};\n options.output = output;\n options.iv = iv;\n start.call(cipher, options);\n };\n\n return cipher;\n}\n","/**\n * A Javascript implementation of AES Cipher Suites for TLS.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2009-2015 Digital Bazaar, Inc.\n *\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./tls');\n\nvar tls = module.exports = forge.tls;\n\n/**\n * Supported cipher suites.\n */\ntls.CipherSuites['TLS_RSA_WITH_AES_128_CBC_SHA'] = {\n id: [0x00, 0x2f],\n name: 'TLS_RSA_WITH_AES_128_CBC_SHA',\n initSecurityParameters: function(sp) {\n sp.bulk_cipher_algorithm = tls.BulkCipherAlgorithm.aes;\n sp.cipher_type = tls.CipherType.block;\n sp.enc_key_length = 16;\n sp.block_length = 16;\n sp.fixed_iv_length = 16;\n sp.record_iv_length = 16;\n sp.mac_algorithm = tls.MACAlgorithm.hmac_sha1;\n sp.mac_length = 20;\n sp.mac_key_length = 20;\n },\n initConnectionState: initConnectionState\n};\ntls.CipherSuites['TLS_RSA_WITH_AES_256_CBC_SHA'] = {\n id: [0x00, 0x35],\n name: 'TLS_RSA_WITH_AES_256_CBC_SHA',\n initSecurityParameters: function(sp) {\n sp.bulk_cipher_algorithm = tls.BulkCipherAlgorithm.aes;\n sp.cipher_type = tls.CipherType.block;\n sp.enc_key_length = 32;\n sp.block_length = 16;\n sp.fixed_iv_length = 16;\n sp.record_iv_length = 16;\n sp.mac_algorithm = tls.MACAlgorithm.hmac_sha1;\n sp.mac_length = 20;\n sp.mac_key_length = 20;\n },\n initConnectionState: initConnectionState\n};\n\nfunction initConnectionState(state, c, sp) {\n var client = (c.entity === forge.tls.ConnectionEnd.client);\n\n // cipher setup\n state.read.cipherState = {\n init: false,\n cipher: forge.cipher.createDecipher('AES-CBC', client ?\n sp.keys.server_write_key : sp.keys.client_write_key),\n iv: client ? sp.keys.server_write_IV : sp.keys.client_write_IV\n };\n state.write.cipherState = {\n init: false,\n cipher: forge.cipher.createCipher('AES-CBC', client ?\n sp.keys.client_write_key : sp.keys.server_write_key),\n iv: client ? sp.keys.client_write_IV : sp.keys.server_write_IV\n };\n state.read.cipherFunction = decrypt_aes_cbc_sha1;\n state.write.cipherFunction = encrypt_aes_cbc_sha1;\n\n // MAC setup\n state.read.macLength = state.write.macLength = sp.mac_length;\n state.read.macFunction = state.write.macFunction = tls.hmac_sha1;\n}\n\n/**\n * Encrypts the TLSCompressed record into a TLSCipherText record using AES\n * in CBC mode.\n *\n * @param record the TLSCompressed record to encrypt.\n * @param s the ConnectionState to use.\n *\n * @return true on success, false on failure.\n */\nfunction encrypt_aes_cbc_sha1(record, s) {\n var rval = false;\n\n // append MAC to fragment, update sequence number\n var mac = s.macFunction(s.macKey, s.sequenceNumber, record);\n record.fragment.putBytes(mac);\n s.updateSequenceNumber();\n\n // TLS 1.1+ use an explicit IV every time to protect against CBC attacks\n var iv;\n if(record.version.minor === tls.Versions.TLS_1_0.minor) {\n // use the pre-generated IV when initializing for TLS 1.0, otherwise use\n // the residue from the previous encryption\n iv = s.cipherState.init ? null : s.cipherState.iv;\n } else {\n iv = forge.random.getBytesSync(16);\n }\n\n s.cipherState.init = true;\n\n // start cipher\n var cipher = s.cipherState.cipher;\n cipher.start({iv: iv});\n\n // TLS 1.1+ write IV into output\n if(record.version.minor >= tls.Versions.TLS_1_1.minor) {\n cipher.output.putBytes(iv);\n }\n\n // do encryption (default padding is appropriate)\n cipher.update(record.fragment);\n if(cipher.finish(encrypt_aes_cbc_sha1_padding)) {\n // set record fragment to encrypted output\n record.fragment = cipher.output;\n record.length = record.fragment.length();\n rval = true;\n }\n\n return rval;\n}\n\n/**\n * Handles padding for aes_cbc_sha1 in encrypt mode.\n *\n * @param blockSize the block size.\n * @param input the input buffer.\n * @param decrypt true in decrypt mode, false in encrypt mode.\n *\n * @return true on success, false on failure.\n */\nfunction encrypt_aes_cbc_sha1_padding(blockSize, input, decrypt) {\n /* The encrypted data length (TLSCiphertext.length) is one more than the sum\n of SecurityParameters.block_length, TLSCompressed.length,\n SecurityParameters.mac_length, and padding_length.\n\n The padding may be any length up to 255 bytes long, as long as it results in\n the TLSCiphertext.length being an integral multiple of the block length.\n Lengths longer than necessary might be desirable to frustrate attacks on a\n protocol based on analysis of the lengths of exchanged messages. Each uint8\n in the padding data vector must be filled with the padding length value.\n\n The padding length should be such that the total size of the\n GenericBlockCipher structure is a multiple of the cipher's block length.\n Legal values range from zero to 255, inclusive. This length specifies the\n length of the padding field exclusive of the padding_length field itself.\n\n This is slightly different from PKCS#7 because the padding value is 1\n less than the actual number of padding bytes if you include the\n padding_length uint8 itself as a padding byte. */\n if(!decrypt) {\n // get the number of padding bytes required to reach the blockSize and\n // subtract 1 for the padding value (to make room for the padding_length\n // uint8)\n var padding = blockSize - (input.length() % blockSize);\n input.fillWithByte(padding - 1, padding);\n }\n return true;\n}\n\n/**\n * Handles padding for aes_cbc_sha1 in decrypt mode.\n *\n * @param blockSize the block size.\n * @param output the output buffer.\n * @param decrypt true in decrypt mode, false in encrypt mode.\n *\n * @return true on success, false on failure.\n */\nfunction decrypt_aes_cbc_sha1_padding(blockSize, output, decrypt) {\n var rval = true;\n if(decrypt) {\n /* The last byte in the output specifies the number of padding bytes not\n including itself. Each of the padding bytes has the same value as that\n last byte (known as the padding_length). Here we check all padding\n bytes to ensure they have the value of padding_length even if one of\n them is bad in order to ward-off timing attacks. */\n var len = output.length();\n var paddingLength = output.last();\n for(var i = len - 1 - paddingLength; i < len - 1; ++i) {\n rval = rval && (output.at(i) == paddingLength);\n }\n if(rval) {\n // trim off padding bytes and last padding length byte\n output.truncate(paddingLength + 1);\n }\n }\n return rval;\n}\n\n/**\n * Decrypts a TLSCipherText record into a TLSCompressed record using\n * AES in CBC mode.\n *\n * @param record the TLSCipherText record to decrypt.\n * @param s the ConnectionState to use.\n *\n * @return true on success, false on failure.\n */\nfunction decrypt_aes_cbc_sha1(record, s) {\n var rval = false;\n\n var iv;\n if(record.version.minor === tls.Versions.TLS_1_0.minor) {\n // use pre-generated IV when initializing for TLS 1.0, otherwise use the\n // residue from the previous decryption\n iv = s.cipherState.init ? null : s.cipherState.iv;\n } else {\n // TLS 1.1+ use an explicit IV every time to protect against CBC attacks\n // that is appended to the record fragment\n iv = record.fragment.getBytes(16);\n }\n\n s.cipherState.init = true;\n\n // start cipher\n var cipher = s.cipherState.cipher;\n cipher.start({iv: iv});\n\n // do decryption\n cipher.update(record.fragment);\n rval = cipher.finish(decrypt_aes_cbc_sha1_padding);\n\n // even if decryption fails, keep going to minimize timing attacks\n\n // decrypted data:\n // first (len - 20) bytes = application data\n // last 20 bytes = MAC\n var macLen = s.macLength;\n\n // create a random MAC to check against should the mac length check fail\n // Note: do this regardless of the failure to keep timing consistent\n var mac = forge.random.getBytesSync(macLen);\n\n // get fragment and mac\n var len = cipher.output.length();\n if(len >= macLen) {\n record.fragment = cipher.output.getBytes(len - macLen);\n mac = cipher.output.getBytes(macLen);\n } else {\n // bad data, but get bytes anyway to try to keep timing consistent\n record.fragment = cipher.output.getBytes();\n }\n record.fragment = forge.util.createBuffer(record.fragment);\n record.length = record.fragment.length();\n\n // see if data integrity checks out, update sequence number\n var mac2 = s.macFunction(s.macKey, s.sequenceNumber, record);\n s.updateSequenceNumber();\n rval = compareMacs(s.macKey, mac, mac2) && rval;\n return rval;\n}\n\n/**\n * Safely compare two MACs. This function will compare two MACs in a way\n * that protects against timing attacks.\n *\n * TODO: Expose elsewhere as a utility API.\n *\n * See: https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2011/february/double-hmac-verification/\n *\n * @param key the MAC key to use.\n * @param mac1 as a binary-encoded string of bytes.\n * @param mac2 as a binary-encoded string of bytes.\n *\n * @return true if the MACs are the same, false if not.\n */\nfunction compareMacs(key, mac1, mac2) {\n var hmac = forge.hmac.create();\n\n hmac.start('SHA1', key);\n hmac.update(mac1);\n mac1 = hmac.digest().getBytes();\n\n hmac.start(null, null);\n hmac.update(mac2);\n mac2 = hmac.digest().getBytes();\n\n return mac1 === mac2;\n}\n","/**\n * Copyright (c) 2019 Digital Bazaar, Inc.\n */\n\nvar forge = require('./forge');\nrequire('./asn1');\nvar asn1 = forge.asn1;\n\nexports.privateKeyValidator = {\n // PrivateKeyInfo\n name: 'PrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // Version (INTEGER)\n name: 'PrivateKeyInfo.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyVersion'\n }, {\n // privateKeyAlgorithm\n name: 'PrivateKeyInfo.privateKeyAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'privateKeyOid'\n }]\n }, {\n // PrivateKey\n name: 'PrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'privateKey'\n }]\n};\n\nexports.publicKeyValidator = {\n name: 'SubjectPublicKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'subjectPublicKeyInfo',\n value: [{\n name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'publicKeyOid'\n }]\n },\n // capture group for ed25519PublicKey\n {\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n composed: true,\n captureBitStringValue: 'ed25519PublicKey'\n }\n // FIXME: this is capture group for rsaPublicKey, use it in this API or\n // discard?\n /* {\n // subjectPublicKey\n name: 'SubjectPublicKeyInfo.subjectPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n value: [{\n // RSAPublicKey\n name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n optional: true,\n captureAsn1: 'rsaPublicKey'\n }]\n } */\n ]\n};\n","/**\n * Javascript implementation of Abstract Syntax Notation Number One.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2015 Digital Bazaar, Inc.\n *\n * An API for storing data using the Abstract Syntax Notation Number One\n * format using DER (Distinguished Encoding Rules) encoding. This encoding is\n * commonly used to store data for PKI, i.e. X.509 Certificates, and this\n * implementation exists for that purpose.\n *\n * Abstract Syntax Notation Number One (ASN.1) is used to define the abstract\n * syntax of information without restricting the way the information is encoded\n * for transmission. It provides a standard that allows for open systems\n * communication. ASN.1 defines the syntax of information data and a number of\n * simple data types as well as a notation for describing them and specifying\n * values for them.\n *\n * The RSA algorithm creates public and private keys that are often stored in\n * X.509 or PKCS#X formats -- which use ASN.1 (encoded in DER format). This\n * class provides the most basic functionality required to store and load DSA\n * keys that are encoded according to ASN.1.\n *\n * The most common binary encodings for ASN.1 are BER (Basic Encoding Rules)\n * and DER (Distinguished Encoding Rules). DER is just a subset of BER that\n * has stricter requirements for how data must be encoded.\n *\n * Each ASN.1 structure has a tag (a byte identifying the ASN.1 structure type)\n * and a byte array for the value of this ASN1 structure which may be data or a\n * list of ASN.1 structures.\n *\n * Each ASN.1 structure using BER is (Tag-Length-Value):\n *\n * | byte 0 | bytes X | bytes Y |\n * |--------|---------|----------\n * | tag | length | value |\n *\n * ASN.1 allows for tags to be of \"High-tag-number form\" which allows a tag to\n * be two or more octets, but that is not supported by this class. A tag is\n * only 1 byte. Bits 1-5 give the tag number (ie the data type within a\n * particular 'class'), 6 indicates whether or not the ASN.1 value is\n * constructed from other ASN.1 values, and bits 7 and 8 give the 'class'. If\n * bits 7 and 8 are both zero, the class is UNIVERSAL. If only bit 7 is set,\n * then the class is APPLICATION. If only bit 8 is set, then the class is\n * CONTEXT_SPECIFIC. If both bits 7 and 8 are set, then the class is PRIVATE.\n * The tag numbers for the data types for the class UNIVERSAL are listed below:\n *\n * UNIVERSAL 0 Reserved for use by the encoding rules\n * UNIVERSAL 1 Boolean type\n * UNIVERSAL 2 Integer type\n * UNIVERSAL 3 Bitstring type\n * UNIVERSAL 4 Octetstring type\n * UNIVERSAL 5 Null type\n * UNIVERSAL 6 Object identifier type\n * UNIVERSAL 7 Object descriptor type\n * UNIVERSAL 8 External type and Instance-of type\n * UNIVERSAL 9 Real type\n * UNIVERSAL 10 Enumerated type\n * UNIVERSAL 11 Embedded-pdv type\n * UNIVERSAL 12 UTF8String type\n * UNIVERSAL 13 Relative object identifier type\n * UNIVERSAL 14-15 Reserved for future editions\n * UNIVERSAL 16 Sequence and Sequence-of types\n * UNIVERSAL 17 Set and Set-of types\n * UNIVERSAL 18-22, 25-30 Character string types\n * UNIVERSAL 23-24 Time types\n *\n * The length of an ASN.1 structure is specified after the tag identifier.\n * There is a definite form and an indefinite form. The indefinite form may\n * be used if the encoding is constructed and not all immediately available.\n * The indefinite form is encoded using a length byte with only the 8th bit\n * set. The end of the constructed object is marked using end-of-contents\n * octets (two zero bytes).\n *\n * The definite form looks like this:\n *\n * The length may take up 1 or more bytes, it depends on the length of the\n * value of the ASN.1 structure. DER encoding requires that if the ASN.1\n * structure has a value that has a length greater than 127, more than 1 byte\n * will be used to store its length, otherwise just one byte will be used.\n * This is strict.\n *\n * In the case that the length of the ASN.1 value is less than 127, 1 octet\n * (byte) is used to store the \"short form\" length. The 8th bit has a value of\n * 0 indicating the length is \"short form\" and not \"long form\" and bits 7-1\n * give the length of the data. (The 8th bit is the left-most, most significant\n * bit: also known as big endian or network format).\n *\n * In the case that the length of the ASN.1 value is greater than 127, 2 to\n * 127 octets (bytes) are used to store the \"long form\" length. The first\n * byte's 8th bit is set to 1 to indicate the length is \"long form.\" Bits 7-1\n * give the number of additional octets. All following octets are in base 256\n * with the most significant digit first (typical big-endian binary unsigned\n * integer storage). So, for instance, if the length of a value was 257, the\n * first byte would be set to:\n *\n * 10000010 = 130 = 0x82.\n *\n * This indicates there are 2 octets (base 256) for the length. The second and\n * third bytes (the octets just mentioned) would store the length in base 256:\n *\n * octet 2: 00000001 = 1 * 256^1 = 256\n * octet 3: 00000001 = 1 * 256^0 = 1\n * total = 257\n *\n * The algorithm for converting a js integer value of 257 to base-256 is:\n *\n * var value = 257;\n * var bytes = [];\n * bytes[0] = (value >>> 8) & 0xFF; // most significant byte first\n * bytes[1] = value & 0xFF; // least significant byte last\n *\n * On the ASN.1 UNIVERSAL Object Identifier (OID) type:\n *\n * An OID can be written like: \"value1.value2.value3...valueN\"\n *\n * The DER encoding rules:\n *\n * The first byte has the value 40 * value1 + value2.\n * The following bytes, if any, encode the remaining values. Each value is\n * encoded in base 128, most significant digit first (big endian), with as\n * few digits as possible, and the most significant bit of each byte set\n * to 1 except the last in each value's encoding. For example: Given the\n * OID \"1.2.840.113549\", its DER encoding is (remember each byte except the\n * last one in each encoding is OR'd with 0x80):\n *\n * byte 1: 40 * 1 + 2 = 42 = 0x2A.\n * bytes 2-3: 128 * 6 + 72 = 840 = 6 72 = 6 72 = 0x0648 = 0x8648\n * bytes 4-6: 16384 * 6 + 128 * 119 + 13 = 6 119 13 = 0x06770D = 0x86F70D\n *\n * The final value is: 0x2A864886F70D.\n * The full OID (including ASN.1 tag and length of 6 bytes) is:\n * 0x06062A864886F70D\n */\nvar forge = require('./forge');\nrequire('./util');\nrequire('./oids');\n\n/* ASN.1 API */\nvar asn1 = module.exports = forge.asn1 = forge.asn1 || {};\n\n/**\n * ASN.1 classes.\n */\nasn1.Class = {\n UNIVERSAL: 0x00,\n APPLICATION: 0x40,\n CONTEXT_SPECIFIC: 0x80,\n PRIVATE: 0xC0\n};\n\n/**\n * ASN.1 types. Not all types are supported by this implementation, only\n * those necessary to implement a simple PKI are implemented.\n */\nasn1.Type = {\n NONE: 0,\n BOOLEAN: 1,\n INTEGER: 2,\n BITSTRING: 3,\n OCTETSTRING: 4,\n NULL: 5,\n OID: 6,\n ODESC: 7,\n EXTERNAL: 8,\n REAL: 9,\n ENUMERATED: 10,\n EMBEDDED: 11,\n UTF8: 12,\n ROID: 13,\n SEQUENCE: 16,\n SET: 17,\n PRINTABLESTRING: 19,\n IA5STRING: 22,\n UTCTIME: 23,\n GENERALIZEDTIME: 24,\n BMPSTRING: 30\n};\n\n/**\n * Creates a new asn1 object.\n *\n * @param tagClass the tag class for the object.\n * @param type the data type (tag number) for the object.\n * @param constructed true if the asn1 object is in constructed form.\n * @param value the value for the object, if it is not constructed.\n * @param [options] the options to use:\n * [bitStringContents] the plain BIT STRING content including padding\n * byte.\n *\n * @return the asn1 object.\n */\nasn1.create = function(tagClass, type, constructed, value, options) {\n /* An asn1 object has a tagClass, a type, a constructed flag, and a\n value. The value's type depends on the constructed flag. If\n constructed, it will contain a list of other asn1 objects. If not,\n it will contain the ASN.1 value as an array of bytes formatted\n according to the ASN.1 data type. */\n\n // remove undefined values\n if(forge.util.isArray(value)) {\n var tmp = [];\n for(var i = 0; i < value.length; ++i) {\n if(value[i] !== undefined) {\n tmp.push(value[i]);\n }\n }\n value = tmp;\n }\n\n var obj = {\n tagClass: tagClass,\n type: type,\n constructed: constructed,\n composed: constructed || forge.util.isArray(value),\n value: value\n };\n if(options && 'bitStringContents' in options) {\n // TODO: copy byte buffer if it's a buffer not a string\n obj.bitStringContents = options.bitStringContents;\n // TODO: add readonly flag to avoid this overhead\n // save copy to detect changes\n obj.original = asn1.copy(obj);\n }\n return obj;\n};\n\n/**\n * Copies an asn1 object.\n *\n * @param obj the asn1 object.\n * @param [options] copy options:\n * [excludeBitStringContents] true to not copy bitStringContents\n *\n * @return the a copy of the asn1 object.\n */\nasn1.copy = function(obj, options) {\n var copy;\n\n if(forge.util.isArray(obj)) {\n copy = [];\n for(var i = 0; i < obj.length; ++i) {\n copy.push(asn1.copy(obj[i], options));\n }\n return copy;\n }\n\n if(typeof obj === 'string') {\n // TODO: copy byte buffer if it's a buffer not a string\n return obj;\n }\n\n copy = {\n tagClass: obj.tagClass,\n type: obj.type,\n constructed: obj.constructed,\n composed: obj.composed,\n value: asn1.copy(obj.value, options)\n };\n if(options && !options.excludeBitStringContents) {\n // TODO: copy byte buffer if it's a buffer not a string\n copy.bitStringContents = obj.bitStringContents;\n }\n return copy;\n};\n\n/**\n * Compares asn1 objects for equality.\n *\n * Note this function does not run in constant time.\n *\n * @param obj1 the first asn1 object.\n * @param obj2 the second asn1 object.\n * @param [options] compare options:\n * [includeBitStringContents] true to compare bitStringContents\n *\n * @return true if the asn1 objects are equal.\n */\nasn1.equals = function(obj1, obj2, options) {\n if(forge.util.isArray(obj1)) {\n if(!forge.util.isArray(obj2)) {\n return false;\n }\n if(obj1.length !== obj2.length) {\n return false;\n }\n for(var i = 0; i < obj1.length; ++i) {\n if(!asn1.equals(obj1[i], obj2[i])) {\n return false;\n }\n }\n return true;\n }\n\n if(typeof obj1 !== typeof obj2) {\n return false;\n }\n\n if(typeof obj1 === 'string') {\n return obj1 === obj2;\n }\n\n var equal = obj1.tagClass === obj2.tagClass &&\n obj1.type === obj2.type &&\n obj1.constructed === obj2.constructed &&\n obj1.composed === obj2.composed &&\n asn1.equals(obj1.value, obj2.value);\n if(options && options.includeBitStringContents) {\n equal = equal && (obj1.bitStringContents === obj2.bitStringContents);\n }\n\n return equal;\n};\n\n/**\n * Gets the length of a BER-encoded ASN.1 value.\n *\n * In case the length is not specified, undefined is returned.\n *\n * @param b the BER-encoded ASN.1 byte buffer, starting with the first\n * length byte.\n *\n * @return the length of the BER-encoded ASN.1 value or undefined.\n */\nasn1.getBerValueLength = function(b) {\n // TODO: move this function and related DER/BER functions to a der.js\n // file; better abstract ASN.1 away from der/ber.\n var b2 = b.getByte();\n if(b2 === 0x80) {\n return undefined;\n }\n\n // see if the length is \"short form\" or \"long form\" (bit 8 set)\n var length;\n var longForm = b2 & 0x80;\n if(!longForm) {\n // length is just the first byte\n length = b2;\n } else {\n // the number of bytes the length is specified in bits 7 through 1\n // and each length byte is in big-endian base-256\n length = b.getInt((b2 & 0x7F) << 3);\n }\n return length;\n};\n\n/**\n * Check if the byte buffer has enough bytes. Throws an Error if not.\n *\n * @param bytes the byte buffer to parse from.\n * @param remaining the bytes remaining in the current parsing state.\n * @param n the number of bytes the buffer must have.\n */\nfunction _checkBufferLength(bytes, remaining, n) {\n if(n > remaining) {\n var error = new Error('Too few bytes to parse DER.');\n error.available = bytes.length();\n error.remaining = remaining;\n error.requested = n;\n throw error;\n }\n}\n\n/**\n * Gets the length of a BER-encoded ASN.1 value.\n *\n * In case the length is not specified, undefined is returned.\n *\n * @param bytes the byte buffer to parse from.\n * @param remaining the bytes remaining in the current parsing state.\n *\n * @return the length of the BER-encoded ASN.1 value or undefined.\n */\nvar _getValueLength = function(bytes, remaining) {\n // TODO: move this function and related DER/BER functions to a der.js\n // file; better abstract ASN.1 away from der/ber.\n // fromDer already checked that this byte exists\n var b2 = bytes.getByte();\n remaining--;\n if(b2 === 0x80) {\n return undefined;\n }\n\n // see if the length is \"short form\" or \"long form\" (bit 8 set)\n var length;\n var longForm = b2 & 0x80;\n if(!longForm) {\n // length is just the first byte\n length = b2;\n } else {\n // the number of bytes the length is specified in bits 7 through 1\n // and each length byte is in big-endian base-256\n var longFormBytes = b2 & 0x7F;\n _checkBufferLength(bytes, remaining, longFormBytes);\n length = bytes.getInt(longFormBytes << 3);\n }\n // FIXME: this will only happen for 32 bit getInt with high bit set\n if(length < 0) {\n throw new Error('Negative length: ' + length);\n }\n return length;\n};\n\n/**\n * Parses an asn1 object from a byte buffer in DER format.\n *\n * @param bytes the byte buffer to parse from.\n * @param [strict] true to be strict when checking value lengths, false to\n * allow truncated values (default: true).\n * @param [options] object with options or boolean strict flag\n * [strict] true to be strict when checking value lengths, false to\n * allow truncated values (default: true).\n * [decodeBitStrings] true to attempt to decode the content of\n * BIT STRINGs (not OCTET STRINGs) using strict mode. Note that\n * without schema support to understand the data context this can\n * erroneously decode values that happen to be valid ASN.1. This\n * flag will be deprecated or removed as soon as schema support is\n * available. (default: true)\n *\n * @return the parsed asn1 object.\n */\nasn1.fromDer = function(bytes, options) {\n if(options === undefined) {\n options = {\n strict: true,\n decodeBitStrings: true\n };\n }\n if(typeof options === 'boolean') {\n options = {\n strict: options,\n decodeBitStrings: true\n };\n }\n if(!('strict' in options)) {\n options.strict = true;\n }\n if(!('decodeBitStrings' in options)) {\n options.decodeBitStrings = true;\n }\n\n // wrap in buffer if needed\n if(typeof bytes === 'string') {\n bytes = forge.util.createBuffer(bytes);\n }\n\n return _fromDer(bytes, bytes.length(), 0, options);\n};\n\n/**\n * Internal function to parse an asn1 object from a byte buffer in DER format.\n *\n * @param bytes the byte buffer to parse from.\n * @param remaining the number of bytes remaining for this chunk.\n * @param depth the current parsing depth.\n * @param options object with same options as fromDer().\n *\n * @return the parsed asn1 object.\n */\nfunction _fromDer(bytes, remaining, depth, options) {\n // temporary storage for consumption calculations\n var start;\n\n // minimum length for ASN.1 DER structure is 2\n _checkBufferLength(bytes, remaining, 2);\n\n // get the first byte\n var b1 = bytes.getByte();\n // consumed one byte\n remaining--;\n\n // get the tag class\n var tagClass = (b1 & 0xC0);\n\n // get the type (bits 1-5)\n var type = b1 & 0x1F;\n\n // get the variable value length and adjust remaining bytes\n start = bytes.length();\n var length = _getValueLength(bytes, remaining);\n remaining -= start - bytes.length();\n\n // ensure there are enough bytes to get the value\n if(length !== undefined && length > remaining) {\n if(options.strict) {\n var error = new Error('Too few bytes to read ASN.1 value.');\n error.available = bytes.length();\n error.remaining = remaining;\n error.requested = length;\n throw error;\n }\n // Note: be lenient with truncated values and use remaining state bytes\n length = remaining;\n }\n\n // value storage\n var value;\n // possible BIT STRING contents storage\n var bitStringContents;\n\n // constructed flag is bit 6 (32 = 0x20) of the first byte\n var constructed = ((b1 & 0x20) === 0x20);\n if(constructed) {\n // parse child asn1 objects from the value\n value = [];\n if(length === undefined) {\n // asn1 object of indefinite length, read until end tag\n for(;;) {\n _checkBufferLength(bytes, remaining, 2);\n if(bytes.bytes(2) === String.fromCharCode(0, 0)) {\n bytes.getBytes(2);\n remaining -= 2;\n break;\n }\n start = bytes.length();\n value.push(_fromDer(bytes, remaining, depth + 1, options));\n remaining -= start - bytes.length();\n }\n } else {\n // parsing asn1 object of definite length\n while(length > 0) {\n start = bytes.length();\n value.push(_fromDer(bytes, length, depth + 1, options));\n remaining -= start - bytes.length();\n length -= start - bytes.length();\n }\n }\n }\n\n // if a BIT STRING, save the contents including padding\n if(value === undefined && tagClass === asn1.Class.UNIVERSAL &&\n type === asn1.Type.BITSTRING) {\n bitStringContents = bytes.bytes(length);\n }\n\n // determine if a non-constructed value should be decoded as a composed\n // value that contains other ASN.1 objects. BIT STRINGs (and OCTET STRINGs)\n // can be used this way.\n if(value === undefined && options.decodeBitStrings &&\n tagClass === asn1.Class.UNIVERSAL &&\n // FIXME: OCTET STRINGs not yet supported here\n // .. other parts of forge expect to decode OCTET STRINGs manually\n (type === asn1.Type.BITSTRING /*|| type === asn1.Type.OCTETSTRING*/) &&\n length > 1) {\n // save read position\n var savedRead = bytes.read;\n var savedRemaining = remaining;\n var unused = 0;\n if(type === asn1.Type.BITSTRING) {\n /* The first octet gives the number of bits by which the length of the\n bit string is less than the next multiple of eight (this is called\n the \"number of unused bits\").\n\n The second and following octets give the value of the bit string\n converted to an octet string. */\n _checkBufferLength(bytes, remaining, 1);\n unused = bytes.getByte();\n remaining--;\n }\n // if all bits are used, maybe the BIT/OCTET STRING holds ASN.1 objs\n if(unused === 0) {\n try {\n // attempt to parse child asn1 object from the value\n // (stored in array to signal composed value)\n start = bytes.length();\n var subOptions = {\n // enforce strict mode to avoid parsing ASN.1 from plain data\n verbose: options.verbose,\n strict: true,\n decodeBitStrings: true\n };\n var composed = _fromDer(bytes, remaining, depth + 1, subOptions);\n var used = start - bytes.length();\n remaining -= used;\n if(type == asn1.Type.BITSTRING) {\n used++;\n }\n\n // if the data all decoded and the class indicates UNIVERSAL or\n // CONTEXT_SPECIFIC then assume we've got an encapsulated ASN.1 object\n var tc = composed.tagClass;\n if(used === length &&\n (tc === asn1.Class.UNIVERSAL || tc === asn1.Class.CONTEXT_SPECIFIC)) {\n value = [composed];\n }\n } catch(ex) {\n }\n }\n if(value === undefined) {\n // restore read position\n bytes.read = savedRead;\n remaining = savedRemaining;\n }\n }\n\n if(value === undefined) {\n // asn1 not constructed or composed, get raw value\n // TODO: do DER to OID conversion and vice-versa in .toDer?\n\n if(length === undefined) {\n if(options.strict) {\n throw new Error('Non-constructed ASN.1 object of indefinite length.');\n }\n // be lenient and use remaining state bytes\n length = remaining;\n }\n\n if(type === asn1.Type.BMPSTRING) {\n value = '';\n for(; length > 0; length -= 2) {\n _checkBufferLength(bytes, remaining, 2);\n value += String.fromCharCode(bytes.getInt16());\n remaining -= 2;\n }\n } else {\n value = bytes.getBytes(length);\n }\n }\n\n // add BIT STRING contents if available\n var asn1Options = bitStringContents === undefined ? null : {\n bitStringContents: bitStringContents\n };\n\n // create and return asn1 object\n return asn1.create(tagClass, type, constructed, value, asn1Options);\n}\n\n/**\n * Converts the given asn1 object to a buffer of bytes in DER format.\n *\n * @param asn1 the asn1 object to convert to bytes.\n *\n * @return the buffer of bytes.\n */\nasn1.toDer = function(obj) {\n var bytes = forge.util.createBuffer();\n\n // build the first byte\n var b1 = obj.tagClass | obj.type;\n\n // for storing the ASN.1 value\n var value = forge.util.createBuffer();\n\n // use BIT STRING contents if available and data not changed\n var useBitStringContents = false;\n if('bitStringContents' in obj) {\n useBitStringContents = true;\n if(obj.original) {\n useBitStringContents = asn1.equals(obj, obj.original);\n }\n }\n\n if(useBitStringContents) {\n value.putBytes(obj.bitStringContents);\n } else if(obj.composed) {\n // if composed, use each child asn1 object's DER bytes as value\n // turn on 6th bit (0x20 = 32) to indicate asn1 is constructed\n // from other asn1 objects\n if(obj.constructed) {\n b1 |= 0x20;\n } else {\n // type is a bit string, add unused bits of 0x00\n value.putByte(0x00);\n }\n\n // add all of the child DER bytes together\n for(var i = 0; i < obj.value.length; ++i) {\n if(obj.value[i] !== undefined) {\n value.putBuffer(asn1.toDer(obj.value[i]));\n }\n }\n } else {\n // use asn1.value directly\n if(obj.type === asn1.Type.BMPSTRING) {\n for(var i = 0; i < obj.value.length; ++i) {\n value.putInt16(obj.value.charCodeAt(i));\n }\n } else {\n // ensure integer is minimally-encoded\n // TODO: should all leading bytes be stripped vs just one?\n // .. ex '00 00 01' => '01'?\n if(obj.type === asn1.Type.INTEGER &&\n obj.value.length > 1 &&\n // leading 0x00 for positive integer\n ((obj.value.charCodeAt(0) === 0 &&\n (obj.value.charCodeAt(1) & 0x80) === 0) ||\n // leading 0xFF for negative integer\n (obj.value.charCodeAt(0) === 0xFF &&\n (obj.value.charCodeAt(1) & 0x80) === 0x80))) {\n value.putBytes(obj.value.substr(1));\n } else {\n value.putBytes(obj.value);\n }\n }\n }\n\n // add tag byte\n bytes.putByte(b1);\n\n // use \"short form\" encoding\n if(value.length() <= 127) {\n // one byte describes the length\n // bit 8 = 0 and bits 7-1 = length\n bytes.putByte(value.length() & 0x7F);\n } else {\n // use \"long form\" encoding\n // 2 to 127 bytes describe the length\n // first byte: bit 8 = 1 and bits 7-1 = # of additional bytes\n // other bytes: length in base 256, big-endian\n var len = value.length();\n var lenBytes = '';\n do {\n lenBytes += String.fromCharCode(len & 0xFF);\n len = len >>> 8;\n } while(len > 0);\n\n // set first byte to # bytes used to store the length and turn on\n // bit 8 to indicate long-form length is used\n bytes.putByte(lenBytes.length | 0x80);\n\n // concatenate length bytes in reverse since they were generated\n // little endian and we need big endian\n for(var i = lenBytes.length - 1; i >= 0; --i) {\n bytes.putByte(lenBytes.charCodeAt(i));\n }\n }\n\n // concatenate value bytes\n bytes.putBuffer(value);\n return bytes;\n};\n\n/**\n * Converts an OID dot-separated string to a byte buffer. The byte buffer\n * contains only the DER-encoded value, not any tag or length bytes.\n *\n * @param oid the OID dot-separated string.\n *\n * @return the byte buffer.\n */\nasn1.oidToDer = function(oid) {\n // split OID into individual values\n var values = oid.split('.');\n var bytes = forge.util.createBuffer();\n\n // first byte is 40 * value1 + value2\n bytes.putByte(40 * parseInt(values[0], 10) + parseInt(values[1], 10));\n // other bytes are each value in base 128 with 8th bit set except for\n // the last byte for each value\n var last, valueBytes, value, b;\n for(var i = 2; i < values.length; ++i) {\n // produce value bytes in reverse because we don't know how many\n // bytes it will take to store the value\n last = true;\n valueBytes = [];\n value = parseInt(values[i], 10);\n do {\n b = value & 0x7F;\n value = value >>> 7;\n // if value is not last, then turn on 8th bit\n if(!last) {\n b |= 0x80;\n }\n valueBytes.push(b);\n last = false;\n } while(value > 0);\n\n // add value bytes in reverse (needs to be in big endian)\n for(var n = valueBytes.length - 1; n >= 0; --n) {\n bytes.putByte(valueBytes[n]);\n }\n }\n\n return bytes;\n};\n\n/**\n * Converts a DER-encoded byte buffer to an OID dot-separated string. The\n * byte buffer should contain only the DER-encoded value, not any tag or\n * length bytes.\n *\n * @param bytes the byte buffer.\n *\n * @return the OID dot-separated string.\n */\nasn1.derToOid = function(bytes) {\n var oid;\n\n // wrap in buffer if needed\n if(typeof bytes === 'string') {\n bytes = forge.util.createBuffer(bytes);\n }\n\n // first byte is 40 * value1 + value2\n var b = bytes.getByte();\n oid = Math.floor(b / 40) + '.' + (b % 40);\n\n // other bytes are each value in base 128 with 8th bit set except for\n // the last byte for each value\n var value = 0;\n while(bytes.length() > 0) {\n b = bytes.getByte();\n value = value << 7;\n // not the last byte for the value\n if(b & 0x80) {\n value += b & 0x7F;\n } else {\n // last byte\n oid += '.' + (value + b);\n value = 0;\n }\n }\n\n return oid;\n};\n\n/**\n * Converts a UTCTime value to a date.\n *\n * Note: GeneralizedTime has 4 digits for the year and is used for X.509\n * dates past 2049. Parsing that structure hasn't been implemented yet.\n *\n * @param utc the UTCTime value to convert.\n *\n * @return the date.\n */\nasn1.utcTimeToDate = function(utc) {\n /* The following formats can be used:\n\n YYMMDDhhmmZ\n YYMMDDhhmm+hh'mm'\n YYMMDDhhmm-hh'mm'\n YYMMDDhhmmssZ\n YYMMDDhhmmss+hh'mm'\n YYMMDDhhmmss-hh'mm'\n\n Where:\n\n YY is the least significant two digits of the year\n MM is the month (01 to 12)\n DD is the day (01 to 31)\n hh is the hour (00 to 23)\n mm are the minutes (00 to 59)\n ss are the seconds (00 to 59)\n Z indicates that local time is GMT, + indicates that local time is\n later than GMT, and - indicates that local time is earlier than GMT\n hh' is the absolute value of the offset from GMT in hours\n mm' is the absolute value of the offset from GMT in minutes */\n var date = new Date();\n\n // if YY >= 50 use 19xx, if YY < 50 use 20xx\n var year = parseInt(utc.substr(0, 2), 10);\n year = (year >= 50) ? 1900 + year : 2000 + year;\n var MM = parseInt(utc.substr(2, 2), 10) - 1; // use 0-11 for month\n var DD = parseInt(utc.substr(4, 2), 10);\n var hh = parseInt(utc.substr(6, 2), 10);\n var mm = parseInt(utc.substr(8, 2), 10);\n var ss = 0;\n\n // not just YYMMDDhhmmZ\n if(utc.length > 11) {\n // get character after minutes\n var c = utc.charAt(10);\n var end = 10;\n\n // see if seconds are present\n if(c !== '+' && c !== '-') {\n // get seconds\n ss = parseInt(utc.substr(10, 2), 10);\n end += 2;\n }\n }\n\n // update date\n date.setUTCFullYear(year, MM, DD);\n date.setUTCHours(hh, mm, ss, 0);\n\n if(end) {\n // get +/- after end of time\n c = utc.charAt(end);\n if(c === '+' || c === '-') {\n // get hours+minutes offset\n var hhoffset = parseInt(utc.substr(end + 1, 2), 10);\n var mmoffset = parseInt(utc.substr(end + 4, 2), 10);\n\n // calculate offset in milliseconds\n var offset = hhoffset * 60 + mmoffset;\n offset *= 60000;\n\n // apply offset\n if(c === '+') {\n date.setTime(+date - offset);\n } else {\n date.setTime(+date + offset);\n }\n }\n }\n\n return date;\n};\n\n/**\n * Converts a GeneralizedTime value to a date.\n *\n * @param gentime the GeneralizedTime value to convert.\n *\n * @return the date.\n */\nasn1.generalizedTimeToDate = function(gentime) {\n /* The following formats can be used:\n\n YYYYMMDDHHMMSS\n YYYYMMDDHHMMSS.fff\n YYYYMMDDHHMMSSZ\n YYYYMMDDHHMMSS.fffZ\n YYYYMMDDHHMMSS+hh'mm'\n YYYYMMDDHHMMSS.fff+hh'mm'\n YYYYMMDDHHMMSS-hh'mm'\n YYYYMMDDHHMMSS.fff-hh'mm'\n\n Where:\n\n YYYY is the year\n MM is the month (01 to 12)\n DD is the day (01 to 31)\n hh is the hour (00 to 23)\n mm are the minutes (00 to 59)\n ss are the seconds (00 to 59)\n .fff is the second fraction, accurate to three decimal places\n Z indicates that local time is GMT, + indicates that local time is\n later than GMT, and - indicates that local time is earlier than GMT\n hh' is the absolute value of the offset from GMT in hours\n mm' is the absolute value of the offset from GMT in minutes */\n var date = new Date();\n\n var YYYY = parseInt(gentime.substr(0, 4), 10);\n var MM = parseInt(gentime.substr(4, 2), 10) - 1; // use 0-11 for month\n var DD = parseInt(gentime.substr(6, 2), 10);\n var hh = parseInt(gentime.substr(8, 2), 10);\n var mm = parseInt(gentime.substr(10, 2), 10);\n var ss = parseInt(gentime.substr(12, 2), 10);\n var fff = 0;\n var offset = 0;\n var isUTC = false;\n\n if(gentime.charAt(gentime.length - 1) === 'Z') {\n isUTC = true;\n }\n\n var end = gentime.length - 5, c = gentime.charAt(end);\n if(c === '+' || c === '-') {\n // get hours+minutes offset\n var hhoffset = parseInt(gentime.substr(end + 1, 2), 10);\n var mmoffset = parseInt(gentime.substr(end + 4, 2), 10);\n\n // calculate offset in milliseconds\n offset = hhoffset * 60 + mmoffset;\n offset *= 60000;\n\n // apply offset\n if(c === '+') {\n offset *= -1;\n }\n\n isUTC = true;\n }\n\n // check for second fraction\n if(gentime.charAt(14) === '.') {\n fff = parseFloat(gentime.substr(14), 10) * 1000;\n }\n\n if(isUTC) {\n date.setUTCFullYear(YYYY, MM, DD);\n date.setUTCHours(hh, mm, ss, fff);\n\n // apply offset\n date.setTime(+date + offset);\n } else {\n date.setFullYear(YYYY, MM, DD);\n date.setHours(hh, mm, ss, fff);\n }\n\n return date;\n};\n\n/**\n * Converts a date to a UTCTime value.\n *\n * Note: GeneralizedTime has 4 digits for the year and is used for X.509\n * dates past 2049. Converting to a GeneralizedTime hasn't been\n * implemented yet.\n *\n * @param date the date to convert.\n *\n * @return the UTCTime value.\n */\nasn1.dateToUtcTime = function(date) {\n // TODO: validate; currently assumes proper format\n if(typeof date === 'string') {\n return date;\n }\n\n var rval = '';\n\n // create format YYMMDDhhmmssZ\n var format = [];\n format.push(('' + date.getUTCFullYear()).substr(2));\n format.push('' + (date.getUTCMonth() + 1));\n format.push('' + date.getUTCDate());\n format.push('' + date.getUTCHours());\n format.push('' + date.getUTCMinutes());\n format.push('' + date.getUTCSeconds());\n\n // ensure 2 digits are used for each format entry\n for(var i = 0; i < format.length; ++i) {\n if(format[i].length < 2) {\n rval += '0';\n }\n rval += format[i];\n }\n rval += 'Z';\n\n return rval;\n};\n\n/**\n * Converts a date to a GeneralizedTime value.\n *\n * @param date the date to convert.\n *\n * @return the GeneralizedTime value as a string.\n */\nasn1.dateToGeneralizedTime = function(date) {\n // TODO: validate; currently assumes proper format\n if(typeof date === 'string') {\n return date;\n }\n\n var rval = '';\n\n // create format YYYYMMDDHHMMSSZ\n var format = [];\n format.push('' + date.getUTCFullYear());\n format.push('' + (date.getUTCMonth() + 1));\n format.push('' + date.getUTCDate());\n format.push('' + date.getUTCHours());\n format.push('' + date.getUTCMinutes());\n format.push('' + date.getUTCSeconds());\n\n // ensure 2 digits are used for each format entry\n for(var i = 0; i < format.length; ++i) {\n if(format[i].length < 2) {\n rval += '0';\n }\n rval += format[i];\n }\n rval += 'Z';\n\n return rval;\n};\n\n/**\n * Converts a javascript integer to a DER-encoded byte buffer to be used\n * as the value for an INTEGER type.\n *\n * @param x the integer.\n *\n * @return the byte buffer.\n */\nasn1.integerToDer = function(x) {\n var rval = forge.util.createBuffer();\n if(x >= -0x80 && x < 0x80) {\n return rval.putSignedInt(x, 8);\n }\n if(x >= -0x8000 && x < 0x8000) {\n return rval.putSignedInt(x, 16);\n }\n if(x >= -0x800000 && x < 0x800000) {\n return rval.putSignedInt(x, 24);\n }\n if(x >= -0x80000000 && x < 0x80000000) {\n return rval.putSignedInt(x, 32);\n }\n var error = new Error('Integer too large; max is 32-bits.');\n error.integer = x;\n throw error;\n};\n\n/**\n * Converts a DER-encoded byte buffer to a javascript integer. This is\n * typically used to decode the value of an INTEGER type.\n *\n * @param bytes the byte buffer.\n *\n * @return the integer.\n */\nasn1.derToInteger = function(bytes) {\n // wrap in buffer if needed\n if(typeof bytes === 'string') {\n bytes = forge.util.createBuffer(bytes);\n }\n\n var n = bytes.length() * 8;\n if(n > 32) {\n throw new Error('Integer too large; max is 32-bits.');\n }\n return bytes.getSignedInt(n);\n};\n\n/**\n * Validates that the given ASN.1 object is at least a super set of the\n * given ASN.1 structure. Only tag classes and types are checked. An\n * optional map may also be provided to capture ASN.1 values while the\n * structure is checked.\n *\n * To capture an ASN.1 value, set an object in the validator's 'capture'\n * parameter to the key to use in the capture map. To capture the full\n * ASN.1 object, specify 'captureAsn1'. To capture BIT STRING bytes, including\n * the leading unused bits counter byte, specify 'captureBitStringContents'.\n * To capture BIT STRING bytes, without the leading unused bits counter byte,\n * specify 'captureBitStringValue'.\n *\n * Objects in the validator may set a field 'optional' to true to indicate\n * that it isn't necessary to pass validation.\n *\n * @param obj the ASN.1 object to validate.\n * @param v the ASN.1 structure validator.\n * @param capture an optional map to capture values in.\n * @param errors an optional array for storing validation errors.\n *\n * @return true on success, false on failure.\n */\nasn1.validate = function(obj, v, capture, errors) {\n var rval = false;\n\n // ensure tag class and type are the same if specified\n if((obj.tagClass === v.tagClass || typeof(v.tagClass) === 'undefined') &&\n (obj.type === v.type || typeof(v.type) === 'undefined')) {\n // ensure constructed flag is the same if specified\n if(obj.constructed === v.constructed ||\n typeof(v.constructed) === 'undefined') {\n rval = true;\n\n // handle sub values\n if(v.value && forge.util.isArray(v.value)) {\n var j = 0;\n for(var i = 0; rval && i < v.value.length; ++i) {\n rval = v.value[i].optional || false;\n if(obj.value[j]) {\n rval = asn1.validate(obj.value[j], v.value[i], capture, errors);\n if(rval) {\n ++j;\n } else if(v.value[i].optional) {\n rval = true;\n }\n }\n if(!rval && errors) {\n errors.push(\n '[' + v.name + '] ' +\n 'Tag class \"' + v.tagClass + '\", type \"' +\n v.type + '\" expected value length \"' +\n v.value.length + '\", got \"' +\n obj.value.length + '\"');\n }\n }\n }\n\n if(rval && capture) {\n if(v.capture) {\n capture[v.capture] = obj.value;\n }\n if(v.captureAsn1) {\n capture[v.captureAsn1] = obj;\n }\n if(v.captureBitStringContents && 'bitStringContents' in obj) {\n capture[v.captureBitStringContents] = obj.bitStringContents;\n }\n if(v.captureBitStringValue && 'bitStringContents' in obj) {\n var value;\n if(obj.bitStringContents.length < 2) {\n capture[v.captureBitStringValue] = '';\n } else {\n // FIXME: support unused bits with data shifting\n var unused = obj.bitStringContents.charCodeAt(0);\n if(unused !== 0) {\n throw new Error(\n 'captureBitStringValue only supported for zero unused bits');\n }\n capture[v.captureBitStringValue] = obj.bitStringContents.slice(1);\n }\n }\n }\n } else if(errors) {\n errors.push(\n '[' + v.name + '] ' +\n 'Expected constructed \"' + v.constructed + '\", got \"' +\n obj.constructed + '\"');\n }\n } else if(errors) {\n if(obj.tagClass !== v.tagClass) {\n errors.push(\n '[' + v.name + '] ' +\n 'Expected tag class \"' + v.tagClass + '\", got \"' +\n obj.tagClass + '\"');\n }\n if(obj.type !== v.type) {\n errors.push(\n '[' + v.name + '] ' +\n 'Expected type \"' + v.type + '\", got \"' + obj.type + '\"');\n }\n }\n return rval;\n};\n\n// regex for testing for non-latin characters\nvar _nonLatinRegex = /[^\\\\u0000-\\\\u00ff]/;\n\n/**\n * Pretty prints an ASN.1 object to a string.\n *\n * @param obj the object to write out.\n * @param level the level in the tree.\n * @param indentation the indentation to use.\n *\n * @return the string.\n */\nasn1.prettyPrint = function(obj, level, indentation) {\n var rval = '';\n\n // set default level and indentation\n level = level || 0;\n indentation = indentation || 2;\n\n // start new line for deep levels\n if(level > 0) {\n rval += '\\n';\n }\n\n // create indent\n var indent = '';\n for(var i = 0; i < level * indentation; ++i) {\n indent += ' ';\n }\n\n // print class:type\n rval += indent + 'Tag: ';\n switch(obj.tagClass) {\n case asn1.Class.UNIVERSAL:\n rval += 'Universal:';\n break;\n case asn1.Class.APPLICATION:\n rval += 'Application:';\n break;\n case asn1.Class.CONTEXT_SPECIFIC:\n rval += 'Context-Specific:';\n break;\n case asn1.Class.PRIVATE:\n rval += 'Private:';\n break;\n }\n\n if(obj.tagClass === asn1.Class.UNIVERSAL) {\n rval += obj.type;\n\n // known types\n switch(obj.type) {\n case asn1.Type.NONE:\n rval += ' (None)';\n break;\n case asn1.Type.BOOLEAN:\n rval += ' (Boolean)';\n break;\n case asn1.Type.INTEGER:\n rval += ' (Integer)';\n break;\n case asn1.Type.BITSTRING:\n rval += ' (Bit string)';\n break;\n case asn1.Type.OCTETSTRING:\n rval += ' (Octet string)';\n break;\n case asn1.Type.NULL:\n rval += ' (Null)';\n break;\n case asn1.Type.OID:\n rval += ' (Object Identifier)';\n break;\n case asn1.Type.ODESC:\n rval += ' (Object Descriptor)';\n break;\n case asn1.Type.EXTERNAL:\n rval += ' (External or Instance of)';\n break;\n case asn1.Type.REAL:\n rval += ' (Real)';\n break;\n case asn1.Type.ENUMERATED:\n rval += ' (Enumerated)';\n break;\n case asn1.Type.EMBEDDED:\n rval += ' (Embedded PDV)';\n break;\n case asn1.Type.UTF8:\n rval += ' (UTF8)';\n break;\n case asn1.Type.ROID:\n rval += ' (Relative Object Identifier)';\n break;\n case asn1.Type.SEQUENCE:\n rval += ' (Sequence)';\n break;\n case asn1.Type.SET:\n rval += ' (Set)';\n break;\n case asn1.Type.PRINTABLESTRING:\n rval += ' (Printable String)';\n break;\n case asn1.Type.IA5String:\n rval += ' (IA5String (ASCII))';\n break;\n case asn1.Type.UTCTIME:\n rval += ' (UTC time)';\n break;\n case asn1.Type.GENERALIZEDTIME:\n rval += ' (Generalized time)';\n break;\n case asn1.Type.BMPSTRING:\n rval += ' (BMP String)';\n break;\n }\n } else {\n rval += obj.type;\n }\n\n rval += '\\n';\n rval += indent + 'Constructed: ' + obj.constructed + '\\n';\n\n if(obj.composed) {\n var subvalues = 0;\n var sub = '';\n for(var i = 0; i < obj.value.length; ++i) {\n if(obj.value[i] !== undefined) {\n subvalues += 1;\n sub += asn1.prettyPrint(obj.value[i], level + 1, indentation);\n if((i + 1) < obj.value.length) {\n sub += ',';\n }\n }\n }\n rval += indent + 'Sub values: ' + subvalues + sub;\n } else {\n rval += indent + 'Value: ';\n if(obj.type === asn1.Type.OID) {\n var oid = asn1.derToOid(obj.value);\n rval += oid;\n if(forge.pki && forge.pki.oids) {\n if(oid in forge.pki.oids) {\n rval += ' (' + forge.pki.oids[oid] + ') ';\n }\n }\n }\n if(obj.type === asn1.Type.INTEGER) {\n try {\n rval += asn1.derToInteger(obj.value);\n } catch(ex) {\n rval += '0x' + forge.util.bytesToHex(obj.value);\n }\n } else if(obj.type === asn1.Type.BITSTRING) {\n // TODO: shift bits as needed to display without padding\n if(obj.value.length > 1) {\n // remove unused bits field\n rval += '0x' + forge.util.bytesToHex(obj.value.slice(1));\n } else {\n rval += '(none)';\n }\n // show unused bit count\n if(obj.value.length > 0) {\n var unused = obj.value.charCodeAt(0);\n if(unused == 1) {\n rval += ' (1 unused bit shown)';\n } else if(unused > 1) {\n rval += ' (' + unused + ' unused bits shown)';\n }\n }\n } else if(obj.type === asn1.Type.OCTETSTRING) {\n if(!_nonLatinRegex.test(obj.value)) {\n rval += '(' + obj.value + ') ';\n }\n rval += '0x' + forge.util.bytesToHex(obj.value);\n } else if(obj.type === asn1.Type.UTF8) {\n rval += forge.util.decodeUtf8(obj.value);\n } else if(obj.type === asn1.Type.PRINTABLESTRING ||\n obj.type === asn1.Type.IA5String) {\n rval += obj.value;\n } else if(_nonLatinRegex.test(obj.value)) {\n rval += '0x' + forge.util.bytesToHex(obj.value);\n } else if(obj.value.length === 0) {\n rval += '[null]';\n } else {\n rval += obj.value;\n }\n }\n\n return rval;\n};\n","/**\n * Base-N/Base-X encoding/decoding functions.\n *\n * Original implementation from base-x:\n * https://github.com/cryptocoinjs/base-x\n *\n * Which is MIT licensed:\n *\n * The MIT License (MIT)\n *\n * Copyright base-x contributors (c) 2016\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nvar api = {};\nmodule.exports = api;\n\n// baseN alphabet indexes\nvar _reverseAlphabets = {};\n\n/**\n * BaseN-encodes a Uint8Array using the given alphabet.\n *\n * @param input the Uint8Array to encode.\n * @param maxline the maximum number of encoded characters per line to use,\n * defaults to none.\n *\n * @return the baseN-encoded output string.\n */\napi.encode = function(input, alphabet, maxline) {\n if(typeof alphabet !== 'string') {\n throw new TypeError('\"alphabet\" must be a string.');\n }\n if(maxline !== undefined && typeof maxline !== 'number') {\n throw new TypeError('\"maxline\" must be a number.');\n }\n\n var output = '';\n\n if(!(input instanceof Uint8Array)) {\n // assume forge byte buffer\n output = _encodeWithByteBuffer(input, alphabet);\n } else {\n var i = 0;\n var base = alphabet.length;\n var first = alphabet.charAt(0);\n var digits = [0];\n for(i = 0; i < input.length; ++i) {\n for(var j = 0, carry = input[i]; j < digits.length; ++j) {\n carry += digits[j] << 8;\n digits[j] = carry % base;\n carry = (carry / base) | 0;\n }\n\n while(carry > 0) {\n digits.push(carry % base);\n carry = (carry / base) | 0;\n }\n }\n\n // deal with leading zeros\n for(i = 0; input[i] === 0 && i < input.length - 1; ++i) {\n output += first;\n }\n // convert digits to a string\n for(i = digits.length - 1; i >= 0; --i) {\n output += alphabet[digits[i]];\n }\n }\n\n if(maxline) {\n var regex = new RegExp('.{1,' + maxline + '}', 'g');\n output = output.match(regex).join('\\r\\n');\n }\n\n return output;\n};\n\n/**\n * Decodes a baseN-encoded (using the given alphabet) string to a\n * Uint8Array.\n *\n * @param input the baseN-encoded input string.\n *\n * @return the Uint8Array.\n */\napi.decode = function(input, alphabet) {\n if(typeof input !== 'string') {\n throw new TypeError('\"input\" must be a string.');\n }\n if(typeof alphabet !== 'string') {\n throw new TypeError('\"alphabet\" must be a string.');\n }\n\n var table = _reverseAlphabets[alphabet];\n if(!table) {\n // compute reverse alphabet\n table = _reverseAlphabets[alphabet] = [];\n for(var i = 0; i < alphabet.length; ++i) {\n table[alphabet.charCodeAt(i)] = i;\n }\n }\n\n // remove whitespace characters\n input = input.replace(/\\s/g, '');\n\n var base = alphabet.length;\n var first = alphabet.charAt(0);\n var bytes = [0];\n for(var i = 0; i < input.length; i++) {\n var value = table[input.charCodeAt(i)];\n if(value === undefined) {\n return;\n }\n\n for(var j = 0, carry = value; j < bytes.length; ++j) {\n carry += bytes[j] * base;\n bytes[j] = carry & 0xff;\n carry >>= 8;\n }\n\n while(carry > 0) {\n bytes.push(carry & 0xff);\n carry >>= 8;\n }\n }\n\n // deal with leading zeros\n for(var k = 0; input[k] === first && k < input.length - 1; ++k) {\n bytes.push(0);\n }\n\n if(typeof Buffer !== 'undefined') {\n return Buffer.from(bytes.reverse());\n }\n\n return new Uint8Array(bytes.reverse());\n};\n\nfunction _encodeWithByteBuffer(input, alphabet) {\n var i = 0;\n var base = alphabet.length;\n var first = alphabet.charAt(0);\n var digits = [0];\n for(i = 0; i < input.length(); ++i) {\n for(var j = 0, carry = input.at(i); j < digits.length; ++j) {\n carry += digits[j] << 8;\n digits[j] = carry % base;\n carry = (carry / base) | 0;\n }\n\n while(carry > 0) {\n digits.push(carry % base);\n carry = (carry / base) | 0;\n }\n }\n\n var output = '';\n\n // deal with leading zeros\n for(i = 0; input.at(i) === 0 && i < input.length() - 1; ++i) {\n output += first;\n }\n // convert digits to a string\n for(i = digits.length - 1; i >= 0; --i) {\n output += alphabet[digits[i]];\n }\n\n return output;\n}\n","/**\n * Cipher base API.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\nmodule.exports = forge.cipher = forge.cipher || {};\n\n// registered algorithms\nforge.cipher.algorithms = forge.cipher.algorithms || {};\n\n/**\n * Creates a cipher object that can be used to encrypt data using the given\n * algorithm and key. The algorithm may be provided as a string value for a\n * previously registered algorithm or it may be given as a cipher algorithm\n * API object.\n *\n * @param algorithm the algorithm to use, either a string or an algorithm API\n * object.\n * @param key the key to use, as a binary-encoded string of bytes or a\n * byte buffer.\n *\n * @return the cipher.\n */\nforge.cipher.createCipher = function(algorithm, key) {\n var api = algorithm;\n if(typeof api === 'string') {\n api = forge.cipher.getAlgorithm(api);\n if(api) {\n api = api();\n }\n }\n if(!api) {\n throw new Error('Unsupported algorithm: ' + algorithm);\n }\n\n // assume block cipher\n return new forge.cipher.BlockCipher({\n algorithm: api,\n key: key,\n decrypt: false\n });\n};\n\n/**\n * Creates a decipher object that can be used to decrypt data using the given\n * algorithm and key. The algorithm may be provided as a string value for a\n * previously registered algorithm or it may be given as a cipher algorithm\n * API object.\n *\n * @param algorithm the algorithm to use, either a string or an algorithm API\n * object.\n * @param key the key to use, as a binary-encoded string of bytes or a\n * byte buffer.\n *\n * @return the cipher.\n */\nforge.cipher.createDecipher = function(algorithm, key) {\n var api = algorithm;\n if(typeof api === 'string') {\n api = forge.cipher.getAlgorithm(api);\n if(api) {\n api = api();\n }\n }\n if(!api) {\n throw new Error('Unsupported algorithm: ' + algorithm);\n }\n\n // assume block cipher\n return new forge.cipher.BlockCipher({\n algorithm: api,\n key: key,\n decrypt: true\n });\n};\n\n/**\n * Registers an algorithm by name. If the name was already registered, the\n * algorithm API object will be overwritten.\n *\n * @param name the name of the algorithm.\n * @param algorithm the algorithm API object.\n */\nforge.cipher.registerAlgorithm = function(name, algorithm) {\n name = name.toUpperCase();\n forge.cipher.algorithms[name] = algorithm;\n};\n\n/**\n * Gets a registered algorithm by name.\n *\n * @param name the name of the algorithm.\n *\n * @return the algorithm, if found, null if not.\n */\nforge.cipher.getAlgorithm = function(name) {\n name = name.toUpperCase();\n if(name in forge.cipher.algorithms) {\n return forge.cipher.algorithms[name];\n }\n return null;\n};\n\nvar BlockCipher = forge.cipher.BlockCipher = function(options) {\n this.algorithm = options.algorithm;\n this.mode = this.algorithm.mode;\n this.blockSize = this.mode.blockSize;\n this._finish = false;\n this._input = null;\n this.output = null;\n this._op = options.decrypt ? this.mode.decrypt : this.mode.encrypt;\n this._decrypt = options.decrypt;\n this.algorithm.initialize(options);\n};\n\n/**\n * Starts or restarts the encryption or decryption process, whichever\n * was previously configured.\n *\n * For non-GCM mode, the IV may be a binary-encoded string of bytes, an array\n * of bytes, a byte buffer, or an array of 32-bit integers. If the IV is in\n * bytes, then it must be Nb (16) bytes in length. If the IV is given in as\n * 32-bit integers, then it must be 4 integers long.\n *\n * Note: an IV is not required or used in ECB mode.\n *\n * For GCM-mode, the IV must be given as a binary-encoded string of bytes or\n * a byte buffer. The number of bytes should be 12 (96 bits) as recommended\n * by NIST SP-800-38D but another length may be given.\n *\n * @param options the options to use:\n * iv the initialization vector to use as a binary-encoded string of\n * bytes, null to reuse the last ciphered block from a previous\n * update() (this \"residue\" method is for legacy support only).\n * additionalData additional authentication data as a binary-encoded\n * string of bytes, for 'GCM' mode, (default: none).\n * tagLength desired length of authentication tag, in bits, for\n * 'GCM' mode (0-128, default: 128).\n * tag the authentication tag to check if decrypting, as a\n * binary-encoded string of bytes.\n * output the output the buffer to write to, null to create one.\n */\nBlockCipher.prototype.start = function(options) {\n options = options || {};\n var opts = {};\n for(var key in options) {\n opts[key] = options[key];\n }\n opts.decrypt = this._decrypt;\n this._finish = false;\n this._input = forge.util.createBuffer();\n this.output = options.output || forge.util.createBuffer();\n this.mode.start(opts);\n};\n\n/**\n * Updates the next block according to the cipher mode.\n *\n * @param input the buffer to read from.\n */\nBlockCipher.prototype.update = function(input) {\n if(input) {\n // input given, so empty it into the input buffer\n this._input.putBuffer(input);\n }\n\n // do cipher operation until it needs more input and not finished\n while(!this._op.call(this.mode, this._input, this.output, this._finish) &&\n !this._finish) {}\n\n // free consumed memory from input buffer\n this._input.compact();\n};\n\n/**\n * Finishes encrypting or decrypting.\n *\n * @param pad a padding function to use in CBC mode, null for default,\n * signature(blockSize, buffer, decrypt).\n *\n * @return true if successful, false on error.\n */\nBlockCipher.prototype.finish = function(pad) {\n // backwards-compatibility w/deprecated padding API\n // Note: will overwrite padding functions even after another start() call\n if(pad && (this.mode.name === 'ECB' || this.mode.name === 'CBC')) {\n this.mode.pad = function(input) {\n return pad(this.blockSize, input, false);\n };\n this.mode.unpad = function(output) {\n return pad(this.blockSize, output, true);\n };\n }\n\n // build options for padding and afterFinish functions\n var options = {};\n options.decrypt = this._decrypt;\n\n // get # of bytes that won't fill a block\n options.overflow = this._input.length() % this.blockSize;\n\n if(!this._decrypt && this.mode.pad) {\n if(!this.mode.pad(this._input, options)) {\n return false;\n }\n }\n\n // do final update\n this._finish = true;\n this.update();\n\n if(this._decrypt && this.mode.unpad) {\n if(!this.mode.unpad(this.output, options)) {\n return false;\n }\n }\n\n if(this.mode.afterFinish) {\n if(!this.mode.afterFinish(this.output, options)) {\n return false;\n }\n }\n\n return true;\n};\n","/**\n * Supported cipher modes.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\nforge.cipher = forge.cipher || {};\n\n// supported cipher modes\nvar modes = module.exports = forge.cipher.modes = forge.cipher.modes || {};\n\n/** Electronic codebook (ECB) (Don't use this; it's not secure) **/\n\nmodes.ecb = function(options) {\n options = options || {};\n this.name = 'ECB';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = new Array(this._ints);\n this._outBlock = new Array(this._ints);\n};\n\nmodes.ecb.prototype.start = function(options) {};\n\nmodes.ecb.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n if(input.length() < this.blockSize && !(finish && input.length() > 0)) {\n return true;\n }\n\n // get next block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32();\n }\n\n // encrypt block\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // write output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i]);\n }\n};\n\nmodes.ecb.prototype.decrypt = function(input, output, finish) {\n // not enough input to decrypt\n if(input.length() < this.blockSize && !(finish && input.length() > 0)) {\n return true;\n }\n\n // get next block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32();\n }\n\n // decrypt block\n this.cipher.decrypt(this._inBlock, this._outBlock);\n\n // write output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i]);\n }\n};\n\nmodes.ecb.prototype.pad = function(input, options) {\n // add PKCS#7 padding to block (each pad byte is the\n // value of the number of pad bytes)\n var padding = (input.length() === this.blockSize ?\n this.blockSize : (this.blockSize - input.length()));\n input.fillWithByte(padding, padding);\n return true;\n};\n\nmodes.ecb.prototype.unpad = function(output, options) {\n // check for error: input data not a multiple of blockSize\n if(options.overflow > 0) {\n return false;\n }\n\n // ensure padding byte count is valid\n var len = output.length();\n var count = output.at(len - 1);\n if(count > (this.blockSize << 2)) {\n return false;\n }\n\n // trim off padding bytes\n output.truncate(count);\n return true;\n};\n\n/** Cipher-block Chaining (CBC) **/\n\nmodes.cbc = function(options) {\n options = options || {};\n this.name = 'CBC';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = new Array(this._ints);\n this._outBlock = new Array(this._ints);\n};\n\nmodes.cbc.prototype.start = function(options) {\n // Note: legacy support for using IV residue (has security flaws)\n // if IV is null, reuse block from previous processing\n if(options.iv === null) {\n // must have a previous block\n if(!this._prev) {\n throw new Error('Invalid IV parameter.');\n }\n this._iv = this._prev.slice(0);\n } else if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n } else {\n // save IV as \"previous\" block\n this._iv = transformIV(options.iv, this.blockSize);\n this._prev = this._iv.slice(0);\n }\n};\n\nmodes.cbc.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n if(input.length() < this.blockSize && !(finish && input.length() > 0)) {\n return true;\n }\n\n // get next block\n // CBC XOR's IV (or previous block) with plaintext\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = this._prev[i] ^ input.getInt32();\n }\n\n // encrypt block\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // write output, save previous block\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i]);\n }\n this._prev = this._outBlock;\n};\n\nmodes.cbc.prototype.decrypt = function(input, output, finish) {\n // not enough input to decrypt\n if(input.length() < this.blockSize && !(finish && input.length() > 0)) {\n return true;\n }\n\n // get next block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32();\n }\n\n // decrypt block\n this.cipher.decrypt(this._inBlock, this._outBlock);\n\n // write output, save previous ciphered block\n // CBC XOR's IV (or previous block) with ciphertext\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._prev[i] ^ this._outBlock[i]);\n }\n this._prev = this._inBlock.slice(0);\n};\n\nmodes.cbc.prototype.pad = function(input, options) {\n // add PKCS#7 padding to block (each pad byte is the\n // value of the number of pad bytes)\n var padding = (input.length() === this.blockSize ?\n this.blockSize : (this.blockSize - input.length()));\n input.fillWithByte(padding, padding);\n return true;\n};\n\nmodes.cbc.prototype.unpad = function(output, options) {\n // check for error: input data not a multiple of blockSize\n if(options.overflow > 0) {\n return false;\n }\n\n // ensure padding byte count is valid\n var len = output.length();\n var count = output.at(len - 1);\n if(count > (this.blockSize << 2)) {\n return false;\n }\n\n // trim off padding bytes\n output.truncate(count);\n return true;\n};\n\n/** Cipher feedback (CFB) **/\n\nmodes.cfb = function(options) {\n options = options || {};\n this.name = 'CFB';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = null;\n this._outBlock = new Array(this._ints);\n this._partialBlock = new Array(this._ints);\n this._partialOutput = forge.util.createBuffer();\n this._partialBytes = 0;\n};\n\nmodes.cfb.prototype.start = function(options) {\n if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n }\n // use IV as first input\n this._iv = transformIV(options.iv, this.blockSize);\n this._inBlock = this._iv.slice(0);\n this._partialBytes = 0;\n};\n\nmodes.cfb.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n var inputLength = input.length();\n if(inputLength === 0) {\n return true;\n }\n\n // encrypt block\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output, write input as output\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32() ^ this._outBlock[i];\n output.putInt32(this._inBlock[i]);\n }\n return;\n }\n\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output, write input as partial output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialBlock[i] = input.getInt32() ^ this._outBlock[i];\n this._partialOutput.putInt32(this._partialBlock[i]);\n }\n\n if(partialBytes > 0) {\n // block still incomplete, restore input buffer\n input.read -= this.blockSize;\n } else {\n // block complete, update input block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = this._partialBlock[i];\n }\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n};\n\nmodes.cfb.prototype.decrypt = function(input, output, finish) {\n // not enough input to decrypt\n var inputLength = input.length();\n if(inputLength === 0) {\n return true;\n }\n\n // encrypt block (CFB always uses encryption mode)\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output, write input as output\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = input.getInt32();\n output.putInt32(this._inBlock[i] ^ this._outBlock[i]);\n }\n return;\n }\n\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output, write input as partial output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialBlock[i] = input.getInt32();\n this._partialOutput.putInt32(this._partialBlock[i] ^ this._outBlock[i]);\n }\n\n if(partialBytes > 0) {\n // block still incomplete, restore input buffer\n input.read -= this.blockSize;\n } else {\n // block complete, update input block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = this._partialBlock[i];\n }\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n};\n\n/** Output feedback (OFB) **/\n\nmodes.ofb = function(options) {\n options = options || {};\n this.name = 'OFB';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = null;\n this._outBlock = new Array(this._ints);\n this._partialOutput = forge.util.createBuffer();\n this._partialBytes = 0;\n};\n\nmodes.ofb.prototype.start = function(options) {\n if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n }\n // use IV as first input\n this._iv = transformIV(options.iv, this.blockSize);\n this._inBlock = this._iv.slice(0);\n this._partialBytes = 0;\n};\n\nmodes.ofb.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n var inputLength = input.length();\n if(input.length() === 0) {\n return true;\n }\n\n // encrypt block (OFB always uses encryption mode)\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output and update next input\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(input.getInt32() ^ this._outBlock[i]);\n this._inBlock[i] = this._outBlock[i];\n }\n return;\n }\n\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);\n }\n\n if(partialBytes > 0) {\n // block still incomplete, restore input buffer\n input.read -= this.blockSize;\n } else {\n // block complete, update input block\n for(var i = 0; i < this._ints; ++i) {\n this._inBlock[i] = this._outBlock[i];\n }\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n};\n\nmodes.ofb.prototype.decrypt = modes.ofb.prototype.encrypt;\n\n/** Counter (CTR) **/\n\nmodes.ctr = function(options) {\n options = options || {};\n this.name = 'CTR';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = null;\n this._outBlock = new Array(this._ints);\n this._partialOutput = forge.util.createBuffer();\n this._partialBytes = 0;\n};\n\nmodes.ctr.prototype.start = function(options) {\n if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n }\n // use IV as first input\n this._iv = transformIV(options.iv, this.blockSize);\n this._inBlock = this._iv.slice(0);\n this._partialBytes = 0;\n};\n\nmodes.ctr.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n var inputLength = input.length();\n if(inputLength === 0) {\n return true;\n }\n\n // encrypt block (CTR always uses encryption mode)\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(input.getInt32() ^ this._outBlock[i]);\n }\n } else {\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);\n }\n\n if(partialBytes > 0) {\n // block still incomplete, restore input buffer\n input.read -= this.blockSize;\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n }\n\n // block complete, increment counter (input block)\n inc32(this._inBlock);\n};\n\nmodes.ctr.prototype.decrypt = modes.ctr.prototype.encrypt;\n\n/** Galois/Counter Mode (GCM) **/\n\nmodes.gcm = function(options) {\n options = options || {};\n this.name = 'GCM';\n this.cipher = options.cipher;\n this.blockSize = options.blockSize || 16;\n this._ints = this.blockSize / 4;\n this._inBlock = new Array(this._ints);\n this._outBlock = new Array(this._ints);\n this._partialOutput = forge.util.createBuffer();\n this._partialBytes = 0;\n\n // R is actually this value concatenated with 120 more zero bits, but\n // we only XOR against R so the other zeros have no effect -- we just\n // apply this value to the first integer in a block\n this._R = 0xE1000000;\n};\n\nmodes.gcm.prototype.start = function(options) {\n if(!('iv' in options)) {\n throw new Error('Invalid IV parameter.');\n }\n // ensure IV is a byte buffer\n var iv = forge.util.createBuffer(options.iv);\n\n // no ciphered data processed yet\n this._cipherLength = 0;\n\n // default additional data is none\n var additionalData;\n if('additionalData' in options) {\n additionalData = forge.util.createBuffer(options.additionalData);\n } else {\n additionalData = forge.util.createBuffer();\n }\n\n // default tag length is 128 bits\n if('tagLength' in options) {\n this._tagLength = options.tagLength;\n } else {\n this._tagLength = 128;\n }\n\n // if tag is given, ensure tag matches tag length\n this._tag = null;\n if(options.decrypt) {\n // save tag to check later\n this._tag = forge.util.createBuffer(options.tag).getBytes();\n if(this._tag.length !== (this._tagLength / 8)) {\n throw new Error('Authentication tag does not match tag length.');\n }\n }\n\n // create tmp storage for hash calculation\n this._hashBlock = new Array(this._ints);\n\n // no tag generated yet\n this.tag = null;\n\n // generate hash subkey\n // (apply block cipher to \"zero\" block)\n this._hashSubkey = new Array(this._ints);\n this.cipher.encrypt([0, 0, 0, 0], this._hashSubkey);\n\n // generate table M\n // use 4-bit tables (32 component decomposition of a 16 byte value)\n // 8-bit tables take more space and are known to have security\n // vulnerabilities (in native implementations)\n this.componentBits = 4;\n this._m = this.generateHashTable(this._hashSubkey, this.componentBits);\n\n // Note: support IV length different from 96 bits? (only supporting\n // 96 bits is recommended by NIST SP-800-38D)\n // generate J_0\n var ivLength = iv.length();\n if(ivLength === 12) {\n // 96-bit IV\n this._j0 = [iv.getInt32(), iv.getInt32(), iv.getInt32(), 1];\n } else {\n // IV is NOT 96-bits\n this._j0 = [0, 0, 0, 0];\n while(iv.length() > 0) {\n this._j0 = this.ghash(\n this._hashSubkey, this._j0,\n [iv.getInt32(), iv.getInt32(), iv.getInt32(), iv.getInt32()]);\n }\n this._j0 = this.ghash(\n this._hashSubkey, this._j0, [0, 0].concat(from64To32(ivLength * 8)));\n }\n\n // generate ICB (initial counter block)\n this._inBlock = this._j0.slice(0);\n inc32(this._inBlock);\n this._partialBytes = 0;\n\n // consume authentication data\n additionalData = forge.util.createBuffer(additionalData);\n // save additional data length as a BE 64-bit number\n this._aDataLength = from64To32(additionalData.length() * 8);\n // pad additional data to 128 bit (16 byte) block size\n var overflow = additionalData.length() % this.blockSize;\n if(overflow) {\n additionalData.fillWithByte(0, this.blockSize - overflow);\n }\n this._s = [0, 0, 0, 0];\n while(additionalData.length() > 0) {\n this._s = this.ghash(this._hashSubkey, this._s, [\n additionalData.getInt32(),\n additionalData.getInt32(),\n additionalData.getInt32(),\n additionalData.getInt32()\n ]);\n }\n};\n\nmodes.gcm.prototype.encrypt = function(input, output, finish) {\n // not enough input to encrypt\n var inputLength = input.length();\n if(inputLength === 0) {\n return true;\n }\n\n // encrypt block\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // handle full block\n if(this._partialBytes === 0 && inputLength >= this.blockSize) {\n // XOR input with output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i] ^= input.getInt32());\n }\n this._cipherLength += this.blockSize;\n } else {\n // handle partial block\n var partialBytes = (this.blockSize - inputLength) % this.blockSize;\n if(partialBytes > 0) {\n partialBytes = this.blockSize - partialBytes;\n }\n\n // XOR input with output\n this._partialOutput.clear();\n for(var i = 0; i < this._ints; ++i) {\n this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);\n }\n\n if(partialBytes <= 0 || finish) {\n // handle overflow prior to hashing\n if(finish) {\n // get block overflow\n var overflow = inputLength % this.blockSize;\n this._cipherLength += overflow;\n // truncate for hash function\n this._partialOutput.truncate(this.blockSize - overflow);\n } else {\n this._cipherLength += this.blockSize;\n }\n\n // get output block for hashing\n for(var i = 0; i < this._ints; ++i) {\n this._outBlock[i] = this._partialOutput.getInt32();\n }\n this._partialOutput.read -= this.blockSize;\n }\n\n // skip any previous partial bytes\n if(this._partialBytes > 0) {\n this._partialOutput.getBytes(this._partialBytes);\n }\n\n if(partialBytes > 0 && !finish) {\n // block still incomplete, restore input buffer, get partial output,\n // and return early\n input.read -= this.blockSize;\n output.putBytes(this._partialOutput.getBytes(\n partialBytes - this._partialBytes));\n this._partialBytes = partialBytes;\n return true;\n }\n\n output.putBytes(this._partialOutput.getBytes(\n inputLength - this._partialBytes));\n this._partialBytes = 0;\n }\n\n // update hash block S\n this._s = this.ghash(this._hashSubkey, this._s, this._outBlock);\n\n // increment counter (input block)\n inc32(this._inBlock);\n};\n\nmodes.gcm.prototype.decrypt = function(input, output, finish) {\n // not enough input to decrypt\n var inputLength = input.length();\n if(inputLength < this.blockSize && !(finish && inputLength > 0)) {\n return true;\n }\n\n // encrypt block (GCM always uses encryption mode)\n this.cipher.encrypt(this._inBlock, this._outBlock);\n\n // increment counter (input block)\n inc32(this._inBlock);\n\n // update hash block S\n this._hashBlock[0] = input.getInt32();\n this._hashBlock[1] = input.getInt32();\n this._hashBlock[2] = input.getInt32();\n this._hashBlock[3] = input.getInt32();\n this._s = this.ghash(this._hashSubkey, this._s, this._hashBlock);\n\n // XOR hash input with output\n for(var i = 0; i < this._ints; ++i) {\n output.putInt32(this._outBlock[i] ^ this._hashBlock[i]);\n }\n\n // increment cipher data length\n if(inputLength < this.blockSize) {\n this._cipherLength += inputLength % this.blockSize;\n } else {\n this._cipherLength += this.blockSize;\n }\n};\n\nmodes.gcm.prototype.afterFinish = function(output, options) {\n var rval = true;\n\n // handle overflow\n if(options.decrypt && options.overflow) {\n output.truncate(this.blockSize - options.overflow);\n }\n\n // handle authentication tag\n this.tag = forge.util.createBuffer();\n\n // concatenate additional data length with cipher length\n var lengths = this._aDataLength.concat(from64To32(this._cipherLength * 8));\n\n // include lengths in hash\n this._s = this.ghash(this._hashSubkey, this._s, lengths);\n\n // do GCTR(J_0, S)\n var tag = [];\n this.cipher.encrypt(this._j0, tag);\n for(var i = 0; i < this._ints; ++i) {\n this.tag.putInt32(this._s[i] ^ tag[i]);\n }\n\n // trim tag to length\n this.tag.truncate(this.tag.length() % (this._tagLength / 8));\n\n // check authentication tag\n if(options.decrypt && this.tag.bytes() !== this._tag) {\n rval = false;\n }\n\n return rval;\n};\n\n/**\n * See NIST SP-800-38D 6.3 (Algorithm 1). This function performs Galois\n * field multiplication. The field, GF(2^128), is defined by the polynomial:\n *\n * x^128 + x^7 + x^2 + x + 1\n *\n * Which is represented in little-endian binary form as: 11100001 (0xe1). When\n * the value of a coefficient is 1, a bit is set. The value R, is the\n * concatenation of this value and 120 zero bits, yielding a 128-bit value\n * which matches the block size.\n *\n * This function will multiply two elements (vectors of bytes), X and Y, in\n * the field GF(2^128). The result is initialized to zero. For each bit of\n * X (out of 128), x_i, if x_i is set, then the result is multiplied (XOR'd)\n * by the current value of Y. For each bit, the value of Y will be raised by\n * a power of x (multiplied by the polynomial x). This can be achieved by\n * shifting Y once to the right. If the current value of Y, prior to being\n * multiplied by x, has 0 as its LSB, then it is a 127th degree polynomial.\n * Otherwise, we must divide by R after shifting to find the remainder.\n *\n * @param x the first block to multiply by the second.\n * @param y the second block to multiply by the first.\n *\n * @return the block result of the multiplication.\n */\nmodes.gcm.prototype.multiply = function(x, y) {\n var z_i = [0, 0, 0, 0];\n var v_i = y.slice(0);\n\n // calculate Z_128 (block has 128 bits)\n for(var i = 0; i < 128; ++i) {\n // if x_i is 0, Z_{i+1} = Z_i (unchanged)\n // else Z_{i+1} = Z_i ^ V_i\n // get x_i by finding 32-bit int position, then left shift 1 by remainder\n var x_i = x[(i / 32) | 0] & (1 << (31 - i % 32));\n if(x_i) {\n z_i[0] ^= v_i[0];\n z_i[1] ^= v_i[1];\n z_i[2] ^= v_i[2];\n z_i[3] ^= v_i[3];\n }\n\n // if LSB(V_i) is 1, V_i = V_i >> 1\n // else V_i = (V_i >> 1) ^ R\n this.pow(v_i, v_i);\n }\n\n return z_i;\n};\n\nmodes.gcm.prototype.pow = function(x, out) {\n // if LSB(x) is 1, x = x >>> 1\n // else x = (x >>> 1) ^ R\n var lsb = x[3] & 1;\n\n // always do x >>> 1:\n // starting with the rightmost integer, shift each integer to the right\n // one bit, pulling in the bit from the integer to the left as its top\n // most bit (do this for the last 3 integers)\n for(var i = 3; i > 0; --i) {\n out[i] = (x[i] >>> 1) | ((x[i - 1] & 1) << 31);\n }\n // shift the first integer normally\n out[0] = x[0] >>> 1;\n\n // if lsb was not set, then polynomial had a degree of 127 and doesn't\n // need to divided; otherwise, XOR with R to find the remainder; we only\n // need to XOR the first integer since R technically ends w/120 zero bits\n if(lsb) {\n out[0] ^= this._R;\n }\n};\n\nmodes.gcm.prototype.tableMultiply = function(x) {\n // assumes 4-bit tables are used\n var z = [0, 0, 0, 0];\n for(var i = 0; i < 32; ++i) {\n var idx = (i / 8) | 0;\n var x_i = (x[idx] >>> ((7 - (i % 8)) * 4)) & 0xF;\n var ah = this._m[i][x_i];\n z[0] ^= ah[0];\n z[1] ^= ah[1];\n z[2] ^= ah[2];\n z[3] ^= ah[3];\n }\n return z;\n};\n\n/**\n * A continuing version of the GHASH algorithm that operates on a single\n * block. The hash block, last hash value (Ym) and the new block to hash\n * are given.\n *\n * @param h the hash block.\n * @param y the previous value for Ym, use [0, 0, 0, 0] for a new hash.\n * @param x the block to hash.\n *\n * @return the hashed value (Ym).\n */\nmodes.gcm.prototype.ghash = function(h, y, x) {\n y[0] ^= x[0];\n y[1] ^= x[1];\n y[2] ^= x[2];\n y[3] ^= x[3];\n return this.tableMultiply(y);\n //return this.multiply(y, h);\n};\n\n/**\n * Precomputes a table for multiplying against the hash subkey. This\n * mechanism provides a substantial speed increase over multiplication\n * performed without a table. The table-based multiplication this table is\n * for solves X * H by multiplying each component of X by H and then\n * composing the results together using XOR.\n *\n * This function can be used to generate tables with different bit sizes\n * for the components, however, this implementation assumes there are\n * 32 components of X (which is a 16 byte vector), therefore each component\n * takes 4-bits (so the table is constructed with bits=4).\n *\n * @param h the hash subkey.\n * @param bits the bit size for a component.\n */\nmodes.gcm.prototype.generateHashTable = function(h, bits) {\n // TODO: There are further optimizations that would use only the\n // first table M_0 (or some variant) along with a remainder table;\n // this can be explored in the future\n var multiplier = 8 / bits;\n var perInt = 4 * multiplier;\n var size = 16 * multiplier;\n var m = new Array(size);\n for(var i = 0; i < size; ++i) {\n var tmp = [0, 0, 0, 0];\n var idx = (i / perInt) | 0;\n var shft = ((perInt - 1 - (i % perInt)) * bits);\n tmp[idx] = (1 << (bits - 1)) << shft;\n m[i] = this.generateSubHashTable(this.multiply(tmp, h), bits);\n }\n return m;\n};\n\n/**\n * Generates a table for multiplying against the hash subkey for one\n * particular component (out of all possible component values).\n *\n * @param mid the pre-multiplied value for the middle key of the table.\n * @param bits the bit size for a component.\n */\nmodes.gcm.prototype.generateSubHashTable = function(mid, bits) {\n // compute the table quickly by minimizing the number of\n // POW operations -- they only need to be performed for powers of 2,\n // all other entries can be composed from those powers using XOR\n var size = 1 << bits;\n var half = size >>> 1;\n var m = new Array(size);\n m[half] = mid.slice(0);\n var i = half >>> 1;\n while(i > 0) {\n // raise m0[2 * i] and store in m0[i]\n this.pow(m[2 * i], m[i] = []);\n i >>= 1;\n }\n i = 2;\n while(i < half) {\n for(var j = 1; j < i; ++j) {\n var m_i = m[i];\n var m_j = m[j];\n m[i + j] = [\n m_i[0] ^ m_j[0],\n m_i[1] ^ m_j[1],\n m_i[2] ^ m_j[2],\n m_i[3] ^ m_j[3]\n ];\n }\n i *= 2;\n }\n m[0] = [0, 0, 0, 0];\n /* Note: We could avoid storing these by doing composition during multiply\n calculate top half using composition by speed is preferred. */\n for(i = half + 1; i < size; ++i) {\n var c = m[i ^ half];\n m[i] = [mid[0] ^ c[0], mid[1] ^ c[1], mid[2] ^ c[2], mid[3] ^ c[3]];\n }\n return m;\n};\n\n/** Utility functions */\n\nfunction transformIV(iv, blockSize) {\n if(typeof iv === 'string') {\n // convert iv string into byte buffer\n iv = forge.util.createBuffer(iv);\n }\n\n if(forge.util.isArray(iv) && iv.length > 4) {\n // convert iv byte array into byte buffer\n var tmp = iv;\n iv = forge.util.createBuffer();\n for(var i = 0; i < tmp.length; ++i) {\n iv.putByte(tmp[i]);\n }\n }\n\n if(iv.length() < blockSize) {\n throw new Error(\n 'Invalid IV length; got ' + iv.length() +\n ' bytes and expected ' + blockSize + ' bytes.');\n }\n\n if(!forge.util.isArray(iv)) {\n // convert iv byte buffer into 32-bit integer array\n var ints = [];\n var blocks = blockSize / 4;\n for(var i = 0; i < blocks; ++i) {\n ints.push(iv.getInt32());\n }\n iv = ints;\n }\n\n return iv;\n}\n\nfunction inc32(block) {\n // increment last 32 bits of block only\n block[block.length - 1] = (block[block.length - 1] + 1) & 0xFFFFFFFF;\n}\n\nfunction from64To32(num) {\n // convert 64-bit number to two BE Int32s\n return [(num / 0x100000000) | 0, num & 0xFFFFFFFF];\n}\n","/**\n * Debugging support for web applications.\n *\n * @author David I. Lehn \n *\n * Copyright 2008-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\n\n/* DEBUG API */\nmodule.exports = forge.debug = forge.debug || {};\n\n// Private storage for debugging.\n// Useful to expose data that is otherwise unviewable behind closures.\n// NOTE: remember that this can hold references to data and cause leaks!\n// format is \"forge._debug.. = data\"\n// Example:\n// (function() {\n// var cat = 'forge.test.Test'; // debugging category\n// var sState = {...}; // local state\n// forge.debug.set(cat, 'sState', sState);\n// })();\nforge.debug.storage = {};\n\n/**\n * Gets debug data. Omit name for all cat data Omit name and cat for\n * all data.\n *\n * @param cat name of debugging category.\n * @param name name of data to get (optional).\n * @return object with requested debug data or undefined.\n */\nforge.debug.get = function(cat, name) {\n var rval;\n if(typeof(cat) === 'undefined') {\n rval = forge.debug.storage;\n } else if(cat in forge.debug.storage) {\n if(typeof(name) === 'undefined') {\n rval = forge.debug.storage[cat];\n } else {\n rval = forge.debug.storage[cat][name];\n }\n }\n return rval;\n};\n\n/**\n * Sets debug data.\n *\n * @param cat name of debugging category.\n * @param name name of data to set.\n * @param data data to set.\n */\nforge.debug.set = function(cat, name, data) {\n if(!(cat in forge.debug.storage)) {\n forge.debug.storage[cat] = {};\n }\n forge.debug.storage[cat][name] = data;\n};\n\n/**\n * Clears debug data. Omit name for all cat data. Omit name and cat for\n * all data.\n *\n * @param cat name of debugging category.\n * @param name name of data to clear or omit to clear entire category.\n */\nforge.debug.clear = function(cat, name) {\n if(typeof(cat) === 'undefined') {\n forge.debug.storage = {};\n } else if(cat in forge.debug.storage) {\n if(typeof(name) === 'undefined') {\n delete forge.debug.storage[cat];\n } else {\n delete forge.debug.storage[cat][name];\n }\n }\n};\n","/**\n * DES (Data Encryption Standard) implementation.\n *\n * This implementation supports DES as well as 3DES-EDE in ECB and CBC mode.\n * It is based on the BSD-licensed implementation by Paul Tero:\n *\n * Paul Tero, July 2001\n * http://www.tero.co.uk/des/\n *\n * Optimised for performance with large blocks by\n * Michael Hayworth, November 2001\n * http://www.netdealing.com\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * @author Stefan Siegl\n * @author Dave Longley\n *\n * Copyright (c) 2012 Stefan Siegl \n * Copyright (c) 2012-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./cipher');\nrequire('./cipherModes');\nrequire('./util');\n\n/* DES API */\nmodule.exports = forge.des = forge.des || {};\n\n/**\n * Deprecated. Instead, use:\n *\n * var cipher = forge.cipher.createCipher('DES-', key);\n * cipher.start({iv: iv});\n *\n * Creates an DES cipher object to encrypt data using the given symmetric key.\n * The output will be stored in the 'output' member of the returned cipher.\n *\n * The key and iv may be given as binary-encoded strings of bytes or\n * byte buffers.\n *\n * @param key the symmetric key to use (64 or 192 bits).\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n * @param mode the cipher mode to use (default: 'CBC' if IV is\n * given, 'ECB' if null).\n *\n * @return the cipher.\n */\nforge.des.startEncrypting = function(key, iv, output, mode) {\n var cipher = _createCipher({\n key: key,\n output: output,\n decrypt: false,\n mode: mode || (iv === null ? 'ECB' : 'CBC')\n });\n cipher.start(iv);\n return cipher;\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var cipher = forge.cipher.createCipher('DES-', key);\n *\n * Creates an DES cipher object to encrypt data using the given symmetric key.\n *\n * The key may be given as a binary-encoded string of bytes or a byte buffer.\n *\n * @param key the symmetric key to use (64 or 192 bits).\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.des.createEncryptionCipher = function(key, mode) {\n return _createCipher({\n key: key,\n output: null,\n decrypt: false,\n mode: mode\n });\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var decipher = forge.cipher.createDecipher('DES-', key);\n * decipher.start({iv: iv});\n *\n * Creates an DES cipher object to decrypt data using the given symmetric key.\n * The output will be stored in the 'output' member of the returned cipher.\n *\n * The key and iv may be given as binary-encoded strings of bytes or\n * byte buffers.\n *\n * @param key the symmetric key to use (64 or 192 bits).\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n * @param mode the cipher mode to use (default: 'CBC' if IV is\n * given, 'ECB' if null).\n *\n * @return the cipher.\n */\nforge.des.startDecrypting = function(key, iv, output, mode) {\n var cipher = _createCipher({\n key: key,\n output: output,\n decrypt: true,\n mode: mode || (iv === null ? 'ECB' : 'CBC')\n });\n cipher.start(iv);\n return cipher;\n};\n\n/**\n * Deprecated. Instead, use:\n *\n * var decipher = forge.cipher.createDecipher('DES-', key);\n *\n * Creates an DES cipher object to decrypt data using the given symmetric key.\n *\n * The key may be given as a binary-encoded string of bytes or a byte buffer.\n *\n * @param key the symmetric key to use (64 or 192 bits).\n * @param mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nforge.des.createDecryptionCipher = function(key, mode) {\n return _createCipher({\n key: key,\n output: null,\n decrypt: true,\n mode: mode\n });\n};\n\n/**\n * Creates a new DES cipher algorithm object.\n *\n * @param name the name of the algorithm.\n * @param mode the mode factory function.\n *\n * @return the DES algorithm object.\n */\nforge.des.Algorithm = function(name, mode) {\n var self = this;\n self.name = name;\n self.mode = new mode({\n blockSize: 8,\n cipher: {\n encrypt: function(inBlock, outBlock) {\n return _updateBlock(self._keys, inBlock, outBlock, false);\n },\n decrypt: function(inBlock, outBlock) {\n return _updateBlock(self._keys, inBlock, outBlock, true);\n }\n }\n });\n self._init = false;\n};\n\n/**\n * Initializes this DES algorithm by expanding its key.\n *\n * @param options the options to use.\n * key the key to use with this algorithm.\n * decrypt true if the algorithm should be initialized for decryption,\n * false for encryption.\n */\nforge.des.Algorithm.prototype.initialize = function(options) {\n if(this._init) {\n return;\n }\n\n var key = forge.util.createBuffer(options.key);\n if(this.name.indexOf('3DES') === 0) {\n if(key.length() !== 24) {\n throw new Error('Invalid Triple-DES key size: ' + key.length() * 8);\n }\n }\n\n // do key expansion to 16 or 48 subkeys (single or triple DES)\n this._keys = _createKeys(key);\n this._init = true;\n};\n\n/** Register DES algorithms **/\n\nregisterAlgorithm('DES-ECB', forge.cipher.modes.ecb);\nregisterAlgorithm('DES-CBC', forge.cipher.modes.cbc);\nregisterAlgorithm('DES-CFB', forge.cipher.modes.cfb);\nregisterAlgorithm('DES-OFB', forge.cipher.modes.ofb);\nregisterAlgorithm('DES-CTR', forge.cipher.modes.ctr);\n\nregisterAlgorithm('3DES-ECB', forge.cipher.modes.ecb);\nregisterAlgorithm('3DES-CBC', forge.cipher.modes.cbc);\nregisterAlgorithm('3DES-CFB', forge.cipher.modes.cfb);\nregisterAlgorithm('3DES-OFB', forge.cipher.modes.ofb);\nregisterAlgorithm('3DES-CTR', forge.cipher.modes.ctr);\n\nfunction registerAlgorithm(name, mode) {\n var factory = function() {\n return new forge.des.Algorithm(name, mode);\n };\n forge.cipher.registerAlgorithm(name, factory);\n}\n\n/** DES implementation **/\n\nvar spfunction1 = [0x1010400,0,0x10000,0x1010404,0x1010004,0x10404,0x4,0x10000,0x400,0x1010400,0x1010404,0x400,0x1000404,0x1010004,0x1000000,0x4,0x404,0x1000400,0x1000400,0x10400,0x10400,0x1010000,0x1010000,0x1000404,0x10004,0x1000004,0x1000004,0x10004,0,0x404,0x10404,0x1000000,0x10000,0x1010404,0x4,0x1010000,0x1010400,0x1000000,0x1000000,0x400,0x1010004,0x10000,0x10400,0x1000004,0x400,0x4,0x1000404,0x10404,0x1010404,0x10004,0x1010000,0x1000404,0x1000004,0x404,0x10404,0x1010400,0x404,0x1000400,0x1000400,0,0x10004,0x10400,0,0x1010004];\nvar spfunction2 = [-0x7fef7fe0,-0x7fff8000,0x8000,0x108020,0x100000,0x20,-0x7fefffe0,-0x7fff7fe0,-0x7fffffe0,-0x7fef7fe0,-0x7fef8000,-0x80000000,-0x7fff8000,0x100000,0x20,-0x7fefffe0,0x108000,0x100020,-0x7fff7fe0,0,-0x80000000,0x8000,0x108020,-0x7ff00000,0x100020,-0x7fffffe0,0,0x108000,0x8020,-0x7fef8000,-0x7ff00000,0x8020,0,0x108020,-0x7fefffe0,0x100000,-0x7fff7fe0,-0x7ff00000,-0x7fef8000,0x8000,-0x7ff00000,-0x7fff8000,0x20,-0x7fef7fe0,0x108020,0x20,0x8000,-0x80000000,0x8020,-0x7fef8000,0x100000,-0x7fffffe0,0x100020,-0x7fff7fe0,-0x7fffffe0,0x100020,0x108000,0,-0x7fff8000,0x8020,-0x80000000,-0x7fefffe0,-0x7fef7fe0,0x108000];\nvar spfunction3 = [0x208,0x8020200,0,0x8020008,0x8000200,0,0x20208,0x8000200,0x20008,0x8000008,0x8000008,0x20000,0x8020208,0x20008,0x8020000,0x208,0x8000000,0x8,0x8020200,0x200,0x20200,0x8020000,0x8020008,0x20208,0x8000208,0x20200,0x20000,0x8000208,0x8,0x8020208,0x200,0x8000000,0x8020200,0x8000000,0x20008,0x208,0x20000,0x8020200,0x8000200,0,0x200,0x20008,0x8020208,0x8000200,0x8000008,0x200,0,0x8020008,0x8000208,0x20000,0x8000000,0x8020208,0x8,0x20208,0x20200,0x8000008,0x8020000,0x8000208,0x208,0x8020000,0x20208,0x8,0x8020008,0x20200];\nvar spfunction4 = [0x802001,0x2081,0x2081,0x80,0x802080,0x800081,0x800001,0x2001,0,0x802000,0x802000,0x802081,0x81,0,0x800080,0x800001,0x1,0x2000,0x800000,0x802001,0x80,0x800000,0x2001,0x2080,0x800081,0x1,0x2080,0x800080,0x2000,0x802080,0x802081,0x81,0x800080,0x800001,0x802000,0x802081,0x81,0,0,0x802000,0x2080,0x800080,0x800081,0x1,0x802001,0x2081,0x2081,0x80,0x802081,0x81,0x1,0x2000,0x800001,0x2001,0x802080,0x800081,0x2001,0x2080,0x800000,0x802001,0x80,0x800000,0x2000,0x802080];\nvar spfunction5 = [0x100,0x2080100,0x2080000,0x42000100,0x80000,0x100,0x40000000,0x2080000,0x40080100,0x80000,0x2000100,0x40080100,0x42000100,0x42080000,0x80100,0x40000000,0x2000000,0x40080000,0x40080000,0,0x40000100,0x42080100,0x42080100,0x2000100,0x42080000,0x40000100,0,0x42000000,0x2080100,0x2000000,0x42000000,0x80100,0x80000,0x42000100,0x100,0x2000000,0x40000000,0x2080000,0x42000100,0x40080100,0x2000100,0x40000000,0x42080000,0x2080100,0x40080100,0x100,0x2000000,0x42080000,0x42080100,0x80100,0x42000000,0x42080100,0x2080000,0,0x40080000,0x42000000,0x80100,0x2000100,0x40000100,0x80000,0,0x40080000,0x2080100,0x40000100];\nvar spfunction6 = [0x20000010,0x20400000,0x4000,0x20404010,0x20400000,0x10,0x20404010,0x400000,0x20004000,0x404010,0x400000,0x20000010,0x400010,0x20004000,0x20000000,0x4010,0,0x400010,0x20004010,0x4000,0x404000,0x20004010,0x10,0x20400010,0x20400010,0,0x404010,0x20404000,0x4010,0x404000,0x20404000,0x20000000,0x20004000,0x10,0x20400010,0x404000,0x20404010,0x400000,0x4010,0x20000010,0x400000,0x20004000,0x20000000,0x4010,0x20000010,0x20404010,0x404000,0x20400000,0x404010,0x20404000,0,0x20400010,0x10,0x4000,0x20400000,0x404010,0x4000,0x400010,0x20004010,0,0x20404000,0x20000000,0x400010,0x20004010];\nvar spfunction7 = [0x200000,0x4200002,0x4000802,0,0x800,0x4000802,0x200802,0x4200800,0x4200802,0x200000,0,0x4000002,0x2,0x4000000,0x4200002,0x802,0x4000800,0x200802,0x200002,0x4000800,0x4000002,0x4200000,0x4200800,0x200002,0x4200000,0x800,0x802,0x4200802,0x200800,0x2,0x4000000,0x200800,0x4000000,0x200800,0x200000,0x4000802,0x4000802,0x4200002,0x4200002,0x2,0x200002,0x4000000,0x4000800,0x200000,0x4200800,0x802,0x200802,0x4200800,0x802,0x4000002,0x4200802,0x4200000,0x200800,0,0x2,0x4200802,0,0x200802,0x4200000,0x800,0x4000002,0x4000800,0x800,0x200002];\nvar spfunction8 = [0x10001040,0x1000,0x40000,0x10041040,0x10000000,0x10001040,0x40,0x10000000,0x40040,0x10040000,0x10041040,0x41000,0x10041000,0x41040,0x1000,0x40,0x10040000,0x10000040,0x10001000,0x1040,0x41000,0x40040,0x10040040,0x10041000,0x1040,0,0,0x10040040,0x10000040,0x10001000,0x41040,0x40000,0x41040,0x40000,0x10041000,0x1000,0x40,0x10040040,0x1000,0x41040,0x10001000,0x40,0x10000040,0x10040000,0x10040040,0x10000000,0x40000,0x10001040,0,0x10041040,0x40040,0x10000040,0x10040000,0x10001000,0x10001040,0,0x10041040,0x41000,0x41000,0x1040,0x1040,0x40040,0x10000000,0x10041000];\n\n/**\n * Create necessary sub keys.\n *\n * @param key the 64-bit or 192-bit key.\n *\n * @return the expanded keys.\n */\nfunction _createKeys(key) {\n var pc2bytes0 = [0,0x4,0x20000000,0x20000004,0x10000,0x10004,0x20010000,0x20010004,0x200,0x204,0x20000200,0x20000204,0x10200,0x10204,0x20010200,0x20010204],\n pc2bytes1 = [0,0x1,0x100000,0x100001,0x4000000,0x4000001,0x4100000,0x4100001,0x100,0x101,0x100100,0x100101,0x4000100,0x4000101,0x4100100,0x4100101],\n pc2bytes2 = [0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808,0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808],\n pc2bytes3 = [0,0x200000,0x8000000,0x8200000,0x2000,0x202000,0x8002000,0x8202000,0x20000,0x220000,0x8020000,0x8220000,0x22000,0x222000,0x8022000,0x8222000],\n pc2bytes4 = [0,0x40000,0x10,0x40010,0,0x40000,0x10,0x40010,0x1000,0x41000,0x1010,0x41010,0x1000,0x41000,0x1010,0x41010],\n pc2bytes5 = [0,0x400,0x20,0x420,0,0x400,0x20,0x420,0x2000000,0x2000400,0x2000020,0x2000420,0x2000000,0x2000400,0x2000020,0x2000420],\n pc2bytes6 = [0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002,0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002],\n pc2bytes7 = [0,0x10000,0x800,0x10800,0x20000000,0x20010000,0x20000800,0x20010800,0x20000,0x30000,0x20800,0x30800,0x20020000,0x20030000,0x20020800,0x20030800],\n pc2bytes8 = [0,0x40000,0,0x40000,0x2,0x40002,0x2,0x40002,0x2000000,0x2040000,0x2000000,0x2040000,0x2000002,0x2040002,0x2000002,0x2040002],\n pc2bytes9 = [0,0x10000000,0x8,0x10000008,0,0x10000000,0x8,0x10000008,0x400,0x10000400,0x408,0x10000408,0x400,0x10000400,0x408,0x10000408],\n pc2bytes10 = [0,0x20,0,0x20,0x100000,0x100020,0x100000,0x100020,0x2000,0x2020,0x2000,0x2020,0x102000,0x102020,0x102000,0x102020],\n pc2bytes11 = [0,0x1000000,0x200,0x1000200,0x200000,0x1200000,0x200200,0x1200200,0x4000000,0x5000000,0x4000200,0x5000200,0x4200000,0x5200000,0x4200200,0x5200200],\n pc2bytes12 = [0,0x1000,0x8000000,0x8001000,0x80000,0x81000,0x8080000,0x8081000,0x10,0x1010,0x8000010,0x8001010,0x80010,0x81010,0x8080010,0x8081010],\n pc2bytes13 = [0,0x4,0x100,0x104,0,0x4,0x100,0x104,0x1,0x5,0x101,0x105,0x1,0x5,0x101,0x105];\n\n // how many iterations (1 for des, 3 for triple des)\n // changed by Paul 16/6/2007 to use Triple DES for 9+ byte keys\n var iterations = key.length() > 8 ? 3 : 1;\n\n // stores the return keys\n var keys = [];\n\n // now define the left shifts which need to be done\n var shifts = [0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0];\n\n var n = 0, tmp;\n for(var j = 0; j < iterations; j++) {\n var left = key.getInt32();\n var right = key.getInt32();\n\n tmp = ((left >>> 4) ^ right) & 0x0f0f0f0f;\n right ^= tmp;\n left ^= (tmp << 4);\n\n tmp = ((right >>> -16) ^ left) & 0x0000ffff;\n left ^= tmp;\n right ^= (tmp << -16);\n\n tmp = ((left >>> 2) ^ right) & 0x33333333;\n right ^= tmp;\n left ^= (tmp << 2);\n\n tmp = ((right >>> -16) ^ left) & 0x0000ffff;\n left ^= tmp;\n right ^= (tmp << -16);\n\n tmp = ((left >>> 1) ^ right) & 0x55555555;\n right ^= tmp;\n left ^= (tmp << 1);\n\n tmp = ((right >>> 8) ^ left) & 0x00ff00ff;\n left ^= tmp;\n right ^= (tmp << 8);\n\n tmp = ((left >>> 1) ^ right) & 0x55555555;\n right ^= tmp;\n left ^= (tmp << 1);\n\n // right needs to be shifted and OR'd with last four bits of left\n tmp = (left << 8) | ((right >>> 20) & 0x000000f0);\n\n // left needs to be put upside down\n left = ((right << 24) | ((right << 8) & 0xff0000) |\n ((right >>> 8) & 0xff00) | ((right >>> 24) & 0xf0));\n right = tmp;\n\n // now go through and perform these shifts on the left and right keys\n for(var i = 0; i < shifts.length; ++i) {\n //shift the keys either one or two bits to the left\n if(shifts[i]) {\n left = (left << 2) | (left >>> 26);\n right = (right << 2) | (right >>> 26);\n } else {\n left = (left << 1) | (left >>> 27);\n right = (right << 1) | (right >>> 27);\n }\n left &= -0xf;\n right &= -0xf;\n\n // now apply PC-2, in such a way that E is easier when encrypting or\n // decrypting this conversion will look like PC-2 except only the last 6\n // bits of each byte are used rather than 48 consecutive bits and the\n // order of lines will be according to how the S selection functions will\n // be applied: S2, S4, S6, S8, S1, S3, S5, S7\n var lefttmp = (\n pc2bytes0[left >>> 28] | pc2bytes1[(left >>> 24) & 0xf] |\n pc2bytes2[(left >>> 20) & 0xf] | pc2bytes3[(left >>> 16) & 0xf] |\n pc2bytes4[(left >>> 12) & 0xf] | pc2bytes5[(left >>> 8) & 0xf] |\n pc2bytes6[(left >>> 4) & 0xf]);\n var righttmp = (\n pc2bytes7[right >>> 28] | pc2bytes8[(right >>> 24) & 0xf] |\n pc2bytes9[(right >>> 20) & 0xf] | pc2bytes10[(right >>> 16) & 0xf] |\n pc2bytes11[(right >>> 12) & 0xf] | pc2bytes12[(right >>> 8) & 0xf] |\n pc2bytes13[(right >>> 4) & 0xf]);\n tmp = ((righttmp >>> 16) ^ lefttmp) & 0x0000ffff;\n keys[n++] = lefttmp ^ tmp;\n keys[n++] = righttmp ^ (tmp << 16);\n }\n }\n\n return keys;\n}\n\n/**\n * Updates a single block (1 byte) using DES. The update will either\n * encrypt or decrypt the block.\n *\n * @param keys the expanded keys.\n * @param input the input block (an array of 32-bit words).\n * @param output the updated output block.\n * @param decrypt true to decrypt the block, false to encrypt it.\n */\nfunction _updateBlock(keys, input, output, decrypt) {\n // set up loops for single or triple DES\n var iterations = keys.length === 32 ? 3 : 9;\n var looping;\n if(iterations === 3) {\n looping = decrypt ? [30, -2, -2] : [0, 32, 2];\n } else {\n looping = (decrypt ?\n [94, 62, -2, 32, 64, 2, 30, -2, -2] :\n [0, 32, 2, 62, 30, -2, 64, 96, 2]);\n }\n\n var tmp;\n\n var left = input[0];\n var right = input[1];\n\n // first each 64 bit chunk of the message must be permuted according to IP\n tmp = ((left >>> 4) ^ right) & 0x0f0f0f0f;\n right ^= tmp;\n left ^= (tmp << 4);\n\n tmp = ((left >>> 16) ^ right) & 0x0000ffff;\n right ^= tmp;\n left ^= (tmp << 16);\n\n tmp = ((right >>> 2) ^ left) & 0x33333333;\n left ^= tmp;\n right ^= (tmp << 2);\n\n tmp = ((right >>> 8) ^ left) & 0x00ff00ff;\n left ^= tmp;\n right ^= (tmp << 8);\n\n tmp = ((left >>> 1) ^ right) & 0x55555555;\n right ^= tmp;\n left ^= (tmp << 1);\n\n // rotate left 1 bit\n left = ((left << 1) | (left >>> 31));\n right = ((right << 1) | (right >>> 31));\n\n for(var j = 0; j < iterations; j += 3) {\n var endloop = looping[j + 1];\n var loopinc = looping[j + 2];\n\n // now go through and perform the encryption or decryption\n for(var i = looping[j]; i != endloop; i += loopinc) {\n var right1 = right ^ keys[i];\n var right2 = ((right >>> 4) | (right << 28)) ^ keys[i + 1];\n\n // passing these bytes through the S selection functions\n tmp = left;\n left = right;\n right = tmp ^ (\n spfunction2[(right1 >>> 24) & 0x3f] |\n spfunction4[(right1 >>> 16) & 0x3f] |\n spfunction6[(right1 >>> 8) & 0x3f] |\n spfunction8[right1 & 0x3f] |\n spfunction1[(right2 >>> 24) & 0x3f] |\n spfunction3[(right2 >>> 16) & 0x3f] |\n spfunction5[(right2 >>> 8) & 0x3f] |\n spfunction7[right2 & 0x3f]);\n }\n // unreverse left and right\n tmp = left;\n left = right;\n right = tmp;\n }\n\n // rotate right 1 bit\n left = ((left >>> 1) | (left << 31));\n right = ((right >>> 1) | (right << 31));\n\n // now perform IP-1, which is IP in the opposite direction\n tmp = ((left >>> 1) ^ right) & 0x55555555;\n right ^= tmp;\n left ^= (tmp << 1);\n\n tmp = ((right >>> 8) ^ left) & 0x00ff00ff;\n left ^= tmp;\n right ^= (tmp << 8);\n\n tmp = ((right >>> 2) ^ left) & 0x33333333;\n left ^= tmp;\n right ^= (tmp << 2);\n\n tmp = ((left >>> 16) ^ right) & 0x0000ffff;\n right ^= tmp;\n left ^= (tmp << 16);\n\n tmp = ((left >>> 4) ^ right) & 0x0f0f0f0f;\n right ^= tmp;\n left ^= (tmp << 4);\n\n output[0] = left;\n output[1] = right;\n}\n\n/**\n * Deprecated. Instead, use:\n *\n * forge.cipher.createCipher('DES-', key);\n * forge.cipher.createDecipher('DES-', key);\n *\n * Creates a deprecated DES cipher object. This object's mode will default to\n * CBC (cipher-block-chaining).\n *\n * The key may be given as a binary-encoded string of bytes or a byte buffer.\n *\n * @param options the options to use.\n * key the symmetric key to use (64 or 192 bits).\n * output the buffer to write to.\n * decrypt true for decryption, false for encryption.\n * mode the cipher mode to use (default: 'CBC').\n *\n * @return the cipher.\n */\nfunction _createCipher(options) {\n options = options || {};\n var mode = (options.mode || 'CBC').toUpperCase();\n var algorithm = 'DES-' + mode;\n\n var cipher;\n if(options.decrypt) {\n cipher = forge.cipher.createDecipher(algorithm, options.key);\n } else {\n cipher = forge.cipher.createCipher(algorithm, options.key);\n }\n\n // backwards compatible start API\n var start = cipher.start;\n cipher.start = function(iv, options) {\n // backwards compatibility: support second arg as output buffer\n var output = null;\n if(options instanceof forge.util.ByteBuffer) {\n output = options;\n options = {};\n }\n options = options || {};\n options.output = output;\n options.iv = iv;\n start.call(cipher, options);\n };\n\n return cipher;\n}\n","/**\n * JavaScript implementation of Ed25519.\n *\n * Copyright (c) 2017-2019 Digital Bazaar, Inc.\n *\n * This implementation is based on the most excellent TweetNaCl which is\n * in the public domain. Many thanks to its contributors:\n *\n * https://github.com/dchest/tweetnacl-js\n */\nvar forge = require('./forge');\nrequire('./jsbn');\nrequire('./random');\nrequire('./sha512');\nrequire('./util');\nvar asn1Validator = require('./asn1-validator');\nvar publicKeyValidator = asn1Validator.publicKeyValidator;\nvar privateKeyValidator = asn1Validator.privateKeyValidator;\n\nif(typeof BigInteger === 'undefined') {\n var BigInteger = forge.jsbn.BigInteger;\n}\n\nvar ByteBuffer = forge.util.ByteBuffer;\nvar NativeBuffer = typeof Buffer === 'undefined' ? Uint8Array : Buffer;\n\n/*\n * Ed25519 algorithms, see RFC 8032:\n * https://tools.ietf.org/html/rfc8032\n */\nforge.pki = forge.pki || {};\nmodule.exports = forge.pki.ed25519 = forge.ed25519 = forge.ed25519 || {};\nvar ed25519 = forge.ed25519;\n\ned25519.constants = {};\ned25519.constants.PUBLIC_KEY_BYTE_LENGTH = 32;\ned25519.constants.PRIVATE_KEY_BYTE_LENGTH = 64;\ned25519.constants.SEED_BYTE_LENGTH = 32;\ned25519.constants.SIGN_BYTE_LENGTH = 64;\ned25519.constants.HASH_BYTE_LENGTH = 64;\n\ned25519.generateKeyPair = function(options) {\n options = options || {};\n var seed = options.seed;\n if(seed === undefined) {\n // generate seed\n seed = forge.random.getBytesSync(ed25519.constants.SEED_BYTE_LENGTH);\n } else if(typeof seed === 'string') {\n if(seed.length !== ed25519.constants.SEED_BYTE_LENGTH) {\n throw new TypeError(\n '\"seed\" must be ' + ed25519.constants.SEED_BYTE_LENGTH +\n ' bytes in length.');\n }\n } else if(!(seed instanceof Uint8Array)) {\n throw new TypeError(\n '\"seed\" must be a node.js Buffer, Uint8Array, or a binary string.');\n }\n\n seed = messageToNativeBuffer({message: seed, encoding: 'binary'});\n\n var pk = new NativeBuffer(ed25519.constants.PUBLIC_KEY_BYTE_LENGTH);\n var sk = new NativeBuffer(ed25519.constants.PRIVATE_KEY_BYTE_LENGTH);\n for(var i = 0; i < 32; ++i) {\n sk[i] = seed[i];\n }\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, privateKey: sk};\n};\n\n/**\n * Converts a private key from a RFC8410 ASN.1 encoding.\n *\n * @param obj - The asn1 representation of a private key.\n *\n * @returns {Object} keyInfo - The key information.\n * @returns {Buffer|Uint8Array} keyInfo.privateKeyBytes - 32 private key bytes.\n */\ned25519.privateKeyFromAsn1 = function(obj) {\n var capture = {};\n var errors = [];\n var valid = forge.asn1.validate(obj, privateKeyValidator, capture, errors);\n if(!valid) {\n var error = new Error('Invalid Key.');\n error.errors = errors;\n throw error;\n }\n var oid = forge.asn1.derToOid(capture.privateKeyOid);\n var ed25519Oid = forge.oids.EdDSA25519;\n if(oid !== ed25519Oid) {\n throw new Error('Invalid OID \"' + oid + '\"; OID must be \"' +\n ed25519Oid + '\".');\n }\n var privateKey = capture.privateKey;\n // manually extract the private key bytes from nested octet string, see FIXME:\n // https://github.com/digitalbazaar/forge/blob/master/lib/asn1.js#L542\n var privateKeyBytes = messageToNativeBuffer({\n message: forge.asn1.fromDer(privateKey).value,\n encoding: 'binary'\n });\n // TODO: RFC8410 specifies a format for encoding the public key bytes along\n // with the private key bytes. `publicKeyBytes` can be returned in the\n // future. https://tools.ietf.org/html/rfc8410#section-10.3\n return {privateKeyBytes: privateKeyBytes};\n};\n\n/**\n * Converts a public key from a RFC8410 ASN.1 encoding.\n *\n * @param obj - The asn1 representation of a public key.\n *\n * @return {Buffer|Uint8Array} - 32 public key bytes.\n */\ned25519.publicKeyFromAsn1 = function(obj) {\n // get SubjectPublicKeyInfo\n var capture = {};\n var errors = [];\n var valid = forge.asn1.validate(obj, publicKeyValidator, capture, errors);\n if(!valid) {\n var error = new Error('Invalid Key.');\n error.errors = errors;\n throw error;\n }\n var oid = forge.asn1.derToOid(capture.publicKeyOid);\n var ed25519Oid = forge.oids.EdDSA25519;\n if(oid !== ed25519Oid) {\n throw new Error('Invalid OID \"' + oid + '\"; OID must be \"' +\n ed25519Oid + '\".');\n }\n var publicKeyBytes = capture.ed25519PublicKey;\n if(publicKeyBytes.length !== ed25519.constants.PUBLIC_KEY_BYTE_LENGTH) {\n throw new Error('Key length is invalid.');\n }\n return messageToNativeBuffer({\n message: publicKeyBytes,\n encoding: 'binary'\n });\n};\n\ned25519.publicKeyFromPrivateKey = function(options) {\n options = options || {};\n var privateKey = messageToNativeBuffer({\n message: options.privateKey, encoding: 'binary'\n });\n if(privateKey.length !== ed25519.constants.PRIVATE_KEY_BYTE_LENGTH) {\n throw new TypeError(\n '\"options.privateKey\" must have a byte length of ' +\n ed25519.constants.PRIVATE_KEY_BYTE_LENGTH);\n }\n\n var pk = new NativeBuffer(ed25519.constants.PUBLIC_KEY_BYTE_LENGTH);\n for(var i = 0; i < pk.length; ++i) {\n pk[i] = privateKey[32 + i];\n }\n return pk;\n};\n\ned25519.sign = function(options) {\n options = options || {};\n var msg = messageToNativeBuffer(options);\n var privateKey = messageToNativeBuffer({\n message: options.privateKey,\n encoding: 'binary'\n });\n if(privateKey.length === ed25519.constants.SEED_BYTE_LENGTH) {\n var keyPair = ed25519.generateKeyPair({seed: privateKey});\n privateKey = keyPair.privateKey;\n } else if(privateKey.length !== ed25519.constants.PRIVATE_KEY_BYTE_LENGTH) {\n throw new TypeError(\n '\"options.privateKey\" must have a byte length of ' +\n ed25519.constants.SEED_BYTE_LENGTH + ' or ' +\n ed25519.constants.PRIVATE_KEY_BYTE_LENGTH);\n }\n\n var signedMsg = new NativeBuffer(\n ed25519.constants.SIGN_BYTE_LENGTH + msg.length);\n crypto_sign(signedMsg, msg, msg.length, privateKey);\n\n var sig = new NativeBuffer(ed25519.constants.SIGN_BYTE_LENGTH);\n for(var i = 0; i < sig.length; ++i) {\n sig[i] = signedMsg[i];\n }\n return sig;\n};\n\ned25519.verify = function(options) {\n options = options || {};\n var msg = messageToNativeBuffer(options);\n if(options.signature === undefined) {\n throw new TypeError(\n '\"options.signature\" must be a node.js Buffer, a Uint8Array, a forge ' +\n 'ByteBuffer, or a binary string.');\n }\n var sig = messageToNativeBuffer({\n message: options.signature,\n encoding: 'binary'\n });\n if(sig.length !== ed25519.constants.SIGN_BYTE_LENGTH) {\n throw new TypeError(\n '\"options.signature\" must have a byte length of ' +\n ed25519.constants.SIGN_BYTE_LENGTH);\n }\n var publicKey = messageToNativeBuffer({\n message: options.publicKey,\n encoding: 'binary'\n });\n if(publicKey.length !== ed25519.constants.PUBLIC_KEY_BYTE_LENGTH) {\n throw new TypeError(\n '\"options.publicKey\" must have a byte length of ' +\n ed25519.constants.PUBLIC_KEY_BYTE_LENGTH);\n }\n\n var sm = new NativeBuffer(ed25519.constants.SIGN_BYTE_LENGTH + msg.length);\n var m = new NativeBuffer(ed25519.constants.SIGN_BYTE_LENGTH + msg.length);\n var i;\n for(i = 0; i < ed25519.constants.SIGN_BYTE_LENGTH; ++i) {\n sm[i] = sig[i];\n }\n for(i = 0; i < msg.length; ++i) {\n sm[i + ed25519.constants.SIGN_BYTE_LENGTH] = msg[i];\n }\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nfunction messageToNativeBuffer(options) {\n var message = options.message;\n if(message instanceof Uint8Array || message instanceof NativeBuffer) {\n return message;\n }\n\n var encoding = options.encoding;\n if(message === undefined) {\n if(options.md) {\n // TODO: more rigorous validation that `md` is a MessageDigest\n message = options.md.digest().getBytes();\n encoding = 'binary';\n } else {\n throw new TypeError('\"options.message\" or \"options.md\" not specified.');\n }\n }\n\n if(typeof message === 'string' && !encoding) {\n throw new TypeError('\"options.encoding\" must be \"binary\" or \"utf8\".');\n }\n\n if(typeof message === 'string') {\n if(typeof Buffer !== 'undefined') {\n return Buffer.from(message, encoding);\n }\n message = new ByteBuffer(message, encoding);\n } else if(!(message instanceof ByteBuffer)) {\n throw new TypeError(\n '\"options.message\" must be a node.js Buffer, a Uint8Array, a forge ' +\n 'ByteBuffer, or a string with \"options.encoding\" specifying its ' +\n 'encoding.');\n }\n\n // convert to native buffer\n var buffer = new NativeBuffer(message.length());\n for(var i = 0; i < buffer.length; ++i) {\n buffer[i] = message.at(i);\n }\n return buffer;\n}\n\nvar gf0 = gf();\nvar gf1 = gf([1]);\nvar D = gf([\n 0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070,\n 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]);\nvar D2 = gf([\n 0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0,\n 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]);\nvar X = gf([\n 0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c,\n 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]);\nvar Y = gf([\n 0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666,\n 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]);\nvar L = new Float64Array([\n 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,\n 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\nvar I = gf([\n 0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43,\n 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\n// TODO: update forge buffer implementation to use `Buffer` or `Uint8Array`,\n// whichever is available, to improve performance\nfunction sha512(msg, msgLen) {\n // Note: `out` and `msg` are NativeBuffer\n var md = forge.md.sha512.create();\n var buffer = new ByteBuffer(msg);\n md.update(buffer.getBytes(msgLen), 'binary');\n var hash = md.digest().getBytes();\n if(typeof Buffer !== 'undefined') {\n return Buffer.from(hash, 'binary');\n }\n var out = new NativeBuffer(ed25519.constants.HASH_BYTE_LENGTH);\n for(var i = 0; i < 64; ++i) {\n out[i] = hash.charCodeAt(i);\n }\n return out;\n}\n\nfunction crypto_sign_keypair(pk, sk) {\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n var d = sha512(sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for(i = 0; i < 32; ++i) {\n sk[i + 32] = pk[i];\n }\n return 0;\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n var d = sha512(sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for(i = 0; i < n; ++i) {\n sm[64 + i] = m[i];\n }\n for(i = 0; i < 32; ++i) {\n sm[32 + i] = d[32 + i];\n }\n\n var r = sha512(sm.subarray(32), n + 32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for(i = 32; i < 64; ++i) {\n sm[i] = sk[i];\n }\n var h = sha512(sm, n + 64);\n reduce(h);\n\n for(i = 32; i < 64; ++i) {\n x[i] = 0;\n }\n for(i = 0; i < 32; ++i) {\n x[i] = r[i];\n }\n for(i = 0; i < 32; ++i) {\n for(j = 0; j < 32; j++) {\n x[i + j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i, mlen;\n var t = new NativeBuffer(32);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n mlen = -1;\n if(n < 64) {\n return -1;\n }\n\n if(unpackneg(q, pk)) {\n return -1;\n }\n\n for(i = 0; i < n; ++i) {\n m[i] = sm[i];\n }\n for(i = 0; i < 32; ++i) {\n m[i + 32] = pk[i];\n }\n var h = sha512(m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if(crypto_verify_32(sm, 0, t, 0)) {\n for(i = 0; i < n; ++i) {\n m[i] = 0;\n }\n return -1;\n }\n\n for(i = 0; i < n; ++i) {\n m[i] = sm[i + 64];\n }\n mlen = n;\n return mlen;\n}\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for(i = 63; i >= 32; --i) {\n carry = 0;\n for(j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = (x[j] + 128) >> 8;\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for(j = 0; j < 32; ++j) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for(j = 0; j < 32; ++j) {\n x[j] -= carry * L[j];\n }\n for(i = 0; i < 32; ++i) {\n x[i + 1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64);\n for(var i = 0; i < 64; ++i) {\n x[i] = r[i];\n r[i] = 0;\n }\n modL(r, x);\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n for(var i = 0; i < 4; ++i) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for(i = 0; i < 16; ++i) {\n t[i] = n[i];\n }\n car25519(t);\n car25519(t);\n car25519(t);\n for(j = 0; j < 2; ++j) {\n m[0] = t[0] - 0xffed;\n for(i = 1; i < 15; ++i) {\n m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1);\n b = (m[15] >> 16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1 - b);\n }\n for (i = 0; i < 16; i++) {\n o[2 * i] = t[i] & 0xff;\n o[2 * i + 1] = t[i] >> 8;\n }\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if(neq25519(chk, num)) {\n M(r[0], r[0], I);\n }\n\n S(chk, r[0]);\n M(chk, chk, den);\n if(neq25519(chk, num)) {\n return -1;\n }\n\n if(par25519(r[0]) === (p[31] >> 7)) {\n Z(r[0], gf0, r[0]);\n }\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for(i = 0; i < 16; ++i) {\n o[i] = n[2 * i] + (n[2 * i + 1] << 8);\n }\n o[15] &= 0x7fff;\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for(a = 0; a < 16; ++a) {\n c[a] = i[a];\n }\n for(a = 250; a >= 0; --a) {\n S(c, c);\n if(a !== 1) {\n M(c, c, i);\n }\n }\n for(a = 0; a < 16; ++a) {\n o[a] = c[a];\n }\n}\n\nfunction neq25519(a, b) {\n var c = new NativeBuffer(32);\n var d = new NativeBuffer(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x, xi, y, yi, 32);\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i, d = 0;\n for(i = 0; i < n; ++i) {\n d |= x[xi + i] ^ y[yi + i];\n }\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction par25519(a) {\n var d = new NativeBuffer(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for(i = 255; i >= 0; --i) {\n b = (s[(i / 8)|0] >> (i & 7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction set25519(r, a) {\n var i;\n for(i = 0; i < 16; i++) {\n r[i] = a[i] | 0;\n }\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for(a = 0; a < 16; ++a) {\n c[a] = i[a];\n }\n for(a = 253; a >= 0; --a) {\n S(c, c);\n if(a !== 2 && a !== 4) {\n M(c, c, i);\n }\n }\n for(a = 0; a < 16; ++a) {\n o[a] = c[a];\n }\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for(i = 0; i < 16; ++i) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c - 1 + 37 * (c - 1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b - 1);\n for(var i = 0; i < 16; ++i) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction gf(init) {\n var i, r = new Float64Array(16);\n if(init) {\n for(i = 0; i < init.length; ++i) {\n r[i] = init[i];\n }\n }\n return r;\n}\n\nfunction A(o, a, b) {\n for(var i = 0; i < 16; ++i) {\n o[i] = a[i] + b[i];\n }\n}\n\nfunction Z(o, a, b) {\n for(var i = 0; i < 16; ++i) {\n o[i] = a[i] - b[i];\n }\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n","/**\n * Node.js module for Forge.\n *\n * @author Dave Longley\n *\n * Copyright 2011-2016 Digital Bazaar, Inc.\n */\nmodule.exports = {\n // default options\n options: {\n usePureJavaScript: false\n }\n};\n","/**\n * Hash-based Message Authentication Code implementation. Requires a message\n * digest object that can be obtained, for example, from forge.md.sha1 or\n * forge.md.md5.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2012 Digital Bazaar, Inc. All rights reserved.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\n/* HMAC API */\nvar hmac = module.exports = forge.hmac = forge.hmac || {};\n\n/**\n * Creates an HMAC object that uses the given message digest object.\n *\n * @return an HMAC object.\n */\nhmac.create = function() {\n // the hmac key to use\n var _key = null;\n\n // the message digest to use\n var _md = null;\n\n // the inner padding\n var _ipadding = null;\n\n // the outer padding\n var _opadding = null;\n\n // hmac context\n var ctx = {};\n\n /**\n * Starts or restarts the HMAC with the given key and message digest.\n *\n * @param md the message digest to use, null to reuse the previous one,\n * a string to use builtin 'sha1', 'md5', 'sha256'.\n * @param key the key to use as a string, array of bytes, byte buffer,\n * or null to reuse the previous key.\n */\n ctx.start = function(md, key) {\n if(md !== null) {\n if(typeof md === 'string') {\n // create builtin message digest\n md = md.toLowerCase();\n if(md in forge.md.algorithms) {\n _md = forge.md.algorithms[md].create();\n } else {\n throw new Error('Unknown hash algorithm \"' + md + '\"');\n }\n } else {\n // store message digest\n _md = md;\n }\n }\n\n if(key === null) {\n // reuse previous key\n key = _key;\n } else {\n if(typeof key === 'string') {\n // convert string into byte buffer\n key = forge.util.createBuffer(key);\n } else if(forge.util.isArray(key)) {\n // convert byte array into byte buffer\n var tmp = key;\n key = forge.util.createBuffer();\n for(var i = 0; i < tmp.length; ++i) {\n key.putByte(tmp[i]);\n }\n }\n\n // if key is longer than blocksize, hash it\n var keylen = key.length();\n if(keylen > _md.blockLength) {\n _md.start();\n _md.update(key.bytes());\n key = _md.digest();\n }\n\n // mix key into inner and outer padding\n // ipadding = [0x36 * blocksize] ^ key\n // opadding = [0x5C * blocksize] ^ key\n _ipadding = forge.util.createBuffer();\n _opadding = forge.util.createBuffer();\n keylen = key.length();\n for(var i = 0; i < keylen; ++i) {\n var tmp = key.at(i);\n _ipadding.putByte(0x36 ^ tmp);\n _opadding.putByte(0x5C ^ tmp);\n }\n\n // if key is shorter than blocksize, add additional padding\n if(keylen < _md.blockLength) {\n var tmp = _md.blockLength - keylen;\n for(var i = 0; i < tmp; ++i) {\n _ipadding.putByte(0x36);\n _opadding.putByte(0x5C);\n }\n }\n _key = key;\n _ipadding = _ipadding.bytes();\n _opadding = _opadding.bytes();\n }\n\n // digest is done like so: hash(opadding | hash(ipadding | message))\n\n // prepare to do inner hash\n // hash(ipadding | message)\n _md.start();\n _md.update(_ipadding);\n };\n\n /**\n * Updates the HMAC with the given message bytes.\n *\n * @param bytes the bytes to update with.\n */\n ctx.update = function(bytes) {\n _md.update(bytes);\n };\n\n /**\n * Produces the Message Authentication Code (MAC).\n *\n * @return a byte buffer containing the digest value.\n */\n ctx.getMac = function() {\n // digest is done like so: hash(opadding | hash(ipadding | message))\n // here we do the outer hashing\n var inner = _md.digest().bytes();\n _md.start();\n _md.update(_opadding);\n _md.update(inner);\n return _md.digest();\n };\n // alias for getMac\n ctx.digest = ctx.getMac;\n\n return ctx;\n};\n","/**\n * Node.js module for Forge.\n *\n * @author Dave Longley\n *\n * Copyright 2011-2016 Digital Bazaar, Inc.\n */\nmodule.exports = require('./forge');\nrequire('./aes');\nrequire('./aesCipherSuites');\nrequire('./asn1');\nrequire('./cipher');\nrequire('./debug');\nrequire('./des');\nrequire('./ed25519');\nrequire('./hmac');\nrequire('./kem');\nrequire('./log');\nrequire('./md.all');\nrequire('./mgf1');\nrequire('./pbkdf2');\nrequire('./pem');\nrequire('./pkcs1');\nrequire('./pkcs12');\nrequire('./pkcs7');\nrequire('./pki');\nrequire('./prime');\nrequire('./prng');\nrequire('./pss');\nrequire('./random');\nrequire('./rc2');\nrequire('./ssh');\nrequire('./task');\nrequire('./tls');\nrequire('./util');\n","// Copyright (c) 2005 Tom Wu\n// All Rights Reserved.\n// See \"LICENSE\" for details.\n\n// Basic JavaScript BN library - subset useful for RSA encryption.\n\n/*\nLicensing (LICENSE)\n-------------------\n\nThis software is covered under the following copyright:\n*/\n/*\n * Copyright (c) 2003-2005 Tom Wu\n * All Rights Reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS-IS\" AND WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY\n * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.\n *\n * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,\n * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER\n * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF\n * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT\n * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n *\n * In addition, the following condition applies:\n *\n * All redistributions must retain an intact copy of this copyright notice\n * and disclaimer.\n */\n/*\nAddress all questions regarding this license to:\n\n Tom Wu\n tjw@cs.Stanford.EDU\n*/\nvar forge = require('./forge');\n\nmodule.exports = forge.jsbn = forge.jsbn || {};\n\n// Bits per digit\nvar dbits;\n\n// JavaScript engine analysis\nvar canary = 0xdeadbeefcafe;\nvar j_lm = ((canary&0xffffff)==0xefcafe);\n\n// (public) Constructor\nfunction BigInteger(a,b,c) {\n this.data = [];\n if(a != null)\n if(\"number\" == typeof a) this.fromNumber(a,b,c);\n else if(b == null && \"string\" != typeof a) this.fromString(a,256);\n else this.fromString(a,b);\n}\nforge.jsbn.BigInteger = BigInteger;\n\n// return new, unset BigInteger\nfunction nbi() { return new BigInteger(null); }\n\n// am: Compute w_j += (x*this_i), propagate carries,\n// c is initial carry, returns final carry.\n// c < 3*dvalue, x < 2*dvalue, this_i < dvalue\n// We need to select the fastest one that works in this environment.\n\n// am1: use a single mult and divide to get the high bits,\n// max digit bits should be 26 because\n// max internal value = 2*dvalue^2-2*dvalue (< 2^53)\nfunction am1(i,x,w,j,c,n) {\n while(--n >= 0) {\n var v = x*this.data[i++]+w.data[j]+c;\n c = Math.floor(v/0x4000000);\n w.data[j++] = v&0x3ffffff;\n }\n return c;\n}\n// am2 avoids a big mult-and-extract completely.\n// Max digit bits should be <= 30 because we do bitwise ops\n// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)\nfunction am2(i,x,w,j,c,n) {\n var xl = x&0x7fff, xh = x>>15;\n while(--n >= 0) {\n var l = this.data[i]&0x7fff;\n var h = this.data[i++]>>15;\n var m = xh*l+h*xl;\n l = xl*l+((m&0x7fff)<<15)+w.data[j]+(c&0x3fffffff);\n c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);\n w.data[j++] = l&0x3fffffff;\n }\n return c;\n}\n// Alternately, set max digit bits to 28 since some\n// browsers slow down when dealing with 32-bit numbers.\nfunction am3(i,x,w,j,c,n) {\n var xl = x&0x3fff, xh = x>>14;\n while(--n >= 0) {\n var l = this.data[i]&0x3fff;\n var h = this.data[i++]>>14;\n var m = xh*l+h*xl;\n l = xl*l+((m&0x3fff)<<14)+w.data[j]+c;\n c = (l>>28)+(m>>14)+xh*h;\n w.data[j++] = l&0xfffffff;\n }\n return c;\n}\n\n// node.js (no browser)\nif(typeof(navigator) === 'undefined')\n{\n BigInteger.prototype.am = am3;\n dbits = 28;\n} else if(j_lm && (navigator.appName == \"Microsoft Internet Explorer\")) {\n BigInteger.prototype.am = am2;\n dbits = 30;\n} else if(j_lm && (navigator.appName != \"Netscape\")) {\n BigInteger.prototype.am = am1;\n dbits = 26;\n} else { // Mozilla/Netscape seems to prefer am3\n BigInteger.prototype.am = am3;\n dbits = 28;\n}\n\nBigInteger.prototype.DB = dbits;\nBigInteger.prototype.DM = ((1<= 0; --i) r.data[i] = this.data[i];\n r.t = this.t;\n r.s = this.s;\n}\n\n// (protected) set from integer value x, -DV <= x < DV\nfunction bnpFromInt(x) {\n this.t = 1;\n this.s = (x<0)?-1:0;\n if(x > 0) this.data[0] = x;\n else if(x < -1) this.data[0] = x+this.DV;\n else this.t = 0;\n}\n\n// return bigint initialized to value\nfunction nbv(i) { var r = nbi(); r.fromInt(i); return r; }\n\n// (protected) set from string and radix\nfunction bnpFromString(s,b) {\n var k;\n if(b == 16) k = 4;\n else if(b == 8) k = 3;\n else if(b == 256) k = 8; // byte array\n else if(b == 2) k = 1;\n else if(b == 32) k = 5;\n else if(b == 4) k = 2;\n else { this.fromRadix(s,b); return; }\n this.t = 0;\n this.s = 0;\n var i = s.length, mi = false, sh = 0;\n while(--i >= 0) {\n var x = (k==8)?s[i]&0xff:intAt(s,i);\n if(x < 0) {\n if(s.charAt(i) == \"-\") mi = true;\n continue;\n }\n mi = false;\n if(sh == 0)\n this.data[this.t++] = x;\n else if(sh+k > this.DB) {\n this.data[this.t-1] |= (x&((1<<(this.DB-sh))-1))<>(this.DB-sh));\n } else\n this.data[this.t-1] |= x<= this.DB) sh -= this.DB;\n }\n if(k == 8 && (s[0]&0x80) != 0) {\n this.s = -1;\n if(sh > 0) this.data[this.t-1] |= ((1<<(this.DB-sh))-1)< 0 && this.data[this.t-1] == c) --this.t;\n}\n\n// (public) return string representation in given radix\nfunction bnToString(b) {\n if(this.s < 0) return \"-\"+this.negate().toString(b);\n var k;\n if(b == 16) k = 4;\n else if(b == 8) k = 3;\n else if(b == 2) k = 1;\n else if(b == 32) k = 5;\n else if(b == 4) k = 2;\n else return this.toRadix(b);\n var km = (1< 0) {\n if(p < this.DB && (d = this.data[i]>>p) > 0) { m = true; r = int2char(d); }\n while(i >= 0) {\n if(p < k) {\n d = (this.data[i]&((1<>(p+=this.DB-k);\n } else {\n d = (this.data[i]>>(p-=k))&km;\n if(p <= 0) { p += this.DB; --i; }\n }\n if(d > 0) m = true;\n if(m) r += int2char(d);\n }\n }\n return m?r:\"0\";\n}\n\n// (public) -this\nfunction bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }\n\n// (public) |this|\nfunction bnAbs() { return (this.s<0)?this.negate():this; }\n\n// (public) return + if this > a, - if this < a, 0 if equal\nfunction bnCompareTo(a) {\n var r = this.s-a.s;\n if(r != 0) return r;\n var i = this.t;\n r = i-a.t;\n if(r != 0) return (this.s<0)?-r:r;\n while(--i >= 0) if((r=this.data[i]-a.data[i]) != 0) return r;\n return 0;\n}\n\n// returns bit length of the integer x\nfunction nbits(x) {\n var r = 1, t;\n if((t=x>>>16) != 0) { x = t; r += 16; }\n if((t=x>>8) != 0) { x = t; r += 8; }\n if((t=x>>4) != 0) { x = t; r += 4; }\n if((t=x>>2) != 0) { x = t; r += 2; }\n if((t=x>>1) != 0) { x = t; r += 1; }\n return r;\n}\n\n// (public) return the number of bits in \"this\"\nfunction bnBitLength() {\n if(this.t <= 0) return 0;\n return this.DB*(this.t-1)+nbits(this.data[this.t-1]^(this.s&this.DM));\n}\n\n// (protected) r = this << n*DB\nfunction bnpDLShiftTo(n,r) {\n var i;\n for(i = this.t-1; i >= 0; --i) r.data[i+n] = this.data[i];\n for(i = n-1; i >= 0; --i) r.data[i] = 0;\n r.t = this.t+n;\n r.s = this.s;\n}\n\n// (protected) r = this >> n*DB\nfunction bnpDRShiftTo(n,r) {\n for(var i = n; i < this.t; ++i) r.data[i-n] = this.data[i];\n r.t = Math.max(this.t-n,0);\n r.s = this.s;\n}\n\n// (protected) r = this << n\nfunction bnpLShiftTo(n,r) {\n var bs = n%this.DB;\n var cbs = this.DB-bs;\n var bm = (1<= 0; --i) {\n r.data[i+ds+1] = (this.data[i]>>cbs)|c;\n c = (this.data[i]&bm)<= 0; --i) r.data[i] = 0;\n r.data[ds] = c;\n r.t = this.t+ds+1;\n r.s = this.s;\n r.clamp();\n}\n\n// (protected) r = this >> n\nfunction bnpRShiftTo(n,r) {\n r.s = this.s;\n var ds = Math.floor(n/this.DB);\n if(ds >= this.t) { r.t = 0; return; }\n var bs = n%this.DB;\n var cbs = this.DB-bs;\n var bm = (1<>bs;\n for(var i = ds+1; i < this.t; ++i) {\n r.data[i-ds-1] |= (this.data[i]&bm)<>bs;\n }\n if(bs > 0) r.data[this.t-ds-1] |= (this.s&bm)<>= this.DB;\n }\n if(a.t < this.t) {\n c -= a.s;\n while(i < this.t) {\n c += this.data[i];\n r.data[i++] = c&this.DM;\n c >>= this.DB;\n }\n c += this.s;\n } else {\n c += this.s;\n while(i < a.t) {\n c -= a.data[i];\n r.data[i++] = c&this.DM;\n c >>= this.DB;\n }\n c -= a.s;\n }\n r.s = (c<0)?-1:0;\n if(c < -1) r.data[i++] = this.DV+c;\n else if(c > 0) r.data[i++] = c;\n r.t = i;\n r.clamp();\n}\n\n// (protected) r = this * a, r != this,a (HAC 14.12)\n// \"this\" should be the larger one if appropriate.\nfunction bnpMultiplyTo(a,r) {\n var x = this.abs(), y = a.abs();\n var i = x.t;\n r.t = i+y.t;\n while(--i >= 0) r.data[i] = 0;\n for(i = 0; i < y.t; ++i) r.data[i+x.t] = x.am(0,y.data[i],r,i,0,x.t);\n r.s = 0;\n r.clamp();\n if(this.s != a.s) BigInteger.ZERO.subTo(r,r);\n}\n\n// (protected) r = this^2, r != this (HAC 14.16)\nfunction bnpSquareTo(r) {\n var x = this.abs();\n var i = r.t = 2*x.t;\n while(--i >= 0) r.data[i] = 0;\n for(i = 0; i < x.t-1; ++i) {\n var c = x.am(i,x.data[i],r,2*i,0,1);\n if((r.data[i+x.t]+=x.am(i+1,2*x.data[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {\n r.data[i+x.t] -= x.DV;\n r.data[i+x.t+1] = 1;\n }\n }\n if(r.t > 0) r.data[r.t-1] += x.am(i,x.data[i],r,2*i,0,1);\n r.s = 0;\n r.clamp();\n}\n\n// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)\n// r != q, this != m. q or r may be null.\nfunction bnpDivRemTo(m,q,r) {\n var pm = m.abs();\n if(pm.t <= 0) return;\n var pt = this.abs();\n if(pt.t < pm.t) {\n if(q != null) q.fromInt(0);\n if(r != null) this.copyTo(r);\n return;\n }\n if(r == null) r = nbi();\n var y = nbi(), ts = this.s, ms = m.s;\n var nsh = this.DB-nbits(pm.data[pm.t-1]);\t// normalize modulus\n if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } else { pm.copyTo(y); pt.copyTo(r); }\n var ys = y.t;\n var y0 = y.data[ys-1];\n if(y0 == 0) return;\n var yt = y0*(1<1)?y.data[ys-2]>>this.F2:0);\n var d1 = this.FV/yt, d2 = (1<= 0) {\n r.data[r.t++] = 1;\n r.subTo(t,r);\n }\n BigInteger.ONE.dlShiftTo(ys,t);\n t.subTo(y,y);\t// \"negative\" y so we can replace sub with am later\n while(y.t < ys) y.data[y.t++] = 0;\n while(--j >= 0) {\n // Estimate quotient digit\n var qd = (r.data[--i]==y0)?this.DM:Math.floor(r.data[i]*d1+(r.data[i-1]+e)*d2);\n if((r.data[i]+=y.am(0,qd,r,j,0,ys)) < qd) {\t// Try it out\n y.dlShiftTo(j,t);\n r.subTo(t,r);\n while(r.data[i] < --qd) r.subTo(t,r);\n }\n }\n if(q != null) {\n r.drShiftTo(ys,q);\n if(ts != ms) BigInteger.ZERO.subTo(q,q);\n }\n r.t = ys;\n r.clamp();\n if(nsh > 0) r.rShiftTo(nsh,r);\t// Denormalize remainder\n if(ts < 0) BigInteger.ZERO.subTo(r,r);\n}\n\n// (public) this mod a\nfunction bnMod(a) {\n var r = nbi();\n this.abs().divRemTo(a,null,r);\n if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);\n return r;\n}\n\n// Modular reduction using \"classic\" algorithm\nfunction Classic(m) { this.m = m; }\nfunction cConvert(x) {\n if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);\n else return x;\n}\nfunction cRevert(x) { return x; }\nfunction cReduce(x) { x.divRemTo(this.m,null,x); }\nfunction cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }\nfunction cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }\n\nClassic.prototype.convert = cConvert;\nClassic.prototype.revert = cRevert;\nClassic.prototype.reduce = cReduce;\nClassic.prototype.mulTo = cMulTo;\nClassic.prototype.sqrTo = cSqrTo;\n\n// (protected) return \"-1/this % 2^DB\"; useful for Mont. reduction\n// justification:\n// xy == 1 (mod m)\n// xy = 1+km\n// xy(2-xy) = (1+km)(1-km)\n// x[y(2-xy)] = 1-k^2m^2\n// x[y(2-xy)] == 1 (mod m^2)\n// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2\n// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.\n// JS multiply \"overflows\" differently from C/C++, so care is needed here.\nfunction bnpInvDigit() {\n if(this.t < 1) return 0;\n var x = this.data[0];\n if((x&1) == 0) return 0;\n var y = x&3;\t\t// y == 1/x mod 2^2\n y = (y*(2-(x&0xf)*y))&0xf;\t// y == 1/x mod 2^4\n y = (y*(2-(x&0xff)*y))&0xff;\t// y == 1/x mod 2^8\n y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff;\t// y == 1/x mod 2^16\n // last step - calculate inverse mod DV directly;\n // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints\n y = (y*(2-x*y%this.DV))%this.DV;\t\t// y == 1/x mod 2^dbits\n // we really want the negative inverse, and -DV < y < DV\n return (y>0)?this.DV-y:-y;\n}\n\n// Montgomery reduction\nfunction Montgomery(m) {\n this.m = m;\n this.mp = m.invDigit();\n this.mpl = this.mp&0x7fff;\n this.mph = this.mp>>15;\n this.um = (1<<(m.DB-15))-1;\n this.mt2 = 2*m.t;\n}\n\n// xR mod m\nfunction montConvert(x) {\n var r = nbi();\n x.abs().dlShiftTo(this.m.t,r);\n r.divRemTo(this.m,null,r);\n if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);\n return r;\n}\n\n// x/R mod m\nfunction montRevert(x) {\n var r = nbi();\n x.copyTo(r);\n this.reduce(r);\n return r;\n}\n\n// x = x/R mod m (HAC 14.32)\nfunction montReduce(x) {\n while(x.t <= this.mt2)\t// pad x so am has enough room later\n x.data[x.t++] = 0;\n for(var i = 0; i < this.m.t; ++i) {\n // faster way of calculating u0 = x.data[i]*mp mod DV\n var j = x.data[i]&0x7fff;\n var u0 = (j*this.mpl+(((j*this.mph+(x.data[i]>>15)*this.mpl)&this.um)<<15))&x.DM;\n // use am to combine the multiply-shift-add into one call\n j = i+this.m.t;\n x.data[j] += this.m.am(0,u0,x,i,0,this.m.t);\n // propagate carry\n while(x.data[j] >= x.DV) { x.data[j] -= x.DV; x.data[++j]++; }\n }\n x.clamp();\n x.drShiftTo(this.m.t,x);\n if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);\n}\n\n// r = \"x^2/R mod m\"; x != r\nfunction montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }\n\n// r = \"xy/R mod m\"; x,y != r\nfunction montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }\n\nMontgomery.prototype.convert = montConvert;\nMontgomery.prototype.revert = montRevert;\nMontgomery.prototype.reduce = montReduce;\nMontgomery.prototype.mulTo = montMulTo;\nMontgomery.prototype.sqrTo = montSqrTo;\n\n// (protected) true iff this is even\nfunction bnpIsEven() { return ((this.t>0)?(this.data[0]&1):this.s) == 0; }\n\n// (protected) this^e, e < 2^32, doing sqr and mul with \"r\" (HAC 14.79)\nfunction bnpExp(e,z) {\n if(e > 0xffffffff || e < 1) return BigInteger.ONE;\n var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;\n g.copyTo(r);\n while(--i >= 0) {\n z.sqrTo(r,r2);\n if((e&(1< 0) z.mulTo(r2,g,r);\n else { var t = r; r = r2; r2 = t; }\n }\n return z.revert(r);\n}\n\n// (public) this^e % m, 0 <= e < 2^32\nfunction bnModPowInt(e,m) {\n var z;\n if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);\n return this.exp(e,z);\n}\n\n// protected\nBigInteger.prototype.copyTo = bnpCopyTo;\nBigInteger.prototype.fromInt = bnpFromInt;\nBigInteger.prototype.fromString = bnpFromString;\nBigInteger.prototype.clamp = bnpClamp;\nBigInteger.prototype.dlShiftTo = bnpDLShiftTo;\nBigInteger.prototype.drShiftTo = bnpDRShiftTo;\nBigInteger.prototype.lShiftTo = bnpLShiftTo;\nBigInteger.prototype.rShiftTo = bnpRShiftTo;\nBigInteger.prototype.subTo = bnpSubTo;\nBigInteger.prototype.multiplyTo = bnpMultiplyTo;\nBigInteger.prototype.squareTo = bnpSquareTo;\nBigInteger.prototype.divRemTo = bnpDivRemTo;\nBigInteger.prototype.invDigit = bnpInvDigit;\nBigInteger.prototype.isEven = bnpIsEven;\nBigInteger.prototype.exp = bnpExp;\n\n// public\nBigInteger.prototype.toString = bnToString;\nBigInteger.prototype.negate = bnNegate;\nBigInteger.prototype.abs = bnAbs;\nBigInteger.prototype.compareTo = bnCompareTo;\nBigInteger.prototype.bitLength = bnBitLength;\nBigInteger.prototype.mod = bnMod;\nBigInteger.prototype.modPowInt = bnModPowInt;\n\n// \"constants\"\nBigInteger.ZERO = nbv(0);\nBigInteger.ONE = nbv(1);\n\n// jsbn2 lib\n\n//Copyright (c) 2005-2009 Tom Wu\n//All Rights Reserved.\n//See \"LICENSE\" for details (See jsbn.js for LICENSE).\n\n//Extended JavaScript BN functions, required for RSA private ops.\n\n//Version 1.1: new BigInteger(\"0\", 10) returns \"proper\" zero\n\n//(public)\nfunction bnClone() { var r = nbi(); this.copyTo(r); return r; }\n\n//(public) return value as integer\nfunction bnIntValue() {\nif(this.s < 0) {\n if(this.t == 1) return this.data[0]-this.DV;\n else if(this.t == 0) return -1;\n} else if(this.t == 1) return this.data[0];\nelse if(this.t == 0) return 0;\n// assumes 16 < DB < 32\nreturn ((this.data[1]&((1<<(32-this.DB))-1))<>24; }\n\n//(public) return value as short (assumes DB>=16)\nfunction bnShortValue() { return (this.t==0)?this.s:(this.data[0]<<16)>>16; }\n\n//(protected) return x s.t. r^x < DV\nfunction bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }\n\n//(public) 0 if this == 0, 1 if this > 0\nfunction bnSigNum() {\nif(this.s < 0) return -1;\nelse if(this.t <= 0 || (this.t == 1 && this.data[0] <= 0)) return 0;\nelse return 1;\n}\n\n//(protected) convert to radix string\nfunction bnpToRadix(b) {\nif(b == null) b = 10;\nif(this.signum() == 0 || b < 2 || b > 36) return \"0\";\nvar cs = this.chunkSize(b);\nvar a = Math.pow(b,cs);\nvar d = nbv(a), y = nbi(), z = nbi(), r = \"\";\nthis.divRemTo(d,y,z);\nwhile(y.signum() > 0) {\n r = (a+z.intValue()).toString(b).substr(1) + r;\n y.divRemTo(d,y,z);\n}\nreturn z.intValue().toString(b) + r;\n}\n\n//(protected) convert from radix string\nfunction bnpFromRadix(s,b) {\nthis.fromInt(0);\nif(b == null) b = 10;\nvar cs = this.chunkSize(b);\nvar d = Math.pow(b,cs), mi = false, j = 0, w = 0;\nfor(var i = 0; i < s.length; ++i) {\n var x = intAt(s,i);\n if(x < 0) {\n if(s.charAt(i) == \"-\" && this.signum() == 0) mi = true;\n continue;\n }\n w = b*w+x;\n if(++j >= cs) {\n this.dMultiply(d);\n this.dAddOffset(w,0);\n j = 0;\n w = 0;\n }\n}\nif(j > 0) {\n this.dMultiply(Math.pow(b,j));\n this.dAddOffset(w,0);\n}\nif(mi) BigInteger.ZERO.subTo(this,this);\n}\n\n//(protected) alternate constructor\nfunction bnpFromNumber(a,b,c) {\nif(\"number\" == typeof b) {\n // new BigInteger(int,int,RNG)\n if(a < 2) this.fromInt(1);\n else {\n this.fromNumber(a,c);\n if(!this.testBit(a-1)) // force MSB set\n this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);\n if(this.isEven()) this.dAddOffset(1,0); // force odd\n while(!this.isProbablePrime(b)) {\n this.dAddOffset(2,0);\n if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this);\n }\n }\n} else {\n // new BigInteger(int,RNG)\n var x = new Array(), t = a&7;\n x.length = (a>>3)+1;\n b.nextBytes(x);\n if(t > 0) x[0] &= ((1< 0) {\n if(p < this.DB && (d = this.data[i]>>p) != (this.s&this.DM)>>p)\n r[k++] = d|(this.s<<(this.DB-p));\n while(i >= 0) {\n if(p < 8) {\n d = (this.data[i]&((1<>(p+=this.DB-8);\n } else {\n d = (this.data[i]>>(p-=8))&0xff;\n if(p <= 0) { p += this.DB; --i; }\n }\n if((d&0x80) != 0) d |= -256;\n if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;\n if(k > 0 || d != this.s) r[k++] = d;\n }\n}\nreturn r;\n}\n\nfunction bnEquals(a) { return(this.compareTo(a)==0); }\nfunction bnMin(a) { return(this.compareTo(a)<0)?this:a; }\nfunction bnMax(a) { return(this.compareTo(a)>0)?this:a; }\n\n//(protected) r = this op a (bitwise)\nfunction bnpBitwiseTo(a,op,r) {\nvar i, f, m = Math.min(a.t,this.t);\nfor(i = 0; i < m; ++i) r.data[i] = op(this.data[i],a.data[i]);\nif(a.t < this.t) {\n f = a.s&this.DM;\n for(i = m; i < this.t; ++i) r.data[i] = op(this.data[i],f);\n r.t = this.t;\n} else {\n f = this.s&this.DM;\n for(i = m; i < a.t; ++i) r.data[i] = op(f,a.data[i]);\n r.t = a.t;\n}\nr.s = op(this.s,a.s);\nr.clamp();\n}\n\n//(public) this & a\nfunction op_and(x,y) { return x&y; }\nfunction bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }\n\n//(public) this | a\nfunction op_or(x,y) { return x|y; }\nfunction bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }\n\n//(public) this ^ a\nfunction op_xor(x,y) { return x^y; }\nfunction bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }\n\n//(public) this & ~a\nfunction op_andnot(x,y) { return x&~y; }\nfunction bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }\n\n//(public) ~this\nfunction bnNot() {\nvar r = nbi();\nfor(var i = 0; i < this.t; ++i) r.data[i] = this.DM&~this.data[i];\nr.t = this.t;\nr.s = ~this.s;\nreturn r;\n}\n\n//(public) this << n\nfunction bnShiftLeft(n) {\nvar r = nbi();\nif(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);\nreturn r;\n}\n\n//(public) this >> n\nfunction bnShiftRight(n) {\nvar r = nbi();\nif(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);\nreturn r;\n}\n\n//return index of lowest 1-bit in x, x < 2^31\nfunction lbit(x) {\nif(x == 0) return -1;\nvar r = 0;\nif((x&0xffff) == 0) { x >>= 16; r += 16; }\nif((x&0xff) == 0) { x >>= 8; r += 8; }\nif((x&0xf) == 0) { x >>= 4; r += 4; }\nif((x&3) == 0) { x >>= 2; r += 2; }\nif((x&1) == 0) ++r;\nreturn r;\n}\n\n//(public) returns index of lowest 1-bit (or -1 if none)\nfunction bnGetLowestSetBit() {\nfor(var i = 0; i < this.t; ++i)\n if(this.data[i] != 0) return i*this.DB+lbit(this.data[i]);\nif(this.s < 0) return this.t*this.DB;\nreturn -1;\n}\n\n//return number of 1 bits in x\nfunction cbit(x) {\nvar r = 0;\nwhile(x != 0) { x &= x-1; ++r; }\nreturn r;\n}\n\n//(public) return number of set bits\nfunction bnBitCount() {\nvar r = 0, x = this.s&this.DM;\nfor(var i = 0; i < this.t; ++i) r += cbit(this.data[i]^x);\nreturn r;\n}\n\n//(public) true iff nth bit is set\nfunction bnTestBit(n) {\nvar j = Math.floor(n/this.DB);\nif(j >= this.t) return(this.s!=0);\nreturn((this.data[j]&(1<<(n%this.DB)))!=0);\n}\n\n//(protected) this op (1<>= this.DB;\n}\nif(a.t < this.t) {\n c += a.s;\n while(i < this.t) {\n c += this.data[i];\n r.data[i++] = c&this.DM;\n c >>= this.DB;\n }\n c += this.s;\n} else {\n c += this.s;\n while(i < a.t) {\n c += a.data[i];\n r.data[i++] = c&this.DM;\n c >>= this.DB;\n }\n c += a.s;\n}\nr.s = (c<0)?-1:0;\nif(c > 0) r.data[i++] = c;\nelse if(c < -1) r.data[i++] = this.DV+c;\nr.t = i;\nr.clamp();\n}\n\n//(public) this + a\nfunction bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }\n\n//(public) this - a\nfunction bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }\n\n//(public) this * a\nfunction bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }\n\n//(public) this / a\nfunction bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }\n\n//(public) this % a\nfunction bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }\n\n//(public) [this/a,this%a]\nfunction bnDivideAndRemainder(a) {\nvar q = nbi(), r = nbi();\nthis.divRemTo(a,q,r);\nreturn new Array(q,r);\n}\n\n//(protected) this *= n, this >= 0, 1 < n < DV\nfunction bnpDMultiply(n) {\nthis.data[this.t] = this.am(0,n-1,this,0,0,this.t);\n++this.t;\nthis.clamp();\n}\n\n//(protected) this += n << w words, this >= 0\nfunction bnpDAddOffset(n,w) {\nif(n == 0) return;\nwhile(this.t <= w) this.data[this.t++] = 0;\nthis.data[w] += n;\nwhile(this.data[w] >= this.DV) {\n this.data[w] -= this.DV;\n if(++w >= this.t) this.data[this.t++] = 0;\n ++this.data[w];\n}\n}\n\n//A \"null\" reducer\nfunction NullExp() {}\nfunction nNop(x) { return x; }\nfunction nMulTo(x,y,r) { x.multiplyTo(y,r); }\nfunction nSqrTo(x,r) { x.squareTo(r); }\n\nNullExp.prototype.convert = nNop;\nNullExp.prototype.revert = nNop;\nNullExp.prototype.mulTo = nMulTo;\nNullExp.prototype.sqrTo = nSqrTo;\n\n//(public) this^e\nfunction bnPow(e) { return this.exp(e,new NullExp()); }\n\n//(protected) r = lower n words of \"this * a\", a.t <= n\n//\"this\" should be the larger one if appropriate.\nfunction bnpMultiplyLowerTo(a,n,r) {\nvar i = Math.min(this.t+a.t,n);\nr.s = 0; // assumes a,this >= 0\nr.t = i;\nwhile(i > 0) r.data[--i] = 0;\nvar j;\nfor(j = r.t-this.t; i < j; ++i) r.data[i+this.t] = this.am(0,a.data[i],r,i,0,this.t);\nfor(j = Math.min(a.t,n); i < j; ++i) this.am(0,a.data[i],r,i,0,n-i);\nr.clamp();\n}\n\n//(protected) r = \"this * a\" without lower n words, n > 0\n//\"this\" should be the larger one if appropriate.\nfunction bnpMultiplyUpperTo(a,n,r) {\n--n;\nvar i = r.t = this.t+a.t-n;\nr.s = 0; // assumes a,this >= 0\nwhile(--i >= 0) r.data[i] = 0;\nfor(i = Math.max(n-this.t,0); i < a.t; ++i)\n r.data[this.t+i-n] = this.am(n-i,a.data[i],r,0,0,this.t+i-n);\nr.clamp();\nr.drShiftTo(1,r);\n}\n\n//Barrett modular reduction\nfunction Barrett(m) {\n// setup Barrett\nthis.r2 = nbi();\nthis.q3 = nbi();\nBigInteger.ONE.dlShiftTo(2*m.t,this.r2);\nthis.mu = this.r2.divide(m);\nthis.m = m;\n}\n\nfunction barrettConvert(x) {\nif(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);\nelse if(x.compareTo(this.m) < 0) return x;\nelse { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }\n}\n\nfunction barrettRevert(x) { return x; }\n\n//x = x mod m (HAC 14.42)\nfunction barrettReduce(x) {\nx.drShiftTo(this.m.t-1,this.r2);\nif(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); }\nthis.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);\nthis.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);\nwhile(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1);\nx.subTo(this.r2,x);\nwhile(x.compareTo(this.m) >= 0) x.subTo(this.m,x);\n}\n\n//r = x^2 mod m; x != r\nfunction barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }\n\n//r = x*y mod m; x,y != r\nfunction barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }\n\nBarrett.prototype.convert = barrettConvert;\nBarrett.prototype.revert = barrettRevert;\nBarrett.prototype.reduce = barrettReduce;\nBarrett.prototype.mulTo = barrettMulTo;\nBarrett.prototype.sqrTo = barrettSqrTo;\n\n//(public) this^e % m (HAC 14.85)\nfunction bnModPow(e,m) {\nvar i = e.bitLength(), k, r = nbv(1), z;\nif(i <= 0) return r;\nelse if(i < 18) k = 1;\nelse if(i < 48) k = 3;\nelse if(i < 144) k = 4;\nelse if(i < 768) k = 5;\nelse k = 6;\nif(i < 8)\n z = new Classic(m);\nelse if(m.isEven())\n z = new Barrett(m);\nelse\n z = new Montgomery(m);\n\n// precomputation\nvar g = new Array(), n = 3, k1 = k-1, km = (1< 1) {\n var g2 = nbi();\n z.sqrTo(g[1],g2);\n while(n <= km) {\n g[n] = nbi();\n z.mulTo(g2,g[n-2],g[n]);\n n += 2;\n }\n}\n\nvar j = e.t-1, w, is1 = true, r2 = nbi(), t;\ni = nbits(e.data[j])-1;\nwhile(j >= 0) {\n if(i >= k1) w = (e.data[j]>>(i-k1))&km;\n else {\n w = (e.data[j]&((1<<(i+1))-1))<<(k1-i);\n if(j > 0) w |= e.data[j-1]>>(this.DB+i-k1);\n }\n\n n = k;\n while((w&1) == 0) { w >>= 1; --n; }\n if((i -= n) < 0) { i += this.DB; --j; }\n if(is1) { // ret == 1, don't bother squaring or multiplying it\n g[w].copyTo(r);\n is1 = false;\n } else {\n while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }\n if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }\n z.mulTo(r2,g[w],r);\n }\n\n while(j >= 0 && (e.data[j]&(1< 0) {\n x.rShiftTo(g,x);\n y.rShiftTo(g,y);\n}\nwhile(x.signum() > 0) {\n if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);\n if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);\n if(x.compareTo(y) >= 0) {\n x.subTo(y,x);\n x.rShiftTo(1,x);\n } else {\n y.subTo(x,y);\n y.rShiftTo(1,y);\n }\n}\nif(g > 0) y.lShiftTo(g,y);\nreturn y;\n}\n\n//(protected) this % n, n < 2^26\nfunction bnpModInt(n) {\nif(n <= 0) return 0;\nvar d = this.DV%n, r = (this.s<0)?n-1:0;\nif(this.t > 0)\n if(d == 0) r = this.data[0]%n;\n else for(var i = this.t-1; i >= 0; --i) r = (d*r+this.data[i])%n;\nreturn r;\n}\n\n//(public) 1/this % m (HAC 14.61)\nfunction bnModInverse(m) {\nvar ac = m.isEven();\nif((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;\nvar u = m.clone(), v = this.clone();\nvar a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);\nwhile(u.signum() != 0) {\n while(u.isEven()) {\n u.rShiftTo(1,u);\n if(ac) {\n if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }\n a.rShiftTo(1,a);\n } else if(!b.isEven()) b.subTo(m,b);\n b.rShiftTo(1,b);\n }\n while(v.isEven()) {\n v.rShiftTo(1,v);\n if(ac) {\n if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }\n c.rShiftTo(1,c);\n } else if(!d.isEven()) d.subTo(m,d);\n d.rShiftTo(1,d);\n }\n if(u.compareTo(v) >= 0) {\n u.subTo(v,u);\n if(ac) a.subTo(c,a);\n b.subTo(d,b);\n } else {\n v.subTo(u,v);\n if(ac) c.subTo(a,c);\n d.subTo(b,d);\n }\n}\nif(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;\nif(d.compareTo(m) >= 0) return d.subtract(m);\nif(d.signum() < 0) d.addTo(m,d); else return d;\nif(d.signum() < 0) return d.add(m); else return d;\n}\n\nvar lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509];\nvar lplim = (1<<26)/lowprimes[lowprimes.length-1];\n\n//(public) test primality with certainty >= 1-.5^t\nfunction bnIsProbablePrime(t) {\nvar i, x = this.abs();\nif(x.t == 1 && x.data[0] <= lowprimes[lowprimes.length-1]) {\n for(i = 0; i < lowprimes.length; ++i)\n if(x.data[0] == lowprimes[i]) return true;\n return false;\n}\nif(x.isEven()) return false;\ni = 1;\nwhile(i < lowprimes.length) {\n var m = lowprimes[i], j = i+1;\n while(j < lowprimes.length && m < lplim) m *= lowprimes[j++];\n m = x.modInt(m);\n while(i < j) if(m%lowprimes[i++] == 0) return false;\n}\nreturn x.millerRabin(t);\n}\n\n//(protected) true if probably prime (HAC 4.24, Miller-Rabin)\nfunction bnpMillerRabin(t) {\nvar n1 = this.subtract(BigInteger.ONE);\nvar k = n1.getLowestSetBit();\nif(k <= 0) return false;\nvar r = n1.shiftRight(k);\nvar prng = bnGetPrng();\nvar a;\nfor(var i = 0; i < t; ++i) {\n // select witness 'a' at random from between 1 and n1\n do {\n a = new BigInteger(this.bitLength(), prng);\n }\n while(a.compareTo(BigInteger.ONE) <= 0 || a.compareTo(n1) >= 0);\n var y = a.modPow(r,this);\n if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {\n var j = 1;\n while(j++ < k && y.compareTo(n1) != 0) {\n y = y.modPowInt(2,this);\n if(y.compareTo(BigInteger.ONE) == 0) return false;\n }\n if(y.compareTo(n1) != 0) return false;\n }\n}\nreturn true;\n}\n\n// get pseudo random number generator\nfunction bnGetPrng() {\n // create prng with api that matches BigInteger secure random\n return {\n // x is an array to fill with bytes\n nextBytes: function(x) {\n for(var i = 0; i < x.length; ++i) {\n x[i] = Math.floor(Math.random() * 0x0100);\n }\n }\n };\n}\n\n//protected\nBigInteger.prototype.chunkSize = bnpChunkSize;\nBigInteger.prototype.toRadix = bnpToRadix;\nBigInteger.prototype.fromRadix = bnpFromRadix;\nBigInteger.prototype.fromNumber = bnpFromNumber;\nBigInteger.prototype.bitwiseTo = bnpBitwiseTo;\nBigInteger.prototype.changeBit = bnpChangeBit;\nBigInteger.prototype.addTo = bnpAddTo;\nBigInteger.prototype.dMultiply = bnpDMultiply;\nBigInteger.prototype.dAddOffset = bnpDAddOffset;\nBigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;\nBigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;\nBigInteger.prototype.modInt = bnpModInt;\nBigInteger.prototype.millerRabin = bnpMillerRabin;\n\n//public\nBigInteger.prototype.clone = bnClone;\nBigInteger.prototype.intValue = bnIntValue;\nBigInteger.prototype.byteValue = bnByteValue;\nBigInteger.prototype.shortValue = bnShortValue;\nBigInteger.prototype.signum = bnSigNum;\nBigInteger.prototype.toByteArray = bnToByteArray;\nBigInteger.prototype.equals = bnEquals;\nBigInteger.prototype.min = bnMin;\nBigInteger.prototype.max = bnMax;\nBigInteger.prototype.and = bnAnd;\nBigInteger.prototype.or = bnOr;\nBigInteger.prototype.xor = bnXor;\nBigInteger.prototype.andNot = bnAndNot;\nBigInteger.prototype.not = bnNot;\nBigInteger.prototype.shiftLeft = bnShiftLeft;\nBigInteger.prototype.shiftRight = bnShiftRight;\nBigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;\nBigInteger.prototype.bitCount = bnBitCount;\nBigInteger.prototype.testBit = bnTestBit;\nBigInteger.prototype.setBit = bnSetBit;\nBigInteger.prototype.clearBit = bnClearBit;\nBigInteger.prototype.flipBit = bnFlipBit;\nBigInteger.prototype.add = bnAdd;\nBigInteger.prototype.subtract = bnSubtract;\nBigInteger.prototype.multiply = bnMultiply;\nBigInteger.prototype.divide = bnDivide;\nBigInteger.prototype.remainder = bnRemainder;\nBigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;\nBigInteger.prototype.modPow = bnModPow;\nBigInteger.prototype.modInverse = bnModInverse;\nBigInteger.prototype.pow = bnPow;\nBigInteger.prototype.gcd = bnGCD;\nBigInteger.prototype.isProbablePrime = bnIsProbablePrime;\n\n//BigInteger interfaces not implemented in jsbn:\n\n//BigInteger(int signum, byte[] magnitude)\n//double doubleValue()\n//float floatValue()\n//int hashCode()\n//long longValue()\n//static BigInteger valueOf(long val)\n","/**\n * Javascript implementation of RSA-KEM.\n *\n * @author Lautaro Cozzani Rodriguez\n * @author Dave Longley\n *\n * Copyright (c) 2014 Lautaro Cozzani \n * Copyright (c) 2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\nrequire('./random');\nrequire('./jsbn');\n\nmodule.exports = forge.kem = forge.kem || {};\n\nvar BigInteger = forge.jsbn.BigInteger;\n\n/**\n * The API for the RSA Key Encapsulation Mechanism (RSA-KEM) from ISO 18033-2.\n */\nforge.kem.rsa = {};\n\n/**\n * Creates an RSA KEM API object for generating a secret asymmetric key.\n *\n * The symmetric key may be generated via a call to 'encrypt', which will\n * produce a ciphertext to be transmitted to the recipient and a key to be\n * kept secret. The ciphertext is a parameter to be passed to 'decrypt' which\n * will produce the same secret key for the recipient to use to decrypt a\n * message that was encrypted with the secret key.\n *\n * @param kdf the KDF API to use (eg: new forge.kem.kdf1()).\n * @param options the options to use.\n * [prng] a custom crypto-secure pseudo-random number generator to use,\n * that must define \"getBytesSync\".\n */\nforge.kem.rsa.create = function(kdf, options) {\n options = options || {};\n var prng = options.prng || forge.random;\n\n var kem = {};\n\n /**\n * Generates a secret key and its encapsulation.\n *\n * @param publicKey the RSA public key to encrypt with.\n * @param keyLength the length, in bytes, of the secret key to generate.\n *\n * @return an object with:\n * encapsulation: the ciphertext for generating the secret key, as a\n * binary-encoded string of bytes.\n * key: the secret key to use for encrypting a message.\n */\n kem.encrypt = function(publicKey, keyLength) {\n // generate a random r where 1 < r < n\n var byteLength = Math.ceil(publicKey.n.bitLength() / 8);\n var r;\n do {\n r = new BigInteger(\n forge.util.bytesToHex(prng.getBytesSync(byteLength)),\n 16).mod(publicKey.n);\n } while(r.compareTo(BigInteger.ONE) <= 0);\n\n // prepend r with zeros\n r = forge.util.hexToBytes(r.toString(16));\n var zeros = byteLength - r.length;\n if(zeros > 0) {\n r = forge.util.fillString(String.fromCharCode(0), zeros) + r;\n }\n\n // encrypt the random\n var encapsulation = publicKey.encrypt(r, 'NONE');\n\n // generate the secret key\n var key = kdf.generate(r, keyLength);\n\n return {encapsulation: encapsulation, key: key};\n };\n\n /**\n * Decrypts an encapsulated secret key.\n *\n * @param privateKey the RSA private key to decrypt with.\n * @param encapsulation the ciphertext for generating the secret key, as\n * a binary-encoded string of bytes.\n * @param keyLength the length, in bytes, of the secret key to generate.\n *\n * @return the secret key as a binary-encoded string of bytes.\n */\n kem.decrypt = function(privateKey, encapsulation, keyLength) {\n // decrypt the encapsulation and generate the secret key\n var r = privateKey.decrypt(encapsulation, 'NONE');\n return kdf.generate(r, keyLength);\n };\n\n return kem;\n};\n\n// TODO: add forge.kem.kdf.create('KDF1', {md: ..., ...}) API?\n\n/**\n * Creates a key derivation API object that implements KDF1 per ISO 18033-2.\n *\n * @param md the hash API to use.\n * @param [digestLength] an optional digest length that must be positive and\n * less than or equal to md.digestLength.\n *\n * @return a KDF1 API object.\n */\nforge.kem.kdf1 = function(md, digestLength) {\n _createKDF(this, md, 0, digestLength || md.digestLength);\n};\n\n/**\n * Creates a key derivation API object that implements KDF2 per ISO 18033-2.\n *\n * @param md the hash API to use.\n * @param [digestLength] an optional digest length that must be positive and\n * less than or equal to md.digestLength.\n *\n * @return a KDF2 API object.\n */\nforge.kem.kdf2 = function(md, digestLength) {\n _createKDF(this, md, 1, digestLength || md.digestLength);\n};\n\n/**\n * Creates a KDF1 or KDF2 API object.\n *\n * @param md the hash API to use.\n * @param counterStart the starting index for the counter.\n * @param digestLength the digest length to use.\n *\n * @return the KDF API object.\n */\nfunction _createKDF(kdf, md, counterStart, digestLength) {\n /**\n * Generate a key of the specified length.\n *\n * @param x the binary-encoded byte string to generate a key from.\n * @param length the number of bytes to generate (the size of the key).\n *\n * @return the key as a binary-encoded string.\n */\n kdf.generate = function(x, length) {\n var key = new forge.util.ByteBuffer();\n\n // run counter from counterStart to ceil(length / Hash.len)\n var k = Math.ceil(length / digestLength) + counterStart;\n\n var c = new forge.util.ByteBuffer();\n for(var i = counterStart; i < k; ++i) {\n // I2OSP(i, 4): convert counter to an octet string of 4 octets\n c.putInt32(i);\n\n // digest 'x' and the counter and add the result to the key\n md.start();\n md.update(x + c.getBytes());\n var hash = md.digest();\n key.putBytes(hash.getBytes(digestLength));\n }\n\n // truncate to the correct key length\n key.truncate(key.length() - length);\n return key.getBytes();\n };\n}\n","/**\n * Cross-browser support for logging in a web application.\n *\n * @author David I. Lehn \n *\n * Copyright (c) 2008-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\n/* LOG API */\nmodule.exports = forge.log = forge.log || {};\n\n/**\n * Application logging system.\n *\n * Each logger level available as it's own function of the form:\n * forge.log.level(category, args...)\n * The category is an arbitrary string, and the args are the same as\n * Firebug's console.log API. By default the call will be output as:\n * 'LEVEL [category] , args[1], ...'\n * This enables proper % formatting via the first argument.\n * Each category is enabled by default but can be enabled or disabled with\n * the setCategoryEnabled() function.\n */\n// list of known levels\nforge.log.levels = [\n 'none', 'error', 'warning', 'info', 'debug', 'verbose', 'max'];\n// info on the levels indexed by name:\n// index: level index\n// name: uppercased display name\nvar sLevelInfo = {};\n// list of loggers\nvar sLoggers = [];\n/**\n * Standard console logger. If no console support is enabled this will\n * remain null. Check before using.\n */\nvar sConsoleLogger = null;\n\n// logger flags\n/**\n * Lock the level at the current value. Used in cases where user config may\n * set the level such that only critical messages are seen but more verbose\n * messages are needed for debugging or other purposes.\n */\nforge.log.LEVEL_LOCKED = (1 << 1);\n/**\n * Always call log function. By default, the logging system will check the\n * message level against logger.level before calling the log function. This\n * flag allows the function to do its own check.\n */\nforge.log.NO_LEVEL_CHECK = (1 << 2);\n/**\n * Perform message interpolation with the passed arguments. \"%\" style\n * fields in log messages will be replaced by arguments as needed. Some\n * loggers, such as Firebug, may do this automatically. The original log\n * message will be available as 'message' and the interpolated version will\n * be available as 'fullMessage'.\n */\nforge.log.INTERPOLATE = (1 << 3);\n\n// setup each log level\nfor(var i = 0; i < forge.log.levels.length; ++i) {\n var level = forge.log.levels[i];\n sLevelInfo[level] = {\n index: i,\n name: level.toUpperCase()\n };\n}\n\n/**\n * Message logger. Will dispatch a message to registered loggers as needed.\n *\n * @param message message object\n */\nforge.log.logMessage = function(message) {\n var messageLevelIndex = sLevelInfo[message.level].index;\n for(var i = 0; i < sLoggers.length; ++i) {\n var logger = sLoggers[i];\n if(logger.flags & forge.log.NO_LEVEL_CHECK) {\n logger.f(message);\n } else {\n // get logger level\n var loggerLevelIndex = sLevelInfo[logger.level].index;\n // check level\n if(messageLevelIndex <= loggerLevelIndex) {\n // message critical enough, call logger\n logger.f(logger, message);\n }\n }\n }\n};\n\n/**\n * Sets the 'standard' key on a message object to:\n * \"LEVEL [category] \" + message\n *\n * @param message a message log object\n */\nforge.log.prepareStandard = function(message) {\n if(!('standard' in message)) {\n message.standard =\n sLevelInfo[message.level].name +\n //' ' + +message.timestamp +\n ' [' + message.category + '] ' +\n message.message;\n }\n};\n\n/**\n * Sets the 'full' key on a message object to the original message\n * interpolated via % formatting with the message arguments.\n *\n * @param message a message log object.\n */\nforge.log.prepareFull = function(message) {\n if(!('full' in message)) {\n // copy args and insert message at the front\n var args = [message.message];\n args = args.concat([] || message['arguments']);\n // format the message\n message.full = forge.util.format.apply(this, args);\n }\n};\n\n/**\n * Applies both preparseStandard() and prepareFull() to a message object and\n * store result in 'standardFull'.\n *\n * @param message a message log object.\n */\nforge.log.prepareStandardFull = function(message) {\n if(!('standardFull' in message)) {\n // FIXME implement 'standardFull' logging\n forge.log.prepareStandard(message);\n message.standardFull = message.standard;\n }\n};\n\n// create log level functions\nif(true) {\n // levels for which we want functions\n var levels = ['error', 'warning', 'info', 'debug', 'verbose'];\n for(var i = 0; i < levels.length; ++i) {\n // wrap in a function to ensure proper level var is passed\n (function(level) {\n // create function for this level\n forge.log[level] = function(category, message/*, args...*/) {\n // convert arguments to real array, remove category and message\n var args = Array.prototype.slice.call(arguments).slice(2);\n // create message object\n // Note: interpolation and standard formatting is done lazily\n var msg = {\n timestamp: new Date(),\n level: level,\n category: category,\n message: message,\n 'arguments': args\n /*standard*/\n /*full*/\n /*fullMessage*/\n };\n // process this message\n forge.log.logMessage(msg);\n };\n })(levels[i]);\n }\n}\n\n/**\n * Creates a new logger with specified custom logging function.\n *\n * The logging function has a signature of:\n * function(logger, message)\n * logger: current logger\n * message: object:\n * level: level id\n * category: category\n * message: string message\n * arguments: Array of extra arguments\n * fullMessage: interpolated message and arguments if INTERPOLATE flag set\n *\n * @param logFunction a logging function which takes a log message object\n * as a parameter.\n *\n * @return a logger object.\n */\nforge.log.makeLogger = function(logFunction) {\n var logger = {\n flags: 0,\n f: logFunction\n };\n forge.log.setLevel(logger, 'none');\n return logger;\n};\n\n/**\n * Sets the current log level on a logger.\n *\n * @param logger the target logger.\n * @param level the new maximum log level as a string.\n *\n * @return true if set, false if not.\n */\nforge.log.setLevel = function(logger, level) {\n var rval = false;\n if(logger && !(logger.flags & forge.log.LEVEL_LOCKED)) {\n for(var i = 0; i < forge.log.levels.length; ++i) {\n var aValidLevel = forge.log.levels[i];\n if(level == aValidLevel) {\n // set level\n logger.level = level;\n rval = true;\n break;\n }\n }\n }\n\n return rval;\n};\n\n/**\n * Locks the log level at its current value.\n *\n * @param logger the target logger.\n * @param lock boolean lock value, default to true.\n */\nforge.log.lock = function(logger, lock) {\n if(typeof lock === 'undefined' || lock) {\n logger.flags |= forge.log.LEVEL_LOCKED;\n } else {\n logger.flags &= ~forge.log.LEVEL_LOCKED;\n }\n};\n\n/**\n * Adds a logger.\n *\n * @param logger the logger object.\n */\nforge.log.addLogger = function(logger) {\n sLoggers.push(logger);\n};\n\n// setup the console logger if possible, else create fake console.log\nif(typeof(console) !== 'undefined' && 'log' in console) {\n var logger;\n if(console.error && console.warn && console.info && console.debug) {\n // looks like Firebug-style logging is available\n // level handlers map\n var levelHandlers = {\n error: console.error,\n warning: console.warn,\n info: console.info,\n debug: console.debug,\n verbose: console.debug\n };\n var f = function(logger, message) {\n forge.log.prepareStandard(message);\n var handler = levelHandlers[message.level];\n // prepend standard message and concat args\n var args = [message.standard];\n args = args.concat(message['arguments'].slice());\n // apply to low-level console function\n handler.apply(console, args);\n };\n logger = forge.log.makeLogger(f);\n } else {\n // only appear to have basic console.log\n var f = function(logger, message) {\n forge.log.prepareStandardFull(message);\n console.log(message.standardFull);\n };\n logger = forge.log.makeLogger(f);\n }\n forge.log.setLevel(logger, 'debug');\n forge.log.addLogger(logger);\n sConsoleLogger = logger;\n} else {\n // define fake console.log to avoid potential script errors on\n // browsers that do not have console logging\n console = {\n log: function() {}\n };\n}\n\n/*\n * Check for logging control query vars.\n *\n * console.level=\n * Set's the console log level by name. Useful to override defaults and\n * allow more verbose logging before a user config is loaded.\n *\n * console.lock=\n * Lock the console log level at whatever level it is set at. This is run\n * after console.level is processed. Useful to force a level of verbosity\n * that could otherwise be limited by a user config.\n */\nif(sConsoleLogger !== null) {\n var query = forge.util.getQueryVariables();\n if('console.level' in query) {\n // set with last value\n forge.log.setLevel(\n sConsoleLogger, query['console.level'].slice(-1)[0]);\n }\n if('console.lock' in query) {\n // set with last value\n var lock = query['console.lock'].slice(-1)[0];\n if(lock == 'true') {\n forge.log.lock(sConsoleLogger);\n }\n }\n}\n\n// provide public access to console logger\nforge.log.consoleLogger = sConsoleLogger;\n","/**\n * Node.js module for all known Forge message digests.\n *\n * @author Dave Longley\n *\n * Copyright 2011-2017 Digital Bazaar, Inc.\n */\nmodule.exports = require('./md');\n\nrequire('./md5');\nrequire('./sha1');\nrequire('./sha256');\nrequire('./sha512');\n","/**\n * Node.js module for Forge message digests.\n *\n * @author Dave Longley\n *\n * Copyright 2011-2017 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\n\nmodule.exports = forge.md = forge.md || {};\nforge.md.algorithms = forge.md.algorithms || {};\n","/**\n * Message Digest Algorithm 5 with 128-bit digest (MD5) implementation.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\nvar md5 = module.exports = forge.md5 = forge.md5 || {};\nforge.md.md5 = forge.md.algorithms.md5 = md5;\n\n/**\n * Creates an MD5 message digest object.\n *\n * @return a message digest object.\n */\nmd5.create = function() {\n // do initialization as necessary\n if(!_initialized) {\n _init();\n }\n\n // MD5 state contains four 32-bit integers\n var _state = null;\n\n // input buffer\n var _input = forge.util.createBuffer();\n\n // used for word storage\n var _w = new Array(16);\n\n // message digest object\n var md = {\n algorithm: 'md5',\n blockLength: 64,\n digestLength: 16,\n // 56-bit length of message so far (does not including padding)\n messageLength: 0,\n // true message length\n fullMessageLength: null,\n // size of message length in bytes\n messageLengthSize: 8\n };\n\n /**\n * Starts the digest.\n *\n * @return this digest object.\n */\n md.start = function() {\n // up to 56-bit message length for convenience\n md.messageLength = 0;\n\n // full message length (set md.messageLength64 for backwards-compatibility)\n md.fullMessageLength = md.messageLength64 = [];\n var int32s = md.messageLengthSize / 4;\n for(var i = 0; i < int32s; ++i) {\n md.fullMessageLength.push(0);\n }\n _input = forge.util.createBuffer();\n _state = {\n h0: 0x67452301,\n h1: 0xEFCDAB89,\n h2: 0x98BADCFE,\n h3: 0x10325476\n };\n return md;\n };\n // start digest automatically for first time\n md.start();\n\n /**\n * Updates the digest with the given message input. The given input can\n * treated as raw input (no encoding will be applied) or an encoding of\n * 'utf8' maybe given to encode the input using UTF-8.\n *\n * @param msg the message input to update with.\n * @param encoding the encoding to use (default: 'raw', other: 'utf8').\n *\n * @return this digest object.\n */\n md.update = function(msg, encoding) {\n if(encoding === 'utf8') {\n msg = forge.util.encodeUtf8(msg);\n }\n\n // update message length\n var len = msg.length;\n md.messageLength += len;\n len = [(len / 0x100000000) >>> 0, len >>> 0];\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n md.fullMessageLength[i] += len[1];\n len[1] = len[0] + ((md.fullMessageLength[i] / 0x100000000) >>> 0);\n md.fullMessageLength[i] = md.fullMessageLength[i] >>> 0;\n len[0] = (len[1] / 0x100000000) >>> 0;\n }\n\n // add bytes to input buffer\n _input.putBytes(msg);\n\n // process bytes\n _update(_state, _w, _input);\n\n // compact input buffer every 2K or if empty\n if(_input.read > 2048 || _input.length() === 0) {\n _input.compact();\n }\n\n return md;\n };\n\n /**\n * Produces the digest.\n *\n * @return a byte buffer containing the digest value.\n */\n md.digest = function() {\n /* Note: Here we copy the remaining bytes in the input buffer and\n add the appropriate MD5 padding. Then we do the final update\n on a copy of the state so that if the user wants to get\n intermediate digests they can do so. */\n\n /* Determine the number of bytes that must be added to the message\n to ensure its length is congruent to 448 mod 512. In other words,\n the data to be digested must be a multiple of 512 bits (or 128 bytes).\n This data includes the message, some padding, and the length of the\n message. Since the length of the message will be encoded as 8 bytes (64\n bits), that means that the last segment of the data must have 56 bytes\n (448 bits) of message and padding. Therefore, the length of the message\n plus the padding must be congruent to 448 mod 512 because\n 512 - 128 = 448.\n\n In order to fill up the message length it must be filled with\n padding that begins with 1 bit followed by all 0 bits. Padding\n must *always* be present, so if the message length is already\n congruent to 448 mod 512, then 512 padding bits must be added. */\n\n var finalBlock = forge.util.createBuffer();\n finalBlock.putBytes(_input.bytes());\n\n // compute remaining size to be digested (include message length size)\n var remaining = (\n md.fullMessageLength[md.fullMessageLength.length - 1] +\n md.messageLengthSize);\n\n // add padding for overflow blockSize - overflow\n // _padding starts with 1 byte with first bit is set (byte value 128), then\n // there may be up to (blockSize - 1) other pad bytes\n var overflow = remaining & (md.blockLength - 1);\n finalBlock.putBytes(_padding.substr(0, md.blockLength - overflow));\n\n // serialize message length in bits in little-endian order; since length\n // is stored in bytes we multiply by 8 and add carry\n var bits, carry = 0;\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n bits = md.fullMessageLength[i] * 8 + carry;\n carry = (bits / 0x100000000) >>> 0;\n finalBlock.putInt32Le(bits >>> 0);\n }\n\n var s2 = {\n h0: _state.h0,\n h1: _state.h1,\n h2: _state.h2,\n h3: _state.h3\n };\n _update(s2, _w, finalBlock);\n var rval = forge.util.createBuffer();\n rval.putInt32Le(s2.h0);\n rval.putInt32Le(s2.h1);\n rval.putInt32Le(s2.h2);\n rval.putInt32Le(s2.h3);\n return rval;\n };\n\n return md;\n};\n\n// padding, constant tables for calculating md5\nvar _padding = null;\nvar _g = null;\nvar _r = null;\nvar _k = null;\nvar _initialized = false;\n\n/**\n * Initializes the constant tables.\n */\nfunction _init() {\n // create padding\n _padding = String.fromCharCode(128);\n _padding += forge.util.fillString(String.fromCharCode(0x00), 64);\n\n // g values\n _g = [\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12,\n 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2,\n 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9];\n\n // rounds table\n _r = [\n 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,\n 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,\n 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,\n 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21];\n\n // get the result of abs(sin(i + 1)) as a 32-bit integer\n _k = new Array(64);\n for(var i = 0; i < 64; ++i) {\n _k[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 0x100000000);\n }\n\n // now initialized\n _initialized = true;\n}\n\n/**\n * Updates an MD5 state with the given byte buffer.\n *\n * @param s the MD5 state to update.\n * @param w the array to use to store words.\n * @param bytes the byte buffer to update with.\n */\nfunction _update(s, w, bytes) {\n // consume 512 bit (64 byte) chunks\n var t, a, b, c, d, f, r, i;\n var len = bytes.length();\n while(len >= 64) {\n // initialize hash value for this chunk\n a = s.h0;\n b = s.h1;\n c = s.h2;\n d = s.h3;\n\n // round 1\n for(i = 0; i < 16; ++i) {\n w[i] = bytes.getInt32Le();\n f = d ^ (b & (c ^ d));\n t = (a + f + _k[i] + w[i]);\n r = _r[i];\n a = d;\n d = c;\n c = b;\n b += (t << r) | (t >>> (32 - r));\n }\n // round 2\n for(; i < 32; ++i) {\n f = c ^ (d & (b ^ c));\n t = (a + f + _k[i] + w[_g[i]]);\n r = _r[i];\n a = d;\n d = c;\n c = b;\n b += (t << r) | (t >>> (32 - r));\n }\n // round 3\n for(; i < 48; ++i) {\n f = b ^ c ^ d;\n t = (a + f + _k[i] + w[_g[i]]);\n r = _r[i];\n a = d;\n d = c;\n c = b;\n b += (t << r) | (t >>> (32 - r));\n }\n // round 4\n for(; i < 64; ++i) {\n f = c ^ (b | ~d);\n t = (a + f + _k[i] + w[_g[i]]);\n r = _r[i];\n a = d;\n d = c;\n c = b;\n b += (t << r) | (t >>> (32 - r));\n }\n\n // update hash state\n s.h0 = (s.h0 + a) | 0;\n s.h1 = (s.h1 + b) | 0;\n s.h2 = (s.h2 + c) | 0;\n s.h3 = (s.h3 + d) | 0;\n\n len -= 64;\n }\n}\n","/**\n * Node.js module for Forge mask generation functions.\n *\n * @author Stefan Siegl\n *\n * Copyright 2012 Stefan Siegl \n */\nvar forge = require('./forge');\nrequire('./mgf1');\n\nmodule.exports = forge.mgf = forge.mgf || {};\nforge.mgf.mgf1 = forge.mgf1;\n","/**\n * Javascript implementation of mask generation function MGF1.\n *\n * @author Stefan Siegl\n * @author Dave Longley\n *\n * Copyright (c) 2012 Stefan Siegl \n * Copyright (c) 2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\nforge.mgf = forge.mgf || {};\nvar mgf1 = module.exports = forge.mgf.mgf1 = forge.mgf1 = forge.mgf1 || {};\n\n/**\n * Creates a MGF1 mask generation function object.\n *\n * @param md the message digest API to use (eg: forge.md.sha1.create()).\n *\n * @return a mask generation function object.\n */\nmgf1.create = function(md) {\n var mgf = {\n /**\n * Generate mask of specified length.\n *\n * @param {String} seed The seed for mask generation.\n * @param maskLen Number of bytes to generate.\n * @return {String} The generated mask.\n */\n generate: function(seed, maskLen) {\n /* 2. Let T be the empty octet string. */\n var t = new forge.util.ByteBuffer();\n\n /* 3. For counter from 0 to ceil(maskLen / hLen), do the following: */\n var len = Math.ceil(maskLen / md.digestLength);\n for(var i = 0; i < len; i++) {\n /* a. Convert counter to an octet string C of length 4 octets */\n var c = new forge.util.ByteBuffer();\n c.putInt32(i);\n\n /* b. Concatenate the hash of the seed mgfSeed and C to the octet\n * string T: */\n md.start();\n md.update(seed + c.getBytes());\n t.putBuffer(md.digest());\n }\n\n /* Output the leading maskLen octets of T as the octet string mask. */\n t.truncate(t.length() - maskLen);\n return t.getBytes();\n }\n };\n\n return mgf;\n};\n","/**\n * Object IDs for ASN.1.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\n\nforge.pki = forge.pki || {};\nvar oids = module.exports = forge.pki.oids = forge.oids = forge.oids || {};\n\n// set id to name mapping and name to id mapping\nfunction _IN(id, name) {\n oids[id] = name;\n oids[name] = id;\n}\n// set id to name mapping only\nfunction _I_(id, name) {\n oids[id] = name;\n}\n\n// algorithm OIDs\n_IN('1.2.840.113549.1.1.1', 'rsaEncryption');\n// Note: md2 & md4 not implemented\n//_IN('1.2.840.113549.1.1.2', 'md2WithRSAEncryption');\n//_IN('1.2.840.113549.1.1.3', 'md4WithRSAEncryption');\n_IN('1.2.840.113549.1.1.4', 'md5WithRSAEncryption');\n_IN('1.2.840.113549.1.1.5', 'sha1WithRSAEncryption');\n_IN('1.2.840.113549.1.1.7', 'RSAES-OAEP');\n_IN('1.2.840.113549.1.1.8', 'mgf1');\n_IN('1.2.840.113549.1.1.9', 'pSpecified');\n_IN('1.2.840.113549.1.1.10', 'RSASSA-PSS');\n_IN('1.2.840.113549.1.1.11', 'sha256WithRSAEncryption');\n_IN('1.2.840.113549.1.1.12', 'sha384WithRSAEncryption');\n_IN('1.2.840.113549.1.1.13', 'sha512WithRSAEncryption');\n// Edwards-curve Digital Signature Algorithm (EdDSA) Ed25519\n_IN('1.3.101.112', 'EdDSA25519');\n\n_IN('1.2.840.10040.4.3', 'dsa-with-sha1');\n\n_IN('1.3.14.3.2.7', 'desCBC');\n\n_IN('1.3.14.3.2.26', 'sha1');\n_IN('2.16.840.1.101.3.4.2.1', 'sha256');\n_IN('2.16.840.1.101.3.4.2.2', 'sha384');\n_IN('2.16.840.1.101.3.4.2.3', 'sha512');\n_IN('1.2.840.113549.2.5', 'md5');\n\n// pkcs#7 content types\n_IN('1.2.840.113549.1.7.1', 'data');\n_IN('1.2.840.113549.1.7.2', 'signedData');\n_IN('1.2.840.113549.1.7.3', 'envelopedData');\n_IN('1.2.840.113549.1.7.4', 'signedAndEnvelopedData');\n_IN('1.2.840.113549.1.7.5', 'digestedData');\n_IN('1.2.840.113549.1.7.6', 'encryptedData');\n\n// pkcs#9 oids\n_IN('1.2.840.113549.1.9.1', 'emailAddress');\n_IN('1.2.840.113549.1.9.2', 'unstructuredName');\n_IN('1.2.840.113549.1.9.3', 'contentType');\n_IN('1.2.840.113549.1.9.4', 'messageDigest');\n_IN('1.2.840.113549.1.9.5', 'signingTime');\n_IN('1.2.840.113549.1.9.6', 'counterSignature');\n_IN('1.2.840.113549.1.9.7', 'challengePassword');\n_IN('1.2.840.113549.1.9.8', 'unstructuredAddress');\n_IN('1.2.840.113549.1.9.14', 'extensionRequest');\n\n_IN('1.2.840.113549.1.9.20', 'friendlyName');\n_IN('1.2.840.113549.1.9.21', 'localKeyId');\n_IN('1.2.840.113549.1.9.22.1', 'x509Certificate');\n\n// pkcs#12 safe bags\n_IN('1.2.840.113549.1.12.10.1.1', 'keyBag');\n_IN('1.2.840.113549.1.12.10.1.2', 'pkcs8ShroudedKeyBag');\n_IN('1.2.840.113549.1.12.10.1.3', 'certBag');\n_IN('1.2.840.113549.1.12.10.1.4', 'crlBag');\n_IN('1.2.840.113549.1.12.10.1.5', 'secretBag');\n_IN('1.2.840.113549.1.12.10.1.6', 'safeContentsBag');\n\n// password-based-encryption for pkcs#12\n_IN('1.2.840.113549.1.5.13', 'pkcs5PBES2');\n_IN('1.2.840.113549.1.5.12', 'pkcs5PBKDF2');\n\n_IN('1.2.840.113549.1.12.1.1', 'pbeWithSHAAnd128BitRC4');\n_IN('1.2.840.113549.1.12.1.2', 'pbeWithSHAAnd40BitRC4');\n_IN('1.2.840.113549.1.12.1.3', 'pbeWithSHAAnd3-KeyTripleDES-CBC');\n_IN('1.2.840.113549.1.12.1.4', 'pbeWithSHAAnd2-KeyTripleDES-CBC');\n_IN('1.2.840.113549.1.12.1.5', 'pbeWithSHAAnd128BitRC2-CBC');\n_IN('1.2.840.113549.1.12.1.6', 'pbewithSHAAnd40BitRC2-CBC');\n\n// hmac OIDs\n_IN('1.2.840.113549.2.7', 'hmacWithSHA1');\n_IN('1.2.840.113549.2.8', 'hmacWithSHA224');\n_IN('1.2.840.113549.2.9', 'hmacWithSHA256');\n_IN('1.2.840.113549.2.10', 'hmacWithSHA384');\n_IN('1.2.840.113549.2.11', 'hmacWithSHA512');\n\n// symmetric key algorithm oids\n_IN('1.2.840.113549.3.7', 'des-EDE3-CBC');\n_IN('2.16.840.1.101.3.4.1.2', 'aes128-CBC');\n_IN('2.16.840.1.101.3.4.1.22', 'aes192-CBC');\n_IN('2.16.840.1.101.3.4.1.42', 'aes256-CBC');\n\n// certificate issuer/subject OIDs\n_IN('2.5.4.3', 'commonName');\n_IN('2.5.4.5', 'serialName');\n_IN('2.5.4.6', 'countryName');\n_IN('2.5.4.7', 'localityName');\n_IN('2.5.4.8', 'stateOrProvinceName');\n_IN('2.5.4.9', 'streetAddress');\n_IN('2.5.4.10', 'organizationName');\n_IN('2.5.4.11', 'organizationalUnitName');\n_IN('2.5.4.13', 'description');\n_IN('2.5.4.15', 'businessCategory');\n_IN('2.5.4.17', 'postalCode');\n_IN('1.3.6.1.4.1.311.60.2.1.2', 'jurisdictionOfIncorporationStateOrProvinceName');\n_IN('1.3.6.1.4.1.311.60.2.1.3', 'jurisdictionOfIncorporationCountryName');\n\n// X.509 extension OIDs\n_IN('2.16.840.1.113730.1.1', 'nsCertType');\n_IN('2.16.840.1.113730.1.13', 'nsComment'); // deprecated in theory; still widely used\n_I_('2.5.29.1', 'authorityKeyIdentifier'); // deprecated, use .35\n_I_('2.5.29.2', 'keyAttributes'); // obsolete use .37 or .15\n_I_('2.5.29.3', 'certificatePolicies'); // deprecated, use .32\n_I_('2.5.29.4', 'keyUsageRestriction'); // obsolete use .37 or .15\n_I_('2.5.29.5', 'policyMapping'); // deprecated use .33\n_I_('2.5.29.6', 'subtreesConstraint'); // obsolete use .30\n_I_('2.5.29.7', 'subjectAltName'); // deprecated use .17\n_I_('2.5.29.8', 'issuerAltName'); // deprecated use .18\n_I_('2.5.29.9', 'subjectDirectoryAttributes');\n_I_('2.5.29.10', 'basicConstraints'); // deprecated use .19\n_I_('2.5.29.11', 'nameConstraints'); // deprecated use .30\n_I_('2.5.29.12', 'policyConstraints'); // deprecated use .36\n_I_('2.5.29.13', 'basicConstraints'); // deprecated use .19\n_IN('2.5.29.14', 'subjectKeyIdentifier');\n_IN('2.5.29.15', 'keyUsage');\n_I_('2.5.29.16', 'privateKeyUsagePeriod');\n_IN('2.5.29.17', 'subjectAltName');\n_IN('2.5.29.18', 'issuerAltName');\n_IN('2.5.29.19', 'basicConstraints');\n_I_('2.5.29.20', 'cRLNumber');\n_I_('2.5.29.21', 'cRLReason');\n_I_('2.5.29.22', 'expirationDate');\n_I_('2.5.29.23', 'instructionCode');\n_I_('2.5.29.24', 'invalidityDate');\n_I_('2.5.29.25', 'cRLDistributionPoints'); // deprecated use .31\n_I_('2.5.29.26', 'issuingDistributionPoint'); // deprecated use .28\n_I_('2.5.29.27', 'deltaCRLIndicator');\n_I_('2.5.29.28', 'issuingDistributionPoint');\n_I_('2.5.29.29', 'certificateIssuer');\n_I_('2.5.29.30', 'nameConstraints');\n_IN('2.5.29.31', 'cRLDistributionPoints');\n_IN('2.5.29.32', 'certificatePolicies');\n_I_('2.5.29.33', 'policyMappings');\n_I_('2.5.29.34', 'policyConstraints'); // deprecated use .36\n_IN('2.5.29.35', 'authorityKeyIdentifier');\n_I_('2.5.29.36', 'policyConstraints');\n_IN('2.5.29.37', 'extKeyUsage');\n_I_('2.5.29.46', 'freshestCRL');\n_I_('2.5.29.54', 'inhibitAnyPolicy');\n\n// extKeyUsage purposes\n_IN('1.3.6.1.4.1.11129.2.4.2', 'timestampList');\n_IN('1.3.6.1.5.5.7.1.1', 'authorityInfoAccess');\n_IN('1.3.6.1.5.5.7.3.1', 'serverAuth');\n_IN('1.3.6.1.5.5.7.3.2', 'clientAuth');\n_IN('1.3.6.1.5.5.7.3.3', 'codeSigning');\n_IN('1.3.6.1.5.5.7.3.4', 'emailProtection');\n_IN('1.3.6.1.5.5.7.3.8', 'timeStamping');\n","/**\n * Password-based encryption functions.\n *\n * @author Dave Longley\n * @author Stefan Siegl \n *\n * Copyright (c) 2010-2013 Digital Bazaar, Inc.\n * Copyright (c) 2012 Stefan Siegl \n *\n * An EncryptedPrivateKeyInfo:\n *\n * EncryptedPrivateKeyInfo ::= SEQUENCE {\n * encryptionAlgorithm EncryptionAlgorithmIdentifier,\n * encryptedData EncryptedData }\n *\n * EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier\n *\n * EncryptedData ::= OCTET STRING\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./asn1');\nrequire('./des');\nrequire('./md');\nrequire('./oids');\nrequire('./pbkdf2');\nrequire('./pem');\nrequire('./random');\nrequire('./rc2');\nrequire('./rsa');\nrequire('./util');\n\nif(typeof BigInteger === 'undefined') {\n var BigInteger = forge.jsbn.BigInteger;\n}\n\n// shortcut for asn.1 API\nvar asn1 = forge.asn1;\n\n/* Password-based encryption implementation. */\nvar pki = forge.pki = forge.pki || {};\nmodule.exports = pki.pbe = forge.pbe = forge.pbe || {};\nvar oids = pki.oids;\n\n// validator for an EncryptedPrivateKeyInfo structure\n// Note: Currently only works w/algorithm params\nvar encryptedPrivateKeyValidator = {\n name: 'EncryptedPrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EncryptedPrivateKeyInfo.encryptionAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'encryptionOid'\n }, {\n name: 'AlgorithmIdentifier.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'encryptionParams'\n }]\n }, {\n // encryptedData\n name: 'EncryptedPrivateKeyInfo.encryptedData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'encryptedData'\n }]\n};\n\n// validator for a PBES2Algorithms structure\n// Note: Currently only works w/PBKDF2 + AES encryption schemes\nvar PBES2AlgorithmsValidator = {\n name: 'PBES2Algorithms',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PBES2Algorithms.keyDerivationFunc',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PBES2Algorithms.keyDerivationFunc.oid',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'kdfOid'\n }, {\n name: 'PBES2Algorithms.params',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PBES2Algorithms.params.salt',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'kdfSalt'\n }, {\n name: 'PBES2Algorithms.params.iterationCount',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'kdfIterationCount'\n }, {\n name: 'PBES2Algorithms.params.keyLength',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n optional: true,\n capture: 'keyLength'\n }, {\n // prf\n name: 'PBES2Algorithms.params.prf',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n optional: true,\n value: [{\n name: 'PBES2Algorithms.params.prf.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'prfOid'\n }]\n }]\n }]\n }, {\n name: 'PBES2Algorithms.encryptionScheme',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PBES2Algorithms.encryptionScheme.oid',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'encOid'\n }, {\n name: 'PBES2Algorithms.encryptionScheme.iv',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'encIv'\n }]\n }]\n};\n\nvar pkcs12PbeParamsValidator = {\n name: 'pkcs-12PbeParams',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'pkcs-12PbeParams.salt',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'salt'\n }, {\n name: 'pkcs-12PbeParams.iterations',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'iterations'\n }]\n};\n\n/**\n * Encrypts a ASN.1 PrivateKeyInfo object, producing an EncryptedPrivateKeyInfo.\n *\n * PBES2Algorithms ALGORITHM-IDENTIFIER ::=\n * { {PBES2-params IDENTIFIED BY id-PBES2}, ...}\n *\n * id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13}\n *\n * PBES2-params ::= SEQUENCE {\n * keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},\n * encryptionScheme AlgorithmIdentifier {{PBES2-Encs}}\n * }\n *\n * PBES2-KDFs ALGORITHM-IDENTIFIER ::=\n * { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ... }\n *\n * PBES2-Encs ALGORITHM-IDENTIFIER ::= { ... }\n *\n * PBKDF2-params ::= SEQUENCE {\n * salt CHOICE {\n * specified OCTET STRING,\n * otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}}\n * },\n * iterationCount INTEGER (1..MAX),\n * keyLength INTEGER (1..MAX) OPTIONAL,\n * prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1\n * }\n *\n * @param obj the ASN.1 PrivateKeyInfo object.\n * @param password the password to encrypt with.\n * @param options:\n * algorithm the encryption algorithm to use\n * ('aes128', 'aes192', 'aes256', '3des'), defaults to 'aes128'.\n * count the iteration count to use.\n * saltSize the salt size to use.\n * prfAlgorithm the PRF message digest algorithm to use\n * ('sha1', 'sha224', 'sha256', 'sha384', 'sha512')\n *\n * @return the ASN.1 EncryptedPrivateKeyInfo.\n */\npki.encryptPrivateKeyInfo = function(obj, password, options) {\n // set default options\n options = options || {};\n options.saltSize = options.saltSize || 8;\n options.count = options.count || 2048;\n options.algorithm = options.algorithm || 'aes128';\n options.prfAlgorithm = options.prfAlgorithm || 'sha1';\n\n // generate PBE params\n var salt = forge.random.getBytesSync(options.saltSize);\n var count = options.count;\n var countBytes = asn1.integerToDer(count);\n var dkLen;\n var encryptionAlgorithm;\n var encryptedData;\n if(options.algorithm.indexOf('aes') === 0 || options.algorithm === 'des') {\n // do PBES2\n var ivLen, encOid, cipherFn;\n switch(options.algorithm) {\n case 'aes128':\n dkLen = 16;\n ivLen = 16;\n encOid = oids['aes128-CBC'];\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'aes192':\n dkLen = 24;\n ivLen = 16;\n encOid = oids['aes192-CBC'];\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'aes256':\n dkLen = 32;\n ivLen = 16;\n encOid = oids['aes256-CBC'];\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'des':\n dkLen = 8;\n ivLen = 8;\n encOid = oids['desCBC'];\n cipherFn = forge.des.createEncryptionCipher;\n break;\n default:\n var error = new Error('Cannot encrypt private key. Unknown encryption algorithm.');\n error.algorithm = options.algorithm;\n throw error;\n }\n\n // get PRF message digest\n var prfAlgorithm = 'hmacWith' + options.prfAlgorithm.toUpperCase();\n var md = prfAlgorithmToMessageDigest(prfAlgorithm);\n\n // encrypt private key using pbe SHA-1 and AES/DES\n var dk = forge.pkcs5.pbkdf2(password, salt, count, dkLen, md);\n var iv = forge.random.getBytesSync(ivLen);\n var cipher = cipherFn(dk);\n cipher.start(iv);\n cipher.update(asn1.toDer(obj));\n cipher.finish();\n encryptedData = cipher.output.getBytes();\n\n // get PBKDF2-params\n var params = createPbkdf2Params(salt, countBytes, dkLen, prfAlgorithm);\n\n encryptionAlgorithm = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(oids['pkcs5PBES2']).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // keyDerivationFunc\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(oids['pkcs5PBKDF2']).getBytes()),\n // PBKDF2-params\n params\n ]),\n // encryptionScheme\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(encOid).getBytes()),\n // iv\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, iv)\n ])\n ])\n ]);\n } else if(options.algorithm === '3des') {\n // Do PKCS12 PBE\n dkLen = 24;\n\n var saltBytes = new forge.util.ByteBuffer(salt);\n var dk = pki.pbe.generatePkcs12Key(password, saltBytes, 1, count, dkLen);\n var iv = pki.pbe.generatePkcs12Key(password, saltBytes, 2, count, dkLen);\n var cipher = forge.des.createEncryptionCipher(dk);\n cipher.start(iv);\n cipher.update(asn1.toDer(obj));\n cipher.finish();\n encryptedData = cipher.output.getBytes();\n\n encryptionAlgorithm = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(oids['pbeWithSHAAnd3-KeyTripleDES-CBC']).getBytes()),\n // pkcs-12PbeParams\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // salt\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, salt),\n // iteration count\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n countBytes.getBytes())\n ])\n ]);\n } else {\n var error = new Error('Cannot encrypt private key. Unknown encryption algorithm.');\n error.algorithm = options.algorithm;\n throw error;\n }\n\n // EncryptedPrivateKeyInfo\n var rval = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // encryptionAlgorithm\n encryptionAlgorithm,\n // encryptedData\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, encryptedData)\n ]);\n return rval;\n};\n\n/**\n * Decrypts a ASN.1 PrivateKeyInfo object.\n *\n * @param obj the ASN.1 EncryptedPrivateKeyInfo object.\n * @param password the password to decrypt with.\n *\n * @return the ASN.1 PrivateKeyInfo on success, null on failure.\n */\npki.decryptPrivateKeyInfo = function(obj, password) {\n var rval = null;\n\n // get PBE params\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, encryptedPrivateKeyValidator, capture, errors)) {\n var error = new Error('Cannot read encrypted private key. ' +\n 'ASN.1 object is not a supported EncryptedPrivateKeyInfo.');\n error.errors = errors;\n throw error;\n }\n\n // get cipher\n var oid = asn1.derToOid(capture.encryptionOid);\n var cipher = pki.pbe.getCipher(oid, capture.encryptionParams, password);\n\n // get encrypted data\n var encrypted = forge.util.createBuffer(capture.encryptedData);\n\n cipher.update(encrypted);\n if(cipher.finish()) {\n rval = asn1.fromDer(cipher.output);\n }\n\n return rval;\n};\n\n/**\n * Converts a EncryptedPrivateKeyInfo to PEM format.\n *\n * @param epki the EncryptedPrivateKeyInfo.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted encrypted private key.\n */\npki.encryptedPrivateKeyToPem = function(epki, maxline) {\n // convert to DER, then PEM-encode\n var msg = {\n type: 'ENCRYPTED PRIVATE KEY',\n body: asn1.toDer(epki).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Converts a PEM-encoded EncryptedPrivateKeyInfo to ASN.1 format. Decryption\n * is not performed.\n *\n * @param pem the EncryptedPrivateKeyInfo in PEM-format.\n *\n * @return the ASN.1 EncryptedPrivateKeyInfo.\n */\npki.encryptedPrivateKeyFromPem = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'ENCRYPTED PRIVATE KEY') {\n var error = new Error('Could not convert encrypted private key from PEM; ' +\n 'PEM header type is \"ENCRYPTED PRIVATE KEY\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert encrypted private key from PEM; ' +\n 'PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n return asn1.fromDer(msg.body);\n};\n\n/**\n * Encrypts an RSA private key. By default, the key will be wrapped in\n * a PrivateKeyInfo and encrypted to produce a PKCS#8 EncryptedPrivateKeyInfo.\n * This is the standard, preferred way to encrypt a private key.\n *\n * To produce a non-standard PEM-encrypted private key that uses encapsulated\n * headers to indicate the encryption algorithm (old-style non-PKCS#8 OpenSSL\n * private key encryption), set the 'legacy' option to true. Note: Using this\n * option will cause the iteration count to be forced to 1.\n *\n * Note: The 'des' algorithm is supported, but it is not considered to be\n * secure because it only uses a single 56-bit key. If possible, it is highly\n * recommended that a different algorithm be used.\n *\n * @param rsaKey the RSA key to encrypt.\n * @param password the password to use.\n * @param options:\n * algorithm: the encryption algorithm to use\n * ('aes128', 'aes192', 'aes256', '3des', 'des').\n * count: the iteration count to use.\n * saltSize: the salt size to use.\n * legacy: output an old non-PKCS#8 PEM-encrypted+encapsulated\n * headers (DEK-Info) private key.\n *\n * @return the PEM-encoded ASN.1 EncryptedPrivateKeyInfo.\n */\npki.encryptRsaPrivateKey = function(rsaKey, password, options) {\n // standard PKCS#8\n options = options || {};\n if(!options.legacy) {\n // encrypt PrivateKeyInfo\n var rval = pki.wrapRsaPrivateKey(pki.privateKeyToAsn1(rsaKey));\n rval = pki.encryptPrivateKeyInfo(rval, password, options);\n return pki.encryptedPrivateKeyToPem(rval);\n }\n\n // legacy non-PKCS#8\n var algorithm;\n var iv;\n var dkLen;\n var cipherFn;\n switch(options.algorithm) {\n case 'aes128':\n algorithm = 'AES-128-CBC';\n dkLen = 16;\n iv = forge.random.getBytesSync(16);\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'aes192':\n algorithm = 'AES-192-CBC';\n dkLen = 24;\n iv = forge.random.getBytesSync(16);\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case 'aes256':\n algorithm = 'AES-256-CBC';\n dkLen = 32;\n iv = forge.random.getBytesSync(16);\n cipherFn = forge.aes.createEncryptionCipher;\n break;\n case '3des':\n algorithm = 'DES-EDE3-CBC';\n dkLen = 24;\n iv = forge.random.getBytesSync(8);\n cipherFn = forge.des.createEncryptionCipher;\n break;\n case 'des':\n algorithm = 'DES-CBC';\n dkLen = 8;\n iv = forge.random.getBytesSync(8);\n cipherFn = forge.des.createEncryptionCipher;\n break;\n default:\n var error = new Error('Could not encrypt RSA private key; unsupported ' +\n 'encryption algorithm \"' + options.algorithm + '\".');\n error.algorithm = options.algorithm;\n throw error;\n }\n\n // encrypt private key using OpenSSL legacy key derivation\n var dk = forge.pbe.opensslDeriveBytes(password, iv.substr(0, 8), dkLen);\n var cipher = cipherFn(dk);\n cipher.start(iv);\n cipher.update(asn1.toDer(pki.privateKeyToAsn1(rsaKey)));\n cipher.finish();\n\n var msg = {\n type: 'RSA PRIVATE KEY',\n procType: {\n version: '4',\n type: 'ENCRYPTED'\n },\n dekInfo: {\n algorithm: algorithm,\n parameters: forge.util.bytesToHex(iv).toUpperCase()\n },\n body: cipher.output.getBytes()\n };\n return forge.pem.encode(msg);\n};\n\n/**\n * Decrypts an RSA private key.\n *\n * @param pem the PEM-formatted EncryptedPrivateKeyInfo to decrypt.\n * @param password the password to use.\n *\n * @return the RSA key on success, null on failure.\n */\npki.decryptRsaPrivateKey = function(pem, password) {\n var rval = null;\n\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'ENCRYPTED PRIVATE KEY' &&\n msg.type !== 'PRIVATE KEY' &&\n msg.type !== 'RSA PRIVATE KEY') {\n var error = new Error('Could not convert private key from PEM; PEM header type ' +\n 'is not \"ENCRYPTED PRIVATE KEY\", \"PRIVATE KEY\", or \"RSA PRIVATE KEY\".');\n error.headerType = error;\n throw error;\n }\n\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n var dkLen;\n var cipherFn;\n switch(msg.dekInfo.algorithm) {\n case 'DES-CBC':\n dkLen = 8;\n cipherFn = forge.des.createDecryptionCipher;\n break;\n case 'DES-EDE3-CBC':\n dkLen = 24;\n cipherFn = forge.des.createDecryptionCipher;\n break;\n case 'AES-128-CBC':\n dkLen = 16;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'AES-192-CBC':\n dkLen = 24;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'AES-256-CBC':\n dkLen = 32;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'RC2-40-CBC':\n dkLen = 5;\n cipherFn = function(key) {\n return forge.rc2.createDecryptionCipher(key, 40);\n };\n break;\n case 'RC2-64-CBC':\n dkLen = 8;\n cipherFn = function(key) {\n return forge.rc2.createDecryptionCipher(key, 64);\n };\n break;\n case 'RC2-128-CBC':\n dkLen = 16;\n cipherFn = function(key) {\n return forge.rc2.createDecryptionCipher(key, 128);\n };\n break;\n default:\n var error = new Error('Could not decrypt private key; unsupported ' +\n 'encryption algorithm \"' + msg.dekInfo.algorithm + '\".');\n error.algorithm = msg.dekInfo.algorithm;\n throw error;\n }\n\n // use OpenSSL legacy key derivation\n var iv = forge.util.hexToBytes(msg.dekInfo.parameters);\n var dk = forge.pbe.opensslDeriveBytes(password, iv.substr(0, 8), dkLen);\n var cipher = cipherFn(dk);\n cipher.start(iv);\n cipher.update(forge.util.createBuffer(msg.body));\n if(cipher.finish()) {\n rval = cipher.output.getBytes();\n } else {\n return rval;\n }\n } else {\n rval = msg.body;\n }\n\n if(msg.type === 'ENCRYPTED PRIVATE KEY') {\n rval = pki.decryptPrivateKeyInfo(asn1.fromDer(rval), password);\n } else {\n // decryption already performed above\n rval = asn1.fromDer(rval);\n }\n\n if(rval !== null) {\n rval = pki.privateKeyFromAsn1(rval);\n }\n\n return rval;\n};\n\n/**\n * Derives a PKCS#12 key.\n *\n * @param password the password to derive the key material from, null or\n * undefined for none.\n * @param salt the salt, as a ByteBuffer, to use.\n * @param id the PKCS#12 ID byte (1 = key material, 2 = IV, 3 = MAC).\n * @param iter the iteration count.\n * @param n the number of bytes to derive from the password.\n * @param md the message digest to use, defaults to SHA-1.\n *\n * @return a ByteBuffer with the bytes derived from the password.\n */\npki.pbe.generatePkcs12Key = function(password, salt, id, iter, n, md) {\n var j, l;\n\n if(typeof md === 'undefined' || md === null) {\n if(!('sha1' in forge.md)) {\n throw new Error('\"sha1\" hash algorithm unavailable.');\n }\n md = forge.md.sha1.create();\n }\n\n var u = md.digestLength;\n var v = md.blockLength;\n var result = new forge.util.ByteBuffer();\n\n /* Convert password to Unicode byte buffer + trailing 0-byte. */\n var passBuf = new forge.util.ByteBuffer();\n if(password !== null && password !== undefined) {\n for(l = 0; l < password.length; l++) {\n passBuf.putInt16(password.charCodeAt(l));\n }\n passBuf.putInt16(0);\n }\n\n /* Length of salt and password in BYTES. */\n var p = passBuf.length();\n var s = salt.length();\n\n /* 1. Construct a string, D (the \"diversifier\"), by concatenating\n v copies of ID. */\n var D = new forge.util.ByteBuffer();\n D.fillWithByte(id, v);\n\n /* 2. Concatenate copies of the salt together to create a string S of length\n v * ceil(s / v) bytes (the final copy of the salt may be trunacted\n to create S).\n Note that if the salt is the empty string, then so is S. */\n var Slen = v * Math.ceil(s / v);\n var S = new forge.util.ByteBuffer();\n for(l = 0; l < Slen; l++) {\n S.putByte(salt.at(l % s));\n }\n\n /* 3. Concatenate copies of the password together to create a string P of\n length v * ceil(p / v) bytes (the final copy of the password may be\n truncated to create P).\n Note that if the password is the empty string, then so is P. */\n var Plen = v * Math.ceil(p / v);\n var P = new forge.util.ByteBuffer();\n for(l = 0; l < Plen; l++) {\n P.putByte(passBuf.at(l % p));\n }\n\n /* 4. Set I=S||P to be the concatenation of S and P. */\n var I = S;\n I.putBuffer(P);\n\n /* 5. Set c=ceil(n / u). */\n var c = Math.ceil(n / u);\n\n /* 6. For i=1, 2, ..., c, do the following: */\n for(var i = 1; i <= c; i++) {\n /* a) Set Ai=H^r(D||I). (l.e. the rth hash of D||I, H(H(H(...H(D||I)))) */\n var buf = new forge.util.ByteBuffer();\n buf.putBytes(D.bytes());\n buf.putBytes(I.bytes());\n for(var round = 0; round < iter; round++) {\n md.start();\n md.update(buf.getBytes());\n buf = md.digest();\n }\n\n /* b) Concatenate copies of Ai to create a string B of length v bytes (the\n final copy of Ai may be truncated to create B). */\n var B = new forge.util.ByteBuffer();\n for(l = 0; l < v; l++) {\n B.putByte(buf.at(l % u));\n }\n\n /* c) Treating I as a concatenation I0, I1, ..., Ik-1 of v-byte blocks,\n where k=ceil(s / v) + ceil(p / v), modify I by setting\n Ij=(Ij+B+1) mod 2v for each j. */\n var k = Math.ceil(s / v) + Math.ceil(p / v);\n var Inew = new forge.util.ByteBuffer();\n for(j = 0; j < k; j++) {\n var chunk = new forge.util.ByteBuffer(I.getBytes(v));\n var x = 0x1ff;\n for(l = B.length() - 1; l >= 0; l--) {\n x = x >> 8;\n x += B.at(l) + chunk.at(l);\n chunk.setAt(l, x & 0xff);\n }\n Inew.putBuffer(chunk);\n }\n I = Inew;\n\n /* Add Ai to A. */\n result.putBuffer(buf);\n }\n\n result.truncate(result.length() - n);\n return result;\n};\n\n/**\n * Get new Forge cipher object instance.\n *\n * @param oid the OID (in string notation).\n * @param params the ASN.1 params object.\n * @param password the password to decrypt with.\n *\n * @return new cipher object instance.\n */\npki.pbe.getCipher = function(oid, params, password) {\n switch(oid) {\n case pki.oids['pkcs5PBES2']:\n return pki.pbe.getCipherForPBES2(oid, params, password);\n\n case pki.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:\n case pki.oids['pbewithSHAAnd40BitRC2-CBC']:\n return pki.pbe.getCipherForPKCS12PBE(oid, params, password);\n\n default:\n var error = new Error('Cannot read encrypted PBE data block. Unsupported OID.');\n error.oid = oid;\n error.supportedOids = [\n 'pkcs5PBES2',\n 'pbeWithSHAAnd3-KeyTripleDES-CBC',\n 'pbewithSHAAnd40BitRC2-CBC'\n ];\n throw error;\n }\n};\n\n/**\n * Get new Forge cipher object instance according to PBES2 params block.\n *\n * The returned cipher instance is already started using the IV\n * from PBES2 parameter block.\n *\n * @param oid the PKCS#5 PBKDF2 OID (in string notation).\n * @param params the ASN.1 PBES2-params object.\n * @param password the password to decrypt with.\n *\n * @return new cipher object instance.\n */\npki.pbe.getCipherForPBES2 = function(oid, params, password) {\n // get PBE params\n var capture = {};\n var errors = [];\n if(!asn1.validate(params, PBES2AlgorithmsValidator, capture, errors)) {\n var error = new Error('Cannot read password-based-encryption algorithm ' +\n 'parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.');\n error.errors = errors;\n throw error;\n }\n\n // check oids\n oid = asn1.derToOid(capture.kdfOid);\n if(oid !== pki.oids['pkcs5PBKDF2']) {\n var error = new Error('Cannot read encrypted private key. ' +\n 'Unsupported key derivation function OID.');\n error.oid = oid;\n error.supportedOids = ['pkcs5PBKDF2'];\n throw error;\n }\n oid = asn1.derToOid(capture.encOid);\n if(oid !== pki.oids['aes128-CBC'] &&\n oid !== pki.oids['aes192-CBC'] &&\n oid !== pki.oids['aes256-CBC'] &&\n oid !== pki.oids['des-EDE3-CBC'] &&\n oid !== pki.oids['desCBC']) {\n var error = new Error('Cannot read encrypted private key. ' +\n 'Unsupported encryption scheme OID.');\n error.oid = oid;\n error.supportedOids = [\n 'aes128-CBC', 'aes192-CBC', 'aes256-CBC', 'des-EDE3-CBC', 'desCBC'];\n throw error;\n }\n\n // set PBE params\n var salt = capture.kdfSalt;\n var count = forge.util.createBuffer(capture.kdfIterationCount);\n count = count.getInt(count.length() << 3);\n var dkLen;\n var cipherFn;\n switch(pki.oids[oid]) {\n case 'aes128-CBC':\n dkLen = 16;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'aes192-CBC':\n dkLen = 24;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'aes256-CBC':\n dkLen = 32;\n cipherFn = forge.aes.createDecryptionCipher;\n break;\n case 'des-EDE3-CBC':\n dkLen = 24;\n cipherFn = forge.des.createDecryptionCipher;\n break;\n case 'desCBC':\n dkLen = 8;\n cipherFn = forge.des.createDecryptionCipher;\n break;\n }\n\n // get PRF message digest\n var md = prfOidToMessageDigest(capture.prfOid);\n\n // decrypt private key using pbe with chosen PRF and AES/DES\n var dk = forge.pkcs5.pbkdf2(password, salt, count, dkLen, md);\n var iv = capture.encIv;\n var cipher = cipherFn(dk);\n cipher.start(iv);\n\n return cipher;\n};\n\n/**\n * Get new Forge cipher object instance for PKCS#12 PBE.\n *\n * The returned cipher instance is already started using the key & IV\n * derived from the provided password and PKCS#12 PBE salt.\n *\n * @param oid The PKCS#12 PBE OID (in string notation).\n * @param params The ASN.1 PKCS#12 PBE-params object.\n * @param password The password to decrypt with.\n *\n * @return the new cipher object instance.\n */\npki.pbe.getCipherForPKCS12PBE = function(oid, params, password) {\n // get PBE params\n var capture = {};\n var errors = [];\n if(!asn1.validate(params, pkcs12PbeParamsValidator, capture, errors)) {\n var error = new Error('Cannot read password-based-encryption algorithm ' +\n 'parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.');\n error.errors = errors;\n throw error;\n }\n\n var salt = forge.util.createBuffer(capture.salt);\n var count = forge.util.createBuffer(capture.iterations);\n count = count.getInt(count.length() << 3);\n\n var dkLen, dIvLen, cipherFn;\n switch(oid) {\n case pki.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:\n dkLen = 24;\n dIvLen = 8;\n cipherFn = forge.des.startDecrypting;\n break;\n\n case pki.oids['pbewithSHAAnd40BitRC2-CBC']:\n dkLen = 5;\n dIvLen = 8;\n cipherFn = function(key, iv) {\n var cipher = forge.rc2.createDecryptionCipher(key, 40);\n cipher.start(iv, null);\n return cipher;\n };\n break;\n\n default:\n var error = new Error('Cannot read PKCS #12 PBE data block. Unsupported OID.');\n error.oid = oid;\n throw error;\n }\n\n // get PRF message digest\n var md = prfOidToMessageDigest(capture.prfOid);\n var key = pki.pbe.generatePkcs12Key(password, salt, 1, count, dkLen, md);\n md.start();\n var iv = pki.pbe.generatePkcs12Key(password, salt, 2, count, dIvLen, md);\n\n return cipherFn(key, iv);\n};\n\n/**\n * OpenSSL's legacy key derivation function.\n *\n * See: http://www.openssl.org/docs/crypto/EVP_BytesToKey.html\n *\n * @param password the password to derive the key from.\n * @param salt the salt to use, null for none.\n * @param dkLen the number of bytes needed for the derived key.\n * @param [options] the options to use:\n * [md] an optional message digest object to use.\n */\npki.pbe.opensslDeriveBytes = function(password, salt, dkLen, md) {\n if(typeof md === 'undefined' || md === null) {\n if(!('md5' in forge.md)) {\n throw new Error('\"md5\" hash algorithm unavailable.');\n }\n md = forge.md.md5.create();\n }\n if(salt === null) {\n salt = '';\n }\n var digests = [hash(md, password + salt)];\n for(var length = 16, i = 1; length < dkLen; ++i, length += 16) {\n digests.push(hash(md, digests[i - 1] + password + salt));\n }\n return digests.join('').substr(0, dkLen);\n};\n\nfunction hash(md, bytes) {\n return md.start().update(bytes).digest().getBytes();\n}\n\nfunction prfOidToMessageDigest(prfOid) {\n // get PRF algorithm, default to SHA-1\n var prfAlgorithm;\n if(!prfOid) {\n prfAlgorithm = 'hmacWithSHA1';\n } else {\n prfAlgorithm = pki.oids[asn1.derToOid(prfOid)];\n if(!prfAlgorithm) {\n var error = new Error('Unsupported PRF OID.');\n error.oid = prfOid;\n error.supported = [\n 'hmacWithSHA1', 'hmacWithSHA224', 'hmacWithSHA256', 'hmacWithSHA384',\n 'hmacWithSHA512'];\n throw error;\n }\n }\n return prfAlgorithmToMessageDigest(prfAlgorithm);\n}\n\nfunction prfAlgorithmToMessageDigest(prfAlgorithm) {\n var factory = forge.md;\n switch(prfAlgorithm) {\n case 'hmacWithSHA224':\n factory = forge.md.sha512;\n case 'hmacWithSHA1':\n case 'hmacWithSHA256':\n case 'hmacWithSHA384':\n case 'hmacWithSHA512':\n prfAlgorithm = prfAlgorithm.substr(8).toLowerCase();\n break;\n default:\n var error = new Error('Unsupported PRF algorithm.');\n error.algorithm = prfAlgorithm;\n error.supported = [\n 'hmacWithSHA1', 'hmacWithSHA224', 'hmacWithSHA256', 'hmacWithSHA384',\n 'hmacWithSHA512'];\n throw error;\n }\n if(!factory || !(prfAlgorithm in factory)) {\n throw new Error('Unknown hash algorithm: ' + prfAlgorithm);\n }\n return factory[prfAlgorithm].create();\n}\n\nfunction createPbkdf2Params(salt, countBytes, dkLen, prfAlgorithm) {\n var params = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // salt\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, salt),\n // iteration count\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n countBytes.getBytes())\n ]);\n // when PRF algorithm is not SHA-1 default, add key length and PRF algorithm\n if(prfAlgorithm !== 'hmacWithSHA1') {\n params.value.push(\n // key length\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n forge.util.hexToBytes(dkLen.toString(16))),\n // AlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids[prfAlgorithm]).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]));\n }\n return params;\n}\n","/**\n * Password-Based Key-Derivation Function #2 implementation.\n *\n * See RFC 2898 for details.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./hmac');\nrequire('./md');\nrequire('./util');\n\nvar pkcs5 = forge.pkcs5 = forge.pkcs5 || {};\n\nvar crypto;\nif(forge.util.isNodejs && !forge.options.usePureJavaScript) {\n crypto = require('crypto');\n}\n\n/**\n * Derives a key from a password.\n *\n * @param p the password as a binary-encoded string of bytes.\n * @param s the salt as a binary-encoded string of bytes.\n * @param c the iteration count, a positive integer.\n * @param dkLen the intended length, in bytes, of the derived key,\n * (max: 2^32 - 1) * hash length of the PRF.\n * @param [md] the message digest (or algorithm identifier as a string) to use\n * in the PRF, defaults to SHA-1.\n * @param [callback(err, key)] presence triggers asynchronous version, called\n * once the operation completes.\n *\n * @return the derived key, as a binary-encoded string of bytes, for the\n * synchronous version (if no callback is specified).\n */\nmodule.exports = forge.pbkdf2 = pkcs5.pbkdf2 = function(\n p, s, c, dkLen, md, callback) {\n if(typeof md === 'function') {\n callback = md;\n md = null;\n }\n\n // use native implementation if possible and not disabled, note that\n // some node versions only support SHA-1, others allow digest to be changed\n if(forge.util.isNodejs && !forge.options.usePureJavaScript &&\n crypto.pbkdf2 && (md === null || typeof md !== 'object') &&\n (crypto.pbkdf2Sync.length > 4 || (!md || md === 'sha1'))) {\n if(typeof md !== 'string') {\n // default prf to SHA-1\n md = 'sha1';\n }\n p = Buffer.from(p, 'binary');\n s = Buffer.from(s, 'binary');\n if(!callback) {\n if(crypto.pbkdf2Sync.length === 4) {\n return crypto.pbkdf2Sync(p, s, c, dkLen).toString('binary');\n }\n return crypto.pbkdf2Sync(p, s, c, dkLen, md).toString('binary');\n }\n if(crypto.pbkdf2Sync.length === 4) {\n return crypto.pbkdf2(p, s, c, dkLen, function(err, key) {\n if(err) {\n return callback(err);\n }\n callback(null, key.toString('binary'));\n });\n }\n return crypto.pbkdf2(p, s, c, dkLen, md, function(err, key) {\n if(err) {\n return callback(err);\n }\n callback(null, key.toString('binary'));\n });\n }\n\n if(typeof md === 'undefined' || md === null) {\n // default prf to SHA-1\n md = 'sha1';\n }\n if(typeof md === 'string') {\n if(!(md in forge.md.algorithms)) {\n throw new Error('Unknown hash algorithm: ' + md);\n }\n md = forge.md[md].create();\n }\n\n var hLen = md.digestLength;\n\n /* 1. If dkLen > (2^32 - 1) * hLen, output \"derived key too long\" and\n stop. */\n if(dkLen > (0xFFFFFFFF * hLen)) {\n var err = new Error('Derived key is too long.');\n if(callback) {\n return callback(err);\n }\n throw err;\n }\n\n /* 2. Let len be the number of hLen-octet blocks in the derived key,\n rounding up, and let r be the number of octets in the last\n block:\n\n len = CEIL(dkLen / hLen),\n r = dkLen - (len - 1) * hLen. */\n var len = Math.ceil(dkLen / hLen);\n var r = dkLen - (len - 1) * hLen;\n\n /* 3. For each block of the derived key apply the function F defined\n below to the password P, the salt S, the iteration count c, and\n the block index to compute the block:\n\n T_1 = F(P, S, c, 1),\n T_2 = F(P, S, c, 2),\n ...\n T_len = F(P, S, c, len),\n\n where the function F is defined as the exclusive-or sum of the\n first c iterates of the underlying pseudorandom function PRF\n applied to the password P and the concatenation of the salt S\n and the block index i:\n\n F(P, S, c, i) = u_1 XOR u_2 XOR ... XOR u_c\n\n where\n\n u_1 = PRF(P, S || INT(i)),\n u_2 = PRF(P, u_1),\n ...\n u_c = PRF(P, u_{c-1}).\n\n Here, INT(i) is a four-octet encoding of the integer i, most\n significant octet first. */\n var prf = forge.hmac.create();\n prf.start(md, p);\n var dk = '';\n var xor, u_c, u_c1;\n\n // sync version\n if(!callback) {\n for(var i = 1; i <= len; ++i) {\n // PRF(P, S || INT(i)) (first iteration)\n prf.start(null, null);\n prf.update(s);\n prf.update(forge.util.int32ToBytes(i));\n xor = u_c1 = prf.digest().getBytes();\n\n // PRF(P, u_{c-1}) (other iterations)\n for(var j = 2; j <= c; ++j) {\n prf.start(null, null);\n prf.update(u_c1);\n u_c = prf.digest().getBytes();\n // F(p, s, c, i)\n xor = forge.util.xorBytes(xor, u_c, hLen);\n u_c1 = u_c;\n }\n\n /* 4. Concatenate the blocks and extract the first dkLen octets to\n produce a derived key DK:\n\n DK = T_1 || T_2 || ... || T_len<0..r-1> */\n dk += (i < len) ? xor : xor.substr(0, r);\n }\n /* 5. Output the derived key DK. */\n return dk;\n }\n\n // async version\n var i = 1, j;\n function outer() {\n if(i > len) {\n // done\n return callback(null, dk);\n }\n\n // PRF(P, S || INT(i)) (first iteration)\n prf.start(null, null);\n prf.update(s);\n prf.update(forge.util.int32ToBytes(i));\n xor = u_c1 = prf.digest().getBytes();\n\n // PRF(P, u_{c-1}) (other iterations)\n j = 2;\n inner();\n }\n\n function inner() {\n if(j <= c) {\n prf.start(null, null);\n prf.update(u_c1);\n u_c = prf.digest().getBytes();\n // F(p, s, c, i)\n xor = forge.util.xorBytes(xor, u_c, hLen);\n u_c1 = u_c;\n ++j;\n return forge.util.setImmediate(inner);\n }\n\n /* 4. Concatenate the blocks and extract the first dkLen octets to\n produce a derived key DK:\n\n DK = T_1 || T_2 || ... || T_len<0..r-1> */\n dk += (i < len) ? xor : xor.substr(0, r);\n\n ++i;\n outer();\n }\n\n outer();\n};\n","/**\n * Javascript implementation of basic PEM (Privacy Enhanced Mail) algorithms.\n *\n * See: RFC 1421.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2013-2014 Digital Bazaar, Inc.\n *\n * A Forge PEM object has the following fields:\n *\n * type: identifies the type of message (eg: \"RSA PRIVATE KEY\").\n *\n * procType: identifies the type of processing performed on the message,\n * it has two subfields: version and type, eg: 4,ENCRYPTED.\n *\n * contentDomain: identifies the type of content in the message, typically\n * only uses the value: \"RFC822\".\n *\n * dekInfo: identifies the message encryption algorithm and mode and includes\n * any parameters for the algorithm, it has two subfields: algorithm and\n * parameters, eg: DES-CBC,F8143EDE5960C597.\n *\n * headers: contains all other PEM encapsulated headers -- where order is\n * significant (for pairing data like recipient ID + key info).\n *\n * body: the binary-encoded body.\n */\nvar forge = require('./forge');\nrequire('./util');\n\n// shortcut for pem API\nvar pem = module.exports = forge.pem = forge.pem || {};\n\n/**\n * Encodes (serializes) the given PEM object.\n *\n * @param msg the PEM message object to encode.\n * @param options the options to use:\n * maxline the maximum characters per line for the body, (default: 64).\n *\n * @return the PEM-formatted string.\n */\npem.encode = function(msg, options) {\n options = options || {};\n var rval = '-----BEGIN ' + msg.type + '-----\\r\\n';\n\n // encode special headers\n var header;\n if(msg.procType) {\n header = {\n name: 'Proc-Type',\n values: [String(msg.procType.version), msg.procType.type]\n };\n rval += foldHeader(header);\n }\n if(msg.contentDomain) {\n header = {name: 'Content-Domain', values: [msg.contentDomain]};\n rval += foldHeader(header);\n }\n if(msg.dekInfo) {\n header = {name: 'DEK-Info', values: [msg.dekInfo.algorithm]};\n if(msg.dekInfo.parameters) {\n header.values.push(msg.dekInfo.parameters);\n }\n rval += foldHeader(header);\n }\n\n if(msg.headers) {\n // encode all other headers\n for(var i = 0; i < msg.headers.length; ++i) {\n rval += foldHeader(msg.headers[i]);\n }\n }\n\n // terminate header\n if(msg.procType) {\n rval += '\\r\\n';\n }\n\n // add body\n rval += forge.util.encode64(msg.body, options.maxline || 64) + '\\r\\n';\n\n rval += '-----END ' + msg.type + '-----\\r\\n';\n return rval;\n};\n\n/**\n * Decodes (deserializes) all PEM messages found in the given string.\n *\n * @param str the PEM-formatted string to decode.\n *\n * @return the PEM message objects in an array.\n */\npem.decode = function(str) {\n var rval = [];\n\n // split string into PEM messages (be lenient w/EOF on BEGIN line)\n var rMessage = /\\s*-----BEGIN ([A-Z0-9- ]+)-----\\r?\\n?([\\x21-\\x7e\\s]+?(?:\\r?\\n\\r?\\n))?([:A-Za-z0-9+\\/=\\s]+?)-----END \\1-----/g;\n var rHeader = /([\\x21-\\x7e]+):\\s*([\\x21-\\x7e\\s^:]+)/;\n var rCRLF = /\\r?\\n/;\n var match;\n while(true) {\n match = rMessage.exec(str);\n if(!match) {\n break;\n }\n\n var msg = {\n type: match[1],\n procType: null,\n contentDomain: null,\n dekInfo: null,\n headers: [],\n body: forge.util.decode64(match[3])\n };\n rval.push(msg);\n\n // no headers\n if(!match[2]) {\n continue;\n }\n\n // parse headers\n var lines = match[2].split(rCRLF);\n var li = 0;\n while(match && li < lines.length) {\n // get line, trim any rhs whitespace\n var line = lines[li].replace(/\\s+$/, '');\n\n // RFC2822 unfold any following folded lines\n for(var nl = li + 1; nl < lines.length; ++nl) {\n var next = lines[nl];\n if(!/\\s/.test(next[0])) {\n break;\n }\n line += next;\n li = nl;\n }\n\n // parse header\n match = line.match(rHeader);\n if(match) {\n var header = {name: match[1], values: []};\n var values = match[2].split(',');\n for(var vi = 0; vi < values.length; ++vi) {\n header.values.push(ltrim(values[vi]));\n }\n\n // Proc-Type must be the first header\n if(!msg.procType) {\n if(header.name !== 'Proc-Type') {\n throw new Error('Invalid PEM formatted message. The first ' +\n 'encapsulated header must be \"Proc-Type\".');\n } else if(header.values.length !== 2) {\n throw new Error('Invalid PEM formatted message. The \"Proc-Type\" ' +\n 'header must have two subfields.');\n }\n msg.procType = {version: values[0], type: values[1]};\n } else if(!msg.contentDomain && header.name === 'Content-Domain') {\n // special-case Content-Domain\n msg.contentDomain = values[0] || '';\n } else if(!msg.dekInfo && header.name === 'DEK-Info') {\n // special-case DEK-Info\n if(header.values.length === 0) {\n throw new Error('Invalid PEM formatted message. The \"DEK-Info\" ' +\n 'header must have at least one subfield.');\n }\n msg.dekInfo = {algorithm: values[0], parameters: values[1] || null};\n } else {\n msg.headers.push(header);\n }\n }\n\n ++li;\n }\n\n if(msg.procType === 'ENCRYPTED' && !msg.dekInfo) {\n throw new Error('Invalid PEM formatted message. The \"DEK-Info\" ' +\n 'header must be present if \"Proc-Type\" is \"ENCRYPTED\".');\n }\n }\n\n if(rval.length === 0) {\n throw new Error('Invalid PEM formatted message.');\n }\n\n return rval;\n};\n\nfunction foldHeader(header) {\n var rval = header.name + ': ';\n\n // ensure values with CRLF are folded\n var values = [];\n var insertSpace = function(match, $1) {\n return ' ' + $1;\n };\n for(var i = 0; i < header.values.length; ++i) {\n values.push(header.values[i].replace(/^(\\S+\\r\\n)/, insertSpace));\n }\n rval += values.join(',') + '\\r\\n';\n\n // do folding\n var length = 0;\n var candidate = -1;\n for(var i = 0; i < rval.length; ++i, ++length) {\n if(length > 65 && candidate !== -1) {\n var insert = rval[candidate];\n if(insert === ',') {\n ++candidate;\n rval = rval.substr(0, candidate) + '\\r\\n ' + rval.substr(candidate);\n } else {\n rval = rval.substr(0, candidate) +\n '\\r\\n' + insert + rval.substr(candidate + 1);\n }\n length = (i - candidate - 1);\n candidate = -1;\n ++i;\n } else if(rval[i] === ' ' || rval[i] === '\\t' || rval[i] === ',') {\n candidate = i;\n }\n }\n\n return rval;\n}\n\nfunction ltrim(str) {\n return str.replace(/^\\s+/, '');\n}\n","/**\n * Partial implementation of PKCS#1 v2.2: RSA-OEAP\n *\n * Modified but based on the following MIT and BSD licensed code:\n *\n * https://github.com/kjur/jsjws/blob/master/rsa.js:\n *\n * The 'jsjws'(JSON Web Signature JavaScript Library) License\n *\n * Copyright (c) 2012 Kenji Urushima\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * http://webrsa.cvs.sourceforge.net/viewvc/webrsa/Client/RSAES-OAEP.js?content-type=text%2Fplain:\n *\n * RSAES-OAEP.js\n * $Id: RSAES-OAEP.js,v 1.1.1.1 2003/03/19 15:37:20 ellispritchard Exp $\n * JavaScript Implementation of PKCS #1 v2.1 RSA CRYPTOGRAPHY STANDARD (RSA Laboratories, June 14, 2002)\n * Copyright (C) Ellis Pritchard, Guardian Unlimited 2003.\n * Contact: ellis@nukinetics.com\n * Distributed under the BSD License.\n *\n * Official documentation: http://www.rsa.com/rsalabs/node.asp?id=2125\n *\n * @author Evan Jones (http://evanjones.ca/)\n * @author Dave Longley\n *\n * Copyright (c) 2013-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\nrequire('./random');\nrequire('./sha1');\n\n// shortcut for PKCS#1 API\nvar pkcs1 = module.exports = forge.pkcs1 = forge.pkcs1 || {};\n\n/**\n * Encode the given RSAES-OAEP message (M) using key, with optional label (L)\n * and seed.\n *\n * This method does not perform RSA encryption, it only encodes the message\n * using RSAES-OAEP.\n *\n * @param key the RSA key to use.\n * @param message the message to encode.\n * @param options the options to use:\n * label an optional label to use.\n * seed the seed to use.\n * md the message digest object to use, undefined for SHA-1.\n * mgf1 optional mgf1 parameters:\n * md the message digest object to use for MGF1.\n *\n * @return the encoded message bytes.\n */\npkcs1.encode_rsa_oaep = function(key, message, options) {\n // parse arguments\n var label;\n var seed;\n var md;\n var mgf1Md;\n // legacy args (label, seed, md)\n if(typeof options === 'string') {\n label = options;\n seed = arguments[3] || undefined;\n md = arguments[4] || undefined;\n } else if(options) {\n label = options.label || undefined;\n seed = options.seed || undefined;\n md = options.md || undefined;\n if(options.mgf1 && options.mgf1.md) {\n mgf1Md = options.mgf1.md;\n }\n }\n\n // default OAEP to SHA-1 message digest\n if(!md) {\n md = forge.md.sha1.create();\n } else {\n md.start();\n }\n\n // default MGF-1 to same as OAEP\n if(!mgf1Md) {\n mgf1Md = md;\n }\n\n // compute length in bytes and check output\n var keyLength = Math.ceil(key.n.bitLength() / 8);\n var maxLength = keyLength - 2 * md.digestLength - 2;\n if(message.length > maxLength) {\n var error = new Error('RSAES-OAEP input message length is too long.');\n error.length = message.length;\n error.maxLength = maxLength;\n throw error;\n }\n\n if(!label) {\n label = '';\n }\n md.update(label, 'raw');\n var lHash = md.digest();\n\n var PS = '';\n var PS_length = maxLength - message.length;\n for(var i = 0; i < PS_length; i++) {\n PS += '\\x00';\n }\n\n var DB = lHash.getBytes() + PS + '\\x01' + message;\n\n if(!seed) {\n seed = forge.random.getBytes(md.digestLength);\n } else if(seed.length !== md.digestLength) {\n var error = new Error('Invalid RSAES-OAEP seed. The seed length must ' +\n 'match the digest length.');\n error.seedLength = seed.length;\n error.digestLength = md.digestLength;\n throw error;\n }\n\n var dbMask = rsa_mgf1(seed, keyLength - md.digestLength - 1, mgf1Md);\n var maskedDB = forge.util.xorBytes(DB, dbMask, DB.length);\n\n var seedMask = rsa_mgf1(maskedDB, md.digestLength, mgf1Md);\n var maskedSeed = forge.util.xorBytes(seed, seedMask, seed.length);\n\n // return encoded message\n return '\\x00' + maskedSeed + maskedDB;\n};\n\n/**\n * Decode the given RSAES-OAEP encoded message (EM) using key, with optional\n * label (L).\n *\n * This method does not perform RSA decryption, it only decodes the message\n * using RSAES-OAEP.\n *\n * @param key the RSA key to use.\n * @param em the encoded message to decode.\n * @param options the options to use:\n * label an optional label to use.\n * md the message digest object to use for OAEP, undefined for SHA-1.\n * mgf1 optional mgf1 parameters:\n * md the message digest object to use for MGF1.\n *\n * @return the decoded message bytes.\n */\npkcs1.decode_rsa_oaep = function(key, em, options) {\n // parse args\n var label;\n var md;\n var mgf1Md;\n // legacy args\n if(typeof options === 'string') {\n label = options;\n md = arguments[3] || undefined;\n } else if(options) {\n label = options.label || undefined;\n md = options.md || undefined;\n if(options.mgf1 && options.mgf1.md) {\n mgf1Md = options.mgf1.md;\n }\n }\n\n // compute length in bytes\n var keyLength = Math.ceil(key.n.bitLength() / 8);\n\n if(em.length !== keyLength) {\n var error = new Error('RSAES-OAEP encoded message length is invalid.');\n error.length = em.length;\n error.expectedLength = keyLength;\n throw error;\n }\n\n // default OAEP to SHA-1 message digest\n if(md === undefined) {\n md = forge.md.sha1.create();\n } else {\n md.start();\n }\n\n // default MGF-1 to same as OAEP\n if(!mgf1Md) {\n mgf1Md = md;\n }\n\n if(keyLength < 2 * md.digestLength + 2) {\n throw new Error('RSAES-OAEP key is too short for the hash function.');\n }\n\n if(!label) {\n label = '';\n }\n md.update(label, 'raw');\n var lHash = md.digest().getBytes();\n\n // split the message into its parts\n var y = em.charAt(0);\n var maskedSeed = em.substring(1, md.digestLength + 1);\n var maskedDB = em.substring(1 + md.digestLength);\n\n var seedMask = rsa_mgf1(maskedDB, md.digestLength, mgf1Md);\n var seed = forge.util.xorBytes(maskedSeed, seedMask, maskedSeed.length);\n\n var dbMask = rsa_mgf1(seed, keyLength - md.digestLength - 1, mgf1Md);\n var db = forge.util.xorBytes(maskedDB, dbMask, maskedDB.length);\n\n var lHashPrime = db.substring(0, md.digestLength);\n\n // constant time check that all values match what is expected\n var error = (y !== '\\x00');\n\n // constant time check lHash vs lHashPrime\n for(var i = 0; i < md.digestLength; ++i) {\n error |= (lHash.charAt(i) !== lHashPrime.charAt(i));\n }\n\n // \"constant time\" find the 0x1 byte separating the padding (zeros) from the\n // message\n // TODO: It must be possible to do this in a better/smarter way?\n var in_ps = 1;\n var index = md.digestLength;\n for(var j = md.digestLength; j < db.length; j++) {\n var code = db.charCodeAt(j);\n\n var is_0 = (code & 0x1) ^ 0x1;\n\n // non-zero if not 0 or 1 in the ps section\n var error_mask = in_ps ? 0xfffe : 0x0000;\n error |= (code & error_mask);\n\n // latch in_ps to zero after we find 0x1\n in_ps = in_ps & is_0;\n index += in_ps;\n }\n\n if(error || db.charCodeAt(index) !== 0x1) {\n throw new Error('Invalid RSAES-OAEP padding.');\n }\n\n return db.substring(index + 1);\n};\n\nfunction rsa_mgf1(seed, maskLength, hash) {\n // default to SHA-1 message digest\n if(!hash) {\n hash = forge.md.sha1.create();\n }\n var t = '';\n var count = Math.ceil(maskLength / hash.digestLength);\n for(var i = 0; i < count; ++i) {\n var c = String.fromCharCode(\n (i >> 24) & 0xFF, (i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF);\n hash.start();\n hash.update(seed + c);\n t += hash.digest().getBytes();\n }\n return t.substring(0, maskLength);\n}\n","/**\n * Javascript implementation of PKCS#12.\n *\n * @author Dave Longley\n * @author Stefan Siegl \n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n * Copyright (c) 2012 Stefan Siegl \n *\n * The ASN.1 representation of PKCS#12 is as follows\n * (see ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-12/pkcs-12-tc1.pdf for details)\n *\n * PFX ::= SEQUENCE {\n * version INTEGER {v3(3)}(v3,...),\n * authSafe ContentInfo,\n * macData MacData OPTIONAL\n * }\n *\n * MacData ::= SEQUENCE {\n * mac DigestInfo,\n * macSalt OCTET STRING,\n * iterations INTEGER DEFAULT 1\n * }\n * Note: The iterations default is for historical reasons and its use is\n * deprecated. A higher value, like 1024, is recommended.\n *\n * DigestInfo is defined in PKCS#7 as follows:\n *\n * DigestInfo ::= SEQUENCE {\n * digestAlgorithm DigestAlgorithmIdentifier,\n * digest Digest\n * }\n *\n * DigestAlgorithmIdentifier ::= AlgorithmIdentifier\n *\n * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters\n * for the algorithm, if any. In the case of SHA1 there is none.\n *\n * AlgorithmIdentifer ::= SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * parameters ANY DEFINED BY algorithm OPTIONAL\n * }\n *\n * Digest ::= OCTET STRING\n *\n *\n * ContentInfo ::= SEQUENCE {\n * contentType ContentType,\n * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL\n * }\n *\n * ContentType ::= OBJECT IDENTIFIER\n *\n * AuthenticatedSafe ::= SEQUENCE OF ContentInfo\n * -- Data if unencrypted\n * -- EncryptedData if password-encrypted\n * -- EnvelopedData if public key-encrypted\n *\n *\n * SafeContents ::= SEQUENCE OF SafeBag\n *\n * SafeBag ::= SEQUENCE {\n * bagId BAG-TYPE.&id ({PKCS12BagSet})\n * bagValue [0] EXPLICIT BAG-TYPE.&Type({PKCS12BagSet}{@bagId}),\n * bagAttributes SET OF PKCS12Attribute OPTIONAL\n * }\n *\n * PKCS12Attribute ::= SEQUENCE {\n * attrId ATTRIBUTE.&id ({PKCS12AttrSet}),\n * attrValues SET OF ATTRIBUTE.&Type ({PKCS12AttrSet}{@attrId})\n * } -- This type is compatible with the X.500 type 'Attribute'\n *\n * PKCS12AttrSet ATTRIBUTE ::= {\n * friendlyName | -- from PKCS #9\n * localKeyId, -- from PKCS #9\n * ... -- Other attributes are allowed\n * }\n *\n * CertBag ::= SEQUENCE {\n * certId BAG-TYPE.&id ({CertTypes}),\n * certValue [0] EXPLICIT BAG-TYPE.&Type ({CertTypes}{@certId})\n * }\n *\n * x509Certificate BAG-TYPE ::= {OCTET STRING IDENTIFIED BY {certTypes 1}}\n * -- DER-encoded X.509 certificate stored in OCTET STRING\n *\n * sdsiCertificate BAG-TYPE ::= {IA5String IDENTIFIED BY {certTypes 2}}\n * -- Base64-encoded SDSI certificate stored in IA5String\n *\n * CertTypes BAG-TYPE ::= {\n * x509Certificate |\n * sdsiCertificate,\n * ... -- For future extensions\n * }\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./hmac');\nrequire('./oids');\nrequire('./pkcs7asn1');\nrequire('./pbe');\nrequire('./random');\nrequire('./rsa');\nrequire('./sha1');\nrequire('./util');\nrequire('./x509');\n\n// shortcut for asn.1 & PKI API\nvar asn1 = forge.asn1;\nvar pki = forge.pki;\n\n// shortcut for PKCS#12 API\nvar p12 = module.exports = forge.pkcs12 = forge.pkcs12 || {};\n\nvar contentInfoValidator = {\n name: 'ContentInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE, // a ContentInfo\n constructed: true,\n value: [{\n name: 'ContentInfo.contentType',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'contentType'\n }, {\n name: 'ContentInfo.content',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n constructed: true,\n captureAsn1: 'content'\n }]\n};\n\nvar pfxValidator = {\n name: 'PFX',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'PFX.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n },\n contentInfoValidator, {\n name: 'PFX.macData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n optional: true,\n captureAsn1: 'mac',\n value: [{\n name: 'PFX.macData.mac',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE, // DigestInfo\n constructed: true,\n value: [{\n name: 'PFX.macData.mac.digestAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE, // DigestAlgorithmIdentifier\n constructed: true,\n value: [{\n name: 'PFX.macData.mac.digestAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'macAlgorithm'\n }, {\n name: 'PFX.macData.mac.digestAlgorithm.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n captureAsn1: 'macAlgorithmParameters'\n }]\n }, {\n name: 'PFX.macData.mac.digest',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'macDigest'\n }]\n }, {\n name: 'PFX.macData.macSalt',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'macSalt'\n }, {\n name: 'PFX.macData.iterations',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n optional: true,\n capture: 'macIterations'\n }]\n }]\n};\n\nvar safeBagValidator = {\n name: 'SafeBag',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SafeBag.bagId',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'bagId'\n }, {\n name: 'SafeBag.bagValue',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n constructed: true,\n captureAsn1: 'bagValue'\n }, {\n name: 'SafeBag.bagAttributes',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true,\n optional: true,\n capture: 'bagAttributes'\n }]\n};\n\nvar attributeValidator = {\n name: 'Attribute',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'Attribute.attrId',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'oid'\n }, {\n name: 'Attribute.attrValues',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true,\n capture: 'values'\n }]\n};\n\nvar certBagValidator = {\n name: 'CertBag',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'CertBag.certId',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'certId'\n }, {\n name: 'CertBag.certValue',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n constructed: true,\n /* So far we only support X.509 certificates (which are wrapped in\n an OCTET STRING, hence hard code that here). */\n value: [{\n name: 'CertBag.certValue[0]',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.OCTETSTRING,\n constructed: false,\n capture: 'cert'\n }]\n }]\n};\n\n/**\n * Search SafeContents structure for bags with matching attributes.\n *\n * The search can optionally be narrowed by a certain bag type.\n *\n * @param safeContents the SafeContents structure to search in.\n * @param attrName the name of the attribute to compare against.\n * @param attrValue the attribute value to search for.\n * @param [bagType] bag type to narrow search by.\n *\n * @return an array of matching bags.\n */\nfunction _getBagsByAttribute(safeContents, attrName, attrValue, bagType) {\n var result = [];\n\n for(var i = 0; i < safeContents.length; i++) {\n for(var j = 0; j < safeContents[i].safeBags.length; j++) {\n var bag = safeContents[i].safeBags[j];\n if(bagType !== undefined && bag.type !== bagType) {\n continue;\n }\n // only filter by bag type, no attribute specified\n if(attrName === null) {\n result.push(bag);\n continue;\n }\n if(bag.attributes[attrName] !== undefined &&\n bag.attributes[attrName].indexOf(attrValue) >= 0) {\n result.push(bag);\n }\n }\n }\n\n return result;\n}\n\n/**\n * Converts a PKCS#12 PFX in ASN.1 notation into a PFX object.\n *\n * @param obj The PKCS#12 PFX in ASN.1 notation.\n * @param strict true to use strict DER decoding, false not to (default: true).\n * @param {String} password Password to decrypt with (optional).\n *\n * @return PKCS#12 PFX object.\n */\np12.pkcs12FromAsn1 = function(obj, strict, password) {\n // handle args\n if(typeof strict === 'string') {\n password = strict;\n strict = true;\n } else if(strict === undefined) {\n strict = true;\n }\n\n // validate PFX and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, pfxValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#12 PFX. ' +\n 'ASN.1 object is not an PKCS#12 PFX.');\n error.errors = error;\n throw error;\n }\n\n var pfx = {\n version: capture.version.charCodeAt(0),\n safeContents: [],\n\n /**\n * Gets bags with matching attributes.\n *\n * @param filter the attributes to filter by:\n * [localKeyId] the localKeyId to search for.\n * [localKeyIdHex] the localKeyId in hex to search for.\n * [friendlyName] the friendly name to search for.\n * [bagType] bag type to narrow each attribute search by.\n *\n * @return a map of attribute type to an array of matching bags or, if no\n * attribute was given but a bag type, the map key will be the\n * bag type.\n */\n getBags: function(filter) {\n var rval = {};\n\n var localKeyId;\n if('localKeyId' in filter) {\n localKeyId = filter.localKeyId;\n } else if('localKeyIdHex' in filter) {\n localKeyId = forge.util.hexToBytes(filter.localKeyIdHex);\n }\n\n // filter on bagType only\n if(localKeyId === undefined && !('friendlyName' in filter) &&\n 'bagType' in filter) {\n rval[filter.bagType] = _getBagsByAttribute(\n pfx.safeContents, null, null, filter.bagType);\n }\n\n if(localKeyId !== undefined) {\n rval.localKeyId = _getBagsByAttribute(\n pfx.safeContents, 'localKeyId',\n localKeyId, filter.bagType);\n }\n if('friendlyName' in filter) {\n rval.friendlyName = _getBagsByAttribute(\n pfx.safeContents, 'friendlyName',\n filter.friendlyName, filter.bagType);\n }\n\n return rval;\n },\n\n /**\n * DEPRECATED: use getBags() instead.\n *\n * Get bags with matching friendlyName attribute.\n *\n * @param friendlyName the friendly name to search for.\n * @param [bagType] bag type to narrow search by.\n *\n * @return an array of bags with matching friendlyName attribute.\n */\n getBagsByFriendlyName: function(friendlyName, bagType) {\n return _getBagsByAttribute(\n pfx.safeContents, 'friendlyName', friendlyName, bagType);\n },\n\n /**\n * DEPRECATED: use getBags() instead.\n *\n * Get bags with matching localKeyId attribute.\n *\n * @param localKeyId the localKeyId to search for.\n * @param [bagType] bag type to narrow search by.\n *\n * @return an array of bags with matching localKeyId attribute.\n */\n getBagsByLocalKeyId: function(localKeyId, bagType) {\n return _getBagsByAttribute(\n pfx.safeContents, 'localKeyId', localKeyId, bagType);\n }\n };\n\n if(capture.version.charCodeAt(0) !== 3) {\n var error = new Error('PKCS#12 PFX of version other than 3 not supported.');\n error.version = capture.version.charCodeAt(0);\n throw error;\n }\n\n if(asn1.derToOid(capture.contentType) !== pki.oids.data) {\n var error = new Error('Only PKCS#12 PFX in password integrity mode supported.');\n error.oid = asn1.derToOid(capture.contentType);\n throw error;\n }\n\n var data = capture.content.value[0];\n if(data.tagClass !== asn1.Class.UNIVERSAL ||\n data.type !== asn1.Type.OCTETSTRING) {\n throw new Error('PKCS#12 authSafe content data is not an OCTET STRING.');\n }\n data = _decodePkcs7Data(data);\n\n // check for MAC\n if(capture.mac) {\n var md = null;\n var macKeyBytes = 0;\n var macAlgorithm = asn1.derToOid(capture.macAlgorithm);\n switch(macAlgorithm) {\n case pki.oids.sha1:\n md = forge.md.sha1.create();\n macKeyBytes = 20;\n break;\n case pki.oids.sha256:\n md = forge.md.sha256.create();\n macKeyBytes = 32;\n break;\n case pki.oids.sha384:\n md = forge.md.sha384.create();\n macKeyBytes = 48;\n break;\n case pki.oids.sha512:\n md = forge.md.sha512.create();\n macKeyBytes = 64;\n break;\n case pki.oids.md5:\n md = forge.md.md5.create();\n macKeyBytes = 16;\n break;\n }\n if(md === null) {\n throw new Error('PKCS#12 uses unsupported MAC algorithm: ' + macAlgorithm);\n }\n\n // verify MAC (iterations default to 1)\n var macSalt = new forge.util.ByteBuffer(capture.macSalt);\n var macIterations = (('macIterations' in capture) ?\n parseInt(forge.util.bytesToHex(capture.macIterations), 16) : 1);\n var macKey = p12.generateKey(\n password, macSalt, 3, macIterations, macKeyBytes, md);\n var mac = forge.hmac.create();\n mac.start(md, macKey);\n mac.update(data.value);\n var macValue = mac.getMac();\n if(macValue.getBytes() !== capture.macDigest) {\n throw new Error('PKCS#12 MAC could not be verified. Invalid password?');\n }\n }\n\n _decodeAuthenticatedSafe(pfx, data.value, strict, password);\n return pfx;\n};\n\n/**\n * Decodes PKCS#7 Data. PKCS#7 (RFC 2315) defines \"Data\" as an OCTET STRING,\n * but it is sometimes an OCTET STRING that is composed/constructed of chunks,\n * each its own OCTET STRING. This is BER-encoding vs. DER-encoding. This\n * function transforms this corner-case into the usual simple,\n * non-composed/constructed OCTET STRING.\n *\n * This function may be moved to ASN.1 at some point to better deal with\n * more BER-encoding issues, should they arise.\n *\n * @param data the ASN.1 Data object to transform.\n */\nfunction _decodePkcs7Data(data) {\n // handle special case of \"chunked\" data content: an octet string composed\n // of other octet strings\n if(data.composed || data.constructed) {\n var value = forge.util.createBuffer();\n for(var i = 0; i < data.value.length; ++i) {\n value.putBytes(data.value[i].value);\n }\n data.composed = data.constructed = false;\n data.value = value.getBytes();\n }\n return data;\n}\n\n/**\n * Decode PKCS#12 AuthenticatedSafe (BER encoded) into PFX object.\n *\n * The AuthenticatedSafe is a BER-encoded SEQUENCE OF ContentInfo.\n *\n * @param pfx The PKCS#12 PFX object to fill.\n * @param {String} authSafe BER-encoded AuthenticatedSafe.\n * @param strict true to use strict DER decoding, false not to.\n * @param {String} password Password to decrypt with (optional).\n */\nfunction _decodeAuthenticatedSafe(pfx, authSafe, strict, password) {\n authSafe = asn1.fromDer(authSafe, strict); /* actually it's BER encoded */\n\n if(authSafe.tagClass !== asn1.Class.UNIVERSAL ||\n authSafe.type !== asn1.Type.SEQUENCE ||\n authSafe.constructed !== true) {\n throw new Error('PKCS#12 AuthenticatedSafe expected to be a ' +\n 'SEQUENCE OF ContentInfo');\n }\n\n for(var i = 0; i < authSafe.value.length; i++) {\n var contentInfo = authSafe.value[i];\n\n // validate contentInfo and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(contentInfo, contentInfoValidator, capture, errors)) {\n var error = new Error('Cannot read ContentInfo.');\n error.errors = errors;\n throw error;\n }\n\n var obj = {\n encrypted: false\n };\n var safeContents = null;\n var data = capture.content.value[0];\n switch(asn1.derToOid(capture.contentType)) {\n case pki.oids.data:\n if(data.tagClass !== asn1.Class.UNIVERSAL ||\n data.type !== asn1.Type.OCTETSTRING) {\n throw new Error('PKCS#12 SafeContents Data is not an OCTET STRING.');\n }\n safeContents = _decodePkcs7Data(data).value;\n break;\n case pki.oids.encryptedData:\n safeContents = _decryptSafeContents(data, password);\n obj.encrypted = true;\n break;\n default:\n var error = new Error('Unsupported PKCS#12 contentType.');\n error.contentType = asn1.derToOid(capture.contentType);\n throw error;\n }\n\n obj.safeBags = _decodeSafeContents(safeContents, strict, password);\n pfx.safeContents.push(obj);\n }\n}\n\n/**\n * Decrypt PKCS#7 EncryptedData structure.\n *\n * @param data ASN.1 encoded EncryptedContentInfo object.\n * @param password The user-provided password.\n *\n * @return The decrypted SafeContents (ASN.1 object).\n */\nfunction _decryptSafeContents(data, password) {\n var capture = {};\n var errors = [];\n if(!asn1.validate(\n data, forge.pkcs7.asn1.encryptedDataValidator, capture, errors)) {\n var error = new Error('Cannot read EncryptedContentInfo.');\n error.errors = errors;\n throw error;\n }\n\n var oid = asn1.derToOid(capture.contentType);\n if(oid !== pki.oids.data) {\n var error = new Error(\n 'PKCS#12 EncryptedContentInfo ContentType is not Data.');\n error.oid = oid;\n throw error;\n }\n\n // get cipher\n oid = asn1.derToOid(capture.encAlgorithm);\n var cipher = pki.pbe.getCipher(oid, capture.encParameter, password);\n\n // get encrypted data\n var encryptedContentAsn1 = _decodePkcs7Data(capture.encryptedContentAsn1);\n var encrypted = forge.util.createBuffer(encryptedContentAsn1.value);\n\n cipher.update(encrypted);\n if(!cipher.finish()) {\n throw new Error('Failed to decrypt PKCS#12 SafeContents.');\n }\n\n return cipher.output.getBytes();\n}\n\n/**\n * Decode PKCS#12 SafeContents (BER-encoded) into array of Bag objects.\n *\n * The safeContents is a BER-encoded SEQUENCE OF SafeBag.\n *\n * @param {String} safeContents BER-encoded safeContents.\n * @param strict true to use strict DER decoding, false not to.\n * @param {String} password Password to decrypt with (optional).\n *\n * @return {Array} Array of Bag objects.\n */\nfunction _decodeSafeContents(safeContents, strict, password) {\n // if strict and no safe contents, return empty safes\n if(!strict && safeContents.length === 0) {\n return [];\n }\n\n // actually it's BER-encoded\n safeContents = asn1.fromDer(safeContents, strict);\n\n if(safeContents.tagClass !== asn1.Class.UNIVERSAL ||\n safeContents.type !== asn1.Type.SEQUENCE ||\n safeContents.constructed !== true) {\n throw new Error(\n 'PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.');\n }\n\n var res = [];\n for(var i = 0; i < safeContents.value.length; i++) {\n var safeBag = safeContents.value[i];\n\n // validate SafeBag and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(safeBag, safeBagValidator, capture, errors)) {\n var error = new Error('Cannot read SafeBag.');\n error.errors = errors;\n throw error;\n }\n\n /* Create bag object and push to result array. */\n var bag = {\n type: asn1.derToOid(capture.bagId),\n attributes: _decodeBagAttributes(capture.bagAttributes)\n };\n res.push(bag);\n\n var validator, decoder;\n var bagAsn1 = capture.bagValue.value[0];\n switch(bag.type) {\n case pki.oids.pkcs8ShroudedKeyBag:\n /* bagAsn1 has a EncryptedPrivateKeyInfo, which we need to decrypt.\n Afterwards we can handle it like a keyBag,\n which is a PrivateKeyInfo. */\n bagAsn1 = pki.decryptPrivateKeyInfo(bagAsn1, password);\n if(bagAsn1 === null) {\n throw new Error(\n 'Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?');\n }\n\n /* fall through */\n case pki.oids.keyBag:\n /* A PKCS#12 keyBag is a simple PrivateKeyInfo as understood by our\n PKI module, hence we don't have to do validation/capturing here,\n just pass what we already got. */\n try {\n bag.key = pki.privateKeyFromAsn1(bagAsn1);\n } catch(e) {\n // ignore unknown key type, pass asn1 value\n bag.key = null;\n bag.asn1 = bagAsn1;\n }\n continue; /* Nothing more to do. */\n\n case pki.oids.certBag:\n /* A PKCS#12 certBag can wrap both X.509 and sdsi certificates.\n Therefore put the SafeBag content through another validator to\n capture the fields. Afterwards check & store the results. */\n validator = certBagValidator;\n decoder = function() {\n if(asn1.derToOid(capture.certId) !== pki.oids.x509Certificate) {\n var error = new Error(\n 'Unsupported certificate type, only X.509 supported.');\n error.oid = asn1.derToOid(capture.certId);\n throw error;\n }\n\n // true=produce cert hash\n var certAsn1 = asn1.fromDer(capture.cert, strict);\n try {\n bag.cert = pki.certificateFromAsn1(certAsn1, true);\n } catch(e) {\n // ignore unknown cert type, pass asn1 value\n bag.cert = null;\n bag.asn1 = certAsn1;\n }\n };\n break;\n\n default:\n var error = new Error('Unsupported PKCS#12 SafeBag type.');\n error.oid = bag.type;\n throw error;\n }\n\n /* Validate SafeBag value (i.e. CertBag, etc.) and capture data if needed. */\n if(validator !== undefined &&\n !asn1.validate(bagAsn1, validator, capture, errors)) {\n var error = new Error('Cannot read PKCS#12 ' + validator.name);\n error.errors = errors;\n throw error;\n }\n\n /* Call decoder function from above to store the results. */\n decoder();\n }\n\n return res;\n}\n\n/**\n * Decode PKCS#12 SET OF PKCS12Attribute into JavaScript object.\n *\n * @param attributes SET OF PKCS12Attribute (ASN.1 object).\n *\n * @return the decoded attributes.\n */\nfunction _decodeBagAttributes(attributes) {\n var decodedAttrs = {};\n\n if(attributes !== undefined) {\n for(var i = 0; i < attributes.length; ++i) {\n var capture = {};\n var errors = [];\n if(!asn1.validate(attributes[i], attributeValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#12 BagAttribute.');\n error.errors = errors;\n throw error;\n }\n\n var oid = asn1.derToOid(capture.oid);\n if(pki.oids[oid] === undefined) {\n // unsupported attribute type, ignore.\n continue;\n }\n\n decodedAttrs[pki.oids[oid]] = [];\n for(var j = 0; j < capture.values.length; ++j) {\n decodedAttrs[pki.oids[oid]].push(capture.values[j].value);\n }\n }\n }\n\n return decodedAttrs;\n}\n\n/**\n * Wraps a private key and certificate in a PKCS#12 PFX wrapper. If a\n * password is provided then the private key will be encrypted.\n *\n * An entire certificate chain may also be included. To do this, pass\n * an array for the \"cert\" parameter where the first certificate is\n * the one that is paired with the private key and each subsequent one\n * verifies the previous one. The certificates may be in PEM format or\n * have been already parsed by Forge.\n *\n * @todo implement password-based-encryption for the whole package\n *\n * @param key the private key.\n * @param cert the certificate (may be an array of certificates in order\n * to specify a certificate chain).\n * @param password the password to use, null for none.\n * @param options:\n * algorithm the encryption algorithm to use\n * ('aes128', 'aes192', 'aes256', '3des'), defaults to 'aes128'.\n * count the iteration count to use.\n * saltSize the salt size to use.\n * useMac true to include a MAC, false not to, defaults to true.\n * localKeyId the local key ID to use, in hex.\n * friendlyName the friendly name to use.\n * generateLocalKeyId true to generate a random local key ID,\n * false not to, defaults to true.\n *\n * @return the PKCS#12 PFX ASN.1 object.\n */\np12.toPkcs12Asn1 = function(key, cert, password, options) {\n // set default options\n options = options || {};\n options.saltSize = options.saltSize || 8;\n options.count = options.count || 2048;\n options.algorithm = options.algorithm || options.encAlgorithm || 'aes128';\n if(!('useMac' in options)) {\n options.useMac = true;\n }\n if(!('localKeyId' in options)) {\n options.localKeyId = null;\n }\n if(!('generateLocalKeyId' in options)) {\n options.generateLocalKeyId = true;\n }\n\n var localKeyId = options.localKeyId;\n var bagAttrs;\n if(localKeyId !== null) {\n localKeyId = forge.util.hexToBytes(localKeyId);\n } else if(options.generateLocalKeyId) {\n // use SHA-1 of paired cert, if available\n if(cert) {\n var pairedCert = forge.util.isArray(cert) ? cert[0] : cert;\n if(typeof pairedCert === 'string') {\n pairedCert = pki.certificateFromPem(pairedCert);\n }\n var sha1 = forge.md.sha1.create();\n sha1.update(asn1.toDer(pki.certificateToAsn1(pairedCert)).getBytes());\n localKeyId = sha1.digest().getBytes();\n } else {\n // FIXME: consider using SHA-1 of public key (which can be generated\n // from private key components), see: cert.generateSubjectKeyIdentifier\n // generate random bytes\n localKeyId = forge.random.getBytes(20);\n }\n }\n\n var attrs = [];\n if(localKeyId !== null) {\n attrs.push(\n // localKeyID\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // attrId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.localKeyId).getBytes()),\n // attrValues\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n localKeyId)\n ])\n ]));\n }\n if('friendlyName' in options) {\n attrs.push(\n // friendlyName\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // attrId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.friendlyName).getBytes()),\n // attrValues\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BMPSTRING, false,\n options.friendlyName)\n ])\n ]));\n }\n\n if(attrs.length > 0) {\n bagAttrs = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, attrs);\n }\n\n // collect contents for AuthenticatedSafe\n var contents = [];\n\n // create safe bag(s) for certificate chain\n var chain = [];\n if(cert !== null) {\n if(forge.util.isArray(cert)) {\n chain = cert;\n } else {\n chain = [cert];\n }\n }\n\n var certSafeBags = [];\n for(var i = 0; i < chain.length; ++i) {\n // convert cert from PEM as necessary\n cert = chain[i];\n if(typeof cert === 'string') {\n cert = pki.certificateFromPem(cert);\n }\n\n // SafeBag\n var certBagAttrs = (i === 0) ? bagAttrs : undefined;\n var certAsn1 = pki.certificateToAsn1(cert);\n var certSafeBag =\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // bagId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.certBag).getBytes()),\n // bagValue\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n // CertBag\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // certId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.x509Certificate).getBytes()),\n // certValue (x509Certificate)\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(certAsn1).getBytes())\n ])])]),\n // bagAttributes (OPTIONAL)\n certBagAttrs\n ]);\n certSafeBags.push(certSafeBag);\n }\n\n if(certSafeBags.length > 0) {\n // SafeContents\n var certSafeContents = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, certSafeBags);\n\n // ContentInfo\n var certCI =\n // PKCS#7 ContentInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // contentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n // OID for the content type is 'data'\n asn1.oidToDer(pki.oids.data).getBytes()),\n // content\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(certSafeContents).getBytes())\n ])\n ]);\n contents.push(certCI);\n }\n\n // create safe contents for private key\n var keyBag = null;\n if(key !== null) {\n // SafeBag\n var pkAsn1 = pki.wrapRsaPrivateKey(pki.privateKeyToAsn1(key));\n if(password === null) {\n // no encryption\n keyBag = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // bagId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.keyBag).getBytes()),\n // bagValue\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n // PrivateKeyInfo\n pkAsn1\n ]),\n // bagAttributes (OPTIONAL)\n bagAttrs\n ]);\n } else {\n // encrypted PrivateKeyInfo\n keyBag = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // bagId\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.pkcs8ShroudedKeyBag).getBytes()),\n // bagValue\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n // EncryptedPrivateKeyInfo\n pki.encryptPrivateKeyInfo(pkAsn1, password, options)\n ]),\n // bagAttributes (OPTIONAL)\n bagAttrs\n ]);\n }\n\n // SafeContents\n var keySafeContents =\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [keyBag]);\n\n // ContentInfo\n var keyCI =\n // PKCS#7 ContentInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // contentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n // OID for the content type is 'data'\n asn1.oidToDer(pki.oids.data).getBytes()),\n // content\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(keySafeContents).getBytes())\n ])\n ]);\n contents.push(keyCI);\n }\n\n // create AuthenticatedSafe by stringing together the contents\n var safe = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, contents);\n\n var macData;\n if(options.useMac) {\n // MacData\n var sha1 = forge.md.sha1.create();\n var macSalt = new forge.util.ByteBuffer(\n forge.random.getBytes(options.saltSize));\n var count = options.count;\n // 160-bit key\n var key = p12.generateKey(password, macSalt, 3, count, 20);\n var mac = forge.hmac.create();\n mac.start(sha1, key);\n mac.update(asn1.toDer(safe).getBytes());\n var macValue = mac.getMac();\n macData = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // mac DigestInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // digestAlgorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm = SHA-1\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.sha1).getBytes()),\n // parameters = Null\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]),\n // digest\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,\n false, macValue.getBytes())\n ]),\n // macSalt OCTET STRING\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, macSalt.getBytes()),\n // iterations INTEGER (XXX: Only support count < 65536)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(count).getBytes()\n )\n ]);\n }\n\n // PFX\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version (3)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(3).getBytes()),\n // PKCS#7 ContentInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // contentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n // OID for the content type is 'data'\n asn1.oidToDer(pki.oids.data).getBytes()),\n // content\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(safe).getBytes())\n ])\n ]),\n macData\n ]);\n};\n\n/**\n * Derives a PKCS#12 key.\n *\n * @param password the password to derive the key material from, null or\n * undefined for none.\n * @param salt the salt, as a ByteBuffer, to use.\n * @param id the PKCS#12 ID byte (1 = key material, 2 = IV, 3 = MAC).\n * @param iter the iteration count.\n * @param n the number of bytes to derive from the password.\n * @param md the message digest to use, defaults to SHA-1.\n *\n * @return a ByteBuffer with the bytes derived from the password.\n */\np12.generateKey = forge.pbe.generatePkcs12Key;\n","/**\n * Javascript implementation of PKCS#7 v1.5.\n *\n * @author Stefan Siegl\n * @author Dave Longley\n *\n * Copyright (c) 2012 Stefan Siegl \n * Copyright (c) 2012-2015 Digital Bazaar, Inc.\n *\n * Currently this implementation only supports ContentType of EnvelopedData,\n * EncryptedData, or SignedData at the root level. The top level elements may\n * contain only a ContentInfo of ContentType Data, i.e. plain data. Further\n * nesting is not (yet) supported.\n *\n * The Forge validators for PKCS #7's ASN.1 structures are available from\n * a separate file pkcs7asn1.js, since those are referenced from other\n * PKCS standards like PKCS #12.\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./asn1');\nrequire('./des');\nrequire('./oids');\nrequire('./pem');\nrequire('./pkcs7asn1');\nrequire('./random');\nrequire('./util');\nrequire('./x509');\n\n// shortcut for ASN.1 API\nvar asn1 = forge.asn1;\n\n// shortcut for PKCS#7 API\nvar p7 = module.exports = forge.pkcs7 = forge.pkcs7 || {};\n\n/**\n * Converts a PKCS#7 message from PEM format.\n *\n * @param pem the PEM-formatted PKCS#7 message.\n *\n * @return the PKCS#7 message.\n */\np7.messageFromPem = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'PKCS7') {\n var error = new Error('Could not convert PKCS#7 message from PEM; PEM ' +\n 'header type is not \"PKCS#7\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert PKCS#7 message from PEM; PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body);\n\n return p7.messageFromAsn1(obj);\n};\n\n/**\n * Converts a PKCS#7 message to PEM format.\n *\n * @param msg The PKCS#7 message object\n * @param maxline The maximum characters per line, defaults to 64.\n *\n * @return The PEM-formatted PKCS#7 message.\n */\np7.messageToPem = function(msg, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var pemObj = {\n type: 'PKCS7',\n body: asn1.toDer(msg.toAsn1()).getBytes()\n };\n return forge.pem.encode(pemObj, {maxline: maxline});\n};\n\n/**\n * Converts a PKCS#7 message from an ASN.1 object.\n *\n * @param obj the ASN.1 representation of a ContentInfo.\n *\n * @return the PKCS#7 message.\n */\np7.messageFromAsn1 = function(obj) {\n // validate root level ContentInfo and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, p7.asn1.contentInfoValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#7 message. ' +\n 'ASN.1 object is not an PKCS#7 ContentInfo.');\n error.errors = errors;\n throw error;\n }\n\n var contentType = asn1.derToOid(capture.contentType);\n var msg;\n\n switch(contentType) {\n case forge.pki.oids.envelopedData:\n msg = p7.createEnvelopedData();\n break;\n\n case forge.pki.oids.encryptedData:\n msg = p7.createEncryptedData();\n break;\n\n case forge.pki.oids.signedData:\n msg = p7.createSignedData();\n break;\n\n default:\n throw new Error('Cannot read PKCS#7 message. ContentType with OID ' +\n contentType + ' is not (yet) supported.');\n }\n\n msg.fromAsn1(capture.content.value[0]);\n return msg;\n};\n\np7.createSignedData = function() {\n var msg = null;\n msg = {\n type: forge.pki.oids.signedData,\n version: 1,\n certificates: [],\n crls: [],\n // TODO: add json-formatted signer stuff here?\n signers: [],\n // populated during sign()\n digestAlgorithmIdentifiers: [],\n contentInfo: null,\n signerInfos: [],\n\n fromAsn1: function(obj) {\n // validate SignedData content block and capture data.\n _fromAsn1(msg, obj, p7.asn1.signedDataValidator);\n msg.certificates = [];\n msg.crls = [];\n msg.digestAlgorithmIdentifiers = [];\n msg.contentInfo = null;\n msg.signerInfos = [];\n\n if(msg.rawCapture.certificates) {\n var certs = msg.rawCapture.certificates.value;\n for(var i = 0; i < certs.length; ++i) {\n msg.certificates.push(forge.pki.certificateFromAsn1(certs[i]));\n }\n }\n\n // TODO: parse crls\n },\n\n toAsn1: function() {\n // degenerate case with no content\n if(!msg.contentInfo) {\n msg.sign();\n }\n\n var certs = [];\n for(var i = 0; i < msg.certificates.length; ++i) {\n certs.push(forge.pki.certificateToAsn1(msg.certificates[i]));\n }\n\n var crls = [];\n // TODO: implement CRLs\n\n // [0] SignedData\n var signedData = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(msg.version).getBytes()),\n // DigestAlgorithmIdentifiers\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SET, true,\n msg.digestAlgorithmIdentifiers),\n // ContentInfo\n msg.contentInfo\n ])\n ]);\n if(certs.length > 0) {\n // [0] IMPLICIT ExtendedCertificatesAndCertificates OPTIONAL\n signedData.value[0].value.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, certs));\n }\n if(crls.length > 0) {\n // [1] IMPLICIT CertificateRevocationLists OPTIONAL\n signedData.value[0].value.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, crls));\n }\n // SignerInfos\n signedData.value[0].value.push(\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true,\n msg.signerInfos));\n\n // ContentInfo\n return asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // ContentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(msg.type).getBytes()),\n // [0] SignedData\n signedData\n ]);\n },\n\n /**\n * Add (another) entity to list of signers.\n *\n * Note: If authenticatedAttributes are provided, then, per RFC 2315,\n * they must include at least two attributes: content type and\n * message digest. The message digest attribute value will be\n * auto-calculated during signing and will be ignored if provided.\n *\n * Here's an example of providing these two attributes:\n *\n * forge.pkcs7.createSignedData();\n * p7.addSigner({\n * issuer: cert.issuer.attributes,\n * serialNumber: cert.serialNumber,\n * key: privateKey,\n * digestAlgorithm: forge.pki.oids.sha1,\n * authenticatedAttributes: [{\n * type: forge.pki.oids.contentType,\n * value: forge.pki.oids.data\n * }, {\n * type: forge.pki.oids.messageDigest\n * }]\n * });\n *\n * TODO: Support [subjectKeyIdentifier] as signer's ID.\n *\n * @param signer the signer information:\n * key the signer's private key.\n * [certificate] a certificate containing the public key\n * associated with the signer's private key; use this option as\n * an alternative to specifying signer.issuer and\n * signer.serialNumber.\n * [issuer] the issuer attributes (eg: cert.issuer.attributes).\n * [serialNumber] the signer's certificate's serial number in\n * hexadecimal (eg: cert.serialNumber).\n * [digestAlgorithm] the message digest OID, as a string, to use\n * (eg: forge.pki.oids.sha1).\n * [authenticatedAttributes] an optional array of attributes\n * to also sign along with the content.\n */\n addSigner: function(signer) {\n var issuer = signer.issuer;\n var serialNumber = signer.serialNumber;\n if(signer.certificate) {\n var cert = signer.certificate;\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n issuer = cert.issuer.attributes;\n serialNumber = cert.serialNumber;\n }\n var key = signer.key;\n if(!key) {\n throw new Error(\n 'Could not add PKCS#7 signer; no private key specified.');\n }\n if(typeof key === 'string') {\n key = forge.pki.privateKeyFromPem(key);\n }\n\n // ensure OID known for digest algorithm\n var digestAlgorithm = signer.digestAlgorithm || forge.pki.oids.sha1;\n switch(digestAlgorithm) {\n case forge.pki.oids.sha1:\n case forge.pki.oids.sha256:\n case forge.pki.oids.sha384:\n case forge.pki.oids.sha512:\n case forge.pki.oids.md5:\n break;\n default:\n throw new Error(\n 'Could not add PKCS#7 signer; unknown message digest algorithm: ' +\n digestAlgorithm);\n }\n\n // if authenticatedAttributes is present, then the attributes\n // must contain at least PKCS #9 content-type and message-digest\n var authenticatedAttributes = signer.authenticatedAttributes || [];\n if(authenticatedAttributes.length > 0) {\n var contentType = false;\n var messageDigest = false;\n for(var i = 0; i < authenticatedAttributes.length; ++i) {\n var attr = authenticatedAttributes[i];\n if(!contentType && attr.type === forge.pki.oids.contentType) {\n contentType = true;\n if(messageDigest) {\n break;\n }\n continue;\n }\n if(!messageDigest && attr.type === forge.pki.oids.messageDigest) {\n messageDigest = true;\n if(contentType) {\n break;\n }\n continue;\n }\n }\n\n if(!contentType || !messageDigest) {\n throw new Error('Invalid signer.authenticatedAttributes. If ' +\n 'signer.authenticatedAttributes is specified, then it must ' +\n 'contain at least two attributes, PKCS #9 content-type and ' +\n 'PKCS #9 message-digest.');\n }\n }\n\n msg.signers.push({\n key: key,\n version: 1,\n issuer: issuer,\n serialNumber: serialNumber,\n digestAlgorithm: digestAlgorithm,\n signatureAlgorithm: forge.pki.oids.rsaEncryption,\n signature: null,\n authenticatedAttributes: authenticatedAttributes,\n unauthenticatedAttributes: []\n });\n },\n\n /**\n * Signs the content.\n * @param options Options to apply when signing:\n * [detached] boolean. If signing should be done in detached mode. Defaults to false.\n */\n sign: function(options) {\n options = options || {};\n // auto-generate content info\n if(typeof msg.content !== 'object' || msg.contentInfo === null) {\n // use Data ContentInfo\n msg.contentInfo = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // ContentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(forge.pki.oids.data).getBytes())\n ]);\n\n // add actual content, if present\n if('content' in msg) {\n var content;\n if(msg.content instanceof forge.util.ByteBuffer) {\n content = msg.content.bytes();\n } else if(typeof msg.content === 'string') {\n content = forge.util.encodeUtf8(msg.content);\n }\n\n if (options.detached) {\n msg.detachedContent = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, content);\n } else {\n msg.contentInfo.value.push(\n // [0] EXPLICIT content\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n content)\n ]));\n }\n }\n }\n\n // no signers, return early (degenerate case for certificate container)\n if(msg.signers.length === 0) {\n return;\n }\n\n // generate digest algorithm identifiers\n var mds = addDigestAlgorithmIds();\n\n // generate signerInfos\n addSignerInfos(mds);\n },\n\n verify: function() {\n throw new Error('PKCS#7 signature verification not yet implemented.');\n },\n\n /**\n * Add a certificate.\n *\n * @param cert the certificate to add.\n */\n addCertificate: function(cert) {\n // convert from PEM\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n msg.certificates.push(cert);\n },\n\n /**\n * Add a certificate revokation list.\n *\n * @param crl the certificate revokation list to add.\n */\n addCertificateRevokationList: function(crl) {\n throw new Error('PKCS#7 CRL support not yet implemented.');\n }\n };\n return msg;\n\n function addDigestAlgorithmIds() {\n var mds = {};\n\n for(var i = 0; i < msg.signers.length; ++i) {\n var signer = msg.signers[i];\n var oid = signer.digestAlgorithm;\n if(!(oid in mds)) {\n // content digest\n mds[oid] = forge.md[forge.pki.oids[oid]].create();\n }\n if(signer.authenticatedAttributes.length === 0) {\n // no custom attributes to digest; use content message digest\n signer.md = mds[oid];\n } else {\n // custom attributes to be digested; use own message digest\n // TODO: optimize to just copy message digest state if that\n // feature is ever supported with message digests\n signer.md = forge.md[forge.pki.oids[oid]].create();\n }\n }\n\n // add unique digest algorithm identifiers\n msg.digestAlgorithmIdentifiers = [];\n for(var oid in mds) {\n msg.digestAlgorithmIdentifiers.push(\n // AlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(oid).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]));\n }\n\n return mds;\n }\n\n function addSignerInfos(mds) {\n var content;\n\n if (msg.detachedContent) {\n // Signature has been made in detached mode.\n content = msg.detachedContent;\n } else {\n // Note: ContentInfo is a SEQUENCE with 2 values, second value is\n // the content field and is optional for a ContentInfo but required here\n // since signers are present\n // get ContentInfo content\n content = msg.contentInfo.value[1];\n // skip [0] EXPLICIT content wrapper\n content = content.value[0];\n }\n\n if(!content) {\n throw new Error(\n 'Could not sign PKCS#7 message; there is no content to sign.');\n }\n\n // get ContentInfo content type\n var contentType = asn1.derToOid(msg.contentInfo.value[0].value);\n\n // serialize content\n var bytes = asn1.toDer(content);\n\n // skip identifier and length per RFC 2315 9.3\n // skip identifier (1 byte)\n bytes.getByte();\n // read and discard length bytes\n asn1.getBerValueLength(bytes);\n bytes = bytes.getBytes();\n\n // digest content DER value bytes\n for(var oid in mds) {\n mds[oid].start().update(bytes);\n }\n\n // sign content\n var signingTime = new Date();\n for(var i = 0; i < msg.signers.length; ++i) {\n var signer = msg.signers[i];\n\n if(signer.authenticatedAttributes.length === 0) {\n // if ContentInfo content type is not \"Data\", then\n // authenticatedAttributes must be present per RFC 2315\n if(contentType !== forge.pki.oids.data) {\n throw new Error(\n 'Invalid signer; authenticatedAttributes must be present ' +\n 'when the ContentInfo content type is not PKCS#7 Data.');\n }\n } else {\n // process authenticated attributes\n // [0] IMPLICIT\n signer.authenticatedAttributesAsn1 = asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, 0, true, []);\n\n // per RFC 2315, attributes are to be digested using a SET container\n // not the above [0] IMPLICIT container\n var attrsAsn1 = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SET, true, []);\n\n for(var ai = 0; ai < signer.authenticatedAttributes.length; ++ai) {\n var attr = signer.authenticatedAttributes[ai];\n if(attr.type === forge.pki.oids.messageDigest) {\n // use content message digest as value\n attr.value = mds[signer.digestAlgorithm].digest();\n } else if(attr.type === forge.pki.oids.signingTime) {\n // auto-populate signing time if not already set\n if(!attr.value) {\n attr.value = signingTime;\n }\n }\n\n // convert to ASN.1 and push onto Attributes SET (for signing) and\n // onto authenticatedAttributesAsn1 to complete SignedData ASN.1\n // TODO: optimize away duplication\n attrsAsn1.value.push(_attributeToAsn1(attr));\n signer.authenticatedAttributesAsn1.value.push(_attributeToAsn1(attr));\n }\n\n // DER-serialize and digest SET OF attributes only\n bytes = asn1.toDer(attrsAsn1).getBytes();\n signer.md.start().update(bytes);\n }\n\n // sign digest\n signer.signature = signer.key.sign(signer.md, 'RSASSA-PKCS1-V1_5');\n }\n\n // add signer info\n msg.signerInfos = _signersToAsn1(msg.signers);\n }\n};\n\n/**\n * Creates an empty PKCS#7 message of type EncryptedData.\n *\n * @return the message.\n */\np7.createEncryptedData = function() {\n var msg = null;\n msg = {\n type: forge.pki.oids.encryptedData,\n version: 0,\n encryptedContent: {\n algorithm: forge.pki.oids['aes256-CBC']\n },\n\n /**\n * Reads an EncryptedData content block (in ASN.1 format)\n *\n * @param obj The ASN.1 representation of the EncryptedData content block\n */\n fromAsn1: function(obj) {\n // Validate EncryptedData content block and capture data.\n _fromAsn1(msg, obj, p7.asn1.encryptedDataValidator);\n },\n\n /**\n * Decrypt encrypted content\n *\n * @param key The (symmetric) key as a byte buffer\n */\n decrypt: function(key) {\n if(key !== undefined) {\n msg.encryptedContent.key = key;\n }\n _decryptContent(msg);\n }\n };\n return msg;\n};\n\n/**\n * Creates an empty PKCS#7 message of type EnvelopedData.\n *\n * @return the message.\n */\np7.createEnvelopedData = function() {\n var msg = null;\n msg = {\n type: forge.pki.oids.envelopedData,\n version: 0,\n recipients: [],\n encryptedContent: {\n algorithm: forge.pki.oids['aes256-CBC']\n },\n\n /**\n * Reads an EnvelopedData content block (in ASN.1 format)\n *\n * @param obj the ASN.1 representation of the EnvelopedData content block.\n */\n fromAsn1: function(obj) {\n // validate EnvelopedData content block and capture data\n var capture = _fromAsn1(msg, obj, p7.asn1.envelopedDataValidator);\n msg.recipients = _recipientsFromAsn1(capture.recipientInfos.value);\n },\n\n toAsn1: function() {\n // ContentInfo\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // ContentType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(msg.type).getBytes()),\n // [0] EnvelopedData\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(msg.version).getBytes()),\n // RecipientInfos\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true,\n _recipientsToAsn1(msg.recipients)),\n // EncryptedContentInfo\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true,\n _encryptedContentToAsn1(msg.encryptedContent))\n ])\n ])\n ]);\n },\n\n /**\n * Find recipient by X.509 certificate's issuer.\n *\n * @param cert the certificate with the issuer to look for.\n *\n * @return the recipient object.\n */\n findRecipient: function(cert) {\n var sAttr = cert.issuer.attributes;\n\n for(var i = 0; i < msg.recipients.length; ++i) {\n var r = msg.recipients[i];\n var rAttr = r.issuer;\n\n if(r.serialNumber !== cert.serialNumber) {\n continue;\n }\n\n if(rAttr.length !== sAttr.length) {\n continue;\n }\n\n var match = true;\n for(var j = 0; j < sAttr.length; ++j) {\n if(rAttr[j].type !== sAttr[j].type ||\n rAttr[j].value !== sAttr[j].value) {\n match = false;\n break;\n }\n }\n\n if(match) {\n return r;\n }\n }\n\n return null;\n },\n\n /**\n * Decrypt enveloped content\n *\n * @param recipient The recipient object related to the private key\n * @param privKey The (RSA) private key object\n */\n decrypt: function(recipient, privKey) {\n if(msg.encryptedContent.key === undefined && recipient !== undefined &&\n privKey !== undefined) {\n switch(recipient.encryptedContent.algorithm) {\n case forge.pki.oids.rsaEncryption:\n case forge.pki.oids.desCBC:\n var key = privKey.decrypt(recipient.encryptedContent.content);\n msg.encryptedContent.key = forge.util.createBuffer(key);\n break;\n\n default:\n throw new Error('Unsupported asymmetric cipher, ' +\n 'OID ' + recipient.encryptedContent.algorithm);\n }\n }\n\n _decryptContent(msg);\n },\n\n /**\n * Add (another) entity to list of recipients.\n *\n * @param cert The certificate of the entity to add.\n */\n addRecipient: function(cert) {\n msg.recipients.push({\n version: 0,\n issuer: cert.issuer.attributes,\n serialNumber: cert.serialNumber,\n encryptedContent: {\n // We simply assume rsaEncryption here, since forge.pki only\n // supports RSA so far. If the PKI module supports other\n // ciphers one day, we need to modify this one as well.\n algorithm: forge.pki.oids.rsaEncryption,\n key: cert.publicKey\n }\n });\n },\n\n /**\n * Encrypt enveloped content.\n *\n * This function supports two optional arguments, cipher and key, which\n * can be used to influence symmetric encryption. Unless cipher is\n * provided, the cipher specified in encryptedContent.algorithm is used\n * (defaults to AES-256-CBC). If no key is provided, encryptedContent.key\n * is (re-)used. If that one's not set, a random key will be generated\n * automatically.\n *\n * @param [key] The key to be used for symmetric encryption.\n * @param [cipher] The OID of the symmetric cipher to use.\n */\n encrypt: function(key, cipher) {\n // Part 1: Symmetric encryption\n if(msg.encryptedContent.content === undefined) {\n cipher = cipher || msg.encryptedContent.algorithm;\n key = key || msg.encryptedContent.key;\n\n var keyLen, ivLen, ciphFn;\n switch(cipher) {\n case forge.pki.oids['aes128-CBC']:\n keyLen = 16;\n ivLen = 16;\n ciphFn = forge.aes.createEncryptionCipher;\n break;\n\n case forge.pki.oids['aes192-CBC']:\n keyLen = 24;\n ivLen = 16;\n ciphFn = forge.aes.createEncryptionCipher;\n break;\n\n case forge.pki.oids['aes256-CBC']:\n keyLen = 32;\n ivLen = 16;\n ciphFn = forge.aes.createEncryptionCipher;\n break;\n\n case forge.pki.oids['des-EDE3-CBC']:\n keyLen = 24;\n ivLen = 8;\n ciphFn = forge.des.createEncryptionCipher;\n break;\n\n default:\n throw new Error('Unsupported symmetric cipher, OID ' + cipher);\n }\n\n if(key === undefined) {\n key = forge.util.createBuffer(forge.random.getBytes(keyLen));\n } else if(key.length() != keyLen) {\n throw new Error('Symmetric key has wrong length; ' +\n 'got ' + key.length() + ' bytes, expected ' + keyLen + '.');\n }\n\n // Keep a copy of the key & IV in the object, so the caller can\n // use it for whatever reason.\n msg.encryptedContent.algorithm = cipher;\n msg.encryptedContent.key = key;\n msg.encryptedContent.parameter = forge.util.createBuffer(\n forge.random.getBytes(ivLen));\n\n var ciph = ciphFn(key);\n ciph.start(msg.encryptedContent.parameter.copy());\n ciph.update(msg.content);\n\n // The finish function does PKCS#7 padding by default, therefore\n // no action required by us.\n if(!ciph.finish()) {\n throw new Error('Symmetric encryption failed.');\n }\n\n msg.encryptedContent.content = ciph.output;\n }\n\n // Part 2: asymmetric encryption for each recipient\n for(var i = 0; i < msg.recipients.length; ++i) {\n var recipient = msg.recipients[i];\n\n // Nothing to do, encryption already done.\n if(recipient.encryptedContent.content !== undefined) {\n continue;\n }\n\n switch(recipient.encryptedContent.algorithm) {\n case forge.pki.oids.rsaEncryption:\n recipient.encryptedContent.content =\n recipient.encryptedContent.key.encrypt(\n msg.encryptedContent.key.data);\n break;\n\n default:\n throw new Error('Unsupported asymmetric cipher, OID ' +\n recipient.encryptedContent.algorithm);\n }\n }\n }\n };\n return msg;\n};\n\n/**\n * Converts a single recipient from an ASN.1 object.\n *\n * @param obj the ASN.1 RecipientInfo.\n *\n * @return the recipient object.\n */\nfunction _recipientFromAsn1(obj) {\n // validate EnvelopedData content block and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, p7.asn1.recipientInfoValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#7 RecipientInfo. ' +\n 'ASN.1 object is not an PKCS#7 RecipientInfo.');\n error.errors = errors;\n throw error;\n }\n\n return {\n version: capture.version.charCodeAt(0),\n issuer: forge.pki.RDNAttributesAsArray(capture.issuer),\n serialNumber: forge.util.createBuffer(capture.serial).toHex(),\n encryptedContent: {\n algorithm: asn1.derToOid(capture.encAlgorithm),\n parameter: capture.encParameter.value,\n content: capture.encKey\n }\n };\n}\n\n/**\n * Converts a single recipient object to an ASN.1 object.\n *\n * @param obj the recipient object.\n *\n * @return the ASN.1 RecipientInfo.\n */\nfunction _recipientToAsn1(obj) {\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(obj.version).getBytes()),\n // IssuerAndSerialNumber\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Name\n forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),\n // Serial\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n forge.util.hexToBytes(obj.serialNumber))\n ]),\n // KeyEncryptionAlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(obj.encryptedContent.algorithm).getBytes()),\n // Parameter, force NULL, only RSA supported for now.\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]),\n // EncryptedKey\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n obj.encryptedContent.content)\n ]);\n}\n\n/**\n * Map a set of RecipientInfo ASN.1 objects to recipient objects.\n *\n * @param infos an array of ASN.1 representations RecipientInfo (i.e. SET OF).\n *\n * @return an array of recipient objects.\n */\nfunction _recipientsFromAsn1(infos) {\n var ret = [];\n for(var i = 0; i < infos.length; ++i) {\n ret.push(_recipientFromAsn1(infos[i]));\n }\n return ret;\n}\n\n/**\n * Map an array of recipient objects to ASN.1 RecipientInfo objects.\n *\n * @param recipients an array of recipientInfo objects.\n *\n * @return an array of ASN.1 RecipientInfos.\n */\nfunction _recipientsToAsn1(recipients) {\n var ret = [];\n for(var i = 0; i < recipients.length; ++i) {\n ret.push(_recipientToAsn1(recipients[i]));\n }\n return ret;\n}\n\n/**\n * Converts a single signer from an ASN.1 object.\n *\n * @param obj the ASN.1 representation of a SignerInfo.\n *\n * @return the signer object.\n */\nfunction _signerFromAsn1(obj) {\n // validate EnvelopedData content block and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, p7.asn1.signerInfoValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#7 SignerInfo. ' +\n 'ASN.1 object is not an PKCS#7 SignerInfo.');\n error.errors = errors;\n throw error;\n }\n\n var rval = {\n version: capture.version.charCodeAt(0),\n issuer: forge.pki.RDNAttributesAsArray(capture.issuer),\n serialNumber: forge.util.createBuffer(capture.serial).toHex(),\n digestAlgorithm: asn1.derToOid(capture.digestAlgorithm),\n signatureAlgorithm: asn1.derToOid(capture.signatureAlgorithm),\n signature: capture.signature,\n authenticatedAttributes: [],\n unauthenticatedAttributes: []\n };\n\n // TODO: convert attributes\n var authenticatedAttributes = capture.authenticatedAttributes || [];\n var unauthenticatedAttributes = capture.unauthenticatedAttributes || [];\n\n return rval;\n}\n\n/**\n * Converts a single signerInfo object to an ASN.1 object.\n *\n * @param obj the signerInfo object.\n *\n * @return the ASN.1 representation of a SignerInfo.\n */\nfunction _signerToAsn1(obj) {\n // SignerInfo\n var rval = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(obj.version).getBytes()),\n // issuerAndSerialNumber\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // name\n forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),\n // serial\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n forge.util.hexToBytes(obj.serialNumber))\n ]),\n // digestAlgorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(obj.digestAlgorithm).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ])\n ]);\n\n // authenticatedAttributes (OPTIONAL)\n if(obj.authenticatedAttributesAsn1) {\n // add ASN.1 previously generated during signing\n rval.value.push(obj.authenticatedAttributesAsn1);\n }\n\n // digestEncryptionAlgorithm\n rval.value.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(obj.signatureAlgorithm).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]));\n\n // encryptedDigest\n rval.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, obj.signature));\n\n // unauthenticatedAttributes (OPTIONAL)\n if(obj.unauthenticatedAttributes.length > 0) {\n // [1] IMPLICIT\n var attrsAsn1 = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, []);\n for(var i = 0; i < obj.unauthenticatedAttributes.length; ++i) {\n var attr = obj.unauthenticatedAttributes[i];\n attrsAsn1.values.push(_attributeToAsn1(attr));\n }\n rval.value.push(attrsAsn1);\n }\n\n return rval;\n}\n\n/**\n * Map a set of SignerInfo ASN.1 objects to an array of signer objects.\n *\n * @param signerInfoAsn1s an array of ASN.1 SignerInfos (i.e. SET OF).\n *\n * @return an array of signers objects.\n */\nfunction _signersFromAsn1(signerInfoAsn1s) {\n var ret = [];\n for(var i = 0; i < signerInfoAsn1s.length; ++i) {\n ret.push(_signerFromAsn1(signerInfoAsn1s[i]));\n }\n return ret;\n}\n\n/**\n * Map an array of signer objects to ASN.1 objects.\n *\n * @param signers an array of signer objects.\n *\n * @return an array of ASN.1 SignerInfos.\n */\nfunction _signersToAsn1(signers) {\n var ret = [];\n for(var i = 0; i < signers.length; ++i) {\n ret.push(_signerToAsn1(signers[i]));\n }\n return ret;\n}\n\n/**\n * Convert an attribute object to an ASN.1 Attribute.\n *\n * @param attr the attribute object.\n *\n * @return the ASN.1 Attribute.\n */\nfunction _attributeToAsn1(attr) {\n var value;\n\n // TODO: generalize to support more attributes\n if(attr.type === forge.pki.oids.contentType) {\n value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(attr.value).getBytes());\n } else if(attr.type === forge.pki.oids.messageDigest) {\n value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n attr.value.bytes());\n } else if(attr.type === forge.pki.oids.signingTime) {\n /* Note per RFC 2985: Dates between 1 January 1950 and 31 December 2049\n (inclusive) MUST be encoded as UTCTime. Any dates with year values\n before 1950 or after 2049 MUST be encoded as GeneralizedTime. [Further,]\n UTCTime values MUST be expressed in Greenwich Mean Time (Zulu) and MUST\n include seconds (i.e., times are YYMMDDHHMMSSZ), even where the\n number of seconds is zero. Midnight (GMT) must be represented as\n \"YYMMDD000000Z\". */\n // TODO: make these module-level constants\n var jan_1_1950 = new Date('1950-01-01T00:00:00Z');\n var jan_1_2050 = new Date('2050-01-01T00:00:00Z');\n var date = attr.value;\n if(typeof date === 'string') {\n // try to parse date\n var timestamp = Date.parse(date);\n if(!isNaN(timestamp)) {\n date = new Date(timestamp);\n } else if(date.length === 13) {\n // YYMMDDHHMMSSZ (13 chars for UTCTime)\n date = asn1.utcTimeToDate(date);\n } else {\n // assume generalized time\n date = asn1.generalizedTimeToDate(date);\n }\n }\n\n if(date >= jan_1_1950 && date < jan_1_2050) {\n value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.UTCTIME, false,\n asn1.dateToUtcTime(date));\n } else {\n value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.GENERALIZEDTIME, false,\n asn1.dateToGeneralizedTime(date));\n }\n }\n\n // TODO: expose as common API call\n // create a RelativeDistinguishedName set\n // each value in the set is an AttributeTypeAndValue first\n // containing the type (an OID) and second the value\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // AttributeType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(attr.type).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n // AttributeValue\n value\n ])\n ]);\n}\n\n/**\n * Map messages encrypted content to ASN.1 objects.\n *\n * @param ec The encryptedContent object of the message.\n *\n * @return ASN.1 representation of the encryptedContent object (SEQUENCE).\n */\nfunction _encryptedContentToAsn1(ec) {\n return [\n // ContentType, always Data for the moment\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(forge.pki.oids.data).getBytes()),\n // ContentEncryptionAlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // Algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(ec.algorithm).getBytes()),\n // Parameters (IV)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n ec.parameter.getBytes())\n ]),\n // [0] EncryptedContent\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n ec.content.getBytes())\n ])\n ];\n}\n\n/**\n * Reads the \"common part\" of an PKCS#7 content block (in ASN.1 format)\n *\n * This function reads the \"common part\" of the PKCS#7 content blocks\n * EncryptedData and EnvelopedData, i.e. version number and symmetrically\n * encrypted content block.\n *\n * The result of the ASN.1 validate and capture process is returned\n * to allow the caller to extract further data, e.g. the list of recipients\n * in case of a EnvelopedData object.\n *\n * @param msg the PKCS#7 object to read the data to.\n * @param obj the ASN.1 representation of the content block.\n * @param validator the ASN.1 structure validator object to use.\n *\n * @return the value map captured by validator object.\n */\nfunction _fromAsn1(msg, obj, validator) {\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, validator, capture, errors)) {\n var error = new Error('Cannot read PKCS#7 message. ' +\n 'ASN.1 object is not a supported PKCS#7 message.');\n error.errors = error;\n throw error;\n }\n\n // Check contentType, so far we only support (raw) Data.\n var contentType = asn1.derToOid(capture.contentType);\n if(contentType !== forge.pki.oids.data) {\n throw new Error('Unsupported PKCS#7 message. ' +\n 'Only wrapped ContentType Data supported.');\n }\n\n if(capture.encryptedContent) {\n var content = '';\n if(forge.util.isArray(capture.encryptedContent)) {\n for(var i = 0; i < capture.encryptedContent.length; ++i) {\n if(capture.encryptedContent[i].type !== asn1.Type.OCTETSTRING) {\n throw new Error('Malformed PKCS#7 message, expecting encrypted ' +\n 'content constructed of only OCTET STRING objects.');\n }\n content += capture.encryptedContent[i].value;\n }\n } else {\n content = capture.encryptedContent;\n }\n msg.encryptedContent = {\n algorithm: asn1.derToOid(capture.encAlgorithm),\n parameter: forge.util.createBuffer(capture.encParameter.value),\n content: forge.util.createBuffer(content)\n };\n }\n\n if(capture.content) {\n var content = '';\n if(forge.util.isArray(capture.content)) {\n for(var i = 0; i < capture.content.length; ++i) {\n if(capture.content[i].type !== asn1.Type.OCTETSTRING) {\n throw new Error('Malformed PKCS#7 message, expecting ' +\n 'content constructed of only OCTET STRING objects.');\n }\n content += capture.content[i].value;\n }\n } else {\n content = capture.content;\n }\n msg.content = forge.util.createBuffer(content);\n }\n\n msg.version = capture.version.charCodeAt(0);\n msg.rawCapture = capture;\n\n return capture;\n}\n\n/**\n * Decrypt the symmetrically encrypted content block of the PKCS#7 message.\n *\n * Decryption is skipped in case the PKCS#7 message object already has a\n * (decrypted) content attribute. The algorithm, key and cipher parameters\n * (probably the iv) are taken from the encryptedContent attribute of the\n * message object.\n *\n * @param The PKCS#7 message object.\n */\nfunction _decryptContent(msg) {\n if(msg.encryptedContent.key === undefined) {\n throw new Error('Symmetric key not available.');\n }\n\n if(msg.content === undefined) {\n var ciph;\n\n switch(msg.encryptedContent.algorithm) {\n case forge.pki.oids['aes128-CBC']:\n case forge.pki.oids['aes192-CBC']:\n case forge.pki.oids['aes256-CBC']:\n ciph = forge.aes.createDecryptionCipher(msg.encryptedContent.key);\n break;\n\n case forge.pki.oids['desCBC']:\n case forge.pki.oids['des-EDE3-CBC']:\n ciph = forge.des.createDecryptionCipher(msg.encryptedContent.key);\n break;\n\n default:\n throw new Error('Unsupported symmetric cipher, OID ' +\n msg.encryptedContent.algorithm);\n }\n ciph.start(msg.encryptedContent.parameter);\n ciph.update(msg.encryptedContent.content);\n\n if(!ciph.finish()) {\n throw new Error('Symmetric decryption failed.');\n }\n\n msg.content = ciph.output;\n }\n}\n","/**\n * Javascript implementation of ASN.1 validators for PKCS#7 v1.5.\n *\n * @author Dave Longley\n * @author Stefan Siegl\n *\n * Copyright (c) 2012-2015 Digital Bazaar, Inc.\n * Copyright (c) 2012 Stefan Siegl \n *\n * The ASN.1 representation of PKCS#7 is as follows\n * (see RFC #2315 for details, http://www.ietf.org/rfc/rfc2315.txt):\n *\n * A PKCS#7 message consists of a ContentInfo on root level, which may\n * contain any number of further ContentInfo nested into it.\n *\n * ContentInfo ::= SEQUENCE {\n * contentType ContentType,\n * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL\n * }\n *\n * ContentType ::= OBJECT IDENTIFIER\n *\n * EnvelopedData ::= SEQUENCE {\n * version Version,\n * recipientInfos RecipientInfos,\n * encryptedContentInfo EncryptedContentInfo\n * }\n *\n * EncryptedData ::= SEQUENCE {\n * version Version,\n * encryptedContentInfo EncryptedContentInfo\n * }\n *\n * id-signedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)\n * us(840) rsadsi(113549) pkcs(1) pkcs7(7) 2 }\n *\n * SignedData ::= SEQUENCE {\n * version INTEGER,\n * digestAlgorithms DigestAlgorithmIdentifiers,\n * contentInfo ContentInfo,\n * certificates [0] IMPLICIT Certificates OPTIONAL,\n * crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,\n * signerInfos SignerInfos\n * }\n *\n * SignerInfos ::= SET OF SignerInfo\n *\n * SignerInfo ::= SEQUENCE {\n * version Version,\n * issuerAndSerialNumber IssuerAndSerialNumber,\n * digestAlgorithm DigestAlgorithmIdentifier,\n * authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL,\n * digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier,\n * encryptedDigest EncryptedDigest,\n * unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL\n * }\n *\n * EncryptedDigest ::= OCTET STRING\n *\n * Attributes ::= SET OF Attribute\n *\n * Attribute ::= SEQUENCE {\n * attrType OBJECT IDENTIFIER,\n * attrValues SET OF AttributeValue\n * }\n *\n * AttributeValue ::= ANY\n *\n * Version ::= INTEGER\n *\n * RecipientInfos ::= SET OF RecipientInfo\n *\n * EncryptedContentInfo ::= SEQUENCE {\n * contentType ContentType,\n * contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,\n * encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL\n * }\n *\n * ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier\n *\n * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters\n * for the algorithm, if any. In the case of AES and DES3, there is only one,\n * the IV.\n *\n * AlgorithmIdentifer ::= SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * parameters ANY DEFINED BY algorithm OPTIONAL\n * }\n *\n * EncryptedContent ::= OCTET STRING\n *\n * RecipientInfo ::= SEQUENCE {\n * version Version,\n * issuerAndSerialNumber IssuerAndSerialNumber,\n * keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,\n * encryptedKey EncryptedKey\n * }\n *\n * IssuerAndSerialNumber ::= SEQUENCE {\n * issuer Name,\n * serialNumber CertificateSerialNumber\n * }\n *\n * CertificateSerialNumber ::= INTEGER\n *\n * KeyEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier\n *\n * EncryptedKey ::= OCTET STRING\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./util');\n\n// shortcut for ASN.1 API\nvar asn1 = forge.asn1;\n\n// shortcut for PKCS#7 API\nvar p7v = module.exports = forge.pkcs7asn1 = forge.pkcs7asn1 || {};\nforge.pkcs7 = forge.pkcs7 || {};\nforge.pkcs7.asn1 = p7v;\n\nvar contentInfoValidator = {\n name: 'ContentInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'ContentInfo.ContentType',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'contentType'\n }, {\n name: 'ContentInfo.content',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n optional: true,\n captureAsn1: 'content'\n }]\n};\np7v.contentInfoValidator = contentInfoValidator;\n\nvar encryptedContentInfoValidator = {\n name: 'EncryptedContentInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EncryptedContentInfo.contentType',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'contentType'\n }, {\n name: 'EncryptedContentInfo.contentEncryptionAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EncryptedContentInfo.contentEncryptionAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'encAlgorithm'\n }, {\n name: 'EncryptedContentInfo.contentEncryptionAlgorithm.parameter',\n tagClass: asn1.Class.UNIVERSAL,\n captureAsn1: 'encParameter'\n }]\n }, {\n name: 'EncryptedContentInfo.encryptedContent',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n /* The PKCS#7 structure output by OpenSSL somewhat differs from what\n * other implementations do generate.\n *\n * OpenSSL generates a structure like this:\n * SEQUENCE {\n * ...\n * [0]\n * 26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38\n * C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45\n * ...\n * }\n *\n * Whereas other implementations (and this PKCS#7 module) generate:\n * SEQUENCE {\n * ...\n * [0] {\n * OCTET STRING\n * 26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38\n * C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45\n * ...\n * }\n * }\n *\n * In order to support both, we just capture the context specific\n * field here. The OCTET STRING bit is removed below.\n */\n capture: 'encryptedContent',\n captureAsn1: 'encryptedContentAsn1'\n }]\n};\n\np7v.envelopedDataValidator = {\n name: 'EnvelopedData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EnvelopedData.Version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n }, {\n name: 'EnvelopedData.RecipientInfos',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true,\n captureAsn1: 'recipientInfos'\n }].concat(encryptedContentInfoValidator)\n};\n\np7v.encryptedDataValidator = {\n name: 'EncryptedData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'EncryptedData.Version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n }].concat(encryptedContentInfoValidator)\n};\n\nvar signerValidator = {\n name: 'SignerInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SignerInfo.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false\n }, {\n name: 'SignerInfo.issuerAndSerialNumber',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SignerInfo.issuerAndSerialNumber.issuer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'issuer'\n }, {\n name: 'SignerInfo.issuerAndSerialNumber.serialNumber',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'serial'\n }]\n }, {\n name: 'SignerInfo.digestAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SignerInfo.digestAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'digestAlgorithm'\n }, {\n name: 'SignerInfo.digestAlgorithm.parameter',\n tagClass: asn1.Class.UNIVERSAL,\n constructed: false,\n captureAsn1: 'digestParameter',\n optional: true\n }]\n }, {\n name: 'SignerInfo.authenticatedAttributes',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n optional: true,\n capture: 'authenticatedAttributes'\n }, {\n name: 'SignerInfo.digestEncryptionAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n capture: 'signatureAlgorithm'\n }, {\n name: 'SignerInfo.encryptedDigest',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'signature'\n }, {\n name: 'SignerInfo.unauthenticatedAttributes',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 1,\n constructed: true,\n optional: true,\n capture: 'unauthenticatedAttributes'\n }]\n};\n\np7v.signedDataValidator = {\n name: 'SignedData',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'SignedData.Version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n }, {\n name: 'SignedData.DigestAlgorithms',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true,\n captureAsn1: 'digestAlgorithms'\n },\n contentInfoValidator,\n {\n name: 'SignedData.Certificates',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n optional: true,\n captureAsn1: 'certificates'\n }, {\n name: 'SignedData.CertificateRevocationLists',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 1,\n optional: true,\n captureAsn1: 'crls'\n }, {\n name: 'SignedData.SignerInfos',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n capture: 'signerInfos',\n optional: true,\n value: [signerValidator]\n }]\n};\n\np7v.recipientInfoValidator = {\n name: 'RecipientInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'RecipientInfo.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'version'\n }, {\n name: 'RecipientInfo.issuerAndSerial',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'RecipientInfo.issuerAndSerial.issuer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'issuer'\n }, {\n name: 'RecipientInfo.issuerAndSerial.serialNumber',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'serial'\n }]\n }, {\n name: 'RecipientInfo.keyEncryptionAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'RecipientInfo.keyEncryptionAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'encAlgorithm'\n }, {\n name: 'RecipientInfo.keyEncryptionAlgorithm.parameter',\n tagClass: asn1.Class.UNIVERSAL,\n constructed: false,\n captureAsn1: 'encParameter'\n }]\n }, {\n name: 'RecipientInfo.encryptedKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'encKey'\n }]\n};\n","/**\n * Javascript implementation of a basic Public Key Infrastructure, including\n * support for RSA public and private keys.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./oids');\nrequire('./pbe');\nrequire('./pem');\nrequire('./pbkdf2');\nrequire('./pkcs12');\nrequire('./pss');\nrequire('./rsa');\nrequire('./util');\nrequire('./x509');\n\n// shortcut for asn.1 API\nvar asn1 = forge.asn1;\n\n/* Public Key Infrastructure (PKI) implementation. */\nvar pki = module.exports = forge.pki = forge.pki || {};\n\n/**\n * NOTE: THIS METHOD IS DEPRECATED. Use pem.decode() instead.\n *\n * Converts PEM-formatted data to DER.\n *\n * @param pem the PEM-formatted data.\n *\n * @return the DER-formatted data.\n */\npki.pemToDer = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert PEM to DER; PEM is encrypted.');\n }\n return forge.util.createBuffer(msg.body);\n};\n\n/**\n * Converts an RSA private key from PEM format.\n *\n * @param pem the PEM-formatted private key.\n *\n * @return the private key.\n */\npki.privateKeyFromPem = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'PRIVATE KEY' && msg.type !== 'RSA PRIVATE KEY') {\n var error = new Error('Could not convert private key from PEM; PEM ' +\n 'header type is not \"PRIVATE KEY\" or \"RSA PRIVATE KEY\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert private key from PEM; PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body);\n\n return pki.privateKeyFromAsn1(obj);\n};\n\n/**\n * Converts an RSA private key to PEM format.\n *\n * @param key the private key.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted private key.\n */\npki.privateKeyToPem = function(key, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'RSA PRIVATE KEY',\n body: asn1.toDer(pki.privateKeyToAsn1(key)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Converts a PrivateKeyInfo to PEM format.\n *\n * @param pki the PrivateKeyInfo.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted private key.\n */\npki.privateKeyInfoToPem = function(pki, maxline) {\n // convert to DER, then PEM-encode\n var msg = {\n type: 'PRIVATE KEY',\n body: asn1.toDer(pki).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n","/**\n * Prime number generation API.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\nrequire('./jsbn');\nrequire('./random');\n\n(function() {\n\n// forge.prime already defined\nif(forge.prime) {\n module.exports = forge.prime;\n return;\n}\n\n/* PRIME API */\nvar prime = module.exports = forge.prime = forge.prime || {};\n\nvar BigInteger = forge.jsbn.BigInteger;\n\n// primes are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29\nvar GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];\nvar THIRTY = new BigInteger(null);\nTHIRTY.fromInt(30);\nvar op_or = function(x, y) {return x|y;};\n\n/**\n * Generates a random probable prime with the given number of bits.\n *\n * Alternative algorithms can be specified by name as a string or as an\n * object with custom options like so:\n *\n * {\n * name: 'PRIMEINC',\n * options: {\n * maxBlockTime: ,\n * millerRabinTests: ,\n * workerScript: ,\n * workers: .\n * workLoad: the size of the work load, ie: number of possible prime\n * numbers for each web worker to check per work assignment,\n * (default: 100).\n * }\n * }\n *\n * @param bits the number of bits for the prime number.\n * @param options the options to use.\n * [algorithm] the algorithm to use (default: 'PRIMEINC').\n * [prng] a custom crypto-secure pseudo-random number generator to use,\n * that must define \"getBytesSync\".\n *\n * @return callback(err, num) called once the operation completes.\n */\nprime.generateProbablePrime = function(bits, options, callback) {\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n // default to PRIMEINC algorithm\n var algorithm = options.algorithm || 'PRIMEINC';\n if(typeof algorithm === 'string') {\n algorithm = {name: algorithm};\n }\n algorithm.options = algorithm.options || {};\n\n // create prng with api that matches BigInteger secure random\n var prng = options.prng || forge.random;\n var rng = {\n // x is an array to fill with bytes\n nextBytes: function(x) {\n var b = prng.getBytesSync(x.length);\n for(var i = 0; i < x.length; ++i) {\n x[i] = b.charCodeAt(i);\n }\n }\n };\n\n if(algorithm.name === 'PRIMEINC') {\n return primeincFindPrime(bits, rng, algorithm.options, callback);\n }\n\n throw new Error('Invalid prime generation algorithm: ' + algorithm.name);\n};\n\nfunction primeincFindPrime(bits, rng, options, callback) {\n if('workers' in options) {\n return primeincFindPrimeWithWorkers(bits, rng, options, callback);\n }\n return primeincFindPrimeWithoutWorkers(bits, rng, options, callback);\n}\n\nfunction primeincFindPrimeWithoutWorkers(bits, rng, options, callback) {\n // initialize random number\n var num = generateRandom(bits, rng);\n\n /* Note: All primes are of the form 30k+i for i < 30 and gcd(30, i)=1. The\n number we are given is always aligned at 30k + 1. Each time the number is\n determined not to be prime we add to get to the next 'i', eg: if the number\n was at 30k + 1 we add 6. */\n var deltaIdx = 0;\n\n // get required number of MR tests\n var mrTests = getMillerRabinTests(num.bitLength());\n if('millerRabinTests' in options) {\n mrTests = options.millerRabinTests;\n }\n\n // find prime nearest to 'num' for maxBlockTime ms\n // 10 ms gives 5ms of leeway for other calculations before dropping\n // below 60fps (1000/60 == 16.67), but in reality, the number will\n // likely be higher due to an 'atomic' big int modPow\n var maxBlockTime = 10;\n if('maxBlockTime' in options) {\n maxBlockTime = options.maxBlockTime;\n }\n\n _primeinc(num, bits, rng, deltaIdx, mrTests, maxBlockTime, callback);\n}\n\nfunction _primeinc(num, bits, rng, deltaIdx, mrTests, maxBlockTime, callback) {\n var start = +new Date();\n do {\n // overflow, regenerate random number\n if(num.bitLength() > bits) {\n num = generateRandom(bits, rng);\n }\n // do primality test\n if(num.isProbablePrime(mrTests)) {\n return callback(null, num);\n }\n // get next potential prime\n num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);\n } while(maxBlockTime < 0 || (+new Date() - start < maxBlockTime));\n\n // keep trying later\n forge.util.setImmediate(function() {\n _primeinc(num, bits, rng, deltaIdx, mrTests, maxBlockTime, callback);\n });\n}\n\n// NOTE: This algorithm is indeterminate in nature because workers\n// run in parallel looking at different segments of numbers. Even if this\n// algorithm is run twice with the same input from a predictable RNG, it\n// may produce different outputs.\nfunction primeincFindPrimeWithWorkers(bits, rng, options, callback) {\n // web workers unavailable\n if(typeof Worker === 'undefined') {\n return primeincFindPrimeWithoutWorkers(bits, rng, options, callback);\n }\n\n // initialize random number\n var num = generateRandom(bits, rng);\n\n // use web workers to generate keys\n var numWorkers = options.workers;\n var workLoad = options.workLoad || 100;\n var range = workLoad * 30 / 8;\n var workerScript = options.workerScript || 'forge/prime.worker.js';\n if(numWorkers === -1) {\n return forge.util.estimateCores(function(err, cores) {\n if(err) {\n // default to 2\n cores = 2;\n }\n numWorkers = cores - 1;\n generate();\n });\n }\n generate();\n\n function generate() {\n // require at least 1 worker\n numWorkers = Math.max(1, numWorkers);\n\n // TODO: consider optimizing by starting workers outside getPrime() ...\n // note that in order to clean up they will have to be made internally\n // asynchronous which may actually be slower\n\n // start workers immediately\n var workers = [];\n for(var i = 0; i < numWorkers; ++i) {\n // FIXME: fix path or use blob URLs\n workers[i] = new Worker(workerScript);\n }\n var running = numWorkers;\n\n // listen for requests from workers and assign ranges to find prime\n for(var i = 0; i < numWorkers; ++i) {\n workers[i].addEventListener('message', workerMessage);\n }\n\n /* Note: The distribution of random numbers is unknown. Therefore, each\n web worker is continuously allocated a range of numbers to check for a\n random number until one is found.\n\n Every 30 numbers will be checked just 8 times, because prime numbers\n have the form:\n\n 30k+i, for i < 30 and gcd(30, i)=1 (there are 8 values of i for this)\n\n Therefore, if we want a web worker to run N checks before asking for\n a new range of numbers, each range must contain N*30/8 numbers.\n\n For 100 checks (workLoad), this is a range of 375. */\n\n var found = false;\n function workerMessage(e) {\n // ignore message, prime already found\n if(found) {\n return;\n }\n\n --running;\n var data = e.data;\n if(data.found) {\n // terminate all workers\n for(var i = 0; i < workers.length; ++i) {\n workers[i].terminate();\n }\n found = true;\n return callback(null, new BigInteger(data.prime, 16));\n }\n\n // overflow, regenerate random number\n if(num.bitLength() > bits) {\n num = generateRandom(bits, rng);\n }\n\n // assign new range to check\n var hex = num.toString(16);\n\n // start prime search\n e.target.postMessage({\n hex: hex,\n workLoad: workLoad\n });\n\n num.dAddOffset(range, 0);\n }\n }\n}\n\n/**\n * Generates a random number using the given number of bits and RNG.\n *\n * @param bits the number of bits for the number.\n * @param rng the random number generator to use.\n *\n * @return the random number.\n */\nfunction generateRandom(bits, rng) {\n var num = new BigInteger(bits, rng);\n // force MSB set\n var bits1 = bits - 1;\n if(!num.testBit(bits1)) {\n num.bitwiseTo(BigInteger.ONE.shiftLeft(bits1), op_or, num);\n }\n // align number on 30k+1 boundary\n num.dAddOffset(31 - num.mod(THIRTY).byteValue(), 0);\n return num;\n}\n\n/**\n * Returns the required number of Miller-Rabin tests to generate a\n * prime with an error probability of (1/2)^80.\n *\n * See Handbook of Applied Cryptography Chapter 4, Table 4.4.\n *\n * @param bits the bit size.\n *\n * @return the required number of iterations.\n */\nfunction getMillerRabinTests(bits) {\n if(bits <= 100) return 27;\n if(bits <= 150) return 18;\n if(bits <= 200) return 15;\n if(bits <= 250) return 12;\n if(bits <= 300) return 9;\n if(bits <= 350) return 8;\n if(bits <= 400) return 7;\n if(bits <= 500) return 6;\n if(bits <= 600) return 5;\n if(bits <= 800) return 4;\n if(bits <= 1250) return 3;\n return 2;\n}\n\n})();\n","/**\n * A javascript implementation of a cryptographically-secure\n * Pseudo Random Number Generator (PRNG). The Fortuna algorithm is followed\n * here though the use of SHA-256 is not enforced; when generating an\n * a PRNG context, the hashing algorithm and block cipher used for\n * the generator are specified via a plugin.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./util');\n\nvar _crypto = null;\nif(forge.util.isNodejs && !forge.options.usePureJavaScript &&\n !process.versions['node-webkit']) {\n _crypto = require('crypto');\n}\n\n/* PRNG API */\nvar prng = module.exports = forge.prng = forge.prng || {};\n\n/**\n * Creates a new PRNG context.\n *\n * A PRNG plugin must be passed in that will provide:\n *\n * 1. A function that initializes the key and seed of a PRNG context. It\n * will be given a 16 byte key and a 16 byte seed. Any key expansion\n * or transformation of the seed from a byte string into an array of\n * integers (or similar) should be performed.\n * 2. The cryptographic function used by the generator. It takes a key and\n * a seed.\n * 3. A seed increment function. It takes the seed and returns seed + 1.\n * 4. An api to create a message digest.\n *\n * For an example, see random.js.\n *\n * @param plugin the PRNG plugin to use.\n */\nprng.create = function(plugin) {\n var ctx = {\n plugin: plugin,\n key: null,\n seed: null,\n time: null,\n // number of reseeds so far\n reseeds: 0,\n // amount of data generated so far\n generated: 0,\n // no initial key bytes\n keyBytes: ''\n };\n\n // create 32 entropy pools (each is a message digest)\n var md = plugin.md;\n var pools = new Array(32);\n for(var i = 0; i < 32; ++i) {\n pools[i] = md.create();\n }\n ctx.pools = pools;\n\n // entropy pools are written to cyclically, starting at index 0\n ctx.pool = 0;\n\n /**\n * Generates random bytes. The bytes may be generated synchronously or\n * asynchronously. Web workers must use the asynchronous interface or\n * else the behavior is undefined.\n *\n * @param count the number of random bytes to generate.\n * @param [callback(err, bytes)] called once the operation completes.\n *\n * @return count random bytes as a string.\n */\n ctx.generate = function(count, callback) {\n // do synchronously\n if(!callback) {\n return ctx.generateSync(count);\n }\n\n // simple generator using counter-based CBC\n var cipher = ctx.plugin.cipher;\n var increment = ctx.plugin.increment;\n var formatKey = ctx.plugin.formatKey;\n var formatSeed = ctx.plugin.formatSeed;\n var b = forge.util.createBuffer();\n\n // paranoid deviation from Fortuna:\n // reset key for every request to protect previously\n // generated random bytes should the key be discovered;\n // there is no 100ms based reseeding because of this\n // forced reseed for every `generate` call\n ctx.key = null;\n\n generate();\n\n function generate(err) {\n if(err) {\n return callback(err);\n }\n\n // sufficient bytes generated\n if(b.length() >= count) {\n return callback(null, b.getBytes(count));\n }\n\n // if amount of data generated is greater than 1 MiB, trigger reseed\n if(ctx.generated > 0xfffff) {\n ctx.key = null;\n }\n\n if(ctx.key === null) {\n // prevent stack overflow\n return forge.util.nextTick(function() {\n _reseed(generate);\n });\n }\n\n // generate the random bytes\n var bytes = cipher(ctx.key, ctx.seed);\n ctx.generated += bytes.length;\n b.putBytes(bytes);\n\n // generate bytes for a new key and seed\n ctx.key = formatKey(cipher(ctx.key, increment(ctx.seed)));\n ctx.seed = formatSeed(cipher(ctx.key, ctx.seed));\n\n forge.util.setImmediate(generate);\n }\n };\n\n /**\n * Generates random bytes synchronously.\n *\n * @param count the number of random bytes to generate.\n *\n * @return count random bytes as a string.\n */\n ctx.generateSync = function(count) {\n // simple generator using counter-based CBC\n var cipher = ctx.plugin.cipher;\n var increment = ctx.plugin.increment;\n var formatKey = ctx.plugin.formatKey;\n var formatSeed = ctx.plugin.formatSeed;\n\n // paranoid deviation from Fortuna:\n // reset key for every request to protect previously\n // generated random bytes should the key be discovered;\n // there is no 100ms based reseeding because of this\n // forced reseed for every `generateSync` call\n ctx.key = null;\n\n var b = forge.util.createBuffer();\n while(b.length() < count) {\n // if amount of data generated is greater than 1 MiB, trigger reseed\n if(ctx.generated > 0xfffff) {\n ctx.key = null;\n }\n\n if(ctx.key === null) {\n _reseedSync();\n }\n\n // generate the random bytes\n var bytes = cipher(ctx.key, ctx.seed);\n ctx.generated += bytes.length;\n b.putBytes(bytes);\n\n // generate bytes for a new key and seed\n ctx.key = formatKey(cipher(ctx.key, increment(ctx.seed)));\n ctx.seed = formatSeed(cipher(ctx.key, ctx.seed));\n }\n\n return b.getBytes(count);\n };\n\n /**\n * Private function that asynchronously reseeds a generator.\n *\n * @param callback(err) called once the operation completes.\n */\n function _reseed(callback) {\n if(ctx.pools[0].messageLength >= 32) {\n _seed();\n return callback();\n }\n // not enough seed data...\n var needed = (32 - ctx.pools[0].messageLength) << 5;\n ctx.seedFile(needed, function(err, bytes) {\n if(err) {\n return callback(err);\n }\n ctx.collect(bytes);\n _seed();\n callback();\n });\n }\n\n /**\n * Private function that synchronously reseeds a generator.\n */\n function _reseedSync() {\n if(ctx.pools[0].messageLength >= 32) {\n return _seed();\n }\n // not enough seed data...\n var needed = (32 - ctx.pools[0].messageLength) << 5;\n ctx.collect(ctx.seedFileSync(needed));\n _seed();\n }\n\n /**\n * Private function that seeds a generator once enough bytes are available.\n */\n function _seed() {\n // update reseed count\n ctx.reseeds = (ctx.reseeds === 0xffffffff) ? 0 : ctx.reseeds + 1;\n\n // goal is to update `key` via:\n // key = hash(key + s)\n // where 's' is all collected entropy from selected pools, then...\n\n // create a plugin-based message digest\n var md = ctx.plugin.md.create();\n\n // consume current key bytes\n md.update(ctx.keyBytes);\n\n // digest the entropy of pools whose index k meet the\n // condition 'n mod 2^k == 0' where n is the number of reseeds\n var _2powK = 1;\n for(var k = 0; k < 32; ++k) {\n if(ctx.reseeds % _2powK === 0) {\n md.update(ctx.pools[k].digest().getBytes());\n ctx.pools[k].start();\n }\n _2powK = _2powK << 1;\n }\n\n // get digest for key bytes\n ctx.keyBytes = md.digest().getBytes();\n\n // paranoid deviation from Fortuna:\n // update `seed` via `seed = hash(key)`\n // instead of initializing to zero once and only\n // ever incrementing it\n md.start();\n md.update(ctx.keyBytes);\n var seedBytes = md.digest().getBytes();\n\n // update state\n ctx.key = ctx.plugin.formatKey(ctx.keyBytes);\n ctx.seed = ctx.plugin.formatSeed(seedBytes);\n ctx.generated = 0;\n }\n\n /**\n * The built-in default seedFile. This seedFile is used when entropy\n * is needed immediately.\n *\n * @param needed the number of bytes that are needed.\n *\n * @return the random bytes.\n */\n function defaultSeedFile(needed) {\n // use window.crypto.getRandomValues strong source of entropy if available\n var getRandomValues = null;\n var globalScope = forge.util.globalScope;\n var _crypto = globalScope.crypto || globalScope.msCrypto;\n if(_crypto && _crypto.getRandomValues) {\n getRandomValues = function(arr) {\n return _crypto.getRandomValues(arr);\n };\n }\n\n var b = forge.util.createBuffer();\n if(getRandomValues) {\n while(b.length() < needed) {\n // max byte length is 65536 before QuotaExceededError is thrown\n // http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues\n var count = Math.max(1, Math.min(needed - b.length(), 65536) / 4);\n var entropy = new Uint32Array(Math.floor(count));\n try {\n getRandomValues(entropy);\n for(var i = 0; i < entropy.length; ++i) {\n b.putInt32(entropy[i]);\n }\n } catch(e) {\n /* only ignore QuotaExceededError */\n if(!(typeof QuotaExceededError !== 'undefined' &&\n e instanceof QuotaExceededError)) {\n throw e;\n }\n }\n }\n }\n\n // be sad and add some weak random data\n if(b.length() < needed) {\n /* Draws from Park-Miller \"minimal standard\" 31 bit PRNG,\n implemented with David G. Carta's optimization: with 32 bit math\n and without division (Public Domain). */\n var hi, lo, next;\n var seed = Math.floor(Math.random() * 0x010000);\n while(b.length() < needed) {\n lo = 16807 * (seed & 0xFFFF);\n hi = 16807 * (seed >> 16);\n lo += (hi & 0x7FFF) << 16;\n lo += hi >> 15;\n lo = (lo & 0x7FFFFFFF) + (lo >> 31);\n seed = lo & 0xFFFFFFFF;\n\n // consume lower 3 bytes of seed\n for(var i = 0; i < 3; ++i) {\n // throw in more pseudo random\n next = seed >>> (i << 3);\n next ^= Math.floor(Math.random() * 0x0100);\n b.putByte(String.fromCharCode(next & 0xFF));\n }\n }\n }\n\n return b.getBytes(needed);\n }\n // initialize seed file APIs\n if(_crypto) {\n // use nodejs async API\n ctx.seedFile = function(needed, callback) {\n _crypto.randomBytes(needed, function(err, bytes) {\n if(err) {\n return callback(err);\n }\n callback(null, bytes.toString());\n });\n };\n // use nodejs sync API\n ctx.seedFileSync = function(needed) {\n return _crypto.randomBytes(needed).toString();\n };\n } else {\n ctx.seedFile = function(needed, callback) {\n try {\n callback(null, defaultSeedFile(needed));\n } catch(e) {\n callback(e);\n }\n };\n ctx.seedFileSync = defaultSeedFile;\n }\n\n /**\n * Adds entropy to a prng ctx's accumulator.\n *\n * @param bytes the bytes of entropy as a string.\n */\n ctx.collect = function(bytes) {\n // iterate over pools distributing entropy cyclically\n var count = bytes.length;\n for(var i = 0; i < count; ++i) {\n ctx.pools[ctx.pool].update(bytes.substr(i, 1));\n ctx.pool = (ctx.pool === 31) ? 0 : ctx.pool + 1;\n }\n };\n\n /**\n * Collects an integer of n bits.\n *\n * @param i the integer entropy.\n * @param n the number of bits in the integer.\n */\n ctx.collectInt = function(i, n) {\n var bytes = '';\n for(var x = 0; x < n; x += 8) {\n bytes += String.fromCharCode((i >> x) & 0xFF);\n }\n ctx.collect(bytes);\n };\n\n /**\n * Registers a Web Worker to receive immediate entropy from the main thread.\n * This method is required until Web Workers can access the native crypto\n * API. This method should be called twice for each created worker, once in\n * the main thread, and once in the worker itself.\n *\n * @param worker the worker to register.\n */\n ctx.registerWorker = function(worker) {\n // worker receives random bytes\n if(worker === self) {\n ctx.seedFile = function(needed, callback) {\n function listener(e) {\n var data = e.data;\n if(data.forge && data.forge.prng) {\n self.removeEventListener('message', listener);\n callback(data.forge.prng.err, data.forge.prng.bytes);\n }\n }\n self.addEventListener('message', listener);\n self.postMessage({forge: {prng: {needed: needed}}});\n };\n } else {\n // main thread sends random bytes upon request\n var listener = function(e) {\n var data = e.data;\n if(data.forge && data.forge.prng) {\n ctx.seedFile(data.forge.prng.needed, function(err, bytes) {\n worker.postMessage({forge: {prng: {err: err, bytes: bytes}}});\n });\n }\n };\n // TODO: do we need to remove the event listener when the worker dies?\n worker.addEventListener('message', listener);\n }\n };\n\n return ctx;\n};\n","/**\n * Javascript implementation of PKCS#1 PSS signature padding.\n *\n * @author Stefan Siegl\n *\n * Copyright (c) 2012 Stefan Siegl \n */\nvar forge = require('./forge');\nrequire('./random');\nrequire('./util');\n\n// shortcut for PSS API\nvar pss = module.exports = forge.pss = forge.pss || {};\n\n/**\n * Creates a PSS signature scheme object.\n *\n * There are several ways to provide a salt for encoding:\n *\n * 1. Specify the saltLength only and the built-in PRNG will generate it.\n * 2. Specify the saltLength and a custom PRNG with 'getBytesSync' defined that\n * will be used.\n * 3. Specify the salt itself as a forge.util.ByteBuffer.\n *\n * @param options the options to use:\n * md the message digest object to use, a forge md instance.\n * mgf the mask generation function to use, a forge mgf instance.\n * [saltLength] the length of the salt in octets.\n * [prng] the pseudo-random number generator to use to produce a salt.\n * [salt] the salt to use when encoding.\n *\n * @return a signature scheme object.\n */\npss.create = function(options) {\n // backwards compatibility w/legacy args: hash, mgf, sLen\n if(arguments.length === 3) {\n options = {\n md: arguments[0],\n mgf: arguments[1],\n saltLength: arguments[2]\n };\n }\n\n var hash = options.md;\n var mgf = options.mgf;\n var hLen = hash.digestLength;\n\n var salt_ = options.salt || null;\n if(typeof salt_ === 'string') {\n // assume binary-encoded string\n salt_ = forge.util.createBuffer(salt_);\n }\n\n var sLen;\n if('saltLength' in options) {\n sLen = options.saltLength;\n } else if(salt_ !== null) {\n sLen = salt_.length();\n } else {\n throw new Error('Salt length not specified or specific salt not given.');\n }\n\n if(salt_ !== null && salt_.length() !== sLen) {\n throw new Error('Given salt length does not match length of given salt.');\n }\n\n var prng = options.prng || forge.random;\n\n var pssobj = {};\n\n /**\n * Encodes a PSS signature.\n *\n * This function implements EMSA-PSS-ENCODE as per RFC 3447, section 9.1.1.\n *\n * @param md the message digest object with the hash to sign.\n * @param modsBits the length of the RSA modulus in bits.\n *\n * @return the encoded message as a binary-encoded string of length\n * ceil((modBits - 1) / 8).\n */\n pssobj.encode = function(md, modBits) {\n var i;\n var emBits = modBits - 1;\n var emLen = Math.ceil(emBits / 8);\n\n /* 2. Let mHash = Hash(M), an octet string of length hLen. */\n var mHash = md.digest().getBytes();\n\n /* 3. If emLen < hLen + sLen + 2, output \"encoding error\" and stop. */\n if(emLen < hLen + sLen + 2) {\n throw new Error('Message is too long to encrypt.');\n }\n\n /* 4. Generate a random octet string salt of length sLen; if sLen = 0,\n * then salt is the empty string. */\n var salt;\n if(salt_ === null) {\n salt = prng.getBytesSync(sLen);\n } else {\n salt = salt_.bytes();\n }\n\n /* 5. Let M' = (0x)00 00 00 00 00 00 00 00 || mHash || salt; */\n var m_ = new forge.util.ByteBuffer();\n m_.fillWithByte(0, 8);\n m_.putBytes(mHash);\n m_.putBytes(salt);\n\n /* 6. Let H = Hash(M'), an octet string of length hLen. */\n hash.start();\n hash.update(m_.getBytes());\n var h = hash.digest().getBytes();\n\n /* 7. Generate an octet string PS consisting of emLen - sLen - hLen - 2\n * zero octets. The length of PS may be 0. */\n var ps = new forge.util.ByteBuffer();\n ps.fillWithByte(0, emLen - sLen - hLen - 2);\n\n /* 8. Let DB = PS || 0x01 || salt; DB is an octet string of length\n * emLen - hLen - 1. */\n ps.putByte(0x01);\n ps.putBytes(salt);\n var db = ps.getBytes();\n\n /* 9. Let dbMask = MGF(H, emLen - hLen - 1). */\n var maskLen = emLen - hLen - 1;\n var dbMask = mgf.generate(h, maskLen);\n\n /* 10. Let maskedDB = DB \\xor dbMask. */\n var maskedDB = '';\n for(i = 0; i < maskLen; i++) {\n maskedDB += String.fromCharCode(db.charCodeAt(i) ^ dbMask.charCodeAt(i));\n }\n\n /* 11. Set the leftmost 8emLen - emBits bits of the leftmost octet in\n * maskedDB to zero. */\n var mask = (0xFF00 >> (8 * emLen - emBits)) & 0xFF;\n maskedDB = String.fromCharCode(maskedDB.charCodeAt(0) & ~mask) +\n maskedDB.substr(1);\n\n /* 12. Let EM = maskedDB || H || 0xbc.\n * 13. Output EM. */\n return maskedDB + h + String.fromCharCode(0xbc);\n };\n\n /**\n * Verifies a PSS signature.\n *\n * This function implements EMSA-PSS-VERIFY as per RFC 3447, section 9.1.2.\n *\n * @param mHash the message digest hash, as a binary-encoded string, to\n * compare against the signature.\n * @param em the encoded message, as a binary-encoded string\n * (RSA decryption result).\n * @param modsBits the length of the RSA modulus in bits.\n *\n * @return true if the signature was verified, false if not.\n */\n pssobj.verify = function(mHash, em, modBits) {\n var i;\n var emBits = modBits - 1;\n var emLen = Math.ceil(emBits / 8);\n\n /* c. Convert the message representative m to an encoded message EM\n * of length emLen = ceil((modBits - 1) / 8) octets, where modBits\n * is the length in bits of the RSA modulus n */\n em = em.substr(-emLen);\n\n /* 3. If emLen < hLen + sLen + 2, output \"inconsistent\" and stop. */\n if(emLen < hLen + sLen + 2) {\n throw new Error('Inconsistent parameters to PSS signature verification.');\n }\n\n /* 4. If the rightmost octet of EM does not have hexadecimal value\n * 0xbc, output \"inconsistent\" and stop. */\n if(em.charCodeAt(emLen - 1) !== 0xbc) {\n throw new Error('Encoded message does not end in 0xBC.');\n }\n\n /* 5. Let maskedDB be the leftmost emLen - hLen - 1 octets of EM, and\n * let H be the next hLen octets. */\n var maskLen = emLen - hLen - 1;\n var maskedDB = em.substr(0, maskLen);\n var h = em.substr(maskLen, hLen);\n\n /* 6. If the leftmost 8emLen - emBits bits of the leftmost octet in\n * maskedDB are not all equal to zero, output \"inconsistent\" and stop. */\n var mask = (0xFF00 >> (8 * emLen - emBits)) & 0xFF;\n if((maskedDB.charCodeAt(0) & mask) !== 0) {\n throw new Error('Bits beyond keysize not zero as expected.');\n }\n\n /* 7. Let dbMask = MGF(H, emLen - hLen - 1). */\n var dbMask = mgf.generate(h, maskLen);\n\n /* 8. Let DB = maskedDB \\xor dbMask. */\n var db = '';\n for(i = 0; i < maskLen; i++) {\n db += String.fromCharCode(maskedDB.charCodeAt(i) ^ dbMask.charCodeAt(i));\n }\n\n /* 9. Set the leftmost 8emLen - emBits bits of the leftmost octet\n * in DB to zero. */\n db = String.fromCharCode(db.charCodeAt(0) & ~mask) + db.substr(1);\n\n /* 10. If the emLen - hLen - sLen - 2 leftmost octets of DB are not zero\n * or if the octet at position emLen - hLen - sLen - 1 (the leftmost\n * position is \"position 1\") does not have hexadecimal value 0x01,\n * output \"inconsistent\" and stop. */\n var checkLen = emLen - hLen - sLen - 2;\n for(i = 0; i < checkLen; i++) {\n if(db.charCodeAt(i) !== 0x00) {\n throw new Error('Leftmost octets not zero as expected');\n }\n }\n\n if(db.charCodeAt(checkLen) !== 0x01) {\n throw new Error('Inconsistent PSS signature, 0x01 marker not found');\n }\n\n /* 11. Let salt be the last sLen octets of DB. */\n var salt = db.substr(-sLen);\n\n /* 12. Let M' = (0x)00 00 00 00 00 00 00 00 || mHash || salt */\n var m_ = new forge.util.ByteBuffer();\n m_.fillWithByte(0, 8);\n m_.putBytes(mHash);\n m_.putBytes(salt);\n\n /* 13. Let H' = Hash(M'), an octet string of length hLen. */\n hash.start();\n hash.update(m_.getBytes());\n var h_ = hash.digest().getBytes();\n\n /* 14. If H = H', output \"consistent.\" Otherwise, output \"inconsistent.\" */\n return h === h_;\n };\n\n return pssobj;\n};\n","/**\n * An API for getting cryptographically-secure random bytes. The bytes are\n * generated using the Fortuna algorithm devised by Bruce Schneier and\n * Niels Ferguson.\n *\n * Getting strong random bytes is not yet easy to do in javascript. The only\n * truish random entropy that can be collected is from the mouse, keyboard, or\n * from timing with respect to page loads, etc. This generator makes a poor\n * attempt at providing random bytes when those sources haven't yet provided\n * enough entropy to initially seed or to reseed the PRNG.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2009-2014 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./sha256');\nrequire('./prng');\nrequire('./util');\n\n(function() {\n\n// forge.random already defined\nif(forge.random && forge.random.getBytes) {\n module.exports = forge.random;\n return;\n}\n\n(function(jQuery) {\n\n// the default prng plugin, uses AES-128\nvar prng_aes = {};\nvar _prng_aes_output = new Array(4);\nvar _prng_aes_buffer = forge.util.createBuffer();\nprng_aes.formatKey = function(key) {\n // convert the key into 32-bit integers\n var tmp = forge.util.createBuffer(key);\n key = new Array(4);\n key[0] = tmp.getInt32();\n key[1] = tmp.getInt32();\n key[2] = tmp.getInt32();\n key[3] = tmp.getInt32();\n\n // return the expanded key\n return forge.aes._expandKey(key, false);\n};\nprng_aes.formatSeed = function(seed) {\n // convert seed into 32-bit integers\n var tmp = forge.util.createBuffer(seed);\n seed = new Array(4);\n seed[0] = tmp.getInt32();\n seed[1] = tmp.getInt32();\n seed[2] = tmp.getInt32();\n seed[3] = tmp.getInt32();\n return seed;\n};\nprng_aes.cipher = function(key, seed) {\n forge.aes._updateBlock(key, seed, _prng_aes_output, false);\n _prng_aes_buffer.putInt32(_prng_aes_output[0]);\n _prng_aes_buffer.putInt32(_prng_aes_output[1]);\n _prng_aes_buffer.putInt32(_prng_aes_output[2]);\n _prng_aes_buffer.putInt32(_prng_aes_output[3]);\n return _prng_aes_buffer.getBytes();\n};\nprng_aes.increment = function(seed) {\n // FIXME: do we care about carry or signed issues?\n ++seed[3];\n return seed;\n};\nprng_aes.md = forge.md.sha256;\n\n/**\n * Creates a new PRNG.\n */\nfunction spawnPrng() {\n var ctx = forge.prng.create(prng_aes);\n\n /**\n * Gets random bytes. If a native secure crypto API is unavailable, this\n * method tries to make the bytes more unpredictable by drawing from data that\n * can be collected from the user of the browser, eg: mouse movement.\n *\n * If a callback is given, this method will be called asynchronously.\n *\n * @param count the number of random bytes to get.\n * @param [callback(err, bytes)] called once the operation completes.\n *\n * @return the random bytes in a string.\n */\n ctx.getBytes = function(count, callback) {\n return ctx.generate(count, callback);\n };\n\n /**\n * Gets random bytes asynchronously. If a native secure crypto API is\n * unavailable, this method tries to make the bytes more unpredictable by\n * drawing from data that can be collected from the user of the browser,\n * eg: mouse movement.\n *\n * @param count the number of random bytes to get.\n *\n * @return the random bytes in a string.\n */\n ctx.getBytesSync = function(count) {\n return ctx.generate(count);\n };\n\n return ctx;\n}\n\n// create default prng context\nvar _ctx = spawnPrng();\n\n// add other sources of entropy only if window.crypto.getRandomValues is not\n// available -- otherwise this source will be automatically used by the prng\nvar getRandomValues = null;\nvar globalScope = forge.util.globalScope;\nvar _crypto = globalScope.crypto || globalScope.msCrypto;\nif(_crypto && _crypto.getRandomValues) {\n getRandomValues = function(arr) {\n return _crypto.getRandomValues(arr);\n };\n}\n\nif(forge.options.usePureJavaScript ||\n (!forge.util.isNodejs && !getRandomValues)) {\n // if this is a web worker, do not use weak entropy, instead register to\n // receive strong entropy asynchronously from the main thread\n if(typeof window === 'undefined' || window.document === undefined) {\n // FIXME:\n }\n\n // get load time entropy\n _ctx.collectInt(+new Date(), 32);\n\n // add some entropy from navigator object\n if(typeof(navigator) !== 'undefined') {\n var _navBytes = '';\n for(var key in navigator) {\n try {\n if(typeof(navigator[key]) == 'string') {\n _navBytes += navigator[key];\n }\n } catch(e) {\n /* Some navigator keys might not be accessible, e.g. the geolocation\n attribute throws an exception if touched in Mozilla chrome://\n context.\n\n Silently ignore this and just don't use this as a source of\n entropy. */\n }\n }\n _ctx.collect(_navBytes);\n _navBytes = null;\n }\n\n // add mouse and keyboard collectors if jquery is available\n if(jQuery) {\n // set up mouse entropy capture\n jQuery().mousemove(function(e) {\n // add mouse coords\n _ctx.collectInt(e.clientX, 16);\n _ctx.collectInt(e.clientY, 16);\n });\n\n // set up keyboard entropy capture\n jQuery().keypress(function(e) {\n _ctx.collectInt(e.charCode, 8);\n });\n }\n}\n\n/* Random API */\nif(!forge.random) {\n forge.random = _ctx;\n} else {\n // extend forge.random with _ctx\n for(var key in _ctx) {\n forge.random[key] = _ctx[key];\n }\n}\n\n// expose spawn PRNG\nforge.random.createInstance = spawnPrng;\n\nmodule.exports = forge.random;\n\n})(typeof(jQuery) !== 'undefined' ? jQuery : null);\n\n})();\n","/**\n * RC2 implementation.\n *\n * @author Stefan Siegl\n *\n * Copyright (c) 2012 Stefan Siegl \n *\n * Information on the RC2 cipher is available from RFC #2268,\n * http://www.ietf.org/rfc/rfc2268.txt\n */\nvar forge = require('./forge');\nrequire('./util');\n\nvar piTable = [\n 0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d,\n 0xc6, 0x7e, 0x37, 0x83, 0x2b, 0x76, 0x53, 0x8e, 0x62, 0x4c, 0x64, 0x88, 0x44, 0x8b, 0xfb, 0xa2,\n 0x17, 0x9a, 0x59, 0xf5, 0x87, 0xb3, 0x4f, 0x13, 0x61, 0x45, 0x6d, 0x8d, 0x09, 0x81, 0x7d, 0x32,\n 0xbd, 0x8f, 0x40, 0xeb, 0x86, 0xb7, 0x7b, 0x0b, 0xf0, 0x95, 0x21, 0x22, 0x5c, 0x6b, 0x4e, 0x82,\n 0x54, 0xd6, 0x65, 0x93, 0xce, 0x60, 0xb2, 0x1c, 0x73, 0x56, 0xc0, 0x14, 0xa7, 0x8c, 0xf1, 0xdc,\n 0x12, 0x75, 0xca, 0x1f, 0x3b, 0xbe, 0xe4, 0xd1, 0x42, 0x3d, 0xd4, 0x30, 0xa3, 0x3c, 0xb6, 0x26,\n 0x6f, 0xbf, 0x0e, 0xda, 0x46, 0x69, 0x07, 0x57, 0x27, 0xf2, 0x1d, 0x9b, 0xbc, 0x94, 0x43, 0x03,\n 0xf8, 0x11, 0xc7, 0xf6, 0x90, 0xef, 0x3e, 0xe7, 0x06, 0xc3, 0xd5, 0x2f, 0xc8, 0x66, 0x1e, 0xd7,\n 0x08, 0xe8, 0xea, 0xde, 0x80, 0x52, 0xee, 0xf7, 0x84, 0xaa, 0x72, 0xac, 0x35, 0x4d, 0x6a, 0x2a,\n 0x96, 0x1a, 0xd2, 0x71, 0x5a, 0x15, 0x49, 0x74, 0x4b, 0x9f, 0xd0, 0x5e, 0x04, 0x18, 0xa4, 0xec,\n 0xc2, 0xe0, 0x41, 0x6e, 0x0f, 0x51, 0xcb, 0xcc, 0x24, 0x91, 0xaf, 0x50, 0xa1, 0xf4, 0x70, 0x39,\n 0x99, 0x7c, 0x3a, 0x85, 0x23, 0xb8, 0xb4, 0x7a, 0xfc, 0x02, 0x36, 0x5b, 0x25, 0x55, 0x97, 0x31,\n 0x2d, 0x5d, 0xfa, 0x98, 0xe3, 0x8a, 0x92, 0xae, 0x05, 0xdf, 0x29, 0x10, 0x67, 0x6c, 0xba, 0xc9,\n 0xd3, 0x00, 0xe6, 0xcf, 0xe1, 0x9e, 0xa8, 0x2c, 0x63, 0x16, 0x01, 0x3f, 0x58, 0xe2, 0x89, 0xa9,\n 0x0d, 0x38, 0x34, 0x1b, 0xab, 0x33, 0xff, 0xb0, 0xbb, 0x48, 0x0c, 0x5f, 0xb9, 0xb1, 0xcd, 0x2e,\n 0xc5, 0xf3, 0xdb, 0x47, 0xe5, 0xa5, 0x9c, 0x77, 0x0a, 0xa6, 0x20, 0x68, 0xfe, 0x7f, 0xc1, 0xad\n];\n\nvar s = [1, 2, 3, 5];\n\n/**\n * Rotate a word left by given number of bits.\n *\n * Bits that are shifted out on the left are put back in on the right\n * hand side.\n *\n * @param word The word to shift left.\n * @param bits The number of bits to shift by.\n * @return The rotated word.\n */\nvar rol = function(word, bits) {\n return ((word << bits) & 0xffff) | ((word & 0xffff) >> (16 - bits));\n};\n\n/**\n * Rotate a word right by given number of bits.\n *\n * Bits that are shifted out on the right are put back in on the left\n * hand side.\n *\n * @param word The word to shift right.\n * @param bits The number of bits to shift by.\n * @return The rotated word.\n */\nvar ror = function(word, bits) {\n return ((word & 0xffff) >> bits) | ((word << (16 - bits)) & 0xffff);\n};\n\n/* RC2 API */\nmodule.exports = forge.rc2 = forge.rc2 || {};\n\n/**\n * Perform RC2 key expansion as per RFC #2268, section 2.\n *\n * @param key variable-length user key (between 1 and 128 bytes)\n * @param effKeyBits number of effective key bits (default: 128)\n * @return the expanded RC2 key (ByteBuffer of 128 bytes)\n */\nforge.rc2.expandKey = function(key, effKeyBits) {\n if(typeof key === 'string') {\n key = forge.util.createBuffer(key);\n }\n effKeyBits = effKeyBits || 128;\n\n /* introduce variables that match the names used in RFC #2268 */\n var L = key;\n var T = key.length();\n var T1 = effKeyBits;\n var T8 = Math.ceil(T1 / 8);\n var TM = 0xff >> (T1 & 0x07);\n var i;\n\n for(i = T; i < 128; i++) {\n L.putByte(piTable[(L.at(i - 1) + L.at(i - T)) & 0xff]);\n }\n\n L.setAt(128 - T8, piTable[L.at(128 - T8) & TM]);\n\n for(i = 127 - T8; i >= 0; i--) {\n L.setAt(i, piTable[L.at(i + 1) ^ L.at(i + T8)]);\n }\n\n return L;\n};\n\n/**\n * Creates a RC2 cipher object.\n *\n * @param key the symmetric key to use (as base for key generation).\n * @param bits the number of effective key bits.\n * @param encrypt false for decryption, true for encryption.\n *\n * @return the cipher.\n */\nvar createCipher = function(key, bits, encrypt) {\n var _finish = false, _input = null, _output = null, _iv = null;\n var mixRound, mashRound;\n var i, j, K = [];\n\n /* Expand key and fill into K[] Array */\n key = forge.rc2.expandKey(key, bits);\n for(i = 0; i < 64; i++) {\n K.push(key.getInt16Le());\n }\n\n if(encrypt) {\n /**\n * Perform one mixing round \"in place\".\n *\n * @param R Array of four words to perform mixing on.\n */\n mixRound = function(R) {\n for(i = 0; i < 4; i++) {\n R[i] += K[j] + (R[(i + 3) % 4] & R[(i + 2) % 4]) +\n ((~R[(i + 3) % 4]) & R[(i + 1) % 4]);\n R[i] = rol(R[i], s[i]);\n j++;\n }\n };\n\n /**\n * Perform one mashing round \"in place\".\n *\n * @param R Array of four words to perform mashing on.\n */\n mashRound = function(R) {\n for(i = 0; i < 4; i++) {\n R[i] += K[R[(i + 3) % 4] & 63];\n }\n };\n } else {\n /**\n * Perform one r-mixing round \"in place\".\n *\n * @param R Array of four words to perform mixing on.\n */\n mixRound = function(R) {\n for(i = 3; i >= 0; i--) {\n R[i] = ror(R[i], s[i]);\n R[i] -= K[j] + (R[(i + 3) % 4] & R[(i + 2) % 4]) +\n ((~R[(i + 3) % 4]) & R[(i + 1) % 4]);\n j--;\n }\n };\n\n /**\n * Perform one r-mashing round \"in place\".\n *\n * @param R Array of four words to perform mashing on.\n */\n mashRound = function(R) {\n for(i = 3; i >= 0; i--) {\n R[i] -= K[R[(i + 3) % 4] & 63];\n }\n };\n }\n\n /**\n * Run the specified cipher execution plan.\n *\n * This function takes four words from the input buffer, applies the IV on\n * it (if requested) and runs the provided execution plan.\n *\n * The plan must be put together in form of a array of arrays. Where the\n * outer one is simply a list of steps to perform and the inner one needs\n * to have two elements: the first one telling how many rounds to perform,\n * the second one telling what to do (i.e. the function to call).\n *\n * @param {Array} plan The plan to execute.\n */\n var runPlan = function(plan) {\n var R = [];\n\n /* Get data from input buffer and fill the four words into R */\n for(i = 0; i < 4; i++) {\n var val = _input.getInt16Le();\n\n if(_iv !== null) {\n if(encrypt) {\n /* We're encrypting, apply the IV first. */\n val ^= _iv.getInt16Le();\n } else {\n /* We're decryption, keep cipher text for next block. */\n _iv.putInt16Le(val);\n }\n }\n\n R.push(val & 0xffff);\n }\n\n /* Reset global \"j\" variable as per spec. */\n j = encrypt ? 0 : 63;\n\n /* Run execution plan. */\n for(var ptr = 0; ptr < plan.length; ptr++) {\n for(var ctr = 0; ctr < plan[ptr][0]; ctr++) {\n plan[ptr][1](R);\n }\n }\n\n /* Write back result to output buffer. */\n for(i = 0; i < 4; i++) {\n if(_iv !== null) {\n if(encrypt) {\n /* We're encrypting in CBC-mode, feed back encrypted bytes into\n IV buffer to carry it forward to next block. */\n _iv.putInt16Le(R[i]);\n } else {\n R[i] ^= _iv.getInt16Le();\n }\n }\n\n _output.putInt16Le(R[i]);\n }\n };\n\n /* Create cipher object */\n var cipher = null;\n cipher = {\n /**\n * Starts or restarts the encryption or decryption process, whichever\n * was previously configured.\n *\n * To use the cipher in CBC mode, iv may be given either as a string\n * of bytes, or as a byte buffer. For ECB mode, give null as iv.\n *\n * @param iv the initialization vector to use, null for ECB mode.\n * @param output the output the buffer to write to, null to create one.\n */\n start: function(iv, output) {\n if(iv) {\n /* CBC mode */\n if(typeof iv === 'string') {\n iv = forge.util.createBuffer(iv);\n }\n }\n\n _finish = false;\n _input = forge.util.createBuffer();\n _output = output || new forge.util.createBuffer();\n _iv = iv;\n\n cipher.output = _output;\n },\n\n /**\n * Updates the next block.\n *\n * @param input the buffer to read from.\n */\n update: function(input) {\n if(!_finish) {\n // not finishing, so fill the input buffer with more input\n _input.putBuffer(input);\n }\n\n while(_input.length() >= 8) {\n runPlan([\n [ 5, mixRound ],\n [ 1, mashRound ],\n [ 6, mixRound ],\n [ 1, mashRound ],\n [ 5, mixRound ]\n ]);\n }\n },\n\n /**\n * Finishes encrypting or decrypting.\n *\n * @param pad a padding function to use, null for PKCS#7 padding,\n * signature(blockSize, buffer, decrypt).\n *\n * @return true if successful, false on error.\n */\n finish: function(pad) {\n var rval = true;\n\n if(encrypt) {\n if(pad) {\n rval = pad(8, _input, !encrypt);\n } else {\n // add PKCS#7 padding to block (each pad byte is the\n // value of the number of pad bytes)\n var padding = (_input.length() === 8) ? 8 : (8 - _input.length());\n _input.fillWithByte(padding, padding);\n }\n }\n\n if(rval) {\n // do final update\n _finish = true;\n cipher.update();\n }\n\n if(!encrypt) {\n // check for error: input data not a multiple of block size\n rval = (_input.length() === 0);\n if(rval) {\n if(pad) {\n rval = pad(8, _output, !encrypt);\n } else {\n // ensure padding byte count is valid\n var len = _output.length();\n var count = _output.at(len - 1);\n\n if(count > len) {\n rval = false;\n } else {\n // trim off padding bytes\n _output.truncate(count);\n }\n }\n }\n }\n\n return rval;\n }\n };\n\n return cipher;\n};\n\n/**\n * Creates an RC2 cipher object to encrypt data in ECB or CBC mode using the\n * given symmetric key. The output will be stored in the 'output' member\n * of the returned cipher.\n *\n * The key and iv may be given as a string of bytes or a byte buffer.\n * The cipher is initialized to use 128 effective key bits.\n *\n * @param key the symmetric key to use.\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n *\n * @return the cipher.\n */\nforge.rc2.startEncrypting = function(key, iv, output) {\n var cipher = forge.rc2.createEncryptionCipher(key, 128);\n cipher.start(iv, output);\n return cipher;\n};\n\n/**\n * Creates an RC2 cipher object to encrypt data in ECB or CBC mode using the\n * given symmetric key.\n *\n * The key may be given as a string of bytes or a byte buffer.\n *\n * To start encrypting call start() on the cipher with an iv and optional\n * output buffer.\n *\n * @param key the symmetric key to use.\n *\n * @return the cipher.\n */\nforge.rc2.createEncryptionCipher = function(key, bits) {\n return createCipher(key, bits, true);\n};\n\n/**\n * Creates an RC2 cipher object to decrypt data in ECB or CBC mode using the\n * given symmetric key. The output will be stored in the 'output' member\n * of the returned cipher.\n *\n * The key and iv may be given as a string of bytes or a byte buffer.\n * The cipher is initialized to use 128 effective key bits.\n *\n * @param key the symmetric key to use.\n * @param iv the initialization vector to use.\n * @param output the buffer to write to, null to create one.\n *\n * @return the cipher.\n */\nforge.rc2.startDecrypting = function(key, iv, output) {\n var cipher = forge.rc2.createDecryptionCipher(key, 128);\n cipher.start(iv, output);\n return cipher;\n};\n\n/**\n * Creates an RC2 cipher object to decrypt data in ECB or CBC mode using the\n * given symmetric key.\n *\n * The key may be given as a string of bytes or a byte buffer.\n *\n * To start decrypting call start() on the cipher with an iv and optional\n * output buffer.\n *\n * @param key the symmetric key to use.\n *\n * @return the cipher.\n */\nforge.rc2.createDecryptionCipher = function(key, bits) {\n return createCipher(key, bits, false);\n};\n","/**\n * Javascript implementation of basic RSA algorithms.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n *\n * The only algorithm currently supported for PKI is RSA.\n *\n * An RSA key is often stored in ASN.1 DER format. The SubjectPublicKeyInfo\n * ASN.1 structure is composed of an algorithm of type AlgorithmIdentifier\n * and a subjectPublicKey of type bit string.\n *\n * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters\n * for the algorithm, if any. In the case of RSA, there aren't any.\n *\n * SubjectPublicKeyInfo ::= SEQUENCE {\n * algorithm AlgorithmIdentifier,\n * subjectPublicKey BIT STRING\n * }\n *\n * AlgorithmIdentifer ::= SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * parameters ANY DEFINED BY algorithm OPTIONAL\n * }\n *\n * For an RSA public key, the subjectPublicKey is:\n *\n * RSAPublicKey ::= SEQUENCE {\n * modulus INTEGER, -- n\n * publicExponent INTEGER -- e\n * }\n *\n * PrivateKeyInfo ::= SEQUENCE {\n * version Version,\n * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,\n * privateKey PrivateKey,\n * attributes [0] IMPLICIT Attributes OPTIONAL\n * }\n *\n * Version ::= INTEGER\n * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier\n * PrivateKey ::= OCTET STRING\n * Attributes ::= SET OF Attribute\n *\n * An RSA private key as the following structure:\n *\n * RSAPrivateKey ::= SEQUENCE {\n * version Version,\n * modulus INTEGER, -- n\n * publicExponent INTEGER, -- e\n * privateExponent INTEGER, -- d\n * prime1 INTEGER, -- p\n * prime2 INTEGER, -- q\n * exponent1 INTEGER, -- d mod (p-1)\n * exponent2 INTEGER, -- d mod (q-1)\n * coefficient INTEGER -- (inverse of q) mod p\n * }\n *\n * Version ::= INTEGER\n *\n * The OID for the RSA key algorithm is: 1.2.840.113549.1.1.1\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./jsbn');\nrequire('./oids');\nrequire('./pkcs1');\nrequire('./prime');\nrequire('./random');\nrequire('./util');\n\nif(typeof BigInteger === 'undefined') {\n var BigInteger = forge.jsbn.BigInteger;\n}\n\nvar _crypto = forge.util.isNodejs ? require('crypto') : null;\n\n// shortcut for asn.1 API\nvar asn1 = forge.asn1;\n\n// shortcut for util API\nvar util = forge.util;\n\n/*\n * RSA encryption and decryption, see RFC 2313.\n */\nforge.pki = forge.pki || {};\nmodule.exports = forge.pki.rsa = forge.rsa = forge.rsa || {};\nvar pki = forge.pki;\n\n// for finding primes, which are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29\nvar GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];\n\n// validator for a PrivateKeyInfo structure\nvar privateKeyValidator = {\n // PrivateKeyInfo\n name: 'PrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // Version (INTEGER)\n name: 'PrivateKeyInfo.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyVersion'\n }, {\n // privateKeyAlgorithm\n name: 'PrivateKeyInfo.privateKeyAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'privateKeyOid'\n }]\n }, {\n // PrivateKey\n name: 'PrivateKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OCTETSTRING,\n constructed: false,\n capture: 'privateKey'\n }]\n};\n\n// validator for an RSA private key\nvar rsaPrivateKeyValidator = {\n // RSAPrivateKey\n name: 'RSAPrivateKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // Version (INTEGER)\n name: 'RSAPrivateKey.version',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyVersion'\n }, {\n // modulus (n)\n name: 'RSAPrivateKey.modulus',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyModulus'\n }, {\n // publicExponent (e)\n name: 'RSAPrivateKey.publicExponent',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyPublicExponent'\n }, {\n // privateExponent (d)\n name: 'RSAPrivateKey.privateExponent',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyPrivateExponent'\n }, {\n // prime1 (p)\n name: 'RSAPrivateKey.prime1',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyPrime1'\n }, {\n // prime2 (q)\n name: 'RSAPrivateKey.prime2',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyPrime2'\n }, {\n // exponent1 (d mod (p-1))\n name: 'RSAPrivateKey.exponent1',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyExponent1'\n }, {\n // exponent2 (d mod (q-1))\n name: 'RSAPrivateKey.exponent2',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyExponent2'\n }, {\n // coefficient ((inverse of q) mod p)\n name: 'RSAPrivateKey.coefficient',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'privateKeyCoefficient'\n }]\n};\n\n// validator for an RSA public key\nvar rsaPublicKeyValidator = {\n // RSAPublicKey\n name: 'RSAPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // modulus (n)\n name: 'RSAPublicKey.modulus',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'publicKeyModulus'\n }, {\n // publicExponent (e)\n name: 'RSAPublicKey.exponent',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'publicKeyExponent'\n }]\n};\n\n// validator for an SubjectPublicKeyInfo structure\n// Note: Currently only works with an RSA public key\nvar publicKeyValidator = forge.pki.rsa.publicKeyValidator = {\n name: 'SubjectPublicKeyInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'subjectPublicKeyInfo',\n value: [{\n name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'publicKeyOid'\n }]\n }, {\n // subjectPublicKey\n name: 'SubjectPublicKeyInfo.subjectPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n value: [{\n // RSAPublicKey\n name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n optional: true,\n captureAsn1: 'rsaPublicKey'\n }]\n }]\n};\n\n/**\n * Wrap digest in DigestInfo object.\n *\n * This function implements EMSA-PKCS1-v1_5-ENCODE as per RFC 3447.\n *\n * DigestInfo ::= SEQUENCE {\n * digestAlgorithm DigestAlgorithmIdentifier,\n * digest Digest\n * }\n *\n * DigestAlgorithmIdentifier ::= AlgorithmIdentifier\n * Digest ::= OCTET STRING\n *\n * @param md the message digest object with the hash to sign.\n *\n * @return the encoded message (ready for RSA encrytion)\n */\nvar emsaPkcs1v15encode = function(md) {\n // get the oid for the algorithm\n var oid;\n if(md.algorithm in pki.oids) {\n oid = pki.oids[md.algorithm];\n } else {\n var error = new Error('Unknown message digest algorithm.');\n error.algorithm = md.algorithm;\n throw error;\n }\n var oidBytes = asn1.oidToDer(oid).getBytes();\n\n // create the digest info\n var digestInfo = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n var digestAlgorithm = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n digestAlgorithm.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OID, false, oidBytes));\n digestAlgorithm.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.NULL, false, ''));\n var digest = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,\n false, md.digest().getBytes());\n digestInfo.value.push(digestAlgorithm);\n digestInfo.value.push(digest);\n\n // encode digest info\n return asn1.toDer(digestInfo).getBytes();\n};\n\n/**\n * Performs x^c mod n (RSA encryption or decryption operation).\n *\n * @param x the number to raise and mod.\n * @param key the key to use.\n * @param pub true if the key is public, false if private.\n *\n * @return the result of x^c mod n.\n */\nvar _modPow = function(x, key, pub) {\n if(pub) {\n return x.modPow(key.e, key.n);\n }\n\n if(!key.p || !key.q) {\n // allow calculation without CRT params (slow)\n return x.modPow(key.d, key.n);\n }\n\n // pre-compute dP, dQ, and qInv if necessary\n if(!key.dP) {\n key.dP = key.d.mod(key.p.subtract(BigInteger.ONE));\n }\n if(!key.dQ) {\n key.dQ = key.d.mod(key.q.subtract(BigInteger.ONE));\n }\n if(!key.qInv) {\n key.qInv = key.q.modInverse(key.p);\n }\n\n /* Chinese remainder theorem (CRT) states:\n\n Suppose n1, n2, ..., nk are positive integers which are pairwise\n coprime (n1 and n2 have no common factors other than 1). For any\n integers x1, x2, ..., xk there exists an integer x solving the\n system of simultaneous congruences (where ~= means modularly\n congruent so a ~= b mod n means a mod n = b mod n):\n\n x ~= x1 mod n1\n x ~= x2 mod n2\n ...\n x ~= xk mod nk\n\n This system of congruences has a single simultaneous solution x\n between 0 and n - 1. Furthermore, each xk solution and x itself\n is congruent modulo the product n = n1*n2*...*nk.\n So x1 mod n = x2 mod n = xk mod n = x mod n.\n\n The single simultaneous solution x can be solved with the following\n equation:\n\n x = sum(xi*ri*si) mod n where ri = n/ni and si = ri^-1 mod ni.\n\n Where x is less than n, xi = x mod ni.\n\n For RSA we are only concerned with k = 2. The modulus n = pq, where\n p and q are coprime. The RSA decryption algorithm is:\n\n y = x^d mod n\n\n Given the above:\n\n x1 = x^d mod p\n r1 = n/p = q\n s1 = q^-1 mod p\n x2 = x^d mod q\n r2 = n/q = p\n s2 = p^-1 mod q\n\n So y = (x1r1s1 + x2r2s2) mod n\n = ((x^d mod p)q(q^-1 mod p) + (x^d mod q)p(p^-1 mod q)) mod n\n\n According to Fermat's Little Theorem, if the modulus P is prime,\n for any integer A not evenly divisible by P, A^(P-1) ~= 1 mod P.\n Since A is not divisible by P it follows that if:\n N ~= M mod (P - 1), then A^N mod P = A^M mod P. Therefore:\n\n A^N mod P = A^(M mod (P - 1)) mod P. (The latter takes less effort\n to calculate). In order to calculate x^d mod p more quickly the\n exponent d mod (p - 1) is stored in the RSA private key (the same\n is done for x^d mod q). These values are referred to as dP and dQ\n respectively. Therefore we now have:\n\n y = ((x^dP mod p)q(q^-1 mod p) + (x^dQ mod q)p(p^-1 mod q)) mod n\n\n Since we'll be reducing x^dP by modulo p (same for q) we can also\n reduce x by p (and q respectively) before hand. Therefore, let\n\n xp = ((x mod p)^dP mod p), and\n xq = ((x mod q)^dQ mod q), yielding:\n\n y = (xp*q*(q^-1 mod p) + xq*p*(p^-1 mod q)) mod n\n\n This can be further reduced to a simple algorithm that only\n requires 1 inverse (the q inverse is used) to be used and stored.\n The algorithm is called Garner's algorithm. If qInv is the\n inverse of q, we simply calculate:\n\n y = (qInv*(xp - xq) mod p) * q + xq\n\n However, there are two further complications. First, we need to\n ensure that xp > xq to prevent signed BigIntegers from being used\n so we add p until this is true (since we will be mod'ing with\n p anyway). Then, there is a known timing attack on algorithms\n using the CRT. To mitigate this risk, \"cryptographic blinding\"\n should be used. This requires simply generating a random number r\n between 0 and n-1 and its inverse and multiplying x by r^e before\n calculating y and then multiplying y by r^-1 afterwards. Note that\n r must be coprime with n (gcd(r, n) === 1) in order to have an\n inverse.\n */\n\n // cryptographic blinding\n var r;\n do {\n r = new BigInteger(\n forge.util.bytesToHex(forge.random.getBytes(key.n.bitLength() / 8)),\n 16);\n } while(r.compareTo(key.n) >= 0 || !r.gcd(key.n).equals(BigInteger.ONE));\n x = x.multiply(r.modPow(key.e, key.n)).mod(key.n);\n\n // calculate xp and xq\n var xp = x.mod(key.p).modPow(key.dP, key.p);\n var xq = x.mod(key.q).modPow(key.dQ, key.q);\n\n // xp must be larger than xq to avoid signed bit usage\n while(xp.compareTo(xq) < 0) {\n xp = xp.add(key.p);\n }\n\n // do last step\n var y = xp.subtract(xq)\n .multiply(key.qInv).mod(key.p)\n .multiply(key.q).add(xq);\n\n // remove effect of random for cryptographic blinding\n y = y.multiply(r.modInverse(key.n)).mod(key.n);\n\n return y;\n};\n\n/**\n * NOTE: THIS METHOD IS DEPRECATED, use 'sign' on a private key object or\n * 'encrypt' on a public key object instead.\n *\n * Performs RSA encryption.\n *\n * The parameter bt controls whether to put padding bytes before the\n * message passed in. Set bt to either true or false to disable padding\n * completely (in order to handle e.g. EMSA-PSS encoding seperately before),\n * signaling whether the encryption operation is a public key operation\n * (i.e. encrypting data) or not, i.e. private key operation (data signing).\n *\n * For PKCS#1 v1.5 padding pass in the block type to use, i.e. either 0x01\n * (for signing) or 0x02 (for encryption). The key operation mode (private\n * or public) is derived from this flag in that case).\n *\n * @param m the message to encrypt as a byte string.\n * @param key the RSA key to use.\n * @param bt for PKCS#1 v1.5 padding, the block type to use\n * (0x01 for private key, 0x02 for public),\n * to disable padding: true = public key, false = private key.\n *\n * @return the encrypted bytes as a string.\n */\npki.rsa.encrypt = function(m, key, bt) {\n var pub = bt;\n var eb;\n\n // get the length of the modulus in bytes\n var k = Math.ceil(key.n.bitLength() / 8);\n\n if(bt !== false && bt !== true) {\n // legacy, default to PKCS#1 v1.5 padding\n pub = (bt === 0x02);\n eb = _encodePkcs1_v1_5(m, key, bt);\n } else {\n eb = forge.util.createBuffer();\n eb.putBytes(m);\n }\n\n // load encryption block as big integer 'x'\n // FIXME: hex conversion inefficient, get BigInteger w/byte strings\n var x = new BigInteger(eb.toHex(), 16);\n\n // do RSA encryption\n var y = _modPow(x, key, pub);\n\n // convert y into the encrypted data byte string, if y is shorter in\n // bytes than k, then prepend zero bytes to fill up ed\n // FIXME: hex conversion inefficient, get BigInteger w/byte strings\n var yhex = y.toString(16);\n var ed = forge.util.createBuffer();\n var zeros = k - Math.ceil(yhex.length / 2);\n while(zeros > 0) {\n ed.putByte(0x00);\n --zeros;\n }\n ed.putBytes(forge.util.hexToBytes(yhex));\n return ed.getBytes();\n};\n\n/**\n * NOTE: THIS METHOD IS DEPRECATED, use 'decrypt' on a private key object or\n * 'verify' on a public key object instead.\n *\n * Performs RSA decryption.\n *\n * The parameter ml controls whether to apply PKCS#1 v1.5 padding\n * or not. Set ml = false to disable padding removal completely\n * (in order to handle e.g. EMSA-PSS later on) and simply pass back\n * the RSA encryption block.\n *\n * @param ed the encrypted data to decrypt in as a byte string.\n * @param key the RSA key to use.\n * @param pub true for a public key operation, false for private.\n * @param ml the message length, if known, false to disable padding.\n *\n * @return the decrypted message as a byte string.\n */\npki.rsa.decrypt = function(ed, key, pub, ml) {\n // get the length of the modulus in bytes\n var k = Math.ceil(key.n.bitLength() / 8);\n\n // error if the length of the encrypted data ED is not k\n if(ed.length !== k) {\n var error = new Error('Encrypted message length is invalid.');\n error.length = ed.length;\n error.expected = k;\n throw error;\n }\n\n // convert encrypted data into a big integer\n // FIXME: hex conversion inefficient, get BigInteger w/byte strings\n var y = new BigInteger(forge.util.createBuffer(ed).toHex(), 16);\n\n // y must be less than the modulus or it wasn't the result of\n // a previous mod operation (encryption) using that modulus\n if(y.compareTo(key.n) >= 0) {\n throw new Error('Encrypted message is invalid.');\n }\n\n // do RSA decryption\n var x = _modPow(y, key, pub);\n\n // create the encryption block, if x is shorter in bytes than k, then\n // prepend zero bytes to fill up eb\n // FIXME: hex conversion inefficient, get BigInteger w/byte strings\n var xhex = x.toString(16);\n var eb = forge.util.createBuffer();\n var zeros = k - Math.ceil(xhex.length / 2);\n while(zeros > 0) {\n eb.putByte(0x00);\n --zeros;\n }\n eb.putBytes(forge.util.hexToBytes(xhex));\n\n if(ml !== false) {\n // legacy, default to PKCS#1 v1.5 padding\n return _decodePkcs1_v1_5(eb.getBytes(), key, pub);\n }\n\n // return message\n return eb.getBytes();\n};\n\n/**\n * Creates an RSA key-pair generation state object. It is used to allow\n * key-generation to be performed in steps. It also allows for a UI to\n * display progress updates.\n *\n * @param bits the size for the private key in bits, defaults to 2048.\n * @param e the public exponent to use, defaults to 65537 (0x10001).\n * @param [options] the options to use.\n * prng a custom crypto-secure pseudo-random number generator to use,\n * that must define \"getBytesSync\".\n * algorithm the algorithm to use (default: 'PRIMEINC').\n *\n * @return the state object to use to generate the key-pair.\n */\npki.rsa.createKeyPairGenerationState = function(bits, e, options) {\n // TODO: migrate step-based prime generation code to forge.prime\n\n // set default bits\n if(typeof(bits) === 'string') {\n bits = parseInt(bits, 10);\n }\n bits = bits || 2048;\n\n // create prng with api that matches BigInteger secure random\n options = options || {};\n var prng = options.prng || forge.random;\n var rng = {\n // x is an array to fill with bytes\n nextBytes: function(x) {\n var b = prng.getBytesSync(x.length);\n for(var i = 0; i < x.length; ++i) {\n x[i] = b.charCodeAt(i);\n }\n }\n };\n\n var algorithm = options.algorithm || 'PRIMEINC';\n\n // create PRIMEINC algorithm state\n var rval;\n if(algorithm === 'PRIMEINC') {\n rval = {\n algorithm: algorithm,\n state: 0,\n bits: bits,\n rng: rng,\n eInt: e || 65537,\n e: new BigInteger(null),\n p: null,\n q: null,\n qBits: bits >> 1,\n pBits: bits - (bits >> 1),\n pqState: 0,\n num: null,\n keys: null\n };\n rval.e.fromInt(rval.eInt);\n } else {\n throw new Error('Invalid key generation algorithm: ' + algorithm);\n }\n\n return rval;\n};\n\n/**\n * Attempts to runs the key-generation algorithm for at most n seconds\n * (approximately) using the given state. When key-generation has completed,\n * the keys will be stored in state.keys.\n *\n * To use this function to update a UI while generating a key or to prevent\n * causing browser lockups/warnings, set \"n\" to a value other than 0. A\n * simple pattern for generating a key and showing a progress indicator is:\n *\n * var state = pki.rsa.createKeyPairGenerationState(2048);\n * var step = function() {\n * // step key-generation, run algorithm for 100 ms, repeat\n * if(!forge.pki.rsa.stepKeyPairGenerationState(state, 100)) {\n * setTimeout(step, 1);\n * } else {\n * // key-generation complete\n * // TODO: turn off progress indicator here\n * // TODO: use the generated key-pair in \"state.keys\"\n * }\n * };\n * // TODO: turn on progress indicator here\n * setTimeout(step, 0);\n *\n * @param state the state to use.\n * @param n the maximum number of milliseconds to run the algorithm for, 0\n * to run the algorithm to completion.\n *\n * @return true if the key-generation completed, false if not.\n */\npki.rsa.stepKeyPairGenerationState = function(state, n) {\n // set default algorithm if not set\n if(!('algorithm' in state)) {\n state.algorithm = 'PRIMEINC';\n }\n\n // TODO: migrate step-based prime generation code to forge.prime\n // TODO: abstract as PRIMEINC algorithm\n\n // do key generation (based on Tom Wu's rsa.js, see jsbn.js license)\n // with some minor optimizations and designed to run in steps\n\n // local state vars\n var THIRTY = new BigInteger(null);\n THIRTY.fromInt(30);\n var deltaIdx = 0;\n var op_or = function(x, y) {return x | y;};\n\n // keep stepping until time limit is reached or done\n var t1 = +new Date();\n var t2;\n var total = 0;\n while(state.keys === null && (n <= 0 || total < n)) {\n // generate p or q\n if(state.state === 0) {\n /* Note: All primes are of the form:\n\n 30k+i, for i < 30 and gcd(30, i)=1, where there are 8 values for i\n\n When we generate a random number, we always align it at 30k + 1. Each\n time the number is determined not to be prime we add to get to the\n next 'i', eg: if the number was at 30k + 1 we add 6. */\n var bits = (state.p === null) ? state.pBits : state.qBits;\n var bits1 = bits - 1;\n\n // get a random number\n if(state.pqState === 0) {\n state.num = new BigInteger(bits, state.rng);\n // force MSB set\n if(!state.num.testBit(bits1)) {\n state.num.bitwiseTo(\n BigInteger.ONE.shiftLeft(bits1), op_or, state.num);\n }\n // align number on 30k+1 boundary\n state.num.dAddOffset(31 - state.num.mod(THIRTY).byteValue(), 0);\n deltaIdx = 0;\n\n ++state.pqState;\n } else if(state.pqState === 1) {\n // try to make the number a prime\n if(state.num.bitLength() > bits) {\n // overflow, try again\n state.pqState = 0;\n // do primality test\n } else if(state.num.isProbablePrime(\n _getMillerRabinTests(state.num.bitLength()))) {\n ++state.pqState;\n } else {\n // get next potential prime\n state.num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);\n }\n } else if(state.pqState === 2) {\n // ensure number is coprime with e\n state.pqState =\n (state.num.subtract(BigInteger.ONE).gcd(state.e)\n .compareTo(BigInteger.ONE) === 0) ? 3 : 0;\n } else if(state.pqState === 3) {\n // store p or q\n state.pqState = 0;\n if(state.p === null) {\n state.p = state.num;\n } else {\n state.q = state.num;\n }\n\n // advance state if both p and q are ready\n if(state.p !== null && state.q !== null) {\n ++state.state;\n }\n state.num = null;\n }\n } else if(state.state === 1) {\n // ensure p is larger than q (swap them if not)\n if(state.p.compareTo(state.q) < 0) {\n state.num = state.p;\n state.p = state.q;\n state.q = state.num;\n }\n ++state.state;\n } else if(state.state === 2) {\n // compute phi: (p - 1)(q - 1) (Euler's totient function)\n state.p1 = state.p.subtract(BigInteger.ONE);\n state.q1 = state.q.subtract(BigInteger.ONE);\n state.phi = state.p1.multiply(state.q1);\n ++state.state;\n } else if(state.state === 3) {\n // ensure e and phi are coprime\n if(state.phi.gcd(state.e).compareTo(BigInteger.ONE) === 0) {\n // phi and e are coprime, advance\n ++state.state;\n } else {\n // phi and e aren't coprime, so generate a new p and q\n state.p = null;\n state.q = null;\n state.state = 0;\n }\n } else if(state.state === 4) {\n // create n, ensure n is has the right number of bits\n state.n = state.p.multiply(state.q);\n\n // ensure n is right number of bits\n if(state.n.bitLength() === state.bits) {\n // success, advance\n ++state.state;\n } else {\n // failed, get new q\n state.q = null;\n state.state = 0;\n }\n } else if(state.state === 5) {\n // set keys\n var d = state.e.modInverse(state.phi);\n state.keys = {\n privateKey: pki.rsa.setPrivateKey(\n state.n, state.e, d, state.p, state.q,\n d.mod(state.p1), d.mod(state.q1),\n state.q.modInverse(state.p)),\n publicKey: pki.rsa.setPublicKey(state.n, state.e)\n };\n }\n\n // update timing\n t2 = +new Date();\n total += t2 - t1;\n t1 = t2;\n }\n\n return state.keys !== null;\n};\n\n/**\n * Generates an RSA public-private key pair in a single call.\n *\n * To generate a key-pair in steps (to allow for progress updates and to\n * prevent blocking or warnings in slow browsers) then use the key-pair\n * generation state functions.\n *\n * To generate a key-pair asynchronously (either through web-workers, if\n * available, or by breaking up the work on the main thread), pass a\n * callback function.\n *\n * @param [bits] the size for the private key in bits, defaults to 2048.\n * @param [e] the public exponent to use, defaults to 65537.\n * @param [options] options for key-pair generation, if given then 'bits'\n * and 'e' must *not* be given:\n * bits the size for the private key in bits, (default: 2048).\n * e the public exponent to use, (default: 65537 (0x10001)).\n * workerScript the worker script URL.\n * workers the number of web workers (if supported) to use,\n * (default: 2).\n * workLoad the size of the work load, ie: number of possible prime\n * numbers for each web worker to check per work assignment,\n * (default: 100).\n * prng a custom crypto-secure pseudo-random number generator to use,\n * that must define \"getBytesSync\". Disables use of native APIs.\n * algorithm the algorithm to use (default: 'PRIMEINC').\n * @param [callback(err, keypair)] called once the operation completes.\n *\n * @return an object with privateKey and publicKey properties.\n */\npki.rsa.generateKeyPair = function(bits, e, options, callback) {\n // (bits), (options), (callback)\n if(arguments.length === 1) {\n if(typeof bits === 'object') {\n options = bits;\n bits = undefined;\n } else if(typeof bits === 'function') {\n callback = bits;\n bits = undefined;\n }\n } else if(arguments.length === 2) {\n // (bits, e), (bits, options), (bits, callback), (options, callback)\n if(typeof bits === 'number') {\n if(typeof e === 'function') {\n callback = e;\n e = undefined;\n } else if(typeof e !== 'number') {\n options = e;\n e = undefined;\n }\n } else {\n options = bits;\n callback = e;\n bits = undefined;\n e = undefined;\n }\n } else if(arguments.length === 3) {\n // (bits, e, options), (bits, e, callback), (bits, options, callback)\n if(typeof e === 'number') {\n if(typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n } else {\n callback = options;\n options = e;\n e = undefined;\n }\n }\n options = options || {};\n if(bits === undefined) {\n bits = options.bits || 2048;\n }\n if(e === undefined) {\n e = options.e || 0x10001;\n }\n\n // use native code if permitted, available, and parameters are acceptable\n if(!forge.options.usePureJavaScript && !options.prng &&\n bits >= 256 && bits <= 16384 && (e === 0x10001 || e === 3)) {\n if(callback) {\n // try native async\n if(_detectNodeCrypto('generateKeyPair')) {\n return _crypto.generateKeyPair('rsa', {\n modulusLength: bits,\n publicExponent: e,\n publicKeyEncoding: {\n type: 'spki',\n format: 'pem'\n },\n privateKeyEncoding: {\n type: 'pkcs8',\n format: 'pem'\n }\n }, function(err, pub, priv) {\n if(err) {\n return callback(err);\n }\n callback(null, {\n privateKey: pki.privateKeyFromPem(priv),\n publicKey: pki.publicKeyFromPem(pub)\n });\n });\n }\n if(_detectSubtleCrypto('generateKey') &&\n _detectSubtleCrypto('exportKey')) {\n // use standard native generateKey\n return util.globalScope.crypto.subtle.generateKey({\n name: 'RSASSA-PKCS1-v1_5',\n modulusLength: bits,\n publicExponent: _intToUint8Array(e),\n hash: {name: 'SHA-256'}\n }, true /* key can be exported*/, ['sign', 'verify'])\n .then(function(pair) {\n return util.globalScope.crypto.subtle.exportKey(\n 'pkcs8', pair.privateKey);\n // avoiding catch(function(err) {...}) to support IE <= 8\n }).then(undefined, function(err) {\n callback(err);\n }).then(function(pkcs8) {\n if(pkcs8) {\n var privateKey = pki.privateKeyFromAsn1(\n asn1.fromDer(forge.util.createBuffer(pkcs8)));\n callback(null, {\n privateKey: privateKey,\n publicKey: pki.setRsaPublicKey(privateKey.n, privateKey.e)\n });\n }\n });\n }\n if(_detectSubtleMsCrypto('generateKey') &&\n _detectSubtleMsCrypto('exportKey')) {\n var genOp = util.globalScope.msCrypto.subtle.generateKey({\n name: 'RSASSA-PKCS1-v1_5',\n modulusLength: bits,\n publicExponent: _intToUint8Array(e),\n hash: {name: 'SHA-256'}\n }, true /* key can be exported*/, ['sign', 'verify']);\n genOp.oncomplete = function(e) {\n var pair = e.target.result;\n var exportOp = util.globalScope.msCrypto.subtle.exportKey(\n 'pkcs8', pair.privateKey);\n exportOp.oncomplete = function(e) {\n var pkcs8 = e.target.result;\n var privateKey = pki.privateKeyFromAsn1(\n asn1.fromDer(forge.util.createBuffer(pkcs8)));\n callback(null, {\n privateKey: privateKey,\n publicKey: pki.setRsaPublicKey(privateKey.n, privateKey.e)\n });\n };\n exportOp.onerror = function(err) {\n callback(err);\n };\n };\n genOp.onerror = function(err) {\n callback(err);\n };\n return;\n }\n } else {\n // try native sync\n if(_detectNodeCrypto('generateKeyPairSync')) {\n var keypair = _crypto.generateKeyPairSync('rsa', {\n modulusLength: bits,\n publicExponent: e,\n publicKeyEncoding: {\n type: 'spki',\n format: 'pem'\n },\n privateKeyEncoding: {\n type: 'pkcs8',\n format: 'pem'\n }\n });\n return {\n privateKey: pki.privateKeyFromPem(keypair.privateKey),\n publicKey: pki.publicKeyFromPem(keypair.publicKey)\n };\n }\n }\n }\n\n // use JavaScript implementation\n var state = pki.rsa.createKeyPairGenerationState(bits, e, options);\n if(!callback) {\n pki.rsa.stepKeyPairGenerationState(state, 0);\n return state.keys;\n }\n _generateKeyPair(state, options, callback);\n};\n\n/**\n * Sets an RSA public key from BigIntegers modulus and exponent.\n *\n * @param n the modulus.\n * @param e the exponent.\n *\n * @return the public key.\n */\npki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {\n var key = {\n n: n,\n e: e\n };\n\n /**\n * Encrypts the given data with this public key. Newer applications\n * should use the 'RSA-OAEP' decryption scheme, 'RSAES-PKCS1-V1_5' is for\n * legacy applications.\n *\n * @param data the byte string to encrypt.\n * @param scheme the encryption scheme to use:\n * 'RSAES-PKCS1-V1_5' (default),\n * 'RSA-OAEP',\n * 'RAW', 'NONE', or null to perform raw RSA encryption,\n * an object with an 'encode' property set to a function\n * with the signature 'function(data, key)' that returns\n * a binary-encoded string representing the encoded data.\n * @param schemeOptions any scheme-specific options.\n *\n * @return the encrypted byte string.\n */\n key.encrypt = function(data, scheme, schemeOptions) {\n if(typeof scheme === 'string') {\n scheme = scheme.toUpperCase();\n } else if(scheme === undefined) {\n scheme = 'RSAES-PKCS1-V1_5';\n }\n\n if(scheme === 'RSAES-PKCS1-V1_5') {\n scheme = {\n encode: function(m, key, pub) {\n return _encodePkcs1_v1_5(m, key, 0x02).getBytes();\n }\n };\n } else if(scheme === 'RSA-OAEP' || scheme === 'RSAES-OAEP') {\n scheme = {\n encode: function(m, key) {\n return forge.pkcs1.encode_rsa_oaep(key, m, schemeOptions);\n }\n };\n } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {\n scheme = {encode: function(e) {return e;}};\n } else if(typeof scheme === 'string') {\n throw new Error('Unsupported encryption scheme: \"' + scheme + '\".');\n }\n\n // do scheme-based encoding then rsa encryption\n var e = scheme.encode(data, key, true);\n return pki.rsa.encrypt(e, key, true);\n };\n\n /**\n * Verifies the given signature against the given digest.\n *\n * PKCS#1 supports multiple (currently two) signature schemes:\n * RSASSA-PKCS1-V1_5 and RSASSA-PSS.\n *\n * By default this implementation uses the \"old scheme\", i.e.\n * RSASSA-PKCS1-V1_5, in which case once RSA-decrypted, the\n * signature is an OCTET STRING that holds a DigestInfo.\n *\n * DigestInfo ::= SEQUENCE {\n * digestAlgorithm DigestAlgorithmIdentifier,\n * digest Digest\n * }\n * DigestAlgorithmIdentifier ::= AlgorithmIdentifier\n * Digest ::= OCTET STRING\n *\n * To perform PSS signature verification, provide an instance\n * of Forge PSS object as the scheme parameter.\n *\n * @param digest the message digest hash to compare against the signature,\n * as a binary-encoded string.\n * @param signature the signature to verify, as a binary-encoded string.\n * @param scheme signature verification scheme to use:\n * 'RSASSA-PKCS1-V1_5' or undefined for RSASSA PKCS#1 v1.5,\n * a Forge PSS object for RSASSA-PSS,\n * 'NONE' or null for none, DigestInfo will not be expected, but\n * PKCS#1 v1.5 padding will still be used.\n *\n * @return true if the signature was verified, false if not.\n */\n key.verify = function(digest, signature, scheme) {\n if(typeof scheme === 'string') {\n scheme = scheme.toUpperCase();\n } else if(scheme === undefined) {\n scheme = 'RSASSA-PKCS1-V1_5';\n }\n\n if(scheme === 'RSASSA-PKCS1-V1_5') {\n scheme = {\n verify: function(digest, d) {\n // remove padding\n d = _decodePkcs1_v1_5(d, key, true);\n // d is ASN.1 BER-encoded DigestInfo\n var obj = asn1.fromDer(d);\n // compare the given digest to the decrypted one\n return digest === obj.value[1].value;\n }\n };\n } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {\n scheme = {\n verify: function(digest, d) {\n // remove padding\n d = _decodePkcs1_v1_5(d, key, true);\n return digest === d;\n }\n };\n }\n\n // do rsa decryption w/o any decoding, then verify -- which does decoding\n var d = pki.rsa.decrypt(signature, key, true, false);\n return scheme.verify(digest, d, key.n.bitLength());\n };\n\n return key;\n};\n\n/**\n * Sets an RSA private key from BigIntegers modulus, exponent, primes,\n * prime exponents, and modular multiplicative inverse.\n *\n * @param n the modulus.\n * @param e the public exponent.\n * @param d the private exponent ((inverse of e) mod n).\n * @param p the first prime.\n * @param q the second prime.\n * @param dP exponent1 (d mod (p-1)).\n * @param dQ exponent2 (d mod (q-1)).\n * @param qInv ((inverse of q) mod p)\n *\n * @return the private key.\n */\npki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(\n n, e, d, p, q, dP, dQ, qInv) {\n var key = {\n n: n,\n e: e,\n d: d,\n p: p,\n q: q,\n dP: dP,\n dQ: dQ,\n qInv: qInv\n };\n\n /**\n * Decrypts the given data with this private key. The decryption scheme\n * must match the one used to encrypt the data.\n *\n * @param data the byte string to decrypt.\n * @param scheme the decryption scheme to use:\n * 'RSAES-PKCS1-V1_5' (default),\n * 'RSA-OAEP',\n * 'RAW', 'NONE', or null to perform raw RSA decryption.\n * @param schemeOptions any scheme-specific options.\n *\n * @return the decrypted byte string.\n */\n key.decrypt = function(data, scheme, schemeOptions) {\n if(typeof scheme === 'string') {\n scheme = scheme.toUpperCase();\n } else if(scheme === undefined) {\n scheme = 'RSAES-PKCS1-V1_5';\n }\n\n // do rsa decryption w/o any decoding\n var d = pki.rsa.decrypt(data, key, false, false);\n\n if(scheme === 'RSAES-PKCS1-V1_5') {\n scheme = {decode: _decodePkcs1_v1_5};\n } else if(scheme === 'RSA-OAEP' || scheme === 'RSAES-OAEP') {\n scheme = {\n decode: function(d, key) {\n return forge.pkcs1.decode_rsa_oaep(key, d, schemeOptions);\n }\n };\n } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {\n scheme = {decode: function(d) {return d;}};\n } else {\n throw new Error('Unsupported encryption scheme: \"' + scheme + '\".');\n }\n\n // decode according to scheme\n return scheme.decode(d, key, false);\n };\n\n /**\n * Signs the given digest, producing a signature.\n *\n * PKCS#1 supports multiple (currently two) signature schemes:\n * RSASSA-PKCS1-V1_5 and RSASSA-PSS.\n *\n * By default this implementation uses the \"old scheme\", i.e.\n * RSASSA-PKCS1-V1_5. In order to generate a PSS signature, provide\n * an instance of Forge PSS object as the scheme parameter.\n *\n * @param md the message digest object with the hash to sign.\n * @param scheme the signature scheme to use:\n * 'RSASSA-PKCS1-V1_5' or undefined for RSASSA PKCS#1 v1.5,\n * a Forge PSS object for RSASSA-PSS,\n * 'NONE' or null for none, DigestInfo will not be used but\n * PKCS#1 v1.5 padding will still be used.\n *\n * @return the signature as a byte string.\n */\n key.sign = function(md, scheme) {\n /* Note: The internal implementation of RSA operations is being\n transitioned away from a PKCS#1 v1.5 hard-coded scheme. Some legacy\n code like the use of an encoding block identifier 'bt' will eventually\n be removed. */\n\n // private key operation\n var bt = false;\n\n if(typeof scheme === 'string') {\n scheme = scheme.toUpperCase();\n }\n\n if(scheme === undefined || scheme === 'RSASSA-PKCS1-V1_5') {\n scheme = {encode: emsaPkcs1v15encode};\n bt = 0x01;\n } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {\n scheme = {encode: function() {return md;}};\n bt = 0x01;\n }\n\n // encode and then encrypt\n var d = scheme.encode(md, key.n.bitLength());\n return pki.rsa.encrypt(d, key, bt);\n };\n\n return key;\n};\n\n/**\n * Wraps an RSAPrivateKey ASN.1 object in an ASN.1 PrivateKeyInfo object.\n *\n * @param rsaKey the ASN.1 RSAPrivateKey.\n *\n * @return the ASN.1 PrivateKeyInfo.\n */\npki.wrapRsaPrivateKey = function(rsaKey) {\n // PrivateKeyInfo\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version (0)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(0).getBytes()),\n // privateKeyAlgorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]),\n // PrivateKey\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,\n asn1.toDer(rsaKey).getBytes())\n ]);\n};\n\n/**\n * Converts a private key from an ASN.1 object.\n *\n * @param obj the ASN.1 representation of a PrivateKeyInfo containing an\n * RSAPrivateKey or an RSAPrivateKey.\n *\n * @return the private key.\n */\npki.privateKeyFromAsn1 = function(obj) {\n // get PrivateKeyInfo\n var capture = {};\n var errors = [];\n if(asn1.validate(obj, privateKeyValidator, capture, errors)) {\n obj = asn1.fromDer(forge.util.createBuffer(capture.privateKey));\n }\n\n // get RSAPrivateKey\n capture = {};\n errors = [];\n if(!asn1.validate(obj, rsaPrivateKeyValidator, capture, errors)) {\n var error = new Error('Cannot read private key. ' +\n 'ASN.1 object does not contain an RSAPrivateKey.');\n error.errors = errors;\n throw error;\n }\n\n // Note: Version is currently ignored.\n // capture.privateKeyVersion\n // FIXME: inefficient, get a BigInteger that uses byte strings\n var n, e, d, p, q, dP, dQ, qInv;\n n = forge.util.createBuffer(capture.privateKeyModulus).toHex();\n e = forge.util.createBuffer(capture.privateKeyPublicExponent).toHex();\n d = forge.util.createBuffer(capture.privateKeyPrivateExponent).toHex();\n p = forge.util.createBuffer(capture.privateKeyPrime1).toHex();\n q = forge.util.createBuffer(capture.privateKeyPrime2).toHex();\n dP = forge.util.createBuffer(capture.privateKeyExponent1).toHex();\n dQ = forge.util.createBuffer(capture.privateKeyExponent2).toHex();\n qInv = forge.util.createBuffer(capture.privateKeyCoefficient).toHex();\n\n // set private key\n return pki.setRsaPrivateKey(\n new BigInteger(n, 16),\n new BigInteger(e, 16),\n new BigInteger(d, 16),\n new BigInteger(p, 16),\n new BigInteger(q, 16),\n new BigInteger(dP, 16),\n new BigInteger(dQ, 16),\n new BigInteger(qInv, 16));\n};\n\n/**\n * Converts a private key to an ASN.1 RSAPrivateKey.\n *\n * @param key the private key.\n *\n * @return the ASN.1 representation of an RSAPrivateKey.\n */\npki.privateKeyToAsn1 = pki.privateKeyToRSAPrivateKey = function(key) {\n // RSAPrivateKey\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version (0 = only 2 primes, 1 multiple primes)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(0).getBytes()),\n // modulus (n)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.n)),\n // publicExponent (e)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.e)),\n // privateExponent (d)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.d)),\n // privateKeyPrime1 (p)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.p)),\n // privateKeyPrime2 (q)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.q)),\n // privateKeyExponent1 (dP)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.dP)),\n // privateKeyExponent2 (dQ)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.dQ)),\n // coefficient (qInv)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.qInv))\n ]);\n};\n\n/**\n * Converts a public key from an ASN.1 SubjectPublicKeyInfo or RSAPublicKey.\n *\n * @param obj the asn1 representation of a SubjectPublicKeyInfo or RSAPublicKey.\n *\n * @return the public key.\n */\npki.publicKeyFromAsn1 = function(obj) {\n // get SubjectPublicKeyInfo\n var capture = {};\n var errors = [];\n if(asn1.validate(obj, publicKeyValidator, capture, errors)) {\n // get oid\n var oid = asn1.derToOid(capture.publicKeyOid);\n if(oid !== pki.oids.rsaEncryption) {\n var error = new Error('Cannot read public key. Unknown OID.');\n error.oid = oid;\n throw error;\n }\n obj = capture.rsaPublicKey;\n }\n\n // get RSA params\n errors = [];\n if(!asn1.validate(obj, rsaPublicKeyValidator, capture, errors)) {\n var error = new Error('Cannot read public key. ' +\n 'ASN.1 object does not contain an RSAPublicKey.');\n error.errors = errors;\n throw error;\n }\n\n // FIXME: inefficient, get a BigInteger that uses byte strings\n var n = forge.util.createBuffer(capture.publicKeyModulus).toHex();\n var e = forge.util.createBuffer(capture.publicKeyExponent).toHex();\n\n // set public key\n return pki.setRsaPublicKey(\n new BigInteger(n, 16),\n new BigInteger(e, 16));\n};\n\n/**\n * Converts a public key to an ASN.1 SubjectPublicKeyInfo.\n *\n * @param key the public key.\n *\n * @return the asn1 representation of a SubjectPublicKeyInfo.\n */\npki.publicKeyToAsn1 = pki.publicKeyToSubjectPublicKeyInfo = function(key) {\n // SubjectPublicKeyInfo\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // AlgorithmIdentifier\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),\n // parameters (null)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ]),\n // subjectPublicKey\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, [\n pki.publicKeyToRSAPublicKey(key)\n ])\n ]);\n};\n\n/**\n * Converts a public key to an ASN.1 RSAPublicKey.\n *\n * @param key the public key.\n *\n * @return the asn1 representation of a RSAPublicKey.\n */\npki.publicKeyToRSAPublicKey = function(key) {\n // RSAPublicKey\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // modulus (n)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.n)),\n // publicExponent (e)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n _bnToBytes(key.e))\n ]);\n};\n\n/**\n * Encodes a message using PKCS#1 v1.5 padding.\n *\n * @param m the message to encode.\n * @param key the RSA key to use.\n * @param bt the block type to use, i.e. either 0x01 (for signing) or 0x02\n * (for encryption).\n *\n * @return the padded byte buffer.\n */\nfunction _encodePkcs1_v1_5(m, key, bt) {\n var eb = forge.util.createBuffer();\n\n // get the length of the modulus in bytes\n var k = Math.ceil(key.n.bitLength() / 8);\n\n /* use PKCS#1 v1.5 padding */\n if(m.length > (k - 11)) {\n var error = new Error('Message is too long for PKCS#1 v1.5 padding.');\n error.length = m.length;\n error.max = k - 11;\n throw error;\n }\n\n /* A block type BT, a padding string PS, and the data D shall be\n formatted into an octet string EB, the encryption block:\n\n EB = 00 || BT || PS || 00 || D\n\n The block type BT shall be a single octet indicating the structure of\n the encryption block. For this version of the document it shall have\n value 00, 01, or 02. For a private-key operation, the block type\n shall be 00 or 01. For a public-key operation, it shall be 02.\n\n The padding string PS shall consist of k-3-||D|| octets. For block\n type 00, the octets shall have value 00; for block type 01, they\n shall have value FF; and for block type 02, they shall be\n pseudorandomly generated and nonzero. This makes the length of the\n encryption block EB equal to k. */\n\n // build the encryption block\n eb.putByte(0x00);\n eb.putByte(bt);\n\n // create the padding\n var padNum = k - 3 - m.length;\n var padByte;\n // private key op\n if(bt === 0x00 || bt === 0x01) {\n padByte = (bt === 0x00) ? 0x00 : 0xFF;\n for(var i = 0; i < padNum; ++i) {\n eb.putByte(padByte);\n }\n } else {\n // public key op\n // pad with random non-zero values\n while(padNum > 0) {\n var numZeros = 0;\n var padBytes = forge.random.getBytes(padNum);\n for(var i = 0; i < padNum; ++i) {\n padByte = padBytes.charCodeAt(i);\n if(padByte === 0) {\n ++numZeros;\n } else {\n eb.putByte(padByte);\n }\n }\n padNum = numZeros;\n }\n }\n\n // zero followed by message\n eb.putByte(0x00);\n eb.putBytes(m);\n\n return eb;\n}\n\n/**\n * Decodes a message using PKCS#1 v1.5 padding.\n *\n * @param em the message to decode.\n * @param key the RSA key to use.\n * @param pub true if the key is a public key, false if it is private.\n * @param ml the message length, if specified.\n *\n * @return the decoded bytes.\n */\nfunction _decodePkcs1_v1_5(em, key, pub, ml) {\n // get the length of the modulus in bytes\n var k = Math.ceil(key.n.bitLength() / 8);\n\n /* It is an error if any of the following conditions occurs:\n\n 1. The encryption block EB cannot be parsed unambiguously.\n 2. The padding string PS consists of fewer than eight octets\n or is inconsisent with the block type BT.\n 3. The decryption process is a public-key operation and the block\n type BT is not 00 or 01, or the decryption process is a\n private-key operation and the block type is not 02.\n */\n\n // parse the encryption block\n var eb = forge.util.createBuffer(em);\n var first = eb.getByte();\n var bt = eb.getByte();\n if(first !== 0x00 ||\n (pub && bt !== 0x00 && bt !== 0x01) ||\n (!pub && bt != 0x02) ||\n (pub && bt === 0x00 && typeof(ml) === 'undefined')) {\n throw new Error('Encryption block is invalid.');\n }\n\n var padNum = 0;\n if(bt === 0x00) {\n // check all padding bytes for 0x00\n padNum = k - 3 - ml;\n for(var i = 0; i < padNum; ++i) {\n if(eb.getByte() !== 0x00) {\n throw new Error('Encryption block is invalid.');\n }\n }\n } else if(bt === 0x01) {\n // find the first byte that isn't 0xFF, should be after all padding\n padNum = 0;\n while(eb.length() > 1) {\n if(eb.getByte() !== 0xFF) {\n --eb.read;\n break;\n }\n ++padNum;\n }\n } else if(bt === 0x02) {\n // look for 0x00 byte\n padNum = 0;\n while(eb.length() > 1) {\n if(eb.getByte() === 0x00) {\n --eb.read;\n break;\n }\n ++padNum;\n }\n }\n\n // zero must be 0x00 and padNum must be (k - 3 - message length)\n var zero = eb.getByte();\n if(zero !== 0x00 || padNum !== (k - 3 - eb.length())) {\n throw new Error('Encryption block is invalid.');\n }\n\n return eb.getBytes();\n}\n\n/**\n * Runs the key-generation algorithm asynchronously, either in the background\n * via Web Workers, or using the main thread and setImmediate.\n *\n * @param state the key-pair generation state.\n * @param [options] options for key-pair generation:\n * workerScript the worker script URL.\n * workers the number of web workers (if supported) to use,\n * (default: 2, -1 to use estimated cores minus one).\n * workLoad the size of the work load, ie: number of possible prime\n * numbers for each web worker to check per work assignment,\n * (default: 100).\n * @param callback(err, keypair) called once the operation completes.\n */\nfunction _generateKeyPair(state, options, callback) {\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n var opts = {\n algorithm: {\n name: options.algorithm || 'PRIMEINC',\n options: {\n workers: options.workers || 2,\n workLoad: options.workLoad || 100,\n workerScript: options.workerScript\n }\n }\n };\n if('prng' in options) {\n opts.prng = options.prng;\n }\n\n generate();\n\n function generate() {\n // find p and then q (done in series to simplify)\n getPrime(state.pBits, function(err, num) {\n if(err) {\n return callback(err);\n }\n state.p = num;\n if(state.q !== null) {\n return finish(err, state.q);\n }\n getPrime(state.qBits, finish);\n });\n }\n\n function getPrime(bits, callback) {\n forge.prime.generateProbablePrime(bits, opts, callback);\n }\n\n function finish(err, num) {\n if(err) {\n return callback(err);\n }\n\n // set q\n state.q = num;\n\n // ensure p is larger than q (swap them if not)\n if(state.p.compareTo(state.q) < 0) {\n var tmp = state.p;\n state.p = state.q;\n state.q = tmp;\n }\n\n // ensure p is coprime with e\n if(state.p.subtract(BigInteger.ONE).gcd(state.e)\n .compareTo(BigInteger.ONE) !== 0) {\n state.p = null;\n generate();\n return;\n }\n\n // ensure q is coprime with e\n if(state.q.subtract(BigInteger.ONE).gcd(state.e)\n .compareTo(BigInteger.ONE) !== 0) {\n state.q = null;\n getPrime(state.qBits, finish);\n return;\n }\n\n // compute phi: (p - 1)(q - 1) (Euler's totient function)\n state.p1 = state.p.subtract(BigInteger.ONE);\n state.q1 = state.q.subtract(BigInteger.ONE);\n state.phi = state.p1.multiply(state.q1);\n\n // ensure e and phi are coprime\n if(state.phi.gcd(state.e).compareTo(BigInteger.ONE) !== 0) {\n // phi and e aren't coprime, so generate a new p and q\n state.p = state.q = null;\n generate();\n return;\n }\n\n // create n, ensure n is has the right number of bits\n state.n = state.p.multiply(state.q);\n if(state.n.bitLength() !== state.bits) {\n // failed, get new q\n state.q = null;\n getPrime(state.qBits, finish);\n return;\n }\n\n // set keys\n var d = state.e.modInverse(state.phi);\n state.keys = {\n privateKey: pki.rsa.setPrivateKey(\n state.n, state.e, d, state.p, state.q,\n d.mod(state.p1), d.mod(state.q1),\n state.q.modInverse(state.p)),\n publicKey: pki.rsa.setPublicKey(state.n, state.e)\n };\n\n callback(null, state.keys);\n }\n}\n\n/**\n * Converts a positive BigInteger into 2's-complement big-endian bytes.\n *\n * @param b the big integer to convert.\n *\n * @return the bytes.\n */\nfunction _bnToBytes(b) {\n // prepend 0x00 if first byte >= 0x80\n var hex = b.toString(16);\n if(hex[0] >= '8') {\n hex = '00' + hex;\n }\n var bytes = forge.util.hexToBytes(hex);\n\n // ensure integer is minimally-encoded\n if(bytes.length > 1 &&\n // leading 0x00 for positive integer\n ((bytes.charCodeAt(0) === 0 &&\n (bytes.charCodeAt(1) & 0x80) === 0) ||\n // leading 0xFF for negative integer\n (bytes.charCodeAt(0) === 0xFF &&\n (bytes.charCodeAt(1) & 0x80) === 0x80))) {\n return bytes.substr(1);\n }\n return bytes;\n}\n\n/**\n * Returns the required number of Miller-Rabin tests to generate a\n * prime with an error probability of (1/2)^80.\n *\n * See Handbook of Applied Cryptography Chapter 4, Table 4.4.\n *\n * @param bits the bit size.\n *\n * @return the required number of iterations.\n */\nfunction _getMillerRabinTests(bits) {\n if(bits <= 100) return 27;\n if(bits <= 150) return 18;\n if(bits <= 200) return 15;\n if(bits <= 250) return 12;\n if(bits <= 300) return 9;\n if(bits <= 350) return 8;\n if(bits <= 400) return 7;\n if(bits <= 500) return 6;\n if(bits <= 600) return 5;\n if(bits <= 800) return 4;\n if(bits <= 1250) return 3;\n return 2;\n}\n\n/**\n * Performs feature detection on the Node crypto interface.\n *\n * @param fn the feature (function) to detect.\n *\n * @return true if detected, false if not.\n */\nfunction _detectNodeCrypto(fn) {\n return forge.util.isNodejs && typeof _crypto[fn] === 'function';\n}\n\n/**\n * Performs feature detection on the SubtleCrypto interface.\n *\n * @param fn the feature (function) to detect.\n *\n * @return true if detected, false if not.\n */\nfunction _detectSubtleCrypto(fn) {\n return (typeof util.globalScope !== 'undefined' &&\n typeof util.globalScope.crypto === 'object' &&\n typeof util.globalScope.crypto.subtle === 'object' &&\n typeof util.globalScope.crypto.subtle[fn] === 'function');\n}\n\n/**\n * Performs feature detection on the deprecated Microsoft Internet Explorer\n * outdated SubtleCrypto interface. This function should only be used after\n * checking for the modern, standard SubtleCrypto interface.\n *\n * @param fn the feature (function) to detect.\n *\n * @return true if detected, false if not.\n */\nfunction _detectSubtleMsCrypto(fn) {\n return (typeof util.globalScope !== 'undefined' &&\n typeof util.globalScope.msCrypto === 'object' &&\n typeof util.globalScope.msCrypto.subtle === 'object' &&\n typeof util.globalScope.msCrypto.subtle[fn] === 'function');\n}\n\nfunction _intToUint8Array(x) {\n var bytes = forge.util.hexToBytes(x.toString(16));\n var buffer = new Uint8Array(bytes.length);\n for(var i = 0; i < bytes.length; ++i) {\n buffer[i] = bytes.charCodeAt(i);\n }\n return buffer;\n}\n\nfunction _privateKeyFromJwk(jwk) {\n if(jwk.kty !== 'RSA') {\n throw new Error(\n 'Unsupported key algorithm \"' + jwk.kty + '\"; algorithm must be \"RSA\".');\n }\n return pki.setRsaPrivateKey(\n _base64ToBigInt(jwk.n),\n _base64ToBigInt(jwk.e),\n _base64ToBigInt(jwk.d),\n _base64ToBigInt(jwk.p),\n _base64ToBigInt(jwk.q),\n _base64ToBigInt(jwk.dp),\n _base64ToBigInt(jwk.dq),\n _base64ToBigInt(jwk.qi));\n}\n\nfunction _publicKeyFromJwk(jwk) {\n if(jwk.kty !== 'RSA') {\n throw new Error('Key algorithm must be \"RSA\".');\n }\n return pki.setRsaPublicKey(\n _base64ToBigInt(jwk.n),\n _base64ToBigInt(jwk.e));\n}\n\nfunction _base64ToBigInt(b64) {\n return new BigInteger(forge.util.bytesToHex(forge.util.decode64(b64)), 16);\n}\n","/**\n * Secure Hash Algorithm with 160-bit digest (SHA-1) implementation.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2015 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\nvar sha1 = module.exports = forge.sha1 = forge.sha1 || {};\nforge.md.sha1 = forge.md.algorithms.sha1 = sha1;\n\n/**\n * Creates a SHA-1 message digest object.\n *\n * @return a message digest object.\n */\nsha1.create = function() {\n // do initialization as necessary\n if(!_initialized) {\n _init();\n }\n\n // SHA-1 state contains five 32-bit integers\n var _state = null;\n\n // input buffer\n var _input = forge.util.createBuffer();\n\n // used for word storage\n var _w = new Array(80);\n\n // message digest object\n var md = {\n algorithm: 'sha1',\n blockLength: 64,\n digestLength: 20,\n // 56-bit length of message so far (does not including padding)\n messageLength: 0,\n // true message length\n fullMessageLength: null,\n // size of message length in bytes\n messageLengthSize: 8\n };\n\n /**\n * Starts the digest.\n *\n * @return this digest object.\n */\n md.start = function() {\n // up to 56-bit message length for convenience\n md.messageLength = 0;\n\n // full message length (set md.messageLength64 for backwards-compatibility)\n md.fullMessageLength = md.messageLength64 = [];\n var int32s = md.messageLengthSize / 4;\n for(var i = 0; i < int32s; ++i) {\n md.fullMessageLength.push(0);\n }\n _input = forge.util.createBuffer();\n _state = {\n h0: 0x67452301,\n h1: 0xEFCDAB89,\n h2: 0x98BADCFE,\n h3: 0x10325476,\n h4: 0xC3D2E1F0\n };\n return md;\n };\n // start digest automatically for first time\n md.start();\n\n /**\n * Updates the digest with the given message input. The given input can\n * treated as raw input (no encoding will be applied) or an encoding of\n * 'utf8' maybe given to encode the input using UTF-8.\n *\n * @param msg the message input to update with.\n * @param encoding the encoding to use (default: 'raw', other: 'utf8').\n *\n * @return this digest object.\n */\n md.update = function(msg, encoding) {\n if(encoding === 'utf8') {\n msg = forge.util.encodeUtf8(msg);\n }\n\n // update message length\n var len = msg.length;\n md.messageLength += len;\n len = [(len / 0x100000000) >>> 0, len >>> 0];\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n md.fullMessageLength[i] += len[1];\n len[1] = len[0] + ((md.fullMessageLength[i] / 0x100000000) >>> 0);\n md.fullMessageLength[i] = md.fullMessageLength[i] >>> 0;\n len[0] = ((len[1] / 0x100000000) >>> 0);\n }\n\n // add bytes to input buffer\n _input.putBytes(msg);\n\n // process bytes\n _update(_state, _w, _input);\n\n // compact input buffer every 2K or if empty\n if(_input.read > 2048 || _input.length() === 0) {\n _input.compact();\n }\n\n return md;\n };\n\n /**\n * Produces the digest.\n *\n * @return a byte buffer containing the digest value.\n */\n md.digest = function() {\n /* Note: Here we copy the remaining bytes in the input buffer and\n add the appropriate SHA-1 padding. Then we do the final update\n on a copy of the state so that if the user wants to get\n intermediate digests they can do so. */\n\n /* Determine the number of bytes that must be added to the message\n to ensure its length is congruent to 448 mod 512. In other words,\n the data to be digested must be a multiple of 512 bits (or 128 bytes).\n This data includes the message, some padding, and the length of the\n message. Since the length of the message will be encoded as 8 bytes (64\n bits), that means that the last segment of the data must have 56 bytes\n (448 bits) of message and padding. Therefore, the length of the message\n plus the padding must be congruent to 448 mod 512 because\n 512 - 128 = 448.\n\n In order to fill up the message length it must be filled with\n padding that begins with 1 bit followed by all 0 bits. Padding\n must *always* be present, so if the message length is already\n congruent to 448 mod 512, then 512 padding bits must be added. */\n\n var finalBlock = forge.util.createBuffer();\n finalBlock.putBytes(_input.bytes());\n\n // compute remaining size to be digested (include message length size)\n var remaining = (\n md.fullMessageLength[md.fullMessageLength.length - 1] +\n md.messageLengthSize);\n\n // add padding for overflow blockSize - overflow\n // _padding starts with 1 byte with first bit is set (byte value 128), then\n // there may be up to (blockSize - 1) other pad bytes\n var overflow = remaining & (md.blockLength - 1);\n finalBlock.putBytes(_padding.substr(0, md.blockLength - overflow));\n\n // serialize message length in bits in big-endian order; since length\n // is stored in bytes we multiply by 8 and add carry from next int\n var next, carry;\n var bits = md.fullMessageLength[0] * 8;\n for(var i = 0; i < md.fullMessageLength.length - 1; ++i) {\n next = md.fullMessageLength[i + 1] * 8;\n carry = (next / 0x100000000) >>> 0;\n bits += carry;\n finalBlock.putInt32(bits >>> 0);\n bits = next >>> 0;\n }\n finalBlock.putInt32(bits);\n\n var s2 = {\n h0: _state.h0,\n h1: _state.h1,\n h2: _state.h2,\n h3: _state.h3,\n h4: _state.h4\n };\n _update(s2, _w, finalBlock);\n var rval = forge.util.createBuffer();\n rval.putInt32(s2.h0);\n rval.putInt32(s2.h1);\n rval.putInt32(s2.h2);\n rval.putInt32(s2.h3);\n rval.putInt32(s2.h4);\n return rval;\n };\n\n return md;\n};\n\n// sha-1 padding bytes not initialized yet\nvar _padding = null;\nvar _initialized = false;\n\n/**\n * Initializes the constant tables.\n */\nfunction _init() {\n // create padding\n _padding = String.fromCharCode(128);\n _padding += forge.util.fillString(String.fromCharCode(0x00), 64);\n\n // now initialized\n _initialized = true;\n}\n\n/**\n * Updates a SHA-1 state with the given byte buffer.\n *\n * @param s the SHA-1 state to update.\n * @param w the array to use to store words.\n * @param bytes the byte buffer to update with.\n */\nfunction _update(s, w, bytes) {\n // consume 512 bit (64 byte) chunks\n var t, a, b, c, d, e, f, i;\n var len = bytes.length();\n while(len >= 64) {\n // the w array will be populated with sixteen 32-bit big-endian words\n // and then extended into 80 32-bit words according to SHA-1 algorithm\n // and for 32-79 using Max Locktyukhin's optimization\n\n // initialize hash value for this chunk\n a = s.h0;\n b = s.h1;\n c = s.h2;\n d = s.h3;\n e = s.h4;\n\n // round 1\n for(i = 0; i < 16; ++i) {\n t = bytes.getInt32();\n w[i] = t;\n f = d ^ (b & (c ^ d));\n t = ((a << 5) | (a >>> 27)) + f + e + 0x5A827999 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n for(; i < 20; ++i) {\n t = (w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]);\n t = (t << 1) | (t >>> 31);\n w[i] = t;\n f = d ^ (b & (c ^ d));\n t = ((a << 5) | (a >>> 27)) + f + e + 0x5A827999 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n // round 2\n for(; i < 32; ++i) {\n t = (w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]);\n t = (t << 1) | (t >>> 31);\n w[i] = t;\n f = b ^ c ^ d;\n t = ((a << 5) | (a >>> 27)) + f + e + 0x6ED9EBA1 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n for(; i < 40; ++i) {\n t = (w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]);\n t = (t << 2) | (t >>> 30);\n w[i] = t;\n f = b ^ c ^ d;\n t = ((a << 5) | (a >>> 27)) + f + e + 0x6ED9EBA1 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n // round 3\n for(; i < 60; ++i) {\n t = (w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]);\n t = (t << 2) | (t >>> 30);\n w[i] = t;\n f = (b & c) | (d & (b ^ c));\n t = ((a << 5) | (a >>> 27)) + f + e + 0x8F1BBCDC + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n // round 4\n for(; i < 80; ++i) {\n t = (w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]);\n t = (t << 2) | (t >>> 30);\n w[i] = t;\n f = b ^ c ^ d;\n t = ((a << 5) | (a >>> 27)) + f + e + 0xCA62C1D6 + t;\n e = d;\n d = c;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n c = ((b << 30) | (b >>> 2)) >>> 0;\n b = a;\n a = t;\n }\n\n // update hash state\n s.h0 = (s.h0 + a) | 0;\n s.h1 = (s.h1 + b) | 0;\n s.h2 = (s.h2 + c) | 0;\n s.h3 = (s.h3 + d) | 0;\n s.h4 = (s.h4 + e) | 0;\n\n len -= 64;\n }\n}\n","/**\n * Secure Hash Algorithm with 256-bit digest (SHA-256) implementation.\n *\n * See FIPS 180-2 for details.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2015 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\nvar sha256 = module.exports = forge.sha256 = forge.sha256 || {};\nforge.md.sha256 = forge.md.algorithms.sha256 = sha256;\n\n/**\n * Creates a SHA-256 message digest object.\n *\n * @return a message digest object.\n */\nsha256.create = function() {\n // do initialization as necessary\n if(!_initialized) {\n _init();\n }\n\n // SHA-256 state contains eight 32-bit integers\n var _state = null;\n\n // input buffer\n var _input = forge.util.createBuffer();\n\n // used for word storage\n var _w = new Array(64);\n\n // message digest object\n var md = {\n algorithm: 'sha256',\n blockLength: 64,\n digestLength: 32,\n // 56-bit length of message so far (does not including padding)\n messageLength: 0,\n // true message length\n fullMessageLength: null,\n // size of message length in bytes\n messageLengthSize: 8\n };\n\n /**\n * Starts the digest.\n *\n * @return this digest object.\n */\n md.start = function() {\n // up to 56-bit message length for convenience\n md.messageLength = 0;\n\n // full message length (set md.messageLength64 for backwards-compatibility)\n md.fullMessageLength = md.messageLength64 = [];\n var int32s = md.messageLengthSize / 4;\n for(var i = 0; i < int32s; ++i) {\n md.fullMessageLength.push(0);\n }\n _input = forge.util.createBuffer();\n _state = {\n h0: 0x6A09E667,\n h1: 0xBB67AE85,\n h2: 0x3C6EF372,\n h3: 0xA54FF53A,\n h4: 0x510E527F,\n h5: 0x9B05688C,\n h6: 0x1F83D9AB,\n h7: 0x5BE0CD19\n };\n return md;\n };\n // start digest automatically for first time\n md.start();\n\n /**\n * Updates the digest with the given message input. The given input can\n * treated as raw input (no encoding will be applied) or an encoding of\n * 'utf8' maybe given to encode the input using UTF-8.\n *\n * @param msg the message input to update with.\n * @param encoding the encoding to use (default: 'raw', other: 'utf8').\n *\n * @return this digest object.\n */\n md.update = function(msg, encoding) {\n if(encoding === 'utf8') {\n msg = forge.util.encodeUtf8(msg);\n }\n\n // update message length\n var len = msg.length;\n md.messageLength += len;\n len = [(len / 0x100000000) >>> 0, len >>> 0];\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n md.fullMessageLength[i] += len[1];\n len[1] = len[0] + ((md.fullMessageLength[i] / 0x100000000) >>> 0);\n md.fullMessageLength[i] = md.fullMessageLength[i] >>> 0;\n len[0] = ((len[1] / 0x100000000) >>> 0);\n }\n\n // add bytes to input buffer\n _input.putBytes(msg);\n\n // process bytes\n _update(_state, _w, _input);\n\n // compact input buffer every 2K or if empty\n if(_input.read > 2048 || _input.length() === 0) {\n _input.compact();\n }\n\n return md;\n };\n\n /**\n * Produces the digest.\n *\n * @return a byte buffer containing the digest value.\n */\n md.digest = function() {\n /* Note: Here we copy the remaining bytes in the input buffer and\n add the appropriate SHA-256 padding. Then we do the final update\n on a copy of the state so that if the user wants to get\n intermediate digests they can do so. */\n\n /* Determine the number of bytes that must be added to the message\n to ensure its length is congruent to 448 mod 512. In other words,\n the data to be digested must be a multiple of 512 bits (or 128 bytes).\n This data includes the message, some padding, and the length of the\n message. Since the length of the message will be encoded as 8 bytes (64\n bits), that means that the last segment of the data must have 56 bytes\n (448 bits) of message and padding. Therefore, the length of the message\n plus the padding must be congruent to 448 mod 512 because\n 512 - 128 = 448.\n\n In order to fill up the message length it must be filled with\n padding that begins with 1 bit followed by all 0 bits. Padding\n must *always* be present, so if the message length is already\n congruent to 448 mod 512, then 512 padding bits must be added. */\n\n var finalBlock = forge.util.createBuffer();\n finalBlock.putBytes(_input.bytes());\n\n // compute remaining size to be digested (include message length size)\n var remaining = (\n md.fullMessageLength[md.fullMessageLength.length - 1] +\n md.messageLengthSize);\n\n // add padding for overflow blockSize - overflow\n // _padding starts with 1 byte with first bit is set (byte value 128), then\n // there may be up to (blockSize - 1) other pad bytes\n var overflow = remaining & (md.blockLength - 1);\n finalBlock.putBytes(_padding.substr(0, md.blockLength - overflow));\n\n // serialize message length in bits in big-endian order; since length\n // is stored in bytes we multiply by 8 and add carry from next int\n var next, carry;\n var bits = md.fullMessageLength[0] * 8;\n for(var i = 0; i < md.fullMessageLength.length - 1; ++i) {\n next = md.fullMessageLength[i + 1] * 8;\n carry = (next / 0x100000000) >>> 0;\n bits += carry;\n finalBlock.putInt32(bits >>> 0);\n bits = next >>> 0;\n }\n finalBlock.putInt32(bits);\n\n var s2 = {\n h0: _state.h0,\n h1: _state.h1,\n h2: _state.h2,\n h3: _state.h3,\n h4: _state.h4,\n h5: _state.h5,\n h6: _state.h6,\n h7: _state.h7\n };\n _update(s2, _w, finalBlock);\n var rval = forge.util.createBuffer();\n rval.putInt32(s2.h0);\n rval.putInt32(s2.h1);\n rval.putInt32(s2.h2);\n rval.putInt32(s2.h3);\n rval.putInt32(s2.h4);\n rval.putInt32(s2.h5);\n rval.putInt32(s2.h6);\n rval.putInt32(s2.h7);\n return rval;\n };\n\n return md;\n};\n\n// sha-256 padding bytes not initialized yet\nvar _padding = null;\nvar _initialized = false;\n\n// table of constants\nvar _k = null;\n\n/**\n * Initializes the constant tables.\n */\nfunction _init() {\n // create padding\n _padding = String.fromCharCode(128);\n _padding += forge.util.fillString(String.fromCharCode(0x00), 64);\n\n // create K table for SHA-256\n _k = [\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,\n 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,\n 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,\n 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,\n 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,\n 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,\n 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,\n 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\n 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];\n\n // now initialized\n _initialized = true;\n}\n\n/**\n * Updates a SHA-256 state with the given byte buffer.\n *\n * @param s the SHA-256 state to update.\n * @param w the array to use to store words.\n * @param bytes the byte buffer to update with.\n */\nfunction _update(s, w, bytes) {\n // consume 512 bit (64 byte) chunks\n var t1, t2, s0, s1, ch, maj, i, a, b, c, d, e, f, g, h;\n var len = bytes.length();\n while(len >= 64) {\n // the w array will be populated with sixteen 32-bit big-endian words\n // and then extended into 64 32-bit words according to SHA-256\n for(i = 0; i < 16; ++i) {\n w[i] = bytes.getInt32();\n }\n for(; i < 64; ++i) {\n // XOR word 2 words ago rot right 17, rot right 19, shft right 10\n t1 = w[i - 2];\n t1 =\n ((t1 >>> 17) | (t1 << 15)) ^\n ((t1 >>> 19) | (t1 << 13)) ^\n (t1 >>> 10);\n // XOR word 15 words ago rot right 7, rot right 18, shft right 3\n t2 = w[i - 15];\n t2 =\n ((t2 >>> 7) | (t2 << 25)) ^\n ((t2 >>> 18) | (t2 << 14)) ^\n (t2 >>> 3);\n // sum(t1, word 7 ago, t2, word 16 ago) modulo 2^32\n w[i] = (t1 + w[i - 7] + t2 + w[i - 16]) | 0;\n }\n\n // initialize hash value for this chunk\n a = s.h0;\n b = s.h1;\n c = s.h2;\n d = s.h3;\n e = s.h4;\n f = s.h5;\n g = s.h6;\n h = s.h7;\n\n // round function\n for(i = 0; i < 64; ++i) {\n // Sum1(e)\n s1 =\n ((e >>> 6) | (e << 26)) ^\n ((e >>> 11) | (e << 21)) ^\n ((e >>> 25) | (e << 7));\n // Ch(e, f, g) (optimized the same way as SHA-1)\n ch = g ^ (e & (f ^ g));\n // Sum0(a)\n s0 =\n ((a >>> 2) | (a << 30)) ^\n ((a >>> 13) | (a << 19)) ^\n ((a >>> 22) | (a << 10));\n // Maj(a, b, c) (optimized the same way as SHA-1)\n maj = (a & b) | (c & (a ^ b));\n\n // main algorithm\n t1 = h + s1 + ch + _k[i] + w[i];\n t2 = s0 + maj;\n h = g;\n g = f;\n f = e;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n // can't truncate with `| 0`\n e = (d + t1) >>> 0;\n d = c;\n c = b;\n b = a;\n // `>>> 0` necessary to avoid iOS/Safari 10 optimization bug\n // can't truncate with `| 0`\n a = (t1 + t2) >>> 0;\n }\n\n // update hash state\n s.h0 = (s.h0 + a) | 0;\n s.h1 = (s.h1 + b) | 0;\n s.h2 = (s.h2 + c) | 0;\n s.h3 = (s.h3 + d) | 0;\n s.h4 = (s.h4 + e) | 0;\n s.h5 = (s.h5 + f) | 0;\n s.h6 = (s.h6 + g) | 0;\n s.h7 = (s.h7 + h) | 0;\n len -= 64;\n }\n}\n","/**\n * Secure Hash Algorithm with a 1024-bit block size implementation.\n *\n * This includes: SHA-512, SHA-384, SHA-512/224, and SHA-512/256. For\n * SHA-256 (block size 512 bits), see sha256.js.\n *\n * See FIPS 180-4 for details.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2014-2015 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./md');\nrequire('./util');\n\nvar sha512 = module.exports = forge.sha512 = forge.sha512 || {};\n\n// SHA-512\nforge.md.sha512 = forge.md.algorithms.sha512 = sha512;\n\n// SHA-384\nvar sha384 = forge.sha384 = forge.sha512.sha384 = forge.sha512.sha384 || {};\nsha384.create = function() {\n return sha512.create('SHA-384');\n};\nforge.md.sha384 = forge.md.algorithms.sha384 = sha384;\n\n// SHA-512/256\nforge.sha512.sha256 = forge.sha512.sha256 || {\n create: function() {\n return sha512.create('SHA-512/256');\n }\n};\nforge.md['sha512/256'] = forge.md.algorithms['sha512/256'] =\n forge.sha512.sha256;\n\n// SHA-512/224\nforge.sha512.sha224 = forge.sha512.sha224 || {\n create: function() {\n return sha512.create('SHA-512/224');\n }\n};\nforge.md['sha512/224'] = forge.md.algorithms['sha512/224'] =\n forge.sha512.sha224;\n\n/**\n * Creates a SHA-2 message digest object.\n *\n * @param algorithm the algorithm to use (SHA-512, SHA-384, SHA-512/224,\n * SHA-512/256).\n *\n * @return a message digest object.\n */\nsha512.create = function(algorithm) {\n // do initialization as necessary\n if(!_initialized) {\n _init();\n }\n\n if(typeof algorithm === 'undefined') {\n algorithm = 'SHA-512';\n }\n\n if(!(algorithm in _states)) {\n throw new Error('Invalid SHA-512 algorithm: ' + algorithm);\n }\n\n // SHA-512 state contains eight 64-bit integers (each as two 32-bit ints)\n var _state = _states[algorithm];\n var _h = null;\n\n // input buffer\n var _input = forge.util.createBuffer();\n\n // used for 64-bit word storage\n var _w = new Array(80);\n for(var wi = 0; wi < 80; ++wi) {\n _w[wi] = new Array(2);\n }\n\n // determine digest length by algorithm name (default)\n var digestLength = 64;\n switch(algorithm) {\n case 'SHA-384':\n digestLength = 48;\n break;\n case 'SHA-512/256':\n digestLength = 32;\n break;\n case 'SHA-512/224':\n digestLength = 28;\n break;\n }\n\n // message digest object\n var md = {\n // SHA-512 => sha512\n algorithm: algorithm.replace('-', '').toLowerCase(),\n blockLength: 128,\n digestLength: digestLength,\n // 56-bit length of message so far (does not including padding)\n messageLength: 0,\n // true message length\n fullMessageLength: null,\n // size of message length in bytes\n messageLengthSize: 16\n };\n\n /**\n * Starts the digest.\n *\n * @return this digest object.\n */\n md.start = function() {\n // up to 56-bit message length for convenience\n md.messageLength = 0;\n\n // full message length (set md.messageLength128 for backwards-compatibility)\n md.fullMessageLength = md.messageLength128 = [];\n var int32s = md.messageLengthSize / 4;\n for(var i = 0; i < int32s; ++i) {\n md.fullMessageLength.push(0);\n }\n _input = forge.util.createBuffer();\n _h = new Array(_state.length);\n for(var i = 0; i < _state.length; ++i) {\n _h[i] = _state[i].slice(0);\n }\n return md;\n };\n // start digest automatically for first time\n md.start();\n\n /**\n * Updates the digest with the given message input. The given input can\n * treated as raw input (no encoding will be applied) or an encoding of\n * 'utf8' maybe given to encode the input using UTF-8.\n *\n * @param msg the message input to update with.\n * @param encoding the encoding to use (default: 'raw', other: 'utf8').\n *\n * @return this digest object.\n */\n md.update = function(msg, encoding) {\n if(encoding === 'utf8') {\n msg = forge.util.encodeUtf8(msg);\n }\n\n // update message length\n var len = msg.length;\n md.messageLength += len;\n len = [(len / 0x100000000) >>> 0, len >>> 0];\n for(var i = md.fullMessageLength.length - 1; i >= 0; --i) {\n md.fullMessageLength[i] += len[1];\n len[1] = len[0] + ((md.fullMessageLength[i] / 0x100000000) >>> 0);\n md.fullMessageLength[i] = md.fullMessageLength[i] >>> 0;\n len[0] = ((len[1] / 0x100000000) >>> 0);\n }\n\n // add bytes to input buffer\n _input.putBytes(msg);\n\n // process bytes\n _update(_h, _w, _input);\n\n // compact input buffer every 2K or if empty\n if(_input.read > 2048 || _input.length() === 0) {\n _input.compact();\n }\n\n return md;\n };\n\n /**\n * Produces the digest.\n *\n * @return a byte buffer containing the digest value.\n */\n md.digest = function() {\n /* Note: Here we copy the remaining bytes in the input buffer and\n add the appropriate SHA-512 padding. Then we do the final update\n on a copy of the state so that if the user wants to get\n intermediate digests they can do so. */\n\n /* Determine the number of bytes that must be added to the message\n to ensure its length is congruent to 896 mod 1024. In other words,\n the data to be digested must be a multiple of 1024 bits (or 128 bytes).\n This data includes the message, some padding, and the length of the\n message. Since the length of the message will be encoded as 16 bytes (128\n bits), that means that the last segment of the data must have 112 bytes\n (896 bits) of message and padding. Therefore, the length of the message\n plus the padding must be congruent to 896 mod 1024 because\n 1024 - 128 = 896.\n\n In order to fill up the message length it must be filled with\n padding that begins with 1 bit followed by all 0 bits. Padding\n must *always* be present, so if the message length is already\n congruent to 896 mod 1024, then 1024 padding bits must be added. */\n\n var finalBlock = forge.util.createBuffer();\n finalBlock.putBytes(_input.bytes());\n\n // compute remaining size to be digested (include message length size)\n var remaining = (\n md.fullMessageLength[md.fullMessageLength.length - 1] +\n md.messageLengthSize);\n\n // add padding for overflow blockSize - overflow\n // _padding starts with 1 byte with first bit is set (byte value 128), then\n // there may be up to (blockSize - 1) other pad bytes\n var overflow = remaining & (md.blockLength - 1);\n finalBlock.putBytes(_padding.substr(0, md.blockLength - overflow));\n\n // serialize message length in bits in big-endian order; since length\n // is stored in bytes we multiply by 8 and add carry from next int\n var next, carry;\n var bits = md.fullMessageLength[0] * 8;\n for(var i = 0; i < md.fullMessageLength.length - 1; ++i) {\n next = md.fullMessageLength[i + 1] * 8;\n carry = (next / 0x100000000) >>> 0;\n bits += carry;\n finalBlock.putInt32(bits >>> 0);\n bits = next >>> 0;\n }\n finalBlock.putInt32(bits);\n\n var h = new Array(_h.length);\n for(var i = 0; i < _h.length; ++i) {\n h[i] = _h[i].slice(0);\n }\n _update(h, _w, finalBlock);\n var rval = forge.util.createBuffer();\n var hlen;\n if(algorithm === 'SHA-512') {\n hlen = h.length;\n } else if(algorithm === 'SHA-384') {\n hlen = h.length - 2;\n } else {\n hlen = h.length - 4;\n }\n for(var i = 0; i < hlen; ++i) {\n rval.putInt32(h[i][0]);\n if(i !== hlen - 1 || algorithm !== 'SHA-512/224') {\n rval.putInt32(h[i][1]);\n }\n }\n return rval;\n };\n\n return md;\n};\n\n// sha-512 padding bytes not initialized yet\nvar _padding = null;\nvar _initialized = false;\n\n// table of constants\nvar _k = null;\n\n// initial hash states\nvar _states = null;\n\n/**\n * Initializes the constant tables.\n */\nfunction _init() {\n // create padding\n _padding = String.fromCharCode(128);\n _padding += forge.util.fillString(String.fromCharCode(0x00), 128);\n\n // create K table for SHA-512\n _k = [\n [0x428a2f98, 0xd728ae22], [0x71374491, 0x23ef65cd],\n [0xb5c0fbcf, 0xec4d3b2f], [0xe9b5dba5, 0x8189dbbc],\n [0x3956c25b, 0xf348b538], [0x59f111f1, 0xb605d019],\n [0x923f82a4, 0xaf194f9b], [0xab1c5ed5, 0xda6d8118],\n [0xd807aa98, 0xa3030242], [0x12835b01, 0x45706fbe],\n [0x243185be, 0x4ee4b28c], [0x550c7dc3, 0xd5ffb4e2],\n [0x72be5d74, 0xf27b896f], [0x80deb1fe, 0x3b1696b1],\n [0x9bdc06a7, 0x25c71235], [0xc19bf174, 0xcf692694],\n [0xe49b69c1, 0x9ef14ad2], [0xefbe4786, 0x384f25e3],\n [0x0fc19dc6, 0x8b8cd5b5], [0x240ca1cc, 0x77ac9c65],\n [0x2de92c6f, 0x592b0275], [0x4a7484aa, 0x6ea6e483],\n [0x5cb0a9dc, 0xbd41fbd4], [0x76f988da, 0x831153b5],\n [0x983e5152, 0xee66dfab], [0xa831c66d, 0x2db43210],\n [0xb00327c8, 0x98fb213f], [0xbf597fc7, 0xbeef0ee4],\n [0xc6e00bf3, 0x3da88fc2], [0xd5a79147, 0x930aa725],\n [0x06ca6351, 0xe003826f], [0x14292967, 0x0a0e6e70],\n [0x27b70a85, 0x46d22ffc], [0x2e1b2138, 0x5c26c926],\n [0x4d2c6dfc, 0x5ac42aed], [0x53380d13, 0x9d95b3df],\n [0x650a7354, 0x8baf63de], [0x766a0abb, 0x3c77b2a8],\n [0x81c2c92e, 0x47edaee6], [0x92722c85, 0x1482353b],\n [0xa2bfe8a1, 0x4cf10364], [0xa81a664b, 0xbc423001],\n [0xc24b8b70, 0xd0f89791], [0xc76c51a3, 0x0654be30],\n [0xd192e819, 0xd6ef5218], [0xd6990624, 0x5565a910],\n [0xf40e3585, 0x5771202a], [0x106aa070, 0x32bbd1b8],\n [0x19a4c116, 0xb8d2d0c8], [0x1e376c08, 0x5141ab53],\n [0x2748774c, 0xdf8eeb99], [0x34b0bcb5, 0xe19b48a8],\n [0x391c0cb3, 0xc5c95a63], [0x4ed8aa4a, 0xe3418acb],\n [0x5b9cca4f, 0x7763e373], [0x682e6ff3, 0xd6b2b8a3],\n [0x748f82ee, 0x5defb2fc], [0x78a5636f, 0x43172f60],\n [0x84c87814, 0xa1f0ab72], [0x8cc70208, 0x1a6439ec],\n [0x90befffa, 0x23631e28], [0xa4506ceb, 0xde82bde9],\n [0xbef9a3f7, 0xb2c67915], [0xc67178f2, 0xe372532b],\n [0xca273ece, 0xea26619c], [0xd186b8c7, 0x21c0c207],\n [0xeada7dd6, 0xcde0eb1e], [0xf57d4f7f, 0xee6ed178],\n [0x06f067aa, 0x72176fba], [0x0a637dc5, 0xa2c898a6],\n [0x113f9804, 0xbef90dae], [0x1b710b35, 0x131c471b],\n [0x28db77f5, 0x23047d84], [0x32caab7b, 0x40c72493],\n [0x3c9ebe0a, 0x15c9bebc], [0x431d67c4, 0x9c100d4c],\n [0x4cc5d4be, 0xcb3e42b6], [0x597f299c, 0xfc657e2a],\n [0x5fcb6fab, 0x3ad6faec], [0x6c44198c, 0x4a475817]\n ];\n\n // initial hash states\n _states = {};\n _states['SHA-512'] = [\n [0x6a09e667, 0xf3bcc908],\n [0xbb67ae85, 0x84caa73b],\n [0x3c6ef372, 0xfe94f82b],\n [0xa54ff53a, 0x5f1d36f1],\n [0x510e527f, 0xade682d1],\n [0x9b05688c, 0x2b3e6c1f],\n [0x1f83d9ab, 0xfb41bd6b],\n [0x5be0cd19, 0x137e2179]\n ];\n _states['SHA-384'] = [\n [0xcbbb9d5d, 0xc1059ed8],\n [0x629a292a, 0x367cd507],\n [0x9159015a, 0x3070dd17],\n [0x152fecd8, 0xf70e5939],\n [0x67332667, 0xffc00b31],\n [0x8eb44a87, 0x68581511],\n [0xdb0c2e0d, 0x64f98fa7],\n [0x47b5481d, 0xbefa4fa4]\n ];\n _states['SHA-512/256'] = [\n [0x22312194, 0xFC2BF72C],\n [0x9F555FA3, 0xC84C64C2],\n [0x2393B86B, 0x6F53B151],\n [0x96387719, 0x5940EABD],\n [0x96283EE2, 0xA88EFFE3],\n [0xBE5E1E25, 0x53863992],\n [0x2B0199FC, 0x2C85B8AA],\n [0x0EB72DDC, 0x81C52CA2]\n ];\n _states['SHA-512/224'] = [\n [0x8C3D37C8, 0x19544DA2],\n [0x73E19966, 0x89DCD4D6],\n [0x1DFAB7AE, 0x32FF9C82],\n [0x679DD514, 0x582F9FCF],\n [0x0F6D2B69, 0x7BD44DA8],\n [0x77E36F73, 0x04C48942],\n [0x3F9D85A8, 0x6A1D36C8],\n [0x1112E6AD, 0x91D692A1]\n ];\n\n // now initialized\n _initialized = true;\n}\n\n/**\n * Updates a SHA-512 state with the given byte buffer.\n *\n * @param s the SHA-512 state to update.\n * @param w the array to use to store words.\n * @param bytes the byte buffer to update with.\n */\nfunction _update(s, w, bytes) {\n // consume 512 bit (128 byte) chunks\n var t1_hi, t1_lo;\n var t2_hi, t2_lo;\n var s0_hi, s0_lo;\n var s1_hi, s1_lo;\n var ch_hi, ch_lo;\n var maj_hi, maj_lo;\n var a_hi, a_lo;\n var b_hi, b_lo;\n var c_hi, c_lo;\n var d_hi, d_lo;\n var e_hi, e_lo;\n var f_hi, f_lo;\n var g_hi, g_lo;\n var h_hi, h_lo;\n var i, hi, lo, w2, w7, w15, w16;\n var len = bytes.length();\n while(len >= 128) {\n // the w array will be populated with sixteen 64-bit big-endian words\n // and then extended into 64 64-bit words according to SHA-512\n for(i = 0; i < 16; ++i) {\n w[i][0] = bytes.getInt32() >>> 0;\n w[i][1] = bytes.getInt32() >>> 0;\n }\n for(; i < 80; ++i) {\n // for word 2 words ago: ROTR 19(x) ^ ROTR 61(x) ^ SHR 6(x)\n w2 = w[i - 2];\n hi = w2[0];\n lo = w2[1];\n\n // high bits\n t1_hi = (\n ((hi >>> 19) | (lo << 13)) ^ // ROTR 19\n ((lo >>> 29) | (hi << 3)) ^ // ROTR 61/(swap + ROTR 29)\n (hi >>> 6)) >>> 0; // SHR 6\n // low bits\n t1_lo = (\n ((hi << 13) | (lo >>> 19)) ^ // ROTR 19\n ((lo << 3) | (hi >>> 29)) ^ // ROTR 61/(swap + ROTR 29)\n ((hi << 26) | (lo >>> 6))) >>> 0; // SHR 6\n\n // for word 15 words ago: ROTR 1(x) ^ ROTR 8(x) ^ SHR 7(x)\n w15 = w[i - 15];\n hi = w15[0];\n lo = w15[1];\n\n // high bits\n t2_hi = (\n ((hi >>> 1) | (lo << 31)) ^ // ROTR 1\n ((hi >>> 8) | (lo << 24)) ^ // ROTR 8\n (hi >>> 7)) >>> 0; // SHR 7\n // low bits\n t2_lo = (\n ((hi << 31) | (lo >>> 1)) ^ // ROTR 1\n ((hi << 24) | (lo >>> 8)) ^ // ROTR 8\n ((hi << 25) | (lo >>> 7))) >>> 0; // SHR 7\n\n // sum(t1, word 7 ago, t2, word 16 ago) modulo 2^64 (carry lo overflow)\n w7 = w[i - 7];\n w16 = w[i - 16];\n lo = (t1_lo + w7[1] + t2_lo + w16[1]);\n w[i][0] = (t1_hi + w7[0] + t2_hi + w16[0] +\n ((lo / 0x100000000) >>> 0)) >>> 0;\n w[i][1] = lo >>> 0;\n }\n\n // initialize hash value for this chunk\n a_hi = s[0][0];\n a_lo = s[0][1];\n b_hi = s[1][0];\n b_lo = s[1][1];\n c_hi = s[2][0];\n c_lo = s[2][1];\n d_hi = s[3][0];\n d_lo = s[3][1];\n e_hi = s[4][0];\n e_lo = s[4][1];\n f_hi = s[5][0];\n f_lo = s[5][1];\n g_hi = s[6][0];\n g_lo = s[6][1];\n h_hi = s[7][0];\n h_lo = s[7][1];\n\n // round function\n for(i = 0; i < 80; ++i) {\n // Sum1(e) = ROTR 14(e) ^ ROTR 18(e) ^ ROTR 41(e)\n s1_hi = (\n ((e_hi >>> 14) | (e_lo << 18)) ^ // ROTR 14\n ((e_hi >>> 18) | (e_lo << 14)) ^ // ROTR 18\n ((e_lo >>> 9) | (e_hi << 23))) >>> 0; // ROTR 41/(swap + ROTR 9)\n s1_lo = (\n ((e_hi << 18) | (e_lo >>> 14)) ^ // ROTR 14\n ((e_hi << 14) | (e_lo >>> 18)) ^ // ROTR 18\n ((e_lo << 23) | (e_hi >>> 9))) >>> 0; // ROTR 41/(swap + ROTR 9)\n\n // Ch(e, f, g) (optimized the same way as SHA-1)\n ch_hi = (g_hi ^ (e_hi & (f_hi ^ g_hi))) >>> 0;\n ch_lo = (g_lo ^ (e_lo & (f_lo ^ g_lo))) >>> 0;\n\n // Sum0(a) = ROTR 28(a) ^ ROTR 34(a) ^ ROTR 39(a)\n s0_hi = (\n ((a_hi >>> 28) | (a_lo << 4)) ^ // ROTR 28\n ((a_lo >>> 2) | (a_hi << 30)) ^ // ROTR 34/(swap + ROTR 2)\n ((a_lo >>> 7) | (a_hi << 25))) >>> 0; // ROTR 39/(swap + ROTR 7)\n s0_lo = (\n ((a_hi << 4) | (a_lo >>> 28)) ^ // ROTR 28\n ((a_lo << 30) | (a_hi >>> 2)) ^ // ROTR 34/(swap + ROTR 2)\n ((a_lo << 25) | (a_hi >>> 7))) >>> 0; // ROTR 39/(swap + ROTR 7)\n\n // Maj(a, b, c) (optimized the same way as SHA-1)\n maj_hi = ((a_hi & b_hi) | (c_hi & (a_hi ^ b_hi))) >>> 0;\n maj_lo = ((a_lo & b_lo) | (c_lo & (a_lo ^ b_lo))) >>> 0;\n\n // main algorithm\n // t1 = (h + s1 + ch + _k[i] + _w[i]) modulo 2^64 (carry lo overflow)\n lo = (h_lo + s1_lo + ch_lo + _k[i][1] + w[i][1]);\n t1_hi = (h_hi + s1_hi + ch_hi + _k[i][0] + w[i][0] +\n ((lo / 0x100000000) >>> 0)) >>> 0;\n t1_lo = lo >>> 0;\n\n // t2 = s0 + maj modulo 2^64 (carry lo overflow)\n lo = s0_lo + maj_lo;\n t2_hi = (s0_hi + maj_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n t2_lo = lo >>> 0;\n\n h_hi = g_hi;\n h_lo = g_lo;\n\n g_hi = f_hi;\n g_lo = f_lo;\n\n f_hi = e_hi;\n f_lo = e_lo;\n\n // e = (d + t1) modulo 2^64 (carry lo overflow)\n lo = d_lo + t1_lo;\n e_hi = (d_hi + t1_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n e_lo = lo >>> 0;\n\n d_hi = c_hi;\n d_lo = c_lo;\n\n c_hi = b_hi;\n c_lo = b_lo;\n\n b_hi = a_hi;\n b_lo = a_lo;\n\n // a = (t1 + t2) modulo 2^64 (carry lo overflow)\n lo = t1_lo + t2_lo;\n a_hi = (t1_hi + t2_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n a_lo = lo >>> 0;\n }\n\n // update hash state (additional modulo 2^64)\n lo = s[0][1] + a_lo;\n s[0][0] = (s[0][0] + a_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[0][1] = lo >>> 0;\n\n lo = s[1][1] + b_lo;\n s[1][0] = (s[1][0] + b_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[1][1] = lo >>> 0;\n\n lo = s[2][1] + c_lo;\n s[2][0] = (s[2][0] + c_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[2][1] = lo >>> 0;\n\n lo = s[3][1] + d_lo;\n s[3][0] = (s[3][0] + d_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[3][1] = lo >>> 0;\n\n lo = s[4][1] + e_lo;\n s[4][0] = (s[4][0] + e_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[4][1] = lo >>> 0;\n\n lo = s[5][1] + f_lo;\n s[5][0] = (s[5][0] + f_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[5][1] = lo >>> 0;\n\n lo = s[6][1] + g_lo;\n s[6][0] = (s[6][0] + g_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[6][1] = lo >>> 0;\n\n lo = s[7][1] + h_lo;\n s[7][0] = (s[7][0] + h_hi + ((lo / 0x100000000) >>> 0)) >>> 0;\n s[7][1] = lo >>> 0;\n\n len -= 128;\n }\n}\n","/**\n * Functions to output keys in SSH-friendly formats.\n *\n * This is part of the Forge project which may be used under the terms of\n * either the BSD License or the GNU General Public License (GPL) Version 2.\n *\n * See: https://github.com/digitalbazaar/forge/blob/cbebca3780658703d925b61b2caffb1d263a6c1d/LICENSE\n *\n * @author https://github.com/shellac\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./hmac');\nrequire('./md5');\nrequire('./sha1');\nrequire('./util');\n\nvar ssh = module.exports = forge.ssh = forge.ssh || {};\n\n/**\n * Encodes (and optionally encrypts) a private RSA key as a Putty PPK file.\n *\n * @param privateKey the key.\n * @param passphrase a passphrase to protect the key (falsy for no encryption).\n * @param comment a comment to include in the key file.\n *\n * @return the PPK file as a string.\n */\nssh.privateKeyToPutty = function(privateKey, passphrase, comment) {\n comment = comment || '';\n passphrase = passphrase || '';\n var algorithm = 'ssh-rsa';\n var encryptionAlgorithm = (passphrase === '') ? 'none' : 'aes256-cbc';\n\n var ppk = 'PuTTY-User-Key-File-2: ' + algorithm + '\\r\\n';\n ppk += 'Encryption: ' + encryptionAlgorithm + '\\r\\n';\n ppk += 'Comment: ' + comment + '\\r\\n';\n\n // public key into buffer for ppk\n var pubbuffer = forge.util.createBuffer();\n _addStringToBuffer(pubbuffer, algorithm);\n _addBigIntegerToBuffer(pubbuffer, privateKey.e);\n _addBigIntegerToBuffer(pubbuffer, privateKey.n);\n\n // write public key\n var pub = forge.util.encode64(pubbuffer.bytes(), 64);\n var length = Math.floor(pub.length / 66) + 1; // 66 = 64 + \\r\\n\n ppk += 'Public-Lines: ' + length + '\\r\\n';\n ppk += pub;\n\n // private key into a buffer\n var privbuffer = forge.util.createBuffer();\n _addBigIntegerToBuffer(privbuffer, privateKey.d);\n _addBigIntegerToBuffer(privbuffer, privateKey.p);\n _addBigIntegerToBuffer(privbuffer, privateKey.q);\n _addBigIntegerToBuffer(privbuffer, privateKey.qInv);\n\n // optionally encrypt the private key\n var priv;\n if(!passphrase) {\n // use the unencrypted buffer\n priv = forge.util.encode64(privbuffer.bytes(), 64);\n } else {\n // encrypt RSA key using passphrase\n var encLen = privbuffer.length() + 16 - 1;\n encLen -= encLen % 16;\n\n // pad private key with sha1-d data -- needs to be a multiple of 16\n var padding = _sha1(privbuffer.bytes());\n\n padding.truncate(padding.length() - encLen + privbuffer.length());\n privbuffer.putBuffer(padding);\n\n var aeskey = forge.util.createBuffer();\n aeskey.putBuffer(_sha1('\\x00\\x00\\x00\\x00', passphrase));\n aeskey.putBuffer(_sha1('\\x00\\x00\\x00\\x01', passphrase));\n\n // encrypt some bytes using CBC mode\n // key is 40 bytes, so truncate *by* 8 bytes\n var cipher = forge.aes.createEncryptionCipher(aeskey.truncate(8), 'CBC');\n cipher.start(forge.util.createBuffer().fillWithByte(0, 16));\n cipher.update(privbuffer.copy());\n cipher.finish();\n var encrypted = cipher.output;\n\n // Note: this appears to differ from Putty -- is forge wrong, or putty?\n // due to padding we finish as an exact multiple of 16\n encrypted.truncate(16); // all padding\n\n priv = forge.util.encode64(encrypted.bytes(), 64);\n }\n\n // output private key\n length = Math.floor(priv.length / 66) + 1; // 64 + \\r\\n\n ppk += '\\r\\nPrivate-Lines: ' + length + '\\r\\n';\n ppk += priv;\n\n // MAC\n var mackey = _sha1('putty-private-key-file-mac-key', passphrase);\n\n var macbuffer = forge.util.createBuffer();\n _addStringToBuffer(macbuffer, algorithm);\n _addStringToBuffer(macbuffer, encryptionAlgorithm);\n _addStringToBuffer(macbuffer, comment);\n macbuffer.putInt32(pubbuffer.length());\n macbuffer.putBuffer(pubbuffer);\n macbuffer.putInt32(privbuffer.length());\n macbuffer.putBuffer(privbuffer);\n\n var hmac = forge.hmac.create();\n hmac.start('sha1', mackey);\n hmac.update(macbuffer.bytes());\n\n ppk += '\\r\\nPrivate-MAC: ' + hmac.digest().toHex() + '\\r\\n';\n\n return ppk;\n};\n\n/**\n * Encodes a public RSA key as an OpenSSH file.\n *\n * @param key the key.\n * @param comment a comment.\n *\n * @return the public key in OpenSSH format.\n */\nssh.publicKeyToOpenSSH = function(key, comment) {\n var type = 'ssh-rsa';\n comment = comment || '';\n\n var buffer = forge.util.createBuffer();\n _addStringToBuffer(buffer, type);\n _addBigIntegerToBuffer(buffer, key.e);\n _addBigIntegerToBuffer(buffer, key.n);\n\n return type + ' ' + forge.util.encode64(buffer.bytes()) + ' ' + comment;\n};\n\n/**\n * Encodes a private RSA key as an OpenSSH file.\n *\n * @param key the key.\n * @param passphrase a passphrase to protect the key (falsy for no encryption).\n *\n * @return the public key in OpenSSH format.\n */\nssh.privateKeyToOpenSSH = function(privateKey, passphrase) {\n if(!passphrase) {\n return forge.pki.privateKeyToPem(privateKey);\n }\n // OpenSSH private key is just a legacy format, it seems\n return forge.pki.encryptRsaPrivateKey(privateKey, passphrase,\n {legacy: true, algorithm: 'aes128'});\n};\n\n/**\n * Gets the SSH fingerprint for the given public key.\n *\n * @param options the options to use.\n * [md] the message digest object to use (defaults to forge.md.md5).\n * [encoding] an alternative output encoding, such as 'hex'\n * (defaults to none, outputs a byte buffer).\n * [delimiter] the delimiter to use between bytes for 'hex' encoded\n * output, eg: ':' (defaults to none).\n *\n * @return the fingerprint as a byte buffer or other encoding based on options.\n */\nssh.getPublicKeyFingerprint = function(key, options) {\n options = options || {};\n var md = options.md || forge.md.md5.create();\n\n var type = 'ssh-rsa';\n var buffer = forge.util.createBuffer();\n _addStringToBuffer(buffer, type);\n _addBigIntegerToBuffer(buffer, key.e);\n _addBigIntegerToBuffer(buffer, key.n);\n\n // hash public key bytes\n md.start();\n md.update(buffer.getBytes());\n var digest = md.digest();\n if(options.encoding === 'hex') {\n var hex = digest.toHex();\n if(options.delimiter) {\n return hex.match(/.{2}/g).join(options.delimiter);\n }\n return hex;\n } else if(options.encoding === 'binary') {\n return digest.getBytes();\n } else if(options.encoding) {\n throw new Error('Unknown encoding \"' + options.encoding + '\".');\n }\n return digest;\n};\n\n/**\n * Adds len(val) then val to a buffer.\n *\n * @param buffer the buffer to add to.\n * @param val a big integer.\n */\nfunction _addBigIntegerToBuffer(buffer, val) {\n var hexVal = val.toString(16);\n // ensure 2s complement +ve\n if(hexVal[0] >= '8') {\n hexVal = '00' + hexVal;\n }\n var bytes = forge.util.hexToBytes(hexVal);\n buffer.putInt32(bytes.length);\n buffer.putBytes(bytes);\n}\n\n/**\n * Adds len(val) then val to a buffer.\n *\n * @param buffer the buffer to add to.\n * @param val a string.\n */\nfunction _addStringToBuffer(buffer, val) {\n buffer.putInt32(val.length);\n buffer.putString(val);\n}\n\n/**\n * Hashes the arguments into one value using SHA-1.\n *\n * @return the sha1 hash of the provided arguments.\n */\nfunction _sha1() {\n var sha = forge.md.sha1.create();\n var num = arguments.length;\n for (var i = 0; i < num; ++i) {\n sha.update(arguments[i]);\n }\n return sha.digest();\n}\n","/**\n * Support for concurrent task management and synchronization in web\n * applications.\n *\n * @author Dave Longley\n * @author David I. Lehn \n *\n * Copyright (c) 2009-2013 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nrequire('./debug');\nrequire('./log');\nrequire('./util');\n\n// logging category\nvar cat = 'forge.task';\n\n// verbose level\n// 0: off, 1: a little, 2: a whole lot\n// Verbose debug logging is surrounded by a level check to avoid the\n// performance issues with even calling the logging code regardless if it\n// is actually logged. For performance reasons this should not be set to 2\n// for production use.\n// ex: if(sVL >= 2) forge.log.verbose(....)\nvar sVL = 0;\n\n// track tasks for debugging\nvar sTasks = {};\nvar sNextTaskId = 0;\n// debug access\nforge.debug.set(cat, 'tasks', sTasks);\n\n// a map of task type to task queue\nvar sTaskQueues = {};\n// debug access\nforge.debug.set(cat, 'queues', sTaskQueues);\n\n// name for unnamed tasks\nvar sNoTaskName = '?';\n\n// maximum number of doNext() recursions before a context swap occurs\n// FIXME: might need to tweak this based on the browser\nvar sMaxRecursions = 30;\n\n// time slice for doing tasks before a context swap occurs\n// FIXME: might need to tweak this based on the browser\nvar sTimeSlice = 20;\n\n/**\n * Task states.\n *\n * READY: ready to start processing\n * RUNNING: task or a subtask is running\n * BLOCKED: task is waiting to acquire N permits to continue\n * SLEEPING: task is sleeping for a period of time\n * DONE: task is done\n * ERROR: task has an error\n */\nvar READY = 'ready';\nvar RUNNING = 'running';\nvar BLOCKED = 'blocked';\nvar SLEEPING = 'sleeping';\nvar DONE = 'done';\nvar ERROR = 'error';\n\n/**\n * Task actions. Used to control state transitions.\n *\n * STOP: stop processing\n * START: start processing tasks\n * BLOCK: block task from continuing until 1 or more permits are released\n * UNBLOCK: release one or more permits\n * SLEEP: sleep for a period of time\n * WAKEUP: wakeup early from SLEEPING state\n * CANCEL: cancel further tasks\n * FAIL: a failure occured\n */\nvar STOP = 'stop';\nvar START = 'start';\nvar BLOCK = 'block';\nvar UNBLOCK = 'unblock';\nvar SLEEP = 'sleep';\nvar WAKEUP = 'wakeup';\nvar CANCEL = 'cancel';\nvar FAIL = 'fail';\n\n/**\n * State transition table.\n *\n * nextState = sStateTable[currentState][action]\n */\nvar sStateTable = {};\n\nsStateTable[READY] = {};\nsStateTable[READY][STOP] = READY;\nsStateTable[READY][START] = RUNNING;\nsStateTable[READY][CANCEL] = DONE;\nsStateTable[READY][FAIL] = ERROR;\n\nsStateTable[RUNNING] = {};\nsStateTable[RUNNING][STOP] = READY;\nsStateTable[RUNNING][START] = RUNNING;\nsStateTable[RUNNING][BLOCK] = BLOCKED;\nsStateTable[RUNNING][UNBLOCK] = RUNNING;\nsStateTable[RUNNING][SLEEP] = SLEEPING;\nsStateTable[RUNNING][WAKEUP] = RUNNING;\nsStateTable[RUNNING][CANCEL] = DONE;\nsStateTable[RUNNING][FAIL] = ERROR;\n\nsStateTable[BLOCKED] = {};\nsStateTable[BLOCKED][STOP] = BLOCKED;\nsStateTable[BLOCKED][START] = BLOCKED;\nsStateTable[BLOCKED][BLOCK] = BLOCKED;\nsStateTable[BLOCKED][UNBLOCK] = BLOCKED;\nsStateTable[BLOCKED][SLEEP] = BLOCKED;\nsStateTable[BLOCKED][WAKEUP] = BLOCKED;\nsStateTable[BLOCKED][CANCEL] = DONE;\nsStateTable[BLOCKED][FAIL] = ERROR;\n\nsStateTable[SLEEPING] = {};\nsStateTable[SLEEPING][STOP] = SLEEPING;\nsStateTable[SLEEPING][START] = SLEEPING;\nsStateTable[SLEEPING][BLOCK] = SLEEPING;\nsStateTable[SLEEPING][UNBLOCK] = SLEEPING;\nsStateTable[SLEEPING][SLEEP] = SLEEPING;\nsStateTable[SLEEPING][WAKEUP] = SLEEPING;\nsStateTable[SLEEPING][CANCEL] = DONE;\nsStateTable[SLEEPING][FAIL] = ERROR;\n\nsStateTable[DONE] = {};\nsStateTable[DONE][STOP] = DONE;\nsStateTable[DONE][START] = DONE;\nsStateTable[DONE][BLOCK] = DONE;\nsStateTable[DONE][UNBLOCK] = DONE;\nsStateTable[DONE][SLEEP] = DONE;\nsStateTable[DONE][WAKEUP] = DONE;\nsStateTable[DONE][CANCEL] = DONE;\nsStateTable[DONE][FAIL] = ERROR;\n\nsStateTable[ERROR] = {};\nsStateTable[ERROR][STOP] = ERROR;\nsStateTable[ERROR][START] = ERROR;\nsStateTable[ERROR][BLOCK] = ERROR;\nsStateTable[ERROR][UNBLOCK] = ERROR;\nsStateTable[ERROR][SLEEP] = ERROR;\nsStateTable[ERROR][WAKEUP] = ERROR;\nsStateTable[ERROR][CANCEL] = ERROR;\nsStateTable[ERROR][FAIL] = ERROR;\n\n/**\n * Creates a new task.\n *\n * @param options options for this task\n * run: the run function for the task (required)\n * name: the run function for the task (optional)\n * parent: parent of this task (optional)\n *\n * @return the empty task.\n */\nvar Task = function(options) {\n // task id\n this.id = -1;\n\n // task name\n this.name = options.name || sNoTaskName;\n\n // task has no parent\n this.parent = options.parent || null;\n\n // save run function\n this.run = options.run;\n\n // create a queue of subtasks to run\n this.subtasks = [];\n\n // error flag\n this.error = false;\n\n // state of the task\n this.state = READY;\n\n // number of times the task has been blocked (also the number\n // of permits needed to be released to continue running)\n this.blocks = 0;\n\n // timeout id when sleeping\n this.timeoutId = null;\n\n // no swap time yet\n this.swapTime = null;\n\n // no user data\n this.userData = null;\n\n // initialize task\n // FIXME: deal with overflow\n this.id = sNextTaskId++;\n sTasks[this.id] = this;\n if(sVL >= 1) {\n forge.log.verbose(cat, '[%s][%s] init', this.id, this.name, this);\n }\n};\n\n/**\n * Logs debug information on this task and the system state.\n */\nTask.prototype.debug = function(msg) {\n msg = msg || '';\n forge.log.debug(cat, msg,\n '[%s][%s] task:', this.id, this.name, this,\n 'subtasks:', this.subtasks.length,\n 'queue:', sTaskQueues);\n};\n\n/**\n * Adds a subtask to run after task.doNext() or task.fail() is called.\n *\n * @param name human readable name for this task (optional).\n * @param subrun a function to run that takes the current task as\n * its first parameter.\n *\n * @return the current task (useful for chaining next() calls).\n */\nTask.prototype.next = function(name, subrun) {\n // juggle parameters if it looks like no name is given\n if(typeof(name) === 'function') {\n subrun = name;\n\n // inherit parent's name\n name = this.name;\n }\n // create subtask, set parent to this task, propagate callbacks\n var subtask = new Task({\n run: subrun,\n name: name,\n parent: this\n });\n // start subtasks running\n subtask.state = RUNNING;\n subtask.type = this.type;\n subtask.successCallback = this.successCallback || null;\n subtask.failureCallback = this.failureCallback || null;\n\n // queue a new subtask\n this.subtasks.push(subtask);\n\n return this;\n};\n\n/**\n * Adds subtasks to run in parallel after task.doNext() or task.fail()\n * is called.\n *\n * @param name human readable name for this task (optional).\n * @param subrun functions to run that take the current task as\n * their first parameter.\n *\n * @return the current task (useful for chaining next() calls).\n */\nTask.prototype.parallel = function(name, subrun) {\n // juggle parameters if it looks like no name is given\n if(forge.util.isArray(name)) {\n subrun = name;\n\n // inherit parent's name\n name = this.name;\n }\n // Wrap parallel tasks in a regular task so they are started at the\n // proper time.\n return this.next(name, function(task) {\n // block waiting for subtasks\n var ptask = task;\n ptask.block(subrun.length);\n\n // we pass the iterator from the loop below as a parameter\n // to a function because it is otherwise included in the\n // closure and changes as the loop changes -- causing i\n // to always be set to its highest value\n var startParallelTask = function(pname, pi) {\n forge.task.start({\n type: pname,\n run: function(task) {\n subrun[pi](task);\n },\n success: function(task) {\n ptask.unblock();\n },\n failure: function(task) {\n ptask.unblock();\n }\n });\n };\n\n for(var i = 0; i < subrun.length; i++) {\n // Type must be unique so task starts in parallel:\n // name + private string + task id + sub-task index\n // start tasks in parallel and unblock when the finish\n var pname = name + '__parallel-' + task.id + '-' + i;\n var pi = i;\n startParallelTask(pname, pi);\n }\n });\n};\n\n/**\n * Stops a running task.\n */\nTask.prototype.stop = function() {\n this.state = sStateTable[this.state][STOP];\n};\n\n/**\n * Starts running a task.\n */\nTask.prototype.start = function() {\n this.error = false;\n this.state = sStateTable[this.state][START];\n\n // try to restart\n if(this.state === RUNNING) {\n this.start = new Date();\n this.run(this);\n runNext(this, 0);\n }\n};\n\n/**\n * Blocks a task until it one or more permits have been released. The\n * task will not resume until the requested number of permits have\n * been released with call(s) to unblock().\n *\n * @param n number of permits to wait for(default: 1).\n */\nTask.prototype.block = function(n) {\n n = typeof(n) === 'undefined' ? 1 : n;\n this.blocks += n;\n if(this.blocks > 0) {\n this.state = sStateTable[this.state][BLOCK];\n }\n};\n\n/**\n * Releases a permit to unblock a task. If a task was blocked by\n * requesting N permits via block(), then it will only continue\n * running once enough permits have been released via unblock() calls.\n *\n * If multiple processes need to synchronize with a single task then\n * use a condition variable (see forge.task.createCondition). It is\n * an error to unblock a task more times than it has been blocked.\n *\n * @param n number of permits to release (default: 1).\n *\n * @return the current block count (task is unblocked when count is 0)\n */\nTask.prototype.unblock = function(n) {\n n = typeof(n) === 'undefined' ? 1 : n;\n this.blocks -= n;\n if(this.blocks === 0 && this.state !== DONE) {\n this.state = RUNNING;\n runNext(this, 0);\n }\n return this.blocks;\n};\n\n/**\n * Sleep for a period of time before resuming tasks.\n *\n * @param n number of milliseconds to sleep (default: 0).\n */\nTask.prototype.sleep = function(n) {\n n = typeof(n) === 'undefined' ? 0 : n;\n this.state = sStateTable[this.state][SLEEP];\n var self = this;\n this.timeoutId = setTimeout(function() {\n self.timeoutId = null;\n self.state = RUNNING;\n runNext(self, 0);\n }, n);\n};\n\n/**\n * Waits on a condition variable until notified. The next task will\n * not be scheduled until notification. A condition variable can be\n * created with forge.task.createCondition().\n *\n * Once cond.notify() is called, the task will continue.\n *\n * @param cond the condition variable to wait on.\n */\nTask.prototype.wait = function(cond) {\n cond.wait(this);\n};\n\n/**\n * If sleeping, wakeup and continue running tasks.\n */\nTask.prototype.wakeup = function() {\n if(this.state === SLEEPING) {\n cancelTimeout(this.timeoutId);\n this.timeoutId = null;\n this.state = RUNNING;\n runNext(this, 0);\n }\n};\n\n/**\n * Cancel all remaining subtasks of this task.\n */\nTask.prototype.cancel = function() {\n this.state = sStateTable[this.state][CANCEL];\n // remove permits needed\n this.permitsNeeded = 0;\n // cancel timeouts\n if(this.timeoutId !== null) {\n cancelTimeout(this.timeoutId);\n this.timeoutId = null;\n }\n // remove subtasks\n this.subtasks = [];\n};\n\n/**\n * Finishes this task with failure and sets error flag. The entire\n * task will be aborted unless the next task that should execute\n * is passed as a parameter. This allows levels of subtasks to be\n * skipped. For instance, to abort only this tasks's subtasks, then\n * call fail(task.parent). To abort this task's subtasks and its\n * parent's subtasks, call fail(task.parent.parent). To abort\n * all tasks and simply call the task callback, call fail() or\n * fail(null).\n *\n * The task callback (success or failure) will always, eventually, be\n * called.\n *\n * @param next the task to continue at, or null to abort entirely.\n */\nTask.prototype.fail = function(next) {\n // set error flag\n this.error = true;\n\n // finish task\n finish(this, true);\n\n if(next) {\n // propagate task info\n next.error = this.error;\n next.swapTime = this.swapTime;\n next.userData = this.userData;\n\n // do next task as specified\n runNext(next, 0);\n } else {\n if(this.parent !== null) {\n // finish root task (ensures it is removed from task queue)\n var parent = this.parent;\n while(parent.parent !== null) {\n // propagate task info\n parent.error = this.error;\n parent.swapTime = this.swapTime;\n parent.userData = this.userData;\n parent = parent.parent;\n }\n finish(parent, true);\n }\n\n // call failure callback if one exists\n if(this.failureCallback) {\n this.failureCallback(this);\n }\n }\n};\n\n/**\n * Asynchronously start a task.\n *\n * @param task the task to start.\n */\nvar start = function(task) {\n task.error = false;\n task.state = sStateTable[task.state][START];\n setTimeout(function() {\n if(task.state === RUNNING) {\n task.swapTime = +new Date();\n task.run(task);\n runNext(task, 0);\n }\n }, 0);\n};\n\n/**\n * Run the next subtask or finish this task.\n *\n * @param task the task to process.\n * @param recurse the recursion count.\n */\nvar runNext = function(task, recurse) {\n // get time since last context swap (ms), if enough time has passed set\n // swap to true to indicate that doNext was performed asynchronously\n // also, if recurse is too high do asynchronously\n var swap =\n (recurse > sMaxRecursions) ||\n (+new Date() - task.swapTime) > sTimeSlice;\n\n var doNext = function(recurse) {\n recurse++;\n if(task.state === RUNNING) {\n if(swap) {\n // update swap time\n task.swapTime = +new Date();\n }\n\n if(task.subtasks.length > 0) {\n // run next subtask\n var subtask = task.subtasks.shift();\n subtask.error = task.error;\n subtask.swapTime = task.swapTime;\n subtask.userData = task.userData;\n subtask.run(subtask);\n if(!subtask.error) {\n runNext(subtask, recurse);\n }\n } else {\n finish(task);\n\n if(!task.error) {\n // chain back up and run parent\n if(task.parent !== null) {\n // propagate task info\n task.parent.error = task.error;\n task.parent.swapTime = task.swapTime;\n task.parent.userData = task.userData;\n\n // no subtasks left, call run next subtask on parent\n runNext(task.parent, recurse);\n }\n }\n }\n }\n };\n\n if(swap) {\n // we're swapping, so run asynchronously\n setTimeout(doNext, 0);\n } else {\n // not swapping, so run synchronously\n doNext(recurse);\n }\n};\n\n/**\n * Finishes a task and looks for the next task in the queue to start.\n *\n * @param task the task to finish.\n * @param suppressCallbacks true to suppress callbacks.\n */\nvar finish = function(task, suppressCallbacks) {\n // subtask is now done\n task.state = DONE;\n\n delete sTasks[task.id];\n if(sVL >= 1) {\n forge.log.verbose(cat, '[%s][%s] finish',\n task.id, task.name, task);\n }\n\n // only do queue processing for root tasks\n if(task.parent === null) {\n // report error if queue is missing\n if(!(task.type in sTaskQueues)) {\n forge.log.error(cat,\n '[%s][%s] task queue missing [%s]',\n task.id, task.name, task.type);\n } else if(sTaskQueues[task.type].length === 0) {\n // report error if queue is empty\n forge.log.error(cat,\n '[%s][%s] task queue empty [%s]',\n task.id, task.name, task.type);\n } else if(sTaskQueues[task.type][0] !== task) {\n // report error if this task isn't the first in the queue\n forge.log.error(cat,\n '[%s][%s] task not first in queue [%s]',\n task.id, task.name, task.type);\n } else {\n // remove ourselves from the queue\n sTaskQueues[task.type].shift();\n // clean up queue if it is empty\n if(sTaskQueues[task.type].length === 0) {\n if(sVL >= 1) {\n forge.log.verbose(cat, '[%s][%s] delete queue [%s]',\n task.id, task.name, task.type);\n }\n /* Note: Only a task can delete a queue of its own type. This\n is used as a way to synchronize tasks. If a queue for a certain\n task type exists, then a task of that type is running.\n */\n delete sTaskQueues[task.type];\n } else {\n // dequeue the next task and start it\n if(sVL >= 1) {\n forge.log.verbose(cat,\n '[%s][%s] queue start next [%s] remain:%s',\n task.id, task.name, task.type,\n sTaskQueues[task.type].length);\n }\n sTaskQueues[task.type][0].start();\n }\n }\n\n if(!suppressCallbacks) {\n // call final callback if one exists\n if(task.error && task.failureCallback) {\n task.failureCallback(task);\n } else if(!task.error && task.successCallback) {\n task.successCallback(task);\n }\n }\n }\n};\n\n/* Tasks API */\nmodule.exports = forge.task = forge.task || {};\n\n/**\n * Starts a new task that will run the passed function asynchronously.\n *\n * In order to finish the task, either task.doNext() or task.fail()\n * *must* be called.\n *\n * The task must have a type (a string identifier) that can be used to\n * synchronize it with other tasks of the same type. That type can also\n * be used to cancel tasks that haven't started yet.\n *\n * To start a task, the following object must be provided as a parameter\n * (each function takes a task object as its first parameter):\n *\n * {\n * type: the type of task.\n * run: the function to run to execute the task.\n * success: a callback to call when the task succeeds (optional).\n * failure: a callback to call when the task fails (optional).\n * }\n *\n * @param options the object as described above.\n */\nforge.task.start = function(options) {\n // create a new task\n var task = new Task({\n run: options.run,\n name: options.name || sNoTaskName\n });\n task.type = options.type;\n task.successCallback = options.success || null;\n task.failureCallback = options.failure || null;\n\n // append the task onto the appropriate queue\n if(!(task.type in sTaskQueues)) {\n if(sVL >= 1) {\n forge.log.verbose(cat, '[%s][%s] create queue [%s]',\n task.id, task.name, task.type);\n }\n // create the queue with the new task\n sTaskQueues[task.type] = [task];\n start(task);\n } else {\n // push the task onto the queue, it will be run after a task\n // with the same type completes\n sTaskQueues[options.type].push(task);\n }\n};\n\n/**\n * Cancels all tasks of the given type that haven't started yet.\n *\n * @param type the type of task to cancel.\n */\nforge.task.cancel = function(type) {\n // find the task queue\n if(type in sTaskQueues) {\n // empty all but the current task from the queue\n sTaskQueues[type] = [sTaskQueues[type][0]];\n }\n};\n\n/**\n * Creates a condition variable to synchronize tasks. To make a task wait\n * on the condition variable, call task.wait(condition). To notify all\n * tasks that are waiting, call condition.notify().\n *\n * @return the condition variable.\n */\nforge.task.createCondition = function() {\n var cond = {\n // all tasks that are blocked\n tasks: {}\n };\n\n /**\n * Causes the given task to block until notify is called. If the task\n * is already waiting on this condition then this is a no-op.\n *\n * @param task the task to cause to wait.\n */\n cond.wait = function(task) {\n // only block once\n if(!(task.id in cond.tasks)) {\n task.block();\n cond.tasks[task.id] = task;\n }\n };\n\n /**\n * Notifies all waiting tasks to wake up.\n */\n cond.notify = function() {\n // since unblock() will run the next task from here, make sure to\n // clear the condition's blocked task list before unblocking\n var tmp = cond.tasks;\n cond.tasks = {};\n for(var id in tmp) {\n tmp[id].unblock();\n }\n };\n\n return cond;\n};\n","/**\n * A Javascript implementation of Transport Layer Security (TLS).\n *\n * @author Dave Longley\n *\n * Copyright (c) 2009-2014 Digital Bazaar, Inc.\n *\n * The TLS Handshake Protocol involves the following steps:\n *\n * - Exchange hello messages to agree on algorithms, exchange random values,\n * and check for session resumption.\n *\n * - Exchange the necessary cryptographic parameters to allow the client and\n * server to agree on a premaster secret.\n *\n * - Exchange certificates and cryptographic information to allow the client\n * and server to authenticate themselves.\n *\n * - Generate a master secret from the premaster secret and exchanged random\n * values.\n *\n * - Provide security parameters to the record layer.\n *\n * - Allow the client and server to verify that their peer has calculated the\n * same security parameters and that the handshake occurred without tampering\n * by an attacker.\n *\n * Up to 4 different messages may be sent during a key exchange. The server\n * certificate, the server key exchange, the client certificate, and the\n * client key exchange.\n *\n * A typical handshake (from the client's perspective).\n *\n * 1. Client sends ClientHello.\n * 2. Client receives ServerHello.\n * 3. Client receives optional Certificate.\n * 4. Client receives optional ServerKeyExchange.\n * 5. Client receives ServerHelloDone.\n * 6. Client sends optional Certificate.\n * 7. Client sends ClientKeyExchange.\n * 8. Client sends optional CertificateVerify.\n * 9. Client sends ChangeCipherSpec.\n * 10. Client sends Finished.\n * 11. Client receives ChangeCipherSpec.\n * 12. Client receives Finished.\n * 13. Client sends/receives application data.\n *\n * To reuse an existing session:\n *\n * 1. Client sends ClientHello with session ID for reuse.\n * 2. Client receives ServerHello with same session ID if reusing.\n * 3. Client receives ChangeCipherSpec message if reusing.\n * 4. Client receives Finished.\n * 5. Client sends ChangeCipherSpec.\n * 6. Client sends Finished.\n *\n * Note: Client ignores HelloRequest if in the middle of a handshake.\n *\n * Record Layer:\n *\n * The record layer fragments information blocks into TLSPlaintext records\n * carrying data in chunks of 2^14 bytes or less. Client message boundaries are\n * not preserved in the record layer (i.e., multiple client messages of the\n * same ContentType MAY be coalesced into a single TLSPlaintext record, or a\n * single message MAY be fragmented across several records).\n *\n * struct {\n * uint8 major;\n * uint8 minor;\n * } ProtocolVersion;\n *\n * struct {\n * ContentType type;\n * ProtocolVersion version;\n * uint16 length;\n * opaque fragment[TLSPlaintext.length];\n * } TLSPlaintext;\n *\n * type:\n * The higher-level protocol used to process the enclosed fragment.\n *\n * version:\n * The version of the protocol being employed. TLS Version 1.2 uses version\n * {3, 3}. TLS Version 1.0 uses version {3, 1}. Note that a client that\n * supports multiple versions of TLS may not know what version will be\n * employed before it receives the ServerHello.\n *\n * length:\n * The length (in bytes) of the following TLSPlaintext.fragment. The length\n * MUST NOT exceed 2^14 = 16384 bytes.\n *\n * fragment:\n * The application data. This data is transparent and treated as an\n * independent block to be dealt with by the higher-level protocol specified\n * by the type field.\n *\n * Implementations MUST NOT send zero-length fragments of Handshake, Alert, or\n * ChangeCipherSpec content types. Zero-length fragments of Application data\n * MAY be sent as they are potentially useful as a traffic analysis\n * countermeasure.\n *\n * Note: Data of different TLS record layer content types MAY be interleaved.\n * Application data is generally of lower precedence for transmission than\n * other content types. However, records MUST be delivered to the network in\n * the same order as they are protected by the record layer. Recipients MUST\n * receive and process interleaved application layer traffic during handshakes\n * subsequent to the first one on a connection.\n *\n * struct {\n * ContentType type; // same as TLSPlaintext.type\n * ProtocolVersion version;// same as TLSPlaintext.version\n * uint16 length;\n * opaque fragment[TLSCompressed.length];\n * } TLSCompressed;\n *\n * length:\n * The length (in bytes) of the following TLSCompressed.fragment.\n * The length MUST NOT exceed 2^14 + 1024.\n *\n * fragment:\n * The compressed form of TLSPlaintext.fragment.\n *\n * Note: A CompressionMethod.null operation is an identity operation; no fields\n * are altered. In this implementation, since no compression is supported,\n * uncompressed records are always the same as compressed records.\n *\n * Encryption Information:\n *\n * The encryption and MAC functions translate a TLSCompressed structure into a\n * TLSCiphertext. The decryption functions reverse the process. The MAC of the\n * record also includes a sequence number so that missing, extra, or repeated\n * messages are detectable.\n *\n * struct {\n * ContentType type;\n * ProtocolVersion version;\n * uint16 length;\n * select (SecurityParameters.cipher_type) {\n * case stream: GenericStreamCipher;\n * case block: GenericBlockCipher;\n * case aead: GenericAEADCipher;\n * } fragment;\n * } TLSCiphertext;\n *\n * type:\n * The type field is identical to TLSCompressed.type.\n *\n * version:\n * The version field is identical to TLSCompressed.version.\n *\n * length:\n * The length (in bytes) of the following TLSCiphertext.fragment.\n * The length MUST NOT exceed 2^14 + 2048.\n *\n * fragment:\n * The encrypted form of TLSCompressed.fragment, with the MAC.\n *\n * Note: Only CBC Block Ciphers are supported by this implementation.\n *\n * The TLSCompressed.fragment structures are converted to/from block\n * TLSCiphertext.fragment structures.\n *\n * struct {\n * opaque IV[SecurityParameters.record_iv_length];\n * block-ciphered struct {\n * opaque content[TLSCompressed.length];\n * opaque MAC[SecurityParameters.mac_length];\n * uint8 padding[GenericBlockCipher.padding_length];\n * uint8 padding_length;\n * };\n * } GenericBlockCipher;\n *\n * The MAC is generated as described in Section 6.2.3.1.\n *\n * IV:\n * The Initialization Vector (IV) SHOULD be chosen at random, and MUST be\n * unpredictable. Note that in versions of TLS prior to 1.1, there was no\n * IV field, and the last ciphertext block of the previous record (the \"CBC\n * residue\") was used as the IV. This was changed to prevent the attacks\n * described in [CBCATT]. For block ciphers, the IV length is of length\n * SecurityParameters.record_iv_length, which is equal to the\n * SecurityParameters.block_size.\n *\n * padding:\n * Padding that is added to force the length of the plaintext to be an\n * integral multiple of the block cipher's block length. The padding MAY be\n * any length up to 255 bytes, as long as it results in the\n * TLSCiphertext.length being an integral multiple of the block length.\n * Lengths longer than necessary might be desirable to frustrate attacks on\n * a protocol that are based on analysis of the lengths of exchanged\n * messages. Each uint8 in the padding data vector MUST be filled with the\n * padding length value. The receiver MUST check this padding and MUST use\n * the bad_record_mac alert to indicate padding errors.\n *\n * padding_length:\n * The padding length MUST be such that the total size of the\n * GenericBlockCipher structure is a multiple of the cipher's block length.\n * Legal values range from zero to 255, inclusive. This length specifies the\n * length of the padding field exclusive of the padding_length field itself.\n *\n * The encrypted data length (TLSCiphertext.length) is one more than the sum of\n * SecurityParameters.block_length, TLSCompressed.length,\n * SecurityParameters.mac_length, and padding_length.\n *\n * Example: If the block length is 8 bytes, the content length\n * (TLSCompressed.length) is 61 bytes, and the MAC length is 20 bytes, then the\n * length before padding is 82 bytes (this does not include the IV. Thus, the\n * padding length modulo 8 must be equal to 6 in order to make the total length\n * an even multiple of 8 bytes (the block length). The padding length can be\n * 6, 14, 22, and so on, through 254. If the padding length were the minimum\n * necessary, 6, the padding would be 6 bytes, each containing the value 6.\n * Thus, the last 8 octets of the GenericBlockCipher before block encryption\n * would be xx 06 06 06 06 06 06 06, where xx is the last octet of the MAC.\n *\n * Note: With block ciphers in CBC mode (Cipher Block Chaining), it is critical\n * that the entire plaintext of the record be known before any ciphertext is\n * transmitted. Otherwise, it is possible for the attacker to mount the attack\n * described in [CBCATT].\n *\n * Implementation note: Canvel et al. [CBCTIME] have demonstrated a timing\n * attack on CBC padding based on the time required to compute the MAC. In\n * order to defend against this attack, implementations MUST ensure that\n * record processing time is essentially the same whether or not the padding\n * is correct. In general, the best way to do this is to compute the MAC even\n * if the padding is incorrect, and only then reject the packet. For instance,\n * if the pad appears to be incorrect, the implementation might assume a\n * zero-length pad and then compute the MAC. This leaves a small timing\n * channel, since MAC performance depends, to some extent, on the size of the\n * data fragment, but it is not believed to be large enough to be exploitable,\n * due to the large block size of existing MACs and the small size of the\n * timing signal.\n */\nvar forge = require('./forge');\nrequire('./asn1');\nrequire('./hmac');\nrequire('./md5');\nrequire('./pem');\nrequire('./pki');\nrequire('./random');\nrequire('./sha1');\nrequire('./util');\n\n/**\n * Generates pseudo random bytes by mixing the result of two hash functions,\n * MD5 and SHA-1.\n *\n * prf_TLS1(secret, label, seed) =\n * P_MD5(S1, label + seed) XOR P_SHA-1(S2, label + seed);\n *\n * Each P_hash function functions as follows:\n *\n * P_hash(secret, seed) = HMAC_hash(secret, A(1) + seed) +\n * HMAC_hash(secret, A(2) + seed) +\n * HMAC_hash(secret, A(3) + seed) + ...\n * A() is defined as:\n * A(0) = seed\n * A(i) = HMAC_hash(secret, A(i-1))\n *\n * The '+' operator denotes concatenation.\n *\n * As many iterations A(N) as are needed are performed to generate enough\n * pseudo random byte output. If an iteration creates more data than is\n * necessary, then it is truncated.\n *\n * Therefore:\n * A(1) = HMAC_hash(secret, A(0))\n * = HMAC_hash(secret, seed)\n * A(2) = HMAC_hash(secret, A(1))\n * = HMAC_hash(secret, HMAC_hash(secret, seed))\n *\n * Therefore:\n * P_hash(secret, seed) =\n * HMAC_hash(secret, HMAC_hash(secret, A(0)) + seed) +\n * HMAC_hash(secret, HMAC_hash(secret, A(1)) + seed) +\n * ...\n *\n * Therefore:\n * P_hash(secret, seed) =\n * HMAC_hash(secret, HMAC_hash(secret, seed) + seed) +\n * HMAC_hash(secret, HMAC_hash(secret, HMAC_hash(secret, seed)) + seed) +\n * ...\n *\n * @param secret the secret to use.\n * @param label the label to use.\n * @param seed the seed value to use.\n * @param length the number of bytes to generate.\n *\n * @return the pseudo random bytes in a byte buffer.\n */\nvar prf_TLS1 = function(secret, label, seed, length) {\n var rval = forge.util.createBuffer();\n\n /* For TLS 1.0, the secret is split in half, into two secrets of equal\n length. If the secret has an odd length then the last byte of the first\n half will be the same as the first byte of the second. The length of the\n two secrets is half of the secret rounded up. */\n var idx = (secret.length >> 1);\n var slen = idx + (secret.length & 1);\n var s1 = secret.substr(0, slen);\n var s2 = secret.substr(idx, slen);\n var ai = forge.util.createBuffer();\n var hmac = forge.hmac.create();\n seed = label + seed;\n\n // determine the number of iterations that must be performed to generate\n // enough output bytes, md5 creates 16 byte hashes, sha1 creates 20\n var md5itr = Math.ceil(length / 16);\n var sha1itr = Math.ceil(length / 20);\n\n // do md5 iterations\n hmac.start('MD5', s1);\n var md5bytes = forge.util.createBuffer();\n ai.putBytes(seed);\n for(var i = 0; i < md5itr; ++i) {\n // HMAC_hash(secret, A(i-1))\n hmac.start(null, null);\n hmac.update(ai.getBytes());\n ai.putBuffer(hmac.digest());\n\n // HMAC_hash(secret, A(i) + seed)\n hmac.start(null, null);\n hmac.update(ai.bytes() + seed);\n md5bytes.putBuffer(hmac.digest());\n }\n\n // do sha1 iterations\n hmac.start('SHA1', s2);\n var sha1bytes = forge.util.createBuffer();\n ai.clear();\n ai.putBytes(seed);\n for(var i = 0; i < sha1itr; ++i) {\n // HMAC_hash(secret, A(i-1))\n hmac.start(null, null);\n hmac.update(ai.getBytes());\n ai.putBuffer(hmac.digest());\n\n // HMAC_hash(secret, A(i) + seed)\n hmac.start(null, null);\n hmac.update(ai.bytes() + seed);\n sha1bytes.putBuffer(hmac.digest());\n }\n\n // XOR the md5 bytes with the sha1 bytes\n rval.putBytes(forge.util.xorBytes(\n md5bytes.getBytes(), sha1bytes.getBytes(), length));\n\n return rval;\n};\n\n/**\n * Generates pseudo random bytes using a SHA256 algorithm. For TLS 1.2.\n *\n * @param secret the secret to use.\n * @param label the label to use.\n * @param seed the seed value to use.\n * @param length the number of bytes to generate.\n *\n * @return the pseudo random bytes in a byte buffer.\n */\nvar prf_sha256 = function(secret, label, seed, length) {\n // FIXME: implement me for TLS 1.2\n};\n\n/**\n * Gets a MAC for a record using the SHA-1 hash algorithm.\n *\n * @param key the mac key.\n * @param state the sequence number (array of two 32-bit integers).\n * @param record the record.\n *\n * @return the sha-1 hash (20 bytes) for the given record.\n */\nvar hmac_sha1 = function(key, seqNum, record) {\n /* MAC is computed like so:\n HMAC_hash(\n key, seqNum +\n TLSCompressed.type +\n TLSCompressed.version +\n TLSCompressed.length +\n TLSCompressed.fragment)\n */\n var hmac = forge.hmac.create();\n hmac.start('SHA1', key);\n var b = forge.util.createBuffer();\n b.putInt32(seqNum[0]);\n b.putInt32(seqNum[1]);\n b.putByte(record.type);\n b.putByte(record.version.major);\n b.putByte(record.version.minor);\n b.putInt16(record.length);\n b.putBytes(record.fragment.bytes());\n hmac.update(b.getBytes());\n return hmac.digest().getBytes();\n};\n\n/**\n * Compresses the TLSPlaintext record into a TLSCompressed record using the\n * deflate algorithm.\n *\n * @param c the TLS connection.\n * @param record the TLSPlaintext record to compress.\n * @param s the ConnectionState to use.\n *\n * @return true on success, false on failure.\n */\nvar deflate = function(c, record, s) {\n var rval = false;\n\n try {\n var bytes = c.deflate(record.fragment.getBytes());\n record.fragment = forge.util.createBuffer(bytes);\n record.length = bytes.length;\n rval = true;\n } catch(ex) {\n // deflate error, fail out\n }\n\n return rval;\n};\n\n/**\n * Decompresses the TLSCompressed record into a TLSPlaintext record using the\n * deflate algorithm.\n *\n * @param c the TLS connection.\n * @param record the TLSCompressed record to decompress.\n * @param s the ConnectionState to use.\n *\n * @return true on success, false on failure.\n */\nvar inflate = function(c, record, s) {\n var rval = false;\n\n try {\n var bytes = c.inflate(record.fragment.getBytes());\n record.fragment = forge.util.createBuffer(bytes);\n record.length = bytes.length;\n rval = true;\n } catch(ex) {\n // inflate error, fail out\n }\n\n return rval;\n};\n\n/**\n * Reads a TLS variable-length vector from a byte buffer.\n *\n * Variable-length vectors are defined by specifying a subrange of legal\n * lengths, inclusively, using the notation . When these are\n * encoded, the actual length precedes the vector's contents in the byte\n * stream. The length will be in the form of a number consuming as many bytes\n * as required to hold the vector's specified maximum (ceiling) length. A\n * variable-length vector with an actual length field of zero is referred to\n * as an empty vector.\n *\n * @param b the byte buffer.\n * @param lenBytes the number of bytes required to store the length.\n *\n * @return the resulting byte buffer.\n */\nvar readVector = function(b, lenBytes) {\n var len = 0;\n switch(lenBytes) {\n case 1:\n len = b.getByte();\n break;\n case 2:\n len = b.getInt16();\n break;\n case 3:\n len = b.getInt24();\n break;\n case 4:\n len = b.getInt32();\n break;\n }\n\n // read vector bytes into a new buffer\n return forge.util.createBuffer(b.getBytes(len));\n};\n\n/**\n * Writes a TLS variable-length vector to a byte buffer.\n *\n * @param b the byte buffer.\n * @param lenBytes the number of bytes required to store the length.\n * @param v the byte buffer vector.\n */\nvar writeVector = function(b, lenBytes, v) {\n // encode length at the start of the vector, where the number of bytes for\n // the length is the maximum number of bytes it would take to encode the\n // vector's ceiling\n b.putInt(v.length(), lenBytes << 3);\n b.putBuffer(v);\n};\n\n/**\n * The tls implementation.\n */\nvar tls = {};\n\n/**\n * Version: TLS 1.2 = 3.3, TLS 1.1 = 3.2, TLS 1.0 = 3.1. Both TLS 1.1 and\n * TLS 1.2 were still too new (ie: openSSL didn't implement them) at the time\n * of this implementation so TLS 1.0 was implemented instead.\n */\ntls.Versions = {\n TLS_1_0: {major: 3, minor: 1},\n TLS_1_1: {major: 3, minor: 2},\n TLS_1_2: {major: 3, minor: 3}\n};\ntls.SupportedVersions = [\n tls.Versions.TLS_1_1,\n tls.Versions.TLS_1_0\n];\ntls.Version = tls.SupportedVersions[0];\n\n/**\n * Maximum fragment size. True maximum is 16384, but we fragment before that\n * to allow for unusual small increases during compression.\n */\ntls.MaxFragment = 16384 - 1024;\n\n/**\n * Whether this entity is considered the \"client\" or \"server\".\n * enum { server, client } ConnectionEnd;\n */\ntls.ConnectionEnd = {\n server: 0,\n client: 1\n};\n\n/**\n * Pseudo-random function algorithm used to generate keys from the master\n * secret.\n * enum { tls_prf_sha256 } PRFAlgorithm;\n */\ntls.PRFAlgorithm = {\n tls_prf_sha256: 0\n};\n\n/**\n * Bulk encryption algorithms.\n * enum { null, rc4, des3, aes } BulkCipherAlgorithm;\n */\ntls.BulkCipherAlgorithm = {\n none: null,\n rc4: 0,\n des3: 1,\n aes: 2\n};\n\n/**\n * Cipher types.\n * enum { stream, block, aead } CipherType;\n */\ntls.CipherType = {\n stream: 0,\n block: 1,\n aead: 2\n};\n\n/**\n * MAC (Message Authentication Code) algorithms.\n * enum { null, hmac_md5, hmac_sha1, hmac_sha256,\n * hmac_sha384, hmac_sha512} MACAlgorithm;\n */\ntls.MACAlgorithm = {\n none: null,\n hmac_md5: 0,\n hmac_sha1: 1,\n hmac_sha256: 2,\n hmac_sha384: 3,\n hmac_sha512: 4\n};\n\n/**\n * Compression algorithms.\n * enum { null(0), deflate(1), (255) } CompressionMethod;\n */\ntls.CompressionMethod = {\n none: 0,\n deflate: 1\n};\n\n/**\n * TLS record content types.\n * enum {\n * change_cipher_spec(20), alert(21), handshake(22),\n * application_data(23), (255)\n * } ContentType;\n */\ntls.ContentType = {\n change_cipher_spec: 20,\n alert: 21,\n handshake: 22,\n application_data: 23,\n heartbeat: 24\n};\n\n/**\n * TLS handshake types.\n * enum {\n * hello_request(0), client_hello(1), server_hello(2),\n * certificate(11), server_key_exchange (12),\n * certificate_request(13), server_hello_done(14),\n * certificate_verify(15), client_key_exchange(16),\n * finished(20), (255)\n * } HandshakeType;\n */\ntls.HandshakeType = {\n hello_request: 0,\n client_hello: 1,\n server_hello: 2,\n certificate: 11,\n server_key_exchange: 12,\n certificate_request: 13,\n server_hello_done: 14,\n certificate_verify: 15,\n client_key_exchange: 16,\n finished: 20\n};\n\n/**\n * TLS Alert Protocol.\n *\n * enum { warning(1), fatal(2), (255) } AlertLevel;\n *\n * enum {\n * close_notify(0),\n * unexpected_message(10),\n * bad_record_mac(20),\n * decryption_failed(21),\n * record_overflow(22),\n * decompression_failure(30),\n * handshake_failure(40),\n * bad_certificate(42),\n * unsupported_certificate(43),\n * certificate_revoked(44),\n * certificate_expired(45),\n * certificate_unknown(46),\n * illegal_parameter(47),\n * unknown_ca(48),\n * access_denied(49),\n * decode_error(50),\n * decrypt_error(51),\n * export_restriction(60),\n * protocol_version(70),\n * insufficient_security(71),\n * internal_error(80),\n * user_canceled(90),\n * no_renegotiation(100),\n * (255)\n * } AlertDescription;\n *\n * struct {\n * AlertLevel level;\n * AlertDescription description;\n * } Alert;\n */\ntls.Alert = {};\ntls.Alert.Level = {\n warning: 1,\n fatal: 2\n};\ntls.Alert.Description = {\n close_notify: 0,\n unexpected_message: 10,\n bad_record_mac: 20,\n decryption_failed: 21,\n record_overflow: 22,\n decompression_failure: 30,\n handshake_failure: 40,\n bad_certificate: 42,\n unsupported_certificate: 43,\n certificate_revoked: 44,\n certificate_expired: 45,\n certificate_unknown: 46,\n illegal_parameter: 47,\n unknown_ca: 48,\n access_denied: 49,\n decode_error: 50,\n decrypt_error: 51,\n export_restriction: 60,\n protocol_version: 70,\n insufficient_security: 71,\n internal_error: 80,\n user_canceled: 90,\n no_renegotiation: 100\n};\n\n/**\n * TLS Heartbeat Message types.\n * enum {\n * heartbeat_request(1),\n * heartbeat_response(2),\n * (255)\n * } HeartbeatMessageType;\n */\ntls.HeartbeatMessageType = {\n heartbeat_request: 1,\n heartbeat_response: 2\n};\n\n/**\n * Supported cipher suites.\n */\ntls.CipherSuites = {};\n\n/**\n * Gets a supported cipher suite from its 2 byte ID.\n *\n * @param twoBytes two bytes in a string.\n *\n * @return the matching supported cipher suite or null.\n */\ntls.getCipherSuite = function(twoBytes) {\n var rval = null;\n for(var key in tls.CipherSuites) {\n var cs = tls.CipherSuites[key];\n if(cs.id[0] === twoBytes.charCodeAt(0) &&\n cs.id[1] === twoBytes.charCodeAt(1)) {\n rval = cs;\n break;\n }\n }\n return rval;\n};\n\n/**\n * Called when an unexpected record is encountered.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleUnexpected = function(c, record) {\n // if connection is client and closed, ignore unexpected messages\n var ignore = (!c.open && c.entity === tls.ConnectionEnd.client);\n if(!ignore) {\n c.error(c, {\n message: 'Unexpected message. Received TLS record out of order.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.unexpected_message\n }\n });\n }\n};\n\n/**\n * Called when a client receives a HelloRequest record.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleHelloRequest = function(c, record, length) {\n // ignore renegotiation requests from the server during a handshake, but\n // if handshaking, send a warning alert that renegotation is denied\n if(!c.handshaking && c.handshakes > 0) {\n // send alert warning\n tls.queue(c, tls.createAlert(c, {\n level: tls.Alert.Level.warning,\n description: tls.Alert.Description.no_renegotiation\n }));\n tls.flush(c);\n }\n\n // continue\n c.process();\n};\n\n/**\n * Parses a hello message from a ClientHello or ServerHello record.\n *\n * @param record the record to parse.\n *\n * @return the parsed message.\n */\ntls.parseHelloMessage = function(c, record, length) {\n var msg = null;\n\n var client = (c.entity === tls.ConnectionEnd.client);\n\n // minimum of 38 bytes in message\n if(length < 38) {\n c.error(c, {\n message: client ?\n 'Invalid ServerHello message. Message too short.' :\n 'Invalid ClientHello message. Message too short.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n } else {\n // use 'remaining' to calculate # of remaining bytes in the message\n var b = record.fragment;\n var remaining = b.length();\n msg = {\n version: {\n major: b.getByte(),\n minor: b.getByte()\n },\n random: forge.util.createBuffer(b.getBytes(32)),\n session_id: readVector(b, 1),\n extensions: []\n };\n if(client) {\n msg.cipher_suite = b.getBytes(2);\n msg.compression_method = b.getByte();\n } else {\n msg.cipher_suites = readVector(b, 2);\n msg.compression_methods = readVector(b, 1);\n }\n\n // read extensions if there are any bytes left in the message\n remaining = length - (remaining - b.length());\n if(remaining > 0) {\n // parse extensions\n var exts = readVector(b, 2);\n while(exts.length() > 0) {\n msg.extensions.push({\n type: [exts.getByte(), exts.getByte()],\n data: readVector(exts, 2)\n });\n }\n\n // TODO: make extension support modular\n if(!client) {\n for(var i = 0; i < msg.extensions.length; ++i) {\n var ext = msg.extensions[i];\n\n // support SNI extension\n if(ext.type[0] === 0x00 && ext.type[1] === 0x00) {\n // get server name list\n var snl = readVector(ext.data, 2);\n while(snl.length() > 0) {\n // read server name type\n var snType = snl.getByte();\n\n // only HostName type (0x00) is known, break out if\n // another type is detected\n if(snType !== 0x00) {\n break;\n }\n\n // add host name to server name list\n c.session.extensions.server_name.serverNameList.push(\n readVector(snl, 2).getBytes());\n }\n }\n }\n }\n }\n\n // version already set, do not allow version change\n if(c.session.version) {\n if(msg.version.major !== c.session.version.major ||\n msg.version.minor !== c.session.version.minor) {\n return c.error(c, {\n message: 'TLS version change is disallowed during renegotiation.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.protocol_version\n }\n });\n }\n }\n\n // get the chosen (ServerHello) cipher suite\n if(client) {\n // FIXME: should be checking configured acceptable cipher suites\n c.session.cipherSuite = tls.getCipherSuite(msg.cipher_suite);\n } else {\n // get a supported preferred (ClientHello) cipher suite\n // choose the first supported cipher suite\n var tmp = forge.util.createBuffer(msg.cipher_suites.bytes());\n while(tmp.length() > 0) {\n // FIXME: should be checking configured acceptable suites\n // cipher suites take up 2 bytes\n c.session.cipherSuite = tls.getCipherSuite(tmp.getBytes(2));\n if(c.session.cipherSuite !== null) {\n break;\n }\n }\n }\n\n // cipher suite not supported\n if(c.session.cipherSuite === null) {\n return c.error(c, {\n message: 'No cipher suites in common.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.handshake_failure\n },\n cipherSuite: forge.util.bytesToHex(msg.cipher_suite)\n });\n }\n\n // TODO: handle compression methods\n if(client) {\n c.session.compressionMethod = msg.compression_method;\n } else {\n // no compression\n c.session.compressionMethod = tls.CompressionMethod.none;\n }\n }\n\n return msg;\n};\n\n/**\n * Creates security parameters for the given connection based on the given\n * hello message.\n *\n * @param c the TLS connection.\n * @param msg the hello message.\n */\ntls.createSecurityParameters = function(c, msg) {\n /* Note: security params are from TLS 1.2, some values like prf_algorithm\n are ignored for TLS 1.0/1.1 and the builtin as specified in the spec is\n used. */\n\n // TODO: handle other options from server when more supported\n\n // get client and server randoms\n var client = (c.entity === tls.ConnectionEnd.client);\n var msgRandom = msg.random.bytes();\n var cRandom = client ? c.session.sp.client_random : msgRandom;\n var sRandom = client ? msgRandom : tls.createRandom().getBytes();\n\n // create new security parameters\n c.session.sp = {\n entity: c.entity,\n prf_algorithm: tls.PRFAlgorithm.tls_prf_sha256,\n bulk_cipher_algorithm: null,\n cipher_type: null,\n enc_key_length: null,\n block_length: null,\n fixed_iv_length: null,\n record_iv_length: null,\n mac_algorithm: null,\n mac_length: null,\n mac_key_length: null,\n compression_algorithm: c.session.compressionMethod,\n pre_master_secret: null,\n master_secret: null,\n client_random: cRandom,\n server_random: sRandom\n };\n};\n\n/**\n * Called when a client receives a ServerHello record.\n *\n * When a ServerHello message will be sent:\n * The server will send this message in response to a client hello message\n * when it was able to find an acceptable set of algorithms. If it cannot\n * find such a match, it will respond with a handshake failure alert.\n *\n * uint24 length;\n * struct {\n * ProtocolVersion server_version;\n * Random random;\n * SessionID session_id;\n * CipherSuite cipher_suite;\n * CompressionMethod compression_method;\n * select(extensions_present) {\n * case false:\n * struct {};\n * case true:\n * Extension extensions<0..2^16-1>;\n * };\n * } ServerHello;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleServerHello = function(c, record, length) {\n var msg = tls.parseHelloMessage(c, record, length);\n if(c.fail) {\n return;\n }\n\n // ensure server version is compatible\n if(msg.version.minor <= c.version.minor) {\n c.version.minor = msg.version.minor;\n } else {\n return c.error(c, {\n message: 'Incompatible TLS version.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.protocol_version\n }\n });\n }\n\n // indicate session version has been set\n c.session.version = c.version;\n\n // get the session ID from the message\n var sessionId = msg.session_id.bytes();\n\n // if the session ID is not blank and matches the cached one, resume\n // the session\n if(sessionId.length > 0 && sessionId === c.session.id) {\n // resuming session, expect a ChangeCipherSpec next\n c.expect = SCC;\n c.session.resuming = true;\n\n // get new server random\n c.session.sp.server_random = msg.random.bytes();\n } else {\n // not resuming, expect a server Certificate message next\n c.expect = SCE;\n c.session.resuming = false;\n\n // create new security parameters\n tls.createSecurityParameters(c, msg);\n }\n\n // set new session ID\n c.session.id = sessionId;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a server receives a ClientHello record.\n *\n * When a ClientHello message will be sent:\n * When a client first connects to a server it is required to send the\n * client hello as its first message. The client can also send a client\n * hello in response to a hello request or on its own initiative in order\n * to renegotiate the security parameters in an existing connection.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleClientHello = function(c, record, length) {\n var msg = tls.parseHelloMessage(c, record, length);\n if(c.fail) {\n return;\n }\n\n // get the session ID from the message\n var sessionId = msg.session_id.bytes();\n\n // see if the given session ID is in the cache\n var session = null;\n if(c.sessionCache) {\n session = c.sessionCache.getSession(sessionId);\n if(session === null) {\n // session ID not found\n sessionId = '';\n } else if(session.version.major !== msg.version.major ||\n session.version.minor > msg.version.minor) {\n // if session version is incompatible with client version, do not resume\n session = null;\n sessionId = '';\n }\n }\n\n // no session found to resume, generate a new session ID\n if(sessionId.length === 0) {\n sessionId = forge.random.getBytes(32);\n }\n\n // update session\n c.session.id = sessionId;\n c.session.clientHelloVersion = msg.version;\n c.session.sp = {};\n if(session) {\n // use version and security parameters from resumed session\n c.version = c.session.version = session.version;\n c.session.sp = session.sp;\n } else {\n // use highest compatible minor version\n var version;\n for(var i = 1; i < tls.SupportedVersions.length; ++i) {\n version = tls.SupportedVersions[i];\n if(version.minor <= msg.version.minor) {\n break;\n }\n }\n c.version = {major: version.major, minor: version.minor};\n c.session.version = c.version;\n }\n\n // if a session is set, resume it\n if(session !== null) {\n // resuming session, expect a ChangeCipherSpec next\n c.expect = CCC;\n c.session.resuming = true;\n\n // get new client random\n c.session.sp.client_random = msg.random.bytes();\n } else {\n // not resuming, expect a Certificate or ClientKeyExchange\n c.expect = (c.verifyClient !== false) ? CCE : CKE;\n c.session.resuming = false;\n\n // create new security parameters\n tls.createSecurityParameters(c, msg);\n }\n\n // connection now open\n c.open = true;\n\n // queue server hello\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createServerHello(c)\n }));\n\n if(c.session.resuming) {\n // queue change cipher spec message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.change_cipher_spec,\n data: tls.createChangeCipherSpec()\n }));\n\n // create pending state\n c.state.pending = tls.createConnectionState(c);\n\n // change current write state to pending write state\n c.state.current.write = c.state.pending.write;\n\n // queue finished\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createFinished(c)\n }));\n } else {\n // queue server certificate\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createCertificate(c)\n }));\n\n if(!c.fail) {\n // queue server key exchange\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createServerKeyExchange(c)\n }));\n\n // request client certificate if set\n if(c.verifyClient !== false) {\n // queue certificate request\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createCertificateRequest(c)\n }));\n }\n\n // queue server hello done\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createServerHelloDone(c)\n }));\n }\n }\n\n // send records\n tls.flush(c);\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a Certificate record.\n *\n * When this message will be sent:\n * The server must send a certificate whenever the agreed-upon key exchange\n * method is not an anonymous one. This message will always immediately\n * follow the server hello message.\n *\n * Meaning of this message:\n * The certificate type must be appropriate for the selected cipher suite's\n * key exchange algorithm, and is generally an X.509v3 certificate. It must\n * contain a key which matches the key exchange method, as follows. Unless\n * otherwise specified, the signing algorithm for the certificate must be\n * the same as the algorithm for the certificate key. Unless otherwise\n * specified, the public key may be of any length.\n *\n * opaque ASN.1Cert<1..2^24-1>;\n * struct {\n * ASN.1Cert certificate_list<1..2^24-1>;\n * } Certificate;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleCertificate = function(c, record, length) {\n // minimum of 3 bytes in message\n if(length < 3) {\n return c.error(c, {\n message: 'Invalid Certificate message. Message too short.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n }\n\n var b = record.fragment;\n var msg = {\n certificate_list: readVector(b, 3)\n };\n\n /* The sender's certificate will be first in the list (chain), each\n subsequent one that follows will certify the previous one, but root\n certificates (self-signed) that specify the certificate authority may\n be omitted under the assumption that clients must already possess it. */\n var cert, asn1;\n var certs = [];\n try {\n while(msg.certificate_list.length() > 0) {\n // each entry in msg.certificate_list is a vector with 3 len bytes\n cert = readVector(msg.certificate_list, 3);\n asn1 = forge.asn1.fromDer(cert);\n cert = forge.pki.certificateFromAsn1(asn1, true);\n certs.push(cert);\n }\n } catch(ex) {\n return c.error(c, {\n message: 'Could not parse certificate list.',\n cause: ex,\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.bad_certificate\n }\n });\n }\n\n // ensure at least 1 certificate was provided if in client-mode\n // or if verifyClient was set to true to require a certificate\n // (as opposed to 'optional')\n var client = (c.entity === tls.ConnectionEnd.client);\n if((client || c.verifyClient === true) && certs.length === 0) {\n // error, no certificate\n c.error(c, {\n message: client ?\n 'No server certificate provided.' :\n 'No client certificate provided.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n } else if(certs.length === 0) {\n // no certs to verify\n // expect a ServerKeyExchange or ClientKeyExchange message next\n c.expect = client ? SKE : CKE;\n } else {\n // save certificate in session\n if(client) {\n c.session.serverCertificate = certs[0];\n } else {\n c.session.clientCertificate = certs[0];\n }\n\n if(tls.verifyCertificateChain(c, certs)) {\n // expect a ServerKeyExchange or ClientKeyExchange message next\n c.expect = client ? SKE : CKE;\n }\n }\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a ServerKeyExchange record.\n *\n * When this message will be sent:\n * This message will be sent immediately after the server certificate\n * message (or the server hello message, if this is an anonymous\n * negotiation).\n *\n * The server key exchange message is sent by the server only when the\n * server certificate message (if sent) does not contain enough data to\n * allow the client to exchange a premaster secret.\n *\n * Meaning of this message:\n * This message conveys cryptographic information to allow the client to\n * communicate the premaster secret: either an RSA public key to encrypt\n * the premaster secret with, or a Diffie-Hellman public key with which the\n * client can complete a key exchange (with the result being the premaster\n * secret.)\n *\n * enum {\n * dhe_dss, dhe_rsa, dh_anon, rsa, dh_dss, dh_rsa\n * } KeyExchangeAlgorithm;\n *\n * struct {\n * opaque dh_p<1..2^16-1>;\n * opaque dh_g<1..2^16-1>;\n * opaque dh_Ys<1..2^16-1>;\n * } ServerDHParams;\n *\n * struct {\n * select(KeyExchangeAlgorithm) {\n * case dh_anon:\n * ServerDHParams params;\n * case dhe_dss:\n * case dhe_rsa:\n * ServerDHParams params;\n * digitally-signed struct {\n * opaque client_random[32];\n * opaque server_random[32];\n * ServerDHParams params;\n * } signed_params;\n * case rsa:\n * case dh_dss:\n * case dh_rsa:\n * struct {};\n * };\n * } ServerKeyExchange;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleServerKeyExchange = function(c, record, length) {\n // this implementation only supports RSA, no Diffie-Hellman support\n // so any length > 0 is invalid\n if(length > 0) {\n return c.error(c, {\n message: 'Invalid key parameters. Only RSA is supported.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.unsupported_certificate\n }\n });\n }\n\n // expect an optional CertificateRequest message next\n c.expect = SCR;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a ClientKeyExchange record.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleClientKeyExchange = function(c, record, length) {\n // this implementation only supports RSA, no Diffie-Hellman support\n // so any length < 48 is invalid\n if(length < 48) {\n return c.error(c, {\n message: 'Invalid key parameters. Only RSA is supported.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.unsupported_certificate\n }\n });\n }\n\n var b = record.fragment;\n var msg = {\n enc_pre_master_secret: readVector(b, 2).getBytes()\n };\n\n // do rsa decryption\n var privateKey = null;\n if(c.getPrivateKey) {\n try {\n privateKey = c.getPrivateKey(c, c.session.serverCertificate);\n privateKey = forge.pki.privateKeyFromPem(privateKey);\n } catch(ex) {\n c.error(c, {\n message: 'Could not get private key.',\n cause: ex,\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n }\n }\n\n if(privateKey === null) {\n return c.error(c, {\n message: 'No private key set.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n }\n\n try {\n // decrypt 48-byte pre-master secret\n var sp = c.session.sp;\n sp.pre_master_secret = privateKey.decrypt(msg.enc_pre_master_secret);\n\n // ensure client hello version matches first 2 bytes\n var version = c.session.clientHelloVersion;\n if(version.major !== sp.pre_master_secret.charCodeAt(0) ||\n version.minor !== sp.pre_master_secret.charCodeAt(1)) {\n // error, do not send alert (see BLEI attack below)\n throw new Error('TLS version rollback attack detected.');\n }\n } catch(ex) {\n /* Note: Daniel Bleichenbacher [BLEI] can be used to attack a\n TLS server which is using PKCS#1 encoded RSA, so instead of\n failing here, we generate 48 random bytes and use that as\n the pre-master secret. */\n sp.pre_master_secret = forge.random.getBytes(48);\n }\n\n // expect a CertificateVerify message if a Certificate was received that\n // does not have fixed Diffie-Hellman params, otherwise expect\n // ChangeCipherSpec\n c.expect = CCC;\n if(c.session.clientCertificate !== null) {\n // only RSA support, so expect CertificateVerify\n // TODO: support Diffie-Hellman\n c.expect = CCV;\n }\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a CertificateRequest record.\n *\n * When this message will be sent:\n * A non-anonymous server can optionally request a certificate from the\n * client, if appropriate for the selected cipher suite. This message, if\n * sent, will immediately follow the Server Key Exchange message (if it is\n * sent; otherwise, the Server Certificate message).\n *\n * enum {\n * rsa_sign(1), dss_sign(2), rsa_fixed_dh(3), dss_fixed_dh(4),\n * rsa_ephemeral_dh_RESERVED(5), dss_ephemeral_dh_RESERVED(6),\n * fortezza_dms_RESERVED(20), (255)\n * } ClientCertificateType;\n *\n * opaque DistinguishedName<1..2^16-1>;\n *\n * struct {\n * ClientCertificateType certificate_types<1..2^8-1>;\n * SignatureAndHashAlgorithm supported_signature_algorithms<2^16-1>;\n * DistinguishedName certificate_authorities<0..2^16-1>;\n * } CertificateRequest;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleCertificateRequest = function(c, record, length) {\n // minimum of 3 bytes in message\n if(length < 3) {\n return c.error(c, {\n message: 'Invalid CertificateRequest. Message too short.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n }\n\n // TODO: TLS 1.2+ has different format including\n // SignatureAndHashAlgorithm after cert types\n var b = record.fragment;\n var msg = {\n certificate_types: readVector(b, 1),\n certificate_authorities: readVector(b, 2)\n };\n\n // save certificate request in session\n c.session.certificateRequest = msg;\n\n // expect a ServerHelloDone message next\n c.expect = SHD;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a server receives a CertificateVerify record.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleCertificateVerify = function(c, record, length) {\n if(length < 2) {\n return c.error(c, {\n message: 'Invalid CertificateVerify. Message too short.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n }\n\n // rewind to get full bytes for message so it can be manually\n // digested below (special case for CertificateVerify messages because\n // they must be digested *after* handling as opposed to all others)\n var b = record.fragment;\n b.read -= 4;\n var msgBytes = b.bytes();\n b.read += 4;\n\n var msg = {\n signature: readVector(b, 2).getBytes()\n };\n\n // TODO: add support for DSA\n\n // generate data to verify\n var verify = forge.util.createBuffer();\n verify.putBuffer(c.session.md5.digest());\n verify.putBuffer(c.session.sha1.digest());\n verify = verify.getBytes();\n\n try {\n var cert = c.session.clientCertificate;\n /*b = forge.pki.rsa.decrypt(\n msg.signature, cert.publicKey, true, verify.length);\n if(b !== verify) {*/\n if(!cert.publicKey.verify(verify, msg.signature, 'NONE')) {\n throw new Error('CertificateVerify signature does not match.');\n }\n\n // digest message now that it has been handled\n c.session.md5.update(msgBytes);\n c.session.sha1.update(msgBytes);\n } catch(ex) {\n return c.error(c, {\n message: 'Bad signature in CertificateVerify.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.handshake_failure\n }\n });\n }\n\n // expect ChangeCipherSpec\n c.expect = CCC;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a client receives a ServerHelloDone record.\n *\n * When this message will be sent:\n * The server hello done message is sent by the server to indicate the end\n * of the server hello and associated messages. After sending this message\n * the server will wait for a client response.\n *\n * Meaning of this message:\n * This message means that the server is done sending messages to support\n * the key exchange, and the client can proceed with its phase of the key\n * exchange.\n *\n * Upon receipt of the server hello done message the client should verify\n * that the server provided a valid certificate if required and check that\n * the server hello parameters are acceptable.\n *\n * struct {} ServerHelloDone;\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleServerHelloDone = function(c, record, length) {\n // len must be 0 bytes\n if(length > 0) {\n return c.error(c, {\n message: 'Invalid ServerHelloDone message. Invalid length.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.record_overflow\n }\n });\n }\n\n if(c.serverCertificate === null) {\n // no server certificate was provided\n var error = {\n message: 'No server certificate provided. Not enough security.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.insufficient_security\n }\n };\n\n // call application callback\n var depth = 0;\n var ret = c.verify(c, error.alert.description, depth, []);\n if(ret !== true) {\n // check for custom alert info\n if(ret || ret === 0) {\n // set custom message and alert description\n if(typeof ret === 'object' && !forge.util.isArray(ret)) {\n if(ret.message) {\n error.message = ret.message;\n }\n if(ret.alert) {\n error.alert.description = ret.alert;\n }\n } else if(typeof ret === 'number') {\n // set custom alert description\n error.alert.description = ret;\n }\n }\n\n // send error\n return c.error(c, error);\n }\n }\n\n // create client certificate message if requested\n if(c.session.certificateRequest !== null) {\n record = tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createCertificate(c)\n });\n tls.queue(c, record);\n }\n\n // create client key exchange message\n record = tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createClientKeyExchange(c)\n });\n tls.queue(c, record);\n\n // expect no messages until the following callback has been called\n c.expect = SER;\n\n // create callback to handle client signature (for client-certs)\n var callback = function(c, signature) {\n if(c.session.certificateRequest !== null &&\n c.session.clientCertificate !== null) {\n // create certificate verify message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createCertificateVerify(c, signature)\n }));\n }\n\n // create change cipher spec message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.change_cipher_spec,\n data: tls.createChangeCipherSpec()\n }));\n\n // create pending state\n c.state.pending = tls.createConnectionState(c);\n\n // change current write state to pending write state\n c.state.current.write = c.state.pending.write;\n\n // create finished message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createFinished(c)\n }));\n\n // expect a server ChangeCipherSpec message next\n c.expect = SCC;\n\n // send records\n tls.flush(c);\n\n // continue\n c.process();\n };\n\n // if there is no certificate request or no client certificate, do\n // callback immediately\n if(c.session.certificateRequest === null ||\n c.session.clientCertificate === null) {\n return callback(c, null);\n }\n\n // otherwise get the client signature\n tls.getClientSignature(c, callback);\n};\n\n/**\n * Called when a ChangeCipherSpec record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleChangeCipherSpec = function(c, record) {\n if(record.fragment.getByte() !== 0x01) {\n return c.error(c, {\n message: 'Invalid ChangeCipherSpec message received.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.illegal_parameter\n }\n });\n }\n\n // create pending state if:\n // 1. Resuming session in client mode OR\n // 2. NOT resuming session in server mode\n var client = (c.entity === tls.ConnectionEnd.client);\n if((c.session.resuming && client) || (!c.session.resuming && !client)) {\n c.state.pending = tls.createConnectionState(c);\n }\n\n // change current read state to pending read state\n c.state.current.read = c.state.pending.read;\n\n // clear pending state if:\n // 1. NOT resuming session in client mode OR\n // 2. resuming a session in server mode\n if((!c.session.resuming && client) || (c.session.resuming && !client)) {\n c.state.pending = null;\n }\n\n // expect a Finished record next\n c.expect = client ? SFI : CFI;\n\n // continue\n c.process();\n};\n\n/**\n * Called when a Finished record is received.\n *\n * When this message will be sent:\n * A finished message is always sent immediately after a change\n * cipher spec message to verify that the key exchange and\n * authentication processes were successful. It is essential that a\n * change cipher spec message be received between the other\n * handshake messages and the Finished message.\n *\n * Meaning of this message:\n * The finished message is the first protected with the just-\n * negotiated algorithms, keys, and secrets. Recipients of finished\n * messages must verify that the contents are correct. Once a side\n * has sent its Finished message and received and validated the\n * Finished message from its peer, it may begin to send and receive\n * application data over the connection.\n *\n * struct {\n * opaque verify_data[verify_data_length];\n * } Finished;\n *\n * verify_data\n * PRF(master_secret, finished_label, Hash(handshake_messages))\n * [0..verify_data_length-1];\n *\n * finished_label\n * For Finished messages sent by the client, the string\n * \"client finished\". For Finished messages sent by the server, the\n * string \"server finished\".\n *\n * verify_data_length depends on the cipher suite. If it is not specified\n * by the cipher suite, then it is 12. Versions of TLS < 1.2 always used\n * 12 bytes.\n *\n * @param c the connection.\n * @param record the record.\n * @param length the length of the handshake message.\n */\ntls.handleFinished = function(c, record, length) {\n // rewind to get full bytes for message so it can be manually\n // digested below (special case for Finished messages because they\n // must be digested *after* handling as opposed to all others)\n var b = record.fragment;\n b.read -= 4;\n var msgBytes = b.bytes();\n b.read += 4;\n\n // message contains only verify_data\n var vd = record.fragment.getBytes();\n\n // ensure verify data is correct\n b = forge.util.createBuffer();\n b.putBuffer(c.session.md5.digest());\n b.putBuffer(c.session.sha1.digest());\n\n // set label based on entity type\n var client = (c.entity === tls.ConnectionEnd.client);\n var label = client ? 'server finished' : 'client finished';\n\n // TODO: determine prf function and verify length for TLS 1.2\n var sp = c.session.sp;\n var vdl = 12;\n var prf = prf_TLS1;\n b = prf(sp.master_secret, label, b.getBytes(), vdl);\n if(b.getBytes() !== vd) {\n return c.error(c, {\n message: 'Invalid verify_data in Finished message.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.decrypt_error\n }\n });\n }\n\n // digest finished message now that it has been handled\n c.session.md5.update(msgBytes);\n c.session.sha1.update(msgBytes);\n\n // resuming session as client or NOT resuming session as server\n if((c.session.resuming && client) || (!c.session.resuming && !client)) {\n // create change cipher spec message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.change_cipher_spec,\n data: tls.createChangeCipherSpec()\n }));\n\n // change current write state to pending write state, clear pending\n c.state.current.write = c.state.pending.write;\n c.state.pending = null;\n\n // create finished message\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createFinished(c)\n }));\n }\n\n // expect application data next\n c.expect = client ? SAD : CAD;\n\n // handshake complete\n c.handshaking = false;\n ++c.handshakes;\n\n // save access to peer certificate\n c.peerCertificate = client ?\n c.session.serverCertificate : c.session.clientCertificate;\n\n // send records\n tls.flush(c);\n\n // now connected\n c.isConnected = true;\n c.connected(c);\n\n // continue\n c.process();\n};\n\n/**\n * Called when an Alert record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleAlert = function(c, record) {\n // read alert\n var b = record.fragment;\n var alert = {\n level: b.getByte(),\n description: b.getByte()\n };\n\n // TODO: consider using a table?\n // get appropriate message\n var msg;\n switch(alert.description) {\n case tls.Alert.Description.close_notify:\n msg = 'Connection closed.';\n break;\n case tls.Alert.Description.unexpected_message:\n msg = 'Unexpected message.';\n break;\n case tls.Alert.Description.bad_record_mac:\n msg = 'Bad record MAC.';\n break;\n case tls.Alert.Description.decryption_failed:\n msg = 'Decryption failed.';\n break;\n case tls.Alert.Description.record_overflow:\n msg = 'Record overflow.';\n break;\n case tls.Alert.Description.decompression_failure:\n msg = 'Decompression failed.';\n break;\n case tls.Alert.Description.handshake_failure:\n msg = 'Handshake failure.';\n break;\n case tls.Alert.Description.bad_certificate:\n msg = 'Bad certificate.';\n break;\n case tls.Alert.Description.unsupported_certificate:\n msg = 'Unsupported certificate.';\n break;\n case tls.Alert.Description.certificate_revoked:\n msg = 'Certificate revoked.';\n break;\n case tls.Alert.Description.certificate_expired:\n msg = 'Certificate expired.';\n break;\n case tls.Alert.Description.certificate_unknown:\n msg = 'Certificate unknown.';\n break;\n case tls.Alert.Description.illegal_parameter:\n msg = 'Illegal parameter.';\n break;\n case tls.Alert.Description.unknown_ca:\n msg = 'Unknown certificate authority.';\n break;\n case tls.Alert.Description.access_denied:\n msg = 'Access denied.';\n break;\n case tls.Alert.Description.decode_error:\n msg = 'Decode error.';\n break;\n case tls.Alert.Description.decrypt_error:\n msg = 'Decrypt error.';\n break;\n case tls.Alert.Description.export_restriction:\n msg = 'Export restriction.';\n break;\n case tls.Alert.Description.protocol_version:\n msg = 'Unsupported protocol version.';\n break;\n case tls.Alert.Description.insufficient_security:\n msg = 'Insufficient security.';\n break;\n case tls.Alert.Description.internal_error:\n msg = 'Internal error.';\n break;\n case tls.Alert.Description.user_canceled:\n msg = 'User canceled.';\n break;\n case tls.Alert.Description.no_renegotiation:\n msg = 'Renegotiation not supported.';\n break;\n default:\n msg = 'Unknown error.';\n break;\n }\n\n // close connection on close_notify, not an error\n if(alert.description === tls.Alert.Description.close_notify) {\n return c.close();\n }\n\n // call error handler\n c.error(c, {\n message: msg,\n send: false,\n // origin is the opposite end\n origin: (c.entity === tls.ConnectionEnd.client) ? 'server' : 'client',\n alert: alert\n });\n\n // continue\n c.process();\n};\n\n/**\n * Called when a Handshake record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleHandshake = function(c, record) {\n // get the handshake type and message length\n var b = record.fragment;\n var type = b.getByte();\n var length = b.getInt24();\n\n // see if the record fragment doesn't yet contain the full message\n if(length > b.length()) {\n // cache the record, clear its fragment, and reset the buffer read\n // pointer before the type and length were read\n c.fragmented = record;\n record.fragment = forge.util.createBuffer();\n b.read -= 4;\n\n // continue\n return c.process();\n }\n\n // full message now available, clear cache, reset read pointer to\n // before type and length\n c.fragmented = null;\n b.read -= 4;\n\n // save the handshake bytes for digestion after handler is found\n // (include type and length of handshake msg)\n var bytes = b.bytes(length + 4);\n\n // restore read pointer\n b.read += 4;\n\n // handle expected message\n if(type in hsTable[c.entity][c.expect]) {\n // initialize server session\n if(c.entity === tls.ConnectionEnd.server && !c.open && !c.fail) {\n c.handshaking = true;\n c.session = {\n version: null,\n extensions: {\n server_name: {\n serverNameList: []\n }\n },\n cipherSuite: null,\n compressionMethod: null,\n serverCertificate: null,\n clientCertificate: null,\n md5: forge.md.md5.create(),\n sha1: forge.md.sha1.create()\n };\n }\n\n /* Update handshake messages digest. Finished and CertificateVerify\n messages are not digested here. They can't be digested as part of\n the verify_data that they contain. These messages are manually\n digested in their handlers. HelloRequest messages are simply never\n included in the handshake message digest according to spec. */\n if(type !== tls.HandshakeType.hello_request &&\n type !== tls.HandshakeType.certificate_verify &&\n type !== tls.HandshakeType.finished) {\n c.session.md5.update(bytes);\n c.session.sha1.update(bytes);\n }\n\n // handle specific handshake type record\n hsTable[c.entity][c.expect][type](c, record, length);\n } else {\n // unexpected record\n tls.handleUnexpected(c, record);\n }\n};\n\n/**\n * Called when an ApplicationData record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleApplicationData = function(c, record) {\n // buffer data, notify that its ready\n c.data.putBuffer(record.fragment);\n c.dataReady(c);\n\n // continue\n c.process();\n};\n\n/**\n * Called when a Heartbeat record is received.\n *\n * @param c the connection.\n * @param record the record.\n */\ntls.handleHeartbeat = function(c, record) {\n // get the heartbeat type and payload\n var b = record.fragment;\n var type = b.getByte();\n var length = b.getInt16();\n var payload = b.getBytes(length);\n\n if(type === tls.HeartbeatMessageType.heartbeat_request) {\n // discard request during handshake or if length is too large\n if(c.handshaking || length > payload.length) {\n // continue\n return c.process();\n }\n // retransmit payload\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.heartbeat,\n data: tls.createHeartbeat(\n tls.HeartbeatMessageType.heartbeat_response, payload)\n }));\n tls.flush(c);\n } else if(type === tls.HeartbeatMessageType.heartbeat_response) {\n // check payload against expected payload, discard heartbeat if no match\n if(payload !== c.expectedHeartbeatPayload) {\n // continue\n return c.process();\n }\n\n // notify that a valid heartbeat was received\n if(c.heartbeatReceived) {\n c.heartbeatReceived(c, forge.util.createBuffer(payload));\n }\n }\n\n // continue\n c.process();\n};\n\n/**\n * The transistional state tables for receiving TLS records. It maps the\n * current TLS engine state and a received record to a function to handle the\n * record and update the state.\n *\n * For instance, if the current state is SHE, then the TLS engine is expecting\n * a ServerHello record. Once a record is received, the handler function is\n * looked up using the state SHE and the record's content type.\n *\n * The resulting function will either be an error handler or a record handler.\n * The function will take whatever action is appropriate and update the state\n * for the next record.\n *\n * The states are all based on possible server record types. Note that the\n * client will never specifically expect to receive a HelloRequest or an alert\n * from the server so there is no state that reflects this. These messages may\n * occur at any time.\n *\n * There are two tables for mapping states because there is a second tier of\n * types for handshake messages. Once a record with a content type of handshake\n * is received, the handshake record handler will look up the handshake type in\n * the secondary map to get its appropriate handler.\n *\n * Valid message orders are as follows:\n *\n * =======================FULL HANDSHAKE======================\n * Client Server\n *\n * ClientHello -------->\n * ServerHello\n * Certificate*\n * ServerKeyExchange*\n * CertificateRequest*\n * <-------- ServerHelloDone\n * Certificate*\n * ClientKeyExchange\n * CertificateVerify*\n * [ChangeCipherSpec]\n * Finished -------->\n * [ChangeCipherSpec]\n * <-------- Finished\n * Application Data <-------> Application Data\n *\n * =====================SESSION RESUMPTION=====================\n * Client Server\n *\n * ClientHello -------->\n * ServerHello\n * [ChangeCipherSpec]\n * <-------- Finished\n * [ChangeCipherSpec]\n * Finished -------->\n * Application Data <-------> Application Data\n */\n// client expect states (indicate which records are expected to be received)\nvar SHE = 0; // rcv server hello\nvar SCE = 1; // rcv server certificate\nvar SKE = 2; // rcv server key exchange\nvar SCR = 3; // rcv certificate request\nvar SHD = 4; // rcv server hello done\nvar SCC = 5; // rcv change cipher spec\nvar SFI = 6; // rcv finished\nvar SAD = 7; // rcv application data\nvar SER = 8; // not expecting any messages at this point\n\n// server expect states\nvar CHE = 0; // rcv client hello\nvar CCE = 1; // rcv client certificate\nvar CKE = 2; // rcv client key exchange\nvar CCV = 3; // rcv certificate verify\nvar CCC = 4; // rcv change cipher spec\nvar CFI = 5; // rcv finished\nvar CAD = 6; // rcv application data\nvar CER = 7; // not expecting any messages at this point\n\n// map client current expect state and content type to function\nvar __ = tls.handleUnexpected;\nvar R0 = tls.handleChangeCipherSpec;\nvar R1 = tls.handleAlert;\nvar R2 = tls.handleHandshake;\nvar R3 = tls.handleApplicationData;\nvar R4 = tls.handleHeartbeat;\nvar ctTable = [];\nctTable[tls.ConnectionEnd.client] = [\n// CC,AL,HS,AD,HB\n/*SHE*/[__,R1,R2,__,R4],\n/*SCE*/[__,R1,R2,__,R4],\n/*SKE*/[__,R1,R2,__,R4],\n/*SCR*/[__,R1,R2,__,R4],\n/*SHD*/[__,R1,R2,__,R4],\n/*SCC*/[R0,R1,__,__,R4],\n/*SFI*/[__,R1,R2,__,R4],\n/*SAD*/[__,R1,R2,R3,R4],\n/*SER*/[__,R1,R2,__,R4]\n];\n\n// map server current expect state and content type to function\nctTable[tls.ConnectionEnd.server] = [\n// CC,AL,HS,AD\n/*CHE*/[__,R1,R2,__,R4],\n/*CCE*/[__,R1,R2,__,R4],\n/*CKE*/[__,R1,R2,__,R4],\n/*CCV*/[__,R1,R2,__,R4],\n/*CCC*/[R0,R1,__,__,R4],\n/*CFI*/[__,R1,R2,__,R4],\n/*CAD*/[__,R1,R2,R3,R4],\n/*CER*/[__,R1,R2,__,R4]\n];\n\n// map client current expect state and handshake type to function\nvar H0 = tls.handleHelloRequest;\nvar H1 = tls.handleServerHello;\nvar H2 = tls.handleCertificate;\nvar H3 = tls.handleServerKeyExchange;\nvar H4 = tls.handleCertificateRequest;\nvar H5 = tls.handleServerHelloDone;\nvar H6 = tls.handleFinished;\nvar hsTable = [];\nhsTable[tls.ConnectionEnd.client] = [\n// HR,01,SH,03,04,05,06,07,08,09,10,SC,SK,CR,HD,15,CK,17,18,19,FI\n/*SHE*/[__,__,H1,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*SCE*/[H0,__,__,__,__,__,__,__,__,__,__,H2,H3,H4,H5,__,__,__,__,__,__],\n/*SKE*/[H0,__,__,__,__,__,__,__,__,__,__,__,H3,H4,H5,__,__,__,__,__,__],\n/*SCR*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,H4,H5,__,__,__,__,__,__],\n/*SHD*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,H5,__,__,__,__,__,__],\n/*SCC*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*SFI*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H6],\n/*SAD*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*SER*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__]\n];\n\n// map server current expect state and handshake type to function\n// Note: CAD[CH] does not map to FB because renegotation is prohibited\nvar H7 = tls.handleClientHello;\nvar H8 = tls.handleClientKeyExchange;\nvar H9 = tls.handleCertificateVerify;\nhsTable[tls.ConnectionEnd.server] = [\n// 01,CH,02,03,04,05,06,07,08,09,10,CC,12,13,14,CV,CK,17,18,19,FI\n/*CHE*/[__,H7,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*CCE*/[__,__,__,__,__,__,__,__,__,__,__,H2,__,__,__,__,__,__,__,__,__],\n/*CKE*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H8,__,__,__,__],\n/*CCV*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H9,__,__,__,__,__],\n/*CCC*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*CFI*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H6],\n/*CAD*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],\n/*CER*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__]\n];\n\n/**\n * Generates the master_secret and keys using the given security parameters.\n *\n * The security parameters for a TLS connection state are defined as such:\n *\n * struct {\n * ConnectionEnd entity;\n * PRFAlgorithm prf_algorithm;\n * BulkCipherAlgorithm bulk_cipher_algorithm;\n * CipherType cipher_type;\n * uint8 enc_key_length;\n * uint8 block_length;\n * uint8 fixed_iv_length;\n * uint8 record_iv_length;\n * MACAlgorithm mac_algorithm;\n * uint8 mac_length;\n * uint8 mac_key_length;\n * CompressionMethod compression_algorithm;\n * opaque master_secret[48];\n * opaque client_random[32];\n * opaque server_random[32];\n * } SecurityParameters;\n *\n * Note that this definition is from TLS 1.2. In TLS 1.0 some of these\n * parameters are ignored because, for instance, the PRFAlgorithm is a\n * builtin-fixed algorithm combining iterations of MD5 and SHA-1 in TLS 1.0.\n *\n * The Record Protocol requires an algorithm to generate keys required by the\n * current connection state.\n *\n * The master secret is expanded into a sequence of secure bytes, which is then\n * split to a client write MAC key, a server write MAC key, a client write\n * encryption key, and a server write encryption key. In TLS 1.0 a client write\n * IV and server write IV are also generated. Each of these is generated from\n * the byte sequence in that order. Unused values are empty. In TLS 1.2, some\n * AEAD ciphers may additionally require a client write IV and a server write\n * IV (see Section 6.2.3.3).\n *\n * When keys, MAC keys, and IVs are generated, the master secret is used as an\n * entropy source.\n *\n * To generate the key material, compute:\n *\n * master_secret = PRF(pre_master_secret, \"master secret\",\n * ClientHello.random + ServerHello.random)\n *\n * key_block = PRF(SecurityParameters.master_secret,\n * \"key expansion\",\n * SecurityParameters.server_random +\n * SecurityParameters.client_random);\n *\n * until enough output has been generated. Then, the key_block is\n * partitioned as follows:\n *\n * client_write_MAC_key[SecurityParameters.mac_key_length]\n * server_write_MAC_key[SecurityParameters.mac_key_length]\n * client_write_key[SecurityParameters.enc_key_length]\n * server_write_key[SecurityParameters.enc_key_length]\n * client_write_IV[SecurityParameters.fixed_iv_length]\n * server_write_IV[SecurityParameters.fixed_iv_length]\n *\n * In TLS 1.2, the client_write_IV and server_write_IV are only generated for\n * implicit nonce techniques as described in Section 3.2.1 of [AEAD]. This\n * implementation uses TLS 1.0 so IVs are generated.\n *\n * Implementation note: The currently defined cipher suite which requires the\n * most material is AES_256_CBC_SHA256. It requires 2 x 32 byte keys and 2 x 32\n * byte MAC keys, for a total 128 bytes of key material. In TLS 1.0 it also\n * requires 2 x 16 byte IVs, so it actually takes 160 bytes of key material.\n *\n * @param c the connection.\n * @param sp the security parameters to use.\n *\n * @return the security keys.\n */\ntls.generateKeys = function(c, sp) {\n // TLS_RSA_WITH_AES_128_CBC_SHA (required to be compliant with TLS 1.2) &\n // TLS_RSA_WITH_AES_256_CBC_SHA are the only cipher suites implemented\n // at present\n\n // TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA is required to be compliant with\n // TLS 1.0 but we don't care right now because AES is better and we have\n // an implementation for it\n\n // TODO: TLS 1.2 implementation\n /*\n // determine the PRF\n var prf;\n switch(sp.prf_algorithm) {\n case tls.PRFAlgorithm.tls_prf_sha256:\n prf = prf_sha256;\n break;\n default:\n // should never happen\n throw new Error('Invalid PRF');\n }\n */\n\n // TLS 1.0/1.1 implementation\n var prf = prf_TLS1;\n\n // concatenate server and client random\n var random = sp.client_random + sp.server_random;\n\n // only create master secret if session is new\n if(!c.session.resuming) {\n // create master secret, clean up pre-master secret\n sp.master_secret = prf(\n sp.pre_master_secret, 'master secret', random, 48).bytes();\n sp.pre_master_secret = null;\n }\n\n // generate the amount of key material needed\n random = sp.server_random + sp.client_random;\n var length = 2 * sp.mac_key_length + 2 * sp.enc_key_length;\n\n // include IV for TLS/1.0\n var tls10 = (c.version.major === tls.Versions.TLS_1_0.major &&\n c.version.minor === tls.Versions.TLS_1_0.minor);\n if(tls10) {\n length += 2 * sp.fixed_iv_length;\n }\n var km = prf(sp.master_secret, 'key expansion', random, length);\n\n // split the key material into the MAC and encryption keys\n var rval = {\n client_write_MAC_key: km.getBytes(sp.mac_key_length),\n server_write_MAC_key: km.getBytes(sp.mac_key_length),\n client_write_key: km.getBytes(sp.enc_key_length),\n server_write_key: km.getBytes(sp.enc_key_length)\n };\n\n // include TLS 1.0 IVs\n if(tls10) {\n rval.client_write_IV = km.getBytes(sp.fixed_iv_length);\n rval.server_write_IV = km.getBytes(sp.fixed_iv_length);\n }\n\n return rval;\n};\n\n/**\n * Creates a new initialized TLS connection state. A connection state has\n * a read mode and a write mode.\n *\n * compression state:\n * The current state of the compression algorithm.\n *\n * cipher state:\n * The current state of the encryption algorithm. This will consist of the\n * scheduled key for that connection. For stream ciphers, this will also\n * contain whatever state information is necessary to allow the stream to\n * continue to encrypt or decrypt data.\n *\n * MAC key:\n * The MAC key for the connection.\n *\n * sequence number:\n * Each connection state contains a sequence number, which is maintained\n * separately for read and write states. The sequence number MUST be set to\n * zero whenever a connection state is made the active state. Sequence\n * numbers are of type uint64 and may not exceed 2^64-1. Sequence numbers do\n * not wrap. If a TLS implementation would need to wrap a sequence number,\n * it must renegotiate instead. A sequence number is incremented after each\n * record: specifically, the first record transmitted under a particular\n * connection state MUST use sequence number 0.\n *\n * @param c the connection.\n *\n * @return the new initialized TLS connection state.\n */\ntls.createConnectionState = function(c) {\n var client = (c.entity === tls.ConnectionEnd.client);\n\n var createMode = function() {\n var mode = {\n // two 32-bit numbers, first is most significant\n sequenceNumber: [0, 0],\n macKey: null,\n macLength: 0,\n macFunction: null,\n cipherState: null,\n cipherFunction: function(record) {return true;},\n compressionState: null,\n compressFunction: function(record) {return true;},\n updateSequenceNumber: function() {\n if(mode.sequenceNumber[1] === 0xFFFFFFFF) {\n mode.sequenceNumber[1] = 0;\n ++mode.sequenceNumber[0];\n } else {\n ++mode.sequenceNumber[1];\n }\n }\n };\n return mode;\n };\n var state = {\n read: createMode(),\n write: createMode()\n };\n\n // update function in read mode will decrypt then decompress a record\n state.read.update = function(c, record) {\n if(!state.read.cipherFunction(record, state.read)) {\n c.error(c, {\n message: 'Could not decrypt record or bad MAC.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n // doesn't matter if decryption failed or MAC was\n // invalid, return the same error so as not to reveal\n // which one occurred\n description: tls.Alert.Description.bad_record_mac\n }\n });\n } else if(!state.read.compressFunction(c, record, state.read)) {\n c.error(c, {\n message: 'Could not decompress record.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.decompression_failure\n }\n });\n }\n return !c.fail;\n };\n\n // update function in write mode will compress then encrypt a record\n state.write.update = function(c, record) {\n if(!state.write.compressFunction(c, record, state.write)) {\n // error, but do not send alert since it would require\n // compression as well\n c.error(c, {\n message: 'Could not compress record.',\n send: false,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n } else if(!state.write.cipherFunction(record, state.write)) {\n // error, but do not send alert since it would require\n // encryption as well\n c.error(c, {\n message: 'Could not encrypt record.',\n send: false,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n }\n return !c.fail;\n };\n\n // handle security parameters\n if(c.session) {\n var sp = c.session.sp;\n c.session.cipherSuite.initSecurityParameters(sp);\n\n // generate keys\n sp.keys = tls.generateKeys(c, sp);\n state.read.macKey = client ?\n sp.keys.server_write_MAC_key : sp.keys.client_write_MAC_key;\n state.write.macKey = client ?\n sp.keys.client_write_MAC_key : sp.keys.server_write_MAC_key;\n\n // cipher suite setup\n c.session.cipherSuite.initConnectionState(state, c, sp);\n\n // compression setup\n switch(sp.compression_algorithm) {\n case tls.CompressionMethod.none:\n break;\n case tls.CompressionMethod.deflate:\n state.read.compressFunction = inflate;\n state.write.compressFunction = deflate;\n break;\n default:\n throw new Error('Unsupported compression algorithm.');\n }\n }\n\n return state;\n};\n\n/**\n * Creates a Random structure.\n *\n * struct {\n * uint32 gmt_unix_time;\n * opaque random_bytes[28];\n * } Random;\n *\n * gmt_unix_time:\n * The current time and date in standard UNIX 32-bit format (seconds since\n * the midnight starting Jan 1, 1970, UTC, ignoring leap seconds) according\n * to the sender's internal clock. Clocks are not required to be set\n * correctly by the basic TLS protocol; higher-level or application\n * protocols may define additional requirements. Note that, for historical\n * reasons, the data element is named using GMT, the predecessor of the\n * current worldwide time base, UTC.\n * random_bytes:\n * 28 bytes generated by a secure random number generator.\n *\n * @return the Random structure as a byte array.\n */\ntls.createRandom = function() {\n // get UTC milliseconds\n var d = new Date();\n var utc = +d + d.getTimezoneOffset() * 60000;\n var rval = forge.util.createBuffer();\n rval.putInt32(utc);\n rval.putBytes(forge.random.getBytes(28));\n return rval;\n};\n\n/**\n * Creates a TLS record with the given type and data.\n *\n * @param c the connection.\n * @param options:\n * type: the record type.\n * data: the plain text data in a byte buffer.\n *\n * @return the created record.\n */\ntls.createRecord = function(c, options) {\n if(!options.data) {\n return null;\n }\n var record = {\n type: options.type,\n version: {\n major: c.version.major,\n minor: c.version.minor\n },\n length: options.data.length(),\n fragment: options.data\n };\n return record;\n};\n\n/**\n * Creates a TLS alert record.\n *\n * @param c the connection.\n * @param alert:\n * level: the TLS alert level.\n * description: the TLS alert description.\n *\n * @return the created alert record.\n */\ntls.createAlert = function(c, alert) {\n var b = forge.util.createBuffer();\n b.putByte(alert.level);\n b.putByte(alert.description);\n return tls.createRecord(c, {\n type: tls.ContentType.alert,\n data: b\n });\n};\n\n/* The structure of a TLS handshake message.\n *\n * struct {\n * HandshakeType msg_type; // handshake type\n * uint24 length; // bytes in message\n * select(HandshakeType) {\n * case hello_request: HelloRequest;\n * case client_hello: ClientHello;\n * case server_hello: ServerHello;\n * case certificate: Certificate;\n * case server_key_exchange: ServerKeyExchange;\n * case certificate_request: CertificateRequest;\n * case server_hello_done: ServerHelloDone;\n * case certificate_verify: CertificateVerify;\n * case client_key_exchange: ClientKeyExchange;\n * case finished: Finished;\n * } body;\n * } Handshake;\n */\n\n/**\n * Creates a ClientHello message.\n *\n * opaque SessionID<0..32>;\n * enum { null(0), deflate(1), (255) } CompressionMethod;\n * uint8 CipherSuite[2];\n *\n * struct {\n * ProtocolVersion client_version;\n * Random random;\n * SessionID session_id;\n * CipherSuite cipher_suites<2..2^16-2>;\n * CompressionMethod compression_methods<1..2^8-1>;\n * select(extensions_present) {\n * case false:\n * struct {};\n * case true:\n * Extension extensions<0..2^16-1>;\n * };\n * } ClientHello;\n *\n * The extension format for extended client hellos and server hellos is:\n *\n * struct {\n * ExtensionType extension_type;\n * opaque extension_data<0..2^16-1>;\n * } Extension;\n *\n * Here:\n *\n * - \"extension_type\" identifies the particular extension type.\n * - \"extension_data\" contains information specific to the particular\n * extension type.\n *\n * The extension types defined in this document are:\n *\n * enum {\n * server_name(0), max_fragment_length(1),\n * client_certificate_url(2), trusted_ca_keys(3),\n * truncated_hmac(4), status_request(5), (65535)\n * } ExtensionType;\n *\n * @param c the connection.\n *\n * @return the ClientHello byte buffer.\n */\ntls.createClientHello = function(c) {\n // save hello version\n c.session.clientHelloVersion = {\n major: c.version.major,\n minor: c.version.minor\n };\n\n // create supported cipher suites\n var cipherSuites = forge.util.createBuffer();\n for(var i = 0; i < c.cipherSuites.length; ++i) {\n var cs = c.cipherSuites[i];\n cipherSuites.putByte(cs.id[0]);\n cipherSuites.putByte(cs.id[1]);\n }\n var cSuites = cipherSuites.length();\n\n // create supported compression methods, null always supported, but\n // also support deflate if connection has inflate and deflate methods\n var compressionMethods = forge.util.createBuffer();\n compressionMethods.putByte(tls.CompressionMethod.none);\n // FIXME: deflate support disabled until issues with raw deflate data\n // without zlib headers are resolved\n /*\n if(c.inflate !== null && c.deflate !== null) {\n compressionMethods.putByte(tls.CompressionMethod.deflate);\n }\n */\n var cMethods = compressionMethods.length();\n\n // create TLS SNI (server name indication) extension if virtual host\n // has been specified, see RFC 3546\n var extensions = forge.util.createBuffer();\n if(c.virtualHost) {\n // create extension struct\n var ext = forge.util.createBuffer();\n ext.putByte(0x00); // type server_name (ExtensionType is 2 bytes)\n ext.putByte(0x00);\n\n /* In order to provide the server name, clients MAY include an\n * extension of type \"server_name\" in the (extended) client hello.\n * The \"extension_data\" field of this extension SHALL contain\n * \"ServerNameList\" where:\n *\n * struct {\n * NameType name_type;\n * select(name_type) {\n * case host_name: HostName;\n * } name;\n * } ServerName;\n *\n * enum {\n * host_name(0), (255)\n * } NameType;\n *\n * opaque HostName<1..2^16-1>;\n *\n * struct {\n * ServerName server_name_list<1..2^16-1>\n * } ServerNameList;\n */\n var serverName = forge.util.createBuffer();\n serverName.putByte(0x00); // type host_name\n writeVector(serverName, 2, forge.util.createBuffer(c.virtualHost));\n\n // ServerNameList is in extension_data\n var snList = forge.util.createBuffer();\n writeVector(snList, 2, serverName);\n writeVector(ext, 2, snList);\n extensions.putBuffer(ext);\n }\n var extLength = extensions.length();\n if(extLength > 0) {\n // add extension vector length\n extLength += 2;\n }\n\n // determine length of the handshake message\n // cipher suites and compression methods size will need to be\n // updated if more get added to the list\n var sessionId = c.session.id;\n var length =\n sessionId.length + 1 + // session ID vector\n 2 + // version (major + minor)\n 4 + 28 + // random time and random bytes\n 2 + cSuites + // cipher suites vector\n 1 + cMethods + // compression methods vector\n extLength; // extensions vector\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.client_hello);\n rval.putInt24(length); // handshake length\n rval.putByte(c.version.major); // major version\n rval.putByte(c.version.minor); // minor version\n rval.putBytes(c.session.sp.client_random); // random time + bytes\n writeVector(rval, 1, forge.util.createBuffer(sessionId));\n writeVector(rval, 2, cipherSuites);\n writeVector(rval, 1, compressionMethods);\n if(extLength > 0) {\n writeVector(rval, 2, extensions);\n }\n return rval;\n};\n\n/**\n * Creates a ServerHello message.\n *\n * @param c the connection.\n *\n * @return the ServerHello byte buffer.\n */\ntls.createServerHello = function(c) {\n // determine length of the handshake message\n var sessionId = c.session.id;\n var length =\n sessionId.length + 1 + // session ID vector\n 2 + // version (major + minor)\n 4 + 28 + // random time and random bytes\n 2 + // chosen cipher suite\n 1; // chosen compression method\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.server_hello);\n rval.putInt24(length); // handshake length\n rval.putByte(c.version.major); // major version\n rval.putByte(c.version.minor); // minor version\n rval.putBytes(c.session.sp.server_random); // random time + bytes\n writeVector(rval, 1, forge.util.createBuffer(sessionId));\n rval.putByte(c.session.cipherSuite.id[0]);\n rval.putByte(c.session.cipherSuite.id[1]);\n rval.putByte(c.session.compressionMethod);\n return rval;\n};\n\n/**\n * Creates a Certificate message.\n *\n * When this message will be sent:\n * This is the first message the client can send after receiving a server\n * hello done message and the first message the server can send after\n * sending a ServerHello. This client message is only sent if the server\n * requests a certificate. If no suitable certificate is available, the\n * client should send a certificate message containing no certificates. If\n * client authentication is required by the server for the handshake to\n * continue, it may respond with a fatal handshake failure alert.\n *\n * opaque ASN.1Cert<1..2^24-1>;\n *\n * struct {\n * ASN.1Cert certificate_list<0..2^24-1>;\n * } Certificate;\n *\n * @param c the connection.\n *\n * @return the Certificate byte buffer.\n */\ntls.createCertificate = function(c) {\n // TODO: check certificate request to ensure types are supported\n\n // get a certificate (a certificate as a PEM string)\n var client = (c.entity === tls.ConnectionEnd.client);\n var cert = null;\n if(c.getCertificate) {\n var hint;\n if(client) {\n hint = c.session.certificateRequest;\n } else {\n hint = c.session.extensions.server_name.serverNameList;\n }\n cert = c.getCertificate(c, hint);\n }\n\n // buffer to hold certificate list\n var certList = forge.util.createBuffer();\n if(cert !== null) {\n try {\n // normalize cert to a chain of certificates\n if(!forge.util.isArray(cert)) {\n cert = [cert];\n }\n var asn1 = null;\n for(var i = 0; i < cert.length; ++i) {\n var msg = forge.pem.decode(cert[i])[0];\n if(msg.type !== 'CERTIFICATE' &&\n msg.type !== 'X509 CERTIFICATE' &&\n msg.type !== 'TRUSTED CERTIFICATE') {\n var error = new Error('Could not convert certificate from PEM; PEM ' +\n 'header type is not \"CERTIFICATE\", \"X509 CERTIFICATE\", or ' +\n '\"TRUSTED CERTIFICATE\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert certificate from PEM; PEM is encrypted.');\n }\n\n var der = forge.util.createBuffer(msg.body);\n if(asn1 === null) {\n asn1 = forge.asn1.fromDer(der.bytes(), false);\n }\n\n // certificate entry is itself a vector with 3 length bytes\n var certBuffer = forge.util.createBuffer();\n writeVector(certBuffer, 3, der);\n\n // add cert vector to cert list vector\n certList.putBuffer(certBuffer);\n }\n\n // save certificate\n cert = forge.pki.certificateFromAsn1(asn1);\n if(client) {\n c.session.clientCertificate = cert;\n } else {\n c.session.serverCertificate = cert;\n }\n } catch(ex) {\n return c.error(c, {\n message: 'Could not send certificate list.',\n cause: ex,\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.bad_certificate\n }\n });\n }\n }\n\n // determine length of the handshake message\n var length = 3 + certList.length(); // cert list vector\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.certificate);\n rval.putInt24(length);\n writeVector(rval, 3, certList);\n return rval;\n};\n\n/**\n * Creates a ClientKeyExchange message.\n *\n * When this message will be sent:\n * This message is always sent by the client. It will immediately follow the\n * client certificate message, if it is sent. Otherwise it will be the first\n * message sent by the client after it receives the server hello done\n * message.\n *\n * Meaning of this message:\n * With this message, the premaster secret is set, either though direct\n * transmission of the RSA-encrypted secret, or by the transmission of\n * Diffie-Hellman parameters which will allow each side to agree upon the\n * same premaster secret. When the key exchange method is DH_RSA or DH_DSS,\n * client certification has been requested, and the client was able to\n * respond with a certificate which contained a Diffie-Hellman public key\n * whose parameters (group and generator) matched those specified by the\n * server in its certificate, this message will not contain any data.\n *\n * Meaning of this message:\n * If RSA is being used for key agreement and authentication, the client\n * generates a 48-byte premaster secret, encrypts it using the public key\n * from the server's certificate or the temporary RSA key provided in a\n * server key exchange message, and sends the result in an encrypted\n * premaster secret message. This structure is a variant of the client\n * key exchange message, not a message in itself.\n *\n * struct {\n * select(KeyExchangeAlgorithm) {\n * case rsa: EncryptedPreMasterSecret;\n * case diffie_hellman: ClientDiffieHellmanPublic;\n * } exchange_keys;\n * } ClientKeyExchange;\n *\n * struct {\n * ProtocolVersion client_version;\n * opaque random[46];\n * } PreMasterSecret;\n *\n * struct {\n * public-key-encrypted PreMasterSecret pre_master_secret;\n * } EncryptedPreMasterSecret;\n *\n * A public-key-encrypted element is encoded as a vector <0..2^16-1>.\n *\n * @param c the connection.\n *\n * @return the ClientKeyExchange byte buffer.\n */\ntls.createClientKeyExchange = function(c) {\n // create buffer to encrypt\n var b = forge.util.createBuffer();\n\n // add highest client-supported protocol to help server avoid version\n // rollback attacks\n b.putByte(c.session.clientHelloVersion.major);\n b.putByte(c.session.clientHelloVersion.minor);\n\n // generate and add 46 random bytes\n b.putBytes(forge.random.getBytes(46));\n\n // save pre-master secret\n var sp = c.session.sp;\n sp.pre_master_secret = b.getBytes();\n\n // RSA-encrypt the pre-master secret\n var key = c.session.serverCertificate.publicKey;\n b = key.encrypt(sp.pre_master_secret);\n\n /* Note: The encrypted pre-master secret will be stored in a\n public-key-encrypted opaque vector that has the length prefixed using\n 2 bytes, so include those 2 bytes in the handshake message length. This\n is done as a minor optimization instead of calling writeVector(). */\n\n // determine length of the handshake message\n var length = b.length + 2;\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.client_key_exchange);\n rval.putInt24(length);\n // add vector length bytes\n rval.putInt16(b.length);\n rval.putBytes(b);\n return rval;\n};\n\n/**\n * Creates a ServerKeyExchange message.\n *\n * @param c the connection.\n *\n * @return the ServerKeyExchange byte buffer.\n */\ntls.createServerKeyExchange = function(c) {\n // this implementation only supports RSA, no Diffie-Hellman support,\n // so this record is empty\n\n // determine length of the handshake message\n var length = 0;\n\n // build record fragment\n var rval = forge.util.createBuffer();\n if(length > 0) {\n rval.putByte(tls.HandshakeType.server_key_exchange);\n rval.putInt24(length);\n }\n return rval;\n};\n\n/**\n * Gets the signed data used to verify a client-side certificate. See\n * tls.createCertificateVerify() for details.\n *\n * @param c the connection.\n * @param callback the callback to call once the signed data is ready.\n */\ntls.getClientSignature = function(c, callback) {\n // generate data to RSA encrypt\n var b = forge.util.createBuffer();\n b.putBuffer(c.session.md5.digest());\n b.putBuffer(c.session.sha1.digest());\n b = b.getBytes();\n\n // create default signing function as necessary\n c.getSignature = c.getSignature || function(c, b, callback) {\n // do rsa encryption, call callback\n var privateKey = null;\n if(c.getPrivateKey) {\n try {\n privateKey = c.getPrivateKey(c, c.session.clientCertificate);\n privateKey = forge.pki.privateKeyFromPem(privateKey);\n } catch(ex) {\n c.error(c, {\n message: 'Could not get private key.',\n cause: ex,\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n }\n }\n if(privateKey === null) {\n c.error(c, {\n message: 'No private key set.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.internal_error\n }\n });\n } else {\n b = privateKey.sign(b, null);\n }\n callback(c, b);\n };\n\n // get client signature\n c.getSignature(c, b, callback);\n};\n\n/**\n * Creates a CertificateVerify message.\n *\n * Meaning of this message:\n * This structure conveys the client's Diffie-Hellman public value\n * (Yc) if it was not already included in the client's certificate.\n * The encoding used for Yc is determined by the enumerated\n * PublicValueEncoding. This structure is a variant of the client\n * key exchange message, not a message in itself.\n *\n * When this message will be sent:\n * This message is used to provide explicit verification of a client\n * certificate. This message is only sent following a client\n * certificate that has signing capability (i.e. all certificates\n * except those containing fixed Diffie-Hellman parameters). When\n * sent, it will immediately follow the client key exchange message.\n *\n * struct {\n * Signature signature;\n * } CertificateVerify;\n *\n * CertificateVerify.signature.md5_hash\n * MD5(handshake_messages);\n *\n * Certificate.signature.sha_hash\n * SHA(handshake_messages);\n *\n * Here handshake_messages refers to all handshake messages sent or\n * received starting at client hello up to but not including this\n * message, including the type and length fields of the handshake\n * messages.\n *\n * select(SignatureAlgorithm) {\n * case anonymous: struct { };\n * case rsa:\n * digitally-signed struct {\n * opaque md5_hash[16];\n * opaque sha_hash[20];\n * };\n * case dsa:\n * digitally-signed struct {\n * opaque sha_hash[20];\n * };\n * } Signature;\n *\n * In digital signing, one-way hash functions are used as input for a\n * signing algorithm. A digitally-signed element is encoded as an opaque\n * vector <0..2^16-1>, where the length is specified by the signing\n * algorithm and key.\n *\n * In RSA signing, a 36-byte structure of two hashes (one SHA and one\n * MD5) is signed (encrypted with the private key). It is encoded with\n * PKCS #1 block type 0 or type 1 as described in [PKCS1].\n *\n * In DSS, the 20 bytes of the SHA hash are run directly through the\n * Digital Signing Algorithm with no additional hashing.\n *\n * @param c the connection.\n * @param signature the signature to include in the message.\n *\n * @return the CertificateVerify byte buffer.\n */\ntls.createCertificateVerify = function(c, signature) {\n /* Note: The signature will be stored in a \"digitally-signed\" opaque\n vector that has the length prefixed using 2 bytes, so include those\n 2 bytes in the handshake message length. This is done as a minor\n optimization instead of calling writeVector(). */\n\n // determine length of the handshake message\n var length = signature.length + 2;\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.certificate_verify);\n rval.putInt24(length);\n // add vector length bytes\n rval.putInt16(signature.length);\n rval.putBytes(signature);\n return rval;\n};\n\n/**\n * Creates a CertificateRequest message.\n *\n * @param c the connection.\n *\n * @return the CertificateRequest byte buffer.\n */\ntls.createCertificateRequest = function(c) {\n // TODO: support other certificate types\n var certTypes = forge.util.createBuffer();\n\n // common RSA certificate type\n certTypes.putByte(0x01);\n\n // add distinguished names from CA store\n var cAs = forge.util.createBuffer();\n for(var key in c.caStore.certs) {\n var cert = c.caStore.certs[key];\n var dn = forge.pki.distinguishedNameToAsn1(cert.subject);\n var byteBuffer = forge.asn1.toDer(dn);\n cAs.putInt16(byteBuffer.length());\n cAs.putBuffer(byteBuffer);\n }\n\n // TODO: TLS 1.2+ has a different format\n\n // determine length of the handshake message\n var length =\n 1 + certTypes.length() +\n 2 + cAs.length();\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.certificate_request);\n rval.putInt24(length);\n writeVector(rval, 1, certTypes);\n writeVector(rval, 2, cAs);\n return rval;\n};\n\n/**\n * Creates a ServerHelloDone message.\n *\n * @param c the connection.\n *\n * @return the ServerHelloDone byte buffer.\n */\ntls.createServerHelloDone = function(c) {\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.server_hello_done);\n rval.putInt24(0);\n return rval;\n};\n\n/**\n * Creates a ChangeCipherSpec message.\n *\n * The change cipher spec protocol exists to signal transitions in\n * ciphering strategies. The protocol consists of a single message,\n * which is encrypted and compressed under the current (not the pending)\n * connection state. The message consists of a single byte of value 1.\n *\n * struct {\n * enum { change_cipher_spec(1), (255) } type;\n * } ChangeCipherSpec;\n *\n * @return the ChangeCipherSpec byte buffer.\n */\ntls.createChangeCipherSpec = function() {\n var rval = forge.util.createBuffer();\n rval.putByte(0x01);\n return rval;\n};\n\n/**\n * Creates a Finished message.\n *\n * struct {\n * opaque verify_data[12];\n * } Finished;\n *\n * verify_data\n * PRF(master_secret, finished_label, MD5(handshake_messages) +\n * SHA-1(handshake_messages)) [0..11];\n *\n * finished_label\n * For Finished messages sent by the client, the string \"client\n * finished\". For Finished messages sent by the server, the\n * string \"server finished\".\n *\n * handshake_messages\n * All of the data from all handshake messages up to but not\n * including this message. This is only data visible at the\n * handshake layer and does not include record layer headers.\n * This is the concatenation of all the Handshake structures as\n * defined in 7.4 exchanged thus far.\n *\n * @param c the connection.\n *\n * @return the Finished byte buffer.\n */\ntls.createFinished = function(c) {\n // generate verify_data\n var b = forge.util.createBuffer();\n b.putBuffer(c.session.md5.digest());\n b.putBuffer(c.session.sha1.digest());\n\n // TODO: determine prf function and verify length for TLS 1.2\n var client = (c.entity === tls.ConnectionEnd.client);\n var sp = c.session.sp;\n var vdl = 12;\n var prf = prf_TLS1;\n var label = client ? 'client finished' : 'server finished';\n b = prf(sp.master_secret, label, b.getBytes(), vdl);\n\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(tls.HandshakeType.finished);\n rval.putInt24(b.length());\n rval.putBuffer(b);\n return rval;\n};\n\n/**\n * Creates a HeartbeatMessage (See RFC 6520).\n *\n * struct {\n * HeartbeatMessageType type;\n * uint16 payload_length;\n * opaque payload[HeartbeatMessage.payload_length];\n * opaque padding[padding_length];\n * } HeartbeatMessage;\n *\n * The total length of a HeartbeatMessage MUST NOT exceed 2^14 or\n * max_fragment_length when negotiated as defined in [RFC6066].\n *\n * type: The message type, either heartbeat_request or heartbeat_response.\n *\n * payload_length: The length of the payload.\n *\n * payload: The payload consists of arbitrary content.\n *\n * padding: The padding is random content that MUST be ignored by the\n * receiver. The length of a HeartbeatMessage is TLSPlaintext.length\n * for TLS and DTLSPlaintext.length for DTLS. Furthermore, the\n * length of the type field is 1 byte, and the length of the\n * payload_length is 2. Therefore, the padding_length is\n * TLSPlaintext.length - payload_length - 3 for TLS and\n * DTLSPlaintext.length - payload_length - 3 for DTLS. The\n * padding_length MUST be at least 16.\n *\n * The sender of a HeartbeatMessage MUST use a random padding of at\n * least 16 bytes. The padding of a received HeartbeatMessage message\n * MUST be ignored.\n *\n * If the payload_length of a received HeartbeatMessage is too large,\n * the received HeartbeatMessage MUST be discarded silently.\n *\n * @param c the connection.\n * @param type the tls.HeartbeatMessageType.\n * @param payload the heartbeat data to send as the payload.\n * @param [payloadLength] the payload length to use, defaults to the\n * actual payload length.\n *\n * @return the HeartbeatRequest byte buffer.\n */\ntls.createHeartbeat = function(type, payload, payloadLength) {\n if(typeof payloadLength === 'undefined') {\n payloadLength = payload.length;\n }\n // build record fragment\n var rval = forge.util.createBuffer();\n rval.putByte(type); // heartbeat message type\n rval.putInt16(payloadLength); // payload length\n rval.putBytes(payload); // payload\n // padding\n var plaintextLength = rval.length();\n var paddingLength = Math.max(16, plaintextLength - payloadLength - 3);\n rval.putBytes(forge.random.getBytes(paddingLength));\n return rval;\n};\n\n/**\n * Fragments, compresses, encrypts, and queues a record for delivery.\n *\n * @param c the connection.\n * @param record the record to queue.\n */\ntls.queue = function(c, record) {\n // error during record creation\n if(!record) {\n return;\n }\n\n if(record.fragment.length() === 0) {\n if(record.type === tls.ContentType.handshake ||\n record.type === tls.ContentType.alert ||\n record.type === tls.ContentType.change_cipher_spec) {\n // Empty handshake, alert of change cipher spec messages are not allowed per the TLS specification and should not be sent.\n return;\n }\n }\n\n // if the record is a handshake record, update handshake hashes\n if(record.type === tls.ContentType.handshake) {\n var bytes = record.fragment.bytes();\n c.session.md5.update(bytes);\n c.session.sha1.update(bytes);\n bytes = null;\n }\n\n // handle record fragmentation\n var records;\n if(record.fragment.length() <= tls.MaxFragment) {\n records = [record];\n } else {\n // fragment data as long as it is too long\n records = [];\n var data = record.fragment.bytes();\n while(data.length > tls.MaxFragment) {\n records.push(tls.createRecord(c, {\n type: record.type,\n data: forge.util.createBuffer(data.slice(0, tls.MaxFragment))\n }));\n data = data.slice(tls.MaxFragment);\n }\n // add last record\n if(data.length > 0) {\n records.push(tls.createRecord(c, {\n type: record.type,\n data: forge.util.createBuffer(data)\n }));\n }\n }\n\n // compress and encrypt all fragmented records\n for(var i = 0; i < records.length && !c.fail; ++i) {\n // update the record using current write state\n var rec = records[i];\n var s = c.state.current.write;\n if(s.update(c, rec)) {\n // store record\n c.records.push(rec);\n }\n }\n};\n\n/**\n * Flushes all queued records to the output buffer and calls the\n * tlsDataReady() handler on the given connection.\n *\n * @param c the connection.\n *\n * @return true on success, false on failure.\n */\ntls.flush = function(c) {\n for(var i = 0; i < c.records.length; ++i) {\n var record = c.records[i];\n\n // add record header and fragment\n c.tlsData.putByte(record.type);\n c.tlsData.putByte(record.version.major);\n c.tlsData.putByte(record.version.minor);\n c.tlsData.putInt16(record.fragment.length());\n c.tlsData.putBuffer(c.records[i].fragment);\n }\n c.records = [];\n return c.tlsDataReady(c);\n};\n\n/**\n * Maps a pki.certificateError to a tls.Alert.Description.\n *\n * @param error the error to map.\n *\n * @return the alert description.\n */\nvar _certErrorToAlertDesc = function(error) {\n switch(error) {\n case true:\n return true;\n case forge.pki.certificateError.bad_certificate:\n return tls.Alert.Description.bad_certificate;\n case forge.pki.certificateError.unsupported_certificate:\n return tls.Alert.Description.unsupported_certificate;\n case forge.pki.certificateError.certificate_revoked:\n return tls.Alert.Description.certificate_revoked;\n case forge.pki.certificateError.certificate_expired:\n return tls.Alert.Description.certificate_expired;\n case forge.pki.certificateError.certificate_unknown:\n return tls.Alert.Description.certificate_unknown;\n case forge.pki.certificateError.unknown_ca:\n return tls.Alert.Description.unknown_ca;\n default:\n return tls.Alert.Description.bad_certificate;\n }\n};\n\n/**\n * Maps a tls.Alert.Description to a pki.certificateError.\n *\n * @param desc the alert description.\n *\n * @return the certificate error.\n */\nvar _alertDescToCertError = function(desc) {\n switch(desc) {\n case true:\n return true;\n case tls.Alert.Description.bad_certificate:\n return forge.pki.certificateError.bad_certificate;\n case tls.Alert.Description.unsupported_certificate:\n return forge.pki.certificateError.unsupported_certificate;\n case tls.Alert.Description.certificate_revoked:\n return forge.pki.certificateError.certificate_revoked;\n case tls.Alert.Description.certificate_expired:\n return forge.pki.certificateError.certificate_expired;\n case tls.Alert.Description.certificate_unknown:\n return forge.pki.certificateError.certificate_unknown;\n case tls.Alert.Description.unknown_ca:\n return forge.pki.certificateError.unknown_ca;\n default:\n return forge.pki.certificateError.bad_certificate;\n }\n};\n\n/**\n * Verifies a certificate chain against the given connection's\n * Certificate Authority store.\n *\n * @param c the TLS connection.\n * @param chain the certificate chain to verify, with the root or highest\n * authority at the end.\n *\n * @return true if successful, false if not.\n */\ntls.verifyCertificateChain = function(c, chain) {\n try {\n // Make a copy of c.verifyOptions so that we can modify options.verify\n // without modifying c.verifyOptions.\n var options = {};\n for (var key in c.verifyOptions) {\n options[key] = c.verifyOptions[key];\n }\n\n options.verify = function(vfd, depth, chain) {\n // convert pki.certificateError to tls alert description\n var desc = _certErrorToAlertDesc(vfd);\n\n // call application callback\n var ret = c.verify(c, vfd, depth, chain);\n if(ret !== true) {\n if(typeof ret === 'object' && !forge.util.isArray(ret)) {\n // throw custom error\n var error = new Error('The application rejected the certificate.');\n error.send = true;\n error.alert = {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.bad_certificate\n };\n if(ret.message) {\n error.message = ret.message;\n }\n if(ret.alert) {\n error.alert.description = ret.alert;\n }\n throw error;\n }\n\n // convert tls alert description to pki.certificateError\n if(ret !== vfd) {\n ret = _alertDescToCertError(ret);\n }\n }\n\n return ret;\n };\n\n // verify chain\n forge.pki.verifyCertificateChain(c.caStore, chain, options);\n } catch(ex) {\n // build tls error if not already customized\n var err = ex;\n if(typeof err !== 'object' || forge.util.isArray(err)) {\n err = {\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: _certErrorToAlertDesc(ex)\n }\n };\n }\n if(!('send' in err)) {\n err.send = true;\n }\n if(!('alert' in err)) {\n err.alert = {\n level: tls.Alert.Level.fatal,\n description: _certErrorToAlertDesc(err.error)\n };\n }\n\n // send error\n c.error(c, err);\n }\n\n return !c.fail;\n};\n\n/**\n * Creates a new TLS session cache.\n *\n * @param cache optional map of session ID to cached session.\n * @param capacity the maximum size for the cache (default: 100).\n *\n * @return the new TLS session cache.\n */\ntls.createSessionCache = function(cache, capacity) {\n var rval = null;\n\n // assume input is already a session cache object\n if(cache && cache.getSession && cache.setSession && cache.order) {\n rval = cache;\n } else {\n // create cache\n rval = {};\n rval.cache = cache || {};\n rval.capacity = Math.max(capacity || 100, 1);\n rval.order = [];\n\n // store order for sessions, delete session overflow\n for(var key in cache) {\n if(rval.order.length <= capacity) {\n rval.order.push(key);\n } else {\n delete cache[key];\n }\n }\n\n // get a session from a session ID (or get any session)\n rval.getSession = function(sessionId) {\n var session = null;\n var key = null;\n\n // if session ID provided, use it\n if(sessionId) {\n key = forge.util.bytesToHex(sessionId);\n } else if(rval.order.length > 0) {\n // get first session from cache\n key = rval.order[0];\n }\n\n if(key !== null && key in rval.cache) {\n // get cached session and remove from cache\n session = rval.cache[key];\n delete rval.cache[key];\n for(var i in rval.order) {\n if(rval.order[i] === key) {\n rval.order.splice(i, 1);\n break;\n }\n }\n }\n\n return session;\n };\n\n // set a session in the cache\n rval.setSession = function(sessionId, session) {\n // remove session from cache if at capacity\n if(rval.order.length === rval.capacity) {\n var key = rval.order.shift();\n delete rval.cache[key];\n }\n // add session to cache\n var key = forge.util.bytesToHex(sessionId);\n rval.order.push(key);\n rval.cache[key] = session;\n };\n }\n\n return rval;\n};\n\n/**\n * Creates a new TLS connection.\n *\n * See public createConnection() docs for more details.\n *\n * @param options the options for this connection.\n *\n * @return the new TLS connection.\n */\ntls.createConnection = function(options) {\n var caStore = null;\n if(options.caStore) {\n // if CA store is an array, convert it to a CA store object\n if(forge.util.isArray(options.caStore)) {\n caStore = forge.pki.createCaStore(options.caStore);\n } else {\n caStore = options.caStore;\n }\n } else {\n // create empty CA store\n caStore = forge.pki.createCaStore();\n }\n\n // setup default cipher suites\n var cipherSuites = options.cipherSuites || null;\n if(cipherSuites === null) {\n cipherSuites = [];\n for(var key in tls.CipherSuites) {\n cipherSuites.push(tls.CipherSuites[key]);\n }\n }\n\n // set default entity\n var entity = (options.server || false) ?\n tls.ConnectionEnd.server : tls.ConnectionEnd.client;\n\n // create session cache if requested\n var sessionCache = options.sessionCache ?\n tls.createSessionCache(options.sessionCache) : null;\n\n // create TLS connection\n var c = {\n version: {major: tls.Version.major, minor: tls.Version.minor},\n entity: entity,\n sessionId: options.sessionId,\n caStore: caStore,\n sessionCache: sessionCache,\n cipherSuites: cipherSuites,\n connected: options.connected,\n virtualHost: options.virtualHost || null,\n verifyClient: options.verifyClient || false,\n verify: options.verify || function(cn, vfd, dpth, cts) {return vfd;},\n verifyOptions: options.verifyOptions || {},\n getCertificate: options.getCertificate || null,\n getPrivateKey: options.getPrivateKey || null,\n getSignature: options.getSignature || null,\n input: forge.util.createBuffer(),\n tlsData: forge.util.createBuffer(),\n data: forge.util.createBuffer(),\n tlsDataReady: options.tlsDataReady,\n dataReady: options.dataReady,\n heartbeatReceived: options.heartbeatReceived,\n closed: options.closed,\n error: function(c, ex) {\n // set origin if not set\n ex.origin = ex.origin ||\n ((c.entity === tls.ConnectionEnd.client) ? 'client' : 'server');\n\n // send TLS alert\n if(ex.send) {\n tls.queue(c, tls.createAlert(c, ex.alert));\n tls.flush(c);\n }\n\n // error is fatal by default\n var fatal = (ex.fatal !== false);\n if(fatal) {\n // set fail flag\n c.fail = true;\n }\n\n // call error handler first\n options.error(c, ex);\n\n if(fatal) {\n // fatal error, close connection, do not clear fail\n c.close(false);\n }\n },\n deflate: options.deflate || null,\n inflate: options.inflate || null\n };\n\n /**\n * Resets a closed TLS connection for reuse. Called in c.close().\n *\n * @param clearFail true to clear the fail flag (default: true).\n */\n c.reset = function(clearFail) {\n c.version = {major: tls.Version.major, minor: tls.Version.minor};\n c.record = null;\n c.session = null;\n c.peerCertificate = null;\n c.state = {\n pending: null,\n current: null\n };\n c.expect = (c.entity === tls.ConnectionEnd.client) ? SHE : CHE;\n c.fragmented = null;\n c.records = [];\n c.open = false;\n c.handshakes = 0;\n c.handshaking = false;\n c.isConnected = false;\n c.fail = !(clearFail || typeof(clearFail) === 'undefined');\n c.input.clear();\n c.tlsData.clear();\n c.data.clear();\n c.state.current = tls.createConnectionState(c);\n };\n\n // do initial reset of connection\n c.reset();\n\n /**\n * Updates the current TLS engine state based on the given record.\n *\n * @param c the TLS connection.\n * @param record the TLS record to act on.\n */\n var _update = function(c, record) {\n // get record handler (align type in table by subtracting lowest)\n var aligned = record.type - tls.ContentType.change_cipher_spec;\n var handlers = ctTable[c.entity][c.expect];\n if(aligned in handlers) {\n handlers[aligned](c, record);\n } else {\n // unexpected record\n tls.handleUnexpected(c, record);\n }\n };\n\n /**\n * Reads the record header and initializes the next record on the given\n * connection.\n *\n * @param c the TLS connection with the next record.\n *\n * @return 0 if the input data could be processed, otherwise the\n * number of bytes required for data to be processed.\n */\n var _readRecordHeader = function(c) {\n var rval = 0;\n\n // get input buffer and its length\n var b = c.input;\n var len = b.length();\n\n // need at least 5 bytes to initialize a record\n if(len < 5) {\n rval = 5 - len;\n } else {\n // enough bytes for header\n // initialize record\n c.record = {\n type: b.getByte(),\n version: {\n major: b.getByte(),\n minor: b.getByte()\n },\n length: b.getInt16(),\n fragment: forge.util.createBuffer(),\n ready: false\n };\n\n // check record version\n var compatibleVersion = (c.record.version.major === c.version.major);\n if(compatibleVersion && c.session && c.session.version) {\n // session version already set, require same minor version\n compatibleVersion = (c.record.version.minor === c.version.minor);\n }\n if(!compatibleVersion) {\n c.error(c, {\n message: 'Incompatible TLS version.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description: tls.Alert.Description.protocol_version\n }\n });\n }\n }\n\n return rval;\n };\n\n /**\n * Reads the next record's contents and appends its message to any\n * previously fragmented message.\n *\n * @param c the TLS connection with the next record.\n *\n * @return 0 if the input data could be processed, otherwise the\n * number of bytes required for data to be processed.\n */\n var _readRecord = function(c) {\n var rval = 0;\n\n // ensure there is enough input data to get the entire record\n var b = c.input;\n var len = b.length();\n if(len < c.record.length) {\n // not enough data yet, return how much is required\n rval = c.record.length - len;\n } else {\n // there is enough data to parse the pending record\n // fill record fragment and compact input buffer\n c.record.fragment.putBytes(b.getBytes(c.record.length));\n b.compact();\n\n // update record using current read state\n var s = c.state.current.read;\n if(s.update(c, c.record)) {\n // see if there is a previously fragmented message that the\n // new record's message fragment should be appended to\n if(c.fragmented !== null) {\n // if the record type matches a previously fragmented\n // record, append the record fragment to it\n if(c.fragmented.type === c.record.type) {\n // concatenate record fragments\n c.fragmented.fragment.putBuffer(c.record.fragment);\n c.record = c.fragmented;\n } else {\n // error, invalid fragmented record\n c.error(c, {\n message: 'Invalid fragmented record.',\n send: true,\n alert: {\n level: tls.Alert.Level.fatal,\n description:\n tls.Alert.Description.unexpected_message\n }\n });\n }\n }\n\n // record is now ready\n c.record.ready = true;\n }\n }\n\n return rval;\n };\n\n /**\n * Performs a handshake using the TLS Handshake Protocol, as a client.\n *\n * This method should only be called if the connection is in client mode.\n *\n * @param sessionId the session ID to use, null to start a new one.\n */\n c.handshake = function(sessionId) {\n // error to call this in non-client mode\n if(c.entity !== tls.ConnectionEnd.client) {\n // not fatal error\n c.error(c, {\n message: 'Cannot initiate handshake as a server.',\n fatal: false\n });\n } else if(c.handshaking) {\n // handshake is already in progress, fail but not fatal error\n c.error(c, {\n message: 'Handshake already in progress.',\n fatal: false\n });\n } else {\n // clear fail flag on reuse\n if(c.fail && !c.open && c.handshakes === 0) {\n c.fail = false;\n }\n\n // now handshaking\n c.handshaking = true;\n\n // default to blank (new session)\n sessionId = sessionId || '';\n\n // if a session ID was specified, try to find it in the cache\n var session = null;\n if(sessionId.length > 0) {\n if(c.sessionCache) {\n session = c.sessionCache.getSession(sessionId);\n }\n\n // matching session not found in cache, clear session ID\n if(session === null) {\n sessionId = '';\n }\n }\n\n // no session given, grab a session from the cache, if available\n if(sessionId.length === 0 && c.sessionCache) {\n session = c.sessionCache.getSession();\n if(session !== null) {\n sessionId = session.id;\n }\n }\n\n // set up session\n c.session = {\n id: sessionId,\n version: null,\n cipherSuite: null,\n compressionMethod: null,\n serverCertificate: null,\n certificateRequest: null,\n clientCertificate: null,\n sp: {},\n md5: forge.md.md5.create(),\n sha1: forge.md.sha1.create()\n };\n\n // use existing session information\n if(session) {\n // only update version on connection, session version not yet set\n c.version = session.version;\n c.session.sp = session.sp;\n }\n\n // generate new client random\n c.session.sp.client_random = tls.createRandom().getBytes();\n\n // connection now open\n c.open = true;\n\n // send hello\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.handshake,\n data: tls.createClientHello(c)\n }));\n tls.flush(c);\n }\n };\n\n /**\n * Called when TLS protocol data has been received from somewhere and should\n * be processed by the TLS engine.\n *\n * @param data the TLS protocol data, as a string, to process.\n *\n * @return 0 if the data could be processed, otherwise the number of bytes\n * required for data to be processed.\n */\n c.process = function(data) {\n var rval = 0;\n\n // buffer input data\n if(data) {\n c.input.putBytes(data);\n }\n\n // process next record if no failure, process will be called after\n // each record is handled (since handling can be asynchronous)\n if(!c.fail) {\n // reset record if ready and now empty\n if(c.record !== null &&\n c.record.ready && c.record.fragment.isEmpty()) {\n c.record = null;\n }\n\n // if there is no pending record, try to read record header\n if(c.record === null) {\n rval = _readRecordHeader(c);\n }\n\n // read the next record (if record not yet ready)\n if(!c.fail && c.record !== null && !c.record.ready) {\n rval = _readRecord(c);\n }\n\n // record ready to be handled, update engine state\n if(!c.fail && c.record !== null && c.record.ready) {\n _update(c, c.record);\n }\n }\n\n return rval;\n };\n\n /**\n * Requests that application data be packaged into a TLS record. The\n * tlsDataReady handler will be called when the TLS record(s) have been\n * prepared.\n *\n * @param data the application data, as a raw 'binary' encoded string, to\n * be sent; to send utf-16/utf-8 string data, use the return value\n * of util.encodeUtf8(str).\n *\n * @return true on success, false on failure.\n */\n c.prepare = function(data) {\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.application_data,\n data: forge.util.createBuffer(data)\n }));\n return tls.flush(c);\n };\n\n /**\n * Requests that a heartbeat request be packaged into a TLS record for\n * transmission. The tlsDataReady handler will be called when TLS record(s)\n * have been prepared.\n *\n * When a heartbeat response has been received, the heartbeatReceived\n * handler will be called with the matching payload. This handler can\n * be used to clear a retransmission timer, etc.\n *\n * @param payload the heartbeat data to send as the payload in the message.\n * @param [payloadLength] the payload length to use, defaults to the\n * actual payload length.\n *\n * @return true on success, false on failure.\n */\n c.prepareHeartbeatRequest = function(payload, payloadLength) {\n if(payload instanceof forge.util.ByteBuffer) {\n payload = payload.bytes();\n }\n if(typeof payloadLength === 'undefined') {\n payloadLength = payload.length;\n }\n c.expectedHeartbeatPayload = payload;\n tls.queue(c, tls.createRecord(c, {\n type: tls.ContentType.heartbeat,\n data: tls.createHeartbeat(\n tls.HeartbeatMessageType.heartbeat_request, payload, payloadLength)\n }));\n return tls.flush(c);\n };\n\n /**\n * Closes the connection (sends a close_notify alert).\n *\n * @param clearFail true to clear the fail flag (default: true).\n */\n c.close = function(clearFail) {\n // save session if connection didn't fail\n if(!c.fail && c.sessionCache && c.session) {\n // only need to preserve session ID, version, and security params\n var session = {\n id: c.session.id,\n version: c.session.version,\n sp: c.session.sp\n };\n session.sp.keys = null;\n c.sessionCache.setSession(session.id, session);\n }\n\n if(c.open) {\n // connection no longer open, clear input\n c.open = false;\n c.input.clear();\n\n // if connected or handshaking, send an alert\n if(c.isConnected || c.handshaking) {\n c.isConnected = c.handshaking = false;\n\n // send close_notify alert\n tls.queue(c, tls.createAlert(c, {\n level: tls.Alert.Level.warning,\n description: tls.Alert.Description.close_notify\n }));\n tls.flush(c);\n }\n\n // call handler\n c.closed(c);\n }\n\n // reset TLS connection, do not clear fail flag\n c.reset(clearFail);\n };\n\n return c;\n};\n\n/* TLS API */\nmodule.exports = forge.tls = forge.tls || {};\n\n// expose non-functions\nfor(var key in tls) {\n if(typeof tls[key] !== 'function') {\n forge.tls[key] = tls[key];\n }\n}\n\n// expose prf_tls1 for testing\nforge.tls.prf_tls1 = prf_TLS1;\n\n// expose sha1 hmac method\nforge.tls.hmac_sha1 = hmac_sha1;\n\n// expose session cache creation\nforge.tls.createSessionCache = tls.createSessionCache;\n\n/**\n * Creates a new TLS connection. This does not make any assumptions about the\n * transport layer that TLS is working on top of, ie: it does not assume there\n * is a TCP/IP connection or establish one. A TLS connection is totally\n * abstracted away from the layer is runs on top of, it merely establishes a\n * secure channel between a client\" and a \"server\".\n *\n * A TLS connection contains 4 connection states: pending read and write, and\n * current read and write.\n *\n * At initialization, the current read and write states will be null. Only once\n * the security parameters have been set and the keys have been generated can\n * the pending states be converted into current states. Current states will be\n * updated for each record processed.\n *\n * A custom certificate verify callback may be provided to check information\n * like the common name on the server's certificate. It will be called for\n * every certificate in the chain. It has the following signature:\n *\n * variable func(c, certs, index, preVerify)\n * Where:\n * c The TLS connection\n * verified Set to true if certificate was verified, otherwise the alert\n * tls.Alert.Description for why the certificate failed.\n * depth The current index in the chain, where 0 is the server's cert.\n * certs The certificate chain, *NOTE* if the server was anonymous then\n * the chain will be empty.\n *\n * The function returns true on success and on failure either the appropriate\n * tls.Alert.Description or an object with 'alert' set to the appropriate\n * tls.Alert.Description and 'message' set to a custom error message. If true\n * is not returned then the connection will abort using, in order of\n * availability, first the returned alert description, second the preVerify\n * alert description, and lastly the default 'bad_certificate'.\n *\n * There are three callbacks that can be used to make use of client-side\n * certificates where each takes the TLS connection as the first parameter:\n *\n * getCertificate(conn, hint)\n * The second parameter is a hint as to which certificate should be\n * returned. If the connection entity is a client, then the hint will be\n * the CertificateRequest message from the server that is part of the\n * TLS protocol. If the connection entity is a server, then it will be\n * the servername list provided via an SNI extension the ClientHello, if\n * one was provided (empty array if not). The hint can be examined to\n * determine which certificate to use (advanced). Most implementations\n * will just return a certificate. The return value must be a\n * PEM-formatted certificate or an array of PEM-formatted certificates\n * that constitute a certificate chain, with the first in the array/chain\n * being the client's certificate.\n * getPrivateKey(conn, certificate)\n * The second parameter is an forge.pki X.509 certificate object that\n * is associated with the requested private key. The return value must\n * be a PEM-formatted private key.\n * getSignature(conn, bytes, callback)\n * This callback can be used instead of getPrivateKey if the private key\n * is not directly accessible in javascript or should not be. For\n * instance, a secure external web service could provide the signature\n * in exchange for appropriate credentials. The second parameter is a\n * string of bytes to be signed that are part of the TLS protocol. These\n * bytes are used to verify that the private key for the previously\n * provided client-side certificate is accessible to the client. The\n * callback is a function that takes 2 parameters, the TLS connection\n * and the RSA encrypted (signed) bytes as a string. This callback must\n * be called once the signature is ready.\n *\n * @param options the options for this connection:\n * server: true if the connection is server-side, false for client.\n * sessionId: a session ID to reuse, null for a new connection.\n * caStore: an array of certificates to trust.\n * sessionCache: a session cache to use.\n * cipherSuites: an optional array of cipher suites to use,\n * see tls.CipherSuites.\n * connected: function(conn) called when the first handshake completes.\n * virtualHost: the virtual server name to use in a TLS SNI extension.\n * verifyClient: true to require a client certificate in server mode,\n * 'optional' to request one, false not to (default: false).\n * verify: a handler used to custom verify certificates in the chain.\n * verifyOptions: an object with options for the certificate chain validation.\n * See documentation of pki.verifyCertificateChain for possible options.\n * verifyOptions.verify is ignored. If you wish to specify a verify handler\n * use the verify key.\n * getCertificate: an optional callback used to get a certificate or\n * a chain of certificates (as an array).\n * getPrivateKey: an optional callback used to get a private key.\n * getSignature: an optional callback used to get a signature.\n * tlsDataReady: function(conn) called when TLS protocol data has been\n * prepared and is ready to be used (typically sent over a socket\n * connection to its destination), read from conn.tlsData buffer.\n * dataReady: function(conn) called when application data has\n * been parsed from a TLS record and should be consumed by the\n * application, read from conn.data buffer.\n * closed: function(conn) called when the connection has been closed.\n * error: function(conn, error) called when there was an error.\n * deflate: function(inBytes) if provided, will deflate TLS records using\n * the deflate algorithm if the server supports it.\n * inflate: function(inBytes) if provided, will inflate TLS records using\n * the deflate algorithm if the server supports it.\n *\n * @return the new TLS connection.\n */\nforge.tls.createConnection = tls.createConnection;\n","/**\n * Utility functions for web applications.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2018 Digital Bazaar, Inc.\n */\nvar forge = require('./forge');\nvar baseN = require('./baseN');\n\n/* Utilities API */\nvar util = module.exports = forge.util = forge.util || {};\n\n// define setImmediate and nextTick\n(function() {\n // use native nextTick (unless we're in webpack)\n // webpack (or better node-libs-browser polyfill) sets process.browser.\n // this way we can detect webpack properly\n if(typeof process !== 'undefined' && process.nextTick && !process.browser) {\n util.nextTick = process.nextTick;\n if(typeof setImmediate === 'function') {\n util.setImmediate = setImmediate;\n } else {\n // polyfill setImmediate with nextTick, older versions of node\n // (those w/o setImmediate) won't totally starve IO\n util.setImmediate = util.nextTick;\n }\n return;\n }\n\n // polyfill nextTick with native setImmediate\n if(typeof setImmediate === 'function') {\n util.setImmediate = function() { return setImmediate.apply(undefined, arguments); };\n util.nextTick = function(callback) {\n return setImmediate(callback);\n };\n return;\n }\n\n /* Note: A polyfill upgrade pattern is used here to allow combining\n polyfills. For example, MutationObserver is fast, but blocks UI updates,\n so it needs to allow UI updates periodically, so it falls back on\n postMessage or setTimeout. */\n\n // polyfill with setTimeout\n util.setImmediate = function(callback) {\n setTimeout(callback, 0);\n };\n\n // upgrade polyfill to use postMessage\n if(typeof window !== 'undefined' &&\n typeof window.postMessage === 'function') {\n var msg = 'forge.setImmediate';\n var callbacks = [];\n util.setImmediate = function(callback) {\n callbacks.push(callback);\n // only send message when one hasn't been sent in\n // the current turn of the event loop\n if(callbacks.length === 1) {\n window.postMessage(msg, '*');\n }\n };\n function handler(event) {\n if(event.source === window && event.data === msg) {\n event.stopPropagation();\n var copy = callbacks.slice();\n callbacks.length = 0;\n copy.forEach(function(callback) {\n callback();\n });\n }\n }\n window.addEventListener('message', handler, true);\n }\n\n // upgrade polyfill to use MutationObserver\n if(typeof MutationObserver !== 'undefined') {\n // polyfill with MutationObserver\n var now = Date.now();\n var attr = true;\n var div = document.createElement('div');\n var callbacks = [];\n new MutationObserver(function() {\n var copy = callbacks.slice();\n callbacks.length = 0;\n copy.forEach(function(callback) {\n callback();\n });\n }).observe(div, {attributes: true});\n var oldSetImmediate = util.setImmediate;\n util.setImmediate = function(callback) {\n if(Date.now() - now > 15) {\n now = Date.now();\n oldSetImmediate(callback);\n } else {\n callbacks.push(callback);\n // only trigger observer when it hasn't been triggered in\n // the current turn of the event loop\n if(callbacks.length === 1) {\n div.setAttribute('a', attr = !attr);\n }\n }\n };\n }\n\n util.nextTick = util.setImmediate;\n})();\n\n// check if running under Node.js\nutil.isNodejs =\n typeof process !== 'undefined' && process.versions && process.versions.node;\n\n\n// 'self' will also work in Web Workers (instance of WorkerGlobalScope) while\n// it will point to `window` in the main thread.\n// To remain compatible with older browsers, we fall back to 'window' if 'self'\n// is not available.\nutil.globalScope = (function() {\n if(util.isNodejs) {\n return global;\n }\n\n return typeof self === 'undefined' ? window : self;\n})();\n\n// define isArray\nutil.isArray = Array.isArray || function(x) {\n return Object.prototype.toString.call(x) === '[object Array]';\n};\n\n// define isArrayBuffer\nutil.isArrayBuffer = function(x) {\n return typeof ArrayBuffer !== 'undefined' && x instanceof ArrayBuffer;\n};\n\n// define isArrayBufferView\nutil.isArrayBufferView = function(x) {\n return x && util.isArrayBuffer(x.buffer) && x.byteLength !== undefined;\n};\n\n/**\n * Ensure a bits param is 8, 16, 24, or 32. Used to validate input for\n * algorithms where bit manipulation, JavaScript limitations, and/or algorithm\n * design only allow for byte operations of a limited size.\n *\n * @param n number of bits.\n *\n * Throw Error if n invalid.\n */\nfunction _checkBitsParam(n) {\n if(!(n === 8 || n === 16 || n === 24 || n === 32)) {\n throw new Error('Only 8, 16, 24, or 32 bits supported: ' + n);\n }\n}\n\n// TODO: set ByteBuffer to best available backing\nutil.ByteBuffer = ByteStringBuffer;\n\n/** Buffer w/BinaryString backing */\n\n/**\n * Constructor for a binary string backed byte buffer.\n *\n * @param [b] the bytes to wrap (either encoded as string, one byte per\n * character, or as an ArrayBuffer or Typed Array).\n */\nfunction ByteStringBuffer(b) {\n // TODO: update to match DataBuffer API\n\n // the data in this buffer\n this.data = '';\n // the pointer for reading from this buffer\n this.read = 0;\n\n if(typeof b === 'string') {\n this.data = b;\n } else if(util.isArrayBuffer(b) || util.isArrayBufferView(b)) {\n if(typeof Buffer !== 'undefined' && b instanceof Buffer) {\n this.data = b.toString('binary');\n } else {\n // convert native buffer to forge buffer\n // FIXME: support native buffers internally instead\n var arr = new Uint8Array(b);\n try {\n this.data = String.fromCharCode.apply(null, arr);\n } catch(e) {\n for(var i = 0; i < arr.length; ++i) {\n this.putByte(arr[i]);\n }\n }\n }\n } else if(b instanceof ByteStringBuffer ||\n (typeof b === 'object' && typeof b.data === 'string' &&\n typeof b.read === 'number')) {\n // copy existing buffer\n this.data = b.data;\n this.read = b.read;\n }\n\n // used for v8 optimization\n this._constructedStringLength = 0;\n}\nutil.ByteStringBuffer = ByteStringBuffer;\n\n/* Note: This is an optimization for V8-based browsers. When V8 concatenates\n a string, the strings are only joined logically using a \"cons string\" or\n \"constructed/concatenated string\". These containers keep references to one\n another and can result in very large memory usage. For example, if a 2MB\n string is constructed by concatenating 4 bytes together at a time, the\n memory usage will be ~44MB; so ~22x increase. The strings are only joined\n together when an operation requiring their joining takes place, such as\n substr(). This function is called when adding data to this buffer to ensure\n these types of strings are periodically joined to reduce the memory\n footprint. */\nvar _MAX_CONSTRUCTED_STRING_LENGTH = 4096;\nutil.ByteStringBuffer.prototype._optimizeConstructedString = function(x) {\n this._constructedStringLength += x;\n if(this._constructedStringLength > _MAX_CONSTRUCTED_STRING_LENGTH) {\n // this substr() should cause the constructed string to join\n this.data.substr(0, 1);\n this._constructedStringLength = 0;\n }\n};\n\n/**\n * Gets the number of bytes in this buffer.\n *\n * @return the number of bytes in this buffer.\n */\nutil.ByteStringBuffer.prototype.length = function() {\n return this.data.length - this.read;\n};\n\n/**\n * Gets whether or not this buffer is empty.\n *\n * @return true if this buffer is empty, false if not.\n */\nutil.ByteStringBuffer.prototype.isEmpty = function() {\n return this.length() <= 0;\n};\n\n/**\n * Puts a byte in this buffer.\n *\n * @param b the byte to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putByte = function(b) {\n return this.putBytes(String.fromCharCode(b));\n};\n\n/**\n * Puts a byte in this buffer N times.\n *\n * @param b the byte to put.\n * @param n the number of bytes of value b to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.fillWithByte = function(b, n) {\n b = String.fromCharCode(b);\n var d = this.data;\n while(n > 0) {\n if(n & 1) {\n d += b;\n }\n n >>>= 1;\n if(n > 0) {\n b += b;\n }\n }\n this.data = d;\n this._optimizeConstructedString(n);\n return this;\n};\n\n/**\n * Puts bytes in this buffer.\n *\n * @param bytes the bytes (as a binary encoded string) to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putBytes = function(bytes) {\n this.data += bytes;\n this._optimizeConstructedString(bytes.length);\n return this;\n};\n\n/**\n * Puts a UTF-16 encoded string into this buffer.\n *\n * @param str the string to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putString = function(str) {\n return this.putBytes(util.encodeUtf8(str));\n};\n\n/**\n * Puts a 16-bit integer in this buffer in big-endian order.\n *\n * @param i the 16-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt16 = function(i) {\n return this.putBytes(\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i & 0xFF));\n};\n\n/**\n * Puts a 24-bit integer in this buffer in big-endian order.\n *\n * @param i the 24-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt24 = function(i) {\n return this.putBytes(\n String.fromCharCode(i >> 16 & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i & 0xFF));\n};\n\n/**\n * Puts a 32-bit integer in this buffer in big-endian order.\n *\n * @param i the 32-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt32 = function(i) {\n return this.putBytes(\n String.fromCharCode(i >> 24 & 0xFF) +\n String.fromCharCode(i >> 16 & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i & 0xFF));\n};\n\n/**\n * Puts a 16-bit integer in this buffer in little-endian order.\n *\n * @param i the 16-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt16Le = function(i) {\n return this.putBytes(\n String.fromCharCode(i & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF));\n};\n\n/**\n * Puts a 24-bit integer in this buffer in little-endian order.\n *\n * @param i the 24-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt24Le = function(i) {\n return this.putBytes(\n String.fromCharCode(i & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i >> 16 & 0xFF));\n};\n\n/**\n * Puts a 32-bit integer in this buffer in little-endian order.\n *\n * @param i the 32-bit integer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt32Le = function(i) {\n return this.putBytes(\n String.fromCharCode(i & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i >> 16 & 0xFF) +\n String.fromCharCode(i >> 24 & 0xFF));\n};\n\n/**\n * Puts an n-bit integer in this buffer in big-endian order.\n *\n * @param i the n-bit integer.\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putInt = function(i, n) {\n _checkBitsParam(n);\n var bytes = '';\n do {\n n -= 8;\n bytes += String.fromCharCode((i >> n) & 0xFF);\n } while(n > 0);\n return this.putBytes(bytes);\n};\n\n/**\n * Puts a signed n-bit integer in this buffer in big-endian order. Two's\n * complement representation is used.\n *\n * @param i the n-bit integer.\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putSignedInt = function(i, n) {\n // putInt checks n\n if(i < 0) {\n i += 2 << (n - 1);\n }\n return this.putInt(i, n);\n};\n\n/**\n * Puts the given buffer into this buffer.\n *\n * @param buffer the buffer to put into this one.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.putBuffer = function(buffer) {\n return this.putBytes(buffer.getBytes());\n};\n\n/**\n * Gets a byte from this buffer and advances the read pointer by 1.\n *\n * @return the byte.\n */\nutil.ByteStringBuffer.prototype.getByte = function() {\n return this.data.charCodeAt(this.read++);\n};\n\n/**\n * Gets a uint16 from this buffer in big-endian order and advances the read\n * pointer by 2.\n *\n * @return the uint16.\n */\nutil.ByteStringBuffer.prototype.getInt16 = function() {\n var rval = (\n this.data.charCodeAt(this.read) << 8 ^\n this.data.charCodeAt(this.read + 1));\n this.read += 2;\n return rval;\n};\n\n/**\n * Gets a uint24 from this buffer in big-endian order and advances the read\n * pointer by 3.\n *\n * @return the uint24.\n */\nutil.ByteStringBuffer.prototype.getInt24 = function() {\n var rval = (\n this.data.charCodeAt(this.read) << 16 ^\n this.data.charCodeAt(this.read + 1) << 8 ^\n this.data.charCodeAt(this.read + 2));\n this.read += 3;\n return rval;\n};\n\n/**\n * Gets a uint32 from this buffer in big-endian order and advances the read\n * pointer by 4.\n *\n * @return the word.\n */\nutil.ByteStringBuffer.prototype.getInt32 = function() {\n var rval = (\n this.data.charCodeAt(this.read) << 24 ^\n this.data.charCodeAt(this.read + 1) << 16 ^\n this.data.charCodeAt(this.read + 2) << 8 ^\n this.data.charCodeAt(this.read + 3));\n this.read += 4;\n return rval;\n};\n\n/**\n * Gets a uint16 from this buffer in little-endian order and advances the read\n * pointer by 2.\n *\n * @return the uint16.\n */\nutil.ByteStringBuffer.prototype.getInt16Le = function() {\n var rval = (\n this.data.charCodeAt(this.read) ^\n this.data.charCodeAt(this.read + 1) << 8);\n this.read += 2;\n return rval;\n};\n\n/**\n * Gets a uint24 from this buffer in little-endian order and advances the read\n * pointer by 3.\n *\n * @return the uint24.\n */\nutil.ByteStringBuffer.prototype.getInt24Le = function() {\n var rval = (\n this.data.charCodeAt(this.read) ^\n this.data.charCodeAt(this.read + 1) << 8 ^\n this.data.charCodeAt(this.read + 2) << 16);\n this.read += 3;\n return rval;\n};\n\n/**\n * Gets a uint32 from this buffer in little-endian order and advances the read\n * pointer by 4.\n *\n * @return the word.\n */\nutil.ByteStringBuffer.prototype.getInt32Le = function() {\n var rval = (\n this.data.charCodeAt(this.read) ^\n this.data.charCodeAt(this.read + 1) << 8 ^\n this.data.charCodeAt(this.read + 2) << 16 ^\n this.data.charCodeAt(this.read + 3) << 24);\n this.read += 4;\n return rval;\n};\n\n/**\n * Gets an n-bit integer from this buffer in big-endian order and advances the\n * read pointer by ceil(n/8).\n *\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return the integer.\n */\nutil.ByteStringBuffer.prototype.getInt = function(n) {\n _checkBitsParam(n);\n var rval = 0;\n do {\n // TODO: Use (rval * 0x100) if adding support for 33 to 53 bits.\n rval = (rval << 8) + this.data.charCodeAt(this.read++);\n n -= 8;\n } while(n > 0);\n return rval;\n};\n\n/**\n * Gets a signed n-bit integer from this buffer in big-endian order, using\n * two's complement, and advances the read pointer by n/8.\n *\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return the integer.\n */\nutil.ByteStringBuffer.prototype.getSignedInt = function(n) {\n // getInt checks n\n var x = this.getInt(n);\n var max = 2 << (n - 2);\n if(x >= max) {\n x -= max << 1;\n }\n return x;\n};\n\n/**\n * Reads bytes out as a binary encoded string and clears them from the\n * buffer. Note that the resulting string is binary encoded (in node.js this\n * encoding is referred to as `binary`, it is *not* `utf8`).\n *\n * @param count the number of bytes to read, undefined or null for all.\n *\n * @return a binary encoded string of bytes.\n */\nutil.ByteStringBuffer.prototype.getBytes = function(count) {\n var rval;\n if(count) {\n // read count bytes\n count = Math.min(this.length(), count);\n rval = this.data.slice(this.read, this.read + count);\n this.read += count;\n } else if(count === 0) {\n rval = '';\n } else {\n // read all bytes, optimize to only copy when needed\n rval = (this.read === 0) ? this.data : this.data.slice(this.read);\n this.clear();\n }\n return rval;\n};\n\n/**\n * Gets a binary encoded string of the bytes from this buffer without\n * modifying the read pointer.\n *\n * @param count the number of bytes to get, omit to get all.\n *\n * @return a string full of binary encoded characters.\n */\nutil.ByteStringBuffer.prototype.bytes = function(count) {\n return (typeof(count) === 'undefined' ?\n this.data.slice(this.read) :\n this.data.slice(this.read, this.read + count));\n};\n\n/**\n * Gets a byte at the given index without modifying the read pointer.\n *\n * @param i the byte index.\n *\n * @return the byte.\n */\nutil.ByteStringBuffer.prototype.at = function(i) {\n return this.data.charCodeAt(this.read + i);\n};\n\n/**\n * Puts a byte at the given index without modifying the read pointer.\n *\n * @param i the byte index.\n * @param b the byte to put.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.setAt = function(i, b) {\n this.data = this.data.substr(0, this.read + i) +\n String.fromCharCode(b) +\n this.data.substr(this.read + i + 1);\n return this;\n};\n\n/**\n * Gets the last byte without modifying the read pointer.\n *\n * @return the last byte.\n */\nutil.ByteStringBuffer.prototype.last = function() {\n return this.data.charCodeAt(this.data.length - 1);\n};\n\n/**\n * Creates a copy of this buffer.\n *\n * @return the copy.\n */\nutil.ByteStringBuffer.prototype.copy = function() {\n var c = util.createBuffer(this.data);\n c.read = this.read;\n return c;\n};\n\n/**\n * Compacts this buffer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.compact = function() {\n if(this.read > 0) {\n this.data = this.data.slice(this.read);\n this.read = 0;\n }\n return this;\n};\n\n/**\n * Clears this buffer.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.clear = function() {\n this.data = '';\n this.read = 0;\n return this;\n};\n\n/**\n * Shortens this buffer by triming bytes off of the end of this buffer.\n *\n * @param count the number of bytes to trim off.\n *\n * @return this buffer.\n */\nutil.ByteStringBuffer.prototype.truncate = function(count) {\n var len = Math.max(0, this.length() - count);\n this.data = this.data.substr(this.read, len);\n this.read = 0;\n return this;\n};\n\n/**\n * Converts this buffer to a hexadecimal string.\n *\n * @return a hexadecimal string.\n */\nutil.ByteStringBuffer.prototype.toHex = function() {\n var rval = '';\n for(var i = this.read; i < this.data.length; ++i) {\n var b = this.data.charCodeAt(i);\n if(b < 16) {\n rval += '0';\n }\n rval += b.toString(16);\n }\n return rval;\n};\n\n/**\n * Converts this buffer to a UTF-16 string (standard JavaScript string).\n *\n * @return a UTF-16 string.\n */\nutil.ByteStringBuffer.prototype.toString = function() {\n return util.decodeUtf8(this.bytes());\n};\n\n/** End Buffer w/BinaryString backing */\n\n/** Buffer w/UInt8Array backing */\n\n/**\n * FIXME: Experimental. Do not use yet.\n *\n * Constructor for an ArrayBuffer-backed byte buffer.\n *\n * The buffer may be constructed from a string, an ArrayBuffer, DataView, or a\n * TypedArray.\n *\n * If a string is given, its encoding should be provided as an option,\n * otherwise it will default to 'binary'. A 'binary' string is encoded such\n * that each character is one byte in length and size.\n *\n * If an ArrayBuffer, DataView, or TypedArray is given, it will be used\n * *directly* without any copying. Note that, if a write to the buffer requires\n * more space, the buffer will allocate a new backing ArrayBuffer to\n * accommodate. The starting read and write offsets for the buffer may be\n * given as options.\n *\n * @param [b] the initial bytes for this buffer.\n * @param options the options to use:\n * [readOffset] the starting read offset to use (default: 0).\n * [writeOffset] the starting write offset to use (default: the\n * length of the first parameter).\n * [growSize] the minimum amount, in bytes, to grow the buffer by to\n * accommodate writes (default: 1024).\n * [encoding] the encoding ('binary', 'utf8', 'utf16', 'hex') for the\n * first parameter, if it is a string (default: 'binary').\n */\nfunction DataBuffer(b, options) {\n // default options\n options = options || {};\n\n // pointers for read from/write to buffer\n this.read = options.readOffset || 0;\n this.growSize = options.growSize || 1024;\n\n var isArrayBuffer = util.isArrayBuffer(b);\n var isArrayBufferView = util.isArrayBufferView(b);\n if(isArrayBuffer || isArrayBufferView) {\n // use ArrayBuffer directly\n if(isArrayBuffer) {\n this.data = new DataView(b);\n } else {\n // TODO: adjust read/write offset based on the type of view\n // or specify that this must be done in the options ... that the\n // offsets are byte-based\n this.data = new DataView(b.buffer, b.byteOffset, b.byteLength);\n }\n this.write = ('writeOffset' in options ?\n options.writeOffset : this.data.byteLength);\n return;\n }\n\n // initialize to empty array buffer and add any given bytes using putBytes\n this.data = new DataView(new ArrayBuffer(0));\n this.write = 0;\n\n if(b !== null && b !== undefined) {\n this.putBytes(b);\n }\n\n if('writeOffset' in options) {\n this.write = options.writeOffset;\n }\n}\nutil.DataBuffer = DataBuffer;\n\n/**\n * Gets the number of bytes in this buffer.\n *\n * @return the number of bytes in this buffer.\n */\nutil.DataBuffer.prototype.length = function() {\n return this.write - this.read;\n};\n\n/**\n * Gets whether or not this buffer is empty.\n *\n * @return true if this buffer is empty, false if not.\n */\nutil.DataBuffer.prototype.isEmpty = function() {\n return this.length() <= 0;\n};\n\n/**\n * Ensures this buffer has enough empty space to accommodate the given number\n * of bytes. An optional parameter may be given that indicates a minimum\n * amount to grow the buffer if necessary. If the parameter is not given,\n * the buffer will be grown by some previously-specified default amount\n * or heuristic.\n *\n * @param amount the number of bytes to accommodate.\n * @param [growSize] the minimum amount, in bytes, to grow the buffer by if\n * necessary.\n */\nutil.DataBuffer.prototype.accommodate = function(amount, growSize) {\n if(this.length() >= amount) {\n return this;\n }\n growSize = Math.max(growSize || this.growSize, amount);\n\n // grow buffer\n var src = new Uint8Array(\n this.data.buffer, this.data.byteOffset, this.data.byteLength);\n var dst = new Uint8Array(this.length() + growSize);\n dst.set(src);\n this.data = new DataView(dst.buffer);\n\n return this;\n};\n\n/**\n * Puts a byte in this buffer.\n *\n * @param b the byte to put.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putByte = function(b) {\n this.accommodate(1);\n this.data.setUint8(this.write++, b);\n return this;\n};\n\n/**\n * Puts a byte in this buffer N times.\n *\n * @param b the byte to put.\n * @param n the number of bytes of value b to put.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.fillWithByte = function(b, n) {\n this.accommodate(n);\n for(var i = 0; i < n; ++i) {\n this.data.setUint8(b);\n }\n return this;\n};\n\n/**\n * Puts bytes in this buffer. The bytes may be given as a string, an\n * ArrayBuffer, a DataView, or a TypedArray.\n *\n * @param bytes the bytes to put.\n * @param [encoding] the encoding for the first parameter ('binary', 'utf8',\n * 'utf16', 'hex'), if it is a string (default: 'binary').\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putBytes = function(bytes, encoding) {\n if(util.isArrayBufferView(bytes)) {\n var src = new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n var len = src.byteLength - src.byteOffset;\n this.accommodate(len);\n var dst = new Uint8Array(this.data.buffer, this.write);\n dst.set(src);\n this.write += len;\n return this;\n }\n\n if(util.isArrayBuffer(bytes)) {\n var src = new Uint8Array(bytes);\n this.accommodate(src.byteLength);\n var dst = new Uint8Array(this.data.buffer);\n dst.set(src, this.write);\n this.write += src.byteLength;\n return this;\n }\n\n // bytes is a util.DataBuffer or equivalent\n if(bytes instanceof util.DataBuffer ||\n (typeof bytes === 'object' &&\n typeof bytes.read === 'number' && typeof bytes.write === 'number' &&\n util.isArrayBufferView(bytes.data))) {\n var src = new Uint8Array(bytes.data.byteLength, bytes.read, bytes.length());\n this.accommodate(src.byteLength);\n var dst = new Uint8Array(bytes.data.byteLength, this.write);\n dst.set(src);\n this.write += src.byteLength;\n return this;\n }\n\n if(bytes instanceof util.ByteStringBuffer) {\n // copy binary string and process as the same as a string parameter below\n bytes = bytes.data;\n encoding = 'binary';\n }\n\n // string conversion\n encoding = encoding || 'binary';\n if(typeof bytes === 'string') {\n var view;\n\n // decode from string\n if(encoding === 'hex') {\n this.accommodate(Math.ceil(bytes.length / 2));\n view = new Uint8Array(this.data.buffer, this.write);\n this.write += util.binary.hex.decode(bytes, view, this.write);\n return this;\n }\n if(encoding === 'base64') {\n this.accommodate(Math.ceil(bytes.length / 4) * 3);\n view = new Uint8Array(this.data.buffer, this.write);\n this.write += util.binary.base64.decode(bytes, view, this.write);\n return this;\n }\n\n // encode text as UTF-8 bytes\n if(encoding === 'utf8') {\n // encode as UTF-8 then decode string as raw binary\n bytes = util.encodeUtf8(bytes);\n encoding = 'binary';\n }\n\n // decode string as raw binary\n if(encoding === 'binary' || encoding === 'raw') {\n // one byte per character\n this.accommodate(bytes.length);\n view = new Uint8Array(this.data.buffer, this.write);\n this.write += util.binary.raw.decode(view);\n return this;\n }\n\n // encode text as UTF-16 bytes\n if(encoding === 'utf16') {\n // two bytes per character\n this.accommodate(bytes.length * 2);\n view = new Uint16Array(this.data.buffer, this.write);\n this.write += util.text.utf16.encode(view);\n return this;\n }\n\n throw new Error('Invalid encoding: ' + encoding);\n }\n\n throw Error('Invalid parameter: ' + bytes);\n};\n\n/**\n * Puts the given buffer into this buffer.\n *\n * @param buffer the buffer to put into this one.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putBuffer = function(buffer) {\n this.putBytes(buffer);\n buffer.clear();\n return this;\n};\n\n/**\n * Puts a string into this buffer.\n *\n * @param str the string to put.\n * @param [encoding] the encoding for the string (default: 'utf16').\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putString = function(str) {\n return this.putBytes(str, 'utf16');\n};\n\n/**\n * Puts a 16-bit integer in this buffer in big-endian order.\n *\n * @param i the 16-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt16 = function(i) {\n this.accommodate(2);\n this.data.setInt16(this.write, i);\n this.write += 2;\n return this;\n};\n\n/**\n * Puts a 24-bit integer in this buffer in big-endian order.\n *\n * @param i the 24-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt24 = function(i) {\n this.accommodate(3);\n this.data.setInt16(this.write, i >> 8 & 0xFFFF);\n this.data.setInt8(this.write, i >> 16 & 0xFF);\n this.write += 3;\n return this;\n};\n\n/**\n * Puts a 32-bit integer in this buffer in big-endian order.\n *\n * @param i the 32-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt32 = function(i) {\n this.accommodate(4);\n this.data.setInt32(this.write, i);\n this.write += 4;\n return this;\n};\n\n/**\n * Puts a 16-bit integer in this buffer in little-endian order.\n *\n * @param i the 16-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt16Le = function(i) {\n this.accommodate(2);\n this.data.setInt16(this.write, i, true);\n this.write += 2;\n return this;\n};\n\n/**\n * Puts a 24-bit integer in this buffer in little-endian order.\n *\n * @param i the 24-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt24Le = function(i) {\n this.accommodate(3);\n this.data.setInt8(this.write, i >> 16 & 0xFF);\n this.data.setInt16(this.write, i >> 8 & 0xFFFF, true);\n this.write += 3;\n return this;\n};\n\n/**\n * Puts a 32-bit integer in this buffer in little-endian order.\n *\n * @param i the 32-bit integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt32Le = function(i) {\n this.accommodate(4);\n this.data.setInt32(this.write, i, true);\n this.write += 4;\n return this;\n};\n\n/**\n * Puts an n-bit integer in this buffer in big-endian order.\n *\n * @param i the n-bit integer.\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putInt = function(i, n) {\n _checkBitsParam(n);\n this.accommodate(n / 8);\n do {\n n -= 8;\n this.data.setInt8(this.write++, (i >> n) & 0xFF);\n } while(n > 0);\n return this;\n};\n\n/**\n * Puts a signed n-bit integer in this buffer in big-endian order. Two's\n * complement representation is used.\n *\n * @param i the n-bit integer.\n * @param n the number of bits in the integer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.putSignedInt = function(i, n) {\n _checkBitsParam(n);\n this.accommodate(n / 8);\n if(i < 0) {\n i += 2 << (n - 1);\n }\n return this.putInt(i, n);\n};\n\n/**\n * Gets a byte from this buffer and advances the read pointer by 1.\n *\n * @return the byte.\n */\nutil.DataBuffer.prototype.getByte = function() {\n return this.data.getInt8(this.read++);\n};\n\n/**\n * Gets a uint16 from this buffer in big-endian order and advances the read\n * pointer by 2.\n *\n * @return the uint16.\n */\nutil.DataBuffer.prototype.getInt16 = function() {\n var rval = this.data.getInt16(this.read);\n this.read += 2;\n return rval;\n};\n\n/**\n * Gets a uint24 from this buffer in big-endian order and advances the read\n * pointer by 3.\n *\n * @return the uint24.\n */\nutil.DataBuffer.prototype.getInt24 = function() {\n var rval = (\n this.data.getInt16(this.read) << 8 ^\n this.data.getInt8(this.read + 2));\n this.read += 3;\n return rval;\n};\n\n/**\n * Gets a uint32 from this buffer in big-endian order and advances the read\n * pointer by 4.\n *\n * @return the word.\n */\nutil.DataBuffer.prototype.getInt32 = function() {\n var rval = this.data.getInt32(this.read);\n this.read += 4;\n return rval;\n};\n\n/**\n * Gets a uint16 from this buffer in little-endian order and advances the read\n * pointer by 2.\n *\n * @return the uint16.\n */\nutil.DataBuffer.prototype.getInt16Le = function() {\n var rval = this.data.getInt16(this.read, true);\n this.read += 2;\n return rval;\n};\n\n/**\n * Gets a uint24 from this buffer in little-endian order and advances the read\n * pointer by 3.\n *\n * @return the uint24.\n */\nutil.DataBuffer.prototype.getInt24Le = function() {\n var rval = (\n this.data.getInt8(this.read) ^\n this.data.getInt16(this.read + 1, true) << 8);\n this.read += 3;\n return rval;\n};\n\n/**\n * Gets a uint32 from this buffer in little-endian order and advances the read\n * pointer by 4.\n *\n * @return the word.\n */\nutil.DataBuffer.prototype.getInt32Le = function() {\n var rval = this.data.getInt32(this.read, true);\n this.read += 4;\n return rval;\n};\n\n/**\n * Gets an n-bit integer from this buffer in big-endian order and advances the\n * read pointer by n/8.\n *\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return the integer.\n */\nutil.DataBuffer.prototype.getInt = function(n) {\n _checkBitsParam(n);\n var rval = 0;\n do {\n // TODO: Use (rval * 0x100) if adding support for 33 to 53 bits.\n rval = (rval << 8) + this.data.getInt8(this.read++);\n n -= 8;\n } while(n > 0);\n return rval;\n};\n\n/**\n * Gets a signed n-bit integer from this buffer in big-endian order, using\n * two's complement, and advances the read pointer by n/8.\n *\n * @param n the number of bits in the integer (8, 16, 24, or 32).\n *\n * @return the integer.\n */\nutil.DataBuffer.prototype.getSignedInt = function(n) {\n // getInt checks n\n var x = this.getInt(n);\n var max = 2 << (n - 2);\n if(x >= max) {\n x -= max << 1;\n }\n return x;\n};\n\n/**\n * Reads bytes out as a binary encoded string and clears them from the\n * buffer.\n *\n * @param count the number of bytes to read, undefined or null for all.\n *\n * @return a binary encoded string of bytes.\n */\nutil.DataBuffer.prototype.getBytes = function(count) {\n // TODO: deprecate this method, it is poorly named and\n // this.toString('binary') replaces it\n // add a toTypedArray()/toArrayBuffer() function\n var rval;\n if(count) {\n // read count bytes\n count = Math.min(this.length(), count);\n rval = this.data.slice(this.read, this.read + count);\n this.read += count;\n } else if(count === 0) {\n rval = '';\n } else {\n // read all bytes, optimize to only copy when needed\n rval = (this.read === 0) ? this.data : this.data.slice(this.read);\n this.clear();\n }\n return rval;\n};\n\n/**\n * Gets a binary encoded string of the bytes from this buffer without\n * modifying the read pointer.\n *\n * @param count the number of bytes to get, omit to get all.\n *\n * @return a string full of binary encoded characters.\n */\nutil.DataBuffer.prototype.bytes = function(count) {\n // TODO: deprecate this method, it is poorly named, add \"getString()\"\n return (typeof(count) === 'undefined' ?\n this.data.slice(this.read) :\n this.data.slice(this.read, this.read + count));\n};\n\n/**\n * Gets a byte at the given index without modifying the read pointer.\n *\n * @param i the byte index.\n *\n * @return the byte.\n */\nutil.DataBuffer.prototype.at = function(i) {\n return this.data.getUint8(this.read + i);\n};\n\n/**\n * Puts a byte at the given index without modifying the read pointer.\n *\n * @param i the byte index.\n * @param b the byte to put.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.setAt = function(i, b) {\n this.data.setUint8(i, b);\n return this;\n};\n\n/**\n * Gets the last byte without modifying the read pointer.\n *\n * @return the last byte.\n */\nutil.DataBuffer.prototype.last = function() {\n return this.data.getUint8(this.write - 1);\n};\n\n/**\n * Creates a copy of this buffer.\n *\n * @return the copy.\n */\nutil.DataBuffer.prototype.copy = function() {\n return new util.DataBuffer(this);\n};\n\n/**\n * Compacts this buffer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.compact = function() {\n if(this.read > 0) {\n var src = new Uint8Array(this.data.buffer, this.read);\n var dst = new Uint8Array(src.byteLength);\n dst.set(src);\n this.data = new DataView(dst);\n this.write -= this.read;\n this.read = 0;\n }\n return this;\n};\n\n/**\n * Clears this buffer.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.clear = function() {\n this.data = new DataView(new ArrayBuffer(0));\n this.read = this.write = 0;\n return this;\n};\n\n/**\n * Shortens this buffer by triming bytes off of the end of this buffer.\n *\n * @param count the number of bytes to trim off.\n *\n * @return this buffer.\n */\nutil.DataBuffer.prototype.truncate = function(count) {\n this.write = Math.max(0, this.length() - count);\n this.read = Math.min(this.read, this.write);\n return this;\n};\n\n/**\n * Converts this buffer to a hexadecimal string.\n *\n * @return a hexadecimal string.\n */\nutil.DataBuffer.prototype.toHex = function() {\n var rval = '';\n for(var i = this.read; i < this.data.byteLength; ++i) {\n var b = this.data.getUint8(i);\n if(b < 16) {\n rval += '0';\n }\n rval += b.toString(16);\n }\n return rval;\n};\n\n/**\n * Converts this buffer to a string, using the given encoding. If no\n * encoding is given, 'utf8' (UTF-8) is used.\n *\n * @param [encoding] the encoding to use: 'binary', 'utf8', 'utf16', 'hex',\n * 'base64' (default: 'utf8').\n *\n * @return a string representation of the bytes in this buffer.\n */\nutil.DataBuffer.prototype.toString = function(encoding) {\n var view = new Uint8Array(this.data, this.read, this.length());\n encoding = encoding || 'utf8';\n\n // encode to string\n if(encoding === 'binary' || encoding === 'raw') {\n return util.binary.raw.encode(view);\n }\n if(encoding === 'hex') {\n return util.binary.hex.encode(view);\n }\n if(encoding === 'base64') {\n return util.binary.base64.encode(view);\n }\n\n // decode to text\n if(encoding === 'utf8') {\n return util.text.utf8.decode(view);\n }\n if(encoding === 'utf16') {\n return util.text.utf16.decode(view);\n }\n\n throw new Error('Invalid encoding: ' + encoding);\n};\n\n/** End Buffer w/UInt8Array backing */\n\n/**\n * Creates a buffer that stores bytes. A value may be given to populate the\n * buffer with data. This value can either be string of encoded bytes or a\n * regular string of characters. When passing a string of binary encoded\n * bytes, the encoding `raw` should be given. This is also the default. When\n * passing a string of characters, the encoding `utf8` should be given.\n *\n * @param [input] a string with encoded bytes to store in the buffer.\n * @param [encoding] (default: 'raw', other: 'utf8').\n */\nutil.createBuffer = function(input, encoding) {\n // TODO: deprecate, use new ByteBuffer() instead\n encoding = encoding || 'raw';\n if(input !== undefined && encoding === 'utf8') {\n input = util.encodeUtf8(input);\n }\n return new util.ByteBuffer(input);\n};\n\n/**\n * Fills a string with a particular value. If you want the string to be a byte\n * string, pass in String.fromCharCode(theByte).\n *\n * @param c the character to fill the string with, use String.fromCharCode\n * to fill the string with a byte value.\n * @param n the number of characters of value c to fill with.\n *\n * @return the filled string.\n */\nutil.fillString = function(c, n) {\n var s = '';\n while(n > 0) {\n if(n & 1) {\n s += c;\n }\n n >>>= 1;\n if(n > 0) {\n c += c;\n }\n }\n return s;\n};\n\n/**\n * Performs a per byte XOR between two byte strings and returns the result as a\n * string of bytes.\n *\n * @param s1 first string of bytes.\n * @param s2 second string of bytes.\n * @param n the number of bytes to XOR.\n *\n * @return the XOR'd result.\n */\nutil.xorBytes = function(s1, s2, n) {\n var s3 = '';\n var b = '';\n var t = '';\n var i = 0;\n var c = 0;\n for(; n > 0; --n, ++i) {\n b = s1.charCodeAt(i) ^ s2.charCodeAt(i);\n if(c >= 10) {\n s3 += t;\n t = '';\n c = 0;\n }\n t += String.fromCharCode(b);\n ++c;\n }\n s3 += t;\n return s3;\n};\n\n/**\n * Converts a hex string into a 'binary' encoded string of bytes.\n *\n * @param hex the hexadecimal string to convert.\n *\n * @return the binary-encoded string of bytes.\n */\nutil.hexToBytes = function(hex) {\n // TODO: deprecate: \"Deprecated. Use util.binary.hex.decode instead.\"\n var rval = '';\n var i = 0;\n if(hex.length & 1 == 1) {\n // odd number of characters, convert first character alone\n i = 1;\n rval += String.fromCharCode(parseInt(hex[0], 16));\n }\n // convert 2 characters (1 byte) at a time\n for(; i < hex.length; i += 2) {\n rval += String.fromCharCode(parseInt(hex.substr(i, 2), 16));\n }\n return rval;\n};\n\n/**\n * Converts a 'binary' encoded string of bytes to hex.\n *\n * @param bytes the byte string to convert.\n *\n * @return the string of hexadecimal characters.\n */\nutil.bytesToHex = function(bytes) {\n // TODO: deprecate: \"Deprecated. Use util.binary.hex.encode instead.\"\n return util.createBuffer(bytes).toHex();\n};\n\n/**\n * Converts an 32-bit integer to 4-big-endian byte string.\n *\n * @param i the integer.\n *\n * @return the byte string.\n */\nutil.int32ToBytes = function(i) {\n return (\n String.fromCharCode(i >> 24 & 0xFF) +\n String.fromCharCode(i >> 16 & 0xFF) +\n String.fromCharCode(i >> 8 & 0xFF) +\n String.fromCharCode(i & 0xFF));\n};\n\n// base64 characters, reverse mapping\nvar _base64 =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\nvar _base64Idx = [\n/*43 -43 = 0*/\n/*'+', 1, 2, 3,'/' */\n 62, -1, -1, -1, 63,\n\n/*'0','1','2','3','4','5','6','7','8','9' */\n 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n\n/*15, 16, 17,'=', 19, 20, 21 */\n -1, -1, -1, 64, -1, -1, -1,\n\n/*65 - 43 = 22*/\n/*'A','B','C','D','E','F','G','H','I','J','K','L','M', */\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\n\n/*'N','O','P','Q','R','S','T','U','V','W','X','Y','Z' */\n 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,\n\n/*91 - 43 = 48 */\n/*48, 49, 50, 51, 52, 53 */\n -1, -1, -1, -1, -1, -1,\n\n/*97 - 43 = 54*/\n/*'a','b','c','d','e','f','g','h','i','j','k','l','m' */\n 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,\n\n/*'n','o','p','q','r','s','t','u','v','w','x','y','z' */\n 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51\n];\n\n// base58 characters (Bitcoin alphabet)\nvar _base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n\n/**\n * Base64 encodes a 'binary' encoded string of bytes.\n *\n * @param input the binary encoded string of bytes to base64-encode.\n * @param maxline the maximum number of encoded characters per line to use,\n * defaults to none.\n *\n * @return the base64-encoded output.\n */\nutil.encode64 = function(input, maxline) {\n // TODO: deprecate: \"Deprecated. Use util.binary.base64.encode instead.\"\n var line = '';\n var output = '';\n var chr1, chr2, chr3;\n var i = 0;\n while(i < input.length) {\n chr1 = input.charCodeAt(i++);\n chr2 = input.charCodeAt(i++);\n chr3 = input.charCodeAt(i++);\n\n // encode 4 character group\n line += _base64.charAt(chr1 >> 2);\n line += _base64.charAt(((chr1 & 3) << 4) | (chr2 >> 4));\n if(isNaN(chr2)) {\n line += '==';\n } else {\n line += _base64.charAt(((chr2 & 15) << 2) | (chr3 >> 6));\n line += isNaN(chr3) ? '=' : _base64.charAt(chr3 & 63);\n }\n\n if(maxline && line.length > maxline) {\n output += line.substr(0, maxline) + '\\r\\n';\n line = line.substr(maxline);\n }\n }\n output += line;\n return output;\n};\n\n/**\n * Base64 decodes a string into a 'binary' encoded string of bytes.\n *\n * @param input the base64-encoded input.\n *\n * @return the binary encoded string.\n */\nutil.decode64 = function(input) {\n // TODO: deprecate: \"Deprecated. Use util.binary.base64.decode instead.\"\n\n // remove all non-base64 characters\n input = input.replace(/[^A-Za-z0-9\\+\\/\\=]/g, '');\n\n var output = '';\n var enc1, enc2, enc3, enc4;\n var i = 0;\n\n while(i < input.length) {\n enc1 = _base64Idx[input.charCodeAt(i++) - 43];\n enc2 = _base64Idx[input.charCodeAt(i++) - 43];\n enc3 = _base64Idx[input.charCodeAt(i++) - 43];\n enc4 = _base64Idx[input.charCodeAt(i++) - 43];\n\n output += String.fromCharCode((enc1 << 2) | (enc2 >> 4));\n if(enc3 !== 64) {\n // decoded at least 2 bytes\n output += String.fromCharCode(((enc2 & 15) << 4) | (enc3 >> 2));\n if(enc4 !== 64) {\n // decoded 3 bytes\n output += String.fromCharCode(((enc3 & 3) << 6) | enc4);\n }\n }\n }\n\n return output;\n};\n\n/**\n * Encodes the given string of characters (a standard JavaScript\n * string) as a binary encoded string where the bytes represent\n * a UTF-8 encoded string of characters. Non-ASCII characters will be\n * encoded as multiple bytes according to UTF-8.\n *\n * @param str a standard string of characters to encode.\n *\n * @return the binary encoded string.\n */\nutil.encodeUtf8 = function(str) {\n return unescape(encodeURIComponent(str));\n};\n\n/**\n * Decodes a binary encoded string that contains bytes that\n * represent a UTF-8 encoded string of characters -- into a\n * string of characters (a standard JavaScript string).\n *\n * @param str the binary encoded string to decode.\n *\n * @return the resulting standard string of characters.\n */\nutil.decodeUtf8 = function(str) {\n return decodeURIComponent(escape(str));\n};\n\n// binary encoding/decoding tools\n// FIXME: Experimental. Do not use yet.\nutil.binary = {\n raw: {},\n hex: {},\n base64: {},\n base58: {},\n baseN : {\n encode: baseN.encode,\n decode: baseN.decode\n }\n};\n\n/**\n * Encodes a Uint8Array as a binary-encoded string. This encoding uses\n * a value between 0 and 255 for each character.\n *\n * @param bytes the Uint8Array to encode.\n *\n * @return the binary-encoded string.\n */\nutil.binary.raw.encode = function(bytes) {\n return String.fromCharCode.apply(null, bytes);\n};\n\n/**\n * Decodes a binary-encoded string to a Uint8Array. This encoding uses\n * a value between 0 and 255 for each character.\n *\n * @param str the binary-encoded string to decode.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.binary.raw.decode = function(str, output, offset) {\n var out = output;\n if(!out) {\n out = new Uint8Array(str.length);\n }\n offset = offset || 0;\n var j = offset;\n for(var i = 0; i < str.length; ++i) {\n out[j++] = str.charCodeAt(i);\n }\n return output ? (j - offset) : out;\n};\n\n/**\n * Encodes a 'binary' string, ArrayBuffer, DataView, TypedArray, or\n * ByteBuffer as a string of hexadecimal characters.\n *\n * @param bytes the bytes to convert.\n *\n * @return the string of hexadecimal characters.\n */\nutil.binary.hex.encode = util.bytesToHex;\n\n/**\n * Decodes a hex-encoded string to a Uint8Array.\n *\n * @param hex the hexadecimal string to convert.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.binary.hex.decode = function(hex, output, offset) {\n var out = output;\n if(!out) {\n out = new Uint8Array(Math.ceil(hex.length / 2));\n }\n offset = offset || 0;\n var i = 0, j = offset;\n if(hex.length & 1) {\n // odd number of characters, convert first character alone\n i = 1;\n out[j++] = parseInt(hex[0], 16);\n }\n // convert 2 characters (1 byte) at a time\n for(; i < hex.length; i += 2) {\n out[j++] = parseInt(hex.substr(i, 2), 16);\n }\n return output ? (j - offset) : out;\n};\n\n/**\n * Base64-encodes a Uint8Array.\n *\n * @param input the Uint8Array to encode.\n * @param maxline the maximum number of encoded characters per line to use,\n * defaults to none.\n *\n * @return the base64-encoded output string.\n */\nutil.binary.base64.encode = function(input, maxline) {\n var line = '';\n var output = '';\n var chr1, chr2, chr3;\n var i = 0;\n while(i < input.byteLength) {\n chr1 = input[i++];\n chr2 = input[i++];\n chr3 = input[i++];\n\n // encode 4 character group\n line += _base64.charAt(chr1 >> 2);\n line += _base64.charAt(((chr1 & 3) << 4) | (chr2 >> 4));\n if(isNaN(chr2)) {\n line += '==';\n } else {\n line += _base64.charAt(((chr2 & 15) << 2) | (chr3 >> 6));\n line += isNaN(chr3) ? '=' : _base64.charAt(chr3 & 63);\n }\n\n if(maxline && line.length > maxline) {\n output += line.substr(0, maxline) + '\\r\\n';\n line = line.substr(maxline);\n }\n }\n output += line;\n return output;\n};\n\n/**\n * Decodes a base64-encoded string to a Uint8Array.\n *\n * @param input the base64-encoded input string.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.binary.base64.decode = function(input, output, offset) {\n var out = output;\n if(!out) {\n out = new Uint8Array(Math.ceil(input.length / 4) * 3);\n }\n\n // remove all non-base64 characters\n input = input.replace(/[^A-Za-z0-9\\+\\/\\=]/g, '');\n\n offset = offset || 0;\n var enc1, enc2, enc3, enc4;\n var i = 0, j = offset;\n\n while(i < input.length) {\n enc1 = _base64Idx[input.charCodeAt(i++) - 43];\n enc2 = _base64Idx[input.charCodeAt(i++) - 43];\n enc3 = _base64Idx[input.charCodeAt(i++) - 43];\n enc4 = _base64Idx[input.charCodeAt(i++) - 43];\n\n out[j++] = (enc1 << 2) | (enc2 >> 4);\n if(enc3 !== 64) {\n // decoded at least 2 bytes\n out[j++] = ((enc2 & 15) << 4) | (enc3 >> 2);\n if(enc4 !== 64) {\n // decoded 3 bytes\n out[j++] = ((enc3 & 3) << 6) | enc4;\n }\n }\n }\n\n // make sure result is the exact decoded length\n return output ? (j - offset) : out.subarray(0, j);\n};\n\n// add support for base58 encoding/decoding with Bitcoin alphabet\nutil.binary.base58.encode = function(input, maxline) {\n return util.binary.baseN.encode(input, _base58, maxline);\n};\nutil.binary.base58.decode = function(input, maxline) {\n return util.binary.baseN.decode(input, _base58, maxline);\n};\n\n// text encoding/decoding tools\n// FIXME: Experimental. Do not use yet.\nutil.text = {\n utf8: {},\n utf16: {}\n};\n\n/**\n * Encodes the given string as UTF-8 in a Uint8Array.\n *\n * @param str the string to encode.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.text.utf8.encode = function(str, output, offset) {\n str = util.encodeUtf8(str);\n var out = output;\n if(!out) {\n out = new Uint8Array(str.length);\n }\n offset = offset || 0;\n var j = offset;\n for(var i = 0; i < str.length; ++i) {\n out[j++] = str.charCodeAt(i);\n }\n return output ? (j - offset) : out;\n};\n\n/**\n * Decodes the UTF-8 contents from a Uint8Array.\n *\n * @param bytes the Uint8Array to decode.\n *\n * @return the resulting string.\n */\nutil.text.utf8.decode = function(bytes) {\n return util.decodeUtf8(String.fromCharCode.apply(null, bytes));\n};\n\n/**\n * Encodes the given string as UTF-16 in a Uint8Array.\n *\n * @param str the string to encode.\n * @param [output] an optional Uint8Array to write the output to; if it\n * is too small, an exception will be thrown.\n * @param [offset] the start offset for writing to the output (default: 0).\n *\n * @return the Uint8Array or the number of bytes written if output was given.\n */\nutil.text.utf16.encode = function(str, output, offset) {\n var out = output;\n if(!out) {\n out = new Uint8Array(str.length * 2);\n }\n var view = new Uint16Array(out.buffer);\n offset = offset || 0;\n var j = offset;\n var k = offset;\n for(var i = 0; i < str.length; ++i) {\n view[k++] = str.charCodeAt(i);\n j += 2;\n }\n return output ? (j - offset) : out;\n};\n\n/**\n * Decodes the UTF-16 contents from a Uint8Array.\n *\n * @param bytes the Uint8Array to decode.\n *\n * @return the resulting string.\n */\nutil.text.utf16.decode = function(bytes) {\n return String.fromCharCode.apply(null, new Uint16Array(bytes.buffer));\n};\n\n/**\n * Deflates the given data using a flash interface.\n *\n * @param api the flash interface.\n * @param bytes the data.\n * @param raw true to return only raw deflate data, false to include zlib\n * header and trailer.\n *\n * @return the deflated data as a string.\n */\nutil.deflate = function(api, bytes, raw) {\n bytes = util.decode64(api.deflate(util.encode64(bytes)).rval);\n\n // strip zlib header and trailer if necessary\n if(raw) {\n // zlib header is 2 bytes (CMF,FLG) where FLG indicates that\n // there is a 4-byte DICT (alder-32) block before the data if\n // its 5th bit is set\n var start = 2;\n var flg = bytes.charCodeAt(1);\n if(flg & 0x20) {\n start = 6;\n }\n // zlib trailer is 4 bytes of adler-32\n bytes = bytes.substring(start, bytes.length - 4);\n }\n\n return bytes;\n};\n\n/**\n * Inflates the given data using a flash interface.\n *\n * @param api the flash interface.\n * @param bytes the data.\n * @param raw true if the incoming data has no zlib header or trailer and is\n * raw DEFLATE data.\n *\n * @return the inflated data as a string, null on error.\n */\nutil.inflate = function(api, bytes, raw) {\n // TODO: add zlib header and trailer if necessary/possible\n var rval = api.inflate(util.encode64(bytes)).rval;\n return (rval === null) ? null : util.decode64(rval);\n};\n\n/**\n * Sets a storage object.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n * @param obj the storage object, null to remove.\n */\nvar _setStorageObject = function(api, id, obj) {\n if(!api) {\n throw new Error('WebStorage not available.');\n }\n\n var rval;\n if(obj === null) {\n rval = api.removeItem(id);\n } else {\n // json-encode and base64-encode object\n obj = util.encode64(JSON.stringify(obj));\n rval = api.setItem(id, obj);\n }\n\n // handle potential flash error\n if(typeof(rval) !== 'undefined' && rval.rval !== true) {\n var error = new Error(rval.error.message);\n error.id = rval.error.id;\n error.name = rval.error.name;\n throw error;\n }\n};\n\n/**\n * Gets a storage object.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n *\n * @return the storage object entry or null if none exists.\n */\nvar _getStorageObject = function(api, id) {\n if(!api) {\n throw new Error('WebStorage not available.');\n }\n\n // get the existing entry\n var rval = api.getItem(id);\n\n /* Note: We check api.init because we can't do (api == localStorage)\n on IE because of \"Class doesn't support Automation\" exception. Only\n the flash api has an init method so this works too, but we need a\n better solution in the future. */\n\n // flash returns item wrapped in an object, handle special case\n if(api.init) {\n if(rval.rval === null) {\n if(rval.error) {\n var error = new Error(rval.error.message);\n error.id = rval.error.id;\n error.name = rval.error.name;\n throw error;\n }\n // no error, but also no item\n rval = null;\n } else {\n rval = rval.rval;\n }\n }\n\n // handle decoding\n if(rval !== null) {\n // base64-decode and json-decode data\n rval = JSON.parse(util.decode64(rval));\n }\n\n return rval;\n};\n\n/**\n * Stores an item in local storage.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n * @param key the key for the item.\n * @param data the data for the item (any javascript object/primitive).\n */\nvar _setItem = function(api, id, key, data) {\n // get storage object\n var obj = _getStorageObject(api, id);\n if(obj === null) {\n // create a new storage object\n obj = {};\n }\n // update key\n obj[key] = data;\n\n // set storage object\n _setStorageObject(api, id, obj);\n};\n\n/**\n * Gets an item from local storage.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n * @param key the key for the item.\n *\n * @return the item.\n */\nvar _getItem = function(api, id, key) {\n // get storage object\n var rval = _getStorageObject(api, id);\n if(rval !== null) {\n // return data at key\n rval = (key in rval) ? rval[key] : null;\n }\n\n return rval;\n};\n\n/**\n * Removes an item from local storage.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n * @param key the key for the item.\n */\nvar _removeItem = function(api, id, key) {\n // get storage object\n var obj = _getStorageObject(api, id);\n if(obj !== null && key in obj) {\n // remove key\n delete obj[key];\n\n // see if entry has no keys remaining\n var empty = true;\n for(var prop in obj) {\n empty = false;\n break;\n }\n if(empty) {\n // remove entry entirely if no keys are left\n obj = null;\n }\n\n // set storage object\n _setStorageObject(api, id, obj);\n }\n};\n\n/**\n * Clears the local disk storage identified by the given ID.\n *\n * @param api the storage interface.\n * @param id the storage ID to use.\n */\nvar _clearItems = function(api, id) {\n _setStorageObject(api, id, null);\n};\n\n/**\n * Calls a storage function.\n *\n * @param func the function to call.\n * @param args the arguments for the function.\n * @param location the location argument.\n *\n * @return the return value from the function.\n */\nvar _callStorageFunction = function(func, args, location) {\n var rval = null;\n\n // default storage types\n if(typeof(location) === 'undefined') {\n location = ['web', 'flash'];\n }\n\n // apply storage types in order of preference\n var type;\n var done = false;\n var exception = null;\n for(var idx in location) {\n type = location[idx];\n try {\n if(type === 'flash' || type === 'both') {\n if(args[0] === null) {\n throw new Error('Flash local storage not available.');\n }\n rval = func.apply(this, args);\n done = (type === 'flash');\n }\n if(type === 'web' || type === 'both') {\n args[0] = localStorage;\n rval = func.apply(this, args);\n done = true;\n }\n } catch(ex) {\n exception = ex;\n }\n if(done) {\n break;\n }\n }\n\n if(!done) {\n throw exception;\n }\n\n return rval;\n};\n\n/**\n * Stores an item on local disk.\n *\n * The available types of local storage include 'flash', 'web', and 'both'.\n *\n * The type 'flash' refers to flash local storage (SharedObject). In order\n * to use flash local storage, the 'api' parameter must be valid. The type\n * 'web' refers to WebStorage, if supported by the browser. The type 'both'\n * refers to storing using both 'flash' and 'web', not just one or the\n * other.\n *\n * The location array should list the storage types to use in order of\n * preference:\n *\n * ['flash']: flash only storage\n * ['web']: web only storage\n * ['both']: try to store in both\n * ['flash','web']: store in flash first, but if not available, 'web'\n * ['web','flash']: store in web first, but if not available, 'flash'\n *\n * The location array defaults to: ['web', 'flash']\n *\n * @param api the flash interface, null to use only WebStorage.\n * @param id the storage ID to use.\n * @param key the key for the item.\n * @param data the data for the item (any javascript object/primitive).\n * @param location an array with the preferred types of storage to use.\n */\nutil.setItem = function(api, id, key, data, location) {\n _callStorageFunction(_setItem, arguments, location);\n};\n\n/**\n * Gets an item on local disk.\n *\n * Set setItem() for details on storage types.\n *\n * @param api the flash interface, null to use only WebStorage.\n * @param id the storage ID to use.\n * @param key the key for the item.\n * @param location an array with the preferred types of storage to use.\n *\n * @return the item.\n */\nutil.getItem = function(api, id, key, location) {\n return _callStorageFunction(_getItem, arguments, location);\n};\n\n/**\n * Removes an item on local disk.\n *\n * Set setItem() for details on storage types.\n *\n * @param api the flash interface.\n * @param id the storage ID to use.\n * @param key the key for the item.\n * @param location an array with the preferred types of storage to use.\n */\nutil.removeItem = function(api, id, key, location) {\n _callStorageFunction(_removeItem, arguments, location);\n};\n\n/**\n * Clears the local disk storage identified by the given ID.\n *\n * Set setItem() for details on storage types.\n *\n * @param api the flash interface if flash is available.\n * @param id the storage ID to use.\n * @param location an array with the preferred types of storage to use.\n */\nutil.clearItems = function(api, id, location) {\n _callStorageFunction(_clearItems, arguments, location);\n};\n\n/**\n * Parses the scheme, host, and port from an http(s) url.\n *\n * @param str the url string.\n *\n * @return the parsed url object or null if the url is invalid.\n */\nutil.parseUrl = function(str) {\n // FIXME: this regex looks a bit broken\n var regex = /^(https?):\\/\\/([^:&^\\/]*):?(\\d*)(.*)$/g;\n regex.lastIndex = 0;\n var m = regex.exec(str);\n var url = (m === null) ? null : {\n full: str,\n scheme: m[1],\n host: m[2],\n port: m[3],\n path: m[4]\n };\n if(url) {\n url.fullHost = url.host;\n if(url.port) {\n if(url.port !== 80 && url.scheme === 'http') {\n url.fullHost += ':' + url.port;\n } else if(url.port !== 443 && url.scheme === 'https') {\n url.fullHost += ':' + url.port;\n }\n } else if(url.scheme === 'http') {\n url.port = 80;\n } else if(url.scheme === 'https') {\n url.port = 443;\n }\n url.full = url.scheme + '://' + url.fullHost;\n }\n return url;\n};\n\n/* Storage for query variables */\nvar _queryVariables = null;\n\n/**\n * Returns the window location query variables. Query is parsed on the first\n * call and the same object is returned on subsequent calls. The mapping\n * is from keys to an array of values. Parameters without values will have\n * an object key set but no value added to the value array. Values are\n * unescaped.\n *\n * ...?k1=v1&k2=v2:\n * {\n * \"k1\": [\"v1\"],\n * \"k2\": [\"v2\"]\n * }\n *\n * ...?k1=v1&k1=v2:\n * {\n * \"k1\": [\"v1\", \"v2\"]\n * }\n *\n * ...?k1=v1&k2:\n * {\n * \"k1\": [\"v1\"],\n * \"k2\": []\n * }\n *\n * ...?k1=v1&k1:\n * {\n * \"k1\": [\"v1\"]\n * }\n *\n * ...?k1&k1:\n * {\n * \"k1\": []\n * }\n *\n * @param query the query string to parse (optional, default to cached\n * results from parsing window location search query).\n *\n * @return object mapping keys to variables.\n */\nutil.getQueryVariables = function(query) {\n var parse = function(q) {\n var rval = {};\n var kvpairs = q.split('&');\n for(var i = 0; i < kvpairs.length; i++) {\n var pos = kvpairs[i].indexOf('=');\n var key;\n var val;\n if(pos > 0) {\n key = kvpairs[i].substring(0, pos);\n val = kvpairs[i].substring(pos + 1);\n } else {\n key = kvpairs[i];\n val = null;\n }\n if(!(key in rval)) {\n rval[key] = [];\n }\n // disallow overriding object prototype keys\n if(!(key in Object.prototype) && val !== null) {\n rval[key].push(unescape(val));\n }\n }\n return rval;\n };\n\n var rval;\n if(typeof(query) === 'undefined') {\n // set cached variables if needed\n if(_queryVariables === null) {\n if(typeof(window) !== 'undefined' && window.location && window.location.search) {\n // parse window search query\n _queryVariables = parse(window.location.search.substring(1));\n } else {\n // no query variables available\n _queryVariables = {};\n }\n }\n rval = _queryVariables;\n } else {\n // parse given query\n rval = parse(query);\n }\n return rval;\n};\n\n/**\n * Parses a fragment into a path and query. This method will take a URI\n * fragment and break it up as if it were the main URI. For example:\n * /bar/baz?a=1&b=2\n * results in:\n * {\n * path: [\"bar\", \"baz\"],\n * query: {\"k1\": [\"v1\"], \"k2\": [\"v2\"]}\n * }\n *\n * @return object with a path array and query object.\n */\nutil.parseFragment = function(fragment) {\n // default to whole fragment\n var fp = fragment;\n var fq = '';\n // split into path and query if possible at the first '?'\n var pos = fragment.indexOf('?');\n if(pos > 0) {\n fp = fragment.substring(0, pos);\n fq = fragment.substring(pos + 1);\n }\n // split path based on '/' and ignore first element if empty\n var path = fp.split('/');\n if(path.length > 0 && path[0] === '') {\n path.shift();\n }\n // convert query into object\n var query = (fq === '') ? {} : util.getQueryVariables(fq);\n\n return {\n pathString: fp,\n queryString: fq,\n path: path,\n query: query\n };\n};\n\n/**\n * Makes a request out of a URI-like request string. This is intended to\n * be used where a fragment id (after a URI '#') is parsed as a URI with\n * path and query parts. The string should have a path beginning and\n * delimited by '/' and optional query parameters following a '?'. The\n * query should be a standard URL set of key value pairs delimited by\n * '&'. For backwards compatibility the initial '/' on the path is not\n * required. The request object has the following API, (fully described\n * in the method code):\n * {\n * path: .\n * query: ,\n * getPath(i): get part or all of the split path array,\n * getQuery(k, i): get part or all of a query key array,\n * getQueryLast(k, _default): get last element of a query key array.\n * }\n *\n * @return object with request parameters.\n */\nutil.makeRequest = function(reqString) {\n var frag = util.parseFragment(reqString);\n var req = {\n // full path string\n path: frag.pathString,\n // full query string\n query: frag.queryString,\n /**\n * Get path or element in path.\n *\n * @param i optional path index.\n *\n * @return path or part of path if i provided.\n */\n getPath: function(i) {\n return (typeof(i) === 'undefined') ? frag.path : frag.path[i];\n },\n /**\n * Get query, values for a key, or value for a key index.\n *\n * @param k optional query key.\n * @param i optional query key index.\n *\n * @return query, values for a key, or value for a key index.\n */\n getQuery: function(k, i) {\n var rval;\n if(typeof(k) === 'undefined') {\n rval = frag.query;\n } else {\n rval = frag.query[k];\n if(rval && typeof(i) !== 'undefined') {\n rval = rval[i];\n }\n }\n return rval;\n },\n getQueryLast: function(k, _default) {\n var rval;\n var vals = req.getQuery(k);\n if(vals) {\n rval = vals[vals.length - 1];\n } else {\n rval = _default;\n }\n return rval;\n }\n };\n return req;\n};\n\n/**\n * Makes a URI out of a path, an object with query parameters, and a\n * fragment. Uses jQuery.param() internally for query string creation.\n * If the path is an array, it will be joined with '/'.\n *\n * @param path string path or array of strings.\n * @param query object with query parameters. (optional)\n * @param fragment fragment string. (optional)\n *\n * @return string object with request parameters.\n */\nutil.makeLink = function(path, query, fragment) {\n // join path parts if needed\n path = jQuery.isArray(path) ? path.join('/') : path;\n\n var qstr = jQuery.param(query || {});\n fragment = fragment || '';\n return path +\n ((qstr.length > 0) ? ('?' + qstr) : '') +\n ((fragment.length > 0) ? ('#' + fragment) : '');\n};\n\n/**\n * Check if an object is empty.\n *\n * Taken from:\n * http://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object-from-json/679937#679937\n *\n * @param object the object to check.\n */\nutil.isEmpty = function(obj) {\n for(var prop in obj) {\n if(obj.hasOwnProperty(prop)) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * Format with simple printf-style interpolation.\n *\n * %%: literal '%'\n * %s,%o: convert next argument into a string.\n *\n * @param format the string to format.\n * @param ... arguments to interpolate into the format string.\n */\nutil.format = function(format) {\n var re = /%./g;\n // current match\n var match;\n // current part\n var part;\n // current arg index\n var argi = 0;\n // collected parts to recombine later\n var parts = [];\n // last index found\n var last = 0;\n // loop while matches remain\n while((match = re.exec(format))) {\n part = format.substring(last, re.lastIndex - 2);\n // don't add empty strings (ie, parts between %s%s)\n if(part.length > 0) {\n parts.push(part);\n }\n last = re.lastIndex;\n // switch on % code\n var code = match[0][1];\n switch(code) {\n case 's':\n case 'o':\n // check if enough arguments were given\n if(argi < arguments.length) {\n parts.push(arguments[argi++ + 1]);\n } else {\n parts.push('');\n }\n break;\n // FIXME: do proper formating for numbers, etc\n //case 'f':\n //case 'd':\n case '%':\n parts.push('%');\n break;\n default:\n parts.push('<%' + code + '?>');\n }\n }\n // add trailing part of format string\n parts.push(format.substring(last));\n return parts.join('');\n};\n\n/**\n * Formats a number.\n *\n * http://snipplr.com/view/5945/javascript-numberformat--ported-from-php/\n */\nutil.formatNumber = function(number, decimals, dec_point, thousands_sep) {\n // http://kevin.vanzonneveld.net\n // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)\n // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)\n // + bugfix by: Michael White (http://crestidg.com)\n // + bugfix by: Benjamin Lupton\n // + bugfix by: Allan Jensen (http://www.winternet.no)\n // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)\n // * example 1: number_format(1234.5678, 2, '.', '');\n // * returns 1: 1234.57\n\n var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;\n var d = dec_point === undefined ? ',' : dec_point;\n var t = thousands_sep === undefined ?\n '.' : thousands_sep, s = n < 0 ? '-' : '';\n var i = parseInt((n = Math.abs(+n || 0).toFixed(c)), 10) + '';\n var j = (i.length > 3) ? i.length % 3 : 0;\n return s + (j ? i.substr(0, j) + t : '') +\n i.substr(j).replace(/(\\d{3})(?=\\d)/g, '$1' + t) +\n (c ? d + Math.abs(n - i).toFixed(c).slice(2) : '');\n};\n\n/**\n * Formats a byte size.\n *\n * http://snipplr.com/view/5949/format-humanize-file-byte-size-presentation-in-javascript/\n */\nutil.formatSize = function(size) {\n if(size >= 1073741824) {\n size = util.formatNumber(size / 1073741824, 2, '.', '') + ' GiB';\n } else if(size >= 1048576) {\n size = util.formatNumber(size / 1048576, 2, '.', '') + ' MiB';\n } else if(size >= 1024) {\n size = util.formatNumber(size / 1024, 0) + ' KiB';\n } else {\n size = util.formatNumber(size, 0) + ' bytes';\n }\n return size;\n};\n\n/**\n * Converts an IPv4 or IPv6 string representation into bytes (in network order).\n *\n * @param ip the IPv4 or IPv6 address to convert.\n *\n * @return the 4-byte IPv6 or 16-byte IPv6 address or null if the address can't\n * be parsed.\n */\nutil.bytesFromIP = function(ip) {\n if(ip.indexOf('.') !== -1) {\n return util.bytesFromIPv4(ip);\n }\n if(ip.indexOf(':') !== -1) {\n return util.bytesFromIPv6(ip);\n }\n return null;\n};\n\n/**\n * Converts an IPv4 string representation into bytes (in network order).\n *\n * @param ip the IPv4 address to convert.\n *\n * @return the 4-byte address or null if the address can't be parsed.\n */\nutil.bytesFromIPv4 = function(ip) {\n ip = ip.split('.');\n if(ip.length !== 4) {\n return null;\n }\n var b = util.createBuffer();\n for(var i = 0; i < ip.length; ++i) {\n var num = parseInt(ip[i], 10);\n if(isNaN(num)) {\n return null;\n }\n b.putByte(num);\n }\n return b.getBytes();\n};\n\n/**\n * Converts an IPv6 string representation into bytes (in network order).\n *\n * @param ip the IPv6 address to convert.\n *\n * @return the 16-byte address or null if the address can't be parsed.\n */\nutil.bytesFromIPv6 = function(ip) {\n var blanks = 0;\n ip = ip.split(':').filter(function(e) {\n if(e.length === 0) ++blanks;\n return true;\n });\n var zeros = (8 - ip.length + blanks) * 2;\n var b = util.createBuffer();\n for(var i = 0; i < 8; ++i) {\n if(!ip[i] || ip[i].length === 0) {\n b.fillWithByte(0, zeros);\n zeros = 0;\n continue;\n }\n var bytes = util.hexToBytes(ip[i]);\n if(bytes.length < 2) {\n b.putByte(0);\n }\n b.putBytes(bytes);\n }\n return b.getBytes();\n};\n\n/**\n * Converts 4-bytes into an IPv4 string representation or 16-bytes into\n * an IPv6 string representation. The bytes must be in network order.\n *\n * @param bytes the bytes to convert.\n *\n * @return the IPv4 or IPv6 string representation if 4 or 16 bytes,\n * respectively, are given, otherwise null.\n */\nutil.bytesToIP = function(bytes) {\n if(bytes.length === 4) {\n return util.bytesToIPv4(bytes);\n }\n if(bytes.length === 16) {\n return util.bytesToIPv6(bytes);\n }\n return null;\n};\n\n/**\n * Converts 4-bytes into an IPv4 string representation. The bytes must be\n * in network order.\n *\n * @param bytes the bytes to convert.\n *\n * @return the IPv4 string representation or null for an invalid # of bytes.\n */\nutil.bytesToIPv4 = function(bytes) {\n if(bytes.length !== 4) {\n return null;\n }\n var ip = [];\n for(var i = 0; i < bytes.length; ++i) {\n ip.push(bytes.charCodeAt(i));\n }\n return ip.join('.');\n};\n\n/**\n * Converts 16-bytes into an IPv16 string representation. The bytes must be\n * in network order.\n *\n * @param bytes the bytes to convert.\n *\n * @return the IPv16 string representation or null for an invalid # of bytes.\n */\nutil.bytesToIPv6 = function(bytes) {\n if(bytes.length !== 16) {\n return null;\n }\n var ip = [];\n var zeroGroups = [];\n var zeroMaxGroup = 0;\n for(var i = 0; i < bytes.length; i += 2) {\n var hex = util.bytesToHex(bytes[i] + bytes[i + 1]);\n // canonicalize zero representation\n while(hex[0] === '0' && hex !== '0') {\n hex = hex.substr(1);\n }\n if(hex === '0') {\n var last = zeroGroups[zeroGroups.length - 1];\n var idx = ip.length;\n if(!last || idx !== last.end + 1) {\n zeroGroups.push({start: idx, end: idx});\n } else {\n last.end = idx;\n if((last.end - last.start) >\n (zeroGroups[zeroMaxGroup].end - zeroGroups[zeroMaxGroup].start)) {\n zeroMaxGroup = zeroGroups.length - 1;\n }\n }\n }\n ip.push(hex);\n }\n if(zeroGroups.length > 0) {\n var group = zeroGroups[zeroMaxGroup];\n // only shorten group of length > 0\n if(group.end - group.start > 0) {\n ip.splice(group.start, group.end - group.start + 1, '');\n if(group.start === 0) {\n ip.unshift('');\n }\n if(group.end === 7) {\n ip.push('');\n }\n }\n }\n return ip.join(':');\n};\n\n/**\n * Estimates the number of processes that can be run concurrently. If\n * creating Web Workers, keep in mind that the main JavaScript process needs\n * its own core.\n *\n * @param options the options to use:\n * update true to force an update (not use the cached value).\n * @param callback(err, max) called once the operation completes.\n */\nutil.estimateCores = function(options, callback) {\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n if('cores' in util && !options.update) {\n return callback(null, util.cores);\n }\n if(typeof navigator !== 'undefined' &&\n 'hardwareConcurrency' in navigator &&\n navigator.hardwareConcurrency > 0) {\n util.cores = navigator.hardwareConcurrency;\n return callback(null, util.cores);\n }\n if(typeof Worker === 'undefined') {\n // workers not available\n util.cores = 1;\n return callback(null, util.cores);\n }\n if(typeof Blob === 'undefined') {\n // can't estimate, default to 2\n util.cores = 2;\n return callback(null, util.cores);\n }\n\n // create worker concurrency estimation code as blob\n var blobUrl = URL.createObjectURL(new Blob(['(',\n function() {\n self.addEventListener('message', function(e) {\n // run worker for 4 ms\n var st = Date.now();\n var et = st + 4;\n while(Date.now() < et);\n self.postMessage({st: st, et: et});\n });\n }.toString(),\n ')()'], {type: 'application/javascript'}));\n\n // take 5 samples using 16 workers\n sample([], 5, 16);\n\n function sample(max, samples, numWorkers) {\n if(samples === 0) {\n // get overlap average\n var avg = Math.floor(max.reduce(function(avg, x) {\n return avg + x;\n }, 0) / max.length);\n util.cores = Math.max(1, avg);\n URL.revokeObjectURL(blobUrl);\n return callback(null, util.cores);\n }\n map(numWorkers, function(err, results) {\n max.push(reduce(numWorkers, results));\n sample(max, samples - 1, numWorkers);\n });\n }\n\n function map(numWorkers, callback) {\n var workers = [];\n var results = [];\n for(var i = 0; i < numWorkers; ++i) {\n var worker = new Worker(blobUrl);\n worker.addEventListener('message', function(e) {\n results.push(e.data);\n if(results.length === numWorkers) {\n for(var i = 0; i < numWorkers; ++i) {\n workers[i].terminate();\n }\n callback(null, results);\n }\n });\n workers.push(worker);\n }\n for(var i = 0; i < numWorkers; ++i) {\n workers[i].postMessage(i);\n }\n }\n\n function reduce(numWorkers, results) {\n // find overlapping time windows\n var overlaps = [];\n for(var n = 0; n < numWorkers; ++n) {\n var r1 = results[n];\n var overlap = overlaps[n] = [];\n for(var i = 0; i < numWorkers; ++i) {\n if(n === i) {\n continue;\n }\n var r2 = results[i];\n if((r1.st > r2.st && r1.st < r2.et) ||\n (r2.st > r1.st && r2.st < r1.et)) {\n overlap.push(i);\n }\n }\n }\n // get maximum overlaps ... don't include overlapping worker itself\n // as the main JS process was also being scheduled during the work and\n // would have to be subtracted from the estimate anyway\n return overlaps.reduce(function(max, overlap) {\n return Math.max(max, overlap.length);\n }, 0);\n }\n};\n","/**\n * Javascript implementation of X.509 and related components (such as\n * Certification Signing Requests) of a Public Key Infrastructure.\n *\n * @author Dave Longley\n *\n * Copyright (c) 2010-2014 Digital Bazaar, Inc.\n *\n * The ASN.1 representation of an X.509v3 certificate is as follows\n * (see RFC 2459):\n *\n * Certificate ::= SEQUENCE {\n * tbsCertificate TBSCertificate,\n * signatureAlgorithm AlgorithmIdentifier,\n * signatureValue BIT STRING\n * }\n *\n * TBSCertificate ::= SEQUENCE {\n * version [0] EXPLICIT Version DEFAULT v1,\n * serialNumber CertificateSerialNumber,\n * signature AlgorithmIdentifier,\n * issuer Name,\n * validity Validity,\n * subject Name,\n * subjectPublicKeyInfo SubjectPublicKeyInfo,\n * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,\n * -- If present, version shall be v2 or v3\n * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,\n * -- If present, version shall be v2 or v3\n * extensions [3] EXPLICIT Extensions OPTIONAL\n * -- If present, version shall be v3\n * }\n *\n * Version ::= INTEGER { v1(0), v2(1), v3(2) }\n *\n * CertificateSerialNumber ::= INTEGER\n *\n * Name ::= CHOICE {\n * // only one possible choice for now\n * RDNSequence\n * }\n *\n * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName\n *\n * RelativeDistinguishedName ::= SET OF AttributeTypeAndValue\n *\n * AttributeTypeAndValue ::= SEQUENCE {\n * type AttributeType,\n * value AttributeValue\n * }\n * AttributeType ::= OBJECT IDENTIFIER\n * AttributeValue ::= ANY DEFINED BY AttributeType\n *\n * Validity ::= SEQUENCE {\n * notBefore Time,\n * notAfter Time\n * }\n *\n * Time ::= CHOICE {\n * utcTime UTCTime,\n * generalTime GeneralizedTime\n * }\n *\n * UniqueIdentifier ::= BIT STRING\n *\n * SubjectPublicKeyInfo ::= SEQUENCE {\n * algorithm AlgorithmIdentifier,\n * subjectPublicKey BIT STRING\n * }\n *\n * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension\n *\n * Extension ::= SEQUENCE {\n * extnID OBJECT IDENTIFIER,\n * critical BOOLEAN DEFAULT FALSE,\n * extnValue OCTET STRING\n * }\n *\n * The only key algorithm currently supported for PKI is RSA.\n *\n * RSASSA-PSS signatures are described in RFC 3447 and RFC 4055.\n *\n * PKCS#10 v1.7 describes certificate signing requests:\n *\n * CertificationRequestInfo:\n *\n * CertificationRequestInfo ::= SEQUENCE {\n * version INTEGER { v1(0) } (v1,...),\n * subject Name,\n * subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},\n * attributes [0] Attributes{{ CRIAttributes }}\n * }\n *\n * Attributes { ATTRIBUTE:IOSet } ::= SET OF Attribute{{ IOSet }}\n *\n * CRIAttributes ATTRIBUTE ::= {\n * ... -- add any locally defined attributes here -- }\n *\n * Attribute { ATTRIBUTE:IOSet } ::= SEQUENCE {\n * type ATTRIBUTE.&id({IOSet}),\n * values SET SIZE(1..MAX) OF ATTRIBUTE.&Type({IOSet}{@type})\n * }\n *\n * CertificationRequest ::= SEQUENCE {\n * certificationRequestInfo CertificationRequestInfo,\n * signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }},\n * signature BIT STRING\n * }\n */\nvar forge = require('./forge');\nrequire('./aes');\nrequire('./asn1');\nrequire('./des');\nrequire('./md');\nrequire('./mgf');\nrequire('./oids');\nrequire('./pem');\nrequire('./pss');\nrequire('./rsa');\nrequire('./util');\n\n// shortcut for asn.1 API\nvar asn1 = forge.asn1;\n\n/* Public Key Infrastructure (PKI) implementation. */\nvar pki = module.exports = forge.pki = forge.pki || {};\nvar oids = pki.oids;\n\n// short name OID mappings\nvar _shortNames = {};\n_shortNames['CN'] = oids['commonName'];\n_shortNames['commonName'] = 'CN';\n_shortNames['C'] = oids['countryName'];\n_shortNames['countryName'] = 'C';\n_shortNames['L'] = oids['localityName'];\n_shortNames['localityName'] = 'L';\n_shortNames['ST'] = oids['stateOrProvinceName'];\n_shortNames['stateOrProvinceName'] = 'ST';\n_shortNames['O'] = oids['organizationName'];\n_shortNames['organizationName'] = 'O';\n_shortNames['OU'] = oids['organizationalUnitName'];\n_shortNames['organizationalUnitName'] = 'OU';\n_shortNames['E'] = oids['emailAddress'];\n_shortNames['emailAddress'] = 'E';\n\n// validator for an SubjectPublicKeyInfo structure\n// Note: Currently only works with an RSA public key\nvar publicKeyValidator = forge.pki.rsa.publicKeyValidator;\n\n// validator for an X.509v3 certificate\nvar x509CertificateValidator = {\n name: 'Certificate',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'Certificate.TBSCertificate',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'tbsCertificate',\n value: [{\n name: 'Certificate.TBSCertificate.version',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n optional: true,\n value: [{\n name: 'Certificate.TBSCertificate.version.integer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'certVersion'\n }]\n }, {\n name: 'Certificate.TBSCertificate.serialNumber',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'certSerialNumber'\n }, {\n name: 'Certificate.TBSCertificate.signature',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'Certificate.TBSCertificate.signature.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'certinfoSignatureOid'\n }, {\n name: 'Certificate.TBSCertificate.signature.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n optional: true,\n captureAsn1: 'certinfoSignatureParams'\n }]\n }, {\n name: 'Certificate.TBSCertificate.issuer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'certIssuer'\n }, {\n name: 'Certificate.TBSCertificate.validity',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n // Note: UTC and generalized times may both appear so the capture\n // names are based on their detected order, the names used below\n // are only for the common case, which validity time really means\n // \"notBefore\" and which means \"notAfter\" will be determined by order\n value: [{\n // notBefore (Time) (UTC time case)\n name: 'Certificate.TBSCertificate.validity.notBefore (utc)',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.UTCTIME,\n constructed: false,\n optional: true,\n capture: 'certValidity1UTCTime'\n }, {\n // notBefore (Time) (generalized time case)\n name: 'Certificate.TBSCertificate.validity.notBefore (generalized)',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.GENERALIZEDTIME,\n constructed: false,\n optional: true,\n capture: 'certValidity2GeneralizedTime'\n }, {\n // notAfter (Time) (only UTC time is supported)\n name: 'Certificate.TBSCertificate.validity.notAfter (utc)',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.UTCTIME,\n constructed: false,\n optional: true,\n capture: 'certValidity3UTCTime'\n }, {\n // notAfter (Time) (only UTC time is supported)\n name: 'Certificate.TBSCertificate.validity.notAfter (generalized)',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.GENERALIZEDTIME,\n constructed: false,\n optional: true,\n capture: 'certValidity4GeneralizedTime'\n }]\n }, {\n // Name (subject) (RDNSequence)\n name: 'Certificate.TBSCertificate.subject',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'certSubject'\n },\n // SubjectPublicKeyInfo\n publicKeyValidator,\n {\n // issuerUniqueID (optional)\n name: 'Certificate.TBSCertificate.issuerUniqueID',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 1,\n constructed: true,\n optional: true,\n value: [{\n name: 'Certificate.TBSCertificate.issuerUniqueID.id',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n // TODO: support arbitrary bit length ids\n captureBitStringValue: 'certIssuerUniqueId'\n }]\n }, {\n // subjectUniqueID (optional)\n name: 'Certificate.TBSCertificate.subjectUniqueID',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 2,\n constructed: true,\n optional: true,\n value: [{\n name: 'Certificate.TBSCertificate.subjectUniqueID.id',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n // TODO: support arbitrary bit length ids\n captureBitStringValue: 'certSubjectUniqueId'\n }]\n }, {\n // Extensions (optional)\n name: 'Certificate.TBSCertificate.extensions',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 3,\n constructed: true,\n captureAsn1: 'certExtensions',\n optional: true\n }]\n }, {\n // AlgorithmIdentifier (signature algorithm)\n name: 'Certificate.signatureAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // algorithm\n name: 'Certificate.signatureAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'certSignatureOid'\n }, {\n name: 'Certificate.TBSCertificate.signature.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n optional: true,\n captureAsn1: 'certSignatureParams'\n }]\n }, {\n // SignatureValue\n name: 'Certificate.signatureValue',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n captureBitStringValue: 'certSignature'\n }]\n};\n\nvar rsassaPssParameterValidator = {\n name: 'rsapss',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'rsapss.hashAlgorithm',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n value: [{\n name: 'rsapss.hashAlgorithm.AlgorithmIdentifier',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.SEQUENCE,\n constructed: true,\n optional: true,\n value: [{\n name: 'rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'hashOid'\n /* parameter block omitted, for SHA1 NULL anyhow. */\n }]\n }]\n }, {\n name: 'rsapss.maskGenAlgorithm',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 1,\n constructed: true,\n value: [{\n name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.SEQUENCE,\n constructed: true,\n optional: true,\n value: [{\n name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'maskGenOid'\n }, {\n name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.params',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'maskGenHashOid'\n /* parameter block omitted, for SHA1 NULL anyhow. */\n }]\n }]\n }]\n }, {\n name: 'rsapss.saltLength',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 2,\n optional: true,\n value: [{\n name: 'rsapss.saltLength.saltLength',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.INTEGER,\n constructed: false,\n capture: 'saltLength'\n }]\n }, {\n name: 'rsapss.trailerField',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 3,\n optional: true,\n value: [{\n name: 'rsapss.trailer.trailer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Class.INTEGER,\n constructed: false,\n capture: 'trailer'\n }]\n }]\n};\n\n// validator for a CertificationRequestInfo structure\nvar certificationRequestInfoValidator = {\n name: 'CertificationRequestInfo',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'certificationRequestInfo',\n value: [{\n name: 'CertificationRequestInfo.integer',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.INTEGER,\n constructed: false,\n capture: 'certificationRequestInfoVersion'\n }, {\n // Name (subject) (RDNSequence)\n name: 'CertificationRequestInfo.subject',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'certificationRequestInfoSubject'\n },\n // SubjectPublicKeyInfo\n publicKeyValidator,\n {\n name: 'CertificationRequestInfo.attributes',\n tagClass: asn1.Class.CONTEXT_SPECIFIC,\n type: 0,\n constructed: true,\n optional: true,\n capture: 'certificationRequestInfoAttributes',\n value: [{\n name: 'CertificationRequestInfo.attributes',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n name: 'CertificationRequestInfo.attributes.type',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false\n }, {\n name: 'CertificationRequestInfo.attributes.value',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SET,\n constructed: true\n }]\n }]\n }]\n};\n\n// validator for a CertificationRequest structure\nvar certificationRequestValidator = {\n name: 'CertificationRequest',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n captureAsn1: 'csr',\n value: [\n certificationRequestInfoValidator, {\n // AlgorithmIdentifier (signature algorithm)\n name: 'CertificationRequest.signatureAlgorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.SEQUENCE,\n constructed: true,\n value: [{\n // algorithm\n name: 'CertificationRequest.signatureAlgorithm.algorithm',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.OID,\n constructed: false,\n capture: 'csrSignatureOid'\n }, {\n name: 'CertificationRequest.signatureAlgorithm.parameters',\n tagClass: asn1.Class.UNIVERSAL,\n optional: true,\n captureAsn1: 'csrSignatureParams'\n }]\n }, {\n // signature\n name: 'CertificationRequest.signature',\n tagClass: asn1.Class.UNIVERSAL,\n type: asn1.Type.BITSTRING,\n constructed: false,\n captureBitStringValue: 'csrSignature'\n }\n ]\n};\n\n/**\n * Converts an RDNSequence of ASN.1 DER-encoded RelativeDistinguishedName\n * sets into an array with objects that have type and value properties.\n *\n * @param rdn the RDNSequence to convert.\n * @param md a message digest to append type and value to if provided.\n */\npki.RDNAttributesAsArray = function(rdn, md) {\n var rval = [];\n\n // each value in 'rdn' in is a SET of RelativeDistinguishedName\n var set, attr, obj;\n for(var si = 0; si < rdn.value.length; ++si) {\n // get the RelativeDistinguishedName set\n set = rdn.value[si];\n\n // each value in the SET is an AttributeTypeAndValue sequence\n // containing first a type (an OID) and second a value (defined by\n // the OID)\n for(var i = 0; i < set.value.length; ++i) {\n obj = {};\n attr = set.value[i];\n obj.type = asn1.derToOid(attr.value[0].value);\n obj.value = attr.value[1].value;\n obj.valueTagClass = attr.value[1].type;\n // if the OID is known, get its name and short name\n if(obj.type in oids) {\n obj.name = oids[obj.type];\n if(obj.name in _shortNames) {\n obj.shortName = _shortNames[obj.name];\n }\n }\n if(md) {\n md.update(obj.type);\n md.update(obj.value);\n }\n rval.push(obj);\n }\n }\n\n return rval;\n};\n\n/**\n * Converts ASN.1 CRIAttributes into an array with objects that have type and\n * value properties.\n *\n * @param attributes the CRIAttributes to convert.\n */\npki.CRIAttributesAsArray = function(attributes) {\n var rval = [];\n\n // each value in 'attributes' in is a SEQUENCE with an OID and a SET\n for(var si = 0; si < attributes.length; ++si) {\n // get the attribute sequence\n var seq = attributes[si];\n\n // each value in the SEQUENCE containing first a type (an OID) and\n // second a set of values (defined by the OID)\n var type = asn1.derToOid(seq.value[0].value);\n var values = seq.value[1].value;\n for(var vi = 0; vi < values.length; ++vi) {\n var obj = {};\n obj.type = type;\n obj.value = values[vi].value;\n obj.valueTagClass = values[vi].type;\n // if the OID is known, get its name and short name\n if(obj.type in oids) {\n obj.name = oids[obj.type];\n if(obj.name in _shortNames) {\n obj.shortName = _shortNames[obj.name];\n }\n }\n // parse extensions\n if(obj.type === oids.extensionRequest) {\n obj.extensions = [];\n for(var ei = 0; ei < obj.value.length; ++ei) {\n obj.extensions.push(pki.certificateExtensionFromAsn1(obj.value[ei]));\n }\n }\n rval.push(obj);\n }\n }\n\n return rval;\n};\n\n/**\n * Gets an issuer or subject attribute from its name, type, or short name.\n *\n * @param obj the issuer or subject object.\n * @param options a short name string or an object with:\n * shortName the short name for the attribute.\n * name the name for the attribute.\n * type the type for the attribute.\n *\n * @return the attribute.\n */\nfunction _getAttribute(obj, options) {\n if(typeof options === 'string') {\n options = {shortName: options};\n }\n\n var rval = null;\n var attr;\n for(var i = 0; rval === null && i < obj.attributes.length; ++i) {\n attr = obj.attributes[i];\n if(options.type && options.type === attr.type) {\n rval = attr;\n } else if(options.name && options.name === attr.name) {\n rval = attr;\n } else if(options.shortName && options.shortName === attr.shortName) {\n rval = attr;\n }\n }\n return rval;\n}\n\n/**\n * Converts signature parameters from ASN.1 structure.\n *\n * Currently only RSASSA-PSS supported. The PKCS#1 v1.5 signature scheme had\n * no parameters.\n *\n * RSASSA-PSS-params ::= SEQUENCE {\n * hashAlgorithm [0] HashAlgorithm DEFAULT\n * sha1Identifier,\n * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT\n * mgf1SHA1Identifier,\n * saltLength [2] INTEGER DEFAULT 20,\n * trailerField [3] INTEGER DEFAULT 1\n * }\n *\n * HashAlgorithm ::= AlgorithmIdentifier\n *\n * MaskGenAlgorithm ::= AlgorithmIdentifier\n *\n * AlgorithmIdentifer ::= SEQUENCE {\n * algorithm OBJECT IDENTIFIER,\n * parameters ANY DEFINED BY algorithm OPTIONAL\n * }\n *\n * @param oid The OID specifying the signature algorithm\n * @param obj The ASN.1 structure holding the parameters\n * @param fillDefaults Whether to use return default values where omitted\n * @return signature parameter object\n */\nvar _readSignatureParameters = function(oid, obj, fillDefaults) {\n var params = {};\n\n if(oid !== oids['RSASSA-PSS']) {\n return params;\n }\n\n if(fillDefaults) {\n params = {\n hash: {\n algorithmOid: oids['sha1']\n },\n mgf: {\n algorithmOid: oids['mgf1'],\n hash: {\n algorithmOid: oids['sha1']\n }\n },\n saltLength: 20\n };\n }\n\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, rsassaPssParameterValidator, capture, errors)) {\n var error = new Error('Cannot read RSASSA-PSS parameter block.');\n error.errors = errors;\n throw error;\n }\n\n if(capture.hashOid !== undefined) {\n params.hash = params.hash || {};\n params.hash.algorithmOid = asn1.derToOid(capture.hashOid);\n }\n\n if(capture.maskGenOid !== undefined) {\n params.mgf = params.mgf || {};\n params.mgf.algorithmOid = asn1.derToOid(capture.maskGenOid);\n params.mgf.hash = params.mgf.hash || {};\n params.mgf.hash.algorithmOid = asn1.derToOid(capture.maskGenHashOid);\n }\n\n if(capture.saltLength !== undefined) {\n params.saltLength = capture.saltLength.charCodeAt(0);\n }\n\n return params;\n};\n\n/**\n * Converts an X.509 certificate from PEM format.\n *\n * Note: If the certificate is to be verified then compute hash should\n * be set to true. This will scan the TBSCertificate part of the ASN.1\n * object while it is converted so it doesn't need to be converted back\n * to ASN.1-DER-encoding later.\n *\n * @param pem the PEM-formatted certificate.\n * @param computeHash true to compute the hash for verification.\n * @param strict true to be strict when checking ASN.1 value lengths, false to\n * allow truncated values (default: true).\n *\n * @return the certificate.\n */\npki.certificateFromPem = function(pem, computeHash, strict) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'CERTIFICATE' &&\n msg.type !== 'X509 CERTIFICATE' &&\n msg.type !== 'TRUSTED CERTIFICATE') {\n var error = new Error(\n 'Could not convert certificate from PEM; PEM header type ' +\n 'is not \"CERTIFICATE\", \"X509 CERTIFICATE\", or \"TRUSTED CERTIFICATE\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error(\n 'Could not convert certificate from PEM; PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body, strict);\n\n return pki.certificateFromAsn1(obj, computeHash);\n};\n\n/**\n * Converts an X.509 certificate to PEM format.\n *\n * @param cert the certificate.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted certificate.\n */\npki.certificateToPem = function(cert, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'CERTIFICATE',\n body: asn1.toDer(pki.certificateToAsn1(cert)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Converts an RSA public key from PEM format.\n *\n * @param pem the PEM-formatted public key.\n *\n * @return the public key.\n */\npki.publicKeyFromPem = function(pem) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'PUBLIC KEY' && msg.type !== 'RSA PUBLIC KEY') {\n var error = new Error('Could not convert public key from PEM; PEM header ' +\n 'type is not \"PUBLIC KEY\" or \"RSA PUBLIC KEY\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert public key from PEM; PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body);\n\n return pki.publicKeyFromAsn1(obj);\n};\n\n/**\n * Converts an RSA public key to PEM format (using a SubjectPublicKeyInfo).\n *\n * @param key the public key.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted public key.\n */\npki.publicKeyToPem = function(key, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'PUBLIC KEY',\n body: asn1.toDer(pki.publicKeyToAsn1(key)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Converts an RSA public key to PEM format (using an RSAPublicKey).\n *\n * @param key the public key.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted public key.\n */\npki.publicKeyToRSAPublicKeyPem = function(key, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'RSA PUBLIC KEY',\n body: asn1.toDer(pki.publicKeyToRSAPublicKey(key)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Gets a fingerprint for the given public key.\n *\n * @param options the options to use.\n * [md] the message digest object to use (defaults to forge.md.sha1).\n * [type] the type of fingerprint, such as 'RSAPublicKey',\n * 'SubjectPublicKeyInfo' (defaults to 'RSAPublicKey').\n * [encoding] an alternative output encoding, such as 'hex'\n * (defaults to none, outputs a byte buffer).\n * [delimiter] the delimiter to use between bytes for 'hex' encoded\n * output, eg: ':' (defaults to none).\n *\n * @return the fingerprint as a byte buffer or other encoding based on options.\n */\npki.getPublicKeyFingerprint = function(key, options) {\n options = options || {};\n var md = options.md || forge.md.sha1.create();\n var type = options.type || 'RSAPublicKey';\n\n var bytes;\n switch(type) {\n case 'RSAPublicKey':\n bytes = asn1.toDer(pki.publicKeyToRSAPublicKey(key)).getBytes();\n break;\n case 'SubjectPublicKeyInfo':\n bytes = asn1.toDer(pki.publicKeyToAsn1(key)).getBytes();\n break;\n default:\n throw new Error('Unknown fingerprint type \"' + options.type + '\".');\n }\n\n // hash public key bytes\n md.start();\n md.update(bytes);\n var digest = md.digest();\n if(options.encoding === 'hex') {\n var hex = digest.toHex();\n if(options.delimiter) {\n return hex.match(/.{2}/g).join(options.delimiter);\n }\n return hex;\n } else if(options.encoding === 'binary') {\n return digest.getBytes();\n } else if(options.encoding) {\n throw new Error('Unknown encoding \"' + options.encoding + '\".');\n }\n return digest;\n};\n\n/**\n * Converts a PKCS#10 certification request (CSR) from PEM format.\n *\n * Note: If the certification request is to be verified then compute hash\n * should be set to true. This will scan the CertificationRequestInfo part of\n * the ASN.1 object while it is converted so it doesn't need to be converted\n * back to ASN.1-DER-encoding later.\n *\n * @param pem the PEM-formatted certificate.\n * @param computeHash true to compute the hash for verification.\n * @param strict true to be strict when checking ASN.1 value lengths, false to\n * allow truncated values (default: true).\n *\n * @return the certification request (CSR).\n */\npki.certificationRequestFromPem = function(pem, computeHash, strict) {\n var msg = forge.pem.decode(pem)[0];\n\n if(msg.type !== 'CERTIFICATE REQUEST') {\n var error = new Error('Could not convert certification request from PEM; ' +\n 'PEM header type is not \"CERTIFICATE REQUEST\".');\n error.headerType = msg.type;\n throw error;\n }\n if(msg.procType && msg.procType.type === 'ENCRYPTED') {\n throw new Error('Could not convert certification request from PEM; ' +\n 'PEM is encrypted.');\n }\n\n // convert DER to ASN.1 object\n var obj = asn1.fromDer(msg.body, strict);\n\n return pki.certificationRequestFromAsn1(obj, computeHash);\n};\n\n/**\n * Converts a PKCS#10 certification request (CSR) to PEM format.\n *\n * @param csr the certification request.\n * @param maxline the maximum characters per line, defaults to 64.\n *\n * @return the PEM-formatted certification request.\n */\npki.certificationRequestToPem = function(csr, maxline) {\n // convert to ASN.1, then DER, then PEM-encode\n var msg = {\n type: 'CERTIFICATE REQUEST',\n body: asn1.toDer(pki.certificationRequestToAsn1(csr)).getBytes()\n };\n return forge.pem.encode(msg, {maxline: maxline});\n};\n\n/**\n * Creates an empty X.509v3 RSA certificate.\n *\n * @return the certificate.\n */\npki.createCertificate = function() {\n var cert = {};\n cert.version = 0x02;\n cert.serialNumber = '00';\n cert.signatureOid = null;\n cert.signature = null;\n cert.siginfo = {};\n cert.siginfo.algorithmOid = null;\n cert.validity = {};\n cert.validity.notBefore = new Date();\n cert.validity.notAfter = new Date();\n\n cert.issuer = {};\n cert.issuer.getField = function(sn) {\n return _getAttribute(cert.issuer, sn);\n };\n cert.issuer.addField = function(attr) {\n _fillMissingFields([attr]);\n cert.issuer.attributes.push(attr);\n };\n cert.issuer.attributes = [];\n cert.issuer.hash = null;\n\n cert.subject = {};\n cert.subject.getField = function(sn) {\n return _getAttribute(cert.subject, sn);\n };\n cert.subject.addField = function(attr) {\n _fillMissingFields([attr]);\n cert.subject.attributes.push(attr);\n };\n cert.subject.attributes = [];\n cert.subject.hash = null;\n\n cert.extensions = [];\n cert.publicKey = null;\n cert.md = null;\n\n /**\n * Sets the subject of this certificate.\n *\n * @param attrs the array of subject attributes to use.\n * @param uniqueId an optional a unique ID to use.\n */\n cert.setSubject = function(attrs, uniqueId) {\n // set new attributes, clear hash\n _fillMissingFields(attrs);\n cert.subject.attributes = attrs;\n delete cert.subject.uniqueId;\n if(uniqueId) {\n // TODO: support arbitrary bit length ids\n cert.subject.uniqueId = uniqueId;\n }\n cert.subject.hash = null;\n };\n\n /**\n * Sets the issuer of this certificate.\n *\n * @param attrs the array of issuer attributes to use.\n * @param uniqueId an optional a unique ID to use.\n */\n cert.setIssuer = function(attrs, uniqueId) {\n // set new attributes, clear hash\n _fillMissingFields(attrs);\n cert.issuer.attributes = attrs;\n delete cert.issuer.uniqueId;\n if(uniqueId) {\n // TODO: support arbitrary bit length ids\n cert.issuer.uniqueId = uniqueId;\n }\n cert.issuer.hash = null;\n };\n\n /**\n * Sets the extensions of this certificate.\n *\n * @param exts the array of extensions to use.\n */\n cert.setExtensions = function(exts) {\n for(var i = 0; i < exts.length; ++i) {\n _fillMissingExtensionFields(exts[i], {cert: cert});\n }\n // set new extensions\n cert.extensions = exts;\n };\n\n /**\n * Gets an extension by its name or id.\n *\n * @param options the name to use or an object with:\n * name the name to use.\n * id the id to use.\n *\n * @return the extension or null if not found.\n */\n cert.getExtension = function(options) {\n if(typeof options === 'string') {\n options = {name: options};\n }\n\n var rval = null;\n var ext;\n for(var i = 0; rval === null && i < cert.extensions.length; ++i) {\n ext = cert.extensions[i];\n if(options.id && ext.id === options.id) {\n rval = ext;\n } else if(options.name && ext.name === options.name) {\n rval = ext;\n }\n }\n return rval;\n };\n\n /**\n * Signs this certificate using the given private key.\n *\n * @param key the private key to sign with.\n * @param md the message digest object to use (defaults to forge.md.sha1).\n */\n cert.sign = function(key, md) {\n // TODO: get signature OID from private key\n cert.md = md || forge.md.sha1.create();\n var algorithmOid = oids[cert.md.algorithm + 'WithRSAEncryption'];\n if(!algorithmOid) {\n var error = new Error('Could not compute certificate digest. ' +\n 'Unknown message digest algorithm OID.');\n error.algorithm = cert.md.algorithm;\n throw error;\n }\n cert.signatureOid = cert.siginfo.algorithmOid = algorithmOid;\n\n // get TBSCertificate, convert to DER\n cert.tbsCertificate = pki.getTBSCertificate(cert);\n var bytes = asn1.toDer(cert.tbsCertificate);\n\n // digest and sign\n cert.md.update(bytes.getBytes());\n cert.signature = key.sign(cert.md);\n };\n\n /**\n * Attempts verify the signature on the passed certificate using this\n * certificate's public key.\n *\n * @param child the certificate to verify.\n *\n * @return true if verified, false if not.\n */\n cert.verify = function(child) {\n var rval = false;\n\n if(!cert.issued(child)) {\n var issuer = child.issuer;\n var subject = cert.subject;\n var error = new Error(\n 'The parent certificate did not issue the given child ' +\n 'certificate; the child certificate\\'s issuer does not match the ' +\n 'parent\\'s subject.');\n error.expectedIssuer = issuer.attributes;\n error.actualIssuer = subject.attributes;\n throw error;\n }\n\n var md = child.md;\n if(md === null) {\n // check signature OID for supported signature types\n if(child.signatureOid in oids) {\n var oid = oids[child.signatureOid];\n switch(oid) {\n case 'sha1WithRSAEncryption':\n md = forge.md.sha1.create();\n break;\n case 'md5WithRSAEncryption':\n md = forge.md.md5.create();\n break;\n case 'sha256WithRSAEncryption':\n md = forge.md.sha256.create();\n break;\n case 'sha384WithRSAEncryption':\n md = forge.md.sha384.create();\n break;\n case 'sha512WithRSAEncryption':\n md = forge.md.sha512.create();\n break;\n case 'RSASSA-PSS':\n md = forge.md.sha256.create();\n break;\n }\n }\n if(md === null) {\n var error = new Error('Could not compute certificate digest. ' +\n 'Unknown signature OID.');\n error.signatureOid = child.signatureOid;\n throw error;\n }\n\n // produce DER formatted TBSCertificate and digest it\n var tbsCertificate = child.tbsCertificate || pki.getTBSCertificate(child);\n var bytes = asn1.toDer(tbsCertificate);\n md.update(bytes.getBytes());\n }\n\n if(md !== null) {\n var scheme;\n\n switch(child.signatureOid) {\n case oids.sha1WithRSAEncryption:\n scheme = undefined; /* use PKCS#1 v1.5 padding scheme */\n break;\n case oids['RSASSA-PSS']:\n var hash, mgf;\n\n /* initialize mgf */\n hash = oids[child.signatureParameters.mgf.hash.algorithmOid];\n if(hash === undefined || forge.md[hash] === undefined) {\n var error = new Error('Unsupported MGF hash function.');\n error.oid = child.signatureParameters.mgf.hash.algorithmOid;\n error.name = hash;\n throw error;\n }\n\n mgf = oids[child.signatureParameters.mgf.algorithmOid];\n if(mgf === undefined || forge.mgf[mgf] === undefined) {\n var error = new Error('Unsupported MGF function.');\n error.oid = child.signatureParameters.mgf.algorithmOid;\n error.name = mgf;\n throw error;\n }\n\n mgf = forge.mgf[mgf].create(forge.md[hash].create());\n\n /* initialize hash function */\n hash = oids[child.signatureParameters.hash.algorithmOid];\n if(hash === undefined || forge.md[hash] === undefined) {\n throw {\n message: 'Unsupported RSASSA-PSS hash function.',\n oid: child.signatureParameters.hash.algorithmOid,\n name: hash\n };\n }\n\n scheme = forge.pss.create(forge.md[hash].create(), mgf,\n child.signatureParameters.saltLength);\n break;\n }\n\n // verify signature on cert using public key\n rval = cert.publicKey.verify(\n md.digest().getBytes(), child.signature, scheme);\n }\n\n return rval;\n };\n\n /**\n * Returns true if this certificate's issuer matches the passed\n * certificate's subject. Note that no signature check is performed.\n *\n * @param parent the certificate to check.\n *\n * @return true if this certificate's issuer matches the passed certificate's\n * subject.\n */\n cert.isIssuer = function(parent) {\n var rval = false;\n\n var i = cert.issuer;\n var s = parent.subject;\n\n // compare hashes if present\n if(i.hash && s.hash) {\n rval = (i.hash === s.hash);\n } else if(i.attributes.length === s.attributes.length) {\n // all attributes are the same so issuer matches subject\n rval = true;\n var iattr, sattr;\n for(var n = 0; rval && n < i.attributes.length; ++n) {\n iattr = i.attributes[n];\n sattr = s.attributes[n];\n if(iattr.type !== sattr.type || iattr.value !== sattr.value) {\n // attribute mismatch\n rval = false;\n }\n }\n }\n\n return rval;\n };\n\n /**\n * Returns true if this certificate's subject matches the issuer of the\n * given certificate). Note that not signature check is performed.\n *\n * @param child the certificate to check.\n *\n * @return true if this certificate's subject matches the passed\n * certificate's issuer.\n */\n cert.issued = function(child) {\n return child.isIssuer(cert);\n };\n\n /**\n * Generates the subjectKeyIdentifier for this certificate as byte buffer.\n *\n * @return the subjectKeyIdentifier for this certificate as byte buffer.\n */\n cert.generateSubjectKeyIdentifier = function() {\n /* See: 4.2.1.2 section of the the RFC3280, keyIdentifier is either:\n\n (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the\n value of the BIT STRING subjectPublicKey (excluding the tag,\n length, and number of unused bits).\n\n (2) The keyIdentifier is composed of a four bit type field with\n the value 0100 followed by the least significant 60 bits of the\n SHA-1 hash of the value of the BIT STRING subjectPublicKey\n (excluding the tag, length, and number of unused bit string bits).\n */\n\n // skipping the tag, length, and number of unused bits is the same\n // as just using the RSAPublicKey (for RSA keys, which are the\n // only ones supported)\n return pki.getPublicKeyFingerprint(cert.publicKey, {type: 'RSAPublicKey'});\n };\n\n /**\n * Verifies the subjectKeyIdentifier extension value for this certificate\n * against its public key. If no extension is found, false will be\n * returned.\n *\n * @return true if verified, false if not.\n */\n cert.verifySubjectKeyIdentifier = function() {\n var oid = oids['subjectKeyIdentifier'];\n for(var i = 0; i < cert.extensions.length; ++i) {\n var ext = cert.extensions[i];\n if(ext.id === oid) {\n var ski = cert.generateSubjectKeyIdentifier().getBytes();\n return (forge.util.hexToBytes(ext.subjectKeyIdentifier) === ski);\n }\n }\n return false;\n };\n\n return cert;\n};\n\n/**\n * Converts an X.509v3 RSA certificate from an ASN.1 object.\n *\n * Note: If the certificate is to be verified then compute hash should\n * be set to true. There is currently no implementation for converting\n * a certificate back to ASN.1 so the TBSCertificate part of the ASN.1\n * object needs to be scanned before the cert object is created.\n *\n * @param obj the asn1 representation of an X.509v3 RSA certificate.\n * @param computeHash true to compute the hash for verification.\n *\n * @return the certificate.\n */\npki.certificateFromAsn1 = function(obj, computeHash) {\n // validate certificate and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, x509CertificateValidator, capture, errors)) {\n var error = new Error('Cannot read X.509 certificate. ' +\n 'ASN.1 object is not an X509v3 Certificate.');\n error.errors = errors;\n throw error;\n }\n\n // get oid\n var oid = asn1.derToOid(capture.publicKeyOid);\n if(oid !== pki.oids.rsaEncryption) {\n throw new Error('Cannot read public key. OID is not RSA.');\n }\n\n // create certificate\n var cert = pki.createCertificate();\n cert.version = capture.certVersion ?\n capture.certVersion.charCodeAt(0) : 0;\n var serial = forge.util.createBuffer(capture.certSerialNumber);\n cert.serialNumber = serial.toHex();\n cert.signatureOid = forge.asn1.derToOid(capture.certSignatureOid);\n cert.signatureParameters = _readSignatureParameters(\n cert.signatureOid, capture.certSignatureParams, true);\n cert.siginfo.algorithmOid = forge.asn1.derToOid(capture.certinfoSignatureOid);\n cert.siginfo.parameters = _readSignatureParameters(cert.siginfo.algorithmOid,\n capture.certinfoSignatureParams, false);\n cert.signature = capture.certSignature;\n\n var validity = [];\n if(capture.certValidity1UTCTime !== undefined) {\n validity.push(asn1.utcTimeToDate(capture.certValidity1UTCTime));\n }\n if(capture.certValidity2GeneralizedTime !== undefined) {\n validity.push(asn1.generalizedTimeToDate(\n capture.certValidity2GeneralizedTime));\n }\n if(capture.certValidity3UTCTime !== undefined) {\n validity.push(asn1.utcTimeToDate(capture.certValidity3UTCTime));\n }\n if(capture.certValidity4GeneralizedTime !== undefined) {\n validity.push(asn1.generalizedTimeToDate(\n capture.certValidity4GeneralizedTime));\n }\n if(validity.length > 2) {\n throw new Error('Cannot read notBefore/notAfter validity times; more ' +\n 'than two times were provided in the certificate.');\n }\n if(validity.length < 2) {\n throw new Error('Cannot read notBefore/notAfter validity times; they ' +\n 'were not provided as either UTCTime or GeneralizedTime.');\n }\n cert.validity.notBefore = validity[0];\n cert.validity.notAfter = validity[1];\n\n // keep TBSCertificate to preserve signature when exporting\n cert.tbsCertificate = capture.tbsCertificate;\n\n if(computeHash) {\n // check signature OID for supported signature types\n cert.md = null;\n if(cert.signatureOid in oids) {\n var oid = oids[cert.signatureOid];\n switch(oid) {\n case 'sha1WithRSAEncryption':\n cert.md = forge.md.sha1.create();\n break;\n case 'md5WithRSAEncryption':\n cert.md = forge.md.md5.create();\n break;\n case 'sha256WithRSAEncryption':\n cert.md = forge.md.sha256.create();\n break;\n case 'sha384WithRSAEncryption':\n cert.md = forge.md.sha384.create();\n break;\n case 'sha512WithRSAEncryption':\n cert.md = forge.md.sha512.create();\n break;\n case 'RSASSA-PSS':\n cert.md = forge.md.sha256.create();\n break;\n }\n }\n if(cert.md === null) {\n var error = new Error('Could not compute certificate digest. ' +\n 'Unknown signature OID.');\n error.signatureOid = cert.signatureOid;\n throw error;\n }\n\n // produce DER formatted TBSCertificate and digest it\n var bytes = asn1.toDer(cert.tbsCertificate);\n cert.md.update(bytes.getBytes());\n }\n\n // handle issuer, build issuer message digest\n var imd = forge.md.sha1.create();\n cert.issuer.getField = function(sn) {\n return _getAttribute(cert.issuer, sn);\n };\n cert.issuer.addField = function(attr) {\n _fillMissingFields([attr]);\n cert.issuer.attributes.push(attr);\n };\n cert.issuer.attributes = pki.RDNAttributesAsArray(capture.certIssuer, imd);\n if(capture.certIssuerUniqueId) {\n cert.issuer.uniqueId = capture.certIssuerUniqueId;\n }\n cert.issuer.hash = imd.digest().toHex();\n\n // handle subject, build subject message digest\n var smd = forge.md.sha1.create();\n cert.subject.getField = function(sn) {\n return _getAttribute(cert.subject, sn);\n };\n cert.subject.addField = function(attr) {\n _fillMissingFields([attr]);\n cert.subject.attributes.push(attr);\n };\n cert.subject.attributes = pki.RDNAttributesAsArray(capture.certSubject, smd);\n if(capture.certSubjectUniqueId) {\n cert.subject.uniqueId = capture.certSubjectUniqueId;\n }\n cert.subject.hash = smd.digest().toHex();\n\n // handle extensions\n if(capture.certExtensions) {\n cert.extensions = pki.certificateExtensionsFromAsn1(capture.certExtensions);\n } else {\n cert.extensions = [];\n }\n\n // convert RSA public key from ASN.1\n cert.publicKey = pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);\n\n return cert;\n};\n\n/**\n * Converts an ASN.1 extensions object (with extension sequences as its\n * values) into an array of extension objects with types and values.\n *\n * Supported extensions:\n *\n * id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }\n * KeyUsage ::= BIT STRING {\n * digitalSignature (0),\n * nonRepudiation (1),\n * keyEncipherment (2),\n * dataEncipherment (3),\n * keyAgreement (4),\n * keyCertSign (5),\n * cRLSign (6),\n * encipherOnly (7),\n * decipherOnly (8)\n * }\n *\n * id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 }\n * BasicConstraints ::= SEQUENCE {\n * cA BOOLEAN DEFAULT FALSE,\n * pathLenConstraint INTEGER (0..MAX) OPTIONAL\n * }\n *\n * subjectAltName EXTENSION ::= {\n * SYNTAX GeneralNames\n * IDENTIFIED BY id-ce-subjectAltName\n * }\n *\n * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName\n *\n * GeneralName ::= CHOICE {\n * otherName [0] INSTANCE OF OTHER-NAME,\n * rfc822Name [1] IA5String,\n * dNSName [2] IA5String,\n * x400Address [3] ORAddress,\n * directoryName [4] Name,\n * ediPartyName [5] EDIPartyName,\n * uniformResourceIdentifier [6] IA5String,\n * IPAddress [7] OCTET STRING,\n * registeredID [8] OBJECT IDENTIFIER\n * }\n *\n * OTHER-NAME ::= TYPE-IDENTIFIER\n *\n * EDIPartyName ::= SEQUENCE {\n * nameAssigner [0] DirectoryString {ub-name} OPTIONAL,\n * partyName [1] DirectoryString {ub-name}\n * }\n *\n * @param exts the extensions ASN.1 with extension sequences to parse.\n *\n * @return the array.\n */\npki.certificateExtensionsFromAsn1 = function(exts) {\n var rval = [];\n for(var i = 0; i < exts.value.length; ++i) {\n // get extension sequence\n var extseq = exts.value[i];\n for(var ei = 0; ei < extseq.value.length; ++ei) {\n rval.push(pki.certificateExtensionFromAsn1(extseq.value[ei]));\n }\n }\n\n return rval;\n};\n\n/**\n * Parses a single certificate extension from ASN.1.\n *\n * @param ext the extension in ASN.1 format.\n *\n * @return the parsed extension as an object.\n */\npki.certificateExtensionFromAsn1 = function(ext) {\n // an extension has:\n // [0] extnID OBJECT IDENTIFIER\n // [1] critical BOOLEAN DEFAULT FALSE\n // [2] extnValue OCTET STRING\n var e = {};\n e.id = asn1.derToOid(ext.value[0].value);\n e.critical = false;\n if(ext.value[1].type === asn1.Type.BOOLEAN) {\n e.critical = (ext.value[1].value.charCodeAt(0) !== 0x00);\n e.value = ext.value[2].value;\n } else {\n e.value = ext.value[1].value;\n }\n // if the oid is known, get its name\n if(e.id in oids) {\n e.name = oids[e.id];\n\n // handle key usage\n if(e.name === 'keyUsage') {\n // get value as BIT STRING\n var ev = asn1.fromDer(e.value);\n var b2 = 0x00;\n var b3 = 0x00;\n if(ev.value.length > 1) {\n // skip first byte, just indicates unused bits which\n // will be padded with 0s anyway\n // get bytes with flag bits\n b2 = ev.value.charCodeAt(1);\n b3 = ev.value.length > 2 ? ev.value.charCodeAt(2) : 0;\n }\n // set flags\n e.digitalSignature = (b2 & 0x80) === 0x80;\n e.nonRepudiation = (b2 & 0x40) === 0x40;\n e.keyEncipherment = (b2 & 0x20) === 0x20;\n e.dataEncipherment = (b2 & 0x10) === 0x10;\n e.keyAgreement = (b2 & 0x08) === 0x08;\n e.keyCertSign = (b2 & 0x04) === 0x04;\n e.cRLSign = (b2 & 0x02) === 0x02;\n e.encipherOnly = (b2 & 0x01) === 0x01;\n e.decipherOnly = (b3 & 0x80) === 0x80;\n } else if(e.name === 'basicConstraints') {\n // handle basic constraints\n // get value as SEQUENCE\n var ev = asn1.fromDer(e.value);\n // get cA BOOLEAN flag (defaults to false)\n if(ev.value.length > 0 && ev.value[0].type === asn1.Type.BOOLEAN) {\n e.cA = (ev.value[0].value.charCodeAt(0) !== 0x00);\n } else {\n e.cA = false;\n }\n // get path length constraint\n var value = null;\n if(ev.value.length > 0 && ev.value[0].type === asn1.Type.INTEGER) {\n value = ev.value[0].value;\n } else if(ev.value.length > 1) {\n value = ev.value[1].value;\n }\n if(value !== null) {\n e.pathLenConstraint = asn1.derToInteger(value);\n }\n } else if(e.name === 'extKeyUsage') {\n // handle extKeyUsage\n // value is a SEQUENCE of OIDs\n var ev = asn1.fromDer(e.value);\n for(var vi = 0; vi < ev.value.length; ++vi) {\n var oid = asn1.derToOid(ev.value[vi].value);\n if(oid in oids) {\n e[oids[oid]] = true;\n } else {\n e[oid] = true;\n }\n }\n } else if(e.name === 'nsCertType') {\n // handle nsCertType\n // get value as BIT STRING\n var ev = asn1.fromDer(e.value);\n var b2 = 0x00;\n if(ev.value.length > 1) {\n // skip first byte, just indicates unused bits which\n // will be padded with 0s anyway\n // get bytes with flag bits\n b2 = ev.value.charCodeAt(1);\n }\n // set flags\n e.client = (b2 & 0x80) === 0x80;\n e.server = (b2 & 0x40) === 0x40;\n e.email = (b2 & 0x20) === 0x20;\n e.objsign = (b2 & 0x10) === 0x10;\n e.reserved = (b2 & 0x08) === 0x08;\n e.sslCA = (b2 & 0x04) === 0x04;\n e.emailCA = (b2 & 0x02) === 0x02;\n e.objCA = (b2 & 0x01) === 0x01;\n } else if(\n e.name === 'subjectAltName' ||\n e.name === 'issuerAltName') {\n // handle subjectAltName/issuerAltName\n e.altNames = [];\n\n // ev is a SYNTAX SEQUENCE\n var gn;\n var ev = asn1.fromDer(e.value);\n for(var n = 0; n < ev.value.length; ++n) {\n // get GeneralName\n gn = ev.value[n];\n\n var altName = {\n type: gn.type,\n value: gn.value\n };\n e.altNames.push(altName);\n\n // Note: Support for types 1,2,6,7,8\n switch(gn.type) {\n // rfc822Name\n case 1:\n // dNSName\n case 2:\n // uniformResourceIdentifier (URI)\n case 6:\n break;\n // IPAddress\n case 7:\n // convert to IPv4/IPv6 string representation\n altName.ip = forge.util.bytesToIP(gn.value);\n break;\n // registeredID\n case 8:\n altName.oid = asn1.derToOid(gn.value);\n break;\n default:\n // unsupported\n }\n }\n } else if(e.name === 'subjectKeyIdentifier') {\n // value is an OCTETSTRING w/the hash of the key-type specific\n // public key structure (eg: RSAPublicKey)\n var ev = asn1.fromDer(e.value);\n e.subjectKeyIdentifier = forge.util.bytesToHex(ev.value);\n }\n }\n return e;\n};\n\n/**\n * Converts a PKCS#10 certification request (CSR) from an ASN.1 object.\n *\n * Note: If the certification request is to be verified then compute hash\n * should be set to true. There is currently no implementation for converting\n * a certificate back to ASN.1 so the CertificationRequestInfo part of the\n * ASN.1 object needs to be scanned before the csr object is created.\n *\n * @param obj the asn1 representation of a PKCS#10 certification request (CSR).\n * @param computeHash true to compute the hash for verification.\n *\n * @return the certification request (CSR).\n */\npki.certificationRequestFromAsn1 = function(obj, computeHash) {\n // validate certification request and capture data\n var capture = {};\n var errors = [];\n if(!asn1.validate(obj, certificationRequestValidator, capture, errors)) {\n var error = new Error('Cannot read PKCS#10 certificate request. ' +\n 'ASN.1 object is not a PKCS#10 CertificationRequest.');\n error.errors = errors;\n throw error;\n }\n\n // get oid\n var oid = asn1.derToOid(capture.publicKeyOid);\n if(oid !== pki.oids.rsaEncryption) {\n throw new Error('Cannot read public key. OID is not RSA.');\n }\n\n // create certification request\n var csr = pki.createCertificationRequest();\n csr.version = capture.csrVersion ? capture.csrVersion.charCodeAt(0) : 0;\n csr.signatureOid = forge.asn1.derToOid(capture.csrSignatureOid);\n csr.signatureParameters = _readSignatureParameters(\n csr.signatureOid, capture.csrSignatureParams, true);\n csr.siginfo.algorithmOid = forge.asn1.derToOid(capture.csrSignatureOid);\n csr.siginfo.parameters = _readSignatureParameters(\n csr.siginfo.algorithmOid, capture.csrSignatureParams, false);\n csr.signature = capture.csrSignature;\n\n // keep CertificationRequestInfo to preserve signature when exporting\n csr.certificationRequestInfo = capture.certificationRequestInfo;\n\n if(computeHash) {\n // check signature OID for supported signature types\n csr.md = null;\n if(csr.signatureOid in oids) {\n var oid = oids[csr.signatureOid];\n switch(oid) {\n case 'sha1WithRSAEncryption':\n csr.md = forge.md.sha1.create();\n break;\n case 'md5WithRSAEncryption':\n csr.md = forge.md.md5.create();\n break;\n case 'sha256WithRSAEncryption':\n csr.md = forge.md.sha256.create();\n break;\n case 'sha384WithRSAEncryption':\n csr.md = forge.md.sha384.create();\n break;\n case 'sha512WithRSAEncryption':\n csr.md = forge.md.sha512.create();\n break;\n case 'RSASSA-PSS':\n csr.md = forge.md.sha256.create();\n break;\n }\n }\n if(csr.md === null) {\n var error = new Error('Could not compute certification request digest. ' +\n 'Unknown signature OID.');\n error.signatureOid = csr.signatureOid;\n throw error;\n }\n\n // produce DER formatted CertificationRequestInfo and digest it\n var bytes = asn1.toDer(csr.certificationRequestInfo);\n csr.md.update(bytes.getBytes());\n }\n\n // handle subject, build subject message digest\n var smd = forge.md.sha1.create();\n csr.subject.getField = function(sn) {\n return _getAttribute(csr.subject, sn);\n };\n csr.subject.addField = function(attr) {\n _fillMissingFields([attr]);\n csr.subject.attributes.push(attr);\n };\n csr.subject.attributes = pki.RDNAttributesAsArray(\n capture.certificationRequestInfoSubject, smd);\n csr.subject.hash = smd.digest().toHex();\n\n // convert RSA public key from ASN.1\n csr.publicKey = pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);\n\n // convert attributes from ASN.1\n csr.getAttribute = function(sn) {\n return _getAttribute(csr, sn);\n };\n csr.addAttribute = function(attr) {\n _fillMissingFields([attr]);\n csr.attributes.push(attr);\n };\n csr.attributes = pki.CRIAttributesAsArray(\n capture.certificationRequestInfoAttributes || []);\n\n return csr;\n};\n\n/**\n * Creates an empty certification request (a CSR or certificate signing\n * request). Once created, its public key and attributes can be set and then\n * it can be signed.\n *\n * @return the empty certification request.\n */\npki.createCertificationRequest = function() {\n var csr = {};\n csr.version = 0x00;\n csr.signatureOid = null;\n csr.signature = null;\n csr.siginfo = {};\n csr.siginfo.algorithmOid = null;\n\n csr.subject = {};\n csr.subject.getField = function(sn) {\n return _getAttribute(csr.subject, sn);\n };\n csr.subject.addField = function(attr) {\n _fillMissingFields([attr]);\n csr.subject.attributes.push(attr);\n };\n csr.subject.attributes = [];\n csr.subject.hash = null;\n\n csr.publicKey = null;\n csr.attributes = [];\n csr.getAttribute = function(sn) {\n return _getAttribute(csr, sn);\n };\n csr.addAttribute = function(attr) {\n _fillMissingFields([attr]);\n csr.attributes.push(attr);\n };\n csr.md = null;\n\n /**\n * Sets the subject of this certification request.\n *\n * @param attrs the array of subject attributes to use.\n */\n csr.setSubject = function(attrs) {\n // set new attributes\n _fillMissingFields(attrs);\n csr.subject.attributes = attrs;\n csr.subject.hash = null;\n };\n\n /**\n * Sets the attributes of this certification request.\n *\n * @param attrs the array of attributes to use.\n */\n csr.setAttributes = function(attrs) {\n // set new attributes\n _fillMissingFields(attrs);\n csr.attributes = attrs;\n };\n\n /**\n * Signs this certification request using the given private key.\n *\n * @param key the private key to sign with.\n * @param md the message digest object to use (defaults to forge.md.sha1).\n */\n csr.sign = function(key, md) {\n // TODO: get signature OID from private key\n csr.md = md || forge.md.sha1.create();\n var algorithmOid = oids[csr.md.algorithm + 'WithRSAEncryption'];\n if(!algorithmOid) {\n var error = new Error('Could not compute certification request digest. ' +\n 'Unknown message digest algorithm OID.');\n error.algorithm = csr.md.algorithm;\n throw error;\n }\n csr.signatureOid = csr.siginfo.algorithmOid = algorithmOid;\n\n // get CertificationRequestInfo, convert to DER\n csr.certificationRequestInfo = pki.getCertificationRequestInfo(csr);\n var bytes = asn1.toDer(csr.certificationRequestInfo);\n\n // digest and sign\n csr.md.update(bytes.getBytes());\n csr.signature = key.sign(csr.md);\n };\n\n /**\n * Attempts verify the signature on the passed certification request using\n * its public key.\n *\n * A CSR that has been exported to a file in PEM format can be verified using\n * OpenSSL using this command:\n *\n * openssl req -in -verify -noout -text\n *\n * @return true if verified, false if not.\n */\n csr.verify = function() {\n var rval = false;\n\n var md = csr.md;\n if(md === null) {\n // check signature OID for supported signature types\n if(csr.signatureOid in oids) {\n // TODO: create DRY `OID to md` function\n var oid = oids[csr.signatureOid];\n switch(oid) {\n case 'sha1WithRSAEncryption':\n md = forge.md.sha1.create();\n break;\n case 'md5WithRSAEncryption':\n md = forge.md.md5.create();\n break;\n case 'sha256WithRSAEncryption':\n md = forge.md.sha256.create();\n break;\n case 'sha384WithRSAEncryption':\n md = forge.md.sha384.create();\n break;\n case 'sha512WithRSAEncryption':\n md = forge.md.sha512.create();\n break;\n case 'RSASSA-PSS':\n md = forge.md.sha256.create();\n break;\n }\n }\n if(md === null) {\n var error = new Error(\n 'Could not compute certification request digest. ' +\n 'Unknown signature OID.');\n error.signatureOid = csr.signatureOid;\n throw error;\n }\n\n // produce DER formatted CertificationRequestInfo and digest it\n var cri = csr.certificationRequestInfo ||\n pki.getCertificationRequestInfo(csr);\n var bytes = asn1.toDer(cri);\n md.update(bytes.getBytes());\n }\n\n if(md !== null) {\n var scheme;\n\n switch(csr.signatureOid) {\n case oids.sha1WithRSAEncryption:\n /* use PKCS#1 v1.5 padding scheme */\n break;\n case oids['RSASSA-PSS']:\n var hash, mgf;\n\n /* initialize mgf */\n hash = oids[csr.signatureParameters.mgf.hash.algorithmOid];\n if(hash === undefined || forge.md[hash] === undefined) {\n var error = new Error('Unsupported MGF hash function.');\n error.oid = csr.signatureParameters.mgf.hash.algorithmOid;\n error.name = hash;\n throw error;\n }\n\n mgf = oids[csr.signatureParameters.mgf.algorithmOid];\n if(mgf === undefined || forge.mgf[mgf] === undefined) {\n var error = new Error('Unsupported MGF function.');\n error.oid = csr.signatureParameters.mgf.algorithmOid;\n error.name = mgf;\n throw error;\n }\n\n mgf = forge.mgf[mgf].create(forge.md[hash].create());\n\n /* initialize hash function */\n hash = oids[csr.signatureParameters.hash.algorithmOid];\n if(hash === undefined || forge.md[hash] === undefined) {\n var error = new Error('Unsupported RSASSA-PSS hash function.');\n error.oid = csr.signatureParameters.hash.algorithmOid;\n error.name = hash;\n throw error;\n }\n\n scheme = forge.pss.create(forge.md[hash].create(), mgf,\n csr.signatureParameters.saltLength);\n break;\n }\n\n // verify signature on csr using its public key\n rval = csr.publicKey.verify(\n md.digest().getBytes(), csr.signature, scheme);\n }\n\n return rval;\n };\n\n return csr;\n};\n\n/**\n * Converts an X.509 subject or issuer to an ASN.1 RDNSequence.\n *\n * @param obj the subject or issuer (distinguished name).\n *\n * @return the ASN.1 RDNSequence.\n */\nfunction _dnToAsn1(obj) {\n // create an empty RDNSequence\n var rval = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n\n // iterate over attributes\n var attr, set;\n var attrs = obj.attributes;\n for(var i = 0; i < attrs.length; ++i) {\n attr = attrs[i];\n var value = attr.value;\n\n // reuse tag class for attribute value if available\n var valueTagClass = asn1.Type.PRINTABLESTRING;\n if('valueTagClass' in attr) {\n valueTagClass = attr.valueTagClass;\n\n if(valueTagClass === asn1.Type.UTF8) {\n value = forge.util.encodeUtf8(value);\n }\n // FIXME: handle more encodings\n }\n\n // create a RelativeDistinguishedName set\n // each value in the set is an AttributeTypeAndValue first\n // containing the type (an OID) and second the value\n set = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // AttributeType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(attr.type).getBytes()),\n // AttributeValue\n asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)\n ])\n ]);\n rval.value.push(set);\n }\n\n return rval;\n}\n\n/**\n * Gets all printable attributes (typically of an issuer or subject) in a\n * simplified JSON format for display.\n *\n * @param attrs the attributes.\n *\n * @return the JSON for display.\n */\nfunction _getAttributesAsJson(attrs) {\n var rval = {};\n for(var i = 0; i < attrs.length; ++i) {\n var attr = attrs[i];\n if(attr.shortName && (\n attr.valueTagClass === asn1.Type.UTF8 ||\n attr.valueTagClass === asn1.Type.PRINTABLESTRING ||\n attr.valueTagClass === asn1.Type.IA5STRING)) {\n var value = attr.value;\n if(attr.valueTagClass === asn1.Type.UTF8) {\n value = forge.util.encodeUtf8(attr.value);\n }\n if(!(attr.shortName in rval)) {\n rval[attr.shortName] = value;\n } else if(forge.util.isArray(rval[attr.shortName])) {\n rval[attr.shortName].push(value);\n } else {\n rval[attr.shortName] = [rval[attr.shortName], value];\n }\n }\n }\n return rval;\n}\n\n/**\n * Fills in missing fields in attributes.\n *\n * @param attrs the attributes to fill missing fields in.\n */\nfunction _fillMissingFields(attrs) {\n var attr;\n for(var i = 0; i < attrs.length; ++i) {\n attr = attrs[i];\n\n // populate missing name\n if(typeof attr.name === 'undefined') {\n if(attr.type && attr.type in pki.oids) {\n attr.name = pki.oids[attr.type];\n } else if(attr.shortName && attr.shortName in _shortNames) {\n attr.name = pki.oids[_shortNames[attr.shortName]];\n }\n }\n\n // populate missing type (OID)\n if(typeof attr.type === 'undefined') {\n if(attr.name && attr.name in pki.oids) {\n attr.type = pki.oids[attr.name];\n } else {\n var error = new Error('Attribute type not specified.');\n error.attribute = attr;\n throw error;\n }\n }\n\n // populate missing shortname\n if(typeof attr.shortName === 'undefined') {\n if(attr.name && attr.name in _shortNames) {\n attr.shortName = _shortNames[attr.name];\n }\n }\n\n // convert extensions to value\n if(attr.type === oids.extensionRequest) {\n attr.valueConstructed = true;\n attr.valueTagClass = asn1.Type.SEQUENCE;\n if(!attr.value && attr.extensions) {\n attr.value = [];\n for(var ei = 0; ei < attr.extensions.length; ++ei) {\n attr.value.push(pki.certificateExtensionToAsn1(\n _fillMissingExtensionFields(attr.extensions[ei])));\n }\n }\n }\n\n if(typeof attr.value === 'undefined') {\n var error = new Error('Attribute value not specified.');\n error.attribute = attr;\n throw error;\n }\n }\n}\n\n/**\n * Fills in missing fields in certificate extensions.\n *\n * @param e the extension.\n * @param [options] the options to use.\n * [cert] the certificate the extensions are for.\n *\n * @return the extension.\n */\nfunction _fillMissingExtensionFields(e, options) {\n options = options || {};\n\n // populate missing name\n if(typeof e.name === 'undefined') {\n if(e.id && e.id in pki.oids) {\n e.name = pki.oids[e.id];\n }\n }\n\n // populate missing id\n if(typeof e.id === 'undefined') {\n if(e.name && e.name in pki.oids) {\n e.id = pki.oids[e.name];\n } else {\n var error = new Error('Extension ID not specified.');\n error.extension = e;\n throw error;\n }\n }\n\n if(typeof e.value !== 'undefined') {\n return e;\n }\n\n // handle missing value:\n\n // value is a BIT STRING\n if(e.name === 'keyUsage') {\n // build flags\n var unused = 0;\n var b2 = 0x00;\n var b3 = 0x00;\n if(e.digitalSignature) {\n b2 |= 0x80;\n unused = 7;\n }\n if(e.nonRepudiation) {\n b2 |= 0x40;\n unused = 6;\n }\n if(e.keyEncipherment) {\n b2 |= 0x20;\n unused = 5;\n }\n if(e.dataEncipherment) {\n b2 |= 0x10;\n unused = 4;\n }\n if(e.keyAgreement) {\n b2 |= 0x08;\n unused = 3;\n }\n if(e.keyCertSign) {\n b2 |= 0x04;\n unused = 2;\n }\n if(e.cRLSign) {\n b2 |= 0x02;\n unused = 1;\n }\n if(e.encipherOnly) {\n b2 |= 0x01;\n unused = 0;\n }\n if(e.decipherOnly) {\n b3 |= 0x80;\n unused = 7;\n }\n\n // create bit string\n var value = String.fromCharCode(unused);\n if(b3 !== 0) {\n value += String.fromCharCode(b2) + String.fromCharCode(b3);\n } else if(b2 !== 0) {\n value += String.fromCharCode(b2);\n }\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, value);\n } else if(e.name === 'basicConstraints') {\n // basicConstraints is a SEQUENCE\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n // cA BOOLEAN flag defaults to false\n if(e.cA) {\n e.value.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,\n String.fromCharCode(0xFF)));\n }\n if('pathLenConstraint' in e) {\n e.value.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(e.pathLenConstraint).getBytes()));\n }\n } else if(e.name === 'extKeyUsage') {\n // extKeyUsage is a SEQUENCE of OIDs\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n var seq = e.value.value;\n for(var key in e) {\n if(e[key] !== true) {\n continue;\n }\n // key is name in OID map\n if(key in oids) {\n seq.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID,\n false, asn1.oidToDer(oids[key]).getBytes()));\n } else if(key.indexOf('.') !== -1) {\n // assume key is an OID\n seq.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID,\n false, asn1.oidToDer(key).getBytes()));\n }\n }\n } else if(e.name === 'nsCertType') {\n // nsCertType is a BIT STRING\n // build flags\n var unused = 0;\n var b2 = 0x00;\n\n if(e.client) {\n b2 |= 0x80;\n unused = 7;\n }\n if(e.server) {\n b2 |= 0x40;\n unused = 6;\n }\n if(e.email) {\n b2 |= 0x20;\n unused = 5;\n }\n if(e.objsign) {\n b2 |= 0x10;\n unused = 4;\n }\n if(e.reserved) {\n b2 |= 0x08;\n unused = 3;\n }\n if(e.sslCA) {\n b2 |= 0x04;\n unused = 2;\n }\n if(e.emailCA) {\n b2 |= 0x02;\n unused = 1;\n }\n if(e.objCA) {\n b2 |= 0x01;\n unused = 0;\n }\n\n // create bit string\n var value = String.fromCharCode(unused);\n if(b2 !== 0) {\n value += String.fromCharCode(b2);\n }\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, value);\n } else if(e.name === 'subjectAltName' || e.name === 'issuerAltName') {\n // SYNTAX SEQUENCE\n e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n\n var altName;\n for(var n = 0; n < e.altNames.length; ++n) {\n altName = e.altNames[n];\n var value = altName.value;\n // handle IP\n if(altName.type === 7 && altName.ip) {\n value = forge.util.bytesFromIP(altName.ip);\n if(value === null) {\n var error = new Error(\n 'Extension \"ip\" value is not a valid IPv4 or IPv6 address.');\n error.extension = e;\n throw error;\n }\n } else if(altName.type === 8) {\n // handle OID\n if(altName.oid) {\n value = asn1.oidToDer(asn1.oidToDer(altName.oid));\n } else {\n // deprecated ... convert value to OID\n value = asn1.oidToDer(value);\n }\n }\n e.value.value.push(asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, altName.type, false,\n value));\n }\n } else if(e.name === 'nsComment' && options.cert) {\n // sanity check value is ASCII (req'd) and not too big\n if(!(/^[\\x00-\\x7F]*$/.test(e.comment)) ||\n (e.comment.length < 1) || (e.comment.length > 128)) {\n throw new Error('Invalid \"nsComment\" content.');\n }\n // IA5STRING opaque comment\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.IA5STRING, false, e.comment);\n } else if(e.name === 'subjectKeyIdentifier' && options.cert) {\n var ski = options.cert.generateSubjectKeyIdentifier();\n e.subjectKeyIdentifier = ski.toHex();\n // OCTETSTRING w/digest\n e.value = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, ski.getBytes());\n } else if(e.name === 'authorityKeyIdentifier' && options.cert) {\n // SYNTAX SEQUENCE\n e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n var seq = e.value.value;\n\n if(e.keyIdentifier) {\n var keyIdentifier = (e.keyIdentifier === true ?\n options.cert.generateSubjectKeyIdentifier().getBytes() :\n e.keyIdentifier);\n seq.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, false, keyIdentifier));\n }\n\n if(e.authorityCertIssuer) {\n var authorityCertIssuer = [\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 4, true, [\n _dnToAsn1(e.authorityCertIssuer === true ?\n options.cert.issuer : e.authorityCertIssuer)\n ])\n ];\n seq.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, authorityCertIssuer));\n }\n\n if(e.serialNumber) {\n var serialNumber = forge.util.hexToBytes(e.serialNumber === true ?\n options.cert.serialNumber : e.serialNumber);\n seq.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, false, serialNumber));\n }\n } else if(e.name === 'cRLDistributionPoints') {\n e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n var seq = e.value.value;\n\n // Create sub SEQUENCE of DistributionPointName\n var subSeq = asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n\n // Create fullName CHOICE\n var fullNameGeneralNames = asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, 0, true, []);\n var altName;\n for(var n = 0; n < e.altNames.length; ++n) {\n altName = e.altNames[n];\n var value = altName.value;\n // handle IP\n if(altName.type === 7 && altName.ip) {\n value = forge.util.bytesFromIP(altName.ip);\n if(value === null) {\n var error = new Error(\n 'Extension \"ip\" value is not a valid IPv4 or IPv6 address.');\n error.extension = e;\n throw error;\n }\n } else if(altName.type === 8) {\n // handle OID\n if(altName.oid) {\n value = asn1.oidToDer(asn1.oidToDer(altName.oid));\n } else {\n // deprecated ... convert value to OID\n value = asn1.oidToDer(value);\n }\n }\n fullNameGeneralNames.value.push(asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, altName.type, false,\n value));\n }\n\n // Add to the parent SEQUENCE\n subSeq.value.push(asn1.create(\n asn1.Class.CONTEXT_SPECIFIC, 0, true, [fullNameGeneralNames]));\n seq.push(subSeq);\n }\n\n // ensure value has been defined by now\n if(typeof e.value === 'undefined') {\n var error = new Error('Extension value not specified.');\n error.extension = e;\n throw error;\n }\n\n return e;\n}\n\n/**\n * Convert signature parameters object to ASN.1\n *\n * @param {String} oid Signature algorithm OID\n * @param params The signature parametrs object\n * @return ASN.1 object representing signature parameters\n */\nfunction _signatureParametersToAsn1(oid, params) {\n switch(oid) {\n case oids['RSASSA-PSS']:\n var parts = [];\n\n if(params.hash.algorithmOid !== undefined) {\n parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(params.hash.algorithmOid).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ])\n ]));\n }\n\n if(params.mgf.algorithmOid !== undefined) {\n parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(params.mgf.algorithmOid).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(params.mgf.hash.algorithmOid).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')\n ])\n ])\n ]));\n }\n\n if(params.saltLength !== undefined) {\n parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(params.saltLength).getBytes())\n ]));\n }\n\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, parts);\n\n default:\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '');\n }\n}\n\n/**\n * Converts a certification request's attributes to an ASN.1 set of\n * CRIAttributes.\n *\n * @param csr certification request.\n *\n * @return the ASN.1 set of CRIAttributes.\n */\nfunction _CRIAttributesToAsn1(csr) {\n // create an empty context-specific container\n var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, []);\n\n // no attributes, return empty container\n if(csr.attributes.length === 0) {\n return rval;\n }\n\n // each attribute has a sequence with a type and a set of values\n var attrs = csr.attributes;\n for(var i = 0; i < attrs.length; ++i) {\n var attr = attrs[i];\n var value = attr.value;\n\n // reuse tag class for attribute value if available\n var valueTagClass = asn1.Type.UTF8;\n if('valueTagClass' in attr) {\n valueTagClass = attr.valueTagClass;\n }\n if(valueTagClass === asn1.Type.UTF8) {\n value = forge.util.encodeUtf8(value);\n }\n var valueConstructed = false;\n if('valueConstructed' in attr) {\n valueConstructed = attr.valueConstructed;\n }\n // FIXME: handle more encodings\n\n // create a RelativeDistinguishedName set\n // each value in the set is an AttributeTypeAndValue first\n // containing the type (an OID) and second the value\n var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // AttributeType\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(attr.type).getBytes()),\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [\n // AttributeValue\n asn1.create(\n asn1.Class.UNIVERSAL, valueTagClass, valueConstructed, value)\n ])\n ]);\n rval.value.push(seq);\n }\n\n return rval;\n}\n\nvar jan_1_1950 = new Date('1950-01-01T00:00:00Z');\nvar jan_1_2050 = new Date('2050-01-01T00:00:00Z');\n\n/**\n * Converts a Date object to ASN.1\n * Handles the different format before and after 1st January 2050\n *\n * @param date date object.\n *\n * @return the ASN.1 object representing the date.\n */\nfunction _dateToAsn1(date) {\n if(date >= jan_1_1950 && date < jan_1_2050) {\n return asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.UTCTIME, false,\n asn1.dateToUtcTime(date));\n } else {\n return asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.GENERALIZEDTIME, false,\n asn1.dateToGeneralizedTime(date));\n }\n}\n\n/**\n * Gets the ASN.1 TBSCertificate part of an X.509v3 certificate.\n *\n * @param cert the certificate.\n *\n * @return the asn1 TBSCertificate.\n */\npki.getTBSCertificate = function(cert) {\n // TBSCertificate\n var notBefore = _dateToAsn1(cert.validity.notBefore);\n var notAfter = _dateToAsn1(cert.validity.notAfter);\n var tbs = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [\n // integer\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(cert.version).getBytes())\n ]),\n // serialNumber\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n forge.util.hexToBytes(cert.serialNumber)),\n // signature\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(cert.siginfo.algorithmOid).getBytes()),\n // parameters\n _signatureParametersToAsn1(\n cert.siginfo.algorithmOid, cert.siginfo.parameters)\n ]),\n // issuer\n _dnToAsn1(cert.issuer),\n // validity\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n notBefore,\n notAfter\n ]),\n // subject\n _dnToAsn1(cert.subject),\n // SubjectPublicKeyInfo\n pki.publicKeyToAsn1(cert.publicKey)\n ]);\n\n if(cert.issuer.uniqueId) {\n // issuerUniqueID (optional)\n tbs.value.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,\n // TODO: support arbitrary bit length ids\n String.fromCharCode(0x00) +\n cert.issuer.uniqueId\n )\n ])\n );\n }\n if(cert.subject.uniqueId) {\n // subjectUniqueID (optional)\n tbs.value.push(\n asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,\n // TODO: support arbitrary bit length ids\n String.fromCharCode(0x00) +\n cert.subject.uniqueId\n )\n ])\n );\n }\n\n if(cert.extensions.length > 0) {\n // extensions (optional)\n tbs.value.push(pki.certificateExtensionsToAsn1(cert.extensions));\n }\n\n return tbs;\n};\n\n/**\n * Gets the ASN.1 CertificationRequestInfo part of a\n * PKCS#10 CertificationRequest.\n *\n * @param csr the certification request.\n *\n * @return the asn1 CertificationRequestInfo.\n */\npki.getCertificationRequestInfo = function(csr) {\n // CertificationRequestInfo\n var cri = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // version\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,\n asn1.integerToDer(csr.version).getBytes()),\n // subject\n _dnToAsn1(csr.subject),\n // SubjectPublicKeyInfo\n pki.publicKeyToAsn1(csr.publicKey),\n // attributes\n _CRIAttributesToAsn1(csr)\n ]);\n\n return cri;\n};\n\n/**\n * Converts a DistinguishedName (subject or issuer) to an ASN.1 object.\n *\n * @param dn the DistinguishedName.\n *\n * @return the asn1 representation of a DistinguishedName.\n */\npki.distinguishedNameToAsn1 = function(dn) {\n return _dnToAsn1(dn);\n};\n\n/**\n * Converts an X.509v3 RSA certificate to an ASN.1 object.\n *\n * @param cert the certificate.\n *\n * @return the asn1 representation of an X.509v3 RSA certificate.\n */\npki.certificateToAsn1 = function(cert) {\n // prefer cached TBSCertificate over generating one\n var tbsCertificate = cert.tbsCertificate || pki.getTBSCertificate(cert);\n\n // Certificate\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // TBSCertificate\n tbsCertificate,\n // AlgorithmIdentifier (signature algorithm)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(cert.signatureOid).getBytes()),\n // parameters\n _signatureParametersToAsn1(cert.signatureOid, cert.signatureParameters)\n ]),\n // SignatureValue\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,\n String.fromCharCode(0x00) + cert.signature)\n ]);\n};\n\n/**\n * Converts X.509v3 certificate extensions to ASN.1.\n *\n * @param exts the extensions to convert.\n *\n * @return the extensions in ASN.1 format.\n */\npki.certificateExtensionsToAsn1 = function(exts) {\n // create top-level extension container\n var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 3, true, []);\n\n // create extension sequence (stores a sequence for each extension)\n var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n rval.value.push(seq);\n\n for(var i = 0; i < exts.length; ++i) {\n seq.value.push(pki.certificateExtensionToAsn1(exts[i]));\n }\n\n return rval;\n};\n\n/**\n * Converts a single certificate extension to ASN.1.\n *\n * @param ext the extension to convert.\n *\n * @return the extension in ASN.1 format.\n */\npki.certificateExtensionToAsn1 = function(ext) {\n // create a sequence for each extension\n var extseq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);\n\n // extnID (OID)\n extseq.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(ext.id).getBytes()));\n\n // critical defaults to false\n if(ext.critical) {\n // critical BOOLEAN DEFAULT FALSE\n extseq.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,\n String.fromCharCode(0xFF)));\n }\n\n var value = ext.value;\n if(typeof ext.value !== 'string') {\n // value is asn.1\n value = asn1.toDer(value).getBytes();\n }\n\n // extnValue (OCTET STRING)\n extseq.value.push(asn1.create(\n asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, value));\n\n return extseq;\n};\n\n/**\n * Converts a PKCS#10 certification request to an ASN.1 object.\n *\n * @param csr the certification request.\n *\n * @return the asn1 representation of a certification request.\n */\npki.certificationRequestToAsn1 = function(csr) {\n // prefer cached CertificationRequestInfo over generating one\n var cri = csr.certificationRequestInfo ||\n pki.getCertificationRequestInfo(csr);\n\n // Certificate\n return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // CertificationRequestInfo\n cri,\n // AlgorithmIdentifier (signature algorithm)\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [\n // algorithm\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,\n asn1.oidToDer(csr.signatureOid).getBytes()),\n // parameters\n _signatureParametersToAsn1(csr.signatureOid, csr.signatureParameters)\n ]),\n // signature\n asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,\n String.fromCharCode(0x00) + csr.signature)\n ]);\n};\n\n/**\n * Creates a CA store.\n *\n * @param certs an optional array of certificate objects or PEM-formatted\n * certificate strings to add to the CA store.\n *\n * @return the CA store.\n */\npki.createCaStore = function(certs) {\n // create CA store\n var caStore = {\n // stored certificates\n certs: {}\n };\n\n /**\n * Gets the certificate that issued the passed certificate or its\n * 'parent'.\n *\n * @param cert the certificate to get the parent for.\n *\n * @return the parent certificate or null if none was found.\n */\n caStore.getIssuer = function(cert) {\n var rval = getBySubject(cert.issuer);\n\n // see if there are multiple matches\n /*if(forge.util.isArray(rval)) {\n // TODO: resolve multiple matches by checking\n // authorityKey/subjectKey/issuerUniqueID/other identifiers, etc.\n // FIXME: or alternatively do authority key mapping\n // if possible (X.509v1 certs can't work?)\n throw new Error('Resolving multiple issuer matches not implemented yet.');\n }*/\n\n return rval;\n };\n\n /**\n * Adds a trusted certificate to the store.\n *\n * @param cert the certificate to add as a trusted certificate (either a\n * pki.certificate object or a PEM-formatted certificate).\n */\n caStore.addCertificate = function(cert) {\n // convert from pem if necessary\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n\n ensureSubjectHasHash(cert.subject);\n\n if(!caStore.hasCertificate(cert)) { // avoid duplicate certificates in store\n if(cert.subject.hash in caStore.certs) {\n // subject hash already exists, append to array\n var tmp = caStore.certs[cert.subject.hash];\n if(!forge.util.isArray(tmp)) {\n tmp = [tmp];\n }\n tmp.push(cert);\n caStore.certs[cert.subject.hash] = tmp;\n } else {\n caStore.certs[cert.subject.hash] = cert;\n }\n }\n };\n\n /**\n * Checks to see if the given certificate is in the store.\n *\n * @param cert the certificate to check (either a pki.certificate or a\n * PEM-formatted certificate).\n *\n * @return true if the certificate is in the store, false if not.\n */\n caStore.hasCertificate = function(cert) {\n // convert from pem if necessary\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n\n var match = getBySubject(cert.subject);\n if(!match) {\n return false;\n }\n if(!forge.util.isArray(match)) {\n match = [match];\n }\n // compare DER-encoding of certificates\n var der1 = asn1.toDer(pki.certificateToAsn1(cert)).getBytes();\n for(var i = 0; i < match.length; ++i) {\n var der2 = asn1.toDer(pki.certificateToAsn1(match[i])).getBytes();\n if(der1 === der2) {\n return true;\n }\n }\n return false;\n };\n\n /**\n * Lists all of the certificates kept in the store.\n *\n * @return an array of all of the pki.certificate objects in the store.\n */\n caStore.listAllCertificates = function() {\n var certList = [];\n\n for(var hash in caStore.certs) {\n if(caStore.certs.hasOwnProperty(hash)) {\n var value = caStore.certs[hash];\n if(!forge.util.isArray(value)) {\n certList.push(value);\n } else {\n for(var i = 0; i < value.length; ++i) {\n certList.push(value[i]);\n }\n }\n }\n }\n\n return certList;\n };\n\n /**\n * Removes a certificate from the store.\n *\n * @param cert the certificate to remove (either a pki.certificate or a\n * PEM-formatted certificate).\n *\n * @return the certificate that was removed or null if the certificate\n * wasn't in store.\n */\n caStore.removeCertificate = function(cert) {\n var result;\n\n // convert from pem if necessary\n if(typeof cert === 'string') {\n cert = forge.pki.certificateFromPem(cert);\n }\n ensureSubjectHasHash(cert.subject);\n if(!caStore.hasCertificate(cert)) {\n return null;\n }\n\n var match = getBySubject(cert.subject);\n\n if(!forge.util.isArray(match)) {\n result = caStore.certs[cert.subject.hash];\n delete caStore.certs[cert.subject.hash];\n return result;\n }\n\n // compare DER-encoding of certificates\n var der1 = asn1.toDer(pki.certificateToAsn1(cert)).getBytes();\n for(var i = 0; i < match.length; ++i) {\n var der2 = asn1.toDer(pki.certificateToAsn1(match[i])).getBytes();\n if(der1 === der2) {\n result = match[i];\n match.splice(i, 1);\n }\n }\n if(match.length === 0) {\n delete caStore.certs[cert.subject.hash];\n }\n\n return result;\n };\n\n function getBySubject(subject) {\n ensureSubjectHasHash(subject);\n return caStore.certs[subject.hash] || null;\n }\n\n function ensureSubjectHasHash(subject) {\n // produce subject hash if it doesn't exist\n if(!subject.hash) {\n var md = forge.md.sha1.create();\n subject.attributes = pki.RDNAttributesAsArray(_dnToAsn1(subject), md);\n subject.hash = md.digest().toHex();\n }\n }\n\n // auto-add passed in certs\n if(certs) {\n // parse PEM-formatted certificates as necessary\n for(var i = 0; i < certs.length; ++i) {\n var cert = certs[i];\n caStore.addCertificate(cert);\n }\n }\n\n return caStore;\n};\n\n/**\n * Certificate verification errors, based on TLS.\n */\npki.certificateError = {\n bad_certificate: 'forge.pki.BadCertificate',\n unsupported_certificate: 'forge.pki.UnsupportedCertificate',\n certificate_revoked: 'forge.pki.CertificateRevoked',\n certificate_expired: 'forge.pki.CertificateExpired',\n certificate_unknown: 'forge.pki.CertificateUnknown',\n unknown_ca: 'forge.pki.UnknownCertificateAuthority'\n};\n\n/**\n * Verifies a certificate chain against the given Certificate Authority store\n * with an optional custom verify callback.\n *\n * @param caStore a certificate store to verify against.\n * @param chain the certificate chain to verify, with the root or highest\n * authority at the end (an array of certificates).\n * @param options a callback to be called for every certificate in the chain or\n * an object with:\n * verify a callback to be called for every certificate in the\n * chain\n * validityCheckDate the date against which the certificate\n * validity period should be checked. Pass null to not check\n * the validity period. By default, the current date is used.\n *\n * The verify callback has the following signature:\n *\n * verified - Set to true if certificate was verified, otherwise the\n * pki.certificateError for why the certificate failed.\n * depth - The current index in the chain, where 0 is the end point's cert.\n * certs - The certificate chain, *NOTE* an empty chain indicates an anonymous\n * end point.\n *\n * The function returns true on success and on failure either the appropriate\n * pki.certificateError or an object with 'error' set to the appropriate\n * pki.certificateError and 'message' set to a custom error message.\n *\n * @return true if successful, error thrown if not.\n */\npki.verifyCertificateChain = function(caStore, chain, options) {\n /* From: RFC3280 - Internet X.509 Public Key Infrastructure Certificate\n Section 6: Certification Path Validation\n See inline parentheticals related to this particular implementation.\n\n The primary goal of path validation is to verify the binding between\n a subject distinguished name or a subject alternative name and subject\n public key, as represented in the end entity certificate, based on the\n public key of the trust anchor. This requires obtaining a sequence of\n certificates that support that binding. That sequence should be provided\n in the passed 'chain'. The trust anchor should be in the given CA\n store. The 'end entity' certificate is the certificate provided by the\n end point (typically a server) and is the first in the chain.\n\n To meet this goal, the path validation process verifies, among other\n things, that a prospective certification path (a sequence of n\n certificates or a 'chain') satisfies the following conditions:\n\n (a) for all x in {1, ..., n-1}, the subject of certificate x is\n the issuer of certificate x+1;\n\n (b) certificate 1 is issued by the trust anchor;\n\n (c) certificate n is the certificate to be validated; and\n\n (d) for all x in {1, ..., n}, the certificate was valid at the\n time in question.\n\n Note that here 'n' is index 0 in the chain and 1 is the last certificate\n in the chain and it must be signed by a certificate in the connection's\n CA store.\n\n The path validation process also determines the set of certificate\n policies that are valid for this path, based on the certificate policies\n extension, policy mapping extension, policy constraints extension, and\n inhibit any-policy extension.\n\n Note: Policy mapping extension not supported (Not Required).\n\n Note: If the certificate has an unsupported critical extension, then it\n must be rejected.\n\n Note: A certificate is self-issued if the DNs that appear in the subject\n and issuer fields are identical and are not empty.\n\n The path validation algorithm assumes the following seven inputs are\n provided to the path processing logic. What this specific implementation\n will use is provided parenthetically:\n\n (a) a prospective certification path of length n (the 'chain')\n (b) the current date/time: ('now').\n (c) user-initial-policy-set: A set of certificate policy identifiers\n naming the policies that are acceptable to the certificate user.\n The user-initial-policy-set contains the special value any-policy\n if the user is not concerned about certificate policy\n (Not implemented. Any policy is accepted).\n (d) trust anchor information, describing a CA that serves as a trust\n anchor for the certification path. The trust anchor information\n includes:\n\n (1) the trusted issuer name,\n (2) the trusted public key algorithm,\n (3) the trusted public key, and\n (4) optionally, the trusted public key parameters associated\n with the public key.\n\n (Trust anchors are provided via certificates in the CA store).\n\n The trust anchor information may be provided to the path processing\n procedure in the form of a self-signed certificate. The trusted anchor\n information is trusted because it was delivered to the path processing\n procedure by some trustworthy out-of-band procedure. If the trusted\n public key algorithm requires parameters, then the parameters are\n provided along with the trusted public key (No parameters used in this\n implementation).\n\n (e) initial-policy-mapping-inhibit, which indicates if policy mapping is\n allowed in the certification path.\n (Not implemented, no policy checking)\n\n (f) initial-explicit-policy, which indicates if the path must be valid\n for at least one of the certificate policies in the user-initial-\n policy-set.\n (Not implemented, no policy checking)\n\n (g) initial-any-policy-inhibit, which indicates whether the\n anyPolicy OID should be processed if it is included in a\n certificate.\n (Not implemented, so any policy is valid provided that it is\n not marked as critical) */\n\n /* Basic Path Processing:\n\n For each certificate in the 'chain', the following is checked:\n\n 1. The certificate validity period includes the current time.\n 2. The certificate was signed by its parent (where the parent is either\n the next in the chain or from the CA store). Allow processing to\n continue to the next step if no parent is found but the certificate is\n in the CA store.\n 3. TODO: The certificate has not been revoked.\n 4. The certificate issuer name matches the parent's subject name.\n 5. TODO: If the certificate is self-issued and not the final certificate\n in the chain, skip this step, otherwise verify that the subject name\n is within one of the permitted subtrees of X.500 distinguished names\n and that each of the alternative names in the subjectAltName extension\n (critical or non-critical) is within one of the permitted subtrees for\n that name type.\n 6. TODO: If the certificate is self-issued and not the final certificate\n in the chain, skip this step, otherwise verify that the subject name\n is not within one of the excluded subtrees for X.500 distinguished\n names and none of the subjectAltName extension names are excluded for\n that name type.\n 7. The other steps in the algorithm for basic path processing involve\n handling the policy extension which is not presently supported in this\n implementation. Instead, if a critical policy extension is found, the\n certificate is rejected as not supported.\n 8. If the certificate is not the first or if its the only certificate in\n the chain (having no parent from the CA store or is self-signed) and it\n has a critical key usage extension, verify that the keyCertSign bit is\n set. If the key usage extension exists, verify that the basic\n constraints extension exists. If the basic constraints extension exists,\n verify that the cA flag is set. If pathLenConstraint is set, ensure that\n the number of certificates that precede in the chain (come earlier\n in the chain as implemented below), excluding the very first in the\n chain (typically the end-entity one), isn't greater than the\n pathLenConstraint. This constraint limits the number of intermediate\n CAs that may appear below a CA before only end-entity certificates\n may be issued. */\n\n // if a verify callback is passed as the third parameter, package it within\n // the options object. This is to support a legacy function signature that\n // expected the verify callback as the third parameter.\n if(typeof options === 'function') {\n options = {verify: options};\n }\n options = options || {};\n\n // copy cert chain references to another array to protect against changes\n // in verify callback\n chain = chain.slice(0);\n var certs = chain.slice(0);\n\n var validityCheckDate = options.validityCheckDate;\n // if no validityCheckDate is specified, default to the current date. Make\n // sure to maintain the value null because it indicates that the validity\n // period should not be checked.\n if(typeof validityCheckDate === 'undefined') {\n validityCheckDate = new Date();\n }\n\n // verify each cert in the chain using its parent, where the parent\n // is either the next in the chain or from the CA store\n var first = true;\n var error = null;\n var depth = 0;\n do {\n var cert = chain.shift();\n var parent = null;\n var selfSigned = false;\n\n if(validityCheckDate) {\n // 1. check valid time\n if(validityCheckDate < cert.validity.notBefore ||\n validityCheckDate > cert.validity.notAfter) {\n error = {\n message: 'Certificate is not valid yet or has expired.',\n error: pki.certificateError.certificate_expired,\n notBefore: cert.validity.notBefore,\n notAfter: cert.validity.notAfter,\n // TODO: we might want to reconsider renaming 'now' to\n // 'validityCheckDate' should this API be changed in the future.\n now: validityCheckDate\n };\n }\n }\n\n // 2. verify with parent from chain or CA store\n if(error === null) {\n parent = chain[0] || caStore.getIssuer(cert);\n if(parent === null) {\n // check for self-signed cert\n if(cert.isIssuer(cert)) {\n selfSigned = true;\n parent = cert;\n }\n }\n\n if(parent) {\n // FIXME: current CA store implementation might have multiple\n // certificates where the issuer can't be determined from the\n // certificate (happens rarely with, eg: old certificates) so normalize\n // by always putting parents into an array\n // TODO: there's may be an extreme degenerate case currently uncovered\n // where an old intermediate certificate seems to have a matching parent\n // but none of the parents actually verify ... but the intermediate\n // is in the CA and it should pass this check; needs investigation\n var parents = parent;\n if(!forge.util.isArray(parents)) {\n parents = [parents];\n }\n\n // try to verify with each possible parent (typically only one)\n var verified = false;\n while(!verified && parents.length > 0) {\n parent = parents.shift();\n try {\n verified = parent.verify(cert);\n } catch(ex) {\n // failure to verify, don't care why, try next one\n }\n }\n\n if(!verified) {\n error = {\n message: 'Certificate signature is invalid.',\n error: pki.certificateError.bad_certificate\n };\n }\n }\n\n if(error === null && (!parent || selfSigned) &&\n !caStore.hasCertificate(cert)) {\n // no parent issuer and certificate itself is not trusted\n error = {\n message: 'Certificate is not trusted.',\n error: pki.certificateError.unknown_ca\n };\n }\n }\n\n // TODO: 3. check revoked\n\n // 4. check for matching issuer/subject\n if(error === null && parent && !cert.isIssuer(parent)) {\n // parent is not issuer\n error = {\n message: 'Certificate issuer is invalid.',\n error: pki.certificateError.bad_certificate\n };\n }\n\n // 5. TODO: check names with permitted names tree\n\n // 6. TODO: check names against excluded names tree\n\n // 7. check for unsupported critical extensions\n if(error === null) {\n // supported extensions\n var se = {\n keyUsage: true,\n basicConstraints: true\n };\n for(var i = 0; error === null && i < cert.extensions.length; ++i) {\n var ext = cert.extensions[i];\n if(ext.critical && !(ext.name in se)) {\n error = {\n message:\n 'Certificate has an unsupported critical extension.',\n error: pki.certificateError.unsupported_certificate\n };\n }\n }\n }\n\n // 8. check for CA if cert is not first or is the only certificate\n // remaining in chain with no parent or is self-signed\n if(error === null &&\n (!first || (chain.length === 0 && (!parent || selfSigned)))) {\n // first check keyUsage extension and then basic constraints\n var bcExt = cert.getExtension('basicConstraints');\n var keyUsageExt = cert.getExtension('keyUsage');\n if(keyUsageExt !== null) {\n // keyCertSign must be true and there must be a basic\n // constraints extension\n if(!keyUsageExt.keyCertSign || bcExt === null) {\n // bad certificate\n error = {\n message:\n 'Certificate keyUsage or basicConstraints conflict ' +\n 'or indicate that the certificate is not a CA. ' +\n 'If the certificate is the only one in the chain or ' +\n 'isn\\'t the first then the certificate must be a ' +\n 'valid CA.',\n error: pki.certificateError.bad_certificate\n };\n }\n }\n // basic constraints cA flag must be set\n if(error === null && bcExt !== null && !bcExt.cA) {\n // bad certificate\n error = {\n message:\n 'Certificate basicConstraints indicates the certificate ' +\n 'is not a CA.',\n error: pki.certificateError.bad_certificate\n };\n }\n // if error is not null and keyUsage is available, then we know it\n // has keyCertSign and there is a basic constraints extension too,\n // which means we can check pathLenConstraint (if it exists)\n if(error === null && keyUsageExt !== null &&\n 'pathLenConstraint' in bcExt) {\n // pathLen is the maximum # of intermediate CA certs that can be\n // found between the current certificate and the end-entity (depth 0)\n // certificate; this number does not include the end-entity (depth 0,\n // last in the chain) even if it happens to be a CA certificate itself\n var pathLen = depth - 1;\n if(pathLen > bcExt.pathLenConstraint) {\n // pathLenConstraint violated, bad certificate\n error = {\n message:\n 'Certificate basicConstraints pathLenConstraint violated.',\n error: pki.certificateError.bad_certificate\n };\n }\n }\n }\n\n // call application callback\n var vfd = (error === null) ? true : error.error;\n var ret = options.verify ? options.verify(vfd, depth, certs) : vfd;\n if(ret === true) {\n // clear any set error\n error = null;\n } else {\n // if passed basic tests, set default message and alert\n if(vfd === true) {\n error = {\n message: 'The application rejected the certificate.',\n error: pki.certificateError.bad_certificate\n };\n }\n\n // check for custom error info\n if(ret || ret === 0) {\n // set custom message and error\n if(typeof ret === 'object' && !forge.util.isArray(ret)) {\n if(ret.message) {\n error.message = ret.message;\n }\n if(ret.error) {\n error.error = ret.error;\n }\n } else if(typeof ret === 'string') {\n // set custom error\n error.error = ret;\n }\n }\n\n // throw error\n throw error;\n }\n\n // no longer first cert in chain\n first = false;\n ++depth;\n } while(chain.length > 0);\n\n return true;\n};\n","var wrappy = require('wrappy')\nmodule.exports = wrappy(once)\nmodule.exports.strict = wrappy(onceStrict)\n\nonce.proto = once(function () {\n Object.defineProperty(Function.prototype, 'once', {\n value: function () {\n return once(this)\n },\n configurable: true\n })\n\n Object.defineProperty(Function.prototype, 'onceStrict', {\n value: function () {\n return onceStrict(this)\n },\n configurable: true\n })\n})\n\nfunction once (fn) {\n var f = function () {\n if (f.called) return f.value\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n f.called = false\n return f\n}\n\nfunction onceStrict (fn) {\n var f = function () {\n if (f.called)\n throw new Error(f.onceError)\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n var name = fn.name || 'Function wrapped with `once`'\n f.onceError = name + \" shouldn't be called more than once\"\n f.called = false\n return f\n}\n","var once = require('once')\nvar eos = require('end-of-stream')\nvar fs = require('fs') // we only need fs to get the ReadStream and WriteStream prototypes\n\nvar noop = function () {}\nvar ancient = /^v?\\.0/.test(process.version)\n\nvar isFn = function (fn) {\n return typeof fn === 'function'\n}\n\nvar isFS = function (stream) {\n if (!ancient) return false // newer node version do not need to care about fs is a special way\n if (!fs) return false // browser\n return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close)\n}\n\nvar isRequest = function (stream) {\n return stream.setHeader && isFn(stream.abort)\n}\n\nvar destroyer = function (stream, reading, writing, callback) {\n callback = once(callback)\n\n var closed = false\n stream.on('close', function () {\n closed = true\n })\n\n eos(stream, {readable: reading, writable: writing}, function (err) {\n if (err) return callback(err)\n closed = true\n callback()\n })\n\n var destroyed = false\n return function (err) {\n if (closed) return\n if (destroyed) return\n destroyed = true\n\n if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks\n if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want\n\n if (isFn(stream.destroy)) return stream.destroy()\n\n callback(err || new Error('stream was destroyed'))\n }\n}\n\nvar call = function (fn) {\n fn()\n}\n\nvar pipe = function (from, to) {\n return from.pipe(to)\n}\n\nvar pump = function () {\n var streams = Array.prototype.slice.call(arguments)\n var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop\n\n if (Array.isArray(streams[0])) streams = streams[0]\n if (streams.length < 2) throw new Error('pump requires two streams per minimum')\n\n var error\n var destroys = streams.map(function (stream, i) {\n var reading = i < streams.length - 1\n var writing = i > 0\n return destroyer(stream, reading, writing, function (err) {\n if (!error) error = err\n if (err) destroys.forEach(call)\n if (reading) return\n destroys.forEach(call)\n callback(error)\n })\n })\n\n return streams.reduce(pipe)\n}\n\nmodule.exports = pump\n","'use strict';\n\nconst codes = {};\n\nfunction createErrorType(code, message, Base) {\n if (!Base) {\n Base = Error\n }\n\n function getMessage (arg1, arg2, arg3) {\n if (typeof message === 'string') {\n return message\n } else {\n return message(arg1, arg2, arg3)\n }\n }\n\n class NodeError extends Base {\n constructor (arg1, arg2, arg3) {\n super(getMessage(arg1, arg2, arg3));\n }\n }\n\n NodeError.prototype.name = Base.name;\n NodeError.prototype.code = code;\n\n codes[code] = NodeError;\n}\n\n// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js\nfunction oneOf(expected, thing) {\n if (Array.isArray(expected)) {\n const len = expected.length;\n expected = expected.map((i) => String(i));\n if (len > 2) {\n return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +\n expected[len - 1];\n } else if (len === 2) {\n return `one of ${thing} ${expected[0]} or ${expected[1]}`;\n } else {\n return `of ${thing} ${expected[0]}`;\n }\n } else {\n return `of ${thing} ${String(expected)}`;\n }\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\nfunction startsWith(str, search, pos) {\n\treturn str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith\nfunction endsWith(str, search, this_len) {\n\tif (this_len === undefined || this_len > str.length) {\n\t\tthis_len = str.length;\n\t}\n\treturn str.substring(this_len - search.length, this_len) === search;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes\nfunction includes(str, search, start) {\n if (typeof start !== 'number') {\n start = 0;\n }\n\n if (start + search.length > str.length) {\n return false;\n } else {\n return str.indexOf(search, start) !== -1;\n }\n}\n\ncreateErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {\n return 'The value \"' + value + '\" is invalid for option \"' + name + '\"'\n}, TypeError);\ncreateErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {\n // determiner: 'must be' or 'must not be'\n let determiner;\n if (typeof expected === 'string' && startsWith(expected, 'not ')) {\n determiner = 'must not be';\n expected = expected.replace(/^not /, '');\n } else {\n determiner = 'must be';\n }\n\n let msg;\n if (endsWith(name, ' argument')) {\n // For cases like 'first argument'\n msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;\n } else {\n const type = includes(name, '.') ? 'property' : 'argument';\n msg = `The \"${name}\" ${type} ${determiner} ${oneOf(expected, 'type')}`;\n }\n\n msg += `. Received type ${typeof actual}`;\n return msg;\n}, TypeError);\ncreateErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');\ncreateErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {\n return 'The ' + name + ' method is not implemented'\n});\ncreateErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');\ncreateErrorType('ERR_STREAM_DESTROYED', function (name) {\n return 'Cannot call ' + name + ' after a stream was destroyed';\n});\ncreateErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');\ncreateErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');\ncreateErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');\ncreateErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);\ncreateErrorType('ERR_UNKNOWN_ENCODING', function (arg) {\n return 'Unknown encoding: ' + arg\n}, TypeError);\ncreateErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');\n\nmodule.exports.codes = codes;\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n'use strict';\n/**/\n\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n\n for (var key in obj) {\n keys.push(key);\n }\n\n return keys;\n};\n/**/\n\n\nmodule.exports = Duplex;\n\nvar Readable = require('./_stream_readable');\n\nvar Writable = require('./_stream_writable');\n\nrequire('inherits')(Duplex, Readable);\n\n{\n // Allow the keys array to be GC'ed.\n var keys = objectKeys(Writable.prototype);\n\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n Readable.call(this, options);\n Writable.call(this, options);\n this.allowHalfOpen = true;\n\n if (options) {\n if (options.readable === false) this.readable = false;\n if (options.writable === false) this.writable = false;\n\n if (options.allowHalfOpen === false) {\n this.allowHalfOpen = false;\n this.once('end', onend);\n }\n }\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.highWaterMark;\n }\n});\nObject.defineProperty(Duplex.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\nObject.defineProperty(Duplex.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.length;\n }\n}); // the no-half-open enforcer\n\nfunction onend() {\n // If the writable side ended, then we're ok.\n if (this._writableState.ended) return; // no more data can be written.\n // But allow more writes to happen in this tick.\n\n process.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\nrequire('inherits')(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n'use strict';\n\nmodule.exports = Readable;\n/**/\n\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n/**/\n\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function EElistenerCount(emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\n\n\nvar Stream = require('./internal/streams/stream');\n/**/\n\n\nvar Buffer = require('buffer').Buffer;\n\nvar OurUint8Array = global.Uint8Array || function () {};\n\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\n\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n/**/\n\n\nvar debugUtil = require('util');\n\nvar debug;\n\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function debug() {};\n}\n/**/\n\n\nvar BufferList = require('./internal/streams/buffer_list');\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nvar _require = require('./internal/streams/state'),\n getHighWaterMark = _require.getHighWaterMark;\n\nvar _require$codes = require('../errors').codes,\n ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,\n ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.\n\n\nvar StringDecoder;\nvar createReadableStreamAsyncIterator;\nvar from;\n\nrequire('inherits')(Readable, Stream);\n\nvar errorOrDestroy = destroyImpl.errorOrDestroy;\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream, isDuplex) {\n Duplex = Duplex || require('./_stream_duplex');\n options = options || {}; // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n\n this.objectMode = !!options.objectMode;\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n\n this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n\n this.sync = true; // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n this.paused = true; // Should close be emitted on destroy. Defaults to true.\n\n this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')\n\n this.autoDestroy = !!options.autoDestroy; // has it been destroyed\n\n this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n\n this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s\n\n this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled\n\n this.readingMore = false;\n this.decoder = null;\n this.encoding = null;\n\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside\n // the ReadableState constructor, at least with V8 6.5\n\n var isDuplex = this instanceof Duplex;\n this._readableState = new ReadableState(options, this, isDuplex); // legacy\n\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._readableState === undefined) {\n return false;\n }\n\n return this._readableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._readableState.destroyed = value;\n }\n});\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\n\nReadable.prototype._destroy = function (err, cb) {\n cb(err);\n}; // Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\n\n\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n}; // Unshift should *always* be something directly out of read()\n\n\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n debug('readableAddChunk', chunk);\n var state = stream._readableState;\n\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n\n if (er) {\n errorOrDestroy(stream, er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());\n } else if (state.destroyed) {\n return false;\n } else {\n state.reading = false;\n\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n maybeReadMore(stream, state);\n }\n } // We can push more data if we are below the highWaterMark.\n // Also, if we have no data yet, we can stand some more bytes.\n // This is to work around cases where hwm=0, such as the repl.\n\n\n return !state.ended && (state.length < state.highWaterMark || state.length === 0);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n state.awaitDrain = 0;\n stream.emit('data', chunk);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n if (state.needReadable) emitReadable(stream);\n }\n\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);\n }\n\n return er;\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n}; // backwards compatibility.\n\n\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n var decoder = new StringDecoder(enc);\n this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8\n\n this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:\n\n var p = this._readableState.buffer.head;\n var content = '';\n\n while (p !== null) {\n content += decoder.write(p.data);\n p = p.next;\n }\n\n this._readableState.buffer.clear();\n\n if (content !== '') this._readableState.buffer.push(content);\n this._readableState.length = content.length;\n return this;\n}; // Don't raise the hwm > 1GB\n\n\nvar MAX_HWM = 0x40000000;\n\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n\n return n;\n} // This function is designed to be inlinable, so please take care when making\n// changes to the function body.\n\n\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n } // If we're asking for more than the current hwm, then raise the hwm.\n\n\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n; // Don't have enough\n\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n\n return state.length;\n} // you can override either this method, or the async _read(n) below.\n\n\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n\n if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.\n\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n } // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n // if we need a readable event, then we need to do some reading.\n\n\n var doRead = state.needReadable;\n debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some\n\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n } // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n\n\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true; // if the length is currently zero, then we *need* a readable event.\n\n if (state.length === 0) state.needReadable = true; // call internal read method\n\n this._read(state.highWaterMark);\n\n state.sync = false; // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = state.length <= state.highWaterMark;\n n = 0;\n } else {\n state.length -= n;\n state.awaitDrain = 0;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.\n\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n debug('onEofChunk');\n if (state.ended) return;\n\n if (state.decoder) {\n var chunk = state.decoder.end();\n\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n\n state.ended = true;\n\n if (state.sync) {\n // if we are sync, wait until next tick to emit the data.\n // Otherwise we risk emitting data in the flow()\n // the readable code triggers during a read() call\n emitReadable(stream);\n } else {\n // emit 'readable' now to make sure it gets picked up.\n state.needReadable = false;\n\n if (!state.emittedReadable) {\n state.emittedReadable = true;\n emitReadable_(stream);\n }\n }\n} // Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\n\n\nfunction emitReadable(stream) {\n var state = stream._readableState;\n debug('emitReadable', state.needReadable, state.emittedReadable);\n state.needReadable = false;\n\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n process.nextTick(emitReadable_, stream);\n }\n}\n\nfunction emitReadable_(stream) {\n var state = stream._readableState;\n debug('emitReadable_', state.destroyed, state.length, state.ended);\n\n if (!state.destroyed && (state.length || state.ended)) {\n stream.emit('readable');\n state.emittedReadable = false;\n } // The stream needs another readable event if\n // 1. It is not flowing, as the flow mechanism will take\n // care of it.\n // 2. It is not ended.\n // 3. It is below the highWaterMark, so we can schedule\n // another readable later.\n\n\n state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;\n flow(stream);\n} // at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\n\n\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n process.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n // Attempt to read more data if we should.\n //\n // The conditions for reading more data are (one of):\n // - Not enough data buffered (state.length < state.highWaterMark). The loop\n // is responsible for filling the buffer with enough data if such data\n // is available. If highWaterMark is 0 and we are not in the flowing mode\n // we should _not_ attempt to buffer any extra data. We'll get more data\n // when the stream consumer calls read() instead.\n // - No data in the buffer, and the stream is in flowing mode. In this mode\n // the loop below is responsible for ensuring read() is called. Failing to\n // call read here would abort the flow and there's no other mechanism for\n // continuing the flow if the stream consumer has just subscribed to the\n // 'data' event.\n //\n // In addition to the above conditions to keep reading data, the following\n // conditions prevent the data from being read:\n // - The stream has ended (state.ended).\n // - There is already a pending 'read' operation (state.reading). This is a\n // case where the the stream has called the implementation defined _read()\n // method, but they are processing the call asynchronously and have _not_\n // called push() with new data. In this case we skip performing more\n // read()s. The execution ends in this method again after the _read() ends\n // up calling push() with more data.\n while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {\n var len = state.length;\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length) // didn't get any data, stop spinning.\n break;\n }\n\n state.readingMore = false;\n} // abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\n\n\nReadable.prototype._read = function (n) {\n errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n\n default:\n state.pipes.push(dest);\n break;\n }\n\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);\n dest.on('unpipe', onunpipe);\n\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n } // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n\n\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n var cleanedUp = false;\n\n function cleanup() {\n debug('cleanup'); // cleanup event handlers once the pipe is broken\n\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n cleanedUp = true; // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n src.on('data', ondata);\n\n function ondata(chunk) {\n debug('ondata');\n var ret = dest.write(chunk);\n debug('dest.write', ret);\n\n if (ret === false) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', state.awaitDrain);\n state.awaitDrain++;\n }\n\n src.pause();\n }\n } // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n\n\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);\n } // Make sure our error handler is attached before userland ones.\n\n\n prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.\n\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n\n dest.once('close', onclose);\n\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n } // tell the dest that it's being piped to\n\n\n dest.emit('pipe', src); // start the flow if it hasn't been started already.\n\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function pipeOnDrainFunctionResult() {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = {\n hasUnpiped: false\n }; // if we're not piping anywhere, then do nothing.\n\n if (state.pipesCount === 0) return this; // just one destination. most common case.\n\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n if (!dest) dest = state.pipes; // got a match.\n\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n } // slow case. multiple pipe destinations.\n\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, {\n hasUnpiped: false\n });\n }\n\n return this;\n } // try to find the right one.\n\n\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n dest.emit('unpipe', this, unpipeInfo);\n return this;\n}; // set up data events if they are asked for\n// Ensure readable listeners eventually get something\n\n\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n var state = this._readableState;\n\n if (ev === 'data') {\n // update readableListening so that resume() may be a no-op\n // a few lines down. This is needed to support once('readable').\n state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused\n\n if (state.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.flowing = false;\n state.emittedReadable = false;\n debug('on readable', state.length, state.reading);\n\n if (state.length) {\n emitReadable(this);\n } else if (!state.reading) {\n process.nextTick(nReadingNextTick, this);\n }\n }\n }\n\n return res;\n};\n\nReadable.prototype.addListener = Readable.prototype.on;\n\nReadable.prototype.removeListener = function (ev, fn) {\n var res = Stream.prototype.removeListener.call(this, ev, fn);\n\n if (ev === 'readable') {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nReadable.prototype.removeAllListeners = function (ev) {\n var res = Stream.prototype.removeAllListeners.apply(this, arguments);\n\n if (ev === 'readable' || ev === undefined) {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nfunction updateReadableListening(self) {\n var state = self._readableState;\n state.readableListening = self.listenerCount('readable') > 0;\n\n if (state.resumeScheduled && !state.paused) {\n // flowing needs to be set to true now, otherwise\n // the upcoming resume will not flow.\n state.flowing = true; // crude way to check if we should resume\n } else if (self.listenerCount('data') > 0) {\n self.resume();\n }\n}\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n} // pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\n\n\nReadable.prototype.resume = function () {\n var state = this._readableState;\n\n if (!state.flowing) {\n debug('resume'); // we flow only if there is no one listening\n // for readable, but we still have to call\n // resume()\n\n state.flowing = !state.readableListening;\n resume(this, state);\n }\n\n state.paused = false;\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n process.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n debug('resume', state.reading);\n\n if (!state.reading) {\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n\n if (this._readableState.flowing !== false) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n\n this._readableState.paused = true;\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n\n while (state.flowing && stream.read() !== null) {\n ;\n }\n} // wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\n\n\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n stream.on('end', function () {\n debug('wrapped end');\n\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode\n\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n\n if (!ret) {\n paused = true;\n stream.pause();\n }\n }); // proxy all the other methods.\n // important when wrapping filters and duplexes.\n\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function methodWrap(method) {\n return function methodWrapReturnFunction() {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n } // proxy certain important events.\n\n\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n } // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n\n\n this._read = function (n) {\n debug('wrapped _read', n);\n\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nif (typeof Symbol === 'function') {\n Readable.prototype[Symbol.asyncIterator] = function () {\n if (createReadableStreamAsyncIterator === undefined) {\n createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');\n }\n\n return createReadableStreamAsyncIterator(this);\n };\n}\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.highWaterMark;\n }\n});\nObject.defineProperty(Readable.prototype, 'readableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState && this._readableState.buffer;\n }\n});\nObject.defineProperty(Readable.prototype, 'readableFlowing', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.flowing;\n },\n set: function set(state) {\n if (this._readableState) {\n this._readableState.flowing = state;\n }\n }\n}); // exposed for testing purposes only.\n\nReadable._fromList = fromList;\nObject.defineProperty(Readable.prototype, 'readableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._readableState.length;\n }\n}); // Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\n\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = state.buffer.consume(n, state.decoder);\n }\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n debug('endReadable', state.endEmitted);\n\n if (!state.endEmitted) {\n state.ended = true;\n process.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.\n\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n\n if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the writable side is ready for autoDestroy as well\n var wState = stream._writableState;\n\n if (!wState || wState.autoDestroy && wState.finished) {\n stream.destroy();\n }\n }\n }\n}\n\nif (typeof Symbol === 'function') {\n Readable.from = function (iterable, opts) {\n if (from === undefined) {\n from = require('./internal/streams/from');\n }\n\n return from(Readable, iterable, opts);\n };\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n\n return -1;\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n'use strict';\n\nmodule.exports = Transform;\n\nvar _require$codes = require('../errors').codes,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,\n ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,\n ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;\n\nvar Duplex = require('./_stream_duplex');\n\nrequire('inherits')(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n var cb = ts.writecb;\n\n if (cb === null) {\n return this.emit('error', new ERR_MULTIPLE_CALLBACK());\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n cb(er);\n var rs = this._readableState;\n rs.reading = false;\n\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n Duplex.call(this, options);\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n }; // start out asking for a readable event once data is transformed.\n\n this._readableState.needReadable = true; // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n if (typeof options.flush === 'function') this._flush = options.flush;\n } // When the writable side finishes, then flush out anything remaining.\n\n\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function' && !this._readableState.destroyed) {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n}; // This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\n\n\nTransform.prototype._transform = function (chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n}; // Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\n\n\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && !ts.transforming) {\n ts.transforming = true;\n\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data); // TODO(BridgeAR): Write a test for these two error cases\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n\n if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();\n if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();\n return stream.push(null);\n}","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n'use strict';\n\nmodule.exports = Writable;\n/* */\n\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n} // It seems a linked list but it is not\n// there will be only 2 of these for each stream\n\n\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\n\n\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n/**/\n\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\n\nvar Stream = require('./internal/streams/stream');\n/**/\n\n\nvar Buffer = require('buffer').Buffer;\n\nvar OurUint8Array = global.Uint8Array || function () {};\n\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\n\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nvar _require = require('./internal/streams/state'),\n getHighWaterMark = _require.getHighWaterMark;\n\nvar _require$codes = require('../errors').codes,\n ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,\n ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,\n ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,\n ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,\n ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,\n ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,\n ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;\n\nvar errorOrDestroy = destroyImpl.errorOrDestroy;\n\nrequire('inherits')(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream, isDuplex) {\n Duplex = Duplex || require('./_stream_duplex');\n options = options || {}; // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream,\n // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.\n\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n\n this.objectMode = !!options.objectMode;\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n\n this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called\n\n this.finalCalled = false; // drain event flag.\n\n this.needDrain = false; // at the start of calling end()\n\n this.ending = false; // when end() has been called, and returned\n\n this.ended = false; // when 'finish' is emitted\n\n this.finished = false; // has it been destroyed\n\n this.destroyed = false; // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n\n this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n\n this.length = 0; // a flag to see when we're in the middle of a write.\n\n this.writing = false; // when true all writes will be buffered until .uncork() call\n\n this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n\n this.sync = true; // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n\n this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)\n\n this.onwrite = function (er) {\n onwrite(stream, er);\n }; // the callback that the user supplies to write(chunk,encoding,cb)\n\n\n this.writecb = null; // the amount that is being written when _write is called.\n\n this.writelen = 0;\n this.bufferedRequest = null;\n this.lastBufferedRequest = null; // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n\n this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n\n this.prefinished = false; // True if the error was already emitted and should not be thrown again\n\n this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.\n\n this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')\n\n this.autoDestroy = !!options.autoDestroy; // count buffered requests\n\n this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n\n while (current) {\n out.push(current);\n current = current.next;\n }\n\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function writableStateBufferGetter() {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})(); // Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\n\n\nvar realHasInstance;\n\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function value(object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function realHasInstance(object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n // Checking for a Stream.Duplex instance is faster here instead of inside\n // the WritableState constructor, at least with V8 6.5\n\n var isDuplex = this instanceof Duplex;\n if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);\n this._writableState = new WritableState(options, this, isDuplex); // legacy.\n\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n if (typeof options.writev === 'function') this._writev = options.writev;\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n} // Otherwise people can pipe Writable streams, which is just wrong.\n\n\nWritable.prototype.pipe = function () {\n errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb\n\n errorOrDestroy(stream, er);\n process.nextTick(cb, er);\n} // Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\n\n\nfunction validChunk(stream, state, chunk, cb) {\n var er;\n\n if (chunk === null) {\n er = new ERR_STREAM_NULL_VALUES();\n } else if (typeof chunk !== 'string' && !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);\n }\n\n if (er) {\n errorOrDestroy(stream, er);\n process.nextTick(cb, er);\n return false;\n }\n\n return true;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n if (typeof cb !== 'function') cb = nop;\n if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n return ret;\n};\n\nWritable.prototype.cork = function () {\n this._writableState.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.highWaterMark;\n }\n}); // if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\n\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n\n var len = state.objectMode ? 1 : chunk.length;\n state.length += len;\n var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.\n\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n process.nextTick(cb, er); // this can emit finish, and it will always happen\n // after error\n\n process.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n errorOrDestroy(stream, er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n errorOrDestroy(stream, er); // this can emit finish, but finish must\n // always follow error\n\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();\n onwriteStateUpdate(state);\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state) || stream.destroyed;\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n process.nextTick(afterWrite, stream, state, finished, cb);\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n} // Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\n\n\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it\n\n\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n var count = 0;\n var allBuffers = true;\n\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n\n buffer.allBuffers = allBuffers;\n doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n\n state.pendingcb++;\n state.lastBufferedRequest = null;\n\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks\n\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n } // ignore unnecessary end() calls.\n\n\n if (!state.ending) endWritable(this, state, cb);\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n return this._writableState.length;\n }\n});\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\n\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n\n if (err) {\n errorOrDestroy(stream, err);\n }\n\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\n\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function' && !state.destroyed) {\n state.pendingcb++;\n state.finalCalled = true;\n process.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n\n if (need) {\n prefinish(stream, state);\n\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n\n if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the readable side is ready for autoDestroy as well\n var rState = stream._readableState;\n\n if (!rState || rState.autoDestroy && rState.endEmitted) {\n stream.destroy();\n }\n }\n }\n }\n\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n\n if (cb) {\n if (state.finished) process.nextTick(cb);else stream.once('finish', cb);\n }\n\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n } // reuse the free corkReq.\n\n\n state.corkedRequestsFree.next = corkReq;\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function get() {\n if (this._writableState === undefined) {\n return false;\n }\n\n return this._writableState.destroyed;\n },\n set: function set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n } // backward compatibility, the user is explicitly\n // managing destroyed\n\n\n this._writableState.destroyed = value;\n }\n});\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\n\nWritable.prototype._destroy = function (err, cb) {\n cb(err);\n};","'use strict';\n\nvar _Object$setPrototypeO;\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar finished = require('./end-of-stream');\n\nvar kLastResolve = Symbol('lastResolve');\nvar kLastReject = Symbol('lastReject');\nvar kError = Symbol('error');\nvar kEnded = Symbol('ended');\nvar kLastPromise = Symbol('lastPromise');\nvar kHandlePromise = Symbol('handlePromise');\nvar kStream = Symbol('stream');\n\nfunction createIterResult(value, done) {\n return {\n value: value,\n done: done\n };\n}\n\nfunction readAndResolve(iter) {\n var resolve = iter[kLastResolve];\n\n if (resolve !== null) {\n var data = iter[kStream].read(); // we defer if data is null\n // we can be expecting either 'end' or\n // 'error'\n\n if (data !== null) {\n iter[kLastPromise] = null;\n iter[kLastResolve] = null;\n iter[kLastReject] = null;\n resolve(createIterResult(data, false));\n }\n }\n}\n\nfunction onReadable(iter) {\n // we wait for the next tick, because it might\n // emit an error with process.nextTick\n process.nextTick(readAndResolve, iter);\n}\n\nfunction wrapForNext(lastPromise, iter) {\n return function (resolve, reject) {\n lastPromise.then(function () {\n if (iter[kEnded]) {\n resolve(createIterResult(undefined, true));\n return;\n }\n\n iter[kHandlePromise](resolve, reject);\n }, reject);\n };\n}\n\nvar AsyncIteratorPrototype = Object.getPrototypeOf(function () {});\nvar ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {\n get stream() {\n return this[kStream];\n },\n\n next: function next() {\n var _this = this;\n\n // if we have detected an error in the meanwhile\n // reject straight away\n var error = this[kError];\n\n if (error !== null) {\n return Promise.reject(error);\n }\n\n if (this[kEnded]) {\n return Promise.resolve(createIterResult(undefined, true));\n }\n\n if (this[kStream].destroyed) {\n // We need to defer via nextTick because if .destroy(err) is\n // called, the error will be emitted via nextTick, and\n // we cannot guarantee that there is no error lingering around\n // waiting to be emitted.\n return new Promise(function (resolve, reject) {\n process.nextTick(function () {\n if (_this[kError]) {\n reject(_this[kError]);\n } else {\n resolve(createIterResult(undefined, true));\n }\n });\n });\n } // if we have multiple next() calls\n // we will wait for the previous Promise to finish\n // this logic is optimized to support for await loops,\n // where next() is only called once at a time\n\n\n var lastPromise = this[kLastPromise];\n var promise;\n\n if (lastPromise) {\n promise = new Promise(wrapForNext(lastPromise, this));\n } else {\n // fast path needed to support multiple this.push()\n // without triggering the next() queue\n var data = this[kStream].read();\n\n if (data !== null) {\n return Promise.resolve(createIterResult(data, false));\n }\n\n promise = new Promise(this[kHandlePromise]);\n }\n\n this[kLastPromise] = promise;\n return promise;\n }\n}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {\n return this;\n}), _defineProperty(_Object$setPrototypeO, \"return\", function _return() {\n var _this2 = this;\n\n // destroy(err, cb) is a private API\n // we can guarantee we have that here, because we control the\n // Readable class this is attached to\n return new Promise(function (resolve, reject) {\n _this2[kStream].destroy(null, function (err) {\n if (err) {\n reject(err);\n return;\n }\n\n resolve(createIterResult(undefined, true));\n });\n });\n}), _Object$setPrototypeO), AsyncIteratorPrototype);\n\nvar createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {\n var _Object$create;\n\n var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {\n value: stream,\n writable: true\n }), _defineProperty(_Object$create, kLastResolve, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kLastReject, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kError, {\n value: null,\n writable: true\n }), _defineProperty(_Object$create, kEnded, {\n value: stream._readableState.endEmitted,\n writable: true\n }), _defineProperty(_Object$create, kHandlePromise, {\n value: function value(resolve, reject) {\n var data = iterator[kStream].read();\n\n if (data) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n resolve(createIterResult(data, false));\n } else {\n iterator[kLastResolve] = resolve;\n iterator[kLastReject] = reject;\n }\n },\n writable: true\n }), _Object$create));\n iterator[kLastPromise] = null;\n finished(stream, function (err) {\n if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {\n var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise\n // returned by next() and store the error\n\n if (reject !== null) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n reject(err);\n }\n\n iterator[kError] = err;\n return;\n }\n\n var resolve = iterator[kLastResolve];\n\n if (resolve !== null) {\n iterator[kLastPromise] = null;\n iterator[kLastResolve] = null;\n iterator[kLastReject] = null;\n resolve(createIterResult(undefined, true));\n }\n\n iterator[kEnded] = true;\n });\n stream.on('readable', onReadable.bind(null, iterator));\n return iterator;\n};\n\nmodule.exports = createReadableStreamAsyncIterator;","'use strict';\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar _require = require('buffer'),\n Buffer = _require.Buffer;\n\nvar _require2 = require('util'),\n inspect = _require2.inspect;\n\nvar custom = inspect && inspect.custom || 'inspect';\n\nfunction copyBuffer(src, target, offset) {\n Buffer.prototype.copy.call(src, target, offset);\n}\n\nmodule.exports =\n/*#__PURE__*/\nfunction () {\n function BufferList() {\n _classCallCheck(this, BufferList);\n\n this.head = null;\n this.tail = null;\n this.length = 0;\n }\n\n _createClass(BufferList, [{\n key: \"push\",\n value: function push(v) {\n var entry = {\n data: v,\n next: null\n };\n if (this.length > 0) this.tail.next = entry;else this.head = entry;\n this.tail = entry;\n ++this.length;\n }\n }, {\n key: \"unshift\",\n value: function unshift(v) {\n var entry = {\n data: v,\n next: this.head\n };\n if (this.length === 0) this.tail = entry;\n this.head = entry;\n ++this.length;\n }\n }, {\n key: \"shift\",\n value: function shift() {\n if (this.length === 0) return;\n var ret = this.head.data;\n if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;\n --this.length;\n return ret;\n }\n }, {\n key: \"clear\",\n value: function clear() {\n this.head = this.tail = null;\n this.length = 0;\n }\n }, {\n key: \"join\",\n value: function join(s) {\n if (this.length === 0) return '';\n var p = this.head;\n var ret = '' + p.data;\n\n while (p = p.next) {\n ret += s + p.data;\n }\n\n return ret;\n }\n }, {\n key: \"concat\",\n value: function concat(n) {\n if (this.length === 0) return Buffer.alloc(0);\n var ret = Buffer.allocUnsafe(n >>> 0);\n var p = this.head;\n var i = 0;\n\n while (p) {\n copyBuffer(p.data, ret, i);\n i += p.data.length;\n p = p.next;\n }\n\n return ret;\n } // Consumes a specified amount of bytes or characters from the buffered data.\n\n }, {\n key: \"consume\",\n value: function consume(n, hasStrings) {\n var ret;\n\n if (n < this.head.data.length) {\n // `slice` is the same for buffers and strings.\n ret = this.head.data.slice(0, n);\n this.head.data = this.head.data.slice(n);\n } else if (n === this.head.data.length) {\n // First chunk is a perfect match.\n ret = this.shift();\n } else {\n // Result spans more than one buffer.\n ret = hasStrings ? this._getString(n) : this._getBuffer(n);\n }\n\n return ret;\n }\n }, {\n key: \"first\",\n value: function first() {\n return this.head.data;\n } // Consumes a specified amount of characters from the buffered data.\n\n }, {\n key: \"_getString\",\n value: function _getString(n) {\n var p = this.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) this.head = p.next;else this.head = this.tail = null;\n } else {\n this.head = p;\n p.data = str.slice(nb);\n }\n\n break;\n }\n\n ++c;\n }\n\n this.length -= c;\n return ret;\n } // Consumes a specified amount of bytes from the buffered data.\n\n }, {\n key: \"_getBuffer\",\n value: function _getBuffer(n) {\n var ret = Buffer.allocUnsafe(n);\n var p = this.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) this.head = p.next;else this.head = this.tail = null;\n } else {\n this.head = p;\n p.data = buf.slice(nb);\n }\n\n break;\n }\n\n ++c;\n }\n\n this.length -= c;\n return ret;\n } // Make sure the linked list only shows the minimal necessary information.\n\n }, {\n key: custom,\n value: function value(_, options) {\n return inspect(this, _objectSpread({}, options, {\n // Only inspect one level.\n depth: 0,\n // It should not recurse.\n customInspect: false\n }));\n }\n }]);\n\n return BufferList;\n}();","'use strict'; // undocumented cb() API, needed for core, not for public API\n\nfunction destroy(err, cb) {\n var _this = this;\n\n var readableDestroyed = this._readableState && this._readableState.destroyed;\n var writableDestroyed = this._writableState && this._writableState.destroyed;\n\n if (readableDestroyed || writableDestroyed) {\n if (cb) {\n cb(err);\n } else if (err) {\n if (!this._writableState) {\n process.nextTick(emitErrorNT, this, err);\n } else if (!this._writableState.errorEmitted) {\n this._writableState.errorEmitted = true;\n process.nextTick(emitErrorNT, this, err);\n }\n }\n\n return this;\n } // we set destroyed to true before firing error callbacks in order\n // to make it re-entrance safe in case destroy() is called within callbacks\n\n\n if (this._readableState) {\n this._readableState.destroyed = true;\n } // if this is a duplex stream mark the writable part as destroyed as well\n\n\n if (this._writableState) {\n this._writableState.destroyed = true;\n }\n\n this._destroy(err || null, function (err) {\n if (!cb && err) {\n if (!_this._writableState) {\n process.nextTick(emitErrorAndCloseNT, _this, err);\n } else if (!_this._writableState.errorEmitted) {\n _this._writableState.errorEmitted = true;\n process.nextTick(emitErrorAndCloseNT, _this, err);\n } else {\n process.nextTick(emitCloseNT, _this);\n }\n } else if (cb) {\n process.nextTick(emitCloseNT, _this);\n cb(err);\n } else {\n process.nextTick(emitCloseNT, _this);\n }\n });\n\n return this;\n}\n\nfunction emitErrorAndCloseNT(self, err) {\n emitErrorNT(self, err);\n emitCloseNT(self);\n}\n\nfunction emitCloseNT(self) {\n if (self._writableState && !self._writableState.emitClose) return;\n if (self._readableState && !self._readableState.emitClose) return;\n self.emit('close');\n}\n\nfunction undestroy() {\n if (this._readableState) {\n this._readableState.destroyed = false;\n this._readableState.reading = false;\n this._readableState.ended = false;\n this._readableState.endEmitted = false;\n }\n\n if (this._writableState) {\n this._writableState.destroyed = false;\n this._writableState.ended = false;\n this._writableState.ending = false;\n this._writableState.finalCalled = false;\n this._writableState.prefinished = false;\n this._writableState.finished = false;\n this._writableState.errorEmitted = false;\n }\n}\n\nfunction emitErrorNT(self, err) {\n self.emit('error', err);\n}\n\nfunction errorOrDestroy(stream, err) {\n // We have tests that rely on errors being emitted\n // in the same tick, so changing this is semver major.\n // For now when you opt-in to autoDestroy we allow\n // the error to be emitted nextTick. In a future\n // semver major update we should change the default to this.\n var rState = stream._readableState;\n var wState = stream._writableState;\n if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);\n}\n\nmodule.exports = {\n destroy: destroy,\n undestroy: undestroy,\n errorOrDestroy: errorOrDestroy\n};","// Ported from https://github.com/mafintosh/end-of-stream with\n// permission from the author, Mathias Buus (@mafintosh).\n'use strict';\n\nvar ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;\n\nfunction once(callback) {\n var called = false;\n return function () {\n if (called) return;\n called = true;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n callback.apply(this, args);\n };\n}\n\nfunction noop() {}\n\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function';\n}\n\nfunction eos(stream, opts, callback) {\n if (typeof opts === 'function') return eos(stream, null, opts);\n if (!opts) opts = {};\n callback = once(callback || noop);\n var readable = opts.readable || opts.readable !== false && stream.readable;\n var writable = opts.writable || opts.writable !== false && stream.writable;\n\n var onlegacyfinish = function onlegacyfinish() {\n if (!stream.writable) onfinish();\n };\n\n var writableEnded = stream._writableState && stream._writableState.finished;\n\n var onfinish = function onfinish() {\n writable = false;\n writableEnded = true;\n if (!readable) callback.call(stream);\n };\n\n var readableEnded = stream._readableState && stream._readableState.endEmitted;\n\n var onend = function onend() {\n readable = false;\n readableEnded = true;\n if (!writable) callback.call(stream);\n };\n\n var onerror = function onerror(err) {\n callback.call(stream, err);\n };\n\n var onclose = function onclose() {\n var err;\n\n if (readable && !readableEnded) {\n if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();\n return callback.call(stream, err);\n }\n\n if (writable && !writableEnded) {\n if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();\n return callback.call(stream, err);\n }\n };\n\n var onrequest = function onrequest() {\n stream.req.on('finish', onfinish);\n };\n\n if (isRequest(stream)) {\n stream.on('complete', onfinish);\n stream.on('abort', onclose);\n if (stream.req) onrequest();else stream.on('request', onrequest);\n } else if (writable && !stream._writableState) {\n // legacy streams\n stream.on('end', onlegacyfinish);\n stream.on('close', onlegacyfinish);\n }\n\n stream.on('end', onend);\n stream.on('finish', onfinish);\n if (opts.error !== false) stream.on('error', onerror);\n stream.on('close', onclose);\n return function () {\n stream.removeListener('complete', onfinish);\n stream.removeListener('abort', onclose);\n stream.removeListener('request', onrequest);\n if (stream.req) stream.req.removeListener('finish', onfinish);\n stream.removeListener('end', onlegacyfinish);\n stream.removeListener('close', onlegacyfinish);\n stream.removeListener('finish', onfinish);\n stream.removeListener('end', onend);\n stream.removeListener('error', onerror);\n stream.removeListener('close', onclose);\n };\n}\n\nmodule.exports = eos;","'use strict';\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar ERR_INVALID_ARG_TYPE = require('../../../errors').codes.ERR_INVALID_ARG_TYPE;\n\nfunction from(Readable, iterable, opts) {\n var iterator;\n\n if (iterable && typeof iterable.next === 'function') {\n iterator = iterable;\n } else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);\n\n var readable = new Readable(_objectSpread({\n objectMode: true\n }, opts)); // Reading boolean to protect against _read\n // being called before last iteration completion.\n\n var reading = false;\n\n readable._read = function () {\n if (!reading) {\n reading = true;\n next();\n }\n };\n\n function next() {\n return _next2.apply(this, arguments);\n }\n\n function _next2() {\n _next2 = _asyncToGenerator(function* () {\n try {\n var _ref = yield iterator.next(),\n value = _ref.value,\n done = _ref.done;\n\n if (done) {\n readable.push(null);\n } else if (readable.push((yield value))) {\n next();\n } else {\n reading = false;\n }\n } catch (err) {\n readable.destroy(err);\n }\n });\n return _next2.apply(this, arguments);\n }\n\n return readable;\n}\n\nmodule.exports = from;","// Ported from https://github.com/mafintosh/pump with\n// permission from the author, Mathias Buus (@mafintosh).\n'use strict';\n\nvar eos;\n\nfunction once(callback) {\n var called = false;\n return function () {\n if (called) return;\n called = true;\n callback.apply(void 0, arguments);\n };\n}\n\nvar _require$codes = require('../../../errors').codes,\n ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,\n ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;\n\nfunction noop(err) {\n // Rethrow the error if it exists to avoid swallowing it\n if (err) throw err;\n}\n\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function';\n}\n\nfunction destroyer(stream, reading, writing, callback) {\n callback = once(callback);\n var closed = false;\n stream.on('close', function () {\n closed = true;\n });\n if (eos === undefined) eos = require('./end-of-stream');\n eos(stream, {\n readable: reading,\n writable: writing\n }, function (err) {\n if (err) return callback(err);\n closed = true;\n callback();\n });\n var destroyed = false;\n return function (err) {\n if (closed) return;\n if (destroyed) return;\n destroyed = true; // request.destroy just do .end - .abort is what we want\n\n if (isRequest(stream)) return stream.abort();\n if (typeof stream.destroy === 'function') return stream.destroy();\n callback(err || new ERR_STREAM_DESTROYED('pipe'));\n };\n}\n\nfunction call(fn) {\n fn();\n}\n\nfunction pipe(from, to) {\n return from.pipe(to);\n}\n\nfunction popCallback(streams) {\n if (!streams.length) return noop;\n if (typeof streams[streams.length - 1] !== 'function') return noop;\n return streams.pop();\n}\n\nfunction pipeline() {\n for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {\n streams[_key] = arguments[_key];\n }\n\n var callback = popCallback(streams);\n if (Array.isArray(streams[0])) streams = streams[0];\n\n if (streams.length < 2) {\n throw new ERR_MISSING_ARGS('streams');\n }\n\n var error;\n var destroys = streams.map(function (stream, i) {\n var reading = i < streams.length - 1;\n var writing = i > 0;\n return destroyer(stream, reading, writing, function (err) {\n if (!error) error = err;\n if (err) destroys.forEach(call);\n if (reading) return;\n destroys.forEach(call);\n callback(error);\n });\n });\n return streams.reduce(pipe);\n}\n\nmodule.exports = pipeline;","'use strict';\n\nvar ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;\n\nfunction highWaterMarkFrom(options, isDuplex, duplexKey) {\n return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;\n}\n\nfunction getHighWaterMark(state, options, duplexKey, isDuplex) {\n var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);\n\n if (hwm != null) {\n if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {\n var name = isDuplex ? duplexKey : 'highWaterMark';\n throw new ERR_INVALID_OPT_VALUE(name, hwm);\n }\n\n return Math.floor(hwm);\n } // Default value\n\n\n return state.objectMode ? 16 : 16 * 1024;\n}\n\nmodule.exports = {\n getHighWaterMark: getHighWaterMark\n};","module.exports = require('stream');\n","var Stream = require('stream');\nif (process.env.READABLE_STREAM === 'disable' && Stream) {\n module.exports = Stream.Readable;\n Object.assign(module.exports, Stream);\n module.exports.Stream = Stream;\n} else {\n exports = module.exports = require('./lib/_stream_readable.js');\n exports.Stream = Stream || exports;\n exports.Readable = exports;\n exports.Writable = require('./lib/_stream_writable.js');\n exports.Duplex = require('./lib/_stream_duplex.js');\n exports.Transform = require('./lib/_stream_transform.js');\n exports.PassThrough = require('./lib/_stream_passthrough.js');\n exports.finished = require('./lib/internal/streams/end-of-stream.js');\n exports.pipeline = require('./lib/internal/streams/pipeline.js');\n}\n","/* eslint-disable node/no-deprecated-api */\n\n'use strict'\n\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\nvar safer = {}\n\nvar key\n\nfor (key in buffer) {\n if (!buffer.hasOwnProperty(key)) continue\n if (key === 'SlowBuffer' || key === 'Buffer') continue\n safer[key] = buffer[key]\n}\n\nvar Safer = safer.Buffer = {}\nfor (key in Buffer) {\n if (!Buffer.hasOwnProperty(key)) continue\n if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue\n Safer[key] = Buffer[key]\n}\n\nsafer.Buffer.prototype = Buffer.prototype\n\nif (!Safer.from || Safer.from === Uint8Array.from) {\n Safer.from = function (value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('The \"value\" argument must not be of type number. Received type ' + typeof value)\n }\n if (value && typeof value.length === 'undefined') {\n throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)\n }\n return Buffer(value, encodingOrOffset, length)\n }\n}\n\nif (!Safer.alloc) {\n Safer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('The \"size\" argument must be of type number. Received type ' + typeof size)\n }\n if (size < 0 || size >= 2 * (1 << 30)) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n var buf = Buffer(size)\n if (!fill || fill.length === 0) {\n buf.fill(0)\n } else if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n return buf\n }\n}\n\nif (!safer.kStringMaxLength) {\n try {\n safer.kStringMaxLength = process.binding('buffer').kStringMaxLength\n } catch (e) {\n // we can't determine kStringMaxLength in environments where process.binding\n // is unsupported, so let's not set it\n }\n}\n\nif (!safer.constants) {\n safer.constants = {\n MAX_LENGTH: safer.kMaxLength\n }\n if (safer.kStringMaxLength) {\n safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength\n }\n}\n\nmodule.exports = safer\n","var fs = require('fs');\n\nmodule.exports = function (filepath, split, encoding) {\n split = typeof split !== 'undefined' ? split : \"\\n\";\n encoding = typeof encoding !== 'undefined' ? encoding : \"utf8\";\n\n var ca = [];\n var chain = fs.readFileSync(filepath, encoding);\n if(chain.indexOf(\"-END CERTIFICATE-\") < 0 || chain.indexOf(\"-BEGIN CERTIFICATE-\") < 0){\n throw Error(\"File does not contain 'BEGIN CERTIFICATE' or 'END CERTIFICATE'\");\n }\n chain = chain.split(split);\n var cert = [];\n var _i, _len;\n for (_i = 0, _len = chain.length; _i < _len; _i++) {\n var line = chain[_i];\n if (!(line.length !== 0)) {\n continue;\n }\n cert.push(line);\n if (line.match(/-END CERTIFICATE-/)) {\n ca.push(cert.join(split));\n cert = [];\n }\n }\n return ca;\n}\n","'use strict';\n\nconst {\n Duplex: DuplexStream,\n Readable: ReadableStream,\n Writable: WritableStream,\n} = require('stream');\n\nconst {\n CHANNEL_EXTENDED_DATATYPE: { STDERR },\n} = require('./protocol/constants.js');\nconst { bufferSlice } = require('./protocol/utils.js');\n\nconst PACKET_SIZE = 32 * 1024;\nconst MAX_WINDOW = 2 * 1024 * 1024;\nconst WINDOW_THRESHOLD = MAX_WINDOW / 2;\n\nclass ClientStderr extends ReadableStream {\n constructor(channel, streamOpts) {\n super(streamOpts);\n\n this._channel = channel;\n }\n _read(n) {\n if (this._channel._waitChanDrain) {\n this._channel._waitChanDrain = false;\n if (this._channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(this._channel);\n }\n }\n}\n\nclass ServerStderr extends WritableStream {\n constructor(channel) {\n super({ highWaterMark: MAX_WINDOW });\n\n this._channel = channel;\n }\n\n _write(data, encoding, cb) {\n const channel = this._channel;\n const protocol = channel._client._protocol;\n const outgoing = channel.outgoing;\n const packetSize = outgoing.packetSize;\n const id = outgoing.id;\n let window = outgoing.window;\n const len = data.length;\n let p = 0;\n\n if (outgoing.state !== 'open')\n return;\n\n while (len - p > 0 && window > 0) {\n let sliceLen = len - p;\n if (sliceLen > window)\n sliceLen = window;\n if (sliceLen > packetSize)\n sliceLen = packetSize;\n\n if (p === 0 && sliceLen === len)\n protocol.channelExtData(id, data, STDERR);\n else\n protocol.channelExtData(id, bufferSlice(data, p, p + sliceLen), STDERR);\n\n p += sliceLen;\n window -= sliceLen;\n }\n\n outgoing.window = window;\n\n if (len - p > 0) {\n if (window === 0)\n channel._waitWindow = true;\n if (p > 0)\n channel._chunkErr = bufferSlice(data, p, len);\n else\n channel._chunkErr = data;\n channel._chunkcbErr = cb;\n return;\n }\n\n cb();\n }\n}\n\nclass Channel extends DuplexStream {\n constructor(client, info, opts) {\n const streamOpts = {\n highWaterMark: MAX_WINDOW,\n allowHalfOpen: (!opts || (opts && opts.allowHalfOpen !== false)),\n emitClose: false,\n };\n super(streamOpts);\n this.allowHalfOpen = streamOpts.allowHalfOpen;\n\n const server = !!(opts && opts.server);\n\n this.server = server;\n this.type = info.type;\n this.subtype = undefined;\n\n /*\n incoming and outgoing contain these properties:\n {\n id: undefined,\n window: undefined,\n packetSize: undefined,\n state: 'closed'\n }\n */\n this.incoming = info.incoming;\n this.outgoing = info.outgoing;\n this._callbacks = [];\n\n this._client = client;\n this._hasX11 = false;\n this._exit = {\n code: undefined,\n signal: undefined,\n dump: undefined,\n desc: undefined,\n };\n\n this.stdin = this.stdout = this;\n\n if (server)\n this.stderr = new ServerStderr(this);\n else\n this.stderr = new ClientStderr(this, streamOpts);\n\n // Outgoing data\n this._waitWindow = false; // SSH-level backpressure\n\n // Incoming data\n this._waitChanDrain = false; // Channel Readable side backpressure\n\n this._chunk = undefined;\n this._chunkcb = undefined;\n this._chunkErr = undefined;\n this._chunkcbErr = undefined;\n\n this.on('finish', onFinish)\n .on('prefinish', onFinish); // For node v0.11+\n\n this.on('end', onEnd).on('close', onEnd);\n }\n\n _read(n) {\n if (this._waitChanDrain) {\n this._waitChanDrain = false;\n if (this.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(this);\n }\n }\n\n _write(data, encoding, cb) {\n const protocol = this._client._protocol;\n const outgoing = this.outgoing;\n const packetSize = outgoing.packetSize;\n const id = outgoing.id;\n let window = outgoing.window;\n const len = data.length;\n let p = 0;\n\n if (outgoing.state !== 'open')\n return;\n\n while (len - p > 0 && window > 0) {\n let sliceLen = len - p;\n if (sliceLen > window)\n sliceLen = window;\n if (sliceLen > packetSize)\n sliceLen = packetSize;\n\n if (p === 0 && sliceLen === len)\n protocol.channelData(id, data);\n else\n protocol.channelData(id, bufferSlice(data, p, p + sliceLen));\n\n p += sliceLen;\n window -= sliceLen;\n }\n\n outgoing.window = window;\n\n if (len - p > 0) {\n if (window === 0)\n this._waitWindow = true;\n if (p > 0)\n this._chunk = bufferSlice(data, p, len);\n else\n this._chunk = data;\n this._chunkcb = cb;\n return;\n }\n\n cb();\n }\n\n eof() {\n if (this.outgoing.state === 'open') {\n this.outgoing.state = 'eof';\n this._client._protocol.channelEOF(this.outgoing.id);\n }\n }\n\n close() {\n if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {\n this.outgoing.state = 'closing';\n this._client._protocol.channelClose(this.outgoing.id);\n }\n }\n\n destroy() {\n this.end();\n this.close();\n return this;\n }\n\n // Session type-specific methods =============================================\n setWindow(rows, cols, height, width) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (this.type === 'session'\n && (this.subtype === 'shell' || this.subtype === 'exec')\n && this.writable\n && this.outgoing.state === 'open') {\n this._client._protocol.windowChange(this.outgoing.id,\n rows,\n cols,\n height,\n width);\n }\n }\n\n signal(signalName) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (this.type === 'session'\n && this.writable\n && this.outgoing.state === 'open') {\n this._client._protocol.signal(this.outgoing.id, signalName);\n }\n }\n\n exit(statusOrSignal, coreDumped, msg) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (this.type === 'session'\n && this.writable\n && this.outgoing.state === 'open') {\n if (typeof statusOrSignal === 'number') {\n this._client._protocol.exitStatus(this.outgoing.id, statusOrSignal);\n } else {\n this._client._protocol.exitSignal(this.outgoing.id,\n statusOrSignal,\n coreDumped,\n msg);\n }\n }\n }\n\n}\n\nfunction onFinish() {\n this.eof();\n if (this.server || !this.allowHalfOpen)\n this.close();\n this.writable = false;\n}\n\nfunction onEnd() {\n this.readable = false;\n}\n\nfunction windowAdjust(self) {\n if (self.outgoing.state === 'closed')\n return;\n const amt = MAX_WINDOW - self.incoming.window;\n if (amt <= 0)\n return;\n self.incoming.window += amt;\n self._client._protocol.channelWindowAdjust(self.outgoing.id, amt);\n}\n\nmodule.exports = {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n};\n",null,"// TODO:\n// * add `.connected` or similar property to allow immediate connection\n// status checking\n// * add/improve debug output during user authentication phase\n'use strict';\n\nconst {\n createHash,\n getHashes,\n randomFillSync,\n} = require('crypto');\nconst { Socket } = require('net');\nconst { lookup: dnsLookup } = require('dns');\nconst EventEmitter = require('events');\nconst HASHES = getHashes();\n\nconst {\n COMPAT,\n CHANNEL_EXTENDED_DATATYPE: { STDERR },\n CHANNEL_OPEN_FAILURE,\n DEFAULT_CIPHER,\n DEFAULT_COMPRESSION,\n DEFAULT_KEX,\n DEFAULT_MAC,\n DEFAULT_SERVER_HOST_KEY,\n DISCONNECT_REASON,\n DISCONNECT_REASON_BY_VALUE,\n SUPPORTED_CIPHER,\n SUPPORTED_COMPRESSION,\n SUPPORTED_KEX,\n SUPPORTED_MAC,\n SUPPORTED_SERVER_HOST_KEY,\n} = require('./protocol/constants.js');\nconst { init: cryptoInit } = require('./protocol/crypto.js');\nconst Protocol = require('./protocol/Protocol.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst { SFTP } = require('./protocol/SFTP.js');\nconst {\n bufferCopy,\n makeBufferParser,\n makeError,\n readUInt32BE,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./protocol/utils.js');\n\nconst { AgentContext, createAgent, isAgent } = require('./agent.js');\nconst {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n} = require('./Channel.js');\nconst {\n ChannelManager,\n generateAlgorithmList,\n isWritable,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n} = require('./utils.js');\n\nconst bufferParser = makeBufferParser();\nconst sigParser = makeBufferParser();\nconst RE_OPENSSH = /^OpenSSH_(?:(?![0-4])\\d)|(?:\\d{2,})/;\nconst noop = (err) => {};\n\nclass Client extends EventEmitter {\n constructor() {\n super();\n\n this.config = {\n host: undefined,\n port: undefined,\n localAddress: undefined,\n localPort: undefined,\n forceIPv4: undefined,\n forceIPv6: undefined,\n keepaliveCountMax: undefined,\n keepaliveInterval: undefined,\n readyTimeout: undefined,\n ident: undefined,\n\n username: undefined,\n password: undefined,\n privateKey: undefined,\n tryKeyboard: undefined,\n agent: undefined,\n allowAgentFwd: undefined,\n authHandler: undefined,\n\n hostHashAlgo: undefined,\n hostHashCb: undefined,\n strictVendor: undefined,\n debug: undefined\n };\n\n this._agent = undefined;\n this._readyTimeout = undefined;\n this._chanMgr = undefined;\n this._callbacks = undefined;\n this._forwarding = undefined;\n this._forwardingUnix = undefined;\n this._acceptX11 = undefined;\n this._agentFwdEnabled = undefined;\n this._remoteVer = undefined;\n\n this._protocol = undefined;\n this._sock = undefined;\n this._resetKA = undefined;\n }\n\n connect(cfg) {\n if (this._sock && isWritable(this._sock)) {\n this.once('close', () => {\n this.connect(cfg);\n });\n this.end();\n return this;\n }\n\n this.config.host = cfg.hostname || cfg.host || 'localhost';\n this.config.port = cfg.port || 22;\n this.config.localAddress = (typeof cfg.localAddress === 'string'\n ? cfg.localAddress\n : undefined);\n this.config.localPort = (typeof cfg.localPort === 'string'\n || typeof cfg.localPort === 'number'\n ? cfg.localPort\n : undefined);\n this.config.forceIPv4 = cfg.forceIPv4 || false;\n this.config.forceIPv6 = cfg.forceIPv6 || false;\n this.config.keepaliveCountMax = (typeof cfg.keepaliveCountMax === 'number'\n && cfg.keepaliveCountMax >= 0\n ? cfg.keepaliveCountMax\n : 3);\n this.config.keepaliveInterval = (typeof cfg.keepaliveInterval === 'number'\n && cfg.keepaliveInterval > 0\n ? cfg.keepaliveInterval\n : 0);\n this.config.readyTimeout = (typeof cfg.readyTimeout === 'number'\n && cfg.readyTimeout >= 0\n ? cfg.readyTimeout\n : 20000);\n this.config.ident = (typeof cfg.ident === 'string'\n || Buffer.isBuffer(cfg.ident)\n ? cfg.ident\n : undefined);\n\n const algorithms = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: [],\n },\n sc: undefined,\n };\n let allOfferDefaults = true;\n if (typeof cfg.algorithms === 'object' && cfg.algorithms !== null) {\n algorithms.kex = generateAlgorithmList(cfg.algorithms.kex,\n DEFAULT_KEX,\n SUPPORTED_KEX);\n if (algorithms.kex !== DEFAULT_KEX)\n allOfferDefaults = false;\n\n algorithms.serverHostKey =\n generateAlgorithmList(cfg.algorithms.serverHostKey,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY);\n if (algorithms.serverHostKey !== DEFAULT_SERVER_HOST_KEY)\n allOfferDefaults = false;\n\n algorithms.cs.cipher = generateAlgorithmList(cfg.algorithms.cipher,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER);\n if (algorithms.cs.cipher !== DEFAULT_CIPHER)\n allOfferDefaults = false;\n\n algorithms.cs.mac = generateAlgorithmList(cfg.algorithms.hmac,\n DEFAULT_MAC,\n SUPPORTED_MAC);\n if (algorithms.cs.mac !== DEFAULT_MAC)\n allOfferDefaults = false;\n\n algorithms.cs.compress = generateAlgorithmList(cfg.algorithms.compress,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION);\n if (algorithms.cs.compress !== DEFAULT_COMPRESSION)\n allOfferDefaults = false;\n\n if (!allOfferDefaults)\n algorithms.sc = algorithms.cs;\n }\n\n if (typeof cfg.username === 'string')\n this.config.username = cfg.username;\n else if (typeof cfg.user === 'string')\n this.config.username = cfg.user;\n else\n throw new Error('Invalid username');\n\n this.config.password = (typeof cfg.password === 'string'\n ? cfg.password\n : undefined);\n this.config.privateKey = (typeof cfg.privateKey === 'string'\n || Buffer.isBuffer(cfg.privateKey)\n ? cfg.privateKey\n : undefined);\n this.config.localHostname = (typeof cfg.localHostname === 'string'\n ? cfg.localHostname\n : undefined);\n this.config.localUsername = (typeof cfg.localUsername === 'string'\n ? cfg.localUsername\n : undefined);\n this.config.tryKeyboard = (cfg.tryKeyboard === true);\n if (typeof cfg.agent === 'string' && cfg.agent.length)\n this.config.agent = createAgent(cfg.agent);\n else if (isAgent(cfg.agent))\n this.config.agent = cfg.agent;\n else\n this.config.agent = undefined;\n this.config.allowAgentFwd = (cfg.agentForward === true\n && this.config.agent !== undefined);\n let authHandler = this.config.authHandler = (\n typeof cfg.authHandler === 'function'\n || Array.isArray(cfg.authHandler)\n ? cfg.authHandler\n : undefined\n );\n\n this.config.strictVendor = (typeof cfg.strictVendor === 'boolean'\n ? cfg.strictVendor\n : true);\n\n const debug = this.config.debug = (typeof cfg.debug === 'function'\n ? cfg.debug\n : undefined);\n\n if (cfg.agentForward === true && !this.config.allowAgentFwd) {\n throw new Error(\n 'You must set a valid agent path to allow agent forwarding'\n );\n }\n\n let callbacks = this._callbacks = [];\n this._chanMgr = new ChannelManager(this);\n this._forwarding = {};\n this._forwardingUnix = {};\n this._acceptX11 = 0;\n this._agentFwdEnabled = false;\n this._agent = (this.config.agent ? this.config.agent : undefined);\n this._remoteVer = undefined;\n let privateKey;\n\n if (this.config.privateKey) {\n privateKey = parseKey(this.config.privateKey, cfg.passphrase);\n if (privateKey instanceof Error)\n throw new Error(`Cannot parse privateKey: ${privateKey.message}`);\n if (Array.isArray(privateKey)) {\n // OpenSSH's newer format only stores 1 key for now\n privateKey = privateKey[0];\n }\n if (privateKey.getPrivatePEM() === null) {\n throw new Error(\n 'privateKey value does not contain a (valid) private key'\n );\n }\n }\n\n let hostVerifier;\n if (typeof cfg.hostVerifier === 'function') {\n const hashCb = cfg.hostVerifier;\n let hasher;\n if (HASHES.indexOf(cfg.hostHash) !== -1) {\n // Default to old behavior of hashing on user's behalf\n hasher = createHash(cfg.hostHash);\n }\n hostVerifier = (key, verify) => {\n if (hasher) {\n hasher.update(key);\n key = hasher.digest('hex');\n }\n const ret = hashCb(key, verify);\n if (ret !== undefined)\n verify(ret);\n };\n }\n\n const sock = this._sock = (cfg.sock || new Socket());\n let ready = false;\n let sawHeader = false;\n if (this._protocol)\n this._protocol.cleanup();\n const DEBUG_HANDLER = (!debug ? undefined : (p, display, msg) => {\n debug(`Debug output from server: ${JSON.stringify(msg)}`);\n });\n const proto = this._protocol = new Protocol({\n ident: this.config.ident,\n offer: (allOfferDefaults ? undefined : algorithms),\n onWrite: (data) => {\n if (isWritable(sock))\n sock.write(data);\n },\n onError: (err) => {\n if (err.level === 'handshake')\n clearTimeout(this._readyTimeout);\n if (!proto._destruct)\n sock.removeAllListeners('data');\n this.emit('error', err);\n try {\n sock.end();\n } catch {}\n },\n onHeader: (header) => {\n sawHeader = true;\n this._remoteVer = header.versions.software;\n if (header.greeting)\n this.emit('greeting', header.greeting);\n },\n onHandshakeComplete: (negotiated) => {\n this.emit('handshake', negotiated);\n if (!ready) {\n ready = true;\n proto.service('ssh-userauth');\n }\n },\n debug,\n hostVerifier,\n messageHandlers: {\n DEBUG: DEBUG_HANDLER,\n DISCONNECT: (p, reason, desc) => {\n if (reason !== DISCONNECT_REASON.BY_APPLICATION) {\n if (!desc) {\n desc = DISCONNECT_REASON_BY_VALUE[reason];\n if (desc === undefined)\n desc = `Unexpected disconnection reason: ${reason}`;\n }\n const err = new Error(desc);\n err.code = reason;\n this.emit('error', err);\n }\n sock.end();\n },\n SERVICE_ACCEPT: (p, name) => {\n if (name === 'ssh-userauth')\n tryNextAuth();\n },\n USERAUTH_BANNER: (p, msg) => {\n this.emit('banner', msg);\n },\n USERAUTH_SUCCESS: (p) => {\n // Start keepalive mechanism\n resetKA();\n\n clearTimeout(this._readyTimeout);\n\n this.emit('ready');\n },\n USERAUTH_FAILURE: (p, authMethods, partialSuccess) => {\n if (curAuth.type === 'agent') {\n const pos = curAuth.agentCtx.pos();\n debug && debug(`Client: Agent key #${pos + 1} failed`);\n return tryNextAgentKey();\n }\n\n debug && debug(`Client: ${curAuth.type} auth failed`);\n\n curPartial = partialSuccess;\n curAuthsLeft = authMethods;\n tryNextAuth();\n },\n USERAUTH_PASSWD_CHANGEREQ: (p, prompt) => {\n if (curAuth.type === 'password') {\n // TODO: support a `changePrompt()` on `curAuth` that defaults to\n // emitting 'change password' as before\n this.emit('change password', prompt, (newPassword) => {\n proto.authPassword(\n this.config.username,\n this.config.password,\n newPassword\n );\n });\n }\n },\n USERAUTH_PK_OK: (p) => {\n if (curAuth.type === 'agent') {\n const key = curAuth.agentCtx.currentKey();\n proto.authPK(curAuth.username, key, (buf, cb) => {\n curAuth.agentCtx.sign(key, buf, {}, (err, signed) => {\n if (err) {\n err.level = 'agent';\n this.emit('error', err);\n } else {\n return cb(signed);\n }\n\n tryNextAgentKey();\n });\n });\n } else if (curAuth.type === 'publickey') {\n proto.authPK(curAuth.username, curAuth.key, (buf, cb) => {\n const signature = curAuth.key.sign(buf);\n if (signature instanceof Error) {\n signature.message =\n `Error signing data with key: ${signature.message}`;\n signature.level = 'client-authentication';\n this.emit('error', signature);\n return tryNextAuth();\n }\n cb(signature);\n });\n }\n },\n USERAUTH_INFO_REQUEST: (p, name, instructions, prompts) => {\n if (curAuth.type === 'keyboard-interactive') {\n const nprompts = (Array.isArray(prompts) ? prompts.length : 0);\n if (nprompts === 0) {\n debug && debug(\n 'Client: Sending automatic USERAUTH_INFO_RESPONSE'\n );\n proto.authInfoRes();\n return;\n }\n // We sent a keyboard-interactive user authentication request and\n // now the server is sending us the prompts we need to present to\n // the user\n curAuth.prompt(\n name,\n instructions,\n '',\n prompts,\n (answers) => {\n proto.authInfoRes(answers);\n }\n );\n }\n },\n REQUEST_SUCCESS: (p, data) => {\n if (callbacks.length)\n callbacks.shift()(false, data);\n },\n REQUEST_FAILURE: (p) => {\n if (callbacks.length)\n callbacks.shift()(true);\n },\n GLOBAL_REQUEST: (p, name, wantReply, data) => {\n switch (name) {\n case 'hostkeys-00@openssh.com':\n // Automatically verify keys before passing to end user\n hostKeysProve(this, data, (err, keys) => {\n if (err)\n return;\n this.emit('hostkeys', keys);\n });\n if (wantReply)\n proto.requestSuccess();\n break;\n default:\n // Auto-reject all other global requests, this can be especially\n // useful if the server is sending us dummy keepalive global\n // requests\n if (wantReply)\n proto.requestFailure();\n }\n },\n CHANNEL_OPEN: (p, info) => {\n // Handle incoming requests from server, typically a forwarded TCP or\n // X11 connection\n onCHANNEL_OPEN(this, info);\n },\n CHANNEL_OPEN_CONFIRMATION: (p, info) => {\n const channel = this._chanMgr.get(info.recipient);\n if (typeof channel !== 'function')\n return;\n\n const isSFTP = (channel.type === 'sftp');\n const type = (isSFTP ? 'session' : channel.type);\n const chanInfo = {\n type,\n incoming: {\n id: info.recipient,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n const instance = (\n isSFTP\n ? new SFTP(this, chanInfo, { debug })\n : new Channel(this, chanInfo)\n );\n this._chanMgr.update(info.recipient, instance);\n channel(undefined, instance);\n },\n CHANNEL_OPEN_FAILURE: (p, recipient, reason, description) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'function')\n return;\n\n const info = { reason, description };\n onChannelOpenFailure(this, recipient, info, channel);\n },\n CHANNEL_DATA: (p, recipient, data) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (channel.push(data) === false) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_EXTENDED_DATA: (p, recipient, data, type) => {\n if (type !== STDERR)\n return;\n\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (!channel.stderr.push(data)) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_WINDOW_ADJUST: (p, recipient, amount) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n // The other side is allowing us to send `amount` more bytes of data\n channel.outgoing.window += amount;\n\n if (channel._waitWindow) {\n channel._waitWindow = false;\n\n if (channel._chunk) {\n channel._write(channel._chunk, null, channel._chunkcb);\n } else if (channel._chunkcb) {\n channel._chunkcb();\n } else if (channel._chunkErr) {\n channel.stderr._write(channel._chunkErr,\n null,\n channel._chunkcbErr);\n } else if (channel._chunkcbErr) {\n channel._chunkcbErr();\n }\n }\n },\n CHANNEL_SUCCESS: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n this._resetKA();\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(false);\n },\n CHANNEL_FAILURE: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n this._resetKA();\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(true);\n },\n CHANNEL_REQUEST: (p, recipient, type, wantReply, data) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n const exit = channel._exit;\n if (exit.code !== undefined)\n return;\n switch (type) {\n case 'exit-status':\n channel.emit('exit', exit.code = data);\n return;\n case 'exit-signal':\n channel.emit('exit',\n exit.code = null,\n exit.signal = `SIG${data.signal}`,\n exit.dump = data.coreDumped,\n exit.desc = data.errorMessage);\n return;\n }\n\n // Keepalive request? OpenSSH will send one as a channel request if\n // there is a channel open\n\n if (wantReply)\n p.channelFailure(channel.outgoing.id);\n },\n CHANNEL_EOF: (p, recipient) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.incoming.state !== 'open')\n return;\n channel.incoming.state = 'eof';\n\n if (channel.readable)\n channel.push(null);\n if (channel.stderr.readable)\n channel.stderr.push(null);\n },\n CHANNEL_CLOSE: (p, recipient) => {\n onCHANNEL_CLOSE(this, recipient, this._chanMgr.get(recipient));\n },\n },\n });\n\n sock.pause();\n\n // TODO: check keepalive implementation\n // Keepalive-related\n const kainterval = this.config.keepaliveInterval;\n const kacountmax = this.config.keepaliveCountMax;\n let kacount = 0;\n let katimer;\n const sendKA = () => {\n if (++kacount > kacountmax) {\n clearInterval(katimer);\n if (sock.readable) {\n const err = new Error('Keepalive timeout');\n err.level = 'client-timeout';\n this.emit('error', err);\n sock.destroy();\n }\n return;\n }\n if (isWritable(sock)) {\n // Append dummy callback to keep correct callback order\n callbacks.push(resetKA);\n proto.ping();\n } else {\n clearInterval(katimer);\n }\n };\n function resetKA() {\n if (kainterval > 0) {\n kacount = 0;\n clearInterval(katimer);\n if (isWritable(sock))\n katimer = setInterval(sendKA, kainterval);\n }\n }\n this._resetKA = resetKA;\n\n const onDone = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n if (wasConnected && !sawHeader) {\n const err =\n makeError('Connection lost before handshake', 'protocol', true);\n this.emit('error', err);\n }\n };\n })();\n const onConnect = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n\n wasConnected = true;\n debug && debug('Socket connected');\n this.emit('connect');\n\n cryptoInit.then(() => {\n proto.start();\n sock.on('data', (data) => {\n try {\n proto.parse(data, 0, data.length);\n } catch (ex) {\n this.emit('error', ex);\n try {\n if (isWritable(sock))\n sock.end();\n } catch {}\n }\n });\n\n // Drain stderr if we are connection hopping using an exec stream\n if (sock.stderr && typeof sock.stderr.resume === 'function')\n sock.stderr.resume();\n\n sock.resume();\n }).catch((err) => {\n this.emit('error', err);\n try {\n if (isWritable(sock))\n sock.end();\n } catch {}\n });\n };\n })();\n let wasConnected = false;\n sock.on('connect', onConnect)\n .on('timeout', () => {\n this.emit('timeout');\n }).on('error', (err) => {\n debug && debug(`Socket error: ${err.message}`);\n clearTimeout(this._readyTimeout);\n err.level = 'client-socket';\n this.emit('error', err);\n }).on('end', () => {\n debug && debug('Socket ended');\n onDone();\n proto.cleanup();\n clearTimeout(this._readyTimeout);\n clearInterval(katimer);\n this.emit('end');\n }).on('close', () => {\n debug && debug('Socket closed');\n onDone();\n proto.cleanup();\n clearTimeout(this._readyTimeout);\n clearInterval(katimer);\n this.emit('close');\n\n // Notify outstanding channel requests of disconnection ...\n const callbacks_ = callbacks;\n callbacks = this._callbacks = [];\n const err = new Error('No response from server');\n for (let i = 0; i < callbacks_.length; ++i)\n callbacks_[i](err);\n\n // Simulate error for any channels waiting to be opened\n this._chanMgr.cleanup(err);\n });\n\n // Begin authentication handling ===========================================\n let curAuth;\n let curPartial = null;\n let curAuthsLeft = null;\n const authsAllowed = ['none'];\n if (this.config.password !== undefined)\n authsAllowed.push('password');\n if (privateKey !== undefined)\n authsAllowed.push('publickey');\n if (this._agent !== undefined)\n authsAllowed.push('agent');\n if (this.config.tryKeyboard)\n authsAllowed.push('keyboard-interactive');\n if (privateKey !== undefined\n && this.config.localHostname !== undefined\n && this.config.localUsername !== undefined) {\n authsAllowed.push('hostbased');\n }\n\n if (Array.isArray(authHandler))\n authHandler = makeSimpleAuthHandler(authHandler);\n else if (typeof authHandler !== 'function')\n authHandler = makeSimpleAuthHandler(authsAllowed);\n\n let hasSentAuth = false;\n const doNextAuth = (nextAuth) => {\n if (hasSentAuth)\n return;\n hasSentAuth = true;\n\n if (nextAuth === false) {\n const err = new Error('All configured authentication methods failed');\n err.level = 'client-authentication';\n this.emit('error', err);\n this.end();\n return;\n }\n\n if (typeof nextAuth === 'string') {\n // Remain backwards compatible with original `authHandler()` usage,\n // which only supported passing names of next method to try using data\n // from the `connect()` config object\n\n const type = nextAuth;\n if (authsAllowed.indexOf(type) === -1)\n return skipAuth(`Authentication method not allowed: ${type}`);\n\n const username = this.config.username;\n switch (type) {\n case 'password':\n nextAuth = { type, username, password: this.config.password };\n break;\n case 'publickey':\n nextAuth = { type, username, key: privateKey };\n break;\n case 'hostbased':\n nextAuth = {\n type,\n username,\n key: privateKey,\n localHostname: this.config.localHostname,\n localUsername: this.config.localUsername,\n };\n break;\n case 'agent':\n nextAuth = {\n type,\n username,\n agentCtx: new AgentContext(this._agent),\n };\n break;\n case 'keyboard-interactive':\n nextAuth = {\n type,\n username,\n prompt: (...args) => this.emit('keyboard-interactive', ...args),\n };\n break;\n case 'none':\n nextAuth = { type, username };\n break;\n default:\n return skipAuth(\n `Skipping unsupported authentication method: ${nextAuth}`\n );\n }\n } else if (typeof nextAuth !== 'object' || nextAuth === null) {\n return skipAuth(\n `Skipping invalid authentication attempt: ${nextAuth}`\n );\n } else {\n const username = nextAuth.username;\n if (typeof username !== 'string') {\n return skipAuth(\n `Skipping invalid authentication attempt: ${nextAuth}`\n );\n }\n const type = nextAuth.type;\n switch (type) {\n case 'password': {\n const { password } = nextAuth;\n if (typeof password !== 'string' && !Buffer.isBuffer(password))\n return skipAuth('Skipping invalid password auth attempt');\n nextAuth = { type, username, password };\n break;\n }\n case 'publickey': {\n const key = parseKey(nextAuth.key, nextAuth.passphrase);\n if (key instanceof Error)\n return skipAuth('Skipping invalid key auth attempt');\n if (!key.isPrivateKey())\n return skipAuth('Skipping non-private key');\n nextAuth = { type, username, key };\n break;\n }\n case 'hostbased': {\n const { localHostname, localUsername } = nextAuth;\n const key = parseKey(nextAuth.key, nextAuth.passphrase);\n if (key instanceof Error\n || typeof localHostname !== 'string'\n || typeof localUsername !== 'string') {\n return skipAuth('Skipping invalid hostbased auth attempt');\n }\n if (!key.isPrivateKey())\n return skipAuth('Skipping non-private key');\n nextAuth = { type, username, key, localHostname, localUsername };\n break;\n }\n case 'agent': {\n let agent = nextAuth.agent;\n if (typeof agent === 'string' && agent.length) {\n agent = createAgent(agent);\n } else if (!isAgent(agent)) {\n return skipAuth(\n `Skipping invalid agent: ${nextAuth.agent}`\n );\n }\n nextAuth = { type, username, agentCtx: new AgentContext(agent) };\n break;\n }\n case 'keyboard-interactive': {\n const { prompt } = nextAuth;\n if (typeof prompt !== 'function') {\n return skipAuth(\n 'Skipping invalid keyboard-interactive auth attempt'\n );\n }\n nextAuth = { type, username, prompt };\n break;\n }\n case 'none':\n nextAuth = { type, username };\n break;\n default:\n return skipAuth(\n `Skipping unsupported authentication method: ${nextAuth}`\n );\n }\n }\n curAuth = nextAuth;\n\n // Begin authentication method's process\n try {\n const username = curAuth.username;\n switch (curAuth.type) {\n case 'password':\n proto.authPassword(username, curAuth.password);\n break;\n case 'publickey':\n proto.authPK(username, curAuth.key);\n break;\n case 'hostbased':\n proto.authHostbased(username,\n curAuth.key,\n curAuth.localHostname,\n curAuth.localUsername,\n (buf, cb) => {\n const signature = curAuth.key.sign(buf);\n if (signature instanceof Error) {\n signature.message =\n `Error while signing with key: ${signature.message}`;\n signature.level = 'client-authentication';\n this.emit('error', signature);\n return tryNextAuth();\n }\n\n cb(signature);\n });\n break;\n case 'agent':\n curAuth.agentCtx.init((err) => {\n if (err) {\n err.level = 'agent';\n this.emit('error', err);\n return tryNextAuth();\n }\n tryNextAgentKey();\n });\n break;\n case 'keyboard-interactive':\n proto.authKeyboard(username);\n break;\n case 'none':\n proto.authNone(username);\n break;\n }\n } finally {\n hasSentAuth = false;\n }\n };\n\n function skipAuth(msg) {\n debug && debug(msg);\n process.nextTick(tryNextAuth);\n }\n\n function tryNextAuth() {\n hasSentAuth = false;\n const auth = authHandler(curAuthsLeft, curPartial, doNextAuth);\n if (hasSentAuth || auth === undefined)\n return;\n doNextAuth(auth);\n }\n\n const tryNextAgentKey = () => {\n if (curAuth.type === 'agent') {\n const key = curAuth.agentCtx.nextKey();\n if (key === false) {\n debug && debug('Agent: No more keys left to try');\n debug && debug('Client: agent auth failed');\n tryNextAuth();\n } else {\n const pos = curAuth.agentCtx.pos();\n debug && debug(`Agent: Trying key #${pos + 1}`);\n proto.authPK(curAuth.username, key);\n }\n }\n };\n\n const startTimeout = () => {\n if (this.config.readyTimeout > 0) {\n this._readyTimeout = setTimeout(() => {\n const err = new Error('Timed out while waiting for handshake');\n err.level = 'client-timeout';\n this.emit('error', err);\n sock.destroy();\n }, this.config.readyTimeout);\n }\n };\n\n if (!cfg.sock) {\n let host = this.config.host;\n const forceIPv4 = this.config.forceIPv4;\n const forceIPv6 = this.config.forceIPv6;\n\n debug && debug(`Client: Trying ${host} on port ${this.config.port} ...`);\n\n const doConnect = () => {\n startTimeout();\n sock.connect({\n host,\n port: this.config.port,\n localAddress: this.config.localAddress,\n localPort: this.config.localPort\n });\n sock.setNoDelay(true);\n sock.setMaxListeners(0);\n sock.setTimeout(typeof cfg.timeout === 'number' ? cfg.timeout : 0);\n };\n\n if ((!forceIPv4 && !forceIPv6) || (forceIPv4 && forceIPv6)) {\n doConnect();\n } else {\n dnsLookup(host, (forceIPv4 ? 4 : 6), (err, address, family) => {\n if (err) {\n const type = (forceIPv4 ? 'IPv4' : 'IPv6');\n const error = new Error(\n `Error while looking up ${type} address for '${host}': ${err}`\n );\n clearTimeout(this._readyTimeout);\n error.level = 'client-dns';\n this.emit('error', error);\n this.emit('close');\n return;\n }\n host = address;\n doConnect();\n });\n }\n } else {\n // Custom socket passed in\n startTimeout();\n if (typeof sock.connecting === 'boolean') {\n // net.Socket\n\n if (!sock.connecting) {\n // Already connected\n onConnect();\n }\n } else {\n // Assume socket/stream is already \"connected\"\n onConnect();\n }\n }\n\n return this;\n }\n\n end() {\n if (this._sock && isWritable(this._sock)) {\n this._protocol.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n this._sock.end();\n }\n return this;\n }\n\n destroy() {\n this._sock && isWritable(this._sock) && this._sock.destroy();\n return this;\n }\n\n exec(cmd, opts, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const extraOpts = { allowHalfOpen: (opts.allowHalfOpen !== false) };\n\n openChannel(this, 'session', extraOpts, (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n const todo = [];\n\n function reqCb(err) {\n if (err) {\n chan.close();\n cb(err);\n return;\n }\n if (todo.length)\n todo.shift()();\n }\n\n if (this.config.allowAgentFwd === true\n || (opts\n && opts.agentForward === true\n && this._agent !== undefined)) {\n todo.push(() => reqAgentFwd(chan, reqCb));\n }\n\n if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.env === 'object' && opts.env !== null)\n reqEnv(chan, opts.env);\n if ((typeof opts.pty === 'object' && opts.pty !== null)\n || opts.pty === true) {\n todo.push(() => reqPty(chan, opts.pty, reqCb));\n }\n if ((typeof opts.x11 === 'object' && opts.x11 !== null)\n || opts.x11 === 'number'\n || opts.x11 === true) {\n todo.push(() => reqX11(chan, opts.x11, reqCb));\n }\n }\n\n todo.push(() => reqExec(chan, cmd, opts, cb));\n todo.shift()();\n });\n\n return this;\n }\n\n shell(wndopts, opts, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof wndopts === 'function') {\n cb = wndopts;\n wndopts = opts = undefined;\n } else if (typeof opts === 'function') {\n cb = opts;\n opts = undefined;\n }\n if (wndopts && (wndopts.x11 !== undefined || wndopts.env !== undefined)) {\n opts = wndopts;\n wndopts = undefined;\n }\n\n openChannel(this, 'session', (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n const todo = [];\n\n function reqCb(err) {\n if (err) {\n chan.close();\n cb(err);\n return;\n }\n if (todo.length)\n todo.shift()();\n }\n\n if (this.config.allowAgentFwd === true\n || (opts\n && opts.agentForward === true\n && this._agent !== undefined)) {\n todo.push(() => reqAgentFwd(chan, reqCb));\n }\n\n if (wndopts !== false)\n todo.push(() => reqPty(chan, wndopts, reqCb));\n\n if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.env === 'object' && opts.env !== null)\n reqEnv(chan, opts.env);\n if ((typeof opts.x11 === 'object' && opts.x11 !== null)\n || opts.x11 === 'number'\n || opts.x11 === true) {\n todo.push(() => reqX11(chan, opts.x11, reqCb));\n }\n }\n\n todo.push(() => reqShell(chan, cb));\n todo.shift()();\n });\n\n return this;\n }\n\n subsys(name, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n openChannel(this, 'session', (err, chan) => {\n if (err) {\n cb(err);\n return;\n }\n\n reqSubsystem(chan, name, (err, stream) => {\n if (err) {\n cb(err);\n return;\n }\n\n cb(undefined, stream);\n });\n });\n\n return this;\n }\n\n forwardIn(bindAddr, bindPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request for the server to start forwarding TCP connections to us\n // on a particular address and port\n\n const wantReply = (typeof cb === 'function');\n\n if (wantReply) {\n this._callbacks.push((had_err, data) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to bind to ${bindAddr}:${bindPort}`));\n return;\n }\n\n let realPort = bindPort;\n if (bindPort === 0 && data && data.length >= 4) {\n realPort = readUInt32BE(data, 0);\n if (!(this._protocol._compatFlags & COMPAT.DYN_RPORT_BUG))\n bindPort = realPort;\n }\n\n this._forwarding[`${bindAddr}:${bindPort}`] = realPort;\n\n cb(undefined, realPort);\n });\n }\n\n this._protocol.tcpipForward(bindAddr, bindPort, wantReply);\n\n return this;\n }\n\n unforwardIn(bindAddr, bindPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request to stop forwarding us new connections for a particular\n // address and port\n\n const wantReply = (typeof cb === 'function');\n\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to unbind from ${bindAddr}:${bindPort}`));\n return;\n }\n\n delete this._forwarding[`${bindAddr}:${bindPort}`];\n\n cb();\n });\n }\n\n this._protocol.cancelTcpipForward(bindAddr, bindPort, wantReply);\n\n return this;\n }\n\n forwardOut(srcIP, srcPort, dstIP, dstPort, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n // Send a request to forward a TCP connection to the server\n\n const cfg = {\n srcIP: srcIP,\n srcPort: srcPort,\n dstIP: dstIP,\n dstPort: dstPort\n };\n\n if (typeof cb !== 'function')\n cb = noop;\n\n openChannel(this, 'direct-tcpip', cfg, cb);\n\n return this;\n }\n\n openssh_noMoreSessions(cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to disable future sessions'));\n return;\n }\n\n cb();\n });\n }\n\n this._protocol.openssh_noMoreSessions(wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_forwardInStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to bind to ${socketPath}`));\n return;\n }\n this._forwardingUnix[socketPath] = true;\n cb();\n });\n }\n\n this._protocol.openssh_streamLocalForward(socketPath, wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_unforwardInStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n const wantReply = (typeof cb === 'function');\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n if (wantReply) {\n this._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to unbind from ${socketPath}`));\n return;\n }\n delete this._forwardingUnix[socketPath];\n cb();\n });\n }\n\n this._protocol.openssh_cancelStreamLocalForward(socketPath, wantReply);\n return this;\n }\n\n if (!wantReply)\n return this;\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n openssh_forwardOutStreamLocal(socketPath, cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n if (typeof cb !== 'function')\n cb = noop;\n\n if (!this.config.strictVendor\n || (this.config.strictVendor && RE_OPENSSH.test(this._remoteVer))) {\n openChannel(this, 'direct-streamlocal@openssh.com', { socketPath }, cb);\n return this;\n }\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n\n return this;\n }\n\n sftp(cb) {\n if (!this._sock || !isWritable(this._sock))\n throw new Error('Not connected');\n\n openChannel(this, 'sftp', (err, sftp) => {\n if (err) {\n cb(err);\n return;\n }\n\n reqSubsystem(sftp, 'sftp', (err, sftp_) => {\n if (err) {\n cb(err);\n return;\n }\n\n function removeListeners() {\n sftp.removeListener('ready', onReady);\n sftp.removeListener('error', onError);\n sftp.removeListener('exit', onExit);\n sftp.removeListener('close', onExit);\n }\n\n function onReady() {\n // TODO: do not remove exit/close in case remote end closes the\n // channel abruptly and we need to notify outstanding callbacks\n removeListeners();\n cb(undefined, sftp);\n }\n\n function onError(err) {\n removeListeners();\n cb(err);\n }\n\n function onExit(code, signal) {\n removeListeners();\n let msg;\n if (typeof code === 'number')\n msg = `Received exit code ${code} while establishing SFTP session`;\n else if (signal !== undefined)\n msg = `Received signal ${signal} while establishing SFTP session`;\n else\n msg = 'Received unexpected SFTP session termination';\n const err = new Error(msg);\n err.code = code;\n err.signal = signal;\n cb(err);\n }\n\n sftp.on('ready', onReady)\n .on('error', onError)\n .on('exit', onExit)\n .on('close', onExit);\n\n sftp._init();\n });\n });\n\n return this;\n }\n}\n\nfunction openChannel(self, type, opts, cb) {\n // Ask the server to open a channel for some purpose\n // (e.g. session (sftp, exec, shell), or forwarding a TCP connection\n const initWindow = MAX_WINDOW;\n const maxPacket = PACKET_SIZE;\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const wrapper = (err, stream) => {\n cb(err, stream);\n };\n wrapper.type = type;\n\n const localChan = self._chanMgr.add(wrapper);\n\n if (localChan === -1) {\n cb(new Error('No free channels available'));\n return;\n }\n\n switch (type) {\n case 'session':\n case 'sftp':\n self._protocol.session(localChan, initWindow, maxPacket);\n break;\n case 'direct-tcpip':\n self._protocol.directTcpip(localChan, initWindow, maxPacket, opts);\n break;\n case 'direct-streamlocal@openssh.com':\n self._protocol.openssh_directStreamLocal(\n localChan, initWindow, maxPacket, opts\n );\n break;\n default:\n throw new Error(`Unsupported channel type: ${type}`);\n }\n}\n\nfunction reqX11(chan, screen, cb) {\n // Asks server to start sending us X11 connections\n const cfg = {\n single: false,\n protocol: 'MIT-MAGIC-COOKIE-1',\n cookie: undefined,\n screen: 0\n };\n\n if (typeof screen === 'function') {\n cb = screen;\n } else if (typeof screen === 'object' && screen !== null) {\n if (typeof screen.single === 'boolean')\n cfg.single = screen.single;\n if (typeof screen.screen === 'number')\n cfg.screen = screen.screen;\n if (typeof screen.protocol === 'string')\n cfg.protocol = screen.protocol;\n if (typeof screen.cookie === 'string')\n cfg.cookie = screen.cookie;\n else if (Buffer.isBuffer(screen.cookie))\n cfg.cookie = screen.cookie.hexSlice(0, screen.cookie.length);\n }\n if (cfg.cookie === undefined)\n cfg.cookie = randomCookie();\n\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n if (wantReply)\n cb(new Error('Channel is not open'));\n return;\n }\n\n if (wantReply) {\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to request X11'));\n return;\n }\n\n chan._hasX11 = true;\n ++chan._client._acceptX11;\n chan.once('close', () => {\n if (chan._client._acceptX11)\n --chan._client._acceptX11;\n });\n\n cb();\n });\n }\n\n chan._client._protocol.x11Forward(chan.outgoing.id, cfg, wantReply);\n}\n\nfunction reqPty(chan, opts, cb) {\n let rows = 24;\n let cols = 80;\n let width = 640;\n let height = 480;\n let term = 'vt100';\n let modes = null;\n\n if (typeof opts === 'function') {\n cb = opts;\n } else if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.rows === 'number')\n rows = opts.rows;\n if (typeof opts.cols === 'number')\n cols = opts.cols;\n if (typeof opts.width === 'number')\n width = opts.width;\n if (typeof opts.height === 'number')\n height = opts.height;\n if (typeof opts.term === 'string')\n term = opts.term;\n if (typeof opts.modes === 'object')\n modes = opts.modes;\n }\n\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n if (wantReply)\n cb(new Error('Channel is not open'));\n return;\n }\n\n if (wantReply) {\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to request a pseudo-terminal'));\n return;\n }\n cb();\n });\n }\n\n chan._client._protocol.pty(chan.outgoing.id,\n rows,\n cols,\n height,\n width,\n term,\n modes,\n wantReply);\n}\n\nfunction reqAgentFwd(chan, cb) {\n const wantReply = (typeof cb === 'function');\n\n if (chan.outgoing.state !== 'open') {\n wantReply && cb(new Error('Channel is not open'));\n return;\n }\n if (chan._client._agentFwdEnabled) {\n wantReply && cb(false);\n return;\n }\n\n chan._client._agentFwdEnabled = true;\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n chan._client._agentFwdEnabled = false;\n if (wantReply) {\n cb(had_err !== true\n ? had_err\n : new Error('Unable to request agent forwarding'));\n }\n return;\n }\n\n if (wantReply)\n cb();\n });\n\n chan._client._protocol.openssh_agentForward(chan.outgoing.id, true);\n}\n\nfunction reqShell(chan, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to open shell'));\n return;\n }\n chan.subtype = 'shell';\n cb(undefined, chan);\n });\n\n chan._client._protocol.shell(chan.outgoing.id, true);\n}\n\nfunction reqExec(chan, cmd, opts, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true ? had_err : new Error('Unable to exec'));\n return;\n }\n chan.subtype = 'exec';\n chan.allowHalfOpen = (opts.allowHalfOpen !== false);\n cb(undefined, chan);\n });\n\n chan._client._protocol.exec(chan.outgoing.id, cmd, true);\n}\n\nfunction reqEnv(chan, env) {\n if (chan.outgoing.state !== 'open')\n return;\n\n const keys = Object.keys(env || {});\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n const val = env[key];\n chan._client._protocol.env(chan.outgoing.id, key, val, false);\n }\n}\n\nfunction reqSubsystem(chan, name, cb) {\n if (chan.outgoing.state !== 'open') {\n cb(new Error('Channel is not open'));\n return;\n }\n\n chan._callbacks.push((had_err) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error(`Unable to start subsystem: ${name}`));\n return;\n }\n chan.subtype = 'subsystem';\n cb(undefined, chan);\n });\n\n chan._client._protocol.subsystem(chan.outgoing.id, name, true);\n}\n\n// TODO: inline implementation into single call site\nfunction onCHANNEL_OPEN(self, info) {\n // The server is trying to open a channel with us, this is usually when\n // we asked the server to forward us connections on some port and now they\n // are asking us to accept/deny an incoming connection on their side\n\n let localChan = -1;\n let reason;\n\n const accept = () => {\n const chanInfo = {\n type: info.type,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n const stream = new Channel(self, chanInfo);\n self._chanMgr.update(localChan, stream);\n\n self._protocol.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n return stream;\n };\n const reject = () => {\n if (reason === undefined) {\n if (localChan === -1)\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n else\n reason = CHANNEL_OPEN_FAILURE.CONNECT_FAILED;\n }\n\n if (localChan !== -1)\n self._chanMgr.remove(localChan);\n\n self._protocol.channelOpenFail(info.sender, reason, '');\n };\n const reserveChannel = () => {\n localChan = self._chanMgr.add();\n\n if (localChan === -1) {\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of incoming channel open: '\n + 'no channels available'\n );\n }\n }\n\n return (localChan !== -1);\n };\n\n const data = info.data;\n switch (info.type) {\n case 'forwarded-tcpip': {\n const val = self._forwarding[`${data.destIP}:${data.destPort}`];\n if (val !== undefined && reserveChannel()) {\n if (data.destPort === 0)\n data.destPort = val;\n self.emit('tcp connection', data, accept, reject);\n return;\n }\n break;\n }\n case 'forwarded-streamlocal@openssh.com':\n if (self._forwardingUnix[data.socketPath] !== undefined\n && reserveChannel()) {\n self.emit('unix connection', data, accept, reject);\n return;\n }\n break;\n case 'auth-agent@openssh.com':\n if (self._agentFwdEnabled\n && typeof self._agent.getStream === 'function'\n && reserveChannel()) {\n self._agent.getStream((err, stream) => {\n if (err)\n return reject();\n\n const upstream = accept();\n upstream.pipe(stream).pipe(upstream);\n });\n return;\n }\n break;\n case 'x11':\n if (self._acceptX11 !== 0 && reserveChannel()) {\n self.emit('x11', data, accept, reject);\n return;\n }\n break;\n default:\n // Automatically reject any unsupported channel open requests\n reason = CHANNEL_OPEN_FAILURE.UNKNOWN_CHANNEL_TYPE;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of unsupported incoming channel open '\n + `type: ${info.type}`\n );\n }\n }\n\n if (reason === undefined) {\n reason = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n if (self.config.debug) {\n self.config.debug(\n 'Client: Automatic rejection of unexpected incoming channel open for: '\n + info.type\n );\n }\n }\n\n reject();\n}\n\nconst randomCookie = (() => {\n const buffer = Buffer.allocUnsafe(16);\n return () => {\n randomFillSync(buffer, 0, 16);\n return buffer.hexSlice(0, 16);\n };\n})();\n\nfunction makeSimpleAuthHandler(authList) {\n if (!Array.isArray(authList))\n throw new Error('authList must be an array');\n\n let a = 0;\n return (authsLeft, partialSuccess, cb) => {\n if (a === authList.length)\n return false;\n return authList[a++];\n };\n}\n\nfunction hostKeysProve(client, keys_, cb) {\n if (!client._sock || !isWritable(client._sock))\n return;\n\n if (typeof cb !== 'function')\n cb = noop;\n\n if (!Array.isArray(keys_))\n throw new TypeError('Invalid keys argument type');\n\n const keys = [];\n for (const key of keys_) {\n const parsed = parseKey(key);\n if (parsed instanceof Error)\n throw parsed;\n keys.push(parsed);\n }\n\n if (!client.config.strictVendor\n || (client.config.strictVendor && RE_OPENSSH.test(client._remoteVer))) {\n client._callbacks.push((had_err, data) => {\n if (had_err) {\n cb(had_err !== true\n ? had_err\n : new Error('Server failed to prove supplied keys'));\n return;\n }\n\n // TODO: move all of this parsing/verifying logic out of the client?\n const ret = [];\n let keyIdx = 0;\n bufferParser.init(data, 0);\n while (bufferParser.avail()) {\n if (keyIdx === keys.length)\n break;\n const key = keys[keyIdx++];\n const keyPublic = key.getPublicSSH();\n\n const sigEntry = bufferParser.readString();\n sigParser.init(sigEntry, 0);\n const type = sigParser.readString(true);\n let value = sigParser.readString();\n\n let algo;\n if (type !== key.type) {\n if (key.type === 'ssh-rsa') {\n switch (type) {\n case 'rsa-sha2-256':\n algo = 'sha256';\n break;\n case 'rsa-sha2-512':\n algo = 'sha512';\n break;\n default:\n continue;\n }\n } else {\n continue;\n }\n }\n\n const sessionID = client._protocol._kex.sessionID;\n const verifyData = Buffer.allocUnsafe(\n 4 + 29 + 4 + sessionID.length + 4 + keyPublic.length\n );\n let p = 0;\n writeUInt32BE(verifyData, 29, p);\n verifyData.utf8Write('hostkeys-prove-00@openssh.com', p += 4, 29);\n writeUInt32BE(verifyData, sessionID.length, p += 29);\n bufferCopy(sessionID, verifyData, 0, sessionID.length, p += 4);\n writeUInt32BE(verifyData, keyPublic.length, p += sessionID.length);\n bufferCopy(keyPublic, verifyData, 0, keyPublic.length, p += 4);\n\n if (!(value = sigSSHToASN1(value, type)))\n continue;\n if (key.verify(verifyData, value, algo) === true)\n ret.push(key);\n }\n sigParser.clear();\n bufferParser.clear();\n\n cb(null, ret);\n });\n\n client._protocol.openssh_hostKeysProve(keys);\n return;\n }\n\n process.nextTick(\n cb,\n new Error(\n 'strictVendor enabled and server is not OpenSSH or compatible version'\n )\n );\n}\n\nmodule.exports = Client;\n","'use strict';\n\nconst { Agent: HttpAgent } = require('http');\nconst { Agent: HttpsAgent } = require('https');\nconst { connect: tlsConnect } = require('tls');\n\nlet Client;\n\nfor (const ctor of [HttpAgent, HttpsAgent]) {\n class SSHAgent extends ctor {\n constructor(connectCfg, agentOptions) {\n super(agentOptions);\n\n this._connectCfg = connectCfg;\n this._defaultSrcIP = (agentOptions && agentOptions.srcIP) || 'localhost';\n }\n\n createConnection(options, cb) {\n const srcIP = (options && options.localAddress) || this._defaultSrcIP;\n const srcPort = (options && options.localPort) || 0;\n const dstIP = options.host;\n const dstPort = options.port;\n\n if (Client === undefined)\n Client = require('./client.js');\n\n const client = new Client();\n let triedForward = false;\n client.on('ready', () => {\n client.forwardOut(srcIP, srcPort, dstIP, dstPort, (err, stream) => {\n triedForward = true;\n if (err) {\n client.end();\n return cb(err);\n }\n stream.once('close', () => client.end());\n cb(null, decorateStream(stream, ctor, options));\n });\n }).on('error', cb).on('close', () => {\n if (!triedForward)\n cb(new Error('Unexpected connection close'));\n }).connect(this._connectCfg);\n }\n }\n\n exports[ctor === HttpAgent ? 'SSHTTPAgent' : 'SSHTTPSAgent'] = SSHAgent;\n}\n\nfunction noop() {}\n\nfunction decorateStream(stream, ctor, options) {\n if (ctor === HttpAgent) {\n // HTTP\n stream.setKeepAlive = noop;\n stream.setNoDelay = noop;\n stream.setTimeout = noop;\n stream.ref = noop;\n stream.unref = noop;\n stream.destroySoon = stream.destroy;\n return stream;\n }\n\n // HTTPS\n options.socket = stream;\n const wrapped = tlsConnect(options);\n\n // This is a workaround for a regression in node v12.16.3+\n // https://github.com/nodejs/node/issues/35904\n const onClose = (() => {\n let called = false;\n return () => {\n if (called)\n return;\n called = true;\n if (stream.isPaused())\n stream.resume();\n };\n })();\n // 'end' listener is needed because 'close' is not emitted in some scenarios\n // in node v12.x for some unknown reason\n wrapped.on('end', onClose).on('close', onClose);\n\n return wrapped;\n}\n","'use strict';\n\nconst {\n AgentProtocol,\n BaseAgent,\n createAgent,\n CygwinAgent,\n OpenSSHAgent,\n PageantAgent,\n} = require('./agent.js');\nconst {\n SSHTTPAgent: HTTPAgent,\n SSHTTPSAgent: HTTPSAgent,\n} = require('./http-agents.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst {\n flagsToString,\n OPEN_MODE,\n STATUS_CODE,\n stringToFlags,\n} = require('./protocol/SFTP.js');\n\nmodule.exports = {\n AgentProtocol,\n BaseAgent,\n createAgent,\n Client: require('./client.js'),\n CygwinAgent,\n HTTPAgent,\n HTTPSAgent,\n OpenSSHAgent,\n PageantAgent,\n Server: require('./server.js'),\n utils: {\n parseKey,\n sftp: {\n flagsToString,\n OPEN_MODE,\n STATUS_CODE,\n stringToFlags,\n },\n },\n};\n","/*\n TODO:\n * Replace `buffer._pos` usage in keyParser.js and elsewhere\n * Utilize optional \"writev\" support when writing packets from\n cipher.encrypt()\n * Built-in support for automatic re-keying, on by default\n * Revisit receiving unexpected/unknown packets\n * Error (fatal or otherwise) or ignore or pass on to user (in some or all\n cases)?\n * Including server/client check for single directional packet types?\n * Check packets for validity or bail as early as possible?\n * Automatic re-key every 2**31 packets after the last key exchange (sent or\n received), as suggested by RFC4344. OpenSSH currently does this.\n * Automatic re-key every so many blocks depending on cipher. RFC4344:\n Because of a birthday property of block ciphers and some modes of\n operation, implementations must be careful not to encrypt too many\n blocks with the same encryption key.\n\n Let L be the block length (in bits) of an SSH encryption method's\n block cipher (e.g., 128 for AES). If L is at least 128, then, after\n rekeying, an SSH implementation SHOULD NOT encrypt more than 2**(L/4)\n blocks before rekeying again. If L is at least 128, then SSH\n implementations should also attempt to force a rekey before receiving\n more than 2**(L/4) blocks. If L is less than 128 (which is the case\n for older ciphers such as 3DES, Blowfish, CAST-128, and IDEA), then,\n although it may be too expensive to rekey every 2**(L/4) blocks, it\n is still advisable for SSH implementations to follow the original\n recommendation in [RFC4253]: rekey at least once for every gigabyte\n of transmitted data.\n\n Note that if L is less than or equal to 128, then the recommendation\n in this subsection supersedes the recommendation in Section 3.1. If\n an SSH implementation uses a block cipher with a larger block size\n (e.g., Rijndael with 256-bit blocks), then the recommendations in\n Section 3.1 may supersede the recommendations in this subsection\n (depending on the lengths of the packets).\n*/\n\n'use strict';\n\nconst { inspect } = require('util');\n\nconst { bindingAvailable, NullCipher, NullDecipher } = require('./crypto.js');\nconst {\n COMPAT_CHECKS,\n DISCONNECT_REASON,\n MESSAGE,\n SIGNALS,\n TERMINAL_MODE,\n} = require('./constants.js');\nconst {\n DEFAULT_KEXINIT,\n KexInit,\n kexinit,\n onKEXPayload,\n} = require('./kex.js');\nconst {\n parseKey,\n} = require('./keyParser.js');\nconst MESSAGE_HANDLERS = require('./handlers.js');\nconst {\n bufferCopy,\n bufferFill,\n bufferSlice,\n convertSignature,\n sendPacket,\n writeUInt32BE,\n} = require('./utils.js');\nconst {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n} = require('./zlib.js');\n\nconst MODULE_VER = require('../../package.json').version;\n\nconst VALID_DISCONNECT_REASONS = new Map(\n Object.values(DISCONNECT_REASON).map((n) => [n, 1])\n);\nconst IDENT_RAW = Buffer.from(`SSH-2.0-ssh2js${MODULE_VER}`);\nconst IDENT = Buffer.from(`${IDENT_RAW}\\r\\n`);\nconst MAX_LINE_LEN = 8192;\nconst MAX_LINES = 1024;\nconst PING_PAYLOAD = Buffer.from([\n MESSAGE.GLOBAL_REQUEST,\n // \"keepalive@openssh.com\"\n 0, 0, 0, 21,\n 107, 101, 101, 112, 97, 108, 105, 118, 101, 64, 111, 112, 101, 110, 115,\n 115, 104, 46, 99, 111, 109,\n // Request a reply\n 1,\n]);\nconst NO_TERMINAL_MODES_BUFFER = Buffer.from([ TERMINAL_MODE.TTY_OP_END ]);\n\nfunction noop() {}\n\n/*\n Inbound:\n * kexinit payload (needed only until exchange hash is generated)\n * raw ident\n * rekey packet queue\n * expected packet (implemented as separate _parse() function?)\n Outbound:\n * kexinit payload (needed only until exchange hash is generated)\n * rekey packet queue\n * kex secret (needed only until NEWKEYS)\n * exchange hash (needed only until NEWKEYS)\n * session ID (set to exchange hash from initial handshake)\n*/\nclass Protocol {\n constructor(config) {\n const onWrite = config.onWrite;\n if (typeof onWrite !== 'function')\n throw new Error('Missing onWrite function');\n this._onWrite = (data) => { onWrite(data); };\n\n const onError = config.onError;\n if (typeof onError !== 'function')\n throw new Error('Missing onError function');\n this._onError = (err) => { onError(err); };\n\n const debug = config.debug;\n this._debug = (typeof debug === 'function'\n ? (msg) => { debug(msg); }\n : undefined);\n\n const onHeader = config.onHeader;\n this._onHeader = (typeof onHeader === 'function'\n ? (...args) => { onHeader(...args); }\n : noop);\n\n const onPacket = config.onPacket;\n this._onPacket = (typeof onPacket === 'function'\n ? () => { onPacket(); }\n : noop);\n\n let onHandshakeComplete = config.onHandshakeComplete;\n if (typeof onHandshakeComplete !== 'function')\n onHandshakeComplete = noop;\n this._onHandshakeComplete = (...args) => {\n this._debug && this._debug('Handshake completed');\n\n // Process packets queued during a rekey where necessary\n const oldQueue = this._queue;\n if (oldQueue) {\n this._queue = undefined;\n this._debug && this._debug(\n `Draining outbound queue (${oldQueue.length}) ...`\n );\n for (let i = 0; i < oldQueue.length; ++i) {\n const data = oldQueue[i];\n // data === payload only\n\n // XXX: hacky\n let finalized = this._packetRW.write.finalize(data);\n if (finalized === data) {\n const packet = this._cipher.allocPacket(data.length);\n packet.set(data, 5);\n finalized = packet;\n }\n\n sendPacket(this, finalized);\n }\n this._debug && this._debug('... finished draining outbound queue');\n }\n\n onHandshakeComplete(...args);\n };\n this._queue = undefined;\n\n const messageHandlers = config.messageHandlers;\n if (typeof messageHandlers === 'object' && messageHandlers !== null)\n this._handlers = messageHandlers;\n else\n this._handlers = {};\n\n this._onPayload = onPayload.bind(this);\n\n this._server = !!config.server;\n this._banner = undefined;\n let greeting;\n if (this._server) {\n if (typeof config.hostKeys !== 'object' || config.hostKeys === null)\n throw new Error('Missing server host key(s)');\n this._hostKeys = config.hostKeys;\n\n // Greeting displayed before the ssh identification string is sent, this\n // is usually ignored by most clients\n if (typeof config.greeting === 'string' && config.greeting.length) {\n greeting = (config.greeting.slice(-2) === '\\r\\n'\n ? config.greeting\n : `${config.greeting}\\r\\n`);\n }\n\n // Banner shown after the handshake completes, but before user\n // authentication begins\n if (typeof config.banner === 'string' && config.banner.length) {\n this._banner = (config.banner.slice(-2) === '\\r\\n'\n ? config.banner\n : `${config.banner}\\r\\n`);\n }\n } else {\n this._hostKeys = undefined;\n }\n\n let offer = config.offer;\n if (typeof offer !== 'object' || offer === null)\n offer = DEFAULT_KEXINIT;\n else if (offer.constructor !== KexInit)\n offer = new KexInit(offer);\n this._kex = undefined;\n this._kexinit = undefined;\n this._offer = offer;\n this._cipher = new NullCipher(0, this._onWrite);\n this._decipher = undefined;\n this._skipNextInboundPacket = false;\n this._packetRW = {\n read: new PacketReader(),\n write: new PacketWriter(this),\n };\n this._hostVerifier = (!this._server\n && typeof config.hostVerifier === 'function'\n ? config.hostVerifier\n : undefined);\n\n this._parse = parseHeader;\n this._buffer = undefined;\n this._authsQueue = [];\n this._authenticated = false;\n this._remoteIdentRaw = undefined;\n let sentIdent;\n if (typeof config.ident === 'string') {\n this._identRaw = Buffer.from(`SSH-2.0-${config.ident}`);\n\n sentIdent = Buffer.allocUnsafe(this._identRaw.length + 2);\n sentIdent.set(this._identRaw, 0);\n sentIdent[sentIdent.length - 2] = 13; // '\\r'\n sentIdent[sentIdent.length - 1] = 10; // '\\n'\n } else if (Buffer.isBuffer(config.ident)) {\n const fullIdent = Buffer.allocUnsafe(8 + config.ident.length);\n fullIdent.latin1Write('SSH-2.0-', 0, 8);\n fullIdent.set(config.ident, 8);\n this._identRaw = fullIdent;\n\n sentIdent = Buffer.allocUnsafe(fullIdent.length + 2);\n sentIdent.set(fullIdent, 0);\n sentIdent[sentIdent.length - 2] = 13; // '\\r'\n sentIdent[sentIdent.length - 1] = 10; // '\\n'\n } else {\n this._identRaw = IDENT_RAW;\n sentIdent = IDENT;\n }\n this._compatFlags = 0;\n\n if (this._debug) {\n if (bindingAvailable)\n this._debug('Custom crypto binding available');\n else\n this._debug('Custom crypto binding not available');\n }\n\n this._debug && this._debug(\n `Local ident: ${inspect(this._identRaw.toString())}`\n );\n this.start = () => {\n this.start = undefined;\n if (greeting)\n this._onWrite(greeting);\n this._onWrite(sentIdent);\n };\n }\n _destruct(reason) {\n this._packetRW.read.cleanup();\n this._packetRW.write.cleanup();\n this._cipher && this._cipher.free();\n this._decipher && this._decipher.free();\n if (typeof reason !== 'string' || reason.length === 0)\n reason = 'fatal error';\n this.parse = () => {\n throw new Error(`Instance unusable after ${reason}`);\n };\n this._onWrite = () => {\n throw new Error(`Instance unusable after ${reason}`);\n };\n this._destruct = undefined;\n }\n cleanup() {\n this._destruct && this._destruct();\n }\n parse(chunk, i, len) {\n while (i < len)\n i = this._parse(chunk, i, len);\n }\n\n // Protocol message API\n\n // ===========================================================================\n // Common/Shared =============================================================\n // ===========================================================================\n\n // Global\n // ------\n disconnect(reason) {\n const pktLen = 1 + 4 + 4 + 4;\n // We don't use _packetRW.write.* here because we need to make sure that\n // we always get a full packet allocated because this message can be sent\n // at any time -- even during a key exchange\n let p = this._packetRW.write.allocStartKEX;\n const packet = this._packetRW.write.alloc(pktLen, true);\n const end = p + pktLen;\n\n if (!VALID_DISCONNECT_REASONS.has(reason))\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n\n packet[p] = MESSAGE.DISCONNECT;\n writeUInt32BE(packet, reason, ++p);\n packet.fill(0, p += 4, end);\n\n this._debug && this._debug(`Outbound: Sending DISCONNECT (${reason})`);\n sendPacket(this, this._packetRW.write.finalize(packet, true), true);\n }\n ping() {\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(PING_PAYLOAD.length);\n\n packet.set(PING_PAYLOAD, p);\n\n this._debug && this._debug(\n 'Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n rekey() {\n if (this._kexinit === undefined) {\n this._debug && this._debug('Outbound: Initiated explicit rekey');\n this._queue = [];\n kexinit(this);\n } else {\n this._debug && this._debug('Outbound: Ignoring rekey during handshake');\n }\n }\n\n // 'ssh-connection' service-specific\n // ---------------------------------\n requestSuccess(data) {\n let p = this._packetRW.write.allocStart;\n let packet;\n if (Buffer.isBuffer(data)) {\n packet = this._packetRW.write.alloc(1 + data.length);\n\n packet[p] = MESSAGE.REQUEST_SUCCESS;\n\n packet.set(data, ++p);\n } else {\n packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.REQUEST_SUCCESS;\n }\n\n this._debug && this._debug('Outbound: Sending REQUEST_SUCCESS');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n requestFailure() {\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.REQUEST_FAILURE;\n\n this._debug && this._debug('Outbound: Sending REQUEST_FAILURE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelSuccess(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_SUCCESS;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelFailure(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_FAILURE;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelEOF(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_EOF;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_EOF (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelClose(chan) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_CLOSE;\n\n writeUInt32BE(packet, chan, ++p);\n\n this._debug && this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelWindowAdjust(chan, amount) {\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_WINDOW_ADJUST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, amount, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${chan}, ${amount})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelData(chan, data) {\n const isBuffer = Buffer.isBuffer(data);\n const dataLen = (isBuffer ? data.length : Buffer.byteLength(data));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + dataLen);\n\n packet[p] = MESSAGE.CHANNEL_DATA;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, dataLen, p += 4);\n\n if (isBuffer)\n packet.set(data, p += 4);\n else\n packet.utf8Write(data, p += 4, dataLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_DATA (r:${chan}, ${dataLen})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelExtData(chan, data, type) {\n const isBuffer = Buffer.isBuffer(data);\n const dataLen = (isBuffer ? data.length : Buffer.byteLength(data));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + dataLen);\n\n packet[p] = MESSAGE.CHANNEL_EXTENDED_DATA;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, type, p += 4);\n\n writeUInt32BE(packet, dataLen, p += 4);\n\n if (isBuffer)\n packet.set(data, p += 4);\n else\n packet.utf8Write(data, p += 4, dataLen);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${chan})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelOpenConfirm(remote, local, initWindow, maxPacket) {\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN_CONFIRMATION;\n\n writeUInt32BE(packet, remote, ++p);\n\n writeUInt32BE(packet, local, p += 4);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${remote}, l:${local})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n channelOpenFail(remote, reason, desc) {\n if (typeof desc !== 'string')\n desc = '';\n\n const descLen = Buffer.byteLength(desc);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + descLen + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN_FAILURE;\n\n writeUInt32BE(packet, remote, ++p);\n\n writeUInt32BE(packet, reason, p += 4);\n\n writeUInt32BE(packet, descLen, p += 4);\n\n p += 4;\n if (descLen) {\n packet.utf8Write(desc, p, descLen);\n p += descLen;\n }\n\n writeUInt32BE(packet, 0, p); // Empty language tag\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${remote})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // ===========================================================================\n // Client-specific ===========================================================\n // ===========================================================================\n\n // Global\n // ------\n service(name) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const nameLen = Buffer.byteLength(name);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + nameLen);\n\n packet[p] = MESSAGE.SERVICE_REQUEST;\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(name, p += 4, nameLen);\n\n this._debug && this._debug(`Outbound: Sending SERVICE_REQUEST (${name})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // 'ssh-userauth' service-specific\n // -------------------------------\n authPassword(username, password, newPassword) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n const passLen = Buffer.byteLength(password);\n const newPassLen = (newPassword ? Buffer.byteLength(newPassword) : 0);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 8 + 1 + 4 + passLen\n + (newPassword ? 4 + newPassLen : 0)\n );\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 8, p += 14);\n packet.utf8Write('password', p += 4, 8);\n\n packet[p += 8] = (newPassword ? 1 : 0);\n\n writeUInt32BE(packet, passLen, ++p);\n if (Buffer.isBuffer(password))\n bufferCopy(password, packet, 0, passLen, p += 4);\n else\n packet.utf8Write(password, p += 4, passLen);\n\n if (newPassword) {\n writeUInt32BE(packet, newPassLen, p += passLen);\n if (Buffer.isBuffer(newPassword))\n bufferCopy(newPassword, packet, 0, newPassLen, p += 4);\n else\n packet.utf8Write(newPassword, p += 4, newPassLen);\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (changed password)'\n );\n } else {\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (password)'\n );\n }\n\n this._authsQueue.push('password');\n\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authPK(username, pubKey, cbSign) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n pubKey = parseKey(pubKey);\n if (pubKey instanceof Error)\n throw new Error('Invalid key');\n\n const keyType = pubKey.type;\n pubKey = pubKey.getPublicSSH();\n\n const userLen = Buffer.byteLength(username);\n const algoLen = Buffer.byteLength(keyType);\n const pubKeyLen = pubKey.length;\n const sessionID = this._kex.sessionID;\n const sesLen = sessionID.length;\n const payloadLen =\n (cbSign ? 4 + sesLen : 0)\n + 1 + 4 + userLen + 4 + 14 + 4 + 9 + 1 + 4 + algoLen + 4 + pubKeyLen;\n let packet;\n let p;\n if (cbSign) {\n packet = Buffer.allocUnsafe(payloadLen);\n p = 0;\n writeUInt32BE(packet, sesLen, p);\n packet.set(sessionID, p += 4);\n p += sesLen;\n } else {\n packet = this._packetRW.write.alloc(payloadLen);\n p = this._packetRW.write.allocStart;\n }\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 9, p += 14);\n packet.utf8Write('publickey', p += 4, 9);\n\n packet[p += 9] = (cbSign ? 1 : 0);\n\n writeUInt32BE(packet, algoLen, ++p);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, pubKeyLen, p += algoLen);\n packet.set(pubKey, p += 4);\n\n if (!cbSign) {\n this._authsQueue.push('publickey');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (publickey -- check)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n return;\n }\n\n cbSign(packet, (signature) => {\n signature = convertSignature(signature, keyType);\n if (signature === false)\n throw new Error('Error while converting handshake signature');\n\n const sigLen = signature.length;\n p = this._packetRW.write.allocStart;\n packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 9 + 1 + 4 + algoLen + 4 + pubKeyLen + 4\n + 4 + algoLen + 4 + sigLen\n );\n\n // TODO: simply copy from original \"packet\" to new `packet` to avoid\n // having to write each individual field a second time?\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 9, p += 14);\n packet.utf8Write('publickey', p += 4, 9);\n\n packet[p += 9] = 1;\n\n writeUInt32BE(packet, algoLen, ++p);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, pubKeyLen, p += algoLen);\n packet.set(pubKey, p += 4);\n\n writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += pubKeyLen);\n\n writeUInt32BE(packet, algoLen, p += 4);\n packet.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(packet, sigLen, p += algoLen);\n packet.set(signature, p += 4);\n\n // Servers shouldn't send packet type 60 in response to signed publickey\n // attempts, but if they do, interpret as type 60.\n this._authsQueue.push('publickey');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (publickey)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n });\n }\n authHostbased(username, pubKey, hostname, userlocal, cbSign) {\n // TODO: Make DRY by sharing similar code with authPK()\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n pubKey = parseKey(pubKey);\n if (pubKey instanceof Error)\n throw new Error('Invalid key');\n\n const keyType = pubKey.type;\n pubKey = pubKey.getPublicSSH();\n\n const userLen = Buffer.byteLength(username);\n const algoLen = Buffer.byteLength(keyType);\n const pubKeyLen = pubKey.length;\n const sessionID = this._kex.sessionID;\n const sesLen = sessionID.length;\n const hostnameLen = Buffer.byteLength(hostname);\n const userlocalLen = Buffer.byteLength(userlocal);\n const data = Buffer.allocUnsafe(\n 4 + sesLen + 1 + 4 + userLen + 4 + 14 + 4 + 9 + 4 + algoLen\n + 4 + pubKeyLen + 4 + hostnameLen + 4 + userlocalLen\n );\n let p = 0;\n\n writeUInt32BE(data, sesLen, p);\n data.set(sessionID, p += 4);\n\n data[p += sesLen] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(data, userLen, ++p);\n data.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(data, 14, p += userLen);\n data.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(data, 9, p += 14);\n data.utf8Write('hostbased', p += 4, 9);\n\n writeUInt32BE(data, algoLen, p += 9);\n data.utf8Write(keyType, p += 4, algoLen);\n\n writeUInt32BE(data, pubKeyLen, p += algoLen);\n data.set(pubKey, p += 4);\n\n writeUInt32BE(data, hostnameLen, p += pubKeyLen);\n data.utf8Write(hostname, p += 4, hostnameLen);\n\n writeUInt32BE(data, userlocalLen, p += hostnameLen);\n data.utf8Write(userlocal, p += 4, userlocalLen);\n\n cbSign(data, (signature) => {\n signature = convertSignature(signature, keyType);\n if (!signature)\n throw new Error('Error while converting handshake signature');\n\n const sigLen = signature.length;\n const reqDataLen = (data.length - sesLen - 4);\n p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n reqDataLen + 4 + 4 + algoLen + 4 + sigLen\n );\n\n bufferCopy(data, packet, 4 + sesLen, data.length, p);\n\n writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += reqDataLen);\n writeUInt32BE(packet, algoLen, p += 4);\n packet.utf8Write(keyType, p += 4, algoLen);\n writeUInt32BE(packet, sigLen, p += algoLen);\n packet.set(signature, p += 4);\n\n this._authsQueue.push('hostbased');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (hostbased)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n });\n }\n authKeyboard(username) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + userLen + 4 + 14 + 4 + 20 + 4 + 4\n );\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 20, p += 14);\n packet.utf8Write('keyboard-interactive', p += 4, 20);\n\n writeUInt32BE(packet, 0, p += 20);\n\n writeUInt32BE(packet, 0, p += 4);\n\n this._authsQueue.push('keyboard-interactive');\n\n this._debug && this._debug(\n 'Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authNone(username) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const userLen = Buffer.byteLength(username);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + userLen + 4 + 14 + 4 + 4);\n\n packet[p] = MESSAGE.USERAUTH_REQUEST;\n\n writeUInt32BE(packet, userLen, ++p);\n packet.utf8Write(username, p += 4, userLen);\n\n writeUInt32BE(packet, 14, p += userLen);\n packet.utf8Write('ssh-connection', p += 4, 14);\n\n writeUInt32BE(packet, 4, p += 14);\n packet.utf8Write('none', p += 4, 4);\n\n this._authsQueue.push('none');\n\n this._debug && this._debug('Outbound: Sending USERAUTH_REQUEST (none)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authInfoRes(responses) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let responsesTotalLen = 0;\n let responseLens;\n\n if (responses) {\n responseLens = new Array(responses.length);\n for (let i = 0; i < responses.length; ++i) {\n const len = Buffer.byteLength(responses[i]);\n responseLens[i] = len;\n responsesTotalLen += 4 + len;\n }\n }\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + responsesTotalLen);\n\n packet[p] = MESSAGE.USERAUTH_INFO_RESPONSE;\n\n if (responses) {\n writeUInt32BE(packet, responses.length, ++p);\n p += 4;\n for (let i = 0; i < responses.length; ++i) {\n const len = responseLens[i];\n writeUInt32BE(packet, len, p);\n p += 4;\n if (len) {\n packet.utf8Write(responses[i], p, len);\n p += len;\n }\n }\n } else {\n writeUInt32BE(packet, 0, ++p);\n }\n\n this._debug && this._debug('Outbound: Sending USERAUTH_INFO_RESPONSE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // 'ssh-connection' service-specific\n // ---------------------------------\n tcpipForward(bindAddr, bindPort, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const addrLen = Buffer.byteLength(bindAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 13 + 1 + 4 + addrLen + 4);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 13, ++p);\n packet.utf8Write('tcpip-forward', p += 4, 13);\n\n packet[p += 13] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, addrLen, ++p);\n packet.utf8Write(bindAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, bindPort, p += addrLen);\n\n this._debug\n && this._debug('Outbound: Sending GLOBAL_REQUEST (tcpip-forward)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n cancelTcpipForward(bindAddr, bindPort, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const addrLen = Buffer.byteLength(bindAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 20 + 1 + 4 + addrLen + 4);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 20, ++p);\n packet.utf8Write('cancel-tcpip-forward', p += 4, 20);\n\n packet[p += 20] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, addrLen, ++p);\n packet.utf8Write(bindAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, bindPort, p += addrLen);\n\n this._debug\n && this._debug('Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_streamLocalForward(socketPath, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const socketPathLen = Buffer.byteLength(socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 31 + 1 + 4 + socketPathLen\n );\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 31, ++p);\n packet.utf8Write('streamlocal-forward@openssh.com', p += 4, 31);\n\n packet[p += 31] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, socketPathLen, ++p);\n packet.utf8Write(socketPath, p += 4, socketPathLen);\n\n this._debug && this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_cancelStreamLocalForward(socketPath, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const socketPathLen = Buffer.byteLength(socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 38 + 1 + 4 + socketPathLen\n );\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 38, ++p);\n packet.utf8Write('cancel-streamlocal-forward@openssh.com', p += 4, 38);\n\n packet[p += 38] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, socketPathLen, ++p);\n packet.utf8Write(socketPath, p += 4, socketPathLen);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending GLOBAL_REQUEST '\n + '(cancel-streamlocal-forward@openssh.com)'\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n directTcpip(chan, initWindow, maxPacket, cfg) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const srcLen = Buffer.byteLength(cfg.srcIP);\n const dstLen = Buffer.byteLength(cfg.dstIP);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 12 + 4 + 4 + 4 + 4 + srcLen + 4 + 4 + dstLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 12, ++p);\n packet.utf8Write('direct-tcpip', p += 4, 12);\n\n writeUInt32BE(packet, chan, p += 12);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, dstLen, p += 4);\n packet.utf8Write(cfg.dstIP, p += 4, dstLen);\n\n writeUInt32BE(packet, cfg.dstPort, p += dstLen);\n\n writeUInt32BE(packet, srcLen, p += 4);\n packet.utf8Write(cfg.srcIP, p += 4, srcLen);\n\n writeUInt32BE(packet, cfg.srcPort, p += srcLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, direct-tcpip)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_directStreamLocal(chan, initWindow, maxPacket, cfg) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n const pathLen = Buffer.byteLength(cfg.socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 30 + 4 + 4 + 4 + 4 + pathLen + 4 + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 30, ++p);\n packet.utf8Write('direct-streamlocal@openssh.com', p += 4, 30);\n\n writeUInt32BE(packet, chan, p += 30);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, pathLen, p += 4);\n packet.utf8Write(cfg.socketPath, p += 4, pathLen);\n\n // zero-fill reserved fields (string and uint32)\n bufferFill(packet, 0, p += pathLen, p + 8);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_OPEN '\n + `(r:${chan}, direct-streamlocal@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_noMoreSessions(wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 28 + 1);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 28, ++p);\n packet.utf8Write('no-more-sessions@openssh.com', p += 4, 28);\n\n packet[p += 28] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n this._debug && this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)'\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n session(chan, initWindow, maxPacket) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 7 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 7, ++p);\n packet.utf8Write('session', p += 4, 7);\n\n writeUInt32BE(packet, chan, p += 7);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_OPEN (r:${chan}, session)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n windowChange(chan, rows, cols, height, width) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 13 + 1 + 4 + 4 + 4 + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 13, p += 4);\n packet.utf8Write('window-change', p += 4, 13);\n\n packet[p += 13] = 0;\n\n writeUInt32BE(packet, cols, ++p);\n\n writeUInt32BE(packet, rows, p += 4);\n\n writeUInt32BE(packet, width, p += 4);\n\n writeUInt32BE(packet, height, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, window-change)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n pty(chan, rows, cols, height, width, term, modes, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n if (!term || !term.length)\n term = 'vt100';\n if (modes\n && !Buffer.isBuffer(modes)\n && !Array.isArray(modes)\n && typeof modes === 'object'\n && modes !== null) {\n modes = modesToBytes(modes);\n }\n if (!modes || !modes.length)\n modes = NO_TERMINAL_MODES_BUFFER;\n\n const termLen = term.length;\n const modesLen = modes.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 7 + 1 + 4 + termLen + 4 + 4 + 4 + 4 + 4 + modesLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 7, p += 4);\n packet.utf8Write('pty-req', p += 4, 7);\n\n packet[p += 7] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, termLen, ++p);\n packet.utf8Write(term, p += 4, termLen);\n\n writeUInt32BE(packet, cols, p += termLen);\n\n writeUInt32BE(packet, rows, p += 4);\n\n writeUInt32BE(packet, width, p += 4);\n\n writeUInt32BE(packet, height, p += 4);\n\n writeUInt32BE(packet, modesLen, p += 4);\n p += 4;\n if (Array.isArray(modes)) {\n for (let i = 0; i < modesLen; ++i)\n packet[p++] = modes[i];\n } else if (Buffer.isBuffer(modes)) {\n packet.set(modes, p);\n }\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, pty-req)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n shell(chan, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 5 + 1);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 5, p += 4);\n packet.utf8Write('shell', p += 4, 5);\n\n packet[p += 5] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, shell)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exec(chan, cmd, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const isBuf = Buffer.isBuffer(cmd);\n const cmdLen = (isBuf ? cmd.length : Buffer.byteLength(cmd));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 4 + 1 + 4 + cmdLen);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 4, p += 4);\n packet.utf8Write('exec', p += 4, 4);\n\n packet[p += 4] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, cmdLen, ++p);\n if (isBuf)\n packet.set(cmd, p += 4);\n else\n packet.utf8Write(cmd, p += 4, cmdLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exec: ${cmd})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n signal(chan, signal) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const origSignal = signal;\n\n signal = signal.toUpperCase();\n if (signal.slice(0, 3) === 'SIG')\n signal = signal.slice(3);\n\n if (SIGNALS[signal] !== 1)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n const signalLen = signal.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 6 + 1 + 4 + signalLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 6, p += 4);\n packet.utf8Write('signal', p += 4, 6);\n\n packet[p += 6] = 0;\n\n writeUInt32BE(packet, signalLen, ++p);\n packet.utf8Write(signal, p += 4, signalLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, signal: ${signal})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n env(chan, key, val, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const keyLen = Buffer.byteLength(key);\n const isBuf = Buffer.isBuffer(val);\n const valLen = (isBuf ? val.length : Buffer.byteLength(val));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 3 + 1 + 4 + keyLen + 4 + valLen\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 3, p += 4);\n packet.utf8Write('env', p += 4, 3);\n\n packet[p += 3] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, keyLen, ++p);\n packet.utf8Write(key, p += 4, keyLen);\n\n writeUInt32BE(packet, valLen, p += keyLen);\n if (isBuf)\n packet.set(val, p += 4);\n else\n packet.utf8Write(val, p += 4, valLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, env: ${key}=${val})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n x11Forward(chan, cfg, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n const protocol = cfg.protocol;\n const cookie = cfg.cookie;\n const isBufProto = Buffer.isBuffer(protocol);\n const protoLen = (isBufProto\n ? protocol.length\n : Buffer.byteLength(protocol));\n const isBufCookie = Buffer.isBuffer(cookie);\n const cookieLen = (isBufCookie\n ? cookie.length\n : Buffer.byteLength(cookie));\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 7 + 1 + 1 + 4 + protoLen + 4 + cookieLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 7, p += 4);\n packet.utf8Write('x11-req', p += 4, 7);\n\n packet[p += 7] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n packet[++p] = (cfg.single ? 1 : 0);\n\n writeUInt32BE(packet, protoLen, ++p);\n if (isBufProto)\n packet.set(protocol, p += 4);\n else\n packet.utf8Write(protocol, p += 4, protoLen);\n\n writeUInt32BE(packet, cookieLen, p += protoLen);\n if (isBufCookie)\n packet.set(cookie, p += 4);\n else\n packet.latin1Write(cookie, p += 4, cookieLen);\n\n writeUInt32BE(packet, (cfg.screen || 0), p += cookieLen);\n\n this._debug\n && this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${chan}, x11-req)`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n subsystem(chan, name, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n const nameLen = Buffer.byteLength(name);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 9 + 1 + 4 + nameLen);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 9, p += 4);\n packet.utf8Write('subsystem', p += 4, 9);\n\n packet[p += 9] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(name, p += 4, nameLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, subsystem: ${name})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_agentForward(chan, wantReply) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n // Does not consume window space\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 26 + 1);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 26, p += 4);\n packet.utf8Write('auth-agent-req@openssh.com', p += 4, 26);\n\n packet[p += 26] = (wantReply === undefined || wantReply === true ? 1 : 0);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_REQUEST '\n + `(r:${chan}, auth-agent-req@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_hostKeysProve(keys) {\n if (this._server)\n throw new Error('Client-only method called in server mode');\n\n let keysTotal = 0;\n const publicKeys = [];\n for (const key of keys) {\n const publicKey = key.getPublicSSH();\n keysTotal += 4 + publicKey.length;\n publicKeys.push(publicKey);\n }\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 29 + 1 + keysTotal);\n\n packet[p] = MESSAGE.GLOBAL_REQUEST;\n\n writeUInt32BE(packet, 29, ++p);\n packet.utf8Write('hostkeys-prove-00@openssh.com', p += 4, 29);\n\n packet[p += 29] = 1; // want reply\n\n ++p;\n for (const buf of publicKeys) {\n writeUInt32BE(packet, buf.length, p);\n bufferCopy(buf, packet, 0, buf.length, p += 4);\n p += buf.length;\n }\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)'\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n\n // ===========================================================================\n // Server-specific ===========================================================\n // ===========================================================================\n\n // Global\n // ------\n serviceAccept(svcName) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const svcNameLen = Buffer.byteLength(svcName);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + svcNameLen);\n\n packet[p] = MESSAGE.SERVICE_ACCEPT;\n\n writeUInt32BE(packet, svcNameLen, ++p);\n packet.utf8Write(svcName, p += 4, svcNameLen);\n\n this._debug && this._debug(`Outbound: Sending SERVICE_ACCEPT (${svcName})`);\n sendPacket(this, this._packetRW.write.finalize(packet));\n\n if (this._server && this._banner && svcName === 'ssh-userauth') {\n const banner = this._banner;\n this._banner = undefined; // Prevent banner from being displayed again\n const bannerLen = Buffer.byteLength(banner);\n p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + bannerLen + 4);\n\n packet[p] = MESSAGE.USERAUTH_BANNER;\n\n writeUInt32BE(packet, bannerLen, ++p);\n packet.utf8Write(banner, p += 4, bannerLen);\n\n writeUInt32BE(packet, 0, p += bannerLen); // Empty language tag\n\n this._debug && this._debug('Outbound: Sending USERAUTH_BANNER');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n }\n // 'ssh-connection' service-specific\n forwardedTcpip(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const boundAddrLen = Buffer.byteLength(cfg.boundAddr);\n const remoteAddrLen = Buffer.byteLength(cfg.remoteAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 15 + 4 + 4 + 4 + 4 + boundAddrLen + 4 + 4 + remoteAddrLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 15, ++p);\n packet.utf8Write('forwarded-tcpip', p += 4, 15);\n\n writeUInt32BE(packet, chan, p += 15);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, boundAddrLen, p += 4);\n packet.utf8Write(cfg.boundAddr, p += 4, boundAddrLen);\n\n writeUInt32BE(packet, cfg.boundPort, p += boundAddrLen);\n\n writeUInt32BE(packet, remoteAddrLen, p += 4);\n packet.utf8Write(cfg.remoteAddr, p += 4, remoteAddrLen);\n\n writeUInt32BE(packet, cfg.remotePort, p += remoteAddrLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, forwarded-tcpip)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n x11(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const addrLen = Buffer.byteLength(cfg.originAddr);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 3 + 4 + 4 + 4 + 4 + addrLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 3, ++p);\n packet.utf8Write('x11', p += 4, 3);\n\n writeUInt32BE(packet, chan, p += 3);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, addrLen, p += 4);\n packet.utf8Write(cfg.originAddr, p += 4, addrLen);\n\n writeUInt32BE(packet, cfg.originPort, p += addrLen);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, x11)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_authAgent(chan, initWindow, maxPacket) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 22 + 4 + 4 + 4);\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 22, ++p);\n packet.utf8Write('auth-agent@openssh.com', p += 4, 22);\n\n writeUInt32BE(packet, chan, p += 22);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_OPEN (r:${chan}, auth-agent@openssh.com)`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n openssh_forwardedStreamLocal(chan, initWindow, maxPacket, cfg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const pathLen = Buffer.byteLength(cfg.socketPath);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 33 + 4 + 4 + 4 + 4 + pathLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_OPEN;\n\n writeUInt32BE(packet, 33, ++p);\n packet.utf8Write('forwarded-streamlocal@openssh.com', p += 4, 33);\n\n writeUInt32BE(packet, chan, p += 33);\n\n writeUInt32BE(packet, initWindow, p += 4);\n\n writeUInt32BE(packet, maxPacket, p += 4);\n\n writeUInt32BE(packet, pathLen, p += 4);\n packet.utf8Write(cfg.socketPath, p += 4, pathLen);\n\n writeUInt32BE(packet, 0, p += pathLen);\n\n if (this._debug) {\n this._debug(\n 'Outbound: Sending CHANNEL_OPEN '\n + `(r:${chan}, forwarded-streamlocal@openssh.com)`\n );\n }\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exitStatus(chan, status) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + 4 + 11 + 1 + 4);\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-status', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, status, ++p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-status: ${status})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n exitSignal(chan, name, coreDumped, msg) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n // Does not consume window space\n\n const origSignal = name;\n\n if (typeof origSignal !== 'string' || !origSignal)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n let signal = name.toUpperCase();\n if (signal.slice(0, 3) === 'SIG')\n signal = signal.slice(3);\n\n if (SIGNALS[signal] !== 1)\n throw new Error(`Invalid signal: ${origSignal}`);\n\n const nameLen = Buffer.byteLength(signal);\n const msgLen = (msg ? Buffer.byteLength(msg) : 0);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + 4 + 11 + 1 + 4 + nameLen + 1 + 4 + msgLen + 4\n );\n\n packet[p] = MESSAGE.CHANNEL_REQUEST;\n\n writeUInt32BE(packet, chan, ++p);\n\n writeUInt32BE(packet, 11, p += 4);\n packet.utf8Write('exit-signal', p += 4, 11);\n\n packet[p += 11] = 0;\n\n writeUInt32BE(packet, nameLen, ++p);\n packet.utf8Write(signal, p += 4, nameLen);\n\n packet[p += nameLen] = (coreDumped ? 1 : 0);\n\n writeUInt32BE(packet, msgLen, ++p);\n\n p += 4;\n if (msgLen) {\n packet.utf8Write(msg, p, msgLen);\n p += msgLen;\n }\n\n writeUInt32BE(packet, 0, p);\n\n this._debug && this._debug(\n `Outbound: Sending CHANNEL_REQUEST (r:${chan}, exit-signal: ${name})`\n );\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n // 'ssh-userauth' service-specific\n authFailure(authMethods, isPartial) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0)\n throw new Error('No auth in progress');\n\n let methods;\n\n if (typeof authMethods === 'boolean') {\n isPartial = authMethods;\n authMethods = undefined;\n }\n\n if (authMethods) {\n methods = [];\n for (let i = 0; i < authMethods.length; ++i) {\n if (authMethods[i].toLowerCase() === 'none')\n continue;\n methods.push(authMethods[i]);\n }\n methods = methods.join(',');\n } else {\n methods = '';\n }\n\n const methodsLen = methods.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + methodsLen + 1);\n\n packet[p] = MESSAGE.USERAUTH_FAILURE;\n\n writeUInt32BE(packet, methodsLen, ++p);\n packet.utf8Write(methods, p += 4, methodsLen);\n\n packet[p += methodsLen] = (isPartial === true ? 1 : 0);\n\n this._authsQueue.shift();\n\n this._debug && this._debug('Outbound: Sending USERAUTH_FAILURE');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authSuccess() {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0)\n throw new Error('No auth in progress');\n\n const p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1);\n\n packet[p] = MESSAGE.USERAUTH_SUCCESS;\n\n this._authsQueue.shift();\n this._authenticated = true;\n\n this._debug && this._debug('Outbound: Sending USERAUTH_SUCCESS');\n sendPacket(this, this._packetRW.write.finalize(packet));\n\n if (this._kex.negotiated.cs.compress === 'zlib@openssh.com')\n this._packetRW.read = new ZlibPacketReader();\n if (this._kex.negotiated.sc.compress === 'zlib@openssh.com')\n this._packetRW.write = new ZlibPacketWriter(this);\n }\n authPKOK(keyAlgo, key) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n if (this._authsQueue.length === 0 || this._authsQueue[0] !== 'publickey')\n throw new Error('\"publickey\" auth not in progress');\n\n // TODO: support parsed key for `key`\n\n const keyAlgoLen = Buffer.byteLength(keyAlgo);\n const keyLen = key.length;\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + keyAlgoLen + 4 + keyLen);\n\n packet[p] = MESSAGE.USERAUTH_PK_OK;\n\n writeUInt32BE(packet, keyAlgoLen, ++p);\n packet.utf8Write(keyAlgo, p += 4, keyAlgoLen);\n\n writeUInt32BE(packet, keyLen, p += keyAlgoLen);\n packet.set(key, p += 4);\n\n this._authsQueue.shift();\n\n this._debug && this._debug('Outbound: Sending USERAUTH_PK_OK');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authPasswdChg(prompt) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n const promptLen = Buffer.byteLength(prompt);\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(1 + 4 + promptLen + 4);\n\n packet[p] = MESSAGE.USERAUTH_PASSWD_CHANGEREQ;\n\n writeUInt32BE(packet, promptLen, ++p);\n packet.utf8Write(prompt, p += 4, promptLen);\n\n writeUInt32BE(packet, 0, p += promptLen); // Empty language tag\n\n this._debug && this._debug('Outbound: Sending USERAUTH_PASSWD_CHANGEREQ');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n authInfoReq(name, instructions, prompts) {\n if (!this._server)\n throw new Error('Server-only method called in client mode');\n\n let promptsLen = 0;\n const nameLen = name ? Buffer.byteLength(name) : 0;\n const instrLen = instructions ? Buffer.byteLength(instructions) : 0;\n\n for (let i = 0; i < prompts.length; ++i)\n promptsLen += 4 + Buffer.byteLength(prompts[i].prompt) + 1;\n\n let p = this._packetRW.write.allocStart;\n const packet = this._packetRW.write.alloc(\n 1 + 4 + nameLen + 4 + instrLen + 4 + 4 + promptsLen\n );\n\n packet[p] = MESSAGE.USERAUTH_INFO_REQUEST;\n\n writeUInt32BE(packet, nameLen, ++p);\n p += 4;\n if (name) {\n packet.utf8Write(name, p, nameLen);\n p += nameLen;\n }\n\n writeUInt32BE(packet, instrLen, p);\n p += 4;\n if (instructions) {\n packet.utf8Write(instructions, p, instrLen);\n p += instrLen;\n }\n\n writeUInt32BE(packet, 0, p);\n\n writeUInt32BE(packet, prompts.length, p += 4);\n p += 4;\n for (let i = 0; i < prompts.length; ++i) {\n const prompt = prompts[i];\n const promptLen = Buffer.byteLength(prompt.prompt);\n\n writeUInt32BE(packet, promptLen, p);\n p += 4;\n if (promptLen) {\n packet.utf8Write(prompt.prompt, p, promptLen);\n p += promptLen;\n }\n packet[p++] = (prompt.echo ? 1 : 0);\n }\n\n this._debug && this._debug('Outbound: Sending USERAUTH_INFO_REQUEST');\n sendPacket(this, this._packetRW.write.finalize(packet));\n }\n}\n\n// SSH-protoversion-softwareversion (SP comments) CR LF\nconst RE_IDENT = /^SSH-(2\\.0|1\\.99)-([^ ]+)(?: (.*))?$/;\n\n// TODO: optimize this by starting n bytes from the end of this._buffer instead\n// of the beginning\nfunction parseHeader(chunk, p, len) {\n let data;\n let chunkOffset;\n if (this._buffer) {\n data = Buffer.allocUnsafe(this._buffer.length + (len - p));\n data.set(this._buffer, 0);\n if (p === 0) {\n data.set(chunk, this._buffer.length);\n } else {\n data.set(new Uint8Array(chunk.buffer,\n chunk.byteOffset + p,\n (len - p)),\n this._buffer.length);\n }\n chunkOffset = this._buffer.length;\n p = 0;\n } else {\n data = chunk;\n chunkOffset = 0;\n }\n const op = p;\n let start = p;\n let end = p;\n let needNL = false;\n let lineLen = 0;\n let lines = 0;\n for (; p < data.length; ++p) {\n const ch = data[p];\n\n if (ch === 13 /* '\\r' */) {\n needNL = true;\n continue;\n }\n\n if (ch === 10 /* '\\n' */) {\n if (end > start\n && end - start > 4\n && data[start] === 83 /* 'S' */\n && data[start + 1] === 83 /* 'S' */\n && data[start + 2] === 72 /* 'H' */\n && data[start + 3] === 45 /* '-' */) {\n\n const full = data.latin1Slice(op, end + 1);\n const identRaw = (start === op ? full : full.slice(start - op));\n const m = RE_IDENT.exec(identRaw);\n if (!m)\n throw new Error('Invalid identification string');\n\n const header = {\n greeting: (start === op ? '' : full.slice(0, start - op)),\n identRaw,\n versions: {\n protocol: m[1],\n software: m[2],\n },\n comments: m[3]\n };\n\n // Needed during handshake\n this._remoteIdentRaw = Buffer.from(identRaw);\n\n this._debug && this._debug(`Remote ident: ${inspect(identRaw)}`);\n this._compatFlags = getCompatFlags(header);\n\n this._buffer = undefined;\n this._decipher =\n new NullDecipher(0, onKEXPayload.bind(this, { firstPacket: true }));\n this._parse = parsePacket;\n\n this._onHeader(header);\n if (!this._destruct) {\n // We disconnected inside _onHeader\n return len;\n }\n\n kexinit(this);\n\n return p + 1 - chunkOffset;\n }\n\n // Only allow pre-ident greetings when we're a client\n if (this._server)\n throw new Error('Greetings from clients not permitted');\n\n if (++lines > MAX_LINES)\n throw new Error('Max greeting lines exceeded');\n\n needNL = false;\n start = p + 1;\n lineLen = 0;\n } else if (needNL) {\n throw new Error('Invalid header: expected newline');\n } else if (++lineLen >= MAX_LINE_LEN) {\n throw new Error('Header line too long');\n }\n\n end = p;\n }\n if (!this._buffer)\n this._buffer = bufferSlice(data, op);\n\n return p - chunkOffset;\n}\n\nfunction parsePacket(chunk, p, len) {\n return this._decipher.decrypt(chunk, p, len);\n}\n\nfunction onPayload(payload) {\n // XXX: move this to the Decipher implementations?\n\n this._onPacket();\n\n if (payload.length === 0) {\n this._debug && this._debug('Inbound: Skipping empty packet payload');\n return;\n }\n\n payload = this._packetRW.read.read(payload);\n\n const type = payload[0];\n if (type === MESSAGE.USERAUTH_SUCCESS\n && !this._server\n && !this._authenticated) {\n this._authenticated = true;\n if (this._kex.negotiated.cs.compress === 'zlib@openssh.com')\n this._packetRW.write = new ZlibPacketWriter(this);\n if (this._kex.negotiated.sc.compress === 'zlib@openssh.com')\n this._packetRW.read = new ZlibPacketReader();\n }\n const handler = MESSAGE_HANDLERS[type];\n if (handler === undefined) {\n this._debug && this._debug(`Inbound: Unsupported message type: ${type}`);\n return;\n }\n\n return handler(this, payload);\n}\n\nfunction getCompatFlags(header) {\n const software = header.versions.software;\n\n let flags = 0;\n\n for (const rule of COMPAT_CHECKS) {\n if (typeof rule[0] === 'string') {\n if (software === rule[0])\n flags |= rule[1];\n } else if (rule[0].test(software)) {\n flags |= rule[1];\n }\n }\n\n return flags;\n}\n\nfunction modesToBytes(modes) {\n const keys = Object.keys(modes);\n const bytes = Buffer.allocUnsafe((5 * keys.length) + 1);\n let b = 0;\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n if (key === 'TTY_OP_END')\n continue;\n\n const opcode = TERMINAL_MODE[key];\n if (opcode === undefined)\n continue;\n\n const val = modes[key];\n if (typeof val === 'number' && isFinite(val)) {\n bytes[b++] = opcode;\n bytes[b++] = val >>> 24;\n bytes[b++] = val >>> 16;\n bytes[b++] = val >>> 8;\n bytes[b++] = val;\n }\n }\n\n bytes[b++] = TERMINAL_MODE.TTY_OP_END;\n\n if (b < bytes.length)\n return bufferSlice(bytes, 0, b);\n\n return bytes;\n}\n\nmodule.exports = Protocol;\n","'use strict';\n\nconst EventEmitter = require('events');\nconst fs = require('fs');\nconst { constants } = fs;\nconst {\n Readable: ReadableStream,\n Writable: WritableStream\n} = require('stream');\nconst { inherits, isDate } = require('util');\n\nconst FastBuffer = Buffer[Symbol.species];\n\nconst {\n bufferCopy,\n bufferSlice,\n makeBufferParser,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst ATTR = {\n SIZE: 0x00000001,\n UIDGID: 0x00000002,\n PERMISSIONS: 0x00000004,\n ACMODTIME: 0x00000008,\n EXTENDED: 0x80000000,\n};\n\n// Large enough to store all possible attributes\nconst ATTRS_BUF = Buffer.alloc(28);\n\nconst STATUS_CODE = {\n OK: 0,\n EOF: 1,\n NO_SUCH_FILE: 2,\n PERMISSION_DENIED: 3,\n FAILURE: 4,\n BAD_MESSAGE: 5,\n NO_CONNECTION: 6,\n CONNECTION_LOST: 7,\n OP_UNSUPPORTED: 8\n};\n\nconst VALID_STATUS_CODES = new Map(\n Object.values(STATUS_CODE).map((n) => [n, 1])\n);\n\nconst STATUS_CODE_STR = {\n [STATUS_CODE.OK]: 'No error',\n [STATUS_CODE.EOF]: 'End of file',\n [STATUS_CODE.NO_SUCH_FILE]: 'No such file or directory',\n [STATUS_CODE.PERMISSION_DENIED]: 'Permission denied',\n [STATUS_CODE.FAILURE]: 'Failure',\n [STATUS_CODE.BAD_MESSAGE]: 'Bad message',\n [STATUS_CODE.NO_CONNECTION]: 'No connection',\n [STATUS_CODE.CONNECTION_LOST]: 'Connection lost',\n [STATUS_CODE.OP_UNSUPPORTED]: 'Operation unsupported',\n};\n\nconst REQUEST = {\n INIT: 1,\n OPEN: 3,\n CLOSE: 4,\n READ: 5,\n WRITE: 6,\n LSTAT: 7,\n FSTAT: 8,\n SETSTAT: 9,\n FSETSTAT: 10,\n OPENDIR: 11,\n READDIR: 12,\n REMOVE: 13,\n MKDIR: 14,\n RMDIR: 15,\n REALPATH: 16,\n STAT: 17,\n RENAME: 18,\n READLINK: 19,\n SYMLINK: 20,\n EXTENDED: 200\n};\n\nconst RESPONSE = {\n VERSION: 2,\n STATUS: 101,\n HANDLE: 102,\n DATA: 103,\n NAME: 104,\n ATTRS: 105,\n EXTENDED: 201\n};\n\nconst OPEN_MODE = {\n READ: 0x00000001,\n WRITE: 0x00000002,\n APPEND: 0x00000004,\n CREAT: 0x00000008,\n TRUNC: 0x00000010,\n EXCL: 0x00000020\n};\n\nconst PKT_RW_OVERHEAD = 2 * 1024;\nconst MAX_REQID = 2 ** 32 - 1;\nconst CLIENT_VERSION_BUFFER = Buffer.from([\n 0, 0, 0, 5 /* length */,\n REQUEST.INIT,\n 0, 0, 0, 3 /* version */\n]);\nconst SERVER_VERSION_BUFFER = Buffer.from([\n 0, 0, 0, 5 /* length */,\n RESPONSE.VERSION,\n 0, 0, 0, 3 /* version */\n]);\n\nconst RE_OPENSSH = /^SSH-2.0-(?:OpenSSH|dropbear)/;\nconst OPENSSH_MAX_PKT_LEN = 256 * 1024;\n\nconst bufferParser = makeBufferParser();\n\nconst fakeStderr = {\n readable: false,\n writable: false,\n push: (data) => {},\n once: () => {},\n on: () => {},\n emit: () => {},\n end: () => {},\n};\n\nfunction noop() {}\n\n// Emulates enough of `Channel` to be able to be used as a drop-in replacement\n// in order to process incoming data with as little overhead as possible\nclass SFTP extends EventEmitter {\n constructor(client, chanInfo, cfg) {\n super();\n\n if (typeof cfg !== 'object' || !cfg)\n cfg = {};\n\n const remoteIdentRaw = client._protocol._remoteIdentRaw;\n\n this.server = !!cfg.server;\n this._debug = (typeof cfg.debug === 'function' ? cfg.debug : undefined);\n this._isOpenSSH = (remoteIdentRaw && RE_OPENSSH.test(remoteIdentRaw));\n\n this._version = -1;\n this._extensions = {};\n this._biOpt = cfg.biOpt;\n this._pktLenBytes = 0;\n this._pktLen = 0;\n this._pktPos = 0;\n this._pktType = 0;\n this._pktData = undefined;\n this._writeReqid = -1;\n this._requests = {};\n this._maxInPktLen = OPENSSH_MAX_PKT_LEN;\n this._maxOutPktLen = 34000;\n this._maxReadLen =\n (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;\n this._maxWriteLen =\n (this._isOpenSSH ? OPENSSH_MAX_PKT_LEN : 34000) - PKT_RW_OVERHEAD;\n\n this.maxOpenHandles = undefined;\n\n // Channel compatibility\n this._client = client;\n this._protocol = client._protocol;\n this._callbacks = [];\n this._hasX11 = false;\n this._exit = {\n code: undefined,\n signal: undefined,\n dump: undefined,\n desc: undefined,\n };\n this._waitWindow = false; // SSH-level backpressure\n this._chunkcb = undefined;\n this._buffer = [];\n this.type = chanInfo.type;\n this.subtype = undefined;\n this.incoming = chanInfo.incoming;\n this.outgoing = chanInfo.outgoing;\n this.stderr = fakeStderr;\n this.readable = true;\n }\n\n // This handles incoming data to parse\n push(data) {\n if (data === null) {\n cleanupRequests(this);\n if (!this.readable)\n return;\n // No more incoming data from the remote side\n this.readable = false;\n this.emit('end');\n return;\n }\n /*\n uint32 length\n byte type\n byte[length - 1] data payload\n */\n let p = 0;\n\n while (p < data.length) {\n if (this._pktLenBytes < 4) {\n let nb = Math.min(4 - this._pktLenBytes, data.length - p);\n this._pktLenBytes += nb;\n\n while (nb--)\n this._pktLen = (this._pktLen << 8) + data[p++];\n\n if (this._pktLenBytes < 4)\n return;\n if (this._pktLen === 0)\n return doFatalSFTPError(this, 'Invalid packet length');\n if (this._pktLen > this._maxInPktLen) {\n const max = this._maxInPktLen;\n return doFatalSFTPError(\n this,\n `Packet length ${this._pktLen} exceeds max length of ${max}`\n );\n }\n if (p >= data.length)\n return;\n }\n if (this._pktPos < this._pktLen) {\n const nb = Math.min(this._pktLen - this._pktPos, data.length - p);\n if (p !== 0 || nb !== data.length) {\n if (nb === this._pktLen) {\n this._pkt = new FastBuffer(data.buffer, data.byteOffset + p, nb);\n } else {\n if (!this._pkt)\n this._pkt = Buffer.allocUnsafe(this._pktLen);\n this._pkt.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._pktPos\n );\n }\n } else if (nb === this._pktLen) {\n this._pkt = data;\n } else {\n if (!this._pkt)\n this._pkt = Buffer.allocUnsafe(this._pktLen);\n this._pkt.set(data, this._pktPos);\n }\n p += nb;\n this._pktPos += nb;\n if (this._pktPos < this._pktLen)\n return;\n }\n\n const type = this._pkt[0];\n const payload = this._pkt;\n\n // Prepare for next packet\n this._pktLen = 0;\n this._pktLenBytes = 0;\n this._pkt = undefined;\n this._pktPos = 0;\n\n const handler = (this.server\n ? SERVER_HANDLERS[type]\n : CLIENT_HANDLERS[type]);\n if (!handler)\n return doFatalSFTPError(this, `Unknown packet type ${type}`);\n\n if (this._version === -1) {\n if (this.server) {\n if (type !== REQUEST.INIT)\n return doFatalSFTPError(this, `Expected INIT packet, got ${type}`);\n } else if (type !== RESPONSE.VERSION) {\n return doFatalSFTPError(this, `Expected VERSION packet, got ${type}`);\n }\n }\n\n if (handler(this, payload) === false)\n return;\n }\n }\n\n end() {\n this.destroy();\n }\n destroy() {\n if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {\n this.outgoing.state = 'closing';\n this._protocol.channelClose(this.outgoing.id);\n }\n }\n _init() {\n this._init = noop;\n if (!this.server)\n sendOrBuffer(this, CLIENT_VERSION_BUFFER);\n }\n\n // ===========================================================================\n // Client-specific ===========================================================\n // ===========================================================================\n createReadStream(path, options) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n return new ReadStream(this, path, options);\n }\n createWriteStream(path, options) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n return new WriteStream(this, path, options);\n }\n open(path, flags_, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (typeof attrs === 'function') {\n cb = attrs;\n attrs = undefined;\n }\n\n const flags = (typeof flags_ === 'number' ? flags_ : stringToFlags(flags_));\n if (flags === null)\n throw new Error(`Unknown flags string: ${flags_}`);\n\n let attrsFlags = 0;\n let attrsLen = 0;\n if (typeof attrs === 'string' || typeof attrs === 'number')\n attrs = { mode: attrs };\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n attrsFlags = attrs.flags;\n attrsLen = attrs.nb;\n }\n\n /*\n uint32 id\n string filename\n uint32 pflags\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.OPEN;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n writeUInt32BE(buf, attrsFlags, p += 4);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPEN`\n );\n }\n close(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.CLOSE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} CLOSE`\n );\n }\n read(handle, buf, off, len, position, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n if (!Buffer.isBuffer(buf))\n throw new Error('buffer is not a Buffer');\n if (off >= buf.length)\n throw new Error('offset is out of bounds');\n if (off + len > buf.length)\n throw new Error('length extends beyond buffer');\n if (position === null)\n throw new Error('null position currently unsupported');\n\n read_(this, handle, buf, off, len, position, cb);\n }\n readData(handle, buf, off, len, position, cb) {\n // Backwards compatibility\n this.read(handle, buf, off, len, position, cb);\n }\n write(handle, buf, off, len, position, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n if (!Buffer.isBuffer(buf))\n throw new Error('buffer is not a Buffer');\n if (off > buf.length)\n throw new Error('offset is out of bounds');\n if (off + len > buf.length)\n throw new Error('length extends beyond buffer');\n if (position === null)\n throw new Error('null position currently unsupported');\n\n if (!len) {\n cb && process.nextTick(cb, undefined, 0);\n return;\n }\n\n const maxDataLen = this._maxWriteLen;\n const overflow = Math.max(len - maxDataLen, 0);\n const origPosition = position;\n\n if (overflow)\n len = maxDataLen;\n\n /*\n uint32 id\n string handle\n uint64 offset\n string data\n */\n const handleLen = handle.length;\n let p = 9;\n const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4 + len);\n\n writeUInt32BE(out, out.length - 4, 0);\n out[4] = REQUEST.WRITE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(out, reqid, 5);\n\n writeUInt32BE(out, handleLen, p);\n out.set(handle, p += 4);\n p += handleLen;\n for (let i = 7; i >= 0; --i) {\n out[p + i] = position & 0xFF;\n position /= 256;\n }\n writeUInt32BE(out, len, p += 8);\n bufferCopy(buf, out, off, off + len, p += 4);\n\n this._requests[reqid] = {\n cb: (err) => {\n if (err) {\n if (typeof cb === 'function')\n cb(err);\n } else if (overflow) {\n this.write(handle,\n buf,\n off + len,\n overflow,\n origPosition + len,\n cb);\n } else if (typeof cb === 'function') {\n cb(undefined, off + len);\n }\n }\n };\n\n const isSent = sendOrBuffer(this, out);\n if (this._debug) {\n const how = (isSent ? 'Sent' : 'Buffered');\n this._debug(`SFTP: Outbound: ${how} WRITE (id:${reqid})`);\n }\n }\n writeData(handle, buf, off, len, position, cb) {\n // Backwards compatibility\n this.write(handle, buf, off, len, position, cb);\n }\n fastGet(remotePath, localPath, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n fastXfer(this, fs, remotePath, localPath, opts, cb);\n }\n fastPut(localPath, remotePath, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n fastXfer(fs, this, localPath, remotePath, opts, cb);\n }\n readFile(path, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, flag: 'r' };\n else if (!options)\n options = { encoding: null, flag: 'r' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n const encoding = options.encoding;\n if (encoding && !Buffer.isEncoding(encoding))\n throw new Error(`Unknown encoding: ${encoding}`);\n\n // First stat the file, so we know the size.\n let size;\n let buffer; // Single buffer with file data\n let buffers; // List for when size is unknown\n let pos = 0;\n let handle;\n\n // SFTPv3 does not support using -1 for read position, so we have to track\n // read position manually\n let bytesRead = 0;\n\n const flag = options.flag || 'r';\n\n const read = () => {\n if (size === 0) {\n buffer = Buffer.allocUnsafe(8192);\n this.read(handle, buffer, 0, 8192, bytesRead, afterRead);\n } else {\n this.read(handle, buffer, pos, size - pos, bytesRead, afterRead);\n }\n };\n\n const afterRead = (er, nbytes) => {\n let eof;\n if (er) {\n eof = (er.code === STATUS_CODE.EOF);\n if (!eof) {\n return this.close(handle, () => {\n return callback && callback(er);\n });\n }\n } else {\n eof = false;\n }\n\n if (eof || (size === 0 && nbytes === 0))\n return close();\n\n bytesRead += nbytes;\n pos += nbytes;\n if (size !== 0) {\n if (pos === size)\n close();\n else\n read();\n } else {\n // Unknown size, just read until we don't get bytes.\n buffers.push(bufferSlice(buffer, 0, nbytes));\n read();\n }\n };\n afterRead._wantEOFError = true;\n\n const close = () => {\n this.close(handle, (er) => {\n if (size === 0) {\n // Collect the data into the buffers list.\n buffer = Buffer.concat(buffers, pos);\n } else if (pos < size) {\n buffer = bufferSlice(buffer, 0, pos);\n }\n\n if (encoding)\n buffer = buffer.toString(encoding);\n return callback && callback(er, buffer);\n });\n };\n\n this.open(path, flag, 0o666, (er, handle_) => {\n if (er)\n return callback && callback(er);\n handle = handle_;\n\n const tryStat = (er, st) => {\n if (er) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.stat(path, (er_, st_) => {\n if (er_) {\n return this.close(handle, () => {\n callback && callback(er);\n });\n }\n tryStat(null, st_);\n });\n return;\n }\n\n size = st.size || 0;\n if (size === 0) {\n // The kernel lies about many files.\n // Go ahead and try to read some bytes.\n buffers = [];\n return read();\n }\n\n buffer = Buffer.allocUnsafe(size);\n read();\n };\n this.fstat(handle, tryStat);\n });\n }\n writeFile(path, data, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, mode: 0o666, flag: 'w' };\n else if (!options)\n options = { encoding: 'utf8', mode: 0o666, flag: 'w' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n if (options.encoding && !Buffer.isEncoding(options.encoding))\n throw new Error(`Unknown encoding: ${options.encoding}`);\n\n const flag = options.flag || 'w';\n this.open(path, flag, options.mode, (openErr, handle) => {\n if (openErr) {\n callback && callback(openErr);\n } else {\n const buffer = (Buffer.isBuffer(data)\n ? data\n : Buffer.from('' + data, options.encoding || 'utf8'));\n const position = (/a/.test(flag) ? null : 0);\n\n // SFTPv3 does not support the notion of 'current position'\n // (null position), so we just attempt to append to the end of the file\n // instead\n if (position === null) {\n const tryStat = (er, st) => {\n if (er) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.stat(path, (er_, st_) => {\n if (er_) {\n return this.close(handle, () => {\n callback && callback(er);\n });\n }\n tryStat(null, st_);\n });\n return;\n }\n writeAll(this, handle, buffer, 0, buffer.length, st.size, callback);\n };\n this.fstat(handle, tryStat);\n return;\n }\n writeAll(this, handle, buffer, 0, buffer.length, position, callback);\n }\n });\n }\n appendFile(path, data, options, callback_) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let callback;\n if (typeof callback_ === 'function') {\n callback = callback_;\n } else if (typeof options === 'function') {\n callback = options;\n options = undefined;\n }\n\n if (typeof options === 'string')\n options = { encoding: options, mode: 0o666, flag: 'a' };\n else if (!options)\n options = { encoding: 'utf8', mode: 0o666, flag: 'a' };\n else if (typeof options !== 'object')\n throw new TypeError('Bad arguments');\n\n if (!options.flag)\n options = Object.assign({ flag: 'a' }, options);\n this.writeFile(path, data, options, callback);\n }\n exists(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n this.stat(path, (err) => {\n cb && cb(err ? false : true);\n });\n }\n unlink(filename, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string filename\n */\n const fnameLen = Buffer.byteLength(filename);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + fnameLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.REMOVE;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, fnameLen, p);\n buf.utf8Write(filename, p += 4, fnameLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REMOVE`\n );\n }\n rename(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.RENAME;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, oldLen, p);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RENAME`\n );\n }\n mkdir(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'function') {\n cb = attrs;\n attrs = undefined;\n }\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n }\n\n /*\n uint32 id\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.MKDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} MKDIR`\n );\n }\n rmdir(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.RMDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} RMDIR`\n );\n }\n readdir(where, opts, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n if (typeof opts !== 'object' || opts === null)\n opts = {};\n\n const doFilter = (opts && opts.full ? false : true);\n\n if (!Buffer.isBuffer(where) && typeof where !== 'string')\n throw new Error('missing directory handle or path');\n\n if (typeof where === 'string') {\n const entries = [];\n let e = 0;\n\n const reread = (err, handle) => {\n if (err)\n return cb(err);\n\n this.readdir(handle, opts, (err, list) => {\n const eof = (err && err.code === STATUS_CODE.EOF);\n\n if (err && !eof)\n return this.close(handle, () => cb(err));\n\n if (eof) {\n return this.close(handle, (err) => {\n if (err)\n return cb(err);\n cb(undefined, entries);\n });\n }\n\n for (let i = 0; i < list.length; ++i, ++e)\n entries[e] = list[i];\n\n reread(undefined, handle);\n });\n };\n return this.opendir(where, reread);\n }\n\n /*\n uint32 id\n string handle\n */\n const handleLen = where.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.READDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(where, p += 4);\n\n this._requests[reqid] = {\n cb: (doFilter\n ? (err, list) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n\n for (let i = list.length - 1; i >= 0; --i) {\n if (list[i].filename === '.' || list[i].filename === '..')\n list.splice(i, 1);\n }\n\n cb(undefined, list);\n }\n : cb)\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READDIR`\n );\n }\n fstat(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.FSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSTAT`\n );\n }\n stat(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.STAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STAT`\n );\n }\n lstat(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.LSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} LSTAT`\n );\n }\n opendir(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.OPENDIR;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} OPENDIR`\n );\n }\n setstat(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.SETSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SETSTAT`\n );\n }\n fsetstat(handle, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string handle\n ATTRS attrs\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.FSETSTAT;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n buf.set(handle, p += 4);\n writeUInt32BE(buf, flags, p += handleLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSETSTAT`\n );\n }\n futimes(handle, atime, mtime, cb) {\n return this.fsetstat(handle, {\n atime: toUnixTimestamp(atime),\n mtime: toUnixTimestamp(mtime)\n }, cb);\n }\n utimes(path, atime, mtime, cb) {\n return this.setstat(path, {\n atime: toUnixTimestamp(atime),\n mtime: toUnixTimestamp(mtime)\n }, cb);\n }\n fchown(handle, uid, gid, cb) {\n return this.fsetstat(handle, {\n uid: uid,\n gid: gid\n }, cb);\n }\n chown(path, uid, gid, cb) {\n return this.setstat(path, {\n uid: uid,\n gid: gid\n }, cb);\n }\n fchmod(handle, mode, cb) {\n return this.fsetstat(handle, {\n mode: mode\n }, cb);\n }\n chmod(path, mode, cb) {\n return this.setstat(path, {\n mode: mode\n }, cb);\n }\n readlink(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.READLINK;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = {\n cb: (err, names) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n if (!names || !names.length)\n return cb(new Error('Response missing link info'));\n cb(undefined, names[0].filename);\n }\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READLINK`\n );\n }\n symlink(targetPath, linkPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string linkpath\n string targetpath\n */\n const linkLen = Buffer.byteLength(linkPath);\n const targetLen = Buffer.byteLength(targetPath);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + linkLen + 4 + targetLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.SYMLINK;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n if (this._isOpenSSH) {\n // OpenSSH has linkpath and targetpath positions switched\n writeUInt32BE(buf, targetLen, p);\n buf.utf8Write(targetPath, p += 4, targetLen);\n writeUInt32BE(buf, linkLen, p += targetLen);\n buf.utf8Write(linkPath, p += 4, linkLen);\n } else {\n writeUInt32BE(buf, linkLen, p);\n buf.utf8Write(linkPath, p += 4, linkLen);\n writeUInt32BE(buf, targetLen, p += linkLen);\n buf.utf8Write(targetPath, p += 4, targetLen);\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SYMLINK`\n );\n }\n realpath(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n /*\n uint32 id\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.REALPATH;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, pathLen, p);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = {\n cb: (err, names) => {\n if (typeof cb !== 'function')\n return;\n if (err)\n return cb(err);\n if (!names || !names.length)\n return cb(new Error('Response missing path info'));\n cb(undefined, names[0].filename);\n }\n };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} REALPATH`\n );\n }\n // extended requests\n ext_openssh_rename(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['posix-rename@openssh.com'];\n if (!ext || ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"posix-rename@openssh.com\"\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 24 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 24, p);\n buf.utf8Write('posix-rename@openssh.com', p += 4, 24);\n writeUInt32BE(buf, oldLen, p += 24);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} posix-rename@openssh.com`);\n }\n }\n ext_openssh_statvfs(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['statvfs@openssh.com'];\n if (!ext || ext !== '2')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"statvfs@openssh.com\"\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 19 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 19, p);\n buf.utf8Write('statvfs@openssh.com', p += 4, 19);\n writeUInt32BE(buf, pathLen, p += 19);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { extended: 'statvfs@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} statvfs@openssh.com`);\n }\n }\n ext_openssh_fstatvfs(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['fstatvfs@openssh.com'];\n if (!ext || ext !== '2')\n throw new Error('Server does not support this extended request');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string \"fstatvfs@openssh.com\"\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('fstatvfs@openssh.com', p += 4, 20);\n writeUInt32BE(buf, handleLen, p += 20);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { extended: 'fstatvfs@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} fstatvfs@openssh.com`);\n }\n }\n ext_openssh_hardlink(oldPath, newPath, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['hardlink@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"hardlink@openssh.com\"\n string oldpath\n string newpath\n */\n const oldLen = Buffer.byteLength(oldPath);\n const newLen = Buffer.byteLength(newPath);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + oldLen + 4 + newLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('hardlink@openssh.com', p += 4, 20);\n writeUInt32BE(buf, oldLen, p += 20);\n buf.utf8Write(oldPath, p += 4, oldLen);\n writeUInt32BE(buf, newLen, p += oldLen);\n buf.utf8Write(newPath, p += 4, newLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${which} hardlink@openssh.com`);\n }\n }\n ext_openssh_fsync(handle, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['fsync@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n /*\n uint32 id\n string \"fsync@openssh.com\"\n string handle\n */\n const handleLen = handle.length;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 17 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 17, p);\n buf.utf8Write('fsync@openssh.com', p += 4, 17);\n writeUInt32BE(buf, handleLen, p += 17);\n buf.set(handle, p += 4);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} fsync@openssh.com`\n );\n }\n ext_openssh_lsetstat(path, attrs, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['lsetstat@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n let flags = 0;\n let attrsLen = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n attrs = attrsToBytes(attrs);\n flags = attrs.flags;\n attrsLen = attrs.nb;\n } else if (typeof attrs === 'function') {\n cb = attrs;\n }\n\n /*\n uint32 id\n string \"lsetstat@openssh.com\"\n string path\n ATTRS attrs\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf =\n Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + pathLen + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 20, p);\n buf.utf8Write('lsetstat@openssh.com', p += 4, 20);\n\n writeUInt32BE(buf, pathLen, p += 20);\n buf.utf8Write(path, p += 4, pathLen);\n\n writeUInt32BE(buf, flags, p += pathLen);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const status = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${status} lsetstat@openssh.com`);\n }\n }\n ext_openssh_expandPath(path, cb) {\n if (this.server)\n throw new Error('Client-only method called in server mode');\n\n const ext = this._extensions['expand-path@openssh.com'];\n if (ext !== '1')\n throw new Error('Server does not support this extended request');\n\n /*\n uint32 id\n string \"expand-path@openssh.com\"\n string path\n */\n const pathLen = Buffer.byteLength(path);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 23 + 4 + pathLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 23, p);\n buf.utf8Write('expand-path@openssh.com', p += 4, 23);\n\n writeUInt32BE(buf, pathLen, p += 20);\n buf.utf8Write(path, p += 4, pathLen);\n\n this._requests[reqid] = { cb };\n\n const isBuffered = sendOrBuffer(this, buf);\n if (this._debug) {\n const status = (isBuffered ? 'Buffered' : 'Sending');\n this._debug(`SFTP: Outbound: ${status} expand-path@openssh.com`);\n }\n }\n // ===========================================================================\n // Server-specific ===========================================================\n // ===========================================================================\n handle(reqid, handle) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!Buffer.isBuffer(handle))\n throw new Error('handle is not a Buffer');\n\n const handleLen = handle.length;\n\n if (handleLen > 256)\n throw new Error('handle too large (> 256 bytes)');\n\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.HANDLE;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, handleLen, p);\n if (handleLen)\n buf.set(handle, p += 4);\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} HANDLE`\n );\n }\n status(reqid, code, message) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!VALID_STATUS_CODES.has(code))\n throw new Error(`Bad status code: ${code}`);\n\n message || (message = '');\n\n const msgLen = Buffer.byteLength(message);\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 4 + msgLen + 4);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.STATUS;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, code, p);\n\n writeUInt32BE(buf, msgLen, p += 4);\n p += 4;\n if (msgLen) {\n buf.utf8Write(message, p, msgLen);\n p += msgLen;\n }\n\n writeUInt32BE(buf, 0, p); // Empty language tag\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STATUS`\n );\n }\n data(reqid, data, encoding) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n const isBuffer = Buffer.isBuffer(data);\n\n if (!isBuffer && typeof data !== 'string')\n throw new Error('data is not a Buffer or string');\n\n let isUTF8;\n if (!isBuffer && !encoding) {\n encoding = undefined;\n isUTF8 = true;\n }\n\n const dataLen = (\n isBuffer\n ? data.length\n : Buffer.byteLength(data, encoding)\n );\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + dataLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.DATA;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, dataLen, p);\n if (dataLen) {\n if (isBuffer)\n buf.set(data, p += 4);\n else if (isUTF8)\n buf.utf8Write(data, p += 4, dataLen);\n else\n buf.write(data, p += 4, dataLen, encoding);\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} DATA`\n );\n }\n name(reqid, names) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (!Array.isArray(names)) {\n if (typeof names !== 'object' || names === null)\n throw new Error('names is not an object or array');\n names = [ names ];\n }\n\n const count = names.length;\n let namesLen = 0;\n let nameAttrs;\n const attrs = [];\n\n for (let i = 0; i < count; ++i) {\n const name = names[i];\n const filename = (\n !name || !name.filename || typeof name.filename !== 'string'\n ? ''\n : name.filename\n );\n namesLen += 4 + Buffer.byteLength(filename);\n const longname = (\n !name || !name.longname || typeof name.longname !== 'string'\n ? ''\n : name.longname\n );\n namesLen += 4 + Buffer.byteLength(longname);\n\n if (typeof name.attrs === 'object' && name.attrs !== null) {\n nameAttrs = attrsToBytes(name.attrs);\n namesLen += 4 + nameAttrs.nb;\n\n if (nameAttrs.nb) {\n let bytes;\n\n if (nameAttrs.nb === ATTRS_BUF.length) {\n bytes = new Uint8Array(ATTRS_BUF);\n } else {\n bytes = new Uint8Array(nameAttrs.nb);\n bufferCopy(ATTRS_BUF, bytes, 0, nameAttrs.nb, 0);\n }\n\n nameAttrs.bytes = bytes;\n }\n\n attrs.push(nameAttrs);\n } else {\n namesLen += 4;\n attrs.push(null);\n }\n }\n\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + namesLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.NAME;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, count, p);\n\n p += 4;\n\n for (let i = 0; i < count; ++i) {\n const name = names[i];\n\n {\n const filename = (\n !name || !name.filename || typeof name.filename !== 'string'\n ? ''\n : name.filename\n );\n const len = Buffer.byteLength(filename);\n writeUInt32BE(buf, len, p);\n p += 4;\n if (len) {\n buf.utf8Write(filename, p, len);\n p += len;\n }\n }\n\n {\n const longname = (\n !name || !name.longname || typeof name.longname !== 'string'\n ? ''\n : name.longname\n );\n const len = Buffer.byteLength(longname);\n writeUInt32BE(buf, len, p);\n p += 4;\n if (len) {\n buf.utf8Write(longname, p, len);\n p += len;\n }\n }\n\n const attr = attrs[i];\n if (attr) {\n writeUInt32BE(buf, attr.flags, p);\n p += 4;\n if (attr.flags && attr.bytes) {\n buf.set(attr.bytes, p);\n p += attr.nb;\n }\n } else {\n writeUInt32BE(buf, 0, p);\n p += 4;\n }\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} NAME`\n );\n }\n attrs(reqid, attrs) {\n if (!this.server)\n throw new Error('Server-only method called in client mode');\n\n if (typeof attrs !== 'object' || attrs === null)\n throw new Error('attrs is not an object');\n\n attrs = attrsToBytes(attrs);\n const flags = attrs.flags;\n const attrsLen = attrs.nb;\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + attrsLen);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = RESPONSE.ATTRS;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, flags, p);\n if (attrsLen) {\n p += 4;\n\n if (attrsLen === ATTRS_BUF.length)\n buf.set(ATTRS_BUF, p);\n else\n bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p);\n\n p += attrsLen;\n }\n\n const isBuffered = sendOrBuffer(this, buf);\n this._debug && this._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} ATTRS`\n );\n }\n}\n\nfunction tryCreateBuffer(size) {\n try {\n return Buffer.allocUnsafe(size);\n } catch (ex) {\n return ex;\n }\n}\n\nfunction read_(self, handle, buf, off, len, position, cb, req_) {\n const maxDataLen = self._maxReadLen;\n const overflow = Math.max(len - maxDataLen, 0);\n\n if (overflow)\n len = maxDataLen;\n\n /*\n uint32 id\n string handle\n uint64 offset\n uint32 len\n */\n const handleLen = handle.length;\n let p = 9;\n let pos = position;\n const out = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 8 + 4);\n\n writeUInt32BE(out, out.length - 4, 0);\n out[4] = REQUEST.READ;\n const reqid = self._writeReqid = (self._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(out, reqid, 5);\n\n writeUInt32BE(out, handleLen, p);\n out.set(handle, p += 4);\n p += handleLen;\n for (let i = 7; i >= 0; --i) {\n out[p + i] = pos & 0xFF;\n pos /= 256;\n }\n writeUInt32BE(out, len, p += 8);\n\n if (typeof cb !== 'function')\n cb = noop;\n\n const req = (req_ || {\n nb: 0,\n position,\n off,\n origOff: off,\n len: undefined,\n overflow: undefined,\n cb: (err, data, nb) => {\n const len = req.len;\n const overflow = req.overflow;\n\n if (err) {\n if (cb._wantEOFError || err.code !== STATUS_CODE.EOF)\n return cb(err);\n } else if (nb > len) {\n return cb(new Error('Received more data than requested'));\n } else if (nb === len && overflow) {\n req.nb += nb;\n req.position += nb;\n req.off += nb;\n read_(self, handle, buf, req.off, overflow, req.position, cb, req);\n return;\n }\n\n if (req.origOff === 0 && buf.length === req.nb)\n data = buf;\n else\n data = bufferSlice(buf, req.origOff, req.origOff + req.nb);\n cb(undefined, req.nb + (nb || 0), data, req.position);\n },\n buffer: undefined,\n });\n\n req.len = len;\n req.overflow = overflow;\n\n // TODO: avoid creating multiple buffer slices when we need to re-call read_()\n // because of overflow\n req.buffer = bufferSlice(buf, off, off + len);\n\n self._requests[reqid] = req;\n\n const isBuffered = sendOrBuffer(self, out);\n self._debug && self._debug(\n `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} READ`\n );\n}\n\nfunction fastXfer(src, dst, srcPath, dstPath, opts, cb) {\n let concurrency = 64;\n let chunkSize = 32768;\n let onstep;\n let mode;\n let fileSize;\n\n if (typeof opts === 'function') {\n cb = opts;\n } else if (typeof opts === 'object' && opts !== null) {\n if (typeof opts.concurrency === 'number'\n && opts.concurrency > 0\n && !isNaN(opts.concurrency)) {\n concurrency = opts.concurrency;\n }\n if (typeof opts.chunkSize === 'number'\n && opts.chunkSize > 0\n && !isNaN(opts.chunkSize)) {\n chunkSize = opts.chunkSize;\n }\n if (typeof opts.fileSize === 'number'\n && opts.fileSize > 0\n && !isNaN(opts.fileSize)) {\n fileSize = opts.fileSize;\n }\n if (typeof opts.step === 'function')\n onstep = opts.step;\n\n if (typeof opts.mode === 'string' || typeof opts.mode === 'number')\n mode = modeNum(opts.mode);\n }\n\n // Internal state variables\n let fsize;\n let pdst = 0;\n let total = 0;\n let hadError = false;\n let srcHandle;\n let dstHandle;\n let readbuf;\n let bufsize = chunkSize * concurrency;\n\n function onerror(err) {\n if (hadError)\n return;\n\n hadError = true;\n\n let left = 0;\n let cbfinal;\n\n if (srcHandle || dstHandle) {\n cbfinal = () => {\n if (--left === 0)\n cb(err);\n };\n if (srcHandle && (src === fs || src.outgoing.state === 'open'))\n ++left;\n if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))\n ++left;\n if (srcHandle && (src === fs || src.outgoing.state === 'open'))\n src.close(srcHandle, cbfinal);\n if (dstHandle && (dst === fs || dst.outgoing.state === 'open'))\n dst.close(dstHandle, cbfinal);\n } else {\n cb(err);\n }\n }\n\n src.open(srcPath, 'r', (err, sourceHandle) => {\n if (err)\n return onerror(err);\n\n srcHandle = sourceHandle;\n\n if (fileSize === undefined)\n src.fstat(srcHandle, tryStat);\n else\n tryStat(null, { size: fileSize });\n\n function tryStat(err, attrs) {\n if (err) {\n if (src !== fs) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n src.stat(srcPath, (err_, attrs_) => {\n if (err_)\n return onerror(err);\n tryStat(null, attrs_);\n });\n return;\n }\n return onerror(err);\n }\n fsize = attrs.size;\n\n dst.open(dstPath, 'w', (err, destHandle) => {\n if (err)\n return onerror(err);\n\n dstHandle = destHandle;\n\n if (fsize <= 0)\n return onerror();\n\n // Use less memory where possible\n while (bufsize > fsize) {\n if (concurrency === 1) {\n bufsize = fsize;\n break;\n }\n bufsize -= chunkSize;\n --concurrency;\n }\n\n readbuf = tryCreateBuffer(bufsize);\n if (readbuf instanceof Error)\n return onerror(readbuf);\n\n if (mode !== undefined) {\n dst.fchmod(dstHandle, mode, function tryAgain(err) {\n if (err) {\n // Try chmod() for sftp servers that may not support fchmod()\n // for whatever reason\n dst.chmod(dstPath, mode, (err_) => tryAgain());\n return;\n }\n startReads();\n });\n } else {\n startReads();\n }\n\n function onread(err, nb, data, dstpos, datapos, origChunkLen) {\n if (err)\n return onerror(err);\n\n datapos = datapos || 0;\n\n dst.write(dstHandle, readbuf, datapos, nb, dstpos, writeCb);\n\n function writeCb(err) {\n if (err)\n return onerror(err);\n\n total += nb;\n onstep && onstep(total, nb, fsize);\n\n if (nb < origChunkLen)\n return singleRead(datapos, dstpos + nb, origChunkLen - nb);\n\n if (total === fsize) {\n dst.close(dstHandle, (err) => {\n dstHandle = undefined;\n if (err)\n return onerror(err);\n src.close(srcHandle, (err) => {\n srcHandle = undefined;\n if (err)\n return onerror(err);\n cb();\n });\n });\n return;\n }\n\n if (pdst >= fsize)\n return;\n\n const chunk =\n (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);\n singleRead(datapos, pdst, chunk);\n pdst += chunk;\n }\n }\n\n function makeCb(psrc, pdst, chunk) {\n return (err, nb, data) => {\n onread(err, nb, data, pdst, psrc, chunk);\n };\n }\n\n function singleRead(psrc, pdst, chunk) {\n src.read(srcHandle,\n readbuf,\n psrc,\n chunk,\n pdst,\n makeCb(psrc, pdst, chunk));\n }\n\n function startReads() {\n let reads = 0;\n let psrc = 0;\n while (pdst < fsize && reads < concurrency) {\n const chunk =\n (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);\n singleRead(psrc, pdst, chunk);\n psrc += chunk;\n pdst += chunk;\n ++reads;\n }\n }\n });\n }\n });\n}\n\nfunction writeAll(sftp, handle, buffer, offset, length, position, callback_) {\n const callback = (typeof callback_ === 'function' ? callback_ : undefined);\n\n sftp.write(handle,\n buffer,\n offset,\n length,\n position,\n (writeErr, written) => {\n if (writeErr) {\n return sftp.close(handle, () => {\n callback && callback(writeErr);\n });\n }\n if (written === length) {\n sftp.close(handle, callback);\n } else {\n offset += written;\n length -= written;\n position += written;\n writeAll(sftp, handle, buffer, offset, length, position, callback);\n }\n });\n}\n\nclass Stats {\n constructor(initial) {\n this.mode = (initial && initial.mode);\n this.uid = (initial && initial.uid);\n this.gid = (initial && initial.gid);\n this.size = (initial && initial.size);\n this.atime = (initial && initial.atime);\n this.mtime = (initial && initial.mtime);\n this.extended = (initial && initial.extended);\n }\n isDirectory() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFDIR);\n }\n isFile() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFREG);\n }\n isBlockDevice() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFBLK);\n }\n isCharacterDevice() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFCHR);\n }\n isSymbolicLink() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFLNK);\n }\n isFIFO() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFIFO);\n }\n isSocket() {\n return ((this.mode & constants.S_IFMT) === constants.S_IFSOCK);\n }\n}\n\nfunction attrsToBytes(attrs) {\n let flags = 0;\n let nb = 0;\n\n if (typeof attrs === 'object' && attrs !== null) {\n if (typeof attrs.size === 'number') {\n flags |= ATTR.SIZE;\n const val = attrs.size;\n // Big Endian\n ATTRS_BUF[nb++] = val / 72057594037927940; // 2**56\n ATTRS_BUF[nb++] = val / 281474976710656; // 2**48\n ATTRS_BUF[nb++] = val / 1099511627776; // 2**40\n ATTRS_BUF[nb++] = val / 4294967296; // 2**32\n ATTRS_BUF[nb++] = val / 16777216; // 2**24\n ATTRS_BUF[nb++] = val / 65536; // 2**16\n ATTRS_BUF[nb++] = val / 256; // 2**8\n ATTRS_BUF[nb++] = val;\n }\n if (typeof attrs.uid === 'number' && typeof attrs.gid === 'number') {\n flags |= ATTR.UIDGID;\n const uid = attrs.uid;\n const gid = attrs.gid;\n // Big Endian\n ATTRS_BUF[nb++] = uid >>> 24;\n ATTRS_BUF[nb++] = uid >>> 16;\n ATTRS_BUF[nb++] = uid >>> 8;\n ATTRS_BUF[nb++] = uid;\n ATTRS_BUF[nb++] = gid >>> 24;\n ATTRS_BUF[nb++] = gid >>> 16;\n ATTRS_BUF[nb++] = gid >>> 8;\n ATTRS_BUF[nb++] = gid;\n }\n if (typeof attrs.mode === 'number' || typeof attrs.mode === 'string') {\n const mode = modeNum(attrs.mode);\n flags |= ATTR.PERMISSIONS;\n // Big Endian\n ATTRS_BUF[nb++] = mode >>> 24;\n ATTRS_BUF[nb++] = mode >>> 16;\n ATTRS_BUF[nb++] = mode >>> 8;\n ATTRS_BUF[nb++] = mode;\n }\n if ((typeof attrs.atime === 'number' || isDate(attrs.atime))\n && (typeof attrs.mtime === 'number' || isDate(attrs.mtime))) {\n const atime = toUnixTimestamp(attrs.atime);\n const mtime = toUnixTimestamp(attrs.mtime);\n\n flags |= ATTR.ACMODTIME;\n // Big Endian\n ATTRS_BUF[nb++] = atime >>> 24;\n ATTRS_BUF[nb++] = atime >>> 16;\n ATTRS_BUF[nb++] = atime >>> 8;\n ATTRS_BUF[nb++] = atime;\n ATTRS_BUF[nb++] = mtime >>> 24;\n ATTRS_BUF[nb++] = mtime >>> 16;\n ATTRS_BUF[nb++] = mtime >>> 8;\n ATTRS_BUF[nb++] = mtime;\n }\n // TODO: extended attributes\n }\n\n return { flags, nb };\n}\n\nfunction toUnixTimestamp(time) {\n // eslint-disable-next-line no-self-compare\n if (typeof time === 'number' && time === time) // Valid, non-NaN number\n return time;\n if (isDate(time))\n return parseInt(time.getTime() / 1000, 10);\n throw new Error(`Cannot parse time: ${time}`);\n}\n\nfunction modeNum(mode) {\n // eslint-disable-next-line no-self-compare\n if (typeof mode === 'number' && mode === mode) // Valid, non-NaN number\n return mode;\n if (typeof mode === 'string')\n return modeNum(parseInt(mode, 8));\n throw new Error(`Cannot parse mode: ${mode}`);\n}\n\nconst stringFlagMap = {\n 'r': OPEN_MODE.READ,\n 'r+': OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'w': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE,\n 'wx': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'xw': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'w+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'wx+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'xw+': OPEN_MODE.TRUNC | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'a': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE,\n 'ax': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'xa': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.WRITE | OPEN_MODE.EXCL,\n 'a+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE,\n 'ax+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL,\n 'xa+': OPEN_MODE.APPEND | OPEN_MODE.CREAT | OPEN_MODE.READ | OPEN_MODE.WRITE\n | OPEN_MODE.EXCL\n};\n\nfunction stringToFlags(str) {\n const flags = stringFlagMap[str];\n return (flags !== undefined ? flags : null);\n}\n\nconst flagsToString = (() => {\n const stringFlagMapKeys = Object.keys(stringFlagMap);\n return (flags) => {\n for (let i = 0; i < stringFlagMapKeys.length; ++i) {\n const key = stringFlagMapKeys[i];\n if (stringFlagMap[key] === flags)\n return key;\n }\n return null;\n };\n})();\n\nfunction readAttrs(biOpt) {\n /*\n uint32 flags\n uint64 size present only if flag SSH_FILEXFER_ATTR_SIZE\n uint32 uid present only if flag SSH_FILEXFER_ATTR_UIDGID\n uint32 gid present only if flag SSH_FILEXFER_ATTR_UIDGID\n uint32 permissions present only if flag SSH_FILEXFER_ATTR_PERMISSIONS\n uint32 atime present only if flag SSH_FILEXFER_ACMODTIME\n uint32 mtime present only if flag SSH_FILEXFER_ACMODTIME\n uint32 extended_count present only if flag SSH_FILEXFER_ATTR_EXTENDED\n string extended_type\n string extended_data\n ... more extended data (extended_type - extended_data pairs),\n so that number of pairs equals extended_count\n */\n const flags = bufferParser.readUInt32BE();\n if (flags === undefined)\n return;\n\n const attrs = new Stats();\n if (flags & ATTR.SIZE) {\n const size = bufferParser.readUInt64BE(biOpt);\n if (size === undefined)\n return;\n attrs.size = size;\n }\n\n if (flags & ATTR.UIDGID) {\n const uid = bufferParser.readUInt32BE();\n const gid = bufferParser.readUInt32BE();\n if (gid === undefined)\n return;\n attrs.uid = uid;\n attrs.gid = gid;\n }\n\n if (flags & ATTR.PERMISSIONS) {\n const mode = bufferParser.readUInt32BE();\n if (mode === undefined)\n return;\n attrs.mode = mode;\n }\n\n if (flags & ATTR.ACMODTIME) {\n const atime = bufferParser.readUInt32BE();\n const mtime = bufferParser.readUInt32BE();\n if (mtime === undefined)\n return;\n attrs.atime = atime;\n attrs.mtime = mtime;\n }\n\n if (flags & ATTR.EXTENDED) {\n const count = bufferParser.readUInt32BE();\n if (count === undefined)\n return;\n const extended = {};\n for (let i = 0; i < count; ++i) {\n const type = bufferParser.readString(true);\n const data = bufferParser.readString();\n if (data === undefined)\n return;\n extended[type] = data;\n }\n attrs.extended = extended;\n }\n\n return attrs;\n}\n\nfunction sendOrBuffer(sftp, payload) {\n const ret = tryWritePayload(sftp, payload);\n if (ret !== undefined) {\n sftp._buffer.push(ret);\n return false;\n }\n return true;\n}\n\nfunction tryWritePayload(sftp, payload) {\n const outgoing = sftp.outgoing;\n if (outgoing.state !== 'open')\n return;\n\n if (outgoing.window === 0) {\n sftp._waitWindow = true; // XXX: Unnecessary?\n return payload;\n }\n\n let ret;\n const len = payload.length;\n let p = 0;\n\n while (len - p > 0 && outgoing.window > 0) {\n const actualLen = Math.min(len - p, outgoing.window, outgoing.packetSize);\n outgoing.window -= actualLen;\n if (outgoing.window === 0) {\n sftp._waitWindow = true;\n sftp._chunkcb = drainBuffer;\n }\n\n if (p === 0 && actualLen === len) {\n sftp._protocol.channelData(sftp.outgoing.id, payload);\n } else {\n sftp._protocol.channelData(sftp.outgoing.id,\n bufferSlice(payload, p, p + actualLen));\n }\n\n p += actualLen;\n }\n\n if (len - p > 0) {\n if (p > 0)\n ret = bufferSlice(payload, p, len);\n else\n ret = payload; // XXX: should never get here?\n }\n\n return ret;\n}\n\nfunction drainBuffer() {\n this._chunkcb = undefined;\n const buffer = this._buffer;\n let i = 0;\n while (i < buffer.length) {\n const payload = buffer[i];\n const ret = tryWritePayload(this, payload);\n if (ret !== undefined) {\n if (ret !== payload)\n buffer[i] = ret;\n if (i > 0)\n this._buffer = buffer.slice(i);\n return;\n }\n ++i;\n }\n if (i > 0)\n this._buffer = [];\n}\n\nfunction doFatalSFTPError(sftp, msg, noDebug) {\n const err = new Error(msg);\n err.level = 'sftp-protocol';\n if (!noDebug && sftp._debug)\n sftp._debug(`SFTP: Inbound: ${msg}`);\n sftp.emit('error', err);\n sftp.destroy();\n cleanupRequests(sftp);\n return false;\n}\n\nfunction cleanupRequests(sftp) {\n const keys = Object.keys(sftp._requests);\n if (keys.length === 0)\n return;\n\n const reqs = sftp._requests;\n sftp._requests = {};\n const err = new Error('No response from server');\n for (let i = 0; i < keys.length; ++i) {\n const req = reqs[keys[i]];\n if (typeof req.cb === 'function')\n req.cb(err);\n }\n}\n\nfunction requestLimits(sftp, cb) {\n /*\n uint32 id\n string \"limits@openssh.com\"\n */\n let p = 9;\n const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 18);\n\n writeUInt32BE(buf, buf.length - 4, 0);\n buf[4] = REQUEST.EXTENDED;\n const reqid = sftp._writeReqid = (sftp._writeReqid + 1) & MAX_REQID;\n writeUInt32BE(buf, reqid, 5);\n\n writeUInt32BE(buf, 18, p);\n buf.utf8Write('limits@openssh.com', p += 4, 18);\n\n sftp._requests[reqid] = { extended: 'limits@openssh.com', cb };\n\n const isBuffered = sendOrBuffer(sftp, buf);\n if (sftp._debug) {\n const which = (isBuffered ? 'Buffered' : 'Sending');\n sftp._debug(`SFTP: Outbound: ${which} limits@openssh.com`);\n }\n}\n\nconst CLIENT_HANDLERS = {\n [RESPONSE.VERSION]: (sftp, payload) => {\n if (sftp._version !== -1)\n return doFatalSFTPError(sftp, 'Duplicate VERSION packet');\n\n const extensions = {};\n\n /*\n uint32 version\n \n */\n bufferParser.init(payload, 1);\n let version = bufferParser.readUInt32BE();\n while (bufferParser.avail()) {\n const extName = bufferParser.readString(true);\n const extData = bufferParser.readString(true);\n if (extData === undefined) {\n version = undefined;\n break;\n }\n extensions[extName] = extData;\n }\n bufferParser.clear();\n\n if (version === undefined)\n return doFatalSFTPError(sftp, 'Malformed VERSION packet');\n\n if (sftp._debug) {\n const names = Object.keys(extensions);\n if (names.length) {\n sftp._debug(\n `SFTP: Inbound: Received VERSION (v${version}, exts:${names})`\n );\n } else {\n sftp._debug(`SFTP: Inbound: Received VERSION (v${version})`);\n }\n }\n\n sftp._version = version;\n sftp._extensions = extensions;\n\n if (extensions['limits@openssh.com'] === '1') {\n return requestLimits(sftp, (err, limits) => {\n if (!err) {\n if (limits.maxPktLen > 0)\n sftp._maxOutPktLen = limits.maxPktLen;\n if (limits.maxReadLen > 0)\n sftp._maxReadLen = limits.maxReadLen;\n if (limits.maxWriteLen > 0)\n sftp._maxWriteLen = limits.maxWriteLen;\n sftp.maxOpenHandles = (\n limits.maxOpenHandles > 0 ? limits.maxOpenHandles : Infinity\n );\n }\n sftp.emit('ready');\n });\n }\n\n sftp.emit('ready');\n },\n [RESPONSE.STATUS]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n uint32 error/status code\n string error message (ISO-10646 UTF-8)\n string language tag\n */\n const errorCode = bufferParser.readUInt32BE();\n const errorMsg = bufferParser.readString(true);\n bufferParser.clear();\n\n // Note: we avoid checking that the error message and language tag are in\n // the packet because there are some broken implementations that incorrectly\n // omit them. The language tag in general was never really used amongst ssh\n // implementations, so in the case of a missing error message we just\n // default to something sensible.\n\n if (sftp._debug) {\n const jsonMsg = JSON.stringify(errorMsg);\n sftp._debug(\n `SFTP: Inbound: Received STATUS (id:${reqID}, ${errorCode}, ${jsonMsg})`\n );\n }\n const req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n if (req && typeof req.cb === 'function') {\n if (errorCode === STATUS_CODE.OK) {\n req.cb();\n return;\n }\n const err = new Error(errorMsg\n || STATUS_CODE_STR[errorCode]\n || 'Unknown status');\n err.code = errorCode;\n req.cb(err);\n }\n },\n [RESPONSE.HANDLE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined) {\n if (reqID !== undefined)\n delete sftp._requests[reqID];\n return doFatalSFTPError(sftp, 'Malformed HANDLE packet');\n }\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received HANDLE (id:${reqID})`);\n\n const req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n if (req && typeof req.cb === 'function')\n req.cb(undefined, handle);\n },\n [RESPONSE.DATA]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n string data\n */\n if (req && typeof req.cb === 'function') {\n if (req.buffer) {\n // We have already pre-allocated space to store the data\n\n const nb = bufferParser.readString(req.buffer);\n bufferParser.clear();\n\n if (nb !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`\n );\n req.cb(undefined, req.buffer, nb);\n return;\n }\n } else {\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${data.length})`\n );\n req.cb(undefined, data);\n return;\n }\n }\n } else {\n const nb = bufferParser.skipString();\n bufferParser.clear();\n if (nb !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received DATA (id:${reqID}, ${nb})`\n );\n return;\n }\n }\n\n return doFatalSFTPError(sftp, 'Malformed DATA packet');\n },\n [RESPONSE.NAME]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n uint32 count\n repeats count times:\n string filename\n string longname\n ATTRS attrs\n */\n const count = bufferParser.readUInt32BE();\n if (count !== undefined) {\n let names = [];\n for (let i = 0; i < count; ++i) {\n // We are going to assume UTF-8 for filenames despite the SFTPv3\n // spec not specifying an encoding because the specs for newer\n // versions of the protocol all explicitly specify UTF-8 for\n // filenames\n const filename = bufferParser.readString(true);\n\n // `longname` only exists in SFTPv3 and since it typically will\n // contain the filename, we assume it is also UTF-8\n const longname = bufferParser.readString(true);\n\n const attrs = readAttrs(sftp._biOpt);\n if (attrs === undefined) {\n names = undefined;\n break;\n }\n names.push({ filename, longname, attrs });\n }\n if (names !== undefined) {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received NAME (id:${reqID}, ${names.length})`\n );\n bufferParser.clear();\n if (req && typeof req.cb === 'function')\n req.cb(undefined, names);\n return;\n }\n }\n\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed NAME packet');\n },\n [RESPONSE.ATTRS]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n let req;\n if (reqID !== undefined) {\n req = sftp._requests[reqID];\n delete sftp._requests[reqID];\n }\n /*\n ATTRS attrs\n */\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n if (attrs !== undefined) {\n sftp._debug && sftp._debug(`SFTP: Inbound: Received ATTRS (id:${reqID})`);\n if (req && typeof req.cb === 'function')\n req.cb(undefined, attrs);\n return;\n }\n\n return doFatalSFTPError(sftp, 'Malformed ATTRS packet');\n },\n [RESPONSE.EXTENDED]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n if (reqID !== undefined) {\n const req = sftp._requests[reqID];\n if (req) {\n delete sftp._requests[reqID];\n switch (req.extended) {\n case 'statvfs@openssh.com':\n case 'fstatvfs@openssh.com': {\n /*\n uint64 f_bsize // file system block size\n uint64 f_frsize // fundamental fs block size\n uint64 f_blocks // number of blocks (unit f_frsize)\n uint64 f_bfree // free blocks in file system\n uint64 f_bavail // free blocks for non-root\n uint64 f_files // total file inodes\n uint64 f_ffree // free file inodes\n uint64 f_favail // free file inodes for to non-root\n uint64 f_fsid // file system id\n uint64 f_flag // bit mask of f_flag values\n uint64 f_namemax // maximum filename length\n */\n const biOpt = sftp._biOpt;\n const stats = {\n f_bsize: bufferParser.readUInt64BE(biOpt),\n f_frsize: bufferParser.readUInt64BE(biOpt),\n f_blocks: bufferParser.readUInt64BE(biOpt),\n f_bfree: bufferParser.readUInt64BE(biOpt),\n f_bavail: bufferParser.readUInt64BE(biOpt),\n f_files: bufferParser.readUInt64BE(biOpt),\n f_ffree: bufferParser.readUInt64BE(biOpt),\n f_favail: bufferParser.readUInt64BE(biOpt),\n f_sid: bufferParser.readUInt64BE(biOpt),\n f_flag: bufferParser.readUInt64BE(biOpt),\n f_namemax: bufferParser.readUInt64BE(biOpt),\n };\n if (stats.f_namemax === undefined)\n break;\n if (sftp._debug) {\n sftp._debug(\n 'SFTP: Inbound: Received EXTENDED_REPLY '\n + `(id:${reqID}, ${req.extended})`\n );\n }\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb(undefined, stats);\n return;\n }\n case 'limits@openssh.com': {\n /*\n uint64 max-packet-length\n uint64 max-read-length\n uint64 max-write-length\n uint64 max-open-handles\n */\n const limits = {\n maxPktLen: bufferParser.readUInt64BE(),\n maxReadLen: bufferParser.readUInt64BE(),\n maxWriteLen: bufferParser.readUInt64BE(),\n maxOpenHandles: bufferParser.readUInt64BE(),\n };\n if (limits.maxOpenHandles === undefined)\n break;\n if (sftp._debug) {\n sftp._debug(\n 'SFTP: Inbound: Received EXTENDED_REPLY '\n + `(id:${reqID}, ${req.extended})`\n );\n }\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb(undefined, limits);\n return;\n }\n default:\n // Unknown extended request\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`\n );\n bufferParser.clear();\n if (typeof req.cb === 'function')\n req.cb();\n return;\n }\n } else {\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED_REPLY (id:${reqID}, ???)`\n );\n bufferParser.clear();\n return;\n }\n }\n\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed EXTENDED_REPLY packet');\n },\n};\nconst SERVER_HANDLERS = {\n [REQUEST.INIT]: (sftp, payload) => {\n if (sftp._version !== -1)\n return doFatalSFTPError(sftp, 'Duplicate INIT packet');\n\n const extensions = {};\n\n /*\n uint32 version\n \n */\n bufferParser.init(payload, 1);\n let version = bufferParser.readUInt32BE();\n while (bufferParser.avail()) {\n const extName = bufferParser.readString(true);\n const extData = bufferParser.readString(true);\n if (extData === undefined) {\n version = undefined;\n break;\n }\n extensions[extName] = extData;\n }\n bufferParser.clear();\n\n if (version === undefined)\n return doFatalSFTPError(sftp, 'Malformed INIT packet');\n\n if (sftp._debug) {\n const names = Object.keys(extensions);\n if (names.length) {\n sftp._debug(\n `SFTP: Inbound: Received INIT (v${version}, exts:${names})`\n );\n } else {\n sftp._debug(`SFTP: Inbound: Received INIT (v${version})`);\n }\n }\n\n sendOrBuffer(sftp, SERVER_VERSION_BUFFER);\n\n sftp._version = version;\n sftp._extensions = extensions;\n sftp.emit('ready');\n },\n [REQUEST.OPEN]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string filename\n uint32 pflags\n ATTRS attrs\n */\n const filename = bufferParser.readString(true);\n const pflags = bufferParser.readUInt32BE();\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed OPEN packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received OPEN (id:${reqID})`);\n\n if (!sftp.emit('OPEN', reqID, filename, pflags, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.CLOSE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed CLOSE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received CLOSE (id:${reqID})`);\n\n if (!sftp.emit('CLOSE', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READ]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n uint64 offset\n uint32 len\n */\n const handle = bufferParser.readString();\n const offset = bufferParser.readUInt64BE(sftp._biOpt);\n const len = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (len === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed READ packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received READ (id:${reqID})`);\n\n if (!sftp.emit('READ', reqID, handle, offset, len)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.WRITE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n uint64 offset\n string data\n */\n const handle = bufferParser.readString();\n const offset = bufferParser.readUInt64BE(sftp._biOpt);\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed WRITE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received WRITE (id:${reqID})`);\n\n if (!sftp.emit('WRITE', reqID, handle, offset, data)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.LSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed LSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received LSTAT (id:${reqID})`);\n\n if (!sftp.emit('LSTAT', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.FSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed FSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received FSTAT (id:${reqID})`);\n\n if (!sftp.emit('FSTAT', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.SETSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n ATTRS attrs\n */\n const path = bufferParser.readString(true);\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed SETSTAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received SETSTAT (id:${reqID})`);\n\n if (!sftp.emit('SETSTAT', reqID, path, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.FSETSTAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n ATTRS attrs\n */\n const handle = bufferParser.readString();\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed FSETSTAT packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received FSETSTAT (id:${reqID})`\n );\n\n if (!sftp.emit('FSETSTAT', reqID, handle, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.OPENDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed OPENDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received OPENDIR (id:${reqID})`);\n\n if (!sftp.emit('OPENDIR', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string handle\n */\n const handle = bufferParser.readString();\n bufferParser.clear();\n\n if (handle === undefined || handle.length > 256)\n return doFatalSFTPError(sftp, 'Malformed READDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received READDIR (id:${reqID})`);\n\n if (!sftp.emit('READDIR', reqID, handle)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.REMOVE]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed REMOVE packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received REMOVE (id:${reqID})`);\n\n if (!sftp.emit('REMOVE', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.MKDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n ATTRS attrs\n */\n const path = bufferParser.readString(true);\n const attrs = readAttrs(sftp._biOpt);\n bufferParser.clear();\n\n if (attrs === undefined)\n return doFatalSFTPError(sftp, 'Malformed MKDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received MKDIR (id:${reqID})`);\n\n if (!sftp.emit('MKDIR', reqID, path, attrs)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.RMDIR]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed RMDIR packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received RMDIR (id:${reqID})`);\n\n if (!sftp.emit('RMDIR', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.REALPATH]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed REALPATH packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received REALPATH (id:${reqID})`\n );\n\n if (!sftp.emit('REALPATH', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.STAT]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed STAT packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received STAT (id:${reqID})`);\n\n if (!sftp.emit('STAT', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.RENAME]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string oldpath\n string newpath\n */\n const oldPath = bufferParser.readString(true);\n const newPath = bufferParser.readString(true);\n bufferParser.clear();\n\n if (newPath === undefined)\n return doFatalSFTPError(sftp, 'Malformed RENAME packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received RENAME (id:${reqID})`);\n\n if (!sftp.emit('RENAME', reqID, oldPath, newPath)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.READLINK]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string path\n */\n const path = bufferParser.readString(true);\n bufferParser.clear();\n\n if (path === undefined)\n return doFatalSFTPError(sftp, 'Malformed READLINK packet');\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received READLINK (id:${reqID})`\n );\n\n if (!sftp.emit('READLINK', reqID, path)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.SYMLINK]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string linkpath\n string targetpath\n */\n const linkPath = bufferParser.readString(true);\n const targetPath = bufferParser.readString(true);\n bufferParser.clear();\n\n if (targetPath === undefined)\n return doFatalSFTPError(sftp, 'Malformed SYMLINK packet');\n\n sftp._debug && sftp._debug(`SFTP: Inbound: Received SYMLINK (id:${reqID})`);\n\n let handled;\n if (sftp._isOpenSSH) {\n // OpenSSH has linkpath and targetpath positions switched\n handled = sftp.emit('SYMLINK', reqID, targetPath, linkPath);\n } else {\n handled = sftp.emit('SYMLINK', reqID, linkPath, targetPath);\n }\n if (!handled) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n [REQUEST.EXTENDED]: (sftp, payload) => {\n bufferParser.init(payload, 1);\n const reqID = bufferParser.readUInt32BE();\n /*\n string extended-request\n ... any request-specific data ...\n */\n const extName = bufferParser.readString(true);\n if (extName === undefined) {\n bufferParser.clear();\n return doFatalSFTPError(sftp, 'Malformed EXTENDED packet');\n }\n\n let extData;\n if (bufferParser.avail())\n extData = bufferParser.readRaw();\n bufferParser.clear();\n\n sftp._debug && sftp._debug(\n `SFTP: Inbound: Received EXTENDED (id:${reqID})`\n );\n\n if (!sftp.emit('EXTENDED', reqID, extName, extData)) {\n // Automatically reject request if no handler for request type\n sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);\n }\n },\n};\n\n// =============================================================================\n// ReadStream/WriteStream-related ==============================================\n// =============================================================================\nconst {\n ERR_INVALID_ARG_TYPE,\n ERR_OUT_OF_RANGE,\n validateNumber\n} = require('./node-fs-compat');\n\nconst kMinPoolSpace = 128;\n\nlet pool;\n// It can happen that we expect to read a large chunk of data, and reserve\n// a large chunk of the pool accordingly, but the read() call only filled\n// a portion of it. If a concurrently executing read() then uses the same pool,\n// the \"reserved\" portion cannot be used, so we allow it to be re-used as a\n// new pool later.\nconst poolFragments = [];\n\nfunction allocNewPool(poolSize) {\n if (poolFragments.length > 0)\n pool = poolFragments.pop();\n else\n pool = Buffer.allocUnsafe(poolSize);\n pool.used = 0;\n}\n\n// Check the `this.start` and `this.end` of stream.\nfunction checkPosition(pos, name) {\n if (!Number.isSafeInteger(pos)) {\n validateNumber(pos, name);\n if (!Number.isInteger(pos))\n throw new ERR_OUT_OF_RANGE(name, 'an integer', pos);\n throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);\n }\n if (pos < 0)\n throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos);\n}\n\nfunction roundUpToMultipleOf8(n) {\n return (n + 7) & ~7; // Align to 8 byte boundary.\n}\n\nfunction ReadStream(sftp, path, options) {\n if (options === undefined)\n options = {};\n else if (typeof options === 'string')\n options = { encoding: options };\n else if (options === null || typeof options !== 'object')\n throw new TypeError('\"options\" argument must be a string or an object');\n else\n options = Object.create(options);\n\n // A little bit bigger buffer and water marks by default\n if (options.highWaterMark === undefined)\n options.highWaterMark = 64 * 1024;\n\n // For backwards compat do not emit close on destroy.\n options.emitClose = false;\n options.autoDestroy = false; // Node 14 major change.\n\n ReadableStream.call(this, options);\n\n this.path = path;\n this.flags = options.flags === undefined ? 'r' : options.flags;\n this.mode = options.mode === undefined ? 0o666 : options.mode;\n\n this.start = options.start;\n this.end = options.end;\n this.autoClose = options.autoClose === undefined ? true : options.autoClose;\n this.pos = 0;\n this.bytesRead = 0;\n this.closed = false;\n\n this.handle = options.handle === undefined ? null : options.handle;\n this.sftp = sftp;\n this._opening = false;\n\n if (this.start !== undefined) {\n checkPosition(this.start, 'start');\n\n this.pos = this.start;\n }\n\n if (this.end === undefined) {\n this.end = Infinity;\n } else if (this.end !== Infinity) {\n checkPosition(this.end, 'end');\n\n if (this.start !== undefined && this.start > this.end) {\n throw new ERR_OUT_OF_RANGE(\n 'start',\n `<= \"end\" (here: ${this.end})`,\n this.start\n );\n }\n }\n\n this.on('end', function() {\n if (this.autoClose)\n this.destroy();\n });\n\n if (!Buffer.isBuffer(this.handle))\n this.open();\n}\ninherits(ReadStream, ReadableStream);\n\nReadStream.prototype.open = function() {\n if (this._opening)\n return;\n\n this._opening = true;\n\n this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {\n this._opening = false;\n\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n\n this.handle = handle;\n this.emit('open', handle);\n this.emit('ready');\n // Start the flow of data.\n this.read();\n });\n};\n\nReadStream.prototype._read = function(n) {\n if (!Buffer.isBuffer(this.handle))\n return this.once('open', () => this._read(n));\n\n // XXX: safe to remove this?\n if (this.destroyed)\n return;\n\n if (!pool || pool.length - pool.used < kMinPoolSpace) {\n // Discard the old pool.\n allocNewPool(this.readableHighWaterMark\n || this._readableState.highWaterMark);\n }\n\n // Grab another reference to the pool in the case that while we're\n // in the thread pool another read() finishes up the pool, and\n // allocates a new one.\n const thisPool = pool;\n let toRead = Math.min(pool.length - pool.used, n);\n const start = pool.used;\n\n if (this.end !== undefined)\n toRead = Math.min(this.end - this.pos + 1, toRead);\n\n // Already read everything we were supposed to read!\n // treat as EOF.\n if (toRead <= 0)\n return this.push(null);\n\n // the actual read.\n this.sftp.read(this.handle,\n pool,\n pool.used,\n toRead,\n this.pos,\n (er, bytesRead) => {\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n let b = null;\n\n // Now that we know how much data we have actually read, re-wind the\n // 'used' field if we can, and otherwise allow the remainder of our\n // reservation to be used as a new pool later.\n if (start + toRead === thisPool.used && thisPool === pool) {\n thisPool.used = roundUpToMultipleOf8(thisPool.used + bytesRead - toRead);\n } else {\n // Round down to the next lowest multiple of 8 to ensure the new pool\n // fragment start and end positions are aligned to an 8 byte boundary.\n const alignedEnd = (start + toRead) & ~7;\n const alignedStart = roundUpToMultipleOf8(start + bytesRead);\n if (alignedEnd - alignedStart >= kMinPoolSpace)\n poolFragments.push(thisPool.slice(alignedStart, alignedEnd));\n }\n\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n b = thisPool.slice(start, start + bytesRead);\n }\n\n // Move the pool positions, and internal position for reading.\n this.pos += bytesRead;\n\n this.push(b);\n });\n\n pool.used = roundUpToMultipleOf8(pool.used + toRead);\n};\n\nReadStream.prototype._destroy = function(err, cb) {\n if (this._opening && !Buffer.isBuffer(this.handle)) {\n this.once('open', closeStream.bind(null, this, cb, err));\n return;\n }\n\n closeStream(this, cb, err);\n this.handle = null;\n this._opening = false;\n};\n\nfunction closeStream(stream, cb, err) {\n if (!stream.handle)\n return onclose();\n\n stream.sftp.close(stream.handle, onclose);\n\n function onclose(er) {\n er = er || err;\n cb(er);\n stream.closed = true;\n if (!er)\n stream.emit('close');\n }\n}\n\nReadStream.prototype.close = function(cb) {\n this.destroy(null, cb);\n};\n\nObject.defineProperty(ReadStream.prototype, 'pending', {\n get() {\n return this.handle === null;\n },\n configurable: true\n});\n\n// TODO: add `concurrency` setting to allow more than one in-flight WRITE\n// request to server to improve throughput\nfunction WriteStream(sftp, path, options) {\n if (options === undefined)\n options = {};\n else if (typeof options === 'string')\n options = { encoding: options };\n else if (options === null || typeof options !== 'object')\n throw new TypeError('\"options\" argument must be a string or an object');\n else\n options = Object.create(options);\n\n // For backwards compat do not emit close on destroy.\n options.emitClose = false;\n options.autoDestroy = false; // Node 14 major change.\n\n WritableStream.call(this, options);\n\n this.path = path;\n this.flags = options.flags === undefined ? 'w' : options.flags;\n this.mode = options.mode === undefined ? 0o666 : options.mode;\n\n this.start = options.start;\n this.autoClose = options.autoClose === undefined ? true : options.autoClose;\n this.pos = 0;\n this.bytesWritten = 0;\n this.closed = false;\n\n this.handle = options.handle === undefined ? null : options.handle;\n this.sftp = sftp;\n this._opening = false;\n\n if (this.start !== undefined) {\n checkPosition(this.start, 'start');\n\n this.pos = this.start;\n }\n\n if (options.encoding)\n this.setDefaultEncoding(options.encoding);\n\n // Node v6.x only\n this.on('finish', function() {\n if (this._writableState.finalCalled)\n return;\n if (this.autoClose)\n this.destroy();\n });\n\n if (!Buffer.isBuffer(this.handle))\n this.open();\n}\ninherits(WriteStream, WritableStream);\n\nWriteStream.prototype._final = function(cb) {\n if (this.autoClose)\n this.destroy();\n cb();\n};\n\nWriteStream.prototype.open = function() {\n if (this._opening)\n return;\n\n this._opening = true;\n\n this.sftp.open(this.path, this.flags, this.mode, (er, handle) => {\n this._opening = false;\n\n if (er) {\n this.emit('error', er);\n if (this.autoClose)\n this.destroy();\n return;\n }\n\n this.handle = handle;\n\n const tryAgain = (err) => {\n if (err) {\n // Try chmod() for sftp servers that may not support fchmod() for\n // whatever reason\n this.sftp.chmod(this.path, this.mode, (err_) => tryAgain());\n return;\n }\n\n // SFTPv3 requires absolute offsets, no matter the open flag used\n if (this.flags[0] === 'a') {\n const tryStat = (err, st) => {\n if (err) {\n // Try stat() for sftp servers that may not support fstat() for\n // whatever reason\n this.sftp.stat(this.path, (err_, st_) => {\n if (err_) {\n this.destroy();\n this.emit('error', err);\n return;\n }\n tryStat(null, st_);\n });\n return;\n }\n\n this.pos = st.size;\n this.emit('open', handle);\n this.emit('ready');\n };\n\n this.sftp.fstat(handle, tryStat);\n return;\n }\n\n this.emit('open', handle);\n this.emit('ready');\n };\n\n this.sftp.fchmod(handle, this.mode, tryAgain);\n });\n};\n\nWriteStream.prototype._write = function(data, encoding, cb) {\n if (!Buffer.isBuffer(data)) {\n const err = new ERR_INVALID_ARG_TYPE('data', 'Buffer', data);\n return this.emit('error', err);\n }\n\n if (!Buffer.isBuffer(this.handle)) {\n return this.once('open', function() {\n this._write(data, encoding, cb);\n });\n }\n\n this.sftp.write(this.handle,\n data,\n 0,\n data.length,\n this.pos,\n (er, bytes) => {\n if (er) {\n if (this.autoClose)\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n cb();\n });\n\n this.pos += data.length;\n};\n\nWriteStream.prototype._writev = function(data, cb) {\n if (!Buffer.isBuffer(this.handle)) {\n return this.once('open', function() {\n this._writev(data, cb);\n });\n }\n\n const sftp = this.sftp;\n const handle = this.handle;\n let writesLeft = data.length;\n\n const onwrite = (er, bytes) => {\n if (er) {\n this.destroy();\n return cb(er);\n }\n this.bytesWritten += bytes;\n if (--writesLeft === 0)\n cb();\n };\n\n // TODO: try to combine chunks to reduce number of requests to the server?\n for (let i = 0; i < data.length; ++i) {\n const chunk = data[i].chunk;\n\n sftp.write(handle, chunk, 0, chunk.length, this.pos, onwrite);\n this.pos += chunk.length;\n }\n};\n\nif (typeof WritableStream.prototype.destroy !== 'function')\n WriteStream.prototype.destroy = ReadStream.prototype.destroy;\n\nWriteStream.prototype._destroy = ReadStream.prototype._destroy;\nWriteStream.prototype.close = function(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on('close', cb);\n }\n\n // If we are not autoClosing, we should call\n // destroy on 'finish'.\n if (!this.autoClose)\n this.on('finish', this.destroy.bind(this));\n\n this.end();\n};\n\n// There is no shutdown() for files.\nWriteStream.prototype.destroySoon = WriteStream.prototype.end;\n\nObject.defineProperty(WriteStream.prototype, 'pending', {\n get() {\n return this.handle === null;\n },\n configurable: true\n});\n// =============================================================================\n\nmodule.exports = {\n flagsToString,\n OPEN_MODE,\n SFTP,\n Stats,\n STATUS_CODE,\n stringToFlags,\n};\n","'use strict';\n\nconst crypto = require('crypto');\n\nlet cpuInfo;\ntry {\n cpuInfo = require('cpu-features')();\n} catch {}\n\nconst { bindingAvailable } = require('./crypto.js');\n\nconst eddsaSupported = (() => {\n if (typeof crypto.sign === 'function'\n && typeof crypto.verify === 'function') {\n const key =\n '-----BEGIN PRIVATE KEY-----\\r\\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD'\n + '/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\\r\\n-----END PRIVATE KEY-----';\n const data = Buffer.from('a');\n let sig;\n let verified;\n try {\n sig = crypto.sign(null, data, key);\n verified = crypto.verify(null, data, key, sig);\n } catch {}\n return (Buffer.isBuffer(sig) && sig.length === 64 && verified === true);\n }\n\n return false;\n})();\n\nconst curve25519Supported = (typeof crypto.diffieHellman === 'function'\n && typeof crypto.generateKeyPairSync === 'function'\n && typeof crypto.createPublicKey === 'function');\n\nconst DEFAULT_KEX = [\n // https://tools.ietf.org/html/rfc5656#section-10.1\n 'ecdh-sha2-nistp256',\n 'ecdh-sha2-nistp384',\n 'ecdh-sha2-nistp521',\n\n // https://tools.ietf.org/html/rfc4419#section-4\n 'diffie-hellman-group-exchange-sha256',\n\n // https://tools.ietf.org/html/rfc8268\n 'diffie-hellman-group14-sha256',\n 'diffie-hellman-group15-sha512',\n 'diffie-hellman-group16-sha512',\n 'diffie-hellman-group17-sha512',\n 'diffie-hellman-group18-sha512',\n];\nif (curve25519Supported) {\n DEFAULT_KEX.unshift('curve25519-sha256');\n DEFAULT_KEX.unshift('curve25519-sha256@libssh.org');\n}\nconst SUPPORTED_KEX = DEFAULT_KEX.concat([\n // https://tools.ietf.org/html/rfc4419#section-4\n 'diffie-hellman-group-exchange-sha1',\n\n 'diffie-hellman-group14-sha1', // REQUIRED\n 'diffie-hellman-group1-sha1', // REQUIRED\n]);\n\n\nconst DEFAULT_SERVER_HOST_KEY = [\n 'ecdsa-sha2-nistp256',\n 'ecdsa-sha2-nistp384',\n 'ecdsa-sha2-nistp521',\n 'rsa-sha2-512', // RFC 8332\n 'rsa-sha2-256', // RFC 8332\n 'ssh-rsa',\n];\nif (eddsaSupported)\n DEFAULT_SERVER_HOST_KEY.unshift('ssh-ed25519');\nconst SUPPORTED_SERVER_HOST_KEY = DEFAULT_SERVER_HOST_KEY.concat([\n 'ssh-dss',\n]);\n\n\nconst DEFAULT_CIPHER = [\n // http://tools.ietf.org/html/rfc5647\n 'aes128-gcm@openssh.com',\n 'aes256-gcm@openssh.com',\n\n // http://tools.ietf.org/html/rfc4344#section-4\n 'aes128-ctr',\n 'aes192-ctr',\n 'aes256-ctr',\n];\nif (cpuInfo && cpuInfo.flags && !cpuInfo.flags.aes) {\n // We know for sure the CPU does not support AES acceleration\n if (bindingAvailable)\n DEFAULT_CIPHER.unshift('chacha20-poly1305@openssh.com');\n else\n DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');\n} else if (bindingAvailable && cpuInfo && cpuInfo.arch === 'x86') {\n // Places chacha20-poly1305 immediately after GCM ciphers since GCM ciphers\n // seem to outperform it on x86, but it seems to be faster than CTR ciphers\n DEFAULT_CIPHER.splice(4, 0, 'chacha20-poly1305@openssh.com');\n} else {\n DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');\n}\nconst SUPPORTED_CIPHER = DEFAULT_CIPHER.concat([\n 'aes256-cbc',\n 'aes192-cbc',\n 'aes128-cbc',\n 'blowfish-cbc',\n '3des-cbc',\n 'aes128-gcm',\n 'aes256-gcm',\n\n // http://tools.ietf.org/html/rfc4345#section-4:\n 'arcfour256',\n 'arcfour128',\n\n 'cast128-cbc',\n 'arcfour',\n]);\n\n\nconst DEFAULT_MAC = [\n 'hmac-sha2-256-etm@openssh.com',\n 'hmac-sha2-512-etm@openssh.com',\n 'hmac-sha1-etm@openssh.com',\n 'hmac-sha2-256',\n 'hmac-sha2-512',\n 'hmac-sha1',\n];\nconst SUPPORTED_MAC = DEFAULT_MAC.concat([\n 'hmac-md5',\n 'hmac-sha2-256-96', // first 96 bits of HMAC-SHA256\n 'hmac-sha2-512-96', // first 96 bits of HMAC-SHA512\n 'hmac-ripemd160',\n 'hmac-sha1-96', // first 96 bits of HMAC-SHA1\n 'hmac-md5-96', // first 96 bits of HMAC-MD5\n]);\n\nconst DEFAULT_COMPRESSION = [\n 'none',\n 'zlib@openssh.com', // ZLIB (LZ77) compression, except\n // compression/decompression does not start until after\n // successful user authentication\n 'zlib', // ZLIB (LZ77) compression\n];\nconst SUPPORTED_COMPRESSION = DEFAULT_COMPRESSION.concat([\n]);\n\n\nconst COMPAT = {\n BAD_DHGEX: 1 << 0,\n OLD_EXIT: 1 << 1,\n DYN_RPORT_BUG: 1 << 2,\n BUG_DHGEX_LARGE: 1 << 3,\n};\n\nmodule.exports = {\n MESSAGE: {\n // Transport layer protocol -- generic (1-19)\n DISCONNECT: 1,\n IGNORE: 2,\n UNIMPLEMENTED: 3,\n DEBUG: 4,\n SERVICE_REQUEST: 5,\n SERVICE_ACCEPT: 6,\n\n // Transport layer protocol -- algorithm negotiation (20-29)\n KEXINIT: 20,\n NEWKEYS: 21,\n\n // Transport layer protocol -- key exchange method-specific (30-49)\n KEXDH_INIT: 30,\n KEXDH_REPLY: 31,\n\n KEXDH_GEX_GROUP: 31,\n KEXDH_GEX_INIT: 32,\n KEXDH_GEX_REPLY: 33,\n KEXDH_GEX_REQUEST: 34,\n\n KEXECDH_INIT: 30,\n KEXECDH_REPLY: 31,\n\n // User auth protocol -- generic (50-59)\n USERAUTH_REQUEST: 50,\n USERAUTH_FAILURE: 51,\n USERAUTH_SUCCESS: 52,\n USERAUTH_BANNER: 53,\n\n // User auth protocol -- user auth method-specific (60-79)\n USERAUTH_PASSWD_CHANGEREQ: 60,\n\n USERAUTH_PK_OK: 60,\n\n USERAUTH_INFO_REQUEST: 60,\n USERAUTH_INFO_RESPONSE: 61,\n\n // Connection protocol -- generic (80-89)\n GLOBAL_REQUEST: 80,\n REQUEST_SUCCESS: 81,\n REQUEST_FAILURE: 82,\n\n // Connection protocol -- channel-related (90-127)\n CHANNEL_OPEN: 90,\n CHANNEL_OPEN_CONFIRMATION: 91,\n CHANNEL_OPEN_FAILURE: 92,\n CHANNEL_WINDOW_ADJUST: 93,\n CHANNEL_DATA: 94,\n CHANNEL_EXTENDED_DATA: 95,\n CHANNEL_EOF: 96,\n CHANNEL_CLOSE: 97,\n CHANNEL_REQUEST: 98,\n CHANNEL_SUCCESS: 99,\n CHANNEL_FAILURE: 100\n\n // Reserved for client protocols (128-191)\n\n // Local extensions (192-155)\n },\n DISCONNECT_REASON: {\n HOST_NOT_ALLOWED_TO_CONNECT: 1,\n PROTOCOL_ERROR: 2,\n KEY_EXCHANGE_FAILED: 3,\n RESERVED: 4,\n MAC_ERROR: 5,\n COMPRESSION_ERROR: 6,\n SERVICE_NOT_AVAILABLE: 7,\n PROTOCOL_VERSION_NOT_SUPPORTED: 8,\n HOST_KEY_NOT_VERIFIABLE: 9,\n CONNECTION_LOST: 10,\n BY_APPLICATION: 11,\n TOO_MANY_CONNECTIONS: 12,\n AUTH_CANCELED_BY_USER: 13,\n NO_MORE_AUTH_METHODS_AVAILABLE: 14,\n ILLEGAL_USER_NAME: 15,\n },\n DISCONNECT_REASON_STR: undefined,\n CHANNEL_OPEN_FAILURE: {\n ADMINISTRATIVELY_PROHIBITED: 1,\n CONNECT_FAILED: 2,\n UNKNOWN_CHANNEL_TYPE: 3,\n RESOURCE_SHORTAGE: 4\n },\n TERMINAL_MODE: {\n TTY_OP_END: 0, // Indicates end of options.\n VINTR: 1, // Interrupt character; 255 if none. Similarly for the\n // other characters. Not all of these characters are\n // supported on all systems.\n VQUIT: 2, // The quit character (sends SIGQUIT signal on POSIX\n // systems).\n VERASE: 3, // Erase the character to left of the cursor.\n VKILL: 4, // Kill the current input line.\n VEOF: 5, // End-of-file character (sends EOF from the\n // terminal).\n VEOL: 6, // End-of-line character in addition to carriage\n // return and/or linefeed.\n VEOL2: 7, // Additional end-of-line character.\n VSTART: 8, // Continues paused output (normally control-Q).\n VSTOP: 9, // Pauses output (normally control-S).\n VSUSP: 10, // Suspends the current program.\n VDSUSP: 11, // Another suspend character.\n VREPRINT: 12, // Reprints the current input line.\n VWERASE: 13, // Erases a word left of cursor.\n VLNEXT: 14, // Enter the next character typed literally, even if\n // it is a special character\n VFLUSH: 15, // Character to flush output.\n VSWTCH: 16, // Switch to a different shell layer.\n VSTATUS: 17, // Prints system status line (load, command, pid,\n // etc).\n VDISCARD: 18, // Toggles the flushing of terminal output.\n IGNPAR: 30, // The ignore parity flag. The parameter SHOULD be 0\n // if this flag is FALSE, and 1 if it is TRUE.\n PARMRK: 31, // Mark parity and framing errors.\n INPCK: 32, // Enable checking of parity errors.\n ISTRIP: 33, // Strip 8th bit off characters.\n INLCR: 34, // Map NL into CR on input.\n IGNCR: 35, // Ignore CR on input.\n ICRNL: 36, // Map CR to NL on input.\n IUCLC: 37, // Translate uppercase characters to lowercase.\n IXON: 38, // Enable output flow control.\n IXANY: 39, // Any char will restart after stop.\n IXOFF: 40, // Enable input flow control.\n IMAXBEL: 41, // Ring bell on input queue full.\n ISIG: 50, // Enable signals INTR, QUIT, [D]SUSP.\n ICANON: 51, // Canonicalize input lines.\n XCASE: 52, // Enable input and output of uppercase characters by\n // preceding their lowercase equivalents with \"\\\".\n ECHO: 53, // Enable echoing.\n ECHOE: 54, // Visually erase chars.\n ECHOK: 55, // Kill character discards current line.\n ECHONL: 56, // Echo NL even if ECHO is off.\n NOFLSH: 57, // Don't flush after interrupt.\n TOSTOP: 58, // Stop background jobs from output.\n IEXTEN: 59, // Enable extensions.\n ECHOCTL: 60, // Echo control characters as ^(Char).\n ECHOKE: 61, // Visual erase for line kill.\n PENDIN: 62, // Retype pending input.\n OPOST: 70, // Enable output processing.\n OLCUC: 71, // Convert lowercase to uppercase.\n ONLCR: 72, // Map NL to CR-NL.\n OCRNL: 73, // Translate carriage return to newline (output).\n ONOCR: 74, // Translate newline to carriage return-newline\n // (output).\n ONLRET: 75, // Newline performs a carriage return (output).\n CS7: 90, // 7 bit mode.\n CS8: 91, // 8 bit mode.\n PARENB: 92, // Parity enable.\n PARODD: 93, // Odd parity, else even.\n TTY_OP_ISPEED: 128, // Specifies the input baud rate in bits per second.\n TTY_OP_OSPEED: 129, // Specifies the output baud rate in bits per second.\n },\n CHANNEL_EXTENDED_DATATYPE: {\n STDERR: 1,\n },\n\n SIGNALS: [\n 'ABRT', 'ALRM', 'FPE', 'HUP', 'ILL', 'INT', 'QUIT', 'SEGV', 'TERM', 'USR1',\n 'USR2', 'KILL', 'PIPE'\n ].reduce((cur, val) => ({ ...cur, [val]: 1 }), {}),\n\n COMPAT,\n COMPAT_CHECKS: [\n [ 'Cisco-1.25', COMPAT.BAD_DHGEX ],\n [ /^Cisco-1\\./, COMPAT.BUG_DHGEX_LARGE ],\n [ /^[0-9.]+$/, COMPAT.OLD_EXIT ], // old SSH.com implementations\n [ /^OpenSSH_5\\.\\d+/, COMPAT.DYN_RPORT_BUG ],\n ],\n\n // KEX proposal-related\n DEFAULT_KEX,\n SUPPORTED_KEX,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER,\n DEFAULT_MAC,\n SUPPORTED_MAC,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION,\n\n curve25519Supported,\n eddsaSupported,\n};\n\nmodule.exports.DISCONNECT_REASON_BY_VALUE =\n Array.from(Object.entries(module.exports.DISCONNECT_REASON))\n .reduce((obj, [key, value]) => ({ ...obj, [value]: key }), {});\n","// TODO:\n// * make max packet size configurable\n// * if decompression is enabled, use `._packet` in decipher instances as\n// input to (sync) zlib inflater with appropriate offset and length to\n// avoid an additional copy of payload data before inflation\n// * factor decompression status into packet length checks\n'use strict';\n\nconst {\n createCipheriv, createDecipheriv, createHmac, randomFillSync, timingSafeEqual\n} = require('crypto');\n\nconst { readUInt32BE, writeUInt32BE } = require('./utils.js');\n\nconst FastBuffer = Buffer[Symbol.species];\nconst MAX_SEQNO = 2 ** 32 - 1;\nconst EMPTY_BUFFER = Buffer.alloc(0);\nconst BUF_INT = Buffer.alloc(4);\nconst DISCARD_CACHE = new Map();\nconst MAX_PACKET_SIZE = 35000;\n\nlet binding;\nlet AESGCMCipher;\nlet ChaChaPolyCipher;\nlet GenericCipher;\nlet AESGCMDecipher;\nlet ChaChaPolyDecipher;\nlet GenericDecipher;\ntry {\n binding = require('./crypto/build/Release/sshcrypto.node');\n ({ AESGCMCipher, ChaChaPolyCipher, GenericCipher,\n AESGCMDecipher, ChaChaPolyDecipher, GenericDecipher } = binding);\n} catch {}\n\nconst CIPHER_STREAM = 1 << 0;\nconst CIPHER_INFO = (() => {\n function info(sslName, blockLen, keyLen, ivLen, authLen, discardLen, flags) {\n return {\n sslName,\n blockLen,\n keyLen,\n ivLen: (ivLen !== 0 || (flags & CIPHER_STREAM)\n ? ivLen\n : blockLen),\n authLen,\n discardLen,\n stream: !!(flags & CIPHER_STREAM),\n };\n }\n\n return {\n 'chacha20-poly1305@openssh.com':\n info('chacha20', 8, 64, 0, 16, 0, CIPHER_STREAM),\n\n 'aes128-gcm': info('aes-128-gcm', 16, 16, 12, 16, 0, CIPHER_STREAM),\n 'aes256-gcm': info('aes-256-gcm', 16, 32, 12, 16, 0, CIPHER_STREAM),\n 'aes128-gcm@openssh.com':\n info('aes-128-gcm', 16, 16, 12, 16, 0, CIPHER_STREAM),\n 'aes256-gcm@openssh.com':\n info('aes-256-gcm', 16, 32, 12, 16, 0, CIPHER_STREAM),\n\n 'aes128-cbc': info('aes-128-cbc', 16, 16, 0, 0, 0, 0),\n 'aes192-cbc': info('aes-192-cbc', 16, 24, 0, 0, 0, 0),\n 'aes256-cbc': info('aes-256-cbc', 16, 32, 0, 0, 0, 0),\n 'rijndael-cbc@lysator.liu.se': info('aes-256-cbc', 16, 32, 0, 0, 0, 0),\n '3des-cbc': info('des-ede3-cbc', 8, 24, 0, 0, 0, 0),\n 'blowfish-cbc': info('bf-cbc', 8, 16, 0, 0, 0, 0),\n 'idea-cbc': info('idea-cbc', 8, 16, 0, 0, 0, 0),\n 'cast128-cbc': info('cast-cbc', 8, 16, 0, 0, 0, 0),\n\n 'aes128-ctr': info('aes-128-ctr', 16, 16, 16, 0, 0, CIPHER_STREAM),\n 'aes192-ctr': info('aes-192-ctr', 16, 24, 16, 0, 0, CIPHER_STREAM),\n 'aes256-ctr': info('aes-256-ctr', 16, 32, 16, 0, 0, CIPHER_STREAM),\n '3des-ctr': info('des-ede3', 8, 24, 8, 0, 0, CIPHER_STREAM),\n 'blowfish-ctr': info('bf-ecb', 8, 16, 8, 0, 0, CIPHER_STREAM),\n 'cast128-ctr': info('cast5-ecb', 8, 16, 8, 0, 0, CIPHER_STREAM),\n\n /* The \"arcfour128\" algorithm is the RC4 cipher, as described in\n [SCHNEIER], using a 128-bit key. The first 1536 bytes of keystream\n generated by the cipher MUST be discarded, and the first byte of the\n first encrypted packet MUST be encrypted using the 1537th byte of\n keystream.\n\n -- http://tools.ietf.org/html/rfc4345#section-4 */\n 'arcfour': info('rc4', 8, 16, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour128': info('rc4', 8, 16, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour256': info('rc4', 8, 32, 0, 0, 1536, CIPHER_STREAM),\n 'arcfour512': info('rc4', 8, 64, 0, 0, 1536, CIPHER_STREAM),\n };\n})();\n\nconst MAC_INFO = (() => {\n function info(sslName, len, actualLen, isETM) {\n return {\n sslName,\n len,\n actualLen,\n isETM,\n };\n }\n\n return {\n 'hmac-md5': info('md5', 16, 16, false),\n 'hmac-md5-96': info('md5', 16, 12, false),\n 'hmac-ripemd160': info('ripemd160', 20, 20, false),\n 'hmac-sha1': info('sha1', 20, 20, false),\n 'hmac-sha1-etm@openssh.com': info('sha1', 20, 20, true),\n 'hmac-sha1-96': info('sha1', 20, 12, false),\n 'hmac-sha2-256': info('sha256', 32, 32, false),\n 'hmac-sha2-256-etm@openssh.com': info('sha256', 32, 32, true),\n 'hmac-sha2-256-96': info('sha256', 32, 12, false),\n 'hmac-sha2-512': info('sha512', 64, 64, false),\n 'hmac-sha2-512-etm@openssh.com': info('sha512', 64, 64, true),\n 'hmac-sha2-512-96': info('sha512', 64, 12, false),\n };\n})();\n\n\n// Should only_be used during the initial handshake\nclass NullCipher {\n constructor(seqno, onWrite) {\n this.outSeqno = seqno;\n this._onWrite = onWrite;\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - (pktLen & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nconst POLY1305_ZEROS = Buffer.alloc(32);\nconst POLY1305_OUT_COMPUTE = Buffer.alloc(16);\nlet POLY1305_WASM_MODULE;\nlet POLY1305_RESULT_MALLOC;\nlet poly1305_auth;\nclass ChaChaPolyCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encKeyMain = enc.cipherKey.slice(0, 32);\n this._encKeyPktLen = enc.cipherKey.slice(32);\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - ((pktLen - 4) & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Generate Poly1305 key\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.outSeqno, 12);\n const polyKey =\n createCipheriv('chacha20', this._encKeyMain, POLY1305_OUT_COMPUTE)\n .update(POLY1305_ZEROS);\n\n // Encrypt packet length\n const pktLenEnc =\n createCipheriv('chacha20', this._encKeyPktLen, POLY1305_OUT_COMPUTE)\n .update(packet.slice(0, 4));\n this._onWrite(pktLenEnc);\n\n // Encrypt rest of packet\n POLY1305_OUT_COMPUTE[0] = 1; // Set counter to 1 (little endian)\n const payloadEnc =\n createCipheriv('chacha20', this._encKeyMain, POLY1305_OUT_COMPUTE)\n .update(packet.slice(4));\n this._onWrite(payloadEnc);\n\n // Calculate Poly1305 MAC\n poly1305_auth(POLY1305_RESULT_MALLOC,\n pktLenEnc,\n pktLenEnc.length,\n payloadEnc,\n payloadEnc.length,\n polyKey);\n const mac = Buffer.allocUnsafe(16);\n mac.set(\n new Uint8Array(POLY1305_WASM_MODULE.HEAPU8.buffer,\n POLY1305_RESULT_MALLOC,\n 16),\n 0\n );\n this._onWrite(mac);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass ChaChaPolyCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._instance = new ChaChaPolyCipher(enc.cipherKey);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 8 - ((pktLen - 4) & (8 - 1));\n if (padLen < 4)\n padLen += 8;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + 16/* MAC */);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet, this.outSeqno);\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass AESGCMCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encSSLName = enc.cipherInfo.sslName;\n this._encKey = enc.cipherKey;\n this._encIV = enc.cipherIV;\n this._dead = false;\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 16 - ((pktLen - 4) & (16 - 1));\n if (padLen < 4)\n padLen += 16;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n const cipher = createCipheriv(this._encSSLName, this._encKey, this._encIV);\n cipher.setAutoPadding(false);\n\n const lenData = packet.slice(0, 4);\n cipher.setAAD(lenData);\n this._onWrite(lenData);\n\n // Encrypt pad length, payload, and padding\n const encrypted = cipher.update(packet.slice(4));\n this._onWrite(encrypted);\n const final = cipher.final();\n // XXX: final.length === 0 always?\n if (final.length)\n this._onWrite(final);\n\n // Generate MAC\n const tag = cipher.getAuthTag();\n this._onWrite(tag);\n\n // Increment counter in IV by 1 for next packet\n ivIncrement(this._encIV);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass AESGCMCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._instance = new AESGCMCipher(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n let pktLen = 4 + 1 + payloadLen;\n let padLen = 16 - ((pktLen - 4) & (16 - 1));\n if (padLen < 4)\n padLen += 16;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + 16/* authTag */);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet);\n\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass GenericCipherNative {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encBlockLen = enc.cipherInfo.blockLen;\n this._cipherInstance = createCipheriv(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV);\n this._macSSLName = enc.macInfo.sslName;\n this._macKey = enc.macKey;\n this._macActualLen = enc.macInfo.actualLen;\n this._macETM = enc.macInfo.isETM;\n this._aadLen = (this._macETM ? 4 : 0);\n this._dead = false;\n\n const discardLen = enc.cipherInfo.discardLen;\n if (discardLen) {\n let discard = DISCARD_CACHE.get(discardLen);\n if (discard === undefined) {\n discard = Buffer.alloc(discardLen);\n DISCARD_CACHE.set(discardLen, discard);\n }\n this._cipherInstance.update(discard);\n }\n }\n free() {\n this._dead = true;\n }\n allocPacket(payloadLen) {\n const blockLen = this._encBlockLen;\n\n let pktLen = 4 + 1 + payloadLen;\n let padLen = blockLen - ((pktLen - this._aadLen) & (blockLen - 1));\n if (padLen < 4)\n padLen += blockLen;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n let mac;\n if (this._macETM) {\n // Encrypt pad length, payload, and padding\n const lenBytes = new Uint8Array(packet.buffer, packet.byteOffset, 4);\n const encrypted = this._cipherInstance.update(\n new Uint8Array(packet.buffer,\n packet.byteOffset + 4,\n packet.length - 4)\n );\n\n this._onWrite(lenBytes);\n this._onWrite(encrypted);\n\n // TODO: look into storing seqno as 4-byte buffer and incrementing like we\n // do for AES-GCM IVs to avoid having to (re)write all 4 bytes every time\n mac = createHmac(this._macSSLName, this._macKey);\n writeUInt32BE(BUF_INT, this.outSeqno, 0);\n mac.update(BUF_INT);\n mac.update(lenBytes);\n mac.update(encrypted);\n } else {\n // Encrypt length field, pad length, payload, and padding\n const encrypted = this._cipherInstance.update(packet);\n this._onWrite(encrypted);\n\n // TODO: look into storing seqno as 4-byte buffer and incrementing like we\n // do for AES-GCM IVs to avoid having to (re)write all 4 bytes every time\n mac = createHmac(this._macSSLName, this._macKey);\n writeUInt32BE(BUF_INT, this.outSeqno, 0);\n mac.update(BUF_INT);\n mac.update(packet);\n }\n\n let digest = mac.digest();\n if (digest.length > this._macActualLen)\n digest = digest.slice(0, this._macActualLen);\n this._onWrite(digest);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\nclass GenericCipherBinding {\n constructor(config) {\n const enc = config.outbound;\n this.outSeqno = enc.seqno;\n this._onWrite = enc.onWrite;\n this._encBlockLen = enc.cipherInfo.blockLen;\n this._macLen = enc.macInfo.len;\n this._macActualLen = enc.macInfo.actualLen;\n this._aadLen = (enc.macInfo.isETM ? 4 : 0);\n this._instance = new GenericCipher(enc.cipherInfo.sslName,\n enc.cipherKey,\n enc.cipherIV,\n enc.macInfo.sslName,\n enc.macKey,\n enc.macInfo.isETM);\n this._dead = false;\n }\n free() {\n this._dead = true;\n this._instance.free();\n }\n allocPacket(payloadLen) {\n const blockLen = this._encBlockLen;\n\n let pktLen = 4 + 1 + payloadLen;\n let padLen = blockLen - ((pktLen - this._aadLen) & (blockLen - 1));\n if (padLen < 4)\n padLen += blockLen;\n pktLen += padLen;\n\n const packet = Buffer.allocUnsafe(pktLen + this._macLen);\n\n writeUInt32BE(packet, pktLen - 4, 0);\n packet[4] = padLen;\n\n randomFillSync(packet, 5 + payloadLen, padLen);\n\n return packet;\n }\n encrypt(packet) {\n // `packet` === unencrypted packet\n\n if (this._dead)\n return;\n\n // Encrypts in-place\n this._instance.encrypt(packet, this.outSeqno);\n\n if (this._macActualLen < this._macLen) {\n packet = new FastBuffer(packet.buffer,\n packet.byteOffset,\n (packet.length\n - (this._macLen - this._macActualLen)));\n }\n this._onWrite(packet);\n\n this.outSeqno = (this.outSeqno + 1) >>> 0;\n }\n}\n\n\nclass NullDecipher {\n constructor(seqno, onPayload) {\n this.inSeqno = seqno;\n this._onPayload = onPayload;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n while (p < dataLen) {\n // Read packet length\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n\n if (this._lenBytes < 4)\n return;\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (4 + this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._packetPos < this._len) {\n const nb = Math.min(this._len - this._packetPos, dataLen - p);\n let chunk;\n if (p !== 0 || nb !== dataLen)\n chunk = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n chunk = data;\n if (nb === this._len) {\n this._packet = chunk;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(chunk, this._packetPos);\n }\n p += nb;\n this._packetPos += nb;\n if (this._packetPos < this._len)\n return;\n }\n\n const payload = (!this._packet\n ? EMPTY_BUFFER\n : new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length\n - this._packet[0] - 1));\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass ChaChaPolyDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decKeyMain = dec.decipherKey.slice(0, 32);\n this._decKeyPktLen = dec.decipherKey.slice(32);\n this._len = 0;\n this._lenBuf = Buffer.alloc(4);\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(16);\n this._calcMac = Buffer.allocUnsafe(16);\n this._macPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length\n if (this._lenPos < 4) {\n let nb = Math.min(4 - this._lenPos, dataLen - p);\n while (nb--)\n this._lenBuf[this._lenPos++] = data[p++];\n if (this._lenPos < 4)\n return;\n\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.inSeqno, 12);\n\n const decLenBytes =\n createDecipheriv('chacha20', this._decKeyPktLen, POLY1305_OUT_COMPUTE)\n .update(this._lenBuf);\n this._len = readUInt32BE(decLenBytes, 0);\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read Poly1305 MAC\n {\n const nb = Math.min(16 - this._macPos, dataLen - p);\n // TODO: avoid copying if entire MAC is in current chunk\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < 16)\n return;\n }\n\n // Generate Poly1305 key\n POLY1305_OUT_COMPUTE[0] = 0; // Set counter to 0 (little endian)\n writeUInt32BE(POLY1305_OUT_COMPUTE, this.inSeqno, 12);\n const polyKey =\n createCipheriv('chacha20', this._decKeyMain, POLY1305_OUT_COMPUTE)\n .update(POLY1305_ZEROS);\n\n // Calculate and compare Poly1305 MACs\n poly1305_auth(POLY1305_RESULT_MALLOC,\n this._lenBuf,\n 4,\n this._packet,\n this._packet.length,\n polyKey);\n\n this._calcMac.set(\n new Uint8Array(POLY1305_WASM_MODULE.HEAPU8.buffer,\n POLY1305_RESULT_MALLOC,\n 16),\n 0\n );\n if (!timingSafeEqual(this._calcMac, this._mac))\n throw new Error('Invalid MAC');\n\n // Decrypt packet\n POLY1305_OUT_COMPUTE[0] = 1; // Set counter to 1 (little endian)\n const packet =\n createDecipheriv('chacha20', this._decKeyMain, POLY1305_OUT_COMPUTE)\n .update(this._packet);\n\n const payload = new FastBuffer(packet.buffer,\n packet.byteOffset + 1,\n packet.length - packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass ChaChaPolyDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new ChaChaPolyDecipher(dec.decipherKey);\n this._len = 0;\n this._lenBuf = Buffer.alloc(4);\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(16);\n this._macPos = 0;\n }\n free() {\n this._instance.free();\n }\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length\n if (this._lenPos < 4) {\n let nb = Math.min(4 - this._lenPos, dataLen - p);\n while (nb--)\n this._lenBuf[this._lenPos++] = data[p++];\n if (this._lenPos < 4)\n return;\n\n this._len = this._instance.decryptLen(this._lenBuf, this.inSeqno);\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 8\n || (this._len & 7) !== 0) {\n throw new Error('Bad packet length');\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read Poly1305 MAC\n {\n const nb = Math.min(16 - this._macPos, dataLen - p);\n // TODO: avoid copying if entire MAC is in current chunk\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < 16)\n return;\n }\n\n this._instance.decrypt(this._packet, this._mac, this.inSeqno);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenPos = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass AESGCMDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decipherInstance = null;\n this._decipherSSLName = dec.decipherInfo.sslName;\n this._decipherKey = dec.decipherKey;\n this._decipherIV = dec.decipherIV;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._tag = Buffer.allocUnsafe(16);\n this._tagPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length (unencrypted, but AAD)\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n if (this._lenBytes < 4)\n return;\n\n if ((this._len + 20) > MAX_PACKET_SIZE\n || this._len < 16\n || (this._len & 15) !== 0) {\n throw new Error('Bad packet length');\n }\n\n this._decipherInstance = createDecipheriv(\n this._decipherSSLName,\n this._decipherKey,\n this._decipherIV\n );\n this._decipherInstance.setAutoPadding(false);\n this._decipherInstance.setAAD(intToBytes(this._len));\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let decrypted;\n if (p !== 0 || nb !== dataLen) {\n decrypted = this._decipherInstance.update(\n new Uint8Array(data.buffer, data.byteOffset + p, nb)\n );\n } else {\n decrypted = this._decipherInstance.update(data);\n }\n if (decrypted.length) {\n if (nb === this._len) {\n this._packet = decrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(decrypted, this._packetPos);\n }\n this._packetPos += decrypted.length;\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read authentication tag\n {\n const nb = Math.min(16 - this._tagPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._tag.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._tagPos\n );\n } else {\n this._tag.set(data, this._tagPos);\n }\n p += nb;\n this._tagPos += nb;\n if (this._tagPos < 16)\n return;\n }\n\n {\n // Verify authentication tag\n this._decipherInstance.setAuthTag(this._tag);\n\n const decrypted = this._decipherInstance.final();\n\n // XXX: this should never output any data since stream ciphers always\n // return data from .update() and block ciphers must end on a multiple\n // of the block length, which would have caused an exception to be\n // thrown if the total input was not...\n if (decrypted.length) {\n if (this._packet)\n this._packet.set(decrypted, this._packetPos);\n else\n this._packet = decrypted;\n }\n }\n\n const payload = (!this._packet\n ? EMPTY_BUFFER\n : new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length\n - this._packet[0] - 1));\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n ivIncrement(this._decipherIV);\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._tagPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass AESGCMDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new AESGCMDecipher(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV);\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._pktLen = 0;\n this._tag = Buffer.allocUnsafe(16);\n this._tagPos = 0;\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read packet length (unencrypted, but AAD)\n if (this._lenBytes < 4) {\n let nb = Math.min(4 - this._lenBytes, dataLen - p);\n this._lenBytes += nb;\n while (nb--)\n this._len = (this._len << 8) + data[p++];\n if (this._lenBytes < 4)\n return;\n\n if ((this._len + 20) > MAX_PACKET_SIZE\n || this._len < 16\n || (this._len & 15) !== 0) {\n throw new Error(`Bad packet length: ${this._len}`);\n }\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n if (p >= dataLen)\n return;\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read authentication tag\n {\n const nb = Math.min(16 - this._tagPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._tag.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._tagPos\n );\n } else {\n this._tag.set(data, this._tagPos);\n }\n p += nb;\n this._tagPos += nb;\n if (this._tagPos < 16)\n return;\n }\n\n this._instance.decrypt(this._packet, this._len, this._tag);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._len = 0;\n this._lenBytes = 0;\n this._packet = null;\n this._pktLen = 0;\n this._tagPos = 0;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\n// TODO: test incremental .update()s vs. copying to _packet and doing a single\n// .update() after entire packet read -- a single .update() would allow\n// verifying MAC before decrypting for ETM MACs\nclass GenericDecipherNative {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._decipherInstance = createDecipheriv(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV);\n this._decipherInstance.setAutoPadding(false);\n this._block = Buffer.allocUnsafe(\n dec.macInfo.isETM ? 4 : dec.decipherInfo.blockLen\n );\n this._blockSize = dec.decipherInfo.blockLen;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(dec.macInfo.actualLen);\n this._macPos = 0;\n this._macSSLName = dec.macInfo.sslName;\n this._macKey = dec.macKey;\n this._macActualLen = dec.macInfo.actualLen;\n this._macETM = dec.macInfo.isETM;\n this._macInstance = null;\n\n const discardLen = dec.decipherInfo.discardLen;\n if (discardLen) {\n let discard = DISCARD_CACHE.get(discardLen);\n if (discard === undefined) {\n discard = Buffer.alloc(discardLen);\n DISCARD_CACHE.set(discardLen, discard);\n }\n this._decipherInstance.update(discard);\n }\n }\n free() {}\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read first encrypted block\n if (this._blockPos < this._block.length) {\n const nb = Math.min(this._block.length - this._blockPos, dataLen - p);\n if (p !== 0 || nb !== dataLen || nb < data.length) {\n this._block.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._blockPos\n );\n } else {\n this._block.set(data, this._blockPos);\n }\n\n p += nb;\n this._blockPos += nb;\n if (this._blockPos < this._block.length)\n return;\n\n let decrypted;\n let need;\n if (this._macETM) {\n this._len = need = readUInt32BE(this._block, 0);\n } else {\n // Decrypt first block to get packet length\n decrypted = this._decipherInstance.update(this._block);\n this._len = readUInt32BE(decrypted, 0);\n need = 4 + this._len - this._blockSize;\n }\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 5\n || (need & (this._blockSize - 1)) !== 0) {\n throw new Error('Bad packet length');\n }\n\n // Create MAC up front to calculate in parallel with decryption\n this._macInstance = createHmac(this._macSSLName, this._macKey);\n\n writeUInt32BE(BUF_INT, this.inSeqno, 0);\n this._macInstance.update(BUF_INT);\n if (this._macETM) {\n this._macInstance.update(this._block);\n } else {\n this._macInstance.update(new Uint8Array(decrypted.buffer,\n decrypted.byteOffset,\n 4));\n this._pktLen = decrypted.length - 4;\n this._packetPos = this._pktLen;\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(\n new Uint8Array(decrypted.buffer,\n decrypted.byteOffset + 4,\n this._packetPos),\n 0\n );\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (this._macETM)\n this._macInstance.update(encrypted);\n const decrypted = this._decipherInstance.update(encrypted);\n if (decrypted.length) {\n if (nb === this._len) {\n this._packet = decrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(decrypted, this._packetPos);\n }\n this._packetPos += decrypted.length;\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read MAC\n {\n const nb = Math.min(this._macActualLen - this._macPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < this._macActualLen)\n return;\n }\n\n // Verify MAC\n if (!this._macETM)\n this._macInstance.update(this._packet);\n let calculated = this._macInstance.digest();\n if (this._macActualLen < calculated.length) {\n calculated = new Uint8Array(calculated.buffer,\n calculated.byteOffset,\n this._macActualLen);\n }\n if (!timingSafeEquals(calculated, this._mac))\n throw new Error('Invalid MAC');\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._packetPos = 0;\n this._pktLen = 0;\n this._macPos = 0;\n this._macInstance = null;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\nclass GenericDecipherBinding {\n constructor(config) {\n const dec = config.inbound;\n this.inSeqno = dec.seqno;\n this._onPayload = dec.onPayload;\n this._instance = new GenericDecipher(dec.decipherInfo.sslName,\n dec.decipherKey,\n dec.decipherIV,\n dec.macInfo.sslName,\n dec.macKey,\n dec.macInfo.isETM,\n dec.macInfo.actualLen);\n this._block = Buffer.allocUnsafe(\n dec.macInfo.isETM || dec.decipherInfo.stream\n ? 4\n : dec.decipherInfo.blockLen\n );\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._pktLen = 0;\n this._mac = Buffer.allocUnsafe(dec.macInfo.actualLen);\n this._macPos = 0;\n this._macActualLen = dec.macInfo.actualLen;\n this._macETM = dec.macInfo.isETM;\n }\n free() {\n this._instance.free();\n }\n decrypt(data, p, dataLen) {\n // `data` === encrypted data\n\n while (p < dataLen) {\n // Read first encrypted block\n if (this._blockPos < this._block.length) {\n const nb = Math.min(this._block.length - this._blockPos, dataLen - p);\n if (p !== 0 || nb !== dataLen || nb < data.length) {\n this._block.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._blockPos\n );\n } else {\n this._block.set(data, this._blockPos);\n }\n\n p += nb;\n this._blockPos += nb;\n if (this._blockPos < this._block.length)\n return;\n\n let need;\n if (this._macETM) {\n this._len = need = readUInt32BE(this._block, 0);\n } else {\n // Decrypt first block to get packet length\n this._instance.decryptBlock(this._block);\n this._len = readUInt32BE(this._block, 0);\n need = 4 + this._len - this._block.length;\n }\n\n if (this._len > MAX_PACKET_SIZE\n || this._len < 5\n || (need & (this._block.length - 1)) !== 0) {\n throw new Error('Bad packet length');\n }\n\n if (!this._macETM) {\n this._pktLen = (this._block.length - 4);\n if (this._pktLen) {\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(\n new Uint8Array(this._block.buffer,\n this._block.byteOffset + 4,\n this._pktLen),\n 0\n );\n }\n }\n\n if (p >= dataLen)\n return;\n }\n\n // Read padding length, payload, and padding\n if (this._pktLen < this._len) {\n const nb = Math.min(this._len - this._pktLen, dataLen - p);\n let encrypted;\n if (p !== 0 || nb !== dataLen)\n encrypted = new Uint8Array(data.buffer, data.byteOffset + p, nb);\n else\n encrypted = data;\n if (nb === this._len) {\n this._packet = encrypted;\n } else {\n if (!this._packet)\n this._packet = Buffer.allocUnsafe(this._len);\n this._packet.set(encrypted, this._pktLen);\n }\n p += nb;\n this._pktLen += nb;\n if (this._pktLen < this._len || p >= dataLen)\n return;\n }\n\n // Read MAC\n {\n const nb = Math.min(this._macActualLen - this._macPos, dataLen - p);\n if (p !== 0 || nb !== dataLen) {\n this._mac.set(\n new Uint8Array(data.buffer, data.byteOffset + p, nb),\n this._macPos\n );\n } else {\n this._mac.set(data, this._macPos);\n }\n p += nb;\n this._macPos += nb;\n if (this._macPos < this._macActualLen)\n return;\n }\n\n // Decrypt and verify MAC\n this._instance.decrypt(this._packet,\n this.inSeqno,\n this._block,\n this._mac);\n\n const payload = new FastBuffer(this._packet.buffer,\n this._packet.byteOffset + 1,\n this._packet.length - this._packet[0] - 1);\n\n // Prepare for next packet\n this.inSeqno = (this.inSeqno + 1) >>> 0;\n this._blockPos = 0;\n this._len = 0;\n this._packet = null;\n this._pktLen = 0;\n this._macPos = 0;\n this._macInstance = null;\n\n {\n const ret = this._onPayload(payload);\n if (ret !== undefined)\n return (ret === false ? p : ret);\n }\n }\n }\n}\n\n// Increments unsigned, big endian counter (last 8 bytes) of AES-GCM IV\nfunction ivIncrement(iv) {\n // eslint-disable-next-line no-unused-expressions\n ++iv[11] >>> 8\n && ++iv[10] >>> 8\n && ++iv[9] >>> 8\n && ++iv[8] >>> 8\n && ++iv[7] >>> 8\n && ++iv[6] >>> 8\n && ++iv[5] >>> 8\n && ++iv[4] >>> 8;\n}\n\nconst intToBytes = (() => {\n const ret = Buffer.alloc(4);\n return (n) => {\n ret[0] = (n >>> 24);\n ret[1] = (n >>> 16);\n ret[2] = (n >>> 8);\n ret[3] = n;\n return ret;\n };\n})();\n\nfunction timingSafeEquals(a, b) {\n if (a.length !== b.length) {\n timingSafeEqual(a, a);\n return false;\n }\n return timingSafeEqual(a, b);\n}\n\nfunction createCipher(config) {\n if (typeof config !== 'object' || config === null)\n throw new Error('Invalid config');\n\n if (typeof config.outbound !== 'object' || config.outbound === null)\n throw new Error('Invalid outbound');\n\n const outbound = config.outbound;\n\n if (typeof outbound.onWrite !== 'function')\n throw new Error('Invalid outbound.onWrite');\n\n if (typeof outbound.cipherInfo !== 'object' || outbound.cipherInfo === null)\n throw new Error('Invalid outbound.cipherInfo');\n\n if (!Buffer.isBuffer(outbound.cipherKey)\n || outbound.cipherKey.length !== outbound.cipherInfo.keyLen) {\n throw new Error('Invalid outbound.cipherKey');\n }\n\n if (outbound.cipherInfo.ivLen\n && (!Buffer.isBuffer(outbound.cipherIV)\n || outbound.cipherIV.length !== outbound.cipherInfo.ivLen)) {\n throw new Error('Invalid outbound.cipherIV');\n }\n\n if (typeof outbound.seqno !== 'number'\n || outbound.seqno < 0\n || outbound.seqno > MAX_SEQNO) {\n throw new Error('Invalid outbound.seqno');\n }\n\n const forceNative = !!outbound.forceNative;\n\n switch (outbound.cipherInfo.sslName) {\n case 'aes-128-gcm':\n case 'aes-256-gcm':\n return (AESGCMCipher && !forceNative\n ? new AESGCMCipherBinding(config)\n : new AESGCMCipherNative(config));\n case 'chacha20':\n return (ChaChaPolyCipher && !forceNative\n ? new ChaChaPolyCipherBinding(config)\n : new ChaChaPolyCipherNative(config));\n default: {\n if (typeof outbound.macInfo !== 'object' || outbound.macInfo === null)\n throw new Error('Invalid outbound.macInfo');\n if (!Buffer.isBuffer(outbound.macKey)\n || outbound.macKey.length !== outbound.macInfo.len) {\n throw new Error('Invalid outbound.macKey');\n }\n return (GenericCipher && !forceNative\n ? new GenericCipherBinding(config)\n : new GenericCipherNative(config));\n }\n }\n}\n\nfunction createDecipher(config) {\n if (typeof config !== 'object' || config === null)\n throw new Error('Invalid config');\n\n if (typeof config.inbound !== 'object' || config.inbound === null)\n throw new Error('Invalid inbound');\n\n const inbound = config.inbound;\n\n if (typeof inbound.onPayload !== 'function')\n throw new Error('Invalid inbound.onPayload');\n\n if (typeof inbound.decipherInfo !== 'object'\n || inbound.decipherInfo === null) {\n throw new Error('Invalid inbound.decipherInfo');\n }\n\n if (!Buffer.isBuffer(inbound.decipherKey)\n || inbound.decipherKey.length !== inbound.decipherInfo.keyLen) {\n throw new Error('Invalid inbound.decipherKey');\n }\n\n if (inbound.decipherInfo.ivLen\n && (!Buffer.isBuffer(inbound.decipherIV)\n || inbound.decipherIV.length !== inbound.decipherInfo.ivLen)) {\n throw new Error('Invalid inbound.decipherIV');\n }\n\n if (typeof inbound.seqno !== 'number'\n || inbound.seqno < 0\n || inbound.seqno > MAX_SEQNO) {\n throw new Error('Invalid inbound.seqno');\n }\n\n const forceNative = !!inbound.forceNative;\n\n switch (inbound.decipherInfo.sslName) {\n case 'aes-128-gcm':\n case 'aes-256-gcm':\n return (AESGCMDecipher && !forceNative\n ? new AESGCMDecipherBinding(config)\n : new AESGCMDecipherNative(config));\n case 'chacha20':\n return (ChaChaPolyDecipher && !forceNative\n ? new ChaChaPolyDecipherBinding(config)\n : new ChaChaPolyDecipherNative(config));\n default: {\n if (typeof inbound.macInfo !== 'object' || inbound.macInfo === null)\n throw new Error('Invalid inbound.macInfo');\n if (!Buffer.isBuffer(inbound.macKey)\n || inbound.macKey.length !== inbound.macInfo.len) {\n throw new Error('Invalid inbound.macKey');\n }\n return (GenericDecipher && !forceNative\n ? new GenericDecipherBinding(config)\n : new GenericDecipherNative(config));\n }\n }\n}\n\nmodule.exports = {\n CIPHER_INFO,\n MAC_INFO,\n bindingAvailable: !!binding,\n init: (() => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n try {\n POLY1305_WASM_MODULE = await require('./crypto/poly1305.js')();\n POLY1305_RESULT_MALLOC = POLY1305_WASM_MODULE._malloc(16);\n poly1305_auth = POLY1305_WASM_MODULE.cwrap(\n 'poly1305_auth',\n null,\n ['number', 'array', 'number', 'array', 'number', 'array']\n );\n } catch (ex) {\n return reject(ex);\n }\n resolve();\n });\n })(),\n\n NullCipher,\n createCipher,\n NullDecipher,\n createDecipher,\n};\n","\nvar createPoly1305 = (function() {\n var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;\n if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;\n return (\nfunction(createPoly1305) {\n createPoly1305 = createPoly1305 || {};\n\n\nvar b;b||(b=typeof createPoly1305 !== 'undefined' ? createPoly1305 : {});var q,r;b.ready=new Promise(function(a,c){q=a;r=c});var u={},w;for(w in b)b.hasOwnProperty(w)&&(u[w]=b[w]);var x=\"object\"===typeof window,y=\"function\"===typeof importScripts,z=\"object\"===typeof process&&\"object\"===typeof process.versions&&\"string\"===typeof process.versions.node,B=\"\",C,D,E,F,G;\nif(z)B=y?require(\"path\").dirname(B)+\"/\":__dirname+\"/\",C=function(a,c){var d=H(a);if(d)return c?d:d.toString();F||(F=require(\"fs\"));G||(G=require(\"path\"));a=G.normalize(a);return F.readFileSync(a,c?null:\"utf8\")},E=function(a){a=C(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},D=function(a,c,d){var e=H(a);e&&c(e);F||(F=require(\"fs\"));G||(G=require(\"path\"));a=G.normalize(a);F.readFile(a,function(f,l){f?d(f):c(l.buffer)})},1=m){var oa=g.charCodeAt(++v);m=65536+((m&1023)<<10)|oa&1023}if(127>=m){if(k>=n)break;h[k++]=m}else{if(2047>=m){if(k+1>=n)break;h[k++]=192|m>>6}else{if(65535>=m){if(k+2>=n)break;h[k++]=224|m>>12}else{if(k+3>=n)break;h[k++]=240|m>>18;h[k++]=128|m>>12&63}h[k++]=128|m>>6&63}h[k++]=128|m&63}}h[k]=\n0}}return p},array:function(g){var p=O(g.length);Q.set(g,p);return p}},l=N(a),A=[];a=0;if(e)for(var t=0;t=n);)++k;if(16h?n+=String.fromCharCode(h):(h-=65536,n+=String.fromCharCode(55296|h>>10,56320|h&1023))}}else n+=String.fromCharCode(h)}g=n}}else g=\"\";else g=\"boolean\"===c?!!g:g;return g}(d);0!==a&&fa(a);return d}var ea=\"undefined\"!==typeof TextDecoder?new TextDecoder(\"utf8\"):void 0,ha,Q,P;\nfunction ia(){var a=L.buffer;ha=a;b.HEAP8=Q=new Int8Array(a);b.HEAP16=new Int16Array(a);b.HEAP32=new Int32Array(a);b.HEAPU8=P=new Uint8Array(a);b.HEAPU16=new Uint16Array(a);b.HEAPU32=new Uint32Array(a);b.HEAPF32=new Float32Array(a);b.HEAPF64=new Float64Array(a)}var R,ja=[],ka=[],la=[];function ma(){var a=b.preRun.shift();ja.unshift(a)}var S=0,T=null,U=null;b.preloadedImages={};b.preloadedAudios={};\nfunction K(a){if(b.onAbort)b.onAbort(a);I(a);M=!0;a=new WebAssembly.RuntimeError(\"abort(\"+a+\"). Build with -s ASSERTIONS=1 for more info.\");r(a);throw a;}var V=\"data:application/octet-stream;base64,\",W;W=\"data:application/octet-stream;base64,AGFzbQEAAAABIAZgAX8Bf2ADf39/AGABfwBgAABgAAF/YAZ/f39/f38AAgcBAWEBYQAAAwsKAAEDAQAAAgQFAgQFAXABAQEFBwEBgAKAgAIGCQF/AUGAjMACCwclCQFiAgABYwADAWQACQFlAAgBZgAHAWcABgFoAAUBaQAKAWoBAAqGTQpPAQJ/QYAIKAIAIgEgAEEDakF8cSICaiEAAkAgAkEAIAAgAU0bDQAgAD8AQRB0SwRAIAAQAEUNAQtBgAggADYCACABDwtBhAhBMDYCAEF/C4wFAg5+Cn8gACgCJCEUIAAoAiAhFSAAKAIcIREgACgCGCESIAAoAhQhEyACQRBPBEAgAC0ATEVBGHQhFyAAKAIEIhZBBWytIQ8gACgCCCIYQQVsrSENIAAoAgwiGUEFbK0hCyAAKAIQIhpBBWytIQkgADUCACEIIBqtIRAgGa0hDiAYrSEMIBatIQoDQCASIAEtAAMiEiABLQAEQQh0ciABLQAFQRB0ciABLQAGIhZBGHRyQQJ2Qf///x9xaq0iAyAOfiABLwAAIAEtAAJBEHRyIBNqIBJBGHRBgICAGHFqrSIEIBB+fCARIAEtAAdBCHQgFnIgAS0ACEEQdHIgAS0ACSIRQRh0ckEEdkH///8fcWqtIgUgDH58IAEtAApBCHQgEXIgAS0AC0EQdHIgAS0ADEEYdHJBBnYgFWqtIgYgCn58IBQgF2ogAS8ADSABLQAPQRB0cmqtIgcgCH58IAMgDH4gBCAOfnwgBSAKfnwgBiAIfnwgByAJfnwgAyAKfiAEIAx+fCAFIAh+fCAGIAl+fCAHIAt+fCADIAh+IAQgCn58IAUgCX58IAYgC358IAcgDX58IAMgCX4gBCAIfnwgBSALfnwgBiANfnwgByAPfnwiA0IaiEL/////D4N8IgRCGohC/////w+DfCIFQhqIQv////8Pg3wiBkIaiEL/////D4N8IgdCGoinQQVsIAOnQf///x9xaiITQRp2IASnQf///x9xaiESIAWnQf///x9xIREgBqdB////H3EhFSAHp0H///8fcSEUIBNB////H3EhEyABQRBqIQEgAkEQayICQQ9LDQALCyAAIBQ2AiQgACAVNgIgIAAgETYCHCAAIBI2AhggACATNgIUCwMAAQu2BAEGfwJAIAAoAjgiBARAIABBPGohBQJAIAJBECAEayIDIAIgA0kbIgZFDQAgBkEDcSEHAkAgBkEBa0EDSQRAQQAhAwwBCyAGQXxxIQhBACEDA0AgBSADIARqaiABIANqLQAAOgAAIAUgA0EBciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0ECciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0EDciIEIAAoAjhqaiABIARqLQAAOgAAIANBBGohAyAAKAI4IQQgCEEEayIIDQALCyAHRQ0AA0AgBSADIARqaiABIANqLQAAOgAAIANBAWohAyAAKAI4IQQgB0EBayIHDQALCyAAIAQgBmoiAzYCOCADQRBJDQEgACAFQRAQAiAAQQA2AjggAiAGayECIAEgBmohAQsgAkEQTwRAIAAgASACQXBxIgMQAiACQQ9xIQIgASADaiEBCyACRQ0AIAJBA3EhBCAAQTxqIQVBACEDIAJBAWtBA08EQCACQXxxIQcDQCAFIAAoAjggA2pqIAEgA2otAAA6AAAgBSADQQFyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQJyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQNyIgYgACgCOGpqIAEgBmotAAA6AAAgA0EEaiEDIAdBBGsiBw0ACwsgBARAA0AgBSAAKAI4IANqaiABIANqLQAAOgAAIANBAWohAyAEQQFrIgQNAAsLIAAgACgCOCACajYCOAsLoS0BDH8jAEEQayIMJAACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAEH0AU0EQEGICCgCACIFQRAgAEELakF4cSAAQQtJGyIIQQN2IgJ2IgFBA3EEQCABQX9zQQFxIAJqIgNBA3QiAUG4CGooAgAiBEEIaiEAAkAgBCgCCCICIAFBsAhqIgFGBEBBiAggBUF+IAN3cTYCAAwBCyACIAE2AgwgASACNgIICyAEIANBA3QiAUEDcjYCBCABIARqIgEgASgCBEEBcjYCBAwNCyAIQZAIKAIAIgpNDQEgAQRAAkBBAiACdCIAQQAgAGtyIAEgAnRxIgBBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2aiIDQQN0IgBBuAhqKAIAIgQoAggiASAAQbAIaiIARgRAQYgIIAVBfiADd3EiBTYCAAwBCyABIAA2AgwgACABNgIICyAEQQhqIQAgBCAIQQNyNgIEIAQgCGoiAiADQQN0IgEgCGsiA0EBcjYCBCABIARqIAM2AgAgCgRAIApBA3YiAUEDdEGwCGohB0GcCCgCACEEAn8gBUEBIAF0IgFxRQRAQYgIIAEgBXI2AgAgBwwBCyAHKAIICyEBIAcgBDYCCCABIAQ2AgwgBCAHNgIMIAQgATYCCAtBnAggAjYCAEGQCCADNgIADA0LQYwIKAIAIgZFDQEgBkEAIAZrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QbgKaigCACIBKAIEQXhxIAhrIQMgASECA0ACQCACKAIQIgBFBEAgAigCFCIARQ0BCyAAKAIEQXhxIAhrIgIgAyACIANJIgIbIQMgACABIAIbIQEgACECDAELCyABIAhqIgkgAU0NAiABKAIYIQsgASABKAIMIgRHBEAgASgCCCIAQZgIKAIASRogACAENgIMIAQgADYCCAwMCyABQRRqIgIoAgAiAEUEQCABKAIQIgBFDQQgAUEQaiECCwNAIAIhByAAIgRBFGoiAigCACIADQAgBEEQaiECIAQoAhAiAA0ACyAHQQA2AgAMCwtBfyEIIABBv39LDQAgAEELaiIAQXhxIQhBjAgoAgAiCUUNAEEAIAhrIQMCQAJAAkACf0EAIAhBgAJJDQAaQR8gCEH///8HSw0AGiAAQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgCCAAQRVqdkEBcXJBHGoLIgVBAnRBuApqKAIAIgJFBEBBACEADAELQQAhACAIQQBBGSAFQQF2ayAFQR9GG3QhAQNAAkAgAigCBEF4cSAIayIHIANPDQAgAiEEIAciAw0AQQAhAyACIQAMAwsgACACKAIUIgcgByACIAFBHXZBBHFqKAIQIgJGGyAAIAcbIQAgAUEBdCEBIAINAAsLIAAgBHJFBEBBACEEQQIgBXQiAEEAIABrciAJcSIARQ0DIABBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2akECdEG4CmooAgAhAAsgAEUNAQsDQCAAKAIEQXhxIAhrIgEgA0khAiABIAMgAhshAyAAIAQgAhshBCAAKAIQIgEEfyABBSAAKAIUCyIADQALCyAERQ0AIANBkAgoAgAgCGtPDQAgBCAIaiIGIARNDQEgBCgCGCEFIAQgBCgCDCIBRwRAIAQoAggiAEGYCCgCAEkaIAAgATYCDCABIAA2AggMCgsgBEEUaiICKAIAIgBFBEAgBCgCECIARQ0EIARBEGohAgsDQCACIQcgACIBQRRqIgIoAgAiAA0AIAFBEGohAiABKAIQIgANAAsgB0EANgIADAkLIAhBkAgoAgAiAk0EQEGcCCgCACEDAkAgAiAIayIBQRBPBEBBkAggATYCAEGcCCADIAhqIgA2AgAgACABQQFyNgIEIAIgA2ogATYCACADIAhBA3I2AgQMAQtBnAhBADYCAEGQCEEANgIAIAMgAkEDcjYCBCACIANqIgAgACgCBEEBcjYCBAsgA0EIaiEADAsLIAhBlAgoAgAiBkkEQEGUCCAGIAhrIgE2AgBBoAhBoAgoAgAiAiAIaiIANgIAIAAgAUEBcjYCBCACIAhBA3I2AgQgAkEIaiEADAsLQQAhACAIQS9qIgkCf0HgCygCAARAQegLKAIADAELQewLQn83AgBB5AtCgKCAgICABDcCAEHgCyAMQQxqQXBxQdiq1aoFczYCAEH0C0EANgIAQcQLQQA2AgBBgCALIgFqIgVBACABayIHcSICIAhNDQpBwAsoAgAiBARAQbgLKAIAIgMgAmoiASADTQ0LIAEgBEsNCwtBxAstAABBBHENBQJAAkBBoAgoAgAiAwRAQcgLIQADQCADIAAoAgAiAU8EQCABIAAoAgRqIANLDQMLIAAoAggiAA0ACwtBABABIgFBf0YNBiACIQVB5AsoAgAiA0EBayIAIAFxBEAgAiABayAAIAFqQQAgA2txaiEFCyAFIAhNDQYgBUH+////B0sNBkHACygCACIEBEBBuAsoAgAiAyAFaiIAIANNDQcgACAESw0HCyAFEAEiACABRw0BDAgLIAUgBmsgB3EiBUH+////B0sNBSAFEAEiASAAKAIAIAAoAgRqRg0EIAEhAAsCQCAAQX9GDQAgCEEwaiAFTQ0AQegLKAIAIgEgCSAFa2pBACABa3EiAUH+////B0sEQCAAIQEMCAsgARABQX9HBEAgASAFaiEFIAAhAQwIC0EAIAVrEAEaDAULIAAiAUF/Rw0GDAQLAAtBACEEDAcLQQAhAQwFCyABQX9HDQILQcQLQcQLKAIAQQRyNgIACyACQf7///8HSw0BIAIQASEBQQAQASEAIAFBf0YNASAAQX9GDQEgACABTQ0BIAAgAWsiBSAIQShqTQ0BC0G4C0G4CygCACAFaiIANgIAQbwLKAIAIABJBEBBvAsgADYCAAsCQAJAAkBBoAgoAgAiBwRAQcgLIQADQCABIAAoAgAiAyAAKAIEIgJqRg0CIAAoAggiAA0ACwwCC0GYCCgCACIAQQAgACABTRtFBEBBmAggATYCAAtBACEAQcwLIAU2AgBByAsgATYCAEGoCEF/NgIAQawIQeALKAIANgIAQdQLQQA2AgADQCAAQQN0IgNBuAhqIANBsAhqIgI2AgAgA0G8CGogAjYCACAAQQFqIgBBIEcNAAtBlAggBUEoayIDQXggAWtBB3FBACABQQhqQQdxGyIAayICNgIAQaAIIAAgAWoiADYCACAAIAJBAXI2AgQgASADakEoNgIEQaQIQfALKAIANgIADAILIAAtAAxBCHENACADIAdLDQAgASAHTQ0AIAAgAiAFajYCBEGgCCAHQXggB2tBB3FBACAHQQhqQQdxGyIAaiICNgIAQZQIQZQIKAIAIAVqIgEgAGsiADYCACACIABBAXI2AgQgASAHakEoNgIEQaQIQfALKAIANgIADAELQZgIKAIAIAFLBEBBmAggATYCAAsgASAFaiECQcgLIQACQAJAAkACQAJAAkADQCACIAAoAgBHBEAgACgCCCIADQEMAgsLIAAtAAxBCHFFDQELQcgLIQADQCAHIAAoAgAiAk8EQCACIAAoAgRqIgQgB0sNAwsgACgCCCEADAALAAsgACABNgIAIAAgACgCBCAFajYCBCABQXggAWtBB3FBACABQQhqQQdxG2oiCSAIQQNyNgIEIAJBeCACa0EHcUEAIAJBCGpBB3EbaiIFIAggCWoiBmshAiAFIAdGBEBBoAggBjYCAEGUCEGUCCgCACACaiIANgIAIAYgAEEBcjYCBAwDCyAFQZwIKAIARgRAQZwIIAY2AgBBkAhBkAgoAgAgAmoiADYCACAGIABBAXI2AgQgACAGaiAANgIADAMLIAUoAgQiAEEDcUEBRgRAIABBeHEhBwJAIABB/wFNBEAgBSgCCCIDIABBA3YiAEEDdEGwCGpGGiADIAUoAgwiAUYEQEGICEGICCgCAEF+IAB3cTYCAAwCCyADIAE2AgwgASADNgIIDAELIAUoAhghCAJAIAUgBSgCDCIBRwRAIAUoAggiACABNgIMIAEgADYCCAwBCwJAIAVBFGoiACgCACIDDQAgBUEQaiIAKAIAIgMNAEEAIQEMAQsDQCAAIQQgAyIBQRRqIgAoAgAiAw0AIAFBEGohACABKAIQIgMNAAsgBEEANgIACyAIRQ0AAkAgBSAFKAIcIgNBAnRBuApqIgAoAgBGBEAgACABNgIAIAENAUGMCEGMCCgCAEF+IAN3cTYCAAwCCyAIQRBBFCAIKAIQIAVGG2ogATYCACABRQ0BCyABIAg2AhggBSgCECIABEAgASAANgIQIAAgATYCGAsgBSgCFCIARQ0AIAEgADYCFCAAIAE2AhgLIAUgB2ohBSACIAdqIQILIAUgBSgCBEF+cTYCBCAGIAJBAXI2AgQgAiAGaiACNgIAIAJB/wFNBEAgAkEDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwDC0EfIQAgAkH///8HTQRAIAJBCHYiACAAQYD+P2pBEHZBCHEiA3QiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASADciAAcmsiAEEBdCACIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQQCQEGMCCgCACIDQQEgAHQiAXFFBEBBjAggASADcjYCACAEIAY2AgAgBiAENgIYDAELIAJBAEEZIABBAXZrIABBH0YbdCEAIAQoAgAhAQNAIAEiAygCBEF4cSACRg0DIABBHXYhASAAQQF0IQAgAyABQQRxaiIEKAIQIgENAAsgBCAGNgIQIAYgAzYCGAsgBiAGNgIMIAYgBjYCCAwCC0GUCCAFQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBBoAggACABaiIANgIAIAAgAkEBcjYCBCABIANqQSg2AgRBpAhB8AsoAgA2AgAgByAEQScgBGtBB3FBACAEQSdrQQdxG2pBL2siACAAIAdBEGpJGyICQRs2AgQgAkHQCykCADcCECACQcgLKQIANwIIQdALIAJBCGo2AgBBzAsgBTYCAEHICyABNgIAQdQLQQA2AgAgAkEYaiEAA0AgAEEHNgIEIABBCGohASAAQQRqIQAgASAESQ0ACyACIAdGDQMgAiACKAIEQX5xNgIEIAcgAiAHayIEQQFyNgIEIAIgBDYCACAEQf8BTQRAIARBA3YiAEEDdEGwCGohAgJ/QYgIKAIAIgFBASAAdCIAcUUEQEGICCAAIAFyNgIAIAIMAQsgAigCCAshACACIAc2AgggACAHNgIMIAcgAjYCDCAHIAA2AggMBAtBHyEAIAdCADcCECAEQf///wdNBEAgBEEIdiIAIABBgP4/akEQdkEIcSICdCIAIABBgOAfakEQdkEEcSIBdCIAIABBgIAPakEQdkECcSIAdEEPdiABIAJyIAByayIAQQF0IAQgAEEVanZBAXFyQRxqIQALIAcgADYCHCAAQQJ0QbgKaiEDAkBBjAgoAgAiAkEBIAB0IgFxRQRAQYwIIAEgAnI2AgAgAyAHNgIAIAcgAzYCGAwBCyAEQQBBGSAAQQF2ayAAQR9GG3QhACADKAIAIQEDQCABIgIoAgRBeHEgBEYNBCAAQR12IQEgAEEBdCEAIAIgAUEEcWoiAygCECIBDQALIAMgBzYCECAHIAI2AhgLIAcgBzYCDCAHIAc2AggMAwsgAygCCCIAIAY2AgwgAyAGNgIIIAZBADYCGCAGIAM2AgwgBiAANgIICyAJQQhqIQAMBQsgAigCCCIAIAc2AgwgAiAHNgIIIAdBADYCGCAHIAI2AgwgByAANgIIC0GUCCgCACIAIAhNDQBBlAggACAIayIBNgIAQaAIQaAIKAIAIgIgCGoiADYCACAAIAFBAXI2AgQgAiAIQQNyNgIEIAJBCGohAAwDC0GECEEwNgIAQQAhAAwCCwJAIAVFDQACQCAEKAIcIgJBAnRBuApqIgAoAgAgBEYEQCAAIAE2AgAgAQ0BQYwIIAlBfiACd3EiCTYCAAwCCyAFQRBBFCAFKAIQIARGG2ogATYCACABRQ0BCyABIAU2AhggBCgCECIABEAgASAANgIQIAAgATYCGAsgBCgCFCIARQ0AIAEgADYCFCAAIAE2AhgLAkAgA0EPTQRAIAQgAyAIaiIAQQNyNgIEIAAgBGoiACAAKAIEQQFyNgIEDAELIAQgCEEDcjYCBCAGIANBAXI2AgQgAyAGaiADNgIAIANB/wFNBEAgA0EDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwBC0EfIQAgA0H///8HTQRAIANBCHYiACAAQYD+P2pBEHZBCHEiAnQiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASACciAAcmsiAEEBdCADIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQICQAJAIAlBASAAdCIBcUUEQEGMCCABIAlyNgIAIAIgBjYCACAGIAI2AhgMAQsgA0EAQRkgAEEBdmsgAEEfRht0IQAgAigCACEIA0AgCCIBKAIEQXhxIANGDQIgAEEddiECIABBAXQhACABIAJBBHFqIgIoAhAiCA0ACyACIAY2AhAgBiABNgIYCyAGIAY2AgwgBiAGNgIIDAELIAEoAggiACAGNgIMIAEgBjYCCCAGQQA2AhggBiABNgIMIAYgADYCCAsgBEEIaiEADAELAkAgC0UNAAJAIAEoAhwiAkECdEG4CmoiACgCACABRgRAIAAgBDYCACAEDQFBjAggBkF+IAJ3cTYCAAwCCyALQRBBFCALKAIQIAFGG2ogBDYCACAERQ0BCyAEIAs2AhggASgCECIABEAgBCAANgIQIAAgBDYCGAsgASgCFCIARQ0AIAQgADYCFCAAIAQ2AhgLAkAgA0EPTQRAIAEgAyAIaiIAQQNyNgIEIAAgAWoiACAAKAIEQQFyNgIEDAELIAEgCEEDcjYCBCAJIANBAXI2AgQgAyAJaiADNgIAIAoEQCAKQQN2IgBBA3RBsAhqIQRBnAgoAgAhAgJ/QQEgAHQiACAFcUUEQEGICCAAIAVyNgIAIAQMAQsgBCgCCAshACAEIAI2AgggACACNgIMIAIgBDYCDCACIAA2AggLQZwIIAk2AgBBkAggAzYCAAsgAUEIaiEACyAMQRBqJAAgAAsQACMAIABrQXBxIgAkACAACwYAIAAkAAsEACMAC4AJAgh/BH4jAEGQAWsiBiQAIAYgBS0AA0EYdEGAgIAYcSAFLwAAIAUtAAJBEHRycjYCACAGIAUoAANBAnZBg/7/H3E2AgQgBiAFKAAGQQR2Qf+B/x9xNgIIIAYgBSgACUEGdkH//8AfcTYCDCAFLwANIQggBS0ADyEJIAZCADcCFCAGQgA3AhwgBkEANgIkIAYgCCAJQRB0QYCAPHFyNgIQIAYgBSgAEDYCKCAGIAUoABQ2AiwgBiAFKAAYNgIwIAUoABwhBSAGQQA6AEwgBkEANgI4IAYgBTYCNCAGIAEgAhAEIAQEQCAGIAMgBBAECyAGKAI4IgEEQCAGQTxqIgIgAWpBAToAACABQQFqQQ9NBEAgASAGakE9aiEEAkBBDyABayIDRQ0AIAMgBGoiAUEBa0EAOgAAIARBADoAACADQQNJDQAgAUECa0EAOgAAIARBADoAASABQQNrQQA6AAAgBEEAOgACIANBB0kNACABQQRrQQA6AAAgBEEAOgADIANBCUkNACAEQQAgBGtBA3EiAWoiBEEANgIAIAQgAyABa0F8cSIBaiIDQQRrQQA2AgAgAUEJSQ0AIARBADYCCCAEQQA2AgQgA0EIa0EANgIAIANBDGtBADYCACABQRlJDQAgBEEANgIYIARBADYCFCAEQQA2AhAgBEEANgIMIANBEGtBADYCACADQRRrQQA2AgAgA0EYa0EANgIAIANBHGtBADYCACABIARBBHFBGHIiAWsiA0EgSQ0AIAEgBGohAQNAIAFCADcDGCABQgA3AxAgAUIANwMIIAFCADcDACABQSBqIQEgA0EgayIDQR9LDQALCwsgBkEBOgBMIAYgAkEQEAILIAY1AjQhECAGNQIwIREgBjUCLCEOIAAgBjUCKCAGKAIkIAYoAiAgBigCHCAGKAIYIgNBGnZqIgJBGnZqIgFBGnZqIgtBgICAYHIgAUH///8fcSINIAJB////H3EiCCAGKAIUIAtBGnZBBWxqIgFB////H3EiCUEFaiIFQRp2IANB////H3EgAUEadmoiA2oiAUEadmoiAkEadmoiBEEadmoiDEEfdSIHIANxIAEgDEEfdkEBayIDQf///x9xIgpxciIBQRp0IAUgCnEgByAJcXJyrXwiDzwAACAAIA9CGIg8AAMgACAPQhCIPAACIAAgD0IIiDwAASAAIA4gByAIcSACIApxciICQRR0IAFBBnZyrXwgD0IgiHwiDjwABCAAIA5CGIg8AAcgACAOQhCIPAAGIAAgDkIIiDwABSAAIBEgByANcSAEIApxciIBQQ50IAJBDHZyrXwgDkIgiHwiDjwACCAAIA5CGIg8AAsgACAOQhCIPAAKIAAgDkIIiDwACSAAIBAgAyAMcSAHIAtxckEIdCABQRJ2cq18IA5CIIh8Ig48AAwgACAOQhiIPAAPIAAgDkIQiDwADiAAIA5CCIg8AA0gBkIANwIwIAZCADcCKCAGQgA3AiAgBkIANwIYIAZCADcCECAGQgA3AgggBkIANwIAIAZBkAFqJAALpwwBB38CQCAARQ0AIABBCGsiAyAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQNxRQ0BIAMgAygCACIBayIDQZgIKAIASQ0BIAAgAWohACADQZwIKAIARwRAIAFB/wFNBEAgAygCCCICIAFBA3YiBEEDdEGwCGpGGiACIAMoAgwiAUYEQEGICEGICCgCAEF+IAR3cTYCAAwDCyACIAE2AgwgASACNgIIDAILIAMoAhghBgJAIAMgAygCDCIBRwRAIAMoAggiAiABNgIMIAEgAjYCCAwBCwJAIANBFGoiAigCACIEDQAgA0EQaiICKAIAIgQNAEEAIQEMAQsDQCACIQcgBCIBQRRqIgIoAgAiBA0AIAFBEGohAiABKAIQIgQNAAsgB0EANgIACyAGRQ0BAkAgAyADKAIcIgJBAnRBuApqIgQoAgBGBEAgBCABNgIAIAENAUGMCEGMCCgCAEF+IAJ3cTYCAAwDCyAGQRBBFCAGKAIQIANGG2ogATYCACABRQ0CCyABIAY2AhggAygCECICBEAgASACNgIQIAIgATYCGAsgAygCFCICRQ0BIAEgAjYCFCACIAE2AhgMAQsgBSgCBCIBQQNxQQNHDQBBkAggADYCACAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAA8LIAMgBU8NACAFKAIEIgFBAXFFDQACQCABQQJxRQRAIAVBoAgoAgBGBEBBoAggAzYCAEGUCEGUCCgCACAAaiIANgIAIAMgAEEBcjYCBCADQZwIKAIARw0DQZAIQQA2AgBBnAhBADYCAA8LIAVBnAgoAgBGBEBBnAggAzYCAEGQCEGQCCgCACAAaiIANgIAIAMgAEEBcjYCBCAAIANqIAA2AgAPCyABQXhxIABqIQACQCABQf8BTQRAIAUoAggiAiABQQN2IgRBA3RBsAhqRhogAiAFKAIMIgFGBEBBiAhBiAgoAgBBfiAEd3E2AgAMAgsgAiABNgIMIAEgAjYCCAwBCyAFKAIYIQYCQCAFIAUoAgwiAUcEQCAFKAIIIgJBmAgoAgBJGiACIAE2AgwgASACNgIIDAELAkAgBUEUaiICKAIAIgQNACAFQRBqIgIoAgAiBA0AQQAhAQwBCwNAIAIhByAEIgFBFGoiAigCACIEDQAgAUEQaiECIAEoAhAiBA0ACyAHQQA2AgALIAZFDQACQCAFIAUoAhwiAkECdEG4CmoiBCgCAEYEQCAEIAE2AgAgAQ0BQYwIQYwIKAIAQX4gAndxNgIADAILIAZBEEEUIAYoAhAgBUYbaiABNgIAIAFFDQELIAEgBjYCGCAFKAIQIgIEQCABIAI2AhAgAiABNgIYCyAFKAIUIgJFDQAgASACNgIUIAIgATYCGAsgAyAAQQFyNgIEIAAgA2ogADYCACADQZwIKAIARw0BQZAIIAA2AgAPCyAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAAsgAEH/AU0EQCAAQQN2IgFBA3RBsAhqIQACf0GICCgCACICQQEgAXQiAXFFBEBBiAggASACcjYCACAADAELIAAoAggLIQIgACADNgIIIAIgAzYCDCADIAA2AgwgAyACNgIIDwtBHyECIANCADcCECAAQf///wdNBEAgAEEIdiIBIAFBgP4/akEQdkEIcSIBdCICIAJBgOAfakEQdkEEcSICdCIEIARBgIAPakEQdkECcSIEdEEPdiABIAJyIARyayIBQQF0IAAgAUEVanZBAXFyQRxqIQILIAMgAjYCHCACQQJ0QbgKaiEBAkACQAJAQYwIKAIAIgRBASACdCIHcUUEQEGMCCAEIAdyNgIAIAEgAzYCACADIAE2AhgMAQsgAEEAQRkgAkEBdmsgAkEfRht0IQIgASgCACEBA0AgASIEKAIEQXhxIABGDQIgAkEddiEBIAJBAXQhAiAEIAFBBHFqIgdBEGooAgAiAQ0ACyAHIAM2AhAgAyAENgIYCyADIAM2AgwgAyADNgIIDAELIAQoAggiACADNgIMIAQgAzYCCCADQQA2AhggAyAENgIMIAMgADYCCAtBqAhBqAgoAgBBAWsiAEF/IAAbNgIACwsLCQEAQYEICwIGUA==\";if(!W.startsWith(V)){var na=W;W=b.locateFile?b.locateFile(na,B):B+na}function pa(){var a=W;try{if(a==W&&J)return new Uint8Array(J);var c=H(a);if(c)return c;if(E)return E(a);throw\"both async and sync fetching of the wasm failed\";}catch(d){K(d)}}\nfunction qa(){if(!J&&(x||y)){if(\"function\"===typeof fetch&&!W.startsWith(\"file://\"))return fetch(W,{credentials:\"same-origin\"}).then(function(a){if(!a.ok)throw\"failed to load wasm binary file at '\"+W+\"'\";return a.arrayBuffer()}).catch(function(){return pa()});if(D)return new Promise(function(a,c){D(W,function(d){a(new Uint8Array(d))},c)})}return Promise.resolve().then(function(){return pa()})}\nfunction X(a){for(;0>4;f=(f&15)<<4|l>>2;var t=(l&3)<<6|A;c+=String.fromCharCode(e);64!==l&&(c+=String.fromCharCode(f));64!==A&&(c+=String.fromCharCode(t))}while(d>>=0;if(2147483648=d;d*=2){var e=c*(1+.2/d);e=Math.min(e,a+100663296);e=Math.max(a,e);0>>16);ia();var f=1;break a}catch(l){}f=void 0}if(f)return!0}return!1}};\n(function(){function a(f){b.asm=f.exports;L=b.asm.b;ia();R=b.asm.j;ka.unshift(b.asm.c);S--;b.monitorRunDependencies&&b.monitorRunDependencies(S);0==S&&(null!==T&&(clearInterval(T),T=null),U&&(f=U,U=null,f()))}function c(f){a(f.instance)}function d(f){return qa().then(function(l){return WebAssembly.instantiate(l,e)}).then(f,function(l){I(\"failed to asynchronously prepare wasm: \"+l);K(l)})}var e={a:sa};S++;b.monitorRunDependencies&&b.monitorRunDependencies(S);if(b.instantiateWasm)try{return b.instantiateWasm(e,\na)}catch(f){return I(\"Module.instantiateWasm callback failed with error: \"+f),!1}(function(){return J||\"function\"!==typeof WebAssembly.instantiateStreaming||W.startsWith(V)||W.startsWith(\"file://\")||\"function\"!==typeof fetch?d(c):fetch(W,{credentials:\"same-origin\"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(c,function(l){I(\"wasm streaming compile failed: \"+l);I(\"falling back to ArrayBuffer instantiation\");return d(c)})})})().catch(r);return{}})();\nb.___wasm_call_ctors=function(){return(b.___wasm_call_ctors=b.asm.c).apply(null,arguments)};b._poly1305_auth=function(){return(b._poly1305_auth=b.asm.d).apply(null,arguments)};var da=b.stackSave=function(){return(da=b.stackSave=b.asm.e).apply(null,arguments)},fa=b.stackRestore=function(){return(fa=b.stackRestore=b.asm.f).apply(null,arguments)},O=b.stackAlloc=function(){return(O=b.stackAlloc=b.asm.g).apply(null,arguments)};b._malloc=function(){return(b._malloc=b.asm.h).apply(null,arguments)};\nb._free=function(){return(b._free=b.asm.i).apply(null,arguments)};b.cwrap=function(a,c,d,e){d=d||[];var f=d.every(function(l){return\"number\"===l});return\"string\"!==c&&f&&!e?N(a):function(){return ca(a,c,d,arguments)}};var Y;U=function ta(){Y||Z();Y||(U=ta)};\nfunction Z(){function a(){if(!Y&&(Y=!0,b.calledRun=!0,!M)){X(ka);q(b);if(b.onRuntimeInitialized)b.onRuntimeInitialized();if(b.postRun)for(\"function\"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var c=b.postRun.shift();la.unshift(c)}X(la)}}if(!(0 {\n // eslint-disable-next-line prefer-const\n for (let [type, handler] of Object.entries(handlers)) {\n type = +type;\n if (isFinite(type) && type >= 0 && type < MESSAGE_HANDLERS.length)\n MESSAGE_HANDLERS[type] = handler;\n }\n});\n\nmodule.exports = MESSAGE_HANDLERS;\n","'use strict';\n\nconst {\n bufferSlice,\n bufferParser,\n doFatalError,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst {\n CHANNEL_OPEN_FAILURE,\n COMPAT,\n MESSAGE,\n TERMINAL_MODE,\n} = require('./constants.js');\n\nconst {\n parseKey,\n} = require('./keyParser.js');\n\nconst TERMINAL_MODE_BY_VALUE =\n Array.from(Object.entries(TERMINAL_MODE))\n .reduce((obj, [key, value]) => ({ ...obj, [key]: value }), {});\n\nmodule.exports = {\n // Transport layer protocol ==================================================\n [MESSAGE.DISCONNECT]: (self, payload) => {\n /*\n byte SSH_MSG_DISCONNECT\n uint32 reason code\n string description in ISO-10646 UTF-8 encoding\n string language tag\n */\n bufferParser.init(payload, 1);\n const reason = bufferParser.readUInt32BE();\n const desc = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed DISCONNECT packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: Received DISCONNECT (${reason}, \"${desc}\")`\n );\n\n const handler = self._handlers.DISCONNECT;\n handler && handler(self, reason, desc);\n },\n [MESSAGE.IGNORE]: (self, payload) => {\n /*\n byte SSH_MSG_IGNORE\n string data\n */\n self._debug && self._debug('Inbound: Received IGNORE');\n },\n [MESSAGE.UNIMPLEMENTED]: (self, payload) => {\n /*\n byte SSH_MSG_UNIMPLEMENTED\n uint32 packet sequence number of rejected message\n */\n bufferParser.init(payload, 1);\n const seqno = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (seqno === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed UNIMPLEMENTED packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: Received UNIMPLEMENTED (seqno ${seqno})`);\n },\n [MESSAGE.DEBUG]: (self, payload) => {\n /*\n byte SSH_MSG_DEBUG\n boolean always_display\n string message in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const display = bufferParser.readBool();\n const msg = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed DEBUG packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received DEBUG');\n\n const handler = self._handlers.DEBUG;\n handler && handler(self, display, msg);\n },\n [MESSAGE.SERVICE_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_SERVICE_REQUEST\n string service name\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n bufferParser.clear();\n\n if (name === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed SERVICE_REQUEST packet'\n );\n }\n\n self._debug && self._debug(`Inbound: Received SERVICE_REQUEST (${name})`);\n\n const handler = self._handlers.SERVICE_REQUEST;\n handler && handler(self, name);\n },\n [MESSAGE.SERVICE_ACCEPT]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_SERVICE_ACCEPT\n string service name\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n bufferParser.clear();\n\n if (name === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed SERVICE_ACCEPT packet'\n );\n }\n\n self._debug && self._debug(`Inbound: Received SERVICE_ACCEPT (${name})`);\n\n const handler = self._handlers.SERVICE_ACCEPT;\n handler && handler(self, name);\n },\n\n // User auth protocol -- generic =============================================\n [MESSAGE.USERAUTH_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_USERAUTH_REQUEST\n string user name in ISO-10646 UTF-8 encoding [RFC3629]\n string service name in US-ASCII\n string method name in US-ASCII\n .... method specific fields\n */\n bufferParser.init(payload, 1);\n const user = bufferParser.readString(true);\n const service = bufferParser.readString(true);\n const method = bufferParser.readString(true);\n let methodData;\n let methodDesc;\n switch (method) {\n case 'none':\n methodData = null;\n break;\n case 'password': {\n /*\n boolean \n string plaintext password in ISO-10646 UTF-8 encoding [RFC3629]\n [string new password]\n */\n const isChange = bufferParser.readBool();\n if (isChange !== undefined) {\n methodData = bufferParser.readString(true);\n if (methodData !== undefined && isChange) {\n const newPassword = bufferParser.readString(true);\n if (newPassword !== undefined)\n methodData = { oldPassword: methodData, newPassword };\n else\n methodData = undefined;\n }\n }\n break;\n }\n case 'publickey': {\n /*\n boolean \n string public key algorithm name\n string public key blob\n [string signature]\n */\n const hasSig = bufferParser.readBool();\n if (hasSig !== undefined) {\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n if (hasSig) {\n const blobEnd = bufferParser.pos();\n let signature = bufferParser.readString();\n if (signature !== undefined) {\n if (signature.length > (4 + keyAlgo.length + 4)\n && signature.utf8Slice(4, 4 + keyAlgo.length) === keyAlgo) {\n // Skip algoLen + algo + sigLen\n signature = bufferSlice(signature, 4 + keyAlgo.length + 4);\n }\n\n signature = sigSSHToASN1(signature, keyAlgo);\n if (signature) {\n const sessionID = self._kex.sessionID;\n const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);\n writeUInt32BE(blob, sessionID.length, 0);\n blob.set(sessionID, 4);\n blob.set(\n new Uint8Array(payload.buffer, payload.byteOffset, blobEnd),\n 4 + sessionID.length\n );\n methodData = {\n keyAlgo,\n key,\n signature,\n blob,\n };\n }\n }\n } else {\n methodData = { keyAlgo, key };\n methodDesc = 'publickey -- check';\n }\n }\n break;\n }\n case 'hostbased': {\n /*\n string public key algorithm for host key\n string public host key and certificates for client host\n string client host name expressed as the FQDN in US-ASCII\n string user name on the client host in ISO-10646 UTF-8 encoding\n [RFC3629]\n string signature\n */\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n const localHostname = bufferParser.readString(true);\n const localUsername = bufferParser.readString(true);\n\n const blobEnd = bufferParser.pos();\n let signature = bufferParser.readString();\n if (signature !== undefined) {\n if (signature.length > (4 + keyAlgo.length + 4)\n && signature.utf8Slice(4, 4 + keyAlgo.length) === keyAlgo) {\n // Skip algoLen + algo + sigLen\n signature = bufferSlice(signature, 4 + keyAlgo.length + 4);\n }\n\n signature = sigSSHToASN1(signature, keyAlgo);\n if (signature !== undefined) {\n const sessionID = self._kex.sessionID;\n const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);\n writeUInt32BE(blob, sessionID.length, 0);\n blob.set(sessionID, 4);\n blob.set(\n new Uint8Array(payload.buffer, payload.byteOffset, blobEnd),\n 4 + sessionID.length\n );\n methodData = {\n keyAlgo,\n key,\n signature,\n blob,\n localHostname,\n localUsername,\n };\n }\n }\n break;\n }\n case 'keyboard-interactive':\n /*\n string language tag (as defined in [RFC-3066])\n string submethods (ISO-10646 UTF-8)\n */\n // Skip/ignore language field -- it's deprecated in RFC 4256\n bufferParser.skipString();\n\n methodData = bufferParser.readList();\n break;\n default:\n if (method !== undefined)\n methodData = bufferParser.readRaw();\n }\n bufferParser.clear();\n\n if (methodData === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_REQUEST packet'\n );\n }\n\n if (methodDesc === undefined)\n methodDesc = method;\n\n self._authsQueue.push(method);\n\n self._debug\n && self._debug(`Inbound: Received USERAUTH_REQUEST (${methodDesc})`);\n\n const handler = self._handlers.USERAUTH_REQUEST;\n handler && handler(self, user, service, method, methodData);\n },\n [MESSAGE.USERAUTH_FAILURE]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_FAILURE\n name-list authentications that can continue\n boolean partial success\n */\n bufferParser.init(payload, 1);\n const authMethods = bufferParser.readList();\n const partialSuccess = bufferParser.readBool();\n bufferParser.clear();\n\n if (partialSuccess === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_FAILURE packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: Received USERAUTH_FAILURE (${authMethods})`);\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_FAILURE;\n handler && handler(self, authMethods, partialSuccess);\n },\n [MESSAGE.USERAUTH_SUCCESS]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_SUCCESS\n */\n self._debug && self._debug('Inbound: Received USERAUTH_SUCCESS');\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_SUCCESS;\n handler && handler(self);\n },\n [MESSAGE.USERAUTH_BANNER]: (self, payload) => {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_BANNER\n string message in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const msg = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_BANNER packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_BANNER');\n\n const handler = self._handlers.USERAUTH_BANNER;\n handler && handler(self, msg);\n },\n\n // User auth protocol -- method-specific =====================================\n 60: (self, payload) => {\n if (!self._authsQueue.length) {\n self._debug\n && self._debug('Inbound: Received payload type 60 without auth');\n return;\n }\n\n switch (self._authsQueue[0]) {\n case 'password': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_PASSWD_CHANGEREQ\n string prompt in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const prompt = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet'\n );\n }\n\n self._debug\n && self._debug('Inbound: Received USERAUTH_PASSWD_CHANGEREQ');\n\n const handler = self._handlers.USERAUTH_PASSWD_CHANGEREQ;\n handler && handler(self, prompt);\n break;\n }\n case 'publickey': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_PK_OK\n string public key algorithm name from the request\n string public key blob from the request\n */\n bufferParser.init(payload, 1);\n const keyAlgo = bufferParser.readString(true);\n const key = bufferParser.readString();\n bufferParser.clear();\n\n if (key === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_PK_OK packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_PK_OK');\n\n self._authsQueue.shift();\n const handler = self._handlers.USERAUTH_PK_OK;\n handler && handler(self, keyAlgo, key);\n break;\n }\n case 'keyboard-interactive': {\n // S->C\n /*\n byte SSH_MSG_USERAUTH_INFO_REQUEST\n string name (ISO-10646 UTF-8)\n string instruction (ISO-10646 UTF-8)\n string language tag (as defined in [RFC-3066])\n int num-prompts\n string prompt[1] (ISO-10646 UTF-8)\n boolean echo[1]\n ...\n string prompt[num-prompts] (ISO-10646 UTF-8)\n boolean echo[num-prompts]\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n const instructions = bufferParser.readString(true);\n bufferParser.readString(); // skip lang\n const numPrompts = bufferParser.readUInt32BE();\n let prompts;\n if (numPrompts !== undefined) {\n prompts = new Array(numPrompts);\n let i;\n for (i = 0; i < numPrompts; ++i) {\n const prompt = bufferParser.readString(true);\n const echo = bufferParser.readBool();\n if (echo === undefined)\n break;\n prompts[i] = { prompt, echo };\n }\n if (i !== numPrompts)\n prompts = undefined;\n }\n bufferParser.clear();\n\n if (prompts === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_INFO_REQUEST packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_INFO_REQUEST');\n\n const handler = self._handlers.USERAUTH_INFO_REQUEST;\n handler && handler(self, name, instructions, prompts);\n break;\n }\n default:\n self._debug\n && self._debug('Inbound: Received unexpected payload type 60');\n }\n },\n 61: (self, payload) => {\n if (!self._authsQueue.length) {\n self._debug\n && self._debug('Inbound: Received payload type 61 without auth');\n return;\n }\n /*\n byte SSH_MSG_USERAUTH_INFO_RESPONSE\n int num-responses\n string response[1] (ISO-10646 UTF-8)\n ...\n string response[num-responses] (ISO-10646 UTF-8)\n */\n if (self._authsQueue[0] !== 'keyboard-interactive') {\n return doFatalError(\n self,\n 'Inbound: Received unexpected payload type 61'\n );\n }\n bufferParser.init(payload, 1);\n const numResponses = bufferParser.readUInt32BE();\n let responses;\n if (numResponses !== undefined) {\n responses = new Array(numResponses);\n let i;\n for (i = 0; i < numResponses; ++i) {\n const response = bufferParser.readString(true);\n if (response === undefined)\n break;\n responses[i] = response;\n }\n if (i !== numResponses)\n responses = undefined;\n }\n bufferParser.clear();\n\n if (responses === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed USERAUTH_INFO_RESPONSE packet'\n );\n }\n\n self._debug && self._debug('Inbound: Received USERAUTH_INFO_RESPONSE');\n\n const handler = self._handlers.USERAUTH_INFO_RESPONSE;\n handler && handler(self, responses);\n },\n\n // Connection protocol -- generic ============================================\n [MESSAGE.GLOBAL_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_GLOBAL_REQUEST\n string request name in US-ASCII only\n boolean want reply\n .... request-specific data follows\n */\n bufferParser.init(payload, 1);\n const name = bufferParser.readString(true);\n const wantReply = bufferParser.readBool();\n let data;\n if (wantReply !== undefined) {\n switch (name) {\n case 'tcpip-forward':\n case 'cancel-tcpip-forward': {\n /*\n string address to bind (e.g., \"0.0.0.0\")\n uint32 port number to bind\n */\n const bindAddr = bufferParser.readString(true);\n const bindPort = bufferParser.readUInt32BE();\n if (bindPort !== undefined)\n data = { bindAddr, bindPort };\n break;\n }\n case 'streamlocal-forward@openssh.com':\n case 'cancel-streamlocal-forward@openssh.com': {\n /*\n string socket path\n */\n const socketPath = bufferParser.readString(true);\n if (socketPath !== undefined)\n data = { socketPath };\n break;\n }\n case 'no-more-sessions@openssh.com':\n data = null;\n break;\n case 'hostkeys-00@openssh.com': {\n data = [];\n while (bufferParser.avail() > 0) {\n const keyRaw = bufferParser.readString();\n if (keyRaw === undefined) {\n data = undefined;\n break;\n }\n const key = parseKey(keyRaw);\n if (!(key instanceof Error))\n data.push(key);\n }\n break;\n }\n default:\n data = bufferParser.readRaw();\n }\n }\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed GLOBAL_REQUEST packet'\n );\n }\n\n self._debug && self._debug(`Inbound: GLOBAL_REQUEST (${name})`);\n\n const handler = self._handlers.GLOBAL_REQUEST;\n if (handler)\n handler(self, name, wantReply, data);\n else\n self.requestFailure(); // Auto reject\n },\n [MESSAGE.REQUEST_SUCCESS]: (self, payload) => {\n /*\n byte SSH_MSG_REQUEST_SUCCESS\n .... response specific data\n */\n const data = (payload.length > 1 ? bufferSlice(payload, 1) : null);\n\n self._debug && self._debug('Inbound: REQUEST_SUCCESS');\n\n const handler = self._handlers.REQUEST_SUCCESS;\n handler && handler(self, data);\n },\n [MESSAGE.REQUEST_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_REQUEST_FAILURE\n */\n self._debug && self._debug('Inbound: Received REQUEST_FAILURE');\n\n const handler = self._handlers.REQUEST_FAILURE;\n handler && handler(self);\n },\n\n // Connection protocol -- channel-related ====================================\n [MESSAGE.CHANNEL_OPEN]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN\n string channel type in US-ASCII only\n uint32 sender channel\n uint32 initial window size\n uint32 maximum packet size\n .... channel type specific data follows\n */\n bufferParser.init(payload, 1);\n const type = bufferParser.readString(true);\n const sender = bufferParser.readUInt32BE();\n const window = bufferParser.readUInt32BE();\n const packetSize = bufferParser.readUInt32BE();\n let channelInfo;\n\n switch (type) {\n case 'forwarded-tcpip': // S->C\n case 'direct-tcpip': { // C->S\n /*\n string address that was connected / host to connect\n uint32 port that was connected / port to connect\n string originator IP address\n uint32 originator port\n */\n const destIP = bufferParser.readString(true);\n const destPort = bufferParser.readUInt32BE();\n const srcIP = bufferParser.readString(true);\n const srcPort = bufferParser.readUInt32BE();\n if (srcPort !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { destIP, destPort, srcIP, srcPort }\n };\n }\n break;\n }\n case 'forwarded-streamlocal@openssh.com': // S->C\n case 'direct-streamlocal@openssh.com': { // C->S\n /*\n string socket path\n string reserved for future use\n\n (direct-streamlocal@openssh.com additionally has:)\n uint32 reserved\n */\n const socketPath = bufferParser.readString(true);\n if (socketPath !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { socketPath }\n };\n }\n break;\n }\n case 'x11': { // S->C\n /*\n string originator address (e.g., \"192.168.7.38\")\n uint32 originator port\n */\n const srcIP = bufferParser.readString(true);\n const srcPort = bufferParser.readUInt32BE();\n if (srcPort !== undefined) {\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: { srcIP, srcPort }\n };\n }\n break;\n }\n default:\n // Includes:\n // 'session' (C->S)\n // 'auth-agent@openssh.com' (S->C)\n channelInfo = {\n type,\n sender,\n window,\n packetSize,\n data: {}\n };\n }\n bufferParser.clear();\n\n if (channelInfo === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_OPEN (s:${sender}, ${type})`);\n\n const handler = self._handlers.CHANNEL_OPEN;\n if (handler) {\n handler(self, channelInfo);\n } else {\n self.channelOpenFail(\n channelInfo.sender,\n CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED,\n '',\n ''\n );\n }\n },\n [MESSAGE.CHANNEL_OPEN_CONFIRMATION]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN_CONFIRMATION\n uint32 recipient channel\n uint32 sender channel\n uint32 initial window size\n uint32 maximum packet size\n .... channel type specific data follows\n */\n // \"The 'recipient channel' is the channel number given in the\n // original open request, and 'sender channel' is the channel number\n // allocated by the other side.\"\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const sender = bufferParser.readUInt32BE();\n const window = bufferParser.readUInt32BE();\n const packetSize = bufferParser.readUInt32BE();\n const data = (bufferParser.avail() ? bufferParser.readRaw() : undefined);\n bufferParser.clear();\n\n if (packetSize === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_OPEN_CONFIRMATION (r:${recipient}, s:${sender})`\n );\n\n const handler = self._handlers.CHANNEL_OPEN_CONFIRMATION;\n if (handler)\n handler(self, { recipient, sender, window, packetSize, data });\n },\n [MESSAGE.CHANNEL_OPEN_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_OPEN_FAILURE\n uint32 recipient channel\n uint32 reason code\n string description in ISO-10646 UTF-8 encoding [RFC3629]\n string language tag [RFC3066]\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const reason = bufferParser.readUInt32BE();\n const description = bufferParser.readString(true);\n const lang = bufferParser.readString();\n bufferParser.clear();\n\n if (lang === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_OPEN_FAILURE packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_OPEN_FAILURE;\n handler && handler(self, recipient, reason, description);\n },\n [MESSAGE.CHANNEL_WINDOW_ADJUST]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_WINDOW_ADJUST\n uint32 recipient channel\n uint32 bytes to add\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const bytesToAdd = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (bytesToAdd === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_WINDOW_ADJUST packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_WINDOW_ADJUST (r:${recipient}, ${bytesToAdd})`\n );\n\n const handler = self._handlers.CHANNEL_WINDOW_ADJUST;\n handler && handler(self, recipient, bytesToAdd);\n },\n [MESSAGE.CHANNEL_DATA]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_DATA\n uint32 recipient channel\n string data\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_DATA packet'\n );\n }\n\n self._debug\n && self._debug(`Inbound: CHANNEL_DATA (r:${recipient}, ${data.length})`);\n\n const handler = self._handlers.CHANNEL_DATA;\n handler && handler(self, recipient, data);\n },\n [MESSAGE.CHANNEL_EXTENDED_DATA]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_EXTENDED_DATA\n uint32 recipient channel\n uint32 data_type_code\n string data\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const type = bufferParser.readUInt32BE();\n const data = bufferParser.readString();\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_EXTENDED_DATA packet'\n );\n }\n\n self._debug && self._debug(\n `Inbound: CHANNEL_EXTENDED_DATA (r:${recipient}, ${data.length})`\n );\n\n const handler = self._handlers.CHANNEL_EXTENDED_DATA;\n handler && handler(self, recipient, data, type);\n },\n [MESSAGE.CHANNEL_EOF]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_EOF\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_EOF packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_EOF (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_EOF;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_CLOSE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_CLOSE\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_CLOSE packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_CLOSE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_CLOSE;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_REQUEST]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_REQUEST\n uint32 recipient channel\n string request type in US-ASCII characters only\n boolean want reply\n .... type-specific data follows\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n const type = bufferParser.readString(true);\n const wantReply = bufferParser.readBool();\n let data;\n if (wantReply !== undefined) {\n switch (type) {\n case 'exit-status': // S->C\n /*\n uint32 exit_status\n */\n data = bufferParser.readUInt32BE();\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'exit-signal': { // S->C\n /*\n string signal name (without the \"SIG\" prefix)\n boolean core dumped\n string error message in ISO-10646 UTF-8 encoding\n string language tag\n */\n let signal;\n let coreDumped;\n if (self._compatFlags & COMPAT.OLD_EXIT) {\n /*\n Instead of `signal name` and `core dumped`, we have just:\n uint32 signal number\n */\n const num = bufferParser.readUInt32BE();\n switch (num) {\n case 1:\n signal = 'HUP';\n break;\n case 2:\n signal = 'INT';\n break;\n case 3:\n signal = 'QUIT';\n break;\n case 6:\n signal = 'ABRT';\n break;\n case 9:\n signal = 'KILL';\n break;\n case 14:\n signal = 'ALRM';\n break;\n case 15:\n signal = 'TERM';\n break;\n default:\n if (num !== undefined) {\n // Unknown or OS-specific\n signal = `UNKNOWN (${num})`;\n }\n }\n coreDumped = false;\n } else {\n signal = bufferParser.readString(true);\n coreDumped = bufferParser.readBool();\n if (coreDumped === undefined)\n signal = undefined;\n }\n const errorMessage = bufferParser.readString(true);\n if (bufferParser.skipString() !== undefined)\n data = { signal, coreDumped, errorMessage };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${signal})`\n );\n break;\n }\n case 'pty-req': { // C->S\n /*\n string TERM environment variable value (e.g., vt100)\n uint32 terminal width, characters (e.g., 80)\n uint32 terminal height, rows (e.g., 24)\n uint32 terminal width, pixels (e.g., 640)\n uint32 terminal height, pixels (e.g., 480)\n string encoded terminal modes\n */\n const term = bufferParser.readString(true);\n const cols = bufferParser.readUInt32BE();\n const rows = bufferParser.readUInt32BE();\n const width = bufferParser.readUInt32BE();\n const height = bufferParser.readUInt32BE();\n const modesBinary = bufferParser.readString();\n if (modesBinary !== undefined) {\n bufferParser.init(modesBinary, 1);\n let modes = {};\n while (bufferParser.avail()) {\n const opcode = bufferParser.readByte();\n if (opcode === TERMINAL_MODE.TTY_OP_END)\n break;\n const name = TERMINAL_MODE_BY_VALUE[opcode];\n const value = bufferParser.readUInt32BE();\n if (opcode === undefined\n || name === undefined\n || value === undefined) {\n modes = undefined;\n break;\n }\n modes[name] = value;\n }\n if (modes !== undefined)\n data = { term, cols, rows, width, height, modes };\n }\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'window-change': { // C->S\n /*\n uint32 terminal width, columns\n uint32 terminal height, rows\n uint32 terminal width, pixels\n uint32 terminal height, pixels\n */\n const cols = bufferParser.readUInt32BE();\n const rows = bufferParser.readUInt32BE();\n const width = bufferParser.readUInt32BE();\n const height = bufferParser.readUInt32BE();\n if (height !== undefined)\n data = { cols, rows, width, height };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'x11-req': { // C->S\n /*\n boolean single connection\n string x11 authentication protocol\n string x11 authentication cookie\n uint32 x11 screen number\n */\n const single = bufferParser.readBool();\n const protocol = bufferParser.readString(true);\n const cookie = bufferParser.readString();\n const screen = bufferParser.readUInt32BE();\n if (screen !== undefined)\n data = { single, protocol, cookie, screen };\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n }\n case 'env': { // C->S\n /*\n string variable name\n string variable value\n */\n const name = bufferParser.readString(true);\n const value = bufferParser.readString(true);\n if (value !== undefined)\n data = { name, value };\n if (self._debug) {\n self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: `\n + `${name}=${value})`\n );\n }\n break;\n }\n case 'shell': // C->S\n data = null; // No extra data\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n case 'exec': // C->S\n /*\n string command\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'subsystem': // C->S\n /*\n string subsystem name\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'signal': // C->S\n /*\n string signal name (without the \"SIG\" prefix)\n */\n data = bufferParser.readString(true);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'xon-xoff': // C->S\n /*\n boolean client can do\n */\n data = bufferParser.readBool();\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type}: ${data})`\n );\n break;\n case 'auth-agent-req@openssh.com': // C-S\n data = null; // No extra data\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n break;\n default:\n data = (bufferParser.avail() ? bufferParser.readRaw() : null);\n self._debug && self._debug(\n `Inbound: CHANNEL_REQUEST (r:${recipient}, ${type})`\n );\n }\n }\n bufferParser.clear();\n\n if (data === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_REQUEST packet'\n );\n }\n\n const handler = self._handlers.CHANNEL_REQUEST;\n handler && handler(self, recipient, type, wantReply, data);\n },\n [MESSAGE.CHANNEL_SUCCESS]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_SUCCESS\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_SUCCESS packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_SUCCESS (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_SUCCESS;\n handler && handler(self, recipient);\n },\n [MESSAGE.CHANNEL_FAILURE]: (self, payload) => {\n /*\n byte SSH_MSG_CHANNEL_FAILURE\n uint32 recipient channel\n */\n bufferParser.init(payload, 1);\n const recipient = bufferParser.readUInt32BE();\n bufferParser.clear();\n\n if (recipient === undefined) {\n return doFatalError(\n self,\n 'Inbound: Malformed CHANNEL_FAILURE packet'\n );\n }\n\n self._debug && self._debug(`Inbound: CHANNEL_FAILURE (r:${recipient})`);\n\n const handler = self._handlers.CHANNEL_FAILURE;\n handler && handler(self, recipient);\n },\n};\n","'use strict';\n\nconst {\n createDiffieHellman,\n createDiffieHellmanGroup,\n createECDH,\n createHash,\n createPublicKey,\n diffieHellman,\n generateKeyPairSync,\n randomFillSync,\n} = require('crypto');\n\nconst { Ber } = require('asn1');\n\nconst {\n COMPAT,\n curve25519Supported,\n DEFAULT_KEX,\n DEFAULT_SERVER_HOST_KEY,\n DEFAULT_CIPHER,\n DEFAULT_MAC,\n DEFAULT_COMPRESSION,\n DISCONNECT_REASON,\n MESSAGE,\n} = require('./constants.js');\nconst {\n CIPHER_INFO,\n createCipher,\n createDecipher,\n MAC_INFO,\n} = require('./crypto.js');\nconst { parseDERKey } = require('./keyParser.js');\nconst {\n bufferFill,\n bufferParser,\n convertSignature,\n doFatalError,\n FastBuffer,\n sigSSHToASN1,\n writeUInt32BE,\n} = require('./utils.js');\nconst {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n} = require('./zlib.js');\n\nlet MESSAGE_HANDLERS;\n\nconst GEX_MIN_BITS = 2048; // RFC 8270\nconst GEX_MAX_BITS = 8192; // RFC 8270\n\nconst EMPTY_BUFFER = Buffer.alloc(0);\n\n// Client/Server\nfunction kexinit(self) {\n /*\n byte SSH_MSG_KEXINIT\n byte[16] cookie (random bytes)\n name-list kex_algorithms\n name-list server_host_key_algorithms\n name-list encryption_algorithms_client_to_server\n name-list encryption_algorithms_server_to_client\n name-list mac_algorithms_client_to_server\n name-list mac_algorithms_server_to_client\n name-list compression_algorithms_client_to_server\n name-list compression_algorithms_server_to_client\n name-list languages_client_to_server\n name-list languages_server_to_client\n boolean first_kex_packet_follows\n uint32 0 (reserved for future extension)\n */\n\n let payload;\n if (self._compatFlags & COMPAT.BAD_DHGEX) {\n const entry = self._offer.lists.kex;\n let kex = entry.array;\n let found = false;\n for (let i = 0; i < kex.length; ++i) {\n if (kex[i].includes('group-exchange')) {\n if (!found) {\n found = true;\n // Copy array lazily\n kex = kex.slice();\n }\n kex.splice(i--, 1);\n }\n }\n if (found) {\n let len = 1 + 16 + self._offer.totalSize + 1 + 4;\n const newKexBuf = Buffer.from(kex.join(','));\n len -= (entry.buffer.length - newKexBuf.length);\n\n const all = self._offer.lists.all;\n const rest = new Uint8Array(\n all.buffer,\n all.byteOffset + 4 + entry.buffer.length,\n all.length - (4 + entry.buffer.length)\n );\n\n payload = Buffer.allocUnsafe(len);\n writeUInt32BE(payload, newKexBuf.length, 17);\n payload.set(newKexBuf, 17 + 4);\n payload.set(rest, 17 + 4 + newKexBuf.length);\n }\n }\n\n if (payload === undefined) {\n payload = Buffer.allocUnsafe(1 + 16 + self._offer.totalSize + 1 + 4);\n self._offer.copyAllTo(payload, 17);\n }\n\n self._debug && self._debug('Outbound: Sending KEXINIT');\n\n payload[0] = MESSAGE.KEXINIT;\n randomFillSync(payload, 1, 16);\n\n // Zero-fill first_kex_packet_follows and reserved bytes\n bufferFill(payload, 0, payload.length - 5);\n\n self._kexinit = payload;\n\n // Needed to correct the starting position in allocated \"packets\" when packets\n // will be buffered due to active key exchange\n self._packetRW.write.allocStart = 0;\n\n // TODO: only create single buffer and set _kexinit as slice of packet instead\n {\n const p = self._packetRW.write.allocStartKEX;\n const packet = self._packetRW.write.alloc(payload.length, true);\n packet.set(payload, p);\n self._cipher.encrypt(self._packetRW.write.finalize(packet, true));\n }\n}\n\nfunction handleKexInit(self, payload) {\n /*\n byte SSH_MSG_KEXINIT\n byte[16] cookie (random bytes)\n name-list kex_algorithms\n name-list server_host_key_algorithms\n name-list encryption_algorithms_client_to_server\n name-list encryption_algorithms_server_to_client\n name-list mac_algorithms_client_to_server\n name-list mac_algorithms_server_to_client\n name-list compression_algorithms_client_to_server\n name-list compression_algorithms_server_to_client\n name-list languages_client_to_server\n name-list languages_server_to_client\n boolean first_kex_packet_follows\n uint32 0 (reserved for future extension)\n */\n const init = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n sc: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n };\n\n bufferParser.init(payload, 17);\n\n if ((init.kex = bufferParser.readList()) === undefined\n || (init.serverHostKey = bufferParser.readList()) === undefined\n || (init.cs.cipher = bufferParser.readList()) === undefined\n || (init.sc.cipher = bufferParser.readList()) === undefined\n || (init.cs.mac = bufferParser.readList()) === undefined\n || (init.sc.mac = bufferParser.readList()) === undefined\n || (init.cs.compress = bufferParser.readList()) === undefined\n || (init.sc.compress = bufferParser.readList()) === undefined\n || (init.cs.lang = bufferParser.readList()) === undefined\n || (init.sc.lang = bufferParser.readList()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n self,\n 'Received malformed KEXINIT',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n const pos = bufferParser.pos();\n const firstFollows = (pos < payload.length && payload[pos] === 1);\n bufferParser.clear();\n\n const local = self._offer;\n const remote = init;\n\n let localKex = local.lists.kex.array;\n if (self._compatFlags & COMPAT.BAD_DHGEX) {\n let found = false;\n for (let i = 0; i < localKex.length; ++i) {\n if (localKex[i].indexOf('group-exchange') !== -1) {\n if (!found) {\n found = true;\n // Copy array lazily\n localKex = localKex.slice();\n }\n localKex.splice(i--, 1);\n }\n }\n }\n\n let clientList;\n let serverList;\n let i;\n const debug = self._debug;\n\n debug && debug('Inbound: Handshake in progress');\n\n // Key exchange method =======================================================\n debug && debug(`Handshake: (local) KEX method: ${localKex}`);\n debug && debug(`Handshake: (remote) KEX method: ${remote.kex}`);\n if (self._server) {\n serverList = localKex;\n clientList = remote.kex;\n } else {\n serverList = remote.kex;\n clientList = localKex;\n }\n // Check for agreeable key exchange algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching key exchange algorithm');\n return doFatalError(\n self,\n 'Handshake failed: no matching key exchange algorithm',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.kex = clientList[i];\n debug && debug(`Handshake: KEX algorithm: ${clientList[i]}`);\n if (firstFollows && (!remote.kex.length || clientList[i] !== remote.kex[0])) {\n // Ignore next inbound packet, it was a wrong first guess at KEX algorithm\n self._skipNextInboundPacket = true;\n }\n\n\n // Server host key format ====================================================\n const localSrvHostKey = local.lists.serverHostKey.array;\n debug && debug(`Handshake: (local) Host key format: ${localSrvHostKey}`);\n debug && debug(\n `Handshake: (remote) Host key format: ${remote.serverHostKey}`\n );\n if (self._server) {\n serverList = localSrvHostKey;\n clientList = remote.serverHostKey;\n } else {\n serverList = remote.serverHostKey;\n clientList = localSrvHostKey;\n }\n // Check for agreeable server host key format\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching host key format');\n return doFatalError(\n self,\n 'Handshake failed: no matching host key format',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.serverHostKey = clientList[i];\n debug && debug(`Handshake: Host key format: ${clientList[i]}`);\n\n\n // Client->Server cipher =====================================================\n const localCSCipher = local.lists.cs.cipher.array;\n debug && debug(`Handshake: (local) C->S cipher: ${localCSCipher}`);\n debug && debug(`Handshake: (remote) C->S cipher: ${remote.cs.cipher}`);\n if (self._server) {\n serverList = localCSCipher;\n clientList = remote.cs.cipher;\n } else {\n serverList = remote.cs.cipher;\n clientList = localCSCipher;\n }\n // Check for agreeable client->server cipher\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S cipher');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S cipher',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.cipher = clientList[i];\n debug && debug(`Handshake: C->S Cipher: ${clientList[i]}`);\n\n\n // Server->Client cipher =====================================================\n const localSCCipher = local.lists.sc.cipher.array;\n debug && debug(`Handshake: (local) S->C cipher: ${localSCCipher}`);\n debug && debug(`Handshake: (remote) S->C cipher: ${remote.sc.cipher}`);\n if (self._server) {\n serverList = localSCCipher;\n clientList = remote.sc.cipher;\n } else {\n serverList = remote.sc.cipher;\n clientList = localSCCipher;\n }\n // Check for agreeable server->client cipher\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C cipher');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C cipher',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.cipher = clientList[i];\n debug && debug(`Handshake: S->C cipher: ${clientList[i]}`);\n\n\n // Client->Server MAC ========================================================\n const localCSMAC = local.lists.cs.mac.array;\n debug && debug(`Handshake: (local) C->S MAC: ${localCSMAC}`);\n debug && debug(`Handshake: (remote) C->S MAC: ${remote.cs.mac}`);\n if (CIPHER_INFO[init.cs.cipher].authLen > 0) {\n init.cs.mac = '';\n debug && debug('Handshake: C->S MAC: ');\n } else {\n if (self._server) {\n serverList = localCSMAC;\n clientList = remote.cs.mac;\n } else {\n serverList = remote.cs.mac;\n clientList = localCSMAC;\n }\n // Check for agreeable client->server hmac algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S MAC');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S MAC',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.mac = clientList[i];\n debug && debug(`Handshake: C->S MAC: ${clientList[i]}`);\n }\n\n\n // Server->Client MAC ========================================================\n const localSCMAC = local.lists.sc.mac.array;\n debug && debug(`Handshake: (local) S->C MAC: ${localSCMAC}`);\n debug && debug(`Handshake: (remote) S->C MAC: ${remote.sc.mac}`);\n if (CIPHER_INFO[init.sc.cipher].authLen > 0) {\n init.sc.mac = '';\n debug && debug('Handshake: S->C MAC: ');\n } else {\n if (self._server) {\n serverList = localSCMAC;\n clientList = remote.sc.mac;\n } else {\n serverList = remote.sc.mac;\n clientList = localSCMAC;\n }\n // Check for agreeable server->client hmac algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C MAC');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C MAC',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.mac = clientList[i];\n debug && debug(`Handshake: S->C MAC: ${clientList[i]}`);\n }\n\n\n // Client->Server compression ================================================\n const localCSCompress = local.lists.cs.compress.array;\n debug && debug(`Handshake: (local) C->S compression: ${localCSCompress}`);\n debug && debug(`Handshake: (remote) C->S compression: ${remote.cs.compress}`);\n if (self._server) {\n serverList = localCSCompress;\n clientList = remote.cs.compress;\n } else {\n serverList = remote.cs.compress;\n clientList = localCSCompress;\n }\n // Check for agreeable client->server compression algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching C->S compression');\n return doFatalError(\n self,\n 'Handshake failed: no matching C->S compression',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.cs.compress = clientList[i];\n debug && debug(`Handshake: C->S compression: ${clientList[i]}`);\n\n\n // Server->Client compression ================================================\n const localSCCompress = local.lists.sc.compress.array;\n debug && debug(`Handshake: (local) S->C compression: ${localSCCompress}`);\n debug && debug(`Handshake: (remote) S->C compression: ${remote.sc.compress}`);\n if (self._server) {\n serverList = localSCCompress;\n clientList = remote.sc.compress;\n } else {\n serverList = remote.sc.compress;\n clientList = localSCCompress;\n }\n // Check for agreeable server->client compression algorithm\n for (i = 0;\n i < clientList.length && serverList.indexOf(clientList[i]) === -1;\n ++i);\n if (i === clientList.length) {\n // No suitable match found!\n debug && debug('Handshake: No matching S->C compression');\n return doFatalError(\n self,\n 'Handshake failed: no matching S->C compression',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n init.sc.compress = clientList[i];\n debug && debug(`Handshake: S->C compression: ${clientList[i]}`);\n\n init.cs.lang = '';\n init.sc.lang = '';\n\n // XXX: hack -- find a better way to do this\n if (self._kex) {\n if (!self._kexinit) {\n // We received a rekey request, but we haven't sent a KEXINIT in response\n // yet\n kexinit(self);\n }\n self._decipher._onPayload = onKEXPayload.bind(self, { firstPacket: false });\n }\n\n self._kex = createKeyExchange(init, self, payload);\n self._kex.start();\n}\n\nconst createKeyExchange = (() => {\n function convertToMpint(buf) {\n let idx = 0;\n let length = buf.length;\n while (buf[idx] === 0x00) {\n ++idx;\n --length;\n }\n let newBuf;\n if (buf[idx] & 0x80) {\n newBuf = Buffer.allocUnsafe(1 + length);\n newBuf[0] = 0;\n buf.copy(newBuf, 1, idx);\n buf = newBuf;\n } else if (length !== buf.length) {\n newBuf = Buffer.allocUnsafe(length);\n buf.copy(newBuf, 0, idx);\n buf = newBuf;\n }\n return buf;\n }\n\n class KeyExchange {\n constructor(negotiated, protocol, remoteKexinit) {\n this._protocol = protocol;\n\n this.sessionID = (protocol._kex ? protocol._kex.sessionID : undefined);\n this.negotiated = negotiated;\n this._step = 1;\n this._public = null;\n this._dh = null;\n this._sentNEWKEYS = false;\n this._receivedNEWKEYS = false;\n this._finished = false;\n this._hostVerified = false;\n\n // Data needed for initializing cipher/decipher/etc.\n this._kexinit = protocol._kexinit;\n this._remoteKexinit = remoteKexinit;\n this._identRaw = protocol._identRaw;\n this._remoteIdentRaw = protocol._remoteIdentRaw;\n this._hostKey = undefined;\n this._dhData = undefined;\n this._sig = undefined;\n }\n finish() {\n if (this._finished)\n return false;\n this._finished = true;\n\n const isServer = this._protocol._server;\n const negotiated = this.negotiated;\n\n const pubKey = this.convertPublicKey(this._dhData);\n let secret = this.computeSecret(this._dhData);\n if (secret instanceof Error) {\n secret.message =\n `Error while computing DH secret (${this.type}): ${secret.message}`;\n secret.level = 'handshake';\n return doFatalError(\n this._protocol,\n secret,\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n const hash = createHash(this.hashName);\n // V_C\n hashString(hash, (isServer ? this._remoteIdentRaw : this._identRaw));\n // \"V_S\"\n hashString(hash, (isServer ? this._identRaw : this._remoteIdentRaw));\n // \"I_C\"\n hashString(hash, (isServer ? this._remoteKexinit : this._kexinit));\n // \"I_S\"\n hashString(hash, (isServer ? this._kexinit : this._remoteKexinit));\n // \"K_S\"\n const serverPublicHostKey = (isServer\n ? this._hostKey.getPublicSSH()\n : this._hostKey);\n hashString(hash, serverPublicHostKey);\n\n if (this.type === 'groupex') {\n // Group exchange-specific\n const params = this.getDHParams();\n const num = Buffer.allocUnsafe(4);\n // min (uint32)\n writeUInt32BE(num, this._minBits, 0);\n hash.update(num);\n // preferred (uint32)\n writeUInt32BE(num, this._prefBits, 0);\n hash.update(num);\n // max (uint32)\n writeUInt32BE(num, this._maxBits, 0);\n hash.update(num);\n // prime\n hashString(hash, params.prime);\n // generator\n hashString(hash, params.generator);\n }\n\n // method-specific data sent by client\n hashString(hash, (isServer ? pubKey : this.getPublicKey()));\n // method-specific data sent by server\n const serverPublicKey = (isServer ? this.getPublicKey() : pubKey);\n hashString(hash, serverPublicKey);\n // shared secret (\"K\")\n hashString(hash, secret);\n\n // \"H\"\n const exchangeHash = hash.digest();\n\n if (!isServer) {\n bufferParser.init(this._sig, 0);\n const sigType = bufferParser.readString(true);\n\n if (!sigType) {\n return doFatalError(\n this._protocol,\n 'Malformed packet while reading signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (sigType !== negotiated.serverHostKey) {\n return doFatalError(\n this._protocol,\n `Wrong signature type: ${sigType}, `\n + `expected: ${negotiated.serverHostKey}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // \"s\"\n let sigValue = bufferParser.readString();\n\n bufferParser.clear();\n\n if (sigValue === undefined) {\n return doFatalError(\n this._protocol,\n 'Malformed packet while reading signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (!(sigValue = sigSSHToASN1(sigValue, sigType))) {\n return doFatalError(\n this._protocol,\n 'Malformed signature',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n let parsedHostKey;\n {\n bufferParser.init(this._hostKey, 0);\n const name = bufferParser.readString(true);\n const hostKey = this._hostKey.slice(bufferParser.pos());\n bufferParser.clear();\n parsedHostKey = parseDERKey(hostKey, name);\n if (parsedHostKey instanceof Error) {\n parsedHostKey.level = 'handshake';\n return doFatalError(\n this._protocol,\n parsedHostKey,\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n let hashAlgo;\n // Check if we need to override the default hash algorithm\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256': hashAlgo = 'sha256'; break;\n case 'rsa-sha2-512': hashAlgo = 'sha512'; break;\n }\n\n this._protocol._debug\n && this._protocol._debug('Verifying signature ...');\n\n const verified = parsedHostKey.verify(exchangeHash, sigValue, hashAlgo);\n if (verified !== true) {\n if (verified instanceof Error) {\n this._protocol._debug && this._protocol._debug(\n `Signature verification failed: ${verified.stack}`\n );\n } else {\n this._protocol._debug && this._protocol._debug(\n 'Signature verification failed'\n );\n }\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature verification failed',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug('Verified signature');\n } else {\n // Server\n\n let hashAlgo;\n // Check if we need to override the default hash algorithm\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256': hashAlgo = 'sha256'; break;\n case 'rsa-sha2-512': hashAlgo = 'sha512'; break;\n }\n\n this._protocol._debug && this._protocol._debug(\n 'Generating signature ...'\n );\n\n let signature = this._hostKey.sign(exchangeHash, hashAlgo);\n if (signature instanceof Error) {\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature generation failed for '\n + `${this._hostKey.type} host key: ${signature.message}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n signature = convertSignature(signature, this._hostKey.type);\n if (signature === false) {\n return doFatalError(\n this._protocol,\n 'Handshake failed: signature conversion failed for '\n + `${this._hostKey.type} host key`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // Send KEX reply\n /*\n byte SSH_MSG_KEXDH_REPLY\n / SSH_MSG_KEX_DH_GEX_REPLY\n / SSH_MSG_KEX_ECDH_REPLY\n string server public host key and certificates (K_S)\n string \n string signature of H\n */\n const sigType = this.negotiated.serverHostKey;\n const sigTypeLen = Buffer.byteLength(sigType);\n const sigLen = 4 + sigTypeLen + 4 + signature.length;\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1\n + 4 + serverPublicHostKey.length\n + 4 + serverPublicKey.length\n + 4 + sigLen,\n true\n );\n\n packet[p] = MESSAGE.KEXDH_REPLY;\n\n writeUInt32BE(packet, serverPublicHostKey.length, ++p);\n packet.set(serverPublicHostKey, p += 4);\n\n writeUInt32BE(packet,\n serverPublicKey.length,\n p += serverPublicHostKey.length);\n packet.set(serverPublicKey, p += 4);\n\n writeUInt32BE(packet, sigLen, p += serverPublicKey.length);\n\n writeUInt32BE(packet, sigTypeLen, p += 4);\n packet.utf8Write(sigType, p += 4, sigTypeLen);\n\n writeUInt32BE(packet, signature.length, p += sigTypeLen);\n packet.set(signature, p += 4);\n\n if (this._protocol._debug) {\n let type;\n switch (this.type) {\n case 'group':\n type = 'KEXDH_REPLY';\n break;\n case 'groupex':\n type = 'KEXDH_GEX_REPLY';\n break;\n default:\n type = 'KEXECDH_REPLY';\n }\n this._protocol._debug(`Outbound: Sending ${type}`);\n }\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n trySendNEWKEYS(this);\n\n const completeHandshake = () => {\n if (!this.sessionID)\n this.sessionID = exchangeHash;\n\n {\n const newSecret = Buffer.allocUnsafe(4 + secret.length);\n writeUInt32BE(newSecret, secret.length, 0);\n newSecret.set(secret, 4);\n secret = newSecret;\n }\n\n // Initialize new ciphers, deciphers, etc.\n\n const csCipherInfo = CIPHER_INFO[negotiated.cs.cipher];\n const scCipherInfo = CIPHER_INFO[negotiated.sc.cipher];\n\n const csIV = generateKEXVal(csCipherInfo.ivLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'A');\n const scIV = generateKEXVal(scCipherInfo.ivLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'B');\n const csKey = generateKEXVal(csCipherInfo.keyLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'C');\n const scKey = generateKEXVal(scCipherInfo.keyLen,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'D');\n let csMacInfo;\n let csMacKey;\n if (!csCipherInfo.authLen) {\n csMacInfo = MAC_INFO[negotiated.cs.mac];\n csMacKey = generateKEXVal(csMacInfo.len,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'E');\n }\n let scMacInfo;\n let scMacKey;\n if (!scCipherInfo.authLen) {\n scMacInfo = MAC_INFO[negotiated.sc.mac];\n scMacKey = generateKEXVal(scMacInfo.len,\n this.hashName,\n secret,\n exchangeHash,\n this.sessionID,\n 'F');\n }\n\n const config = {\n inbound: {\n onPayload: this._protocol._onPayload,\n seqno: this._protocol._decipher.inSeqno,\n decipherInfo: (!isServer ? scCipherInfo : csCipherInfo),\n decipherIV: (!isServer ? scIV : csIV),\n decipherKey: (!isServer ? scKey : csKey),\n macInfo: (!isServer ? scMacInfo : csMacInfo),\n macKey: (!isServer ? scMacKey : csMacKey),\n },\n outbound: {\n onWrite: this._protocol._onWrite,\n seqno: this._protocol._cipher.outSeqno,\n cipherInfo: (isServer ? scCipherInfo : csCipherInfo),\n cipherIV: (isServer ? scIV : csIV),\n cipherKey: (isServer ? scKey : csKey),\n macInfo: (isServer ? scMacInfo : csMacInfo),\n macKey: (isServer ? scMacKey : csMacKey),\n },\n };\n this._protocol._cipher && this._protocol._cipher.free();\n this._protocol._decipher && this._protocol._decipher.free();\n this._protocol._cipher = createCipher(config);\n this._protocol._decipher = createDecipher(config);\n\n const rw = {\n read: undefined,\n write: undefined,\n };\n switch (negotiated.cs.compress) {\n case 'zlib': // starts immediately\n if (isServer)\n rw.read = new ZlibPacketReader();\n else\n rw.write = new ZlibPacketWriter(this._protocol);\n break;\n case 'zlib@openssh.com':\n // Starts after successful user authentication\n\n if (this._protocol._authenticated) {\n // If a rekey happens and this compression method is selected and\n // we already authenticated successfully, we need to start\n // immediately instead\n if (isServer)\n rw.read = new ZlibPacketReader();\n else\n rw.write = new ZlibPacketWriter(this._protocol);\n break;\n }\n // FALLTHROUGH\n default:\n // none -- never any compression/decompression\n\n if (isServer)\n rw.read = new PacketReader();\n else\n rw.write = new PacketWriter(this._protocol);\n }\n switch (negotiated.sc.compress) {\n case 'zlib': // starts immediately\n if (isServer)\n rw.write = new ZlibPacketWriter(this._protocol);\n else\n rw.read = new ZlibPacketReader();\n break;\n case 'zlib@openssh.com':\n // Starts after successful user authentication\n\n if (this._protocol._authenticated) {\n // If a rekey happens and this compression method is selected and\n // we already authenticated successfully, we need to start\n // immediately instead\n if (isServer)\n rw.write = new ZlibPacketWriter(this._protocol);\n else\n rw.read = new ZlibPacketReader();\n break;\n }\n // FALLTHROUGH\n default:\n // none -- never any compression/decompression\n\n if (isServer)\n rw.write = new PacketWriter(this._protocol);\n else\n rw.read = new PacketReader();\n }\n this._protocol._packetRW.read.cleanup();\n this._protocol._packetRW.write.cleanup();\n this._protocol._packetRW = rw;\n\n // Cleanup/reset various state\n this._public = null;\n this._dh = null;\n this._kexinit = this._protocol._kexinit = undefined;\n this._remoteKexinit = undefined;\n this._identRaw = undefined;\n this._remoteIdentRaw = undefined;\n this._hostKey = undefined;\n this._dhData = undefined;\n this._sig = undefined;\n\n this._protocol._onHandshakeComplete(negotiated);\n\n return false;\n };\n if (!isServer)\n return completeHandshake();\n this.finish = completeHandshake;\n }\n\n start() {\n if (!this._protocol._server) {\n if (this._protocol._debug) {\n let type;\n switch (this.type) {\n case 'group':\n type = 'KEXDH_INIT';\n break;\n default:\n type = 'KEXECDH_INIT';\n }\n this._protocol._debug(`Outbound: Sending ${type}`);\n }\n\n const pubKey = this.getPublicKey();\n\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1 + 4 + pubKey.length,\n true\n );\n packet[p] = MESSAGE.KEXDH_INIT;\n writeUInt32BE(packet, pubKey.length, ++p);\n packet.set(pubKey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n }\n getPublicKey() {\n this.generateKeys();\n\n const key = this._public;\n\n if (key)\n return this.convertPublicKey(key);\n }\n convertPublicKey(key) {\n let newKey;\n let idx = 0;\n let len = key.length;\n while (key[idx] === 0x00) {\n ++idx;\n --len;\n }\n\n if (key[idx] & 0x80) {\n newKey = Buffer.allocUnsafe(1 + len);\n newKey[0] = 0;\n key.copy(newKey, 1, idx);\n return newKey;\n }\n\n if (len !== key.length) {\n newKey = Buffer.allocUnsafe(len);\n key.copy(newKey, 0, idx);\n key = newKey;\n }\n return key;\n }\n computeSecret(otherPublicKey) {\n this.generateKeys();\n\n try {\n return convertToMpint(this._dh.computeSecret(otherPublicKey));\n } catch (ex) {\n return ex;\n }\n }\n parse(payload) {\n const type = payload[0];\n switch (this._step) {\n case 1:\n if (this._protocol._server) {\n // Server\n if (type !== MESSAGE.KEXDH_INIT) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_INIT}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH Init'\n );\n /*\n byte SSH_MSG_KEXDH_INIT\n / SSH_MSG_KEX_ECDH_INIT\n string \n */\n bufferParser.init(payload, 1);\n const dhData = bufferParser.readString();\n bufferParser.clear();\n if (dhData === undefined) {\n return doFatalError(\n this._protocol,\n 'Received malformed KEX*_INIT',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n // Client public key\n this._dhData = dhData;\n\n let hostKey =\n this._protocol._hostKeys[this.negotiated.serverHostKey];\n if (Array.isArray(hostKey))\n hostKey = hostKey[0];\n this._hostKey = hostKey;\n\n this.finish();\n } else {\n // Client\n if (type !== MESSAGE.KEXDH_REPLY) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_REPLY}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH Reply'\n );\n /*\n byte SSH_MSG_KEXDH_REPLY\n / SSH_MSG_KEX_DH_GEX_REPLY\n / SSH_MSG_KEX_ECDH_REPLY\n string server public host key and certificates (K_S)\n string \n string signature of H\n */\n bufferParser.init(payload, 1);\n let hostPubKey;\n let dhData;\n let sig;\n if ((hostPubKey = bufferParser.readString()) === undefined\n || (dhData = bufferParser.readString()) === undefined\n || (sig = bufferParser.readString()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n this._protocol,\n 'Received malformed KEX*_REPLY',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n bufferParser.clear();\n\n // Check that the host public key type matches what was negotiated\n // during KEXINIT swap\n bufferParser.init(hostPubKey, 0);\n const hostPubKeyType = bufferParser.readString(true);\n bufferParser.clear();\n if (hostPubKeyType === undefined) {\n return doFatalError(\n this._protocol,\n 'Received malformed host public key',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n if (hostPubKeyType !== this.negotiated.serverHostKey) {\n // Check if we need to make an exception\n switch (this.negotiated.serverHostKey) {\n case 'rsa-sha2-256':\n case 'rsa-sha2-512':\n if (hostPubKeyType === 'ssh-rsa')\n break;\n // FALLTHROUGH\n default:\n return doFatalError(\n this._protocol,\n 'Host key does not match negotiated type',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n this._hostKey = hostPubKey;\n this._dhData = dhData;\n this._sig = sig;\n\n let checked = false;\n let ret;\n if (this._protocol._hostVerifier === undefined) {\n ret = true;\n this._protocol._debug && this._protocol._debug(\n 'Host accepted by default (no verification)'\n );\n } else {\n ret = this._protocol._hostVerifier(hostPubKey, (permitted) => {\n if (checked)\n return;\n checked = true;\n if (permitted === false) {\n this._protocol._debug && this._protocol._debug(\n 'Host denied (verification failed)'\n );\n return doFatalError(\n this._protocol,\n 'Host denied (verification failed)',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Host accepted (verified)'\n );\n this._hostVerified = true;\n if (this._receivedNEWKEYS)\n this.finish();\n else\n trySendNEWKEYS(this);\n });\n }\n if (ret === undefined) {\n // Async host verification\n ++this._step;\n return;\n }\n checked = true;\n if (ret === false) {\n this._protocol._debug && this._protocol._debug(\n 'Host denied (verification failed)'\n );\n return doFatalError(\n this._protocol,\n 'Host denied (verification failed)',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Host accepted (verified)'\n );\n this._hostVerified = true;\n trySendNEWKEYS(this);\n }\n ++this._step;\n break;\n case 2:\n if (type !== MESSAGE.NEWKEYS) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.NEWKEYS}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Inbound: NEWKEYS'\n );\n this._receivedNEWKEYS = true;\n ++this._step;\n if (this._protocol._server || this._hostVerified)\n return this.finish();\n\n // Signal to current decipher that we need to change to a new decipher\n // for the next packet\n return false;\n default:\n return doFatalError(\n this._protocol,\n `Received unexpected packet ${type} after NEWKEYS`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n }\n\n class Curve25519Exchange extends KeyExchange {\n constructor(hashName, ...args) {\n super(...args);\n\n this.type = '25519';\n this.hashName = hashName;\n this._keys = null;\n }\n generateKeys() {\n if (!this._keys)\n this._keys = generateKeyPairSync('x25519');\n }\n getPublicKey() {\n this.generateKeys();\n\n const key = this._keys.publicKey.export({ type: 'spki', format: 'der' });\n return key.slice(-32); // HACK: avoids parsing DER/BER header\n }\n convertPublicKey(key) {\n let newKey;\n let idx = 0;\n let len = key.length;\n while (key[idx] === 0x00) {\n ++idx;\n --len;\n }\n\n if (key.length === 32)\n return key;\n\n if (len !== key.length) {\n newKey = Buffer.allocUnsafe(len);\n key.copy(newKey, 0, idx);\n key = newKey;\n }\n return key;\n }\n computeSecret(otherPublicKey) {\n this.generateKeys();\n\n try {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.110'); // id-X25519\n asnWriter.endSequence();\n\n // PublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(otherPublicKey.length);\n otherPublicKey.copy(asnWriter._buf,\n asnWriter._offset,\n 0,\n otherPublicKey.length);\n asnWriter._offset += otherPublicKey.length;\n asnWriter.endSequence();\n asnWriter.endSequence();\n\n return convertToMpint(diffieHellman({\n privateKey: this._keys.privateKey,\n publicKey: createPublicKey({\n key: asnWriter.buffer,\n type: 'spki',\n format: 'der',\n }),\n }));\n } catch (ex) {\n return ex;\n }\n }\n }\n\n class ECDHExchange extends KeyExchange {\n constructor(curveName, hashName, ...args) {\n super(...args);\n\n this.type = 'ecdh';\n this.curveName = curveName;\n this.hashName = hashName;\n }\n generateKeys() {\n if (!this._dh) {\n this._dh = createECDH(this.curveName);\n this._public = this._dh.generateKeys();\n }\n }\n }\n\n class DHGroupExchange extends KeyExchange {\n constructor(hashName, ...args) {\n super(...args);\n\n this.type = 'groupex';\n this.hashName = hashName;\n this._prime = null;\n this._generator = null;\n this._minBits = GEX_MIN_BITS;\n this._prefBits = dhEstimate(this.negotiated);\n if (this._protocol._compatFlags & COMPAT.BUG_DHGEX_LARGE)\n this._prefBits = Math.min(this._prefBits, 4096);\n this._maxBits = GEX_MAX_BITS;\n }\n start() {\n if (this._protocol._server)\n return;\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_GEX_REQUEST'\n );\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet = this._protocol._packetRW.write.alloc(\n 1 + 4 + 4 + 4,\n true\n );\n packet[p] = MESSAGE.KEXDH_GEX_REQUEST;\n writeUInt32BE(packet, this._minBits, ++p);\n writeUInt32BE(packet, this._prefBits, p += 4);\n writeUInt32BE(packet, this._maxBits, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n generateKeys() {\n if (!this._dh && this._prime && this._generator) {\n this._dh = createDiffieHellman(this._prime, this._generator);\n this._public = this._dh.generateKeys();\n }\n }\n setDHParams(prime, generator) {\n if (!Buffer.isBuffer(prime))\n throw new Error('Invalid prime value');\n if (!Buffer.isBuffer(generator))\n throw new Error('Invalid generator value');\n this._prime = prime;\n this._generator = generator;\n }\n getDHParams() {\n if (this._dh) {\n return {\n prime: convertToMpint(this._dh.getPrime()),\n generator: convertToMpint(this._dh.getGenerator()),\n };\n }\n }\n parse(payload) {\n const type = payload[0];\n switch (this._step) {\n case 1:\n if (this._protocol._server) {\n if (type !== MESSAGE.KEXDH_GEX_REQUEST) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of `\n + MESSAGE.KEXDH_GEX_REQUEST,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n // TODO: allow user implementation to provide safe prime and\n // generator on demand to support group exchange on server side\n return doFatalError(\n this._protocol,\n 'Group exchange not implemented for server',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n if (type !== MESSAGE.KEXDH_GEX_GROUP) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_GROUP}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Group'\n );\n\n /*\n byte SSH_MSG_KEX_DH_GEX_GROUP\n mpint p, safe prime\n mpint g, generator for subgroup in GF(p)\n */\n bufferParser.init(payload, 1);\n let prime;\n let gen;\n if ((prime = bufferParser.readString()) === undefined\n || (gen = bufferParser.readString()) === undefined) {\n bufferParser.clear();\n return doFatalError(\n this._protocol,\n 'Received malformed KEXDH_GEX_GROUP',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n bufferParser.clear();\n\n // TODO: validate prime\n this.setDHParams(prime, gen);\n this.generateKeys();\n const pubkey = this.getPublicKey();\n\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_GEX_INIT'\n );\n\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet =\n this._protocol._packetRW.write.alloc(1 + 4 + pubkey.length, true);\n packet[p] = MESSAGE.KEXDH_GEX_INIT;\n writeUInt32BE(packet, pubkey.length, ++p);\n packet.set(pubkey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n\n ++this._step;\n break;\n case 2:\n if (this._protocol._server) {\n if (type !== MESSAGE.KEXDH_GEX_INIT) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_INIT}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Init'\n );\n return doFatalError(\n this._protocol,\n 'Group exchange not implemented for server',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n } else if (type !== MESSAGE.KEXDH_GEX_REPLY) {\n return doFatalError(\n this._protocol,\n `Received packet ${type} instead of ${MESSAGE.KEXDH_GEX_REPLY}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n this._protocol._debug && this._protocol._debug(\n 'Received DH GEX Reply'\n );\n this._step = 1;\n payload[0] = MESSAGE.KEXDH_REPLY;\n this.parse = KeyExchange.prototype.parse;\n this.parse(payload);\n }\n }\n }\n\n class DHExchange extends KeyExchange {\n constructor(groupName, hashName, ...args) {\n super(...args);\n\n this.type = 'group';\n this.groupName = groupName;\n this.hashName = hashName;\n }\n start() {\n if (!this._protocol._server) {\n this._protocol._debug && this._protocol._debug(\n 'Outbound: Sending KEXDH_INIT'\n );\n const pubKey = this.getPublicKey();\n let p = this._protocol._packetRW.write.allocStartKEX;\n const packet =\n this._protocol._packetRW.write.alloc(1 + 4 + pubKey.length, true);\n packet[p] = MESSAGE.KEXDH_INIT;\n writeUInt32BE(packet, pubKey.length, ++p);\n packet.set(pubKey, p += 4);\n this._protocol._cipher.encrypt(\n this._protocol._packetRW.write.finalize(packet, true)\n );\n }\n }\n generateKeys() {\n if (!this._dh) {\n this._dh = createDiffieHellmanGroup(this.groupName);\n this._public = this._dh.generateKeys();\n }\n }\n getDHParams() {\n if (this._dh) {\n return {\n prime: convertToMpint(this._dh.getPrime()),\n generator: convertToMpint(this._dh.getGenerator()),\n };\n }\n }\n }\n\n return (negotiated, ...args) => {\n if (typeof negotiated !== 'object' || negotiated === null)\n throw new Error('Invalid negotiated argument');\n const kexType = negotiated.kex;\n if (typeof kexType === 'string') {\n args = [negotiated, ...args];\n switch (kexType) {\n case 'curve25519-sha256':\n case 'curve25519-sha256@libssh.org':\n if (!curve25519Supported)\n break;\n return new Curve25519Exchange('sha256', ...args);\n\n case 'ecdh-sha2-nistp256':\n return new ECDHExchange('prime256v1', 'sha256', ...args);\n case 'ecdh-sha2-nistp384':\n return new ECDHExchange('secp384r1', 'sha384', ...args);\n case 'ecdh-sha2-nistp521':\n return new ECDHExchange('secp521r1', 'sha512', ...args);\n\n case 'diffie-hellman-group1-sha1':\n return new DHExchange('modp2', 'sha1', ...args);\n case 'diffie-hellman-group14-sha1':\n return new DHExchange('modp14', 'sha1', ...args);\n case 'diffie-hellman-group14-sha256':\n return new DHExchange('modp14', 'sha256', ...args);\n case 'diffie-hellman-group15-sha512':\n return new DHExchange('modp15', 'sha512', ...args);\n case 'diffie-hellman-group16-sha512':\n return new DHExchange('modp16', 'sha512', ...args);\n case 'diffie-hellman-group17-sha512':\n return new DHExchange('modp17', 'sha512', ...args);\n case 'diffie-hellman-group18-sha512':\n return new DHExchange('modp18', 'sha512', ...args);\n\n case 'diffie-hellman-group-exchange-sha1':\n return new DHGroupExchange('sha1', ...args);\n case 'diffie-hellman-group-exchange-sha256':\n return new DHGroupExchange('sha256', ...args);\n }\n throw new Error(`Unsupported key exchange algorithm: ${kexType}`);\n }\n throw new Error(`Invalid key exchange type: ${kexType}`);\n };\n})();\n\nconst KexInit = (() => {\n const KEX_PROPERTY_NAMES = [\n 'kex',\n 'serverHostKey',\n ['cs', 'cipher' ],\n ['sc', 'cipher' ],\n ['cs', 'mac' ],\n ['sc', 'mac' ],\n ['cs', 'compress' ],\n ['sc', 'compress' ],\n ['cs', 'lang' ],\n ['sc', 'lang' ],\n ];\n return class KexInit {\n constructor(obj) {\n if (typeof obj !== 'object' || obj === null)\n throw new TypeError('Argument must be an object');\n\n const lists = {\n kex: undefined,\n serverHostKey: undefined,\n cs: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n sc: {\n cipher: undefined,\n mac: undefined,\n compress: undefined,\n lang: undefined,\n },\n\n all: undefined,\n };\n let totalSize = 0;\n for (const prop of KEX_PROPERTY_NAMES) {\n let base;\n let val;\n let desc;\n let key;\n if (typeof prop === 'string') {\n base = lists;\n val = obj[prop];\n desc = key = prop;\n } else {\n const parent = prop[0];\n base = lists[parent];\n key = prop[1];\n val = obj[parent][key];\n desc = `${parent}.${key}`;\n }\n const entry = { array: undefined, buffer: undefined };\n if (Buffer.isBuffer(val)) {\n entry.array = ('' + val).split(',');\n entry.buffer = val;\n totalSize += 4 + val.length;\n } else {\n if (typeof val === 'string')\n val = val.split(',');\n if (Array.isArray(val)) {\n entry.array = val;\n entry.buffer = Buffer.from(val.join(','));\n } else {\n throw new TypeError(`Invalid \\`${desc}\\` type: ${typeof val}`);\n }\n totalSize += 4 + entry.buffer.length;\n }\n base[key] = entry;\n }\n\n const all = Buffer.allocUnsafe(totalSize);\n lists.all = all;\n\n let allPos = 0;\n for (const prop of KEX_PROPERTY_NAMES) {\n let data;\n if (typeof prop === 'string')\n data = lists[prop].buffer;\n else\n data = lists[prop[0]][prop[1]].buffer;\n allPos = writeUInt32BE(all, data.length, allPos);\n all.set(data, allPos);\n allPos += data.length;\n }\n\n this.totalSize = totalSize;\n this.lists = lists;\n }\n copyAllTo(buf, offset) {\n const src = this.lists.all;\n if (typeof offset !== 'number')\n throw new TypeError(`Invalid offset value: ${typeof offset}`);\n if (buf.length - offset < src.length)\n throw new Error('Insufficient space to copy list');\n buf.set(src, offset);\n return src.length;\n }\n };\n})();\n\nconst hashString = (() => {\n const LEN = Buffer.allocUnsafe(4);\n return (hash, buf) => {\n writeUInt32BE(LEN, buf.length, 0);\n hash.update(LEN);\n hash.update(buf);\n };\n})();\n\nfunction generateKEXVal(len, hashName, secret, exchangeHash, sessionID, char) {\n let ret;\n if (len) {\n let digest = createHash(hashName)\n .update(secret)\n .update(exchangeHash)\n .update(char)\n .update(sessionID)\n .digest();\n while (digest.length < len) {\n const chunk = createHash(hashName)\n .update(secret)\n .update(exchangeHash)\n .update(digest)\n .digest();\n const extended = Buffer.allocUnsafe(digest.length + chunk.length);\n extended.set(digest, 0);\n extended.set(chunk, digest.length);\n digest = extended;\n }\n if (digest.length === len)\n ret = digest;\n else\n ret = new FastBuffer(digest.buffer, digest.byteOffset, len);\n } else {\n ret = EMPTY_BUFFER;\n }\n return ret;\n}\n\nfunction onKEXPayload(state, payload) {\n // XXX: move this to the Decipher implementations?\n if (payload.length === 0) {\n this._debug && this._debug('Inbound: Skipping empty packet payload');\n return;\n }\n\n if (this._skipNextInboundPacket) {\n this._skipNextInboundPacket = false;\n return;\n }\n\n payload = this._packetRW.read.read(payload);\n\n const type = payload[0];\n switch (type) {\n case MESSAGE.DISCONNECT:\n case MESSAGE.IGNORE:\n case MESSAGE.UNIMPLEMENTED:\n case MESSAGE.DEBUG:\n if (!MESSAGE_HANDLERS)\n MESSAGE_HANDLERS = require('./handlers.js');\n return MESSAGE_HANDLERS[type](this, payload);\n case MESSAGE.KEXINIT:\n if (!state.firstPacket) {\n return doFatalError(\n this,\n 'Received extra KEXINIT during handshake',\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n state.firstPacket = false;\n return handleKexInit(this, payload);\n default:\n if (type < 20 || type > 49) {\n return doFatalError(\n this,\n `Received unexpected packet type ${type}`,\n 'handshake',\n DISCONNECT_REASON.KEY_EXCHANGE_FAILED\n );\n }\n }\n\n return this._kex.parse(payload);\n}\n\nfunction dhEstimate(neg) {\n const csCipher = CIPHER_INFO[neg.cs.cipher];\n const scCipher = CIPHER_INFO[neg.sc.cipher];\n // XXX: if OpenSSH's `umac-*` MACs are ever supported, their key lengths will\n // also need to be considered when calculating `bits`\n const bits = Math.max(\n 0,\n (csCipher.sslName === 'des-ede3-cbc' ? 14 : csCipher.keyLen),\n csCipher.blockLen,\n csCipher.ivLen,\n (scCipher.sslName === 'des-ede3-cbc' ? 14 : scCipher.keyLen),\n scCipher.blockLen,\n scCipher.ivLen\n ) * 8;\n if (bits <= 112)\n return 2048;\n if (bits <= 128)\n return 3072;\n if (bits <= 192)\n return 7680;\n return 8192;\n}\n\nfunction trySendNEWKEYS(kex) {\n if (!kex._sentNEWKEYS) {\n kex._protocol._debug && kex._protocol._debug(\n 'Outbound: Sending NEWKEYS'\n );\n const p = kex._protocol._packetRW.write.allocStartKEX;\n const packet = kex._protocol._packetRW.write.alloc(1, true);\n packet[p] = MESSAGE.NEWKEYS;\n kex._protocol._cipher.encrypt(\n kex._protocol._packetRW.write.finalize(packet, true)\n );\n kex._sentNEWKEYS = true;\n }\n}\n\nmodule.exports = {\n KexInit,\n kexinit,\n onKEXPayload,\n DEFAULT_KEXINIT: new KexInit({\n kex: DEFAULT_KEX,\n serverHostKey: DEFAULT_SERVER_HOST_KEY,\n cs: {\n cipher: DEFAULT_CIPHER,\n mac: DEFAULT_MAC,\n compress: DEFAULT_COMPRESSION,\n lang: [],\n },\n sc: {\n cipher: DEFAULT_CIPHER,\n mac: DEFAULT_MAC,\n compress: DEFAULT_COMPRESSION,\n lang: [],\n },\n }),\n HANDLERS: {\n [MESSAGE.KEXINIT]: handleKexInit,\n },\n};\n","// TODO:\n// * utilize `crypto.create(Private|Public)Key()` and `keyObject.export()`\n// * handle multi-line header values (OpenSSH)?\n// * more thorough validation?\n'use strict';\n\nconst {\n createDecipheriv,\n createECDH,\n createHash,\n createHmac,\n createSign,\n createVerify,\n getCiphers,\n sign: sign_,\n verify: verify_,\n} = require('crypto');\nconst supportedOpenSSLCiphers = getCiphers();\n\nconst { Ber } = require('asn1');\nconst bcrypt_pbkdf = require('bcrypt-pbkdf').pbkdf;\n\nconst { CIPHER_INFO } = require('./crypto.js');\nconst { eddsaSupported, SUPPORTED_CIPHER } = require('./constants.js');\nconst {\n bufferSlice,\n makeBufferParser,\n readString,\n readUInt32BE,\n writeUInt32BE,\n} = require('./utils.js');\n\nconst SYM_HASH_ALGO = Symbol('Hash Algorithm');\nconst SYM_PRIV_PEM = Symbol('Private key PEM');\nconst SYM_PUB_PEM = Symbol('Public key PEM');\nconst SYM_PUB_SSH = Symbol('Public key SSH');\nconst SYM_DECRYPTED = Symbol('Decrypted Key');\n\n// Create OpenSSL cipher name -> SSH cipher name conversion table\nconst CIPHER_INFO_OPENSSL = Object.create(null);\n{\n const keys = Object.keys(CIPHER_INFO);\n for (let i = 0; i < keys.length; ++i) {\n const cipherName = CIPHER_INFO[keys[i]].sslName;\n if (!cipherName || CIPHER_INFO_OPENSSL[cipherName])\n continue;\n CIPHER_INFO_OPENSSL[cipherName] = CIPHER_INFO[keys[i]];\n }\n}\n\nconst binaryKeyParser = makeBufferParser();\n\nfunction makePEM(type, data) {\n data = data.base64Slice(0, data.length);\n let formatted = data.replace(/.{64}/g, '$&\\n');\n if (data.length & 63)\n formatted += '\\n';\n return `-----BEGIN ${type} KEY-----\\n${formatted}-----END ${type} KEY-----`;\n}\n\nfunction combineBuffers(buf1, buf2) {\n const result = Buffer.allocUnsafe(buf1.length + buf2.length);\n result.set(buf1, 0);\n result.set(buf2, buf1.length);\n return result;\n}\n\nfunction skipFields(buf, nfields) {\n const bufLen = buf.length;\n let pos = (buf._pos || 0);\n for (let i = 0; i < nfields; ++i) {\n const left = (bufLen - pos);\n if (pos >= bufLen || left < 4)\n return false;\n const len = readUInt32BE(buf, pos);\n if (left < 4 + len)\n return false;\n pos += 4 + len;\n }\n buf._pos = pos;\n return true;\n}\n\nfunction genOpenSSLRSAPub(n, e) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.113549.1.1.1'); // rsaEncryption\n // algorithm parameters (RSA has none)\n asnWriter.writeNull();\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n asnWriter.startSequence();\n asnWriter.writeBuffer(n, Ber.Integer);\n asnWriter.writeBuffer(e, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHRSAPub(n, e) {\n const publicKey = Buffer.allocUnsafe(4 + 7 + 4 + e.length + 4 + n.length);\n\n writeUInt32BE(publicKey, 7, 0);\n publicKey.utf8Write('ssh-rsa', 4, 7);\n\n let i = 4 + 7;\n writeUInt32BE(publicKey, e.length, i);\n publicKey.set(e, i += 4);\n\n writeUInt32BE(publicKey, n.length, i += e.length);\n publicKey.set(n, i + 4);\n\n return publicKey;\n}\n\nconst genOpenSSLRSAPriv = (() => {\n function genRSAASN1Buf(n, e, d, p, q, dmp1, dmq1, iqmp) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeInt(0x00, Ber.Integer);\n asnWriter.writeBuffer(n, Ber.Integer);\n asnWriter.writeBuffer(e, Ber.Integer);\n asnWriter.writeBuffer(d, Ber.Integer);\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(dmp1, Ber.Integer);\n asnWriter.writeBuffer(dmq1, Ber.Integer);\n asnWriter.writeBuffer(iqmp, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n\n function bigIntFromBuffer(buf) {\n return BigInt(`0x${buf.hexSlice(0, buf.length)}`);\n }\n\n function bigIntToBuffer(bn) {\n let hex = bn.toString(16);\n if ((hex.length & 1) !== 0) {\n hex = `0${hex}`;\n } else {\n const sigbit = hex.charCodeAt(0);\n // BER/DER integers require leading zero byte to denote a positive value\n // when first byte >= 0x80\n if (sigbit === 56/* '8' */\n || sigbit === 57/* '9' */\n || (sigbit >= 97/* 'a' */ && sigbit <= 102/* 'f' */)) {\n hex = `00${hex}`;\n }\n }\n return Buffer.from(hex, 'hex');\n }\n\n return function genOpenSSLRSAPriv(n, e, d, iqmp, p, q) {\n const bn_d = bigIntFromBuffer(d);\n const dmp1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(p) - 1n));\n const dmq1 = bigIntToBuffer(bn_d % (bigIntFromBuffer(q) - 1n));\n return makePEM('RSA PRIVATE',\n genRSAASN1Buf(n, e, d, p, q, dmp1, dmq1, iqmp));\n };\n})();\n\nfunction genOpenSSLDSAPub(p, q, g, y) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.10040.4.1'); // id-dsa\n // algorithm parameters\n asnWriter.startSequence();\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(g, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n asnWriter.writeBuffer(y, Ber.Integer);\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHDSAPub(p, q, g, y) {\n const publicKey = Buffer.allocUnsafe(\n 4 + 7 + 4 + p.length + 4 + q.length + 4 + g.length + 4 + y.length\n );\n\n writeUInt32BE(publicKey, 7, 0);\n publicKey.utf8Write('ssh-dss', 4, 7);\n\n let i = 4 + 7;\n writeUInt32BE(publicKey, p.length, i);\n publicKey.set(p, i += 4);\n\n writeUInt32BE(publicKey, q.length, i += p.length);\n publicKey.set(q, i += 4);\n\n writeUInt32BE(publicKey, g.length, i += q.length);\n publicKey.set(g, i += 4);\n\n writeUInt32BE(publicKey, y.length, i += g.length);\n publicKey.set(y, i + 4);\n\n return publicKey;\n}\n\nfunction genOpenSSLDSAPriv(p, q, g, y, x) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeInt(0x00, Ber.Integer);\n asnWriter.writeBuffer(p, Ber.Integer);\n asnWriter.writeBuffer(q, Ber.Integer);\n asnWriter.writeBuffer(g, Ber.Integer);\n asnWriter.writeBuffer(y, Ber.Integer);\n asnWriter.writeBuffer(x, Ber.Integer);\n asnWriter.endSequence();\n return makePEM('DSA PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLEdPub(pub) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.112'); // id-Ed25519\n asnWriter.endSequence();\n\n // PublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(pub.length);\n asnWriter._buf.set(pub, asnWriter._offset);\n asnWriter._offset += pub.length;\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHEdPub(pub) {\n const publicKey = Buffer.allocUnsafe(4 + 11 + 4 + pub.length);\n\n writeUInt32BE(publicKey, 11, 0);\n publicKey.utf8Write('ssh-ed25519', 4, 11);\n\n writeUInt32BE(publicKey, pub.length, 15);\n publicKey.set(pub, 19);\n\n return publicKey;\n}\n\nfunction genOpenSSLEdPriv(priv) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // version\n asnWriter.writeInt(0x00, Ber.Integer);\n\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.3.101.112'); // id-Ed25519\n asnWriter.endSequence();\n\n // PrivateKey\n asnWriter.startSequence(Ber.OctetString);\n asnWriter.writeBuffer(priv, Ber.OctetString);\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLECDSAPub(oid, Q) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // algorithm\n asnWriter.startSequence();\n asnWriter.writeOID('1.2.840.10045.2.1'); // id-ecPublicKey\n // algorithm parameters (namedCurve)\n asnWriter.writeOID(oid);\n asnWriter.endSequence();\n\n // subjectPublicKey\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(Q.length);\n asnWriter._buf.set(Q, asnWriter._offset);\n asnWriter._offset += Q.length;\n // end hack\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('PUBLIC', asnWriter.buffer);\n}\n\nfunction genOpenSSHECDSAPub(oid, Q) {\n let curveName;\n switch (oid) {\n case '1.2.840.10045.3.1.7':\n // prime256v1/secp256r1\n curveName = 'nistp256';\n break;\n case '1.3.132.0.34':\n // secp384r1\n curveName = 'nistp384';\n break;\n case '1.3.132.0.35':\n // secp521r1\n curveName = 'nistp521';\n break;\n default:\n return;\n }\n\n const publicKey = Buffer.allocUnsafe(4 + 19 + 4 + 8 + 4 + Q.length);\n\n writeUInt32BE(publicKey, 19, 0);\n publicKey.utf8Write(`ecdsa-sha2-${curveName}`, 4, 19);\n\n writeUInt32BE(publicKey, 8, 23);\n publicKey.utf8Write(curveName, 27, 8);\n\n writeUInt32BE(publicKey, Q.length, 35);\n publicKey.set(Q, 39);\n\n return publicKey;\n}\n\nfunction genOpenSSLECDSAPriv(oid, pub, priv) {\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n // version\n asnWriter.writeInt(0x01, Ber.Integer);\n // privateKey\n asnWriter.writeBuffer(priv, Ber.OctetString);\n // parameters (optional)\n asnWriter.startSequence(0xA0);\n asnWriter.writeOID(oid);\n asnWriter.endSequence();\n // publicKey (optional)\n asnWriter.startSequence(0xA1);\n asnWriter.startSequence(Ber.BitString);\n asnWriter.writeByte(0x00);\n // XXX: hack to write a raw buffer without a tag -- yuck\n asnWriter._ensure(pub.length);\n asnWriter._buf.set(pub, asnWriter._offset);\n asnWriter._offset += pub.length;\n // end hack\n asnWriter.endSequence();\n asnWriter.endSequence();\n asnWriter.endSequence();\n return makePEM('EC PRIVATE', asnWriter.buffer);\n}\n\nfunction genOpenSSLECDSAPubFromPriv(curveName, priv) {\n const tempECDH = createECDH(curveName);\n tempECDH.setPrivateKey(priv);\n return tempECDH.getPublicKey();\n}\n\nconst BaseKey = {\n sign: (() => {\n if (typeof sign_ === 'function') {\n return function sign(data, algo) {\n const pem = this[SYM_PRIV_PEM];\n if (pem === null)\n return new Error('No private key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n try {\n return sign_(algo, data, pem);\n } catch (ex) {\n return ex;\n }\n };\n }\n return function sign(data, algo) {\n const pem = this[SYM_PRIV_PEM];\n if (pem === null)\n return new Error('No private key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n const signature = createSign(algo);\n signature.update(data);\n try {\n return signature.sign(pem);\n } catch (ex) {\n return ex;\n }\n };\n })(),\n verify: (() => {\n if (typeof verify_ === 'function') {\n return function verify(data, signature, algo) {\n const pem = this[SYM_PUB_PEM];\n if (pem === null)\n return new Error('No public key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n try {\n return verify_(algo, data, pem, signature);\n } catch (ex) {\n return ex;\n }\n };\n }\n return function verify(data, signature, algo) {\n const pem = this[SYM_PUB_PEM];\n if (pem === null)\n return new Error('No public key available');\n if (!algo || typeof algo !== 'string')\n algo = this[SYM_HASH_ALGO];\n const verifier = createVerify(algo);\n verifier.update(data);\n try {\n return verifier.verify(pem, signature);\n } catch (ex) {\n return ex;\n }\n };\n })(),\n isPrivateKey: function isPrivateKey() {\n return (this[SYM_PRIV_PEM] !== null);\n },\n getPrivatePEM: function getPrivatePEM() {\n return this[SYM_PRIV_PEM];\n },\n getPublicPEM: function getPublicPEM() {\n return this[SYM_PUB_PEM];\n },\n getPublicSSH: function getPublicSSH() {\n return this[SYM_PUB_SSH];\n },\n equals: function equals(key) {\n const parsed = parseKey(key);\n if (parsed instanceof Error)\n return false;\n return (\n this.type === parsed.type\n && this[SYM_PRIV_PEM] === parsed[SYM_PRIV_PEM]\n && this[SYM_PUB_PEM] === parsed[SYM_PUB_PEM]\n && this[SYM_PUB_SSH] === parsed[SYM_PUB_SSH]\n );\n },\n};\n\n\nfunction OpenSSH_Private(type, comment, privPEM, pubPEM, pubSSH, algo,\n decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nOpenSSH_Private.prototype = BaseKey;\n{\n const regexp = /^-----BEGIN OPENSSH PRIVATE KEY-----(?:\\r\\n|\\n)([\\s\\S]+)(?:\\r\\n|\\n)-----END OPENSSH PRIVATE KEY-----$/;\n OpenSSH_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n let ret;\n const data = Buffer.from(m[1], 'base64');\n if (data.length < 31) // magic (+ magic null term.) + minimum field lengths\n return new Error('Malformed OpenSSH private key');\n const magic = data.utf8Slice(0, 15);\n if (magic !== 'openssh-key-v1\\0')\n return new Error(`Unsupported OpenSSH key magic: ${magic}`);\n\n const cipherName = readString(data, 15, true);\n if (cipherName === undefined)\n return new Error('Malformed OpenSSH private key');\n if (cipherName !== 'none' && SUPPORTED_CIPHER.indexOf(cipherName) === -1)\n return new Error(`Unsupported cipher for OpenSSH key: ${cipherName}`);\n\n const kdfName = readString(data, data._pos, true);\n if (kdfName === undefined)\n return new Error('Malformed OpenSSH private key');\n if (kdfName !== 'none') {\n if (cipherName === 'none')\n return new Error('Malformed OpenSSH private key');\n if (kdfName !== 'bcrypt')\n return new Error(`Unsupported kdf name for OpenSSH key: ${kdfName}`);\n if (!passphrase) {\n return new Error(\n 'Encrypted private OpenSSH key detected, but no passphrase given'\n );\n }\n } else if (cipherName !== 'none') {\n return new Error('Malformed OpenSSH private key');\n }\n\n let encInfo;\n let cipherKey;\n let cipherIV;\n if (cipherName !== 'none')\n encInfo = CIPHER_INFO[cipherName];\n const kdfOptions = readString(data, data._pos);\n if (kdfOptions === undefined)\n return new Error('Malformed OpenSSH private key');\n if (kdfOptions.length) {\n switch (kdfName) {\n case 'none':\n return new Error('Malformed OpenSSH private key');\n case 'bcrypt':\n /*\n string salt\n uint32 rounds\n */\n const salt = readString(kdfOptions, 0);\n if (salt === undefined || kdfOptions._pos + 4 > kdfOptions.length)\n return new Error('Malformed OpenSSH private key');\n const rounds = readUInt32BE(kdfOptions, kdfOptions._pos);\n const gen = Buffer.allocUnsafe(encInfo.keyLen + encInfo.ivLen);\n const r = bcrypt_pbkdf(passphrase,\n passphrase.length,\n salt,\n salt.length,\n gen,\n gen.length,\n rounds);\n if (r !== 0)\n return new Error('Failed to generate information to decrypt key');\n cipherKey = bufferSlice(gen, 0, encInfo.keyLen);\n cipherIV = bufferSlice(gen, encInfo.keyLen, gen.length);\n break;\n }\n } else if (kdfName !== 'none') {\n return new Error('Malformed OpenSSH private key');\n }\n\n if (data._pos + 3 >= data.length)\n return new Error('Malformed OpenSSH private key');\n const keyCount = readUInt32BE(data, data._pos);\n data._pos += 4;\n\n if (keyCount > 0) {\n // TODO: place sensible limit on max `keyCount`\n\n // Read public keys first\n for (let i = 0; i < keyCount; ++i) {\n const pubData = readString(data, data._pos);\n if (pubData === undefined)\n return new Error('Malformed OpenSSH private key');\n const type = readString(pubData, 0, true);\n if (type === undefined)\n return new Error('Malformed OpenSSH private key');\n }\n\n let privBlob = readString(data, data._pos);\n if (privBlob === undefined)\n return new Error('Malformed OpenSSH private key');\n\n if (cipherKey !== undefined) {\n // Encrypted private key(s)\n if (privBlob.length < encInfo.blockLen\n || (privBlob.length % encInfo.blockLen) !== 0) {\n return new Error('Malformed OpenSSH private key');\n }\n try {\n const options = { authTagLength: encInfo.authLen };\n const decipher = createDecipheriv(encInfo.sslName,\n cipherKey,\n cipherIV,\n options);\n if (encInfo.authLen > 0) {\n if (data.length - data._pos < encInfo.authLen)\n return new Error('Malformed OpenSSH private key');\n decipher.setAuthTag(\n bufferSlice(data, data._pos, data._pos += encInfo.authLen)\n );\n }\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n } catch (ex) {\n return ex;\n }\n }\n // Nothing should we follow the private key(s), except a possible\n // authentication tag for relevant ciphers\n if (data._pos !== data.length)\n return new Error('Malformed OpenSSH private key');\n\n ret = parseOpenSSHPrivKeys(privBlob, keyCount, cipherKey !== undefined);\n } else {\n ret = [];\n }\n if (ret instanceof Error)\n return ret;\n // This will need to change if/when OpenSSH ever starts storing multiple\n // keys in their key files\n return ret[0];\n };\n\n function parseOpenSSHPrivKeys(data, nkeys, decrypted) {\n const keys = [];\n /*\n uint32 checkint\n uint32 checkint\n string privatekey1\n string comment1\n string privatekey2\n string comment2\n ...\n string privatekeyN\n string commentN\n char 1\n char 2\n char 3\n ...\n char padlen % 255\n */\n if (data.length < 8)\n return new Error('Malformed OpenSSH private key');\n const check1 = readUInt32BE(data, 0);\n const check2 = readUInt32BE(data, 4);\n if (check1 !== check2) {\n if (decrypted) {\n return new Error(\n 'OpenSSH key integrity check failed -- bad passphrase?'\n );\n }\n return new Error('OpenSSH key integrity check failed');\n }\n data._pos = 8;\n let i;\n let oid;\n for (i = 0; i < nkeys; ++i) {\n let algo;\n let privPEM;\n let pubPEM;\n let pubSSH;\n // The OpenSSH documentation for the key format actually lies, the\n // entirety of the private key content is not contained with a string\n // field, it's actually the literal contents of the private key, so to be\n // able to find the end of the key data you need to know the layout/format\n // of each key type ...\n const type = readString(data, data._pos, true);\n if (type === undefined)\n return new Error('Malformed OpenSSH private key');\n\n switch (type) {\n case 'ssh-rsa': {\n /*\n string n -- public\n string e -- public\n string d -- private\n string iqmp -- private\n string p -- private\n string q -- private\n */\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed OpenSSH private key');\n const e = readString(data, data._pos);\n if (e === undefined)\n return new Error('Malformed OpenSSH private key');\n const d = readString(data, data._pos);\n if (d === undefined)\n return new Error('Malformed OpenSSH private key');\n const iqmp = readString(data, data._pos);\n if (iqmp === undefined)\n return new Error('Malformed OpenSSH private key');\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed OpenSSH private key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n privPEM = genOpenSSLRSAPriv(n, e, d, iqmp, p, q);\n algo = 'sha1';\n break;\n }\n case 'ssh-dss': {\n /*\n string p -- public\n string q -- public\n string g -- public\n string y -- public\n string x -- private\n */\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed OpenSSH private key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH private key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed OpenSSH private key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed OpenSSH private key');\n const x = readString(data, data._pos);\n if (x === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n privPEM = genOpenSSLDSAPriv(p, q, g, y, x);\n algo = 'sha1';\n break;\n }\n case 'ssh-ed25519': {\n if (!eddsaSupported)\n return new Error(`Unsupported OpenSSH private key type: ${type}`);\n /*\n * string public key\n * string private key + public key\n */\n const edpub = readString(data, data._pos);\n if (edpub === undefined || edpub.length !== 32)\n return new Error('Malformed OpenSSH private key');\n const edpriv = readString(data, data._pos);\n if (edpriv === undefined || edpriv.length !== 64)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLEdPub(edpub);\n pubSSH = genOpenSSHEdPub(edpub);\n privPEM = genOpenSSLEdPriv(bufferSlice(edpriv, 0, 32));\n algo = null;\n break;\n }\n case 'ecdsa-sha2-nistp256':\n algo = 'sha256';\n oid = '1.2.840.10045.3.1.7';\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp384':\n if (algo === undefined) {\n algo = 'sha384';\n oid = '1.3.132.0.34';\n }\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp521': {\n if (algo === undefined) {\n algo = 'sha512';\n oid = '1.3.132.0.35';\n }\n /*\n string curve name\n string Q -- public\n string d -- private\n */\n // TODO: validate curve name against type\n if (!skipFields(data, 1)) // Skip curve name\n return new Error('Malformed OpenSSH private key');\n const ecpub = readString(data, data._pos);\n if (ecpub === undefined)\n return new Error('Malformed OpenSSH private key');\n const ecpriv = readString(data, data._pos);\n if (ecpriv === undefined)\n return new Error('Malformed OpenSSH private key');\n\n pubPEM = genOpenSSLECDSAPub(oid, ecpub);\n pubSSH = genOpenSSHECDSAPub(oid, ecpub);\n privPEM = genOpenSSLECDSAPriv(oid, ecpub, ecpriv);\n break;\n }\n default:\n return new Error(`Unsupported OpenSSH private key type: ${type}`);\n }\n\n const privComment = readString(data, data._pos, true);\n if (privComment === undefined)\n return new Error('Malformed OpenSSH private key');\n\n keys.push(\n new OpenSSH_Private(type, privComment, privPEM, pubPEM, pubSSH, algo,\n decrypted)\n );\n }\n let cnt = 0;\n for (i = data._pos; i < data.length; ++i) {\n if (data[i] !== (++cnt % 255))\n return new Error('Malformed OpenSSH private key');\n }\n\n return keys;\n }\n}\n\n\nfunction OpenSSH_Old_Private(type, comment, privPEM, pubPEM, pubSSH, algo,\n decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nOpenSSH_Old_Private.prototype = BaseKey;\n{\n const regexp = /^-----BEGIN (RSA|DSA|EC) PRIVATE KEY-----(?:\\r\\n|\\n)((?:[^:]+:\\s*[\\S].*(?:\\r\\n|\\n))*)([\\s\\S]+)(?:\\r\\n|\\n)-----END (RSA|DSA|EC) PRIVATE KEY-----$/;\n OpenSSH_Old_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n let privBlob = Buffer.from(m[3], 'base64');\n let headers = m[2];\n let decrypted = false;\n if (headers !== undefined) {\n // encrypted key\n headers = headers.split(/\\r\\n|\\n/g);\n for (let i = 0; i < headers.length; ++i) {\n const header = headers[i];\n let sepIdx = header.indexOf(':');\n if (header.slice(0, sepIdx) === 'DEK-Info') {\n const val = header.slice(sepIdx + 2);\n sepIdx = val.indexOf(',');\n if (sepIdx === -1)\n continue;\n const cipherName = val.slice(0, sepIdx).toLowerCase();\n if (supportedOpenSSLCiphers.indexOf(cipherName) === -1) {\n return new Error(\n `Cipher (${cipherName}) not supported `\n + 'for encrypted OpenSSH private key'\n );\n }\n const encInfo = CIPHER_INFO_OPENSSL[cipherName];\n if (!encInfo) {\n return new Error(\n `Cipher (${cipherName}) not supported `\n + 'for encrypted OpenSSH private key'\n );\n }\n const cipherIV = Buffer.from(val.slice(sepIdx + 1), 'hex');\n if (cipherIV.length !== encInfo.ivLen)\n return new Error('Malformed encrypted OpenSSH private key');\n if (!passphrase) {\n return new Error(\n 'Encrypted OpenSSH private key detected, but no passphrase given'\n );\n }\n const ivSlice = bufferSlice(cipherIV, 0, 8);\n let cipherKey = createHash('md5')\n .update(passphrase)\n .update(ivSlice)\n .digest();\n while (cipherKey.length < encInfo.keyLen) {\n cipherKey = combineBuffers(\n cipherKey,\n createHash('md5')\n .update(cipherKey)\n .update(passphrase)\n .update(ivSlice)\n .digest()\n );\n }\n if (cipherKey.length > encInfo.keyLen)\n cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);\n try {\n const decipher = createDecipheriv(cipherName, cipherKey, cipherIV);\n decipher.setAutoPadding(false);\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n decrypted = true;\n } catch (ex) {\n return ex;\n }\n }\n }\n }\n\n let type;\n let privPEM;\n let pubPEM;\n let pubSSH;\n let algo;\n let reader;\n let errMsg = 'Malformed OpenSSH private key';\n if (decrypted)\n errMsg += '. Bad passphrase?';\n switch (m[1]) {\n case 'RSA':\n type = 'ssh-rsa';\n privPEM = makePEM('RSA PRIVATE', privBlob);\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n const n = reader.readString(Ber.Integer, true);\n if (n === null)\n return new Error(errMsg);\n const e = reader.readString(Ber.Integer, true);\n if (e === null)\n return new Error(errMsg);\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n } catch {\n return new Error(errMsg);\n }\n algo = 'sha1';\n break;\n case 'DSA':\n type = 'ssh-dss';\n privPEM = makePEM('DSA PRIVATE', privBlob);\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n const p = reader.readString(Ber.Integer, true);\n if (p === null)\n return new Error(errMsg);\n const q = reader.readString(Ber.Integer, true);\n if (q === null)\n return new Error(errMsg);\n const g = reader.readString(Ber.Integer, true);\n if (g === null)\n return new Error(errMsg);\n const y = reader.readString(Ber.Integer, true);\n if (y === null)\n return new Error(errMsg);\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n } catch {\n return new Error(errMsg);\n }\n algo = 'sha1';\n break;\n case 'EC':\n let ecSSLName;\n let ecPriv;\n let ecOID;\n try {\n reader = new Ber.Reader(privBlob);\n reader.readSequence();\n reader.readInt(); // skip version\n ecPriv = reader.readString(Ber.OctetString, true);\n reader.readByte(); // Skip \"complex\" context type byte\n const offset = reader.readLength(); // Skip context length\n if (offset !== null) {\n reader._offset = offset;\n ecOID = reader.readOID();\n if (ecOID === null)\n return new Error(errMsg);\n switch (ecOID) {\n case '1.2.840.10045.3.1.7':\n // prime256v1/secp256r1\n ecSSLName = 'prime256v1';\n type = 'ecdsa-sha2-nistp256';\n algo = 'sha256';\n break;\n case '1.3.132.0.34':\n // secp384r1\n ecSSLName = 'secp384r1';\n type = 'ecdsa-sha2-nistp384';\n algo = 'sha384';\n break;\n case '1.3.132.0.35':\n // secp521r1\n ecSSLName = 'secp521r1';\n type = 'ecdsa-sha2-nistp521';\n algo = 'sha512';\n break;\n default:\n return new Error(`Unsupported private key EC OID: ${ecOID}`);\n }\n } else {\n return new Error(errMsg);\n }\n } catch {\n return new Error(errMsg);\n }\n privPEM = makePEM('EC PRIVATE', privBlob);\n const pubBlob = genOpenSSLECDSAPubFromPriv(ecSSLName, ecPriv);\n pubPEM = genOpenSSLECDSAPub(ecOID, pubBlob);\n pubSSH = genOpenSSHECDSAPub(ecOID, pubBlob);\n break;\n }\n\n return new OpenSSH_Old_Private(type, '', privPEM, pubPEM, pubSSH, algo,\n decrypted);\n };\n}\n\n\nfunction PPK_Private(type, comment, privPEM, pubPEM, pubSSH, algo, decrypted) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = privPEM;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = decrypted;\n}\nPPK_Private.prototype = BaseKey;\n{\n const EMPTY_PASSPHRASE = Buffer.alloc(0);\n const PPK_IV = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);\n const PPK_PP1 = Buffer.from([0, 0, 0, 0]);\n const PPK_PP2 = Buffer.from([0, 0, 0, 1]);\n const regexp = /^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\\r?\\nEncryption: (aes256-cbc|none)\\r?\\nComment: ([^\\r\\n]*)\\r?\\nPublic-Lines: \\d+\\r?\\n([\\s\\S]+?)\\r?\\nPrivate-Lines: \\d+\\r?\\n([\\s\\S]+?)\\r?\\nPrivate-MAC: ([^\\r\\n]+)/;\n PPK_Private.parse = (str, passphrase) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n // m[1] = key type\n // m[2] = encryption type\n // m[3] = comment\n // m[4] = base64-encoded public key data:\n // for \"ssh-rsa\":\n // string \"ssh-rsa\"\n // mpint e (public exponent)\n // mpint n (modulus)\n // for \"ssh-dss\":\n // string \"ssh-dss\"\n // mpint p (modulus)\n // mpint q (prime)\n // mpint g (base number)\n // mpint y (public key parameter: g^x mod p)\n // m[5] = base64-encoded private key data:\n // for \"ssh-rsa\":\n // mpint d (private exponent)\n // mpint p (prime 1)\n // mpint q (prime 2)\n // mpint iqmp ([inverse of q] mod p)\n // for \"ssh-dss\":\n // mpint x (private key parameter)\n // m[6] = SHA1 HMAC over:\n // string name of algorithm (\"ssh-dss\", \"ssh-rsa\")\n // string encryption type\n // string comment\n // string public key data\n // string private-plaintext (including the final padding)\n const cipherName = m[2];\n const encrypted = (cipherName !== 'none');\n if (encrypted && !passphrase) {\n return new Error(\n 'Encrypted PPK private key detected, but no passphrase given'\n );\n }\n\n let privBlob = Buffer.from(m[5], 'base64');\n\n if (encrypted) {\n const encInfo = CIPHER_INFO[cipherName];\n let cipherKey = combineBuffers(\n createHash('sha1').update(PPK_PP1).update(passphrase).digest(),\n createHash('sha1').update(PPK_PP2).update(passphrase).digest()\n );\n if (cipherKey.length > encInfo.keyLen)\n cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);\n try {\n const decipher = createDecipheriv(encInfo.sslName,\n cipherKey,\n PPK_IV);\n decipher.setAutoPadding(false);\n privBlob = combineBuffers(decipher.update(privBlob),\n decipher.final());\n } catch (ex) {\n return ex;\n }\n }\n\n const type = m[1];\n const comment = m[3];\n const pubBlob = Buffer.from(m[4], 'base64');\n\n const mac = m[6];\n const typeLen = type.length;\n const cipherNameLen = cipherName.length;\n const commentLen = Buffer.byteLength(comment);\n const pubLen = pubBlob.length;\n const privLen = privBlob.length;\n const macData = Buffer.allocUnsafe(4 + typeLen\n + 4 + cipherNameLen\n + 4 + commentLen\n + 4 + pubLen\n + 4 + privLen);\n let p = 0;\n\n writeUInt32BE(macData, typeLen, p);\n macData.utf8Write(type, p += 4, typeLen);\n writeUInt32BE(macData, cipherNameLen, p += typeLen);\n macData.utf8Write(cipherName, p += 4, cipherNameLen);\n writeUInt32BE(macData, commentLen, p += cipherNameLen);\n macData.utf8Write(comment, p += 4, commentLen);\n writeUInt32BE(macData, pubLen, p += commentLen);\n macData.set(pubBlob, p += 4);\n writeUInt32BE(macData, privLen, p += pubLen);\n macData.set(privBlob, p + 4);\n\n if (!passphrase)\n passphrase = EMPTY_PASSPHRASE;\n\n const calcMAC = createHmac(\n 'sha1',\n createHash('sha1')\n .update('putty-private-key-file-mac-key')\n .update(passphrase)\n .digest()\n ).update(macData).digest('hex');\n\n if (calcMAC !== mac) {\n if (encrypted) {\n return new Error(\n 'PPK private key integrity check failed -- bad passphrase?'\n );\n }\n return new Error('PPK private key integrity check failed');\n }\n\n let pubPEM;\n let pubSSH;\n let privPEM;\n pubBlob._pos = 0;\n skipFields(pubBlob, 1); // skip (duplicate) key type\n switch (type) {\n case 'ssh-rsa': {\n const e = readString(pubBlob, pubBlob._pos);\n if (e === undefined)\n return new Error('Malformed PPK public key');\n const n = readString(pubBlob, pubBlob._pos);\n if (n === undefined)\n return new Error('Malformed PPK public key');\n const d = readString(privBlob, 0);\n if (d === undefined)\n return new Error('Malformed PPK private key');\n const p = readString(privBlob, privBlob._pos);\n if (p === undefined)\n return new Error('Malformed PPK private key');\n const q = readString(privBlob, privBlob._pos);\n if (q === undefined)\n return new Error('Malformed PPK private key');\n const iqmp = readString(privBlob, privBlob._pos);\n if (iqmp === undefined)\n return new Error('Malformed PPK private key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n privPEM = genOpenSSLRSAPriv(n, e, d, iqmp, p, q);\n break;\n }\n case 'ssh-dss': {\n const p = readString(pubBlob, pubBlob._pos);\n if (p === undefined)\n return new Error('Malformed PPK public key');\n const q = readString(pubBlob, pubBlob._pos);\n if (q === undefined)\n return new Error('Malformed PPK public key');\n const g = readString(pubBlob, pubBlob._pos);\n if (g === undefined)\n return new Error('Malformed PPK public key');\n const y = readString(pubBlob, pubBlob._pos);\n if (y === undefined)\n return new Error('Malformed PPK public key');\n const x = readString(privBlob, 0);\n if (x === undefined)\n return new Error('Malformed PPK private key');\n\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n privPEM = genOpenSSLDSAPriv(p, q, g, y, x);\n break;\n }\n }\n\n return new PPK_Private(type, comment, privPEM, pubPEM, pubSSH, 'sha1',\n encrypted);\n };\n}\n\n\nfunction OpenSSH_Public(type, comment, pubPEM, pubSSH, algo) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = null;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = false;\n}\nOpenSSH_Public.prototype = BaseKey;\n{\n let regexp;\n if (eddsaSupported)\n regexp = /^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\\s+([\\S].*)?)$/;\n else\n regexp = /^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\\s+([\\S].*)?)$/;\n OpenSSH_Public.parse = (str) => {\n const m = regexp.exec(str);\n if (m === null)\n return null;\n // m[1] = full type\n // m[2] = base type\n // m[3] = base64-encoded public key\n // m[4] = comment\n\n const fullType = m[1];\n const baseType = m[2];\n const data = Buffer.from(m[3], 'base64');\n const comment = (m[4] || '');\n\n const type = readString(data, data._pos, true);\n if (type === undefined || type.indexOf(baseType) !== 0)\n return new Error('Malformed OpenSSH public key');\n\n return parseDER(data, baseType, comment, fullType);\n };\n}\n\n\nfunction RFC4716_Public(type, comment, pubPEM, pubSSH, algo) {\n this.type = type;\n this.comment = comment;\n this[SYM_PRIV_PEM] = null;\n this[SYM_PUB_PEM] = pubPEM;\n this[SYM_PUB_SSH] = pubSSH;\n this[SYM_HASH_ALGO] = algo;\n this[SYM_DECRYPTED] = false;\n}\nRFC4716_Public.prototype = BaseKey;\n{\n const regexp = /^---- BEGIN SSH2 PUBLIC KEY ----(?:\\r?\\n)((?:.{0,72}\\r?\\n)+)---- END SSH2 PUBLIC KEY ----$/;\n const RE_DATA = /^[A-Z0-9a-z/+=\\r\\n]+$/;\n const RE_HEADER = /^([\\x21-\\x39\\x3B-\\x7E]{1,64}): ((?:[^\\\\]*\\\\\\r?\\n)*[^\\r\\n]+)\\r?\\n/gm;\n const RE_HEADER_ENDS = /\\\\\\r?\\n/g;\n RFC4716_Public.parse = (str) => {\n let m = regexp.exec(str);\n if (m === null)\n return null;\n\n const body = m[1];\n let dataStart = 0;\n let comment = '';\n\n while (m = RE_HEADER.exec(body)) {\n const headerName = m[1];\n const headerValue = m[2].replace(RE_HEADER_ENDS, '');\n if (headerValue.length > 1024) {\n RE_HEADER.lastIndex = 0;\n return new Error('Malformed RFC4716 public key');\n }\n\n dataStart = RE_HEADER.lastIndex;\n\n if (headerName.toLowerCase() === 'comment') {\n comment = headerValue;\n if (comment.length > 1\n && comment.charCodeAt(0) === 34/* '\"' */\n && comment.charCodeAt(comment.length - 1) === 34/* '\"' */) {\n comment = comment.slice(1, -1);\n }\n }\n }\n\n let data = body.slice(dataStart);\n if (!RE_DATA.test(data))\n return new Error('Malformed RFC4716 public key');\n\n data = Buffer.from(data, 'base64');\n\n const type = readString(data, 0, true);\n if (type === undefined)\n return new Error('Malformed RFC4716 public key');\n\n let pubPEM = null;\n let pubSSH = null;\n switch (type) {\n case 'ssh-rsa': {\n const e = readString(data, data._pos);\n if (e === undefined)\n return new Error('Malformed RFC4716 public key');\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed RFC4716 public key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n break;\n }\n case 'ssh-dss': {\n const p = readString(data, data._pos);\n if (p === undefined)\n return new Error('Malformed RFC4716 public key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed RFC4716 public key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed RFC4716 public key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed RFC4716 public key');\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n break;\n }\n default:\n return new Error('Malformed RFC4716 public key');\n }\n\n return new RFC4716_Public(type, comment, pubPEM, pubSSH, 'sha1');\n };\n}\n\n\nfunction parseDER(data, baseType, comment, fullType) {\n if (!isSupportedKeyType(baseType))\n return new Error(`Unsupported OpenSSH public key type: ${baseType}`);\n\n let algo;\n let oid;\n let pubPEM = null;\n let pubSSH = null;\n\n switch (baseType) {\n case 'ssh-rsa': {\n const e = readString(data, data._pos || 0);\n if (e === undefined)\n return new Error('Malformed OpenSSH public key');\n const n = readString(data, data._pos);\n if (n === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLRSAPub(n, e);\n pubSSH = genOpenSSHRSAPub(n, e);\n algo = 'sha1';\n break;\n }\n case 'ssh-dss': {\n const p = readString(data, data._pos || 0);\n if (p === undefined)\n return new Error('Malformed OpenSSH public key');\n const q = readString(data, data._pos);\n if (q === undefined)\n return new Error('Malformed OpenSSH public key');\n const g = readString(data, data._pos);\n if (g === undefined)\n return new Error('Malformed OpenSSH public key');\n const y = readString(data, data._pos);\n if (y === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLDSAPub(p, q, g, y);\n pubSSH = genOpenSSHDSAPub(p, q, g, y);\n algo = 'sha1';\n break;\n }\n case 'ssh-ed25519': {\n const edpub = readString(data, data._pos || 0);\n if (edpub === undefined || edpub.length !== 32)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLEdPub(edpub);\n pubSSH = genOpenSSHEdPub(edpub);\n algo = null;\n break;\n }\n case 'ecdsa-sha2-nistp256':\n algo = 'sha256';\n oid = '1.2.840.10045.3.1.7';\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp384':\n if (algo === undefined) {\n algo = 'sha384';\n oid = '1.3.132.0.34';\n }\n // FALLTHROUGH\n case 'ecdsa-sha2-nistp521': {\n if (algo === undefined) {\n algo = 'sha512';\n oid = '1.3.132.0.35';\n }\n // TODO: validate curve name against type\n if (!skipFields(data, 1)) // Skip curve name\n return new Error('Malformed OpenSSH public key');\n const ecpub = readString(data, data._pos || 0);\n if (ecpub === undefined)\n return new Error('Malformed OpenSSH public key');\n pubPEM = genOpenSSLECDSAPub(oid, ecpub);\n pubSSH = genOpenSSHECDSAPub(oid, ecpub);\n break;\n }\n default:\n return new Error(`Unsupported OpenSSH public key type: ${baseType}`);\n }\n\n return new OpenSSH_Public(fullType, comment, pubPEM, pubSSH, algo);\n}\n\nfunction isSupportedKeyType(type) {\n switch (type) {\n case 'ssh-rsa':\n case 'ssh-dss':\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521':\n return true;\n case 'ssh-ed25519':\n if (eddsaSupported)\n return true;\n // FALLTHROUGH\n default:\n return false;\n }\n}\n\nfunction isParsedKey(val) {\n if (!val)\n return false;\n return (typeof val[SYM_DECRYPTED] === 'boolean');\n}\n\nfunction parseKey(data, passphrase) {\n if (isParsedKey(data))\n return data;\n\n let origBuffer;\n if (Buffer.isBuffer(data)) {\n origBuffer = data;\n data = data.utf8Slice(0, data.length).trim();\n } else if (typeof data === 'string') {\n data = data.trim();\n } else {\n return new Error('Key data must be a Buffer or string');\n }\n\n // eslint-disable-next-line eqeqeq\n if (passphrase != undefined) {\n if (typeof passphrase === 'string')\n passphrase = Buffer.from(passphrase);\n else if (!Buffer.isBuffer(passphrase))\n return new Error('Passphrase must be a string or Buffer when supplied');\n }\n\n let ret;\n\n // First try as printable string format (e.g. PEM)\n\n // Private keys\n if ((ret = OpenSSH_Private.parse(data, passphrase)) !== null)\n return ret;\n if ((ret = OpenSSH_Old_Private.parse(data, passphrase)) !== null)\n return ret;\n if ((ret = PPK_Private.parse(data, passphrase)) !== null)\n return ret;\n\n // Public keys\n if ((ret = OpenSSH_Public.parse(data)) !== null)\n return ret;\n if ((ret = RFC4716_Public.parse(data)) !== null)\n return ret;\n\n // Finally try as a binary format if we were originally passed binary data\n if (origBuffer) {\n binaryKeyParser.init(origBuffer, 0);\n const type = binaryKeyParser.readString(true);\n if (type !== undefined) {\n data = binaryKeyParser.readRaw();\n if (data !== undefined) {\n ret = parseDER(data, type, '', type);\n // Ignore potentially useless errors in case the data was not actually\n // in the binary format\n if (ret instanceof Error)\n ret = null;\n }\n }\n binaryKeyParser.clear();\n }\n\n if (ret)\n return ret;\n\n return new Error('Unsupported key format');\n}\n\nmodule.exports = {\n isParsedKey,\n isSupportedKeyType,\n parseDERKey: (data, type) => parseDER(data, type, '', type),\n parseKey,\n};\n","'use strict';\n\nconst assert = require('assert');\nconst { inspect } = require('util');\n\n// Only use this for integers! Decimal numbers do not work with this function.\nfunction addNumericalSeparator(val) {\n let res = '';\n let i = val.length;\n const start = val[0] === '-' ? 1 : 0;\n for (; i >= start + 4; i -= 3)\n res = `_${val.slice(i - 3, i)}${res}`;\n return `${val.slice(0, i)}${res}`;\n}\n\nfunction oneOf(expected, thing) {\n assert(typeof thing === 'string', '`thing` has to be of type string');\n if (Array.isArray(expected)) {\n const len = expected.length;\n assert(len > 0, 'At least one expected value needs to be specified');\n expected = expected.map((i) => String(i));\n if (len > 2) {\n return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or `\n + expected[len - 1];\n } else if (len === 2) {\n return `one of ${thing} ${expected[0]} or ${expected[1]}`;\n }\n return `of ${thing} ${expected[0]}`;\n }\n return `of ${thing} ${String(expected)}`;\n}\n\n\nexports.ERR_INTERNAL_ASSERTION = class ERR_INTERNAL_ASSERTION extends Error {\n constructor(message) {\n super();\n Error.captureStackTrace(this, ERR_INTERNAL_ASSERTION);\n\n const suffix = 'This is caused by either a bug in ssh2 '\n + 'or incorrect usage of ssh2 internals.\\n'\n + 'Please open an issue with this stack trace at '\n + 'https://github.com/mscdex/ssh2/issues\\n';\n\n this.message = (message === undefined ? suffix : `${message}\\n${suffix}`);\n }\n};\n\nconst MAX_32BIT_INT = 2 ** 32;\nconst MAX_32BIT_BIGINT = (() => {\n try {\n return new Function('return 2n ** 32n')();\n } catch {}\n})();\nexports.ERR_OUT_OF_RANGE = class ERR_OUT_OF_RANGE extends RangeError {\n constructor(str, range, input, replaceDefaultBoolean) {\n super();\n Error.captureStackTrace(this, ERR_OUT_OF_RANGE);\n\n assert(range, 'Missing \"range\" argument');\n let msg = (replaceDefaultBoolean\n ? str\n : `The value of \"${str}\" is out of range.`);\n let received;\n if (Number.isInteger(input) && Math.abs(input) > MAX_32BIT_INT) {\n received = addNumericalSeparator(String(input));\n } else if (typeof input === 'bigint') {\n received = String(input);\n if (input > MAX_32BIT_BIGINT || input < -MAX_32BIT_BIGINT)\n received = addNumericalSeparator(received);\n received += 'n';\n } else {\n received = inspect(input);\n }\n msg += ` It must be ${range}. Received ${received}`;\n\n this.message = msg;\n }\n};\n\nclass ERR_INVALID_ARG_TYPE extends TypeError {\n constructor(name, expected, actual) {\n super();\n Error.captureStackTrace(this, ERR_INVALID_ARG_TYPE);\n\n assert(typeof name === 'string', `'name' must be a string`);\n\n // determiner: 'must be' or 'must not be'\n let determiner;\n if (typeof expected === 'string' && expected.startsWith('not ')) {\n determiner = 'must not be';\n expected = expected.replace(/^not /, '');\n } else {\n determiner = 'must be';\n }\n\n let msg;\n if (name.endsWith(' argument')) {\n // For cases like 'first argument'\n msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;\n } else {\n const type = (name.includes('.') ? 'property' : 'argument');\n msg = `The \"${name}\" ${type} ${determiner} ${oneOf(expected, 'type')}`;\n }\n\n msg += `. Received type ${typeof actual}`;\n\n this.message = msg;\n }\n}\nexports.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;\n\nexports.validateNumber = function validateNumber(value, name) {\n if (typeof value !== 'number')\n throw new ERR_INVALID_ARG_TYPE(name, 'number', value);\n};\n","'use strict';\n\nconst Ber = require('asn1').Ber;\n\nlet DISCONNECT_REASON;\n\nconst FastBuffer = Buffer[Symbol.species];\nconst TypedArrayFill = Object.getPrototypeOf(Uint8Array.prototype).fill;\n\nfunction readUInt32BE(buf, offset) {\n return (buf[offset++] * 16777216)\n + (buf[offset++] * 65536)\n + (buf[offset++] * 256)\n + buf[offset];\n}\n\nfunction bufferCopy(src, dest, srcStart, srcEnd, destStart) {\n if (!destStart)\n destStart = 0;\n if (srcEnd > src.length)\n srcEnd = src.length;\n let nb = srcEnd - srcStart;\n const destLeft = (dest.length - destStart);\n if (nb > destLeft)\n nb = destLeft;\n dest.set(new Uint8Array(src.buffer, src.byteOffset + srcStart, nb),\n destStart);\n return nb;\n}\n\nfunction bufferSlice(buf, start, end) {\n if (end === undefined)\n end = buf.length;\n return new FastBuffer(buf.buffer, buf.byteOffset + start, end - start);\n}\n\nfunction makeBufferParser() {\n let pos = 0;\n let buffer;\n\n const self = {\n init: (buf, start) => {\n buffer = buf;\n pos = (typeof start === 'number' ? start : 0);\n },\n pos: () => pos,\n length: () => (buffer ? buffer.length : 0),\n avail: () => (buffer && pos < buffer.length ? buffer.length - pos : 0),\n clear: () => {\n buffer = undefined;\n },\n readUInt32BE: () => {\n if (!buffer || pos + 3 >= buffer.length)\n return;\n return (buffer[pos++] * 16777216)\n + (buffer[pos++] * 65536)\n + (buffer[pos++] * 256)\n + buffer[pos++];\n },\n readUInt64BE: (behavior) => {\n if (!buffer || pos + 7 >= buffer.length)\n return;\n switch (behavior) {\n case 'always':\n return BigInt(`0x${buffer.hexSlice(pos, pos += 8)}`);\n case 'maybe':\n if (buffer[pos] > 0x1F)\n return BigInt(`0x${buffer.hexSlice(pos, pos += 8)}`);\n // FALLTHROUGH\n default:\n return (buffer[pos++] * 72057594037927940)\n + (buffer[pos++] * 281474976710656)\n + (buffer[pos++] * 1099511627776)\n + (buffer[pos++] * 4294967296)\n + (buffer[pos++] * 16777216)\n + (buffer[pos++] * 65536)\n + (buffer[pos++] * 256)\n + buffer[pos++];\n }\n },\n skip: (n) => {\n if (buffer && n > 0)\n pos += n;\n },\n skipString: () => {\n const len = self.readUInt32BE();\n if (len === undefined)\n return;\n pos += len;\n return (pos <= buffer.length ? len : undefined);\n },\n readByte: () => {\n if (buffer && pos < buffer.length)\n return buffer[pos++];\n },\n readBool: () => {\n if (buffer && pos < buffer.length)\n return !!buffer[pos++];\n },\n readList: () => {\n const list = self.readString(true);\n if (list === undefined)\n return;\n return (list ? list.split(',') : []);\n },\n readString: (dest, maxLen) => {\n if (typeof dest === 'number') {\n maxLen = dest;\n dest = undefined;\n }\n\n const len = self.readUInt32BE();\n if (len === undefined)\n return;\n\n if ((buffer.length - pos) < len\n || (typeof maxLen === 'number' && len > maxLen)) {\n return;\n }\n\n if (dest) {\n if (Buffer.isBuffer(dest))\n return bufferCopy(buffer, dest, pos, pos += len);\n return buffer.utf8Slice(pos, pos += len);\n }\n return bufferSlice(buffer, pos, pos += len);\n },\n readRaw: (len) => {\n if (!buffer)\n return;\n if (typeof len !== 'number')\n return bufferSlice(buffer, pos, pos += (buffer.length - pos));\n if ((buffer.length - pos) >= len)\n return bufferSlice(buffer, pos, pos += len);\n },\n };\n\n return self;\n}\n\nfunction makeError(msg, level, fatal) {\n const err = new Error(msg);\n if (typeof level === 'boolean') {\n fatal = level;\n err.level = 'protocol';\n } else {\n err.level = level || 'protocol';\n }\n err.fatal = !!fatal;\n return err;\n}\n\nfunction writeUInt32BE(buf, value, offset) {\n buf[offset++] = (value >>> 24);\n buf[offset++] = (value >>> 16);\n buf[offset++] = (value >>> 8);\n buf[offset++] = value;\n return offset;\n}\n\nconst utilBufferParser = makeBufferParser();\n\nmodule.exports = {\n bufferCopy,\n bufferSlice,\n FastBuffer,\n bufferFill: (buf, value, start, end) => {\n return TypedArrayFill.call(buf, value, start, end);\n },\n makeError,\n doFatalError: (protocol, msg, level, reason) => {\n let err;\n if (DISCONNECT_REASON === undefined)\n ({ DISCONNECT_REASON } = require('./utils.js'));\n if (msg instanceof Error) {\n // doFatalError(protocol, err[, reason])\n err = msg;\n if (typeof level !== 'number')\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n else\n reason = level;\n } else {\n // doFatalError(protocol, msg[, level[, reason]])\n err = makeError(msg, level, true);\n }\n if (typeof reason !== 'number')\n reason = DISCONNECT_REASON.PROTOCOL_ERROR;\n protocol.disconnect(reason);\n protocol._destruct();\n protocol._onError(err);\n return Infinity;\n },\n readUInt32BE,\n writeUInt32BE,\n writeUInt32LE: (buf, value, offset) => {\n buf[offset++] = value;\n buf[offset++] = (value >>> 8);\n buf[offset++] = (value >>> 16);\n buf[offset++] = (value >>> 24);\n return offset;\n },\n makeBufferParser,\n bufferParser: makeBufferParser(),\n readString: (buffer, start, dest, maxLen) => {\n if (typeof dest === 'number') {\n maxLen = dest;\n dest = undefined;\n }\n\n if (start === undefined)\n start = 0;\n\n const left = (buffer.length - start);\n if (start < 0 || start >= buffer.length || left < 4)\n return;\n\n const len = readUInt32BE(buffer, start);\n if (left < (4 + len) || (typeof maxLen === 'number' && len > maxLen))\n return;\n\n start += 4;\n const end = start + len;\n buffer._pos = end;\n\n if (dest) {\n if (Buffer.isBuffer(dest))\n return bufferCopy(buffer, dest, start, end);\n return buffer.utf8Slice(start, end);\n }\n return bufferSlice(buffer, start, end);\n },\n sigSSHToASN1: (sig, type) => {\n switch (type) {\n case 'ssh-dss': {\n if (sig.length > 40)\n return sig;\n // Change bare signature r and s values to ASN.1 BER values for OpenSSL\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n let r = sig.slice(0, 20);\n let s = sig.slice(20);\n if (r[0] & 0x80) {\n const rNew = Buffer.allocUnsafe(21);\n rNew[0] = 0x00;\n r.copy(rNew, 1);\n r = rNew;\n } else if (r[0] === 0x00 && !(r[1] & 0x80)) {\n r = r.slice(1);\n }\n if (s[0] & 0x80) {\n const sNew = Buffer.allocUnsafe(21);\n sNew[0] = 0x00;\n s.copy(sNew, 1);\n s = sNew;\n } else if (s[0] === 0x00 && !(s[1] & 0x80)) {\n s = s.slice(1);\n }\n asnWriter.writeBuffer(r, Ber.Integer);\n asnWriter.writeBuffer(s, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521': {\n utilBufferParser.init(sig, 0);\n const r = utilBufferParser.readString();\n const s = utilBufferParser.readString();\n utilBufferParser.clear();\n if (r === undefined || s === undefined)\n return;\n\n const asnWriter = new Ber.Writer();\n asnWriter.startSequence();\n asnWriter.writeBuffer(r, Ber.Integer);\n asnWriter.writeBuffer(s, Ber.Integer);\n asnWriter.endSequence();\n return asnWriter.buffer;\n }\n default:\n return sig;\n }\n },\n convertSignature: (signature, keyType) => {\n switch (keyType) {\n case 'ssh-dss': {\n if (signature.length <= 40)\n return signature;\n // This is a quick and dirty way to get from BER encoded r and s that\n // OpenSSL gives us, to just the bare values back to back (40 bytes\n // total) like OpenSSH (and possibly others) are expecting\n const asnReader = new Ber.Reader(signature);\n asnReader.readSequence();\n let r = asnReader.readString(Ber.Integer, true);\n let s = asnReader.readString(Ber.Integer, true);\n let rOffset = 0;\n let sOffset = 0;\n if (r.length < 20) {\n const rNew = Buffer.allocUnsafe(20);\n rNew.set(r, 1);\n r = rNew;\n r[0] = 0;\n }\n if (s.length < 20) {\n const sNew = Buffer.allocUnsafe(20);\n sNew.set(s, 1);\n s = sNew;\n s[0] = 0;\n }\n if (r.length > 20 && r[0] === 0)\n rOffset = 1;\n if (s.length > 20 && s[0] === 0)\n sOffset = 1;\n const newSig =\n Buffer.allocUnsafe((r.length - rOffset) + (s.length - sOffset));\n bufferCopy(r, newSig, rOffset, r.length, 0);\n bufferCopy(s, newSig, sOffset, s.length, r.length - rOffset);\n return newSig;\n }\n case 'ecdsa-sha2-nistp256':\n case 'ecdsa-sha2-nistp384':\n case 'ecdsa-sha2-nistp521': {\n if (signature[0] === 0)\n return signature;\n // Convert SSH signature parameters to ASN.1 BER values for OpenSSL\n const asnReader = new Ber.Reader(signature);\n asnReader.readSequence();\n const r = asnReader.readString(Ber.Integer, true);\n const s = asnReader.readString(Ber.Integer, true);\n if (r === null || s === null)\n return;\n const newSig = Buffer.allocUnsafe(4 + r.length + 4 + s.length);\n writeUInt32BE(newSig, r.length, 0);\n newSig.set(r, 4);\n writeUInt32BE(newSig, s.length, 4 + r.length);\n newSig.set(s, 4 + 4 + r.length);\n return newSig;\n }\n }\n\n return signature;\n },\n sendPacket: (proto, packet, bypass) => {\n if (!bypass && proto._kexinit !== undefined) {\n // We're currently in the middle of a handshake\n\n if (proto._queue === undefined)\n proto._queue = [];\n proto._queue.push(packet);\n proto._debug && proto._debug('Outbound: ... packet queued');\n return false;\n }\n proto._cipher.encrypt(packet);\n return true;\n },\n};\n","'use strict';\n\nconst { kMaxLength } = require('buffer');\nconst {\n createInflate,\n constants: {\n DEFLATE,\n INFLATE,\n Z_DEFAULT_CHUNK,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_MEMLEVEL,\n Z_DEFAULT_STRATEGY,\n Z_DEFAULT_WINDOWBITS,\n Z_PARTIAL_FLUSH,\n }\n} = require('zlib');\nconst ZlibHandle = createInflate()._handle.constructor;\n\nfunction processCallback() {\n throw new Error('Should not get here');\n}\n\nfunction zlibOnError(message, errno, code) {\n const self = this._owner;\n // There is no way to cleanly recover.\n // Continuing only obscures problems.\n\n const error = new Error(message);\n error.errno = errno;\n error.code = code;\n self._err = error;\n}\n\nfunction _close(engine) {\n // Caller may invoke .close after a zlib error (which will null _handle).\n if (!engine._handle)\n return;\n\n engine._handle.close();\n engine._handle = null;\n}\n\nclass Zlib {\n constructor(mode) {\n const windowBits = Z_DEFAULT_WINDOWBITS;\n const level = Z_DEFAULT_COMPRESSION;\n const memLevel = Z_DEFAULT_MEMLEVEL;\n const strategy = Z_DEFAULT_STRATEGY;\n const dictionary = undefined;\n\n this._err = undefined;\n this._writeState = new Uint32Array(2);\n this._chunkSize = Z_DEFAULT_CHUNK;\n this._maxOutputLength = kMaxLength;\n this._outBuffer = Buffer.allocUnsafe(this._chunkSize);\n this._outOffset = 0;\n\n this._handle = new ZlibHandle(mode);\n this._handle._owner = this;\n this._handle.onerror = zlibOnError;\n this._handle.init(windowBits,\n level,\n memLevel,\n strategy,\n this._writeState,\n processCallback,\n dictionary);\n }\n\n writeSync(chunk, retChunks) {\n const handle = this._handle;\n if (!handle)\n throw new Error('Invalid Zlib instance');\n\n let availInBefore = chunk.length;\n let availOutBefore = this._chunkSize - this._outOffset;\n let inOff = 0;\n let availOutAfter;\n let availInAfter;\n\n let buffers;\n let nread = 0;\n const state = this._writeState;\n let buffer = this._outBuffer;\n let offset = this._outOffset;\n const chunkSize = this._chunkSize;\n\n while (true) {\n handle.writeSync(Z_PARTIAL_FLUSH,\n chunk, // in\n inOff, // in_off\n availInBefore, // in_len\n buffer, // out\n offset, // out_off\n availOutBefore); // out_len\n if (this._err)\n throw this._err;\n\n availOutAfter = state[0];\n availInAfter = state[1];\n\n const inDelta = availInBefore - availInAfter;\n const have = availOutBefore - availOutAfter;\n\n if (have > 0) {\n const out = (offset === 0 && have === buffer.length\n ? buffer\n : buffer.slice(offset, offset + have));\n offset += have;\n if (!buffers)\n buffers = out;\n else if (buffers.push === undefined)\n buffers = [buffers, out];\n else\n buffers.push(out);\n nread += out.byteLength;\n\n if (nread > this._maxOutputLength) {\n _close(this);\n throw new Error(\n `Output length exceeded maximum of ${this._maxOutputLength}`\n );\n }\n } else if (have !== 0) {\n throw new Error('have should not go down');\n }\n\n // Exhausted the output buffer, or used all the input create a new one.\n if (availOutAfter === 0 || offset >= chunkSize) {\n availOutBefore = chunkSize;\n offset = 0;\n buffer = Buffer.allocUnsafe(chunkSize);\n }\n\n if (availOutAfter === 0) {\n // Not actually done. Need to reprocess.\n // Also, update the availInBefore to the availInAfter value,\n // so that if we have to hit it a third (fourth, etc.) time,\n // it'll have the correct byte counts.\n inOff += inDelta;\n availInBefore = availInAfter;\n } else {\n break;\n }\n }\n\n this._outBuffer = buffer;\n this._outOffset = offset;\n\n if (nread === 0)\n buffers = Buffer.alloc(0);\n\n if (retChunks) {\n buffers.totalLen = nread;\n return buffers;\n }\n\n if (buffers.push === undefined)\n return buffers;\n\n const output = Buffer.allocUnsafe(nread);\n for (let i = 0, p = 0; i < buffers.length; ++i) {\n const buf = buffers[i];\n output.set(buf, p);\n p += buf.length;\n }\n return output;\n }\n}\n\nclass ZlibPacketWriter {\n constructor(protocol) {\n this.allocStart = 0;\n this.allocStartKEX = 0;\n this._protocol = protocol;\n this._zlib = new Zlib(DEFLATE);\n }\n\n cleanup() {\n if (this._zlib)\n _close(this._zlib);\n }\n\n alloc(payloadSize, force) {\n return Buffer.allocUnsafe(payloadSize);\n }\n\n finalize(payload, force) {\n if (this._protocol._kexinit === undefined || force) {\n const output = this._zlib.writeSync(payload, true);\n const packet = this._protocol._cipher.allocPacket(output.totalLen);\n if (output.push === undefined) {\n packet.set(output, 5);\n } else {\n for (let i = 0, p = 5; i < output.length; ++i) {\n const chunk = output[i];\n packet.set(chunk, p);\n p += chunk.length;\n }\n }\n return packet;\n }\n return payload;\n }\n}\n\nclass PacketWriter {\n constructor(protocol) {\n this.allocStart = 5;\n this.allocStartKEX = 5;\n this._protocol = protocol;\n }\n\n cleanup() {}\n\n alloc(payloadSize, force) {\n if (this._protocol._kexinit === undefined || force)\n return this._protocol._cipher.allocPacket(payloadSize);\n return Buffer.allocUnsafe(payloadSize);\n }\n\n finalize(packet, force) {\n return packet;\n }\n}\n\nclass ZlibPacketReader {\n constructor() {\n this._zlib = new Zlib(INFLATE);\n }\n\n cleanup() {\n if (this._zlib)\n _close(this._zlib);\n }\n\n read(data) {\n return this._zlib.writeSync(data, false);\n }\n}\n\nclass PacketReader {\n cleanup() {}\n\n read(data) {\n return data;\n }\n}\n\nmodule.exports = {\n PacketReader,\n PacketWriter,\n ZlibPacketReader,\n ZlibPacketWriter,\n};\n","// TODO:\n// * convert listenerCount() usage to emit() return value checking?\n// * emit error when connection severed early (e.g. before handshake)\n// * add '.connected' or similar property to connection objects to allow\n// immediate connection status checking\n'use strict';\n\nconst { Server: netServer } = require('net');\nconst EventEmitter = require('events');\nconst { listenerCount } = EventEmitter;\n\nconst {\n CHANNEL_OPEN_FAILURE,\n DEFAULT_CIPHER,\n DEFAULT_COMPRESSION,\n DEFAULT_KEX,\n DEFAULT_MAC,\n DEFAULT_SERVER_HOST_KEY,\n DISCONNECT_REASON,\n DISCONNECT_REASON_BY_VALUE,\n SUPPORTED_CIPHER,\n SUPPORTED_COMPRESSION,\n SUPPORTED_KEX,\n SUPPORTED_MAC,\n SUPPORTED_SERVER_HOST_KEY,\n} = require('./protocol/constants.js');\nconst { init: cryptoInit } = require('./protocol/crypto.js');\nconst { KexInit } = require('./protocol/kex.js');\nconst { parseKey } = require('./protocol/keyParser.js');\nconst Protocol = require('./protocol/Protocol.js');\nconst { SFTP } = require('./protocol/SFTP.js');\nconst { writeUInt32BE } = require('./protocol/utils.js');\n\nconst {\n Channel,\n MAX_WINDOW,\n PACKET_SIZE,\n windowAdjust,\n WINDOW_THRESHOLD,\n} = require('./Channel.js');\n\nconst {\n ChannelManager,\n generateAlgorithmList,\n isWritable,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n} = require('./utils.js');\n\nconst MAX_PENDING_AUTHS = 10;\n\nclass AuthContext extends EventEmitter {\n constructor(protocol, username, service, method, cb) {\n super();\n\n this.username = this.user = username;\n this.service = service;\n this.method = method;\n this._initialResponse = false;\n this._finalResponse = false;\n this._multistep = false;\n this._cbfinal = (allowed, methodsLeft, isPartial) => {\n if (!this._finalResponse) {\n this._finalResponse = true;\n cb(this, allowed, methodsLeft, isPartial);\n }\n };\n this._protocol = protocol;\n }\n\n accept() {\n this._cleanup && this._cleanup();\n this._initialResponse = true;\n this._cbfinal(true);\n }\n reject(methodsLeft, isPartial) {\n this._cleanup && this._cleanup();\n this._initialResponse = true;\n this._cbfinal(false, methodsLeft, isPartial);\n }\n}\n\n\nclass KeyboardAuthContext extends AuthContext {\n constructor(protocol, username, service, method, submethods, cb) {\n super(protocol, username, service, method, cb);\n\n this._multistep = true;\n\n this._cb = undefined;\n this._onInfoResponse = (responses) => {\n const callback = this._cb;\n if (callback) {\n this._cb = undefined;\n callback(responses);\n }\n };\n this.submethods = submethods;\n this.on('abort', () => {\n this._cb && this._cb(new Error('Authentication request aborted'));\n });\n }\n\n prompt(prompts, title, instructions, cb) {\n if (!Array.isArray(prompts))\n prompts = [ prompts ];\n\n if (typeof title === 'function') {\n cb = title;\n title = instructions = undefined;\n } else if (typeof instructions === 'function') {\n cb = instructions;\n instructions = undefined;\n } else if (typeof cb !== 'function') {\n cb = undefined;\n }\n\n for (let i = 0; i < prompts.length; ++i) {\n if (typeof prompts[i] === 'string') {\n prompts[i] = {\n prompt: prompts[i],\n echo: true\n };\n }\n }\n\n this._cb = cb;\n this._initialResponse = true;\n\n this._protocol.authInfoReq(title, instructions, prompts);\n }\n}\n\nclass PKAuthContext extends AuthContext {\n constructor(protocol, username, service, method, pkInfo, cb) {\n super(protocol, username, service, method, cb);\n\n this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };\n this.signature = pkInfo.signature;\n this.blob = pkInfo.blob;\n }\n\n accept() {\n if (!this.signature) {\n this._initialResponse = true;\n this._protocol.authPKOK(this.key.algo, this.key.data);\n } else {\n AuthContext.prototype.accept.call(this);\n }\n }\n}\n\nclass HostbasedAuthContext extends AuthContext {\n constructor(protocol, username, service, method, pkInfo, cb) {\n super(protocol, username, service, method, cb);\n\n this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };\n this.signature = pkInfo.signature;\n this.blob = pkInfo.blob;\n this.localHostname = pkInfo.localHostname;\n this.localUsername = pkInfo.localUsername;\n }\n}\n\nclass PwdAuthContext extends AuthContext {\n constructor(protocol, username, service, method, password, cb) {\n super(protocol, username, service, method, cb);\n\n this.password = password;\n this._changeCb = undefined;\n }\n\n requestChange(prompt, cb) {\n if (this._changeCb)\n throw new Error('Change request already in progress');\n if (typeof prompt !== 'string')\n throw new Error('prompt argument must be a string');\n if (typeof cb !== 'function')\n throw new Error('Callback argument must be a function');\n this._changeCb = cb;\n this._protocol.authPasswdChg(prompt);\n }\n}\n\n\nclass Session extends EventEmitter {\n constructor(client, info, localChan) {\n super();\n\n this.type = 'session';\n this.subtype = undefined;\n this.server = true;\n this._ending = false;\n this._channel = undefined;\n this._chanInfo = {\n type: 'session',\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n }\n}\n\n\nclass Server extends EventEmitter {\n constructor(cfg, listener) {\n super();\n\n if (typeof cfg !== 'object' || cfg === null)\n throw new Error('Missing configuration object');\n\n const hostKeys = Object.create(null);\n const hostKeyAlgoOrder = [];\n\n const hostKeys_ = cfg.hostKeys;\n if (!Array.isArray(hostKeys_))\n throw new Error('hostKeys must be an array');\n\n const cfgAlgos = (\n typeof cfg.algorithms === 'object' && cfg.algorithms !== null\n ? cfg.algorithms\n : {}\n );\n\n const hostKeyAlgos = generateAlgorithmList(\n cfgAlgos.serverHostKey,\n DEFAULT_SERVER_HOST_KEY,\n SUPPORTED_SERVER_HOST_KEY\n );\n for (let i = 0; i < hostKeys_.length; ++i) {\n let privateKey;\n if (Buffer.isBuffer(hostKeys_[i]) || typeof hostKeys_[i] === 'string')\n privateKey = parseKey(hostKeys_[i]);\n else\n privateKey = parseKey(hostKeys_[i].key, hostKeys_[i].passphrase);\n\n if (privateKey instanceof Error)\n throw new Error(`Cannot parse privateKey: ${privateKey.message}`);\n\n if (Array.isArray(privateKey)) {\n // OpenSSH's newer format only stores 1 key for now\n privateKey = privateKey[0];\n }\n\n if (privateKey.getPrivatePEM() === null)\n throw new Error('privateKey value contains an invalid private key');\n\n // Discard key if we already found a key of the same type\n if (hostKeyAlgoOrder.includes(privateKey.type))\n continue;\n\n if (privateKey.type === 'ssh-rsa') {\n // SSH supports multiple signature hashing algorithms for RSA, so we add\n // the algorithms in the desired order\n let sha1Pos = hostKeyAlgos.indexOf('ssh-rsa');\n const sha256Pos = hostKeyAlgos.indexOf('rsa-sha2-256');\n const sha512Pos = hostKeyAlgos.indexOf('rsa-sha2-512');\n if (sha1Pos === -1) {\n // Fall back to giving SHA1 the lowest priority\n sha1Pos = Infinity;\n }\n [sha1Pos, sha256Pos, sha512Pos].sort(compareNumbers).forEach((pos) => {\n if (pos === -1)\n return;\n\n let type;\n switch (pos) {\n case sha1Pos: type = 'ssh-rsa'; break;\n case sha256Pos: type = 'rsa-sha2-256'; break;\n case sha512Pos: type = 'rsa-sha2-512'; break;\n default: return;\n }\n\n // Store same RSA key under each hash algorithm name for convenience\n hostKeys[type] = privateKey;\n\n hostKeyAlgoOrder.push(type);\n });\n } else {\n hostKeys[privateKey.type] = privateKey;\n hostKeyAlgoOrder.push(privateKey.type);\n }\n }\n\n const algorithms = {\n kex: generateAlgorithmList(cfgAlgos.kex, DEFAULT_KEX, SUPPORTED_KEX),\n serverHostKey: hostKeyAlgoOrder,\n cs: {\n cipher: generateAlgorithmList(\n cfgAlgos.cipher,\n DEFAULT_CIPHER,\n SUPPORTED_CIPHER\n ),\n mac: generateAlgorithmList(cfgAlgos.hmac, DEFAULT_MAC, SUPPORTED_MAC),\n compress: generateAlgorithmList(\n cfgAlgos.compress,\n DEFAULT_COMPRESSION,\n SUPPORTED_COMPRESSION\n ),\n lang: [],\n },\n sc: undefined,\n };\n algorithms.sc = algorithms.cs;\n\n if (typeof listener === 'function')\n this.on('connection', listener);\n\n const origDebug = (typeof cfg.debug === 'function' ? cfg.debug : undefined);\n const ident = (cfg.ident ? Buffer.from(cfg.ident) : undefined);\n const offer = new KexInit(algorithms);\n\n this._srv = new netServer((socket) => {\n if (this._connections >= this.maxConnections) {\n socket.destroy();\n return;\n }\n ++this._connections;\n socket.once('close', () => {\n --this._connections;\n });\n\n let debug;\n if (origDebug) {\n // Prepend debug output with a unique identifier in case there are\n // multiple clients connected at the same time\n const debugPrefix = `[${process.hrtime().join('.')}] `;\n debug = (msg) => {\n origDebug(`${debugPrefix}${msg}`);\n };\n }\n\n // eslint-disable-next-line no-use-before-define\n new Client(socket, hostKeys, ident, offer, debug, this, cfg);\n }).on('error', (err) => {\n this.emit('error', err);\n }).on('listening', () => {\n this.emit('listening');\n }).on('close', () => {\n this.emit('close');\n });\n this._connections = 0;\n this.maxConnections = Infinity;\n }\n\n injectSocket(socket) {\n this._srv.emit('connection', socket);\n }\n\n listen(...args) {\n this._srv.listen(...args);\n return this;\n }\n\n address() {\n return this._srv.address();\n }\n\n getConnections(cb) {\n this._srv.getConnections(cb);\n return this;\n }\n\n close(cb) {\n this._srv.close(cb);\n return this;\n }\n\n ref() {\n this._srv.ref();\n return this;\n }\n\n unref() {\n this._srv.unref();\n return this;\n }\n}\nServer.KEEPALIVE_CLIENT_INTERVAL = 15000;\nServer.KEEPALIVE_CLIENT_COUNT_MAX = 3;\n\n\nclass Client extends EventEmitter {\n constructor(socket, hostKeys, ident, offer, debug, server, srvCfg) {\n super();\n\n let exchanges = 0;\n let acceptedAuthSvc = false;\n let pendingAuths = [];\n let authCtx;\n let kaTimer;\n let onPacket;\n const unsentGlobalRequestsReplies = [];\n this._sock = socket;\n this._chanMgr = new ChannelManager(this);\n this._debug = debug;\n this.noMoreSessions = false;\n this.authenticated = false;\n\n // Silence pre-header errors\n function onClientPreHeaderError(err) {}\n this.on('error', onClientPreHeaderError);\n\n const DEBUG_HANDLER = (!debug ? undefined : (p, display, msg) => {\n debug(`Debug output from client: ${JSON.stringify(msg)}`);\n });\n\n const kaIntvl = (\n typeof srvCfg.keepaliveInterval === 'number'\n && isFinite(srvCfg.keepaliveInterval)\n && srvCfg.keepaliveInterval > 0\n ? srvCfg.keepaliveInterval\n : (\n typeof Server.KEEPALIVE_CLIENT_INTERVAL === 'number'\n && isFinite(Server.KEEPALIVE_CLIENT_INTERVAL)\n && Server.KEEPALIVE_CLIENT_INTERVAL > 0\n ? Server.KEEPALIVE_CLIENT_INTERVAL\n : -1\n )\n );\n const kaCountMax = (\n typeof srvCfg.keepaliveCountMax === 'number'\n && isFinite(srvCfg.keepaliveCountMax)\n && srvCfg.keepaliveCountMax >= 0\n ? srvCfg.keepaliveCountMax\n : (\n typeof Server.KEEPALIVE_CLIENT_COUNT_MAX === 'number'\n && isFinite(Server.KEEPALIVE_CLIENT_COUNT_MAX)\n && Server.KEEPALIVE_CLIENT_COUNT_MAX >= 0\n ? Server.KEEPALIVE_CLIENT_COUNT_MAX\n : -1\n )\n );\n let kaCurCount = 0;\n if (kaIntvl !== -1 && kaCountMax !== -1) {\n this.once('ready', () => {\n const onClose = () => {\n clearInterval(kaTimer);\n };\n this.on('close', onClose).on('end', onClose);\n kaTimer = setInterval(() => {\n if (++kaCurCount > kaCountMax) {\n clearInterval(kaTimer);\n const err = new Error('Keepalive timeout');\n err.level = 'client-timeout';\n this.emit('error', err);\n this.end();\n } else {\n // XXX: if the server ever starts sending real global requests to\n // the client, we will need to add a dummy callback here to\n // keep the correct reply order\n proto.ping();\n }\n }, kaIntvl);\n });\n // TODO: re-verify keepalive behavior with OpenSSH\n onPacket = () => {\n kaTimer && kaTimer.refresh();\n kaCurCount = 0;\n };\n }\n\n const proto = this._protocol = new Protocol({\n server: true,\n hostKeys,\n ident,\n offer,\n onPacket,\n greeting: srvCfg.greeting,\n banner: srvCfg.banner,\n onWrite: (data) => {\n if (isWritable(socket))\n socket.write(data);\n },\n onError: (err) => {\n if (!proto._destruct)\n socket.removeAllListeners('data');\n this.emit('error', err);\n try {\n socket.end();\n } catch {}\n },\n onHeader: (header) => {\n this.removeListener('error', onClientPreHeaderError);\n\n const info = {\n ip: socket.remoteAddress,\n family: socket.remoteFamily,\n port: socket.remotePort,\n header,\n };\n if (!server.emit('connection', this, info)) {\n // auto reject\n proto.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n socket.end();\n return;\n }\n\n if (header.greeting)\n this.emit('greeting', header.greeting);\n },\n onHandshakeComplete: (negotiated) => {\n if (++exchanges > 1)\n this.emit('rekey');\n this.emit('handshake', negotiated);\n },\n debug,\n messageHandlers: {\n DEBUG: DEBUG_HANDLER,\n DISCONNECT: (p, reason, desc) => {\n if (reason !== DISCONNECT_REASON.BY_APPLICATION) {\n if (!desc) {\n desc = DISCONNECT_REASON_BY_VALUE[reason];\n if (desc === undefined)\n desc = `Unexpected disconnection reason: ${reason}`;\n }\n const err = new Error(desc);\n err.code = reason;\n this.emit('error', err);\n }\n socket.end();\n },\n CHANNEL_OPEN: (p, info) => {\n // Handle incoming requests from client\n\n // Do early reject in some cases to prevent wasteful channel\n // allocation\n if ((info.type === 'session' && this.noMoreSessions)\n || !this.authenticated) {\n const reasonCode = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n return proto.channelOpenFail(info.sender, reasonCode);\n }\n\n let localChan = -1;\n let reason;\n let replied = false;\n\n let accept;\n const reject = () => {\n if (replied)\n return;\n replied = true;\n\n if (reason === undefined) {\n if (localChan === -1)\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n else\n reason = CHANNEL_OPEN_FAILURE.CONNECT_FAILED;\n }\n\n if (localChan !== -1)\n this._chanMgr.remove(localChan);\n proto.channelOpenFail(info.sender, reason, '');\n };\n const reserveChannel = () => {\n localChan = this._chanMgr.add();\n\n if (localChan === -1) {\n reason = CHANNEL_OPEN_FAILURE.RESOURCE_SHORTAGE;\n if (debug) {\n debug('Automatic rejection of incoming channel open: '\n + 'no channels available');\n }\n }\n\n return (localChan !== -1);\n };\n\n const data = info.data;\n switch (info.type) {\n case 'session':\n if (listenerCount(this, 'session') && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const instance = new Session(this, info, localChan);\n this._chanMgr.update(localChan, instance);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return instance;\n };\n\n this.emit('session', accept, reject);\n return;\n }\n break;\n case 'direct-tcpip':\n if (listenerCount(this, 'tcpip') && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const chanInfo = {\n type: undefined,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const stream = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(localChan, stream);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return stream;\n };\n\n this.emit('tcpip', accept, reject, data);\n return;\n }\n break;\n case 'direct-streamlocal@openssh.com':\n if (listenerCount(this, 'openssh.streamlocal')\n && reserveChannel()) {\n accept = () => {\n if (replied)\n return;\n replied = true;\n\n const chanInfo = {\n type: undefined,\n incoming: {\n id: localChan,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const stream = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(localChan, stream);\n\n proto.channelOpenConfirm(info.sender,\n localChan,\n MAX_WINDOW,\n PACKET_SIZE);\n\n return stream;\n };\n\n this.emit('openssh.streamlocal', accept, reject, data);\n return;\n }\n break;\n default:\n // Automatically reject any unsupported channel open requests\n reason = CHANNEL_OPEN_FAILURE.UNKNOWN_CHANNEL_TYPE;\n if (debug) {\n debug('Automatic rejection of unsupported incoming channel open'\n + ` type: ${info.type}`);\n }\n }\n\n if (reason === undefined) {\n reason = CHANNEL_OPEN_FAILURE.ADMINISTRATIVELY_PROHIBITED;\n if (debug) {\n debug('Automatic rejection of unexpected incoming channel open'\n + ` for: ${info.type}`);\n }\n }\n\n reject();\n },\n CHANNEL_OPEN_CONFIRMATION: (p, info) => {\n const channel = this._chanMgr.get(info.recipient);\n if (typeof channel !== 'function')\n return;\n\n const chanInfo = {\n type: channel.type,\n incoming: {\n id: info.recipient,\n window: MAX_WINDOW,\n packetSize: PACKET_SIZE,\n state: 'open'\n },\n outgoing: {\n id: info.sender,\n window: info.window,\n packetSize: info.packetSize,\n state: 'open'\n }\n };\n\n const instance = new Channel(this, chanInfo, { server: true });\n this._chanMgr.update(info.recipient, instance);\n channel(undefined, instance);\n },\n CHANNEL_OPEN_FAILURE: (p, recipient, reason, description) => {\n const channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'function')\n return;\n\n const info = { reason, description };\n onChannelOpenFailure(this, recipient, info, channel);\n },\n CHANNEL_DATA: (p, recipient, data) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n // The remote party should not be sending us data if there is no\n // window space available ...\n // TODO: raise error on data with not enough window?\n if (channel.incoming.window === 0)\n return;\n\n channel.incoming.window -= data.length;\n\n if (channel.push(data) === false) {\n channel._waitChanDrain = true;\n return;\n }\n\n if (channel.incoming.window <= WINDOW_THRESHOLD)\n windowAdjust(channel);\n },\n CHANNEL_EXTENDED_DATA: (p, recipient, data, type) => {\n // NOOP -- should not be sent by client\n },\n CHANNEL_WINDOW_ADJUST: (p, recipient, amount) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n // The other side is allowing us to send `amount` more bytes of data\n channel.outgoing.window += amount;\n\n if (channel._waitWindow) {\n channel._waitWindow = false;\n\n if (channel._chunk) {\n channel._write(channel._chunk, null, channel._chunkcb);\n } else if (channel._chunkcb) {\n channel._chunkcb();\n } else if (channel._chunkErr) {\n channel.stderr._write(channel._chunkErr,\n null,\n channel._chunkcbErr);\n } else if (channel._chunkcbErr) {\n channel._chunkcbErr();\n }\n }\n },\n CHANNEL_SUCCESS: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(false);\n },\n CHANNEL_FAILURE: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel._callbacks.length)\n channel._callbacks.shift()(true);\n },\n CHANNEL_REQUEST: (p, recipient, type, wantReply, data) => {\n const session = this._chanMgr.get(recipient);\n if (typeof session !== 'object' || session === null)\n return;\n\n let replied = false;\n let accept;\n let reject;\n\n if (session.constructor !== Session) {\n // normal Channel instance\n if (wantReply)\n proto.channelFailure(session.outgoing.id);\n return;\n }\n\n if (wantReply) {\n // \"real session\" requests will have custom accept behaviors\n if (type !== 'shell'\n && type !== 'exec'\n && type !== 'subsystem') {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n proto.channelSuccess(session._chanInfo.outgoing.id);\n };\n }\n\n reject = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n proto.channelFailure(session._chanInfo.outgoing.id);\n };\n }\n\n if (session._ending) {\n reject && reject();\n return;\n }\n\n switch (type) {\n // \"pre-real session start\" requests\n case 'env':\n if (listenerCount(session, 'env')) {\n session.emit('env', accept, reject, {\n key: data.name,\n val: data.value\n });\n return;\n }\n break;\n case 'pty-req':\n if (listenerCount(session, 'pty')) {\n session.emit('pty', accept, reject, data);\n return;\n }\n break;\n case 'window-change':\n if (listenerCount(session, 'window-change'))\n session.emit('window-change', accept, reject, data);\n else\n reject && reject();\n break;\n case 'x11-req':\n if (listenerCount(session, 'x11')) {\n session.emit('x11', accept, reject, data);\n return;\n }\n break;\n // \"post-real session start\" requests\n case 'signal':\n if (listenerCount(session, 'signal')) {\n session.emit('signal', accept, reject, {\n name: data\n });\n return;\n }\n break;\n // XXX: is `auth-agent-req@openssh.com` really \"post-real session\n // start\"?\n case 'auth-agent-req@openssh.com':\n if (listenerCount(session, 'auth-agent')) {\n session.emit('auth-agent', accept, reject);\n return;\n }\n break;\n // \"real session start\" requests\n case 'shell':\n if (listenerCount(session, 'shell')) {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n const channel = new Channel(\n this, session._chanInfo, { server: true }\n );\n\n channel.subtype = session.subtype = type;\n session._channel = channel;\n\n return channel;\n };\n\n session.emit('shell', accept, reject);\n return;\n }\n break;\n case 'exec':\n if (listenerCount(session, 'exec')) {\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n const channel = new Channel(\n this, session._chanInfo, { server: true }\n );\n\n channel.subtype = session.subtype = type;\n session._channel = channel;\n\n return channel;\n };\n\n session.emit('exec', accept, reject, {\n command: data\n });\n return;\n }\n break;\n case 'subsystem': {\n let useSFTP = (data === 'sftp');\n accept = () => {\n if (replied || session._ending || session._channel)\n return;\n replied = true;\n\n if (wantReply)\n proto.channelSuccess(session._chanInfo.outgoing.id);\n\n let instance;\n if (useSFTP) {\n instance = new SFTP(this, session._chanInfo, {\n server: true,\n debug,\n });\n } else {\n instance = new Channel(\n this, session._chanInfo, { server: true }\n );\n instance.subtype =\n session.subtype = `${type}:${data}`;\n }\n session._channel = instance;\n\n return instance;\n };\n\n if (data === 'sftp') {\n if (listenerCount(session, 'sftp')) {\n session.emit('sftp', accept, reject);\n return;\n }\n useSFTP = false;\n }\n if (listenerCount(session, 'subsystem')) {\n session.emit('subsystem', accept, reject, {\n name: data\n });\n return;\n }\n break;\n }\n }\n debug && debug(\n `Automatic rejection of incoming channel request: ${type}`\n );\n reject && reject();\n },\n CHANNEL_EOF: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n if (!channel._ending) {\n channel._ending = true;\n channel.emit('eof');\n channel.emit('end');\n }\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n if (channel.incoming.state !== 'open')\n return;\n channel.incoming.state = 'eof';\n\n if (channel.readable)\n channel.push(null);\n },\n CHANNEL_CLOSE: (p, recipient) => {\n let channel = this._chanMgr.get(recipient);\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.constructor === Session) {\n channel._ending = true;\n channel.emit('close');\n channel = channel._channel;\n if (!channel)\n return;\n }\n\n onCHANNEL_CLOSE(this, recipient, channel);\n },\n // Begin service/auth-related ==========================================\n SERVICE_REQUEST: (p, service) => {\n if (exchanges === 0\n || acceptedAuthSvc\n || this.authenticated\n || service !== 'ssh-userauth') {\n proto.disconnect(DISCONNECT_REASON.SERVICE_NOT_AVAILABLE);\n socket.end();\n return;\n }\n\n acceptedAuthSvc = true;\n proto.serviceAccept(service);\n },\n USERAUTH_REQUEST: (p, username, service, method, methodData) => {\n if (exchanges === 0\n || this.authenticated\n || (authCtx\n && (authCtx.username !== username\n || authCtx.service !== service))\n // TODO: support hostbased auth\n || (method !== 'password'\n && method !== 'publickey'\n && method !== 'hostbased'\n && method !== 'keyboard-interactive'\n && method !== 'none')\n || pendingAuths.length === MAX_PENDING_AUTHS) {\n proto.disconnect(DISCONNECT_REASON.PROTOCOL_ERROR);\n socket.end();\n return;\n } else if (service !== 'ssh-connection') {\n proto.disconnect(DISCONNECT_REASON.SERVICE_NOT_AVAILABLE);\n socket.end();\n return;\n }\n\n let ctx;\n switch (method) {\n case 'keyboard-interactive':\n ctx = new KeyboardAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'publickey':\n ctx = new PKAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'hostbased':\n ctx = new HostbasedAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'password':\n if (authCtx\n && authCtx instanceof PwdAuthContext\n && authCtx._changeCb) {\n const cb = authCtx._changeCb;\n authCtx._changeCb = undefined;\n cb(methodData.newPassword);\n return;\n }\n ctx = new PwdAuthContext(proto, username, service, method,\n methodData, onAuthDecide);\n break;\n case 'none':\n ctx = new AuthContext(proto, username, service, method,\n onAuthDecide);\n break;\n }\n\n if (authCtx) {\n if (!authCtx._initialResponse) {\n return pendingAuths.push(ctx);\n } else if (authCtx._multistep && !authCtx._finalResponse) {\n // RFC 4252 says to silently abort the current auth request if a\n // new auth request comes in before the final response from an\n // auth method that requires additional request/response exchanges\n // -- this means keyboard-interactive for now ...\n authCtx._cleanup && authCtx._cleanup();\n authCtx.emit('abort');\n }\n }\n\n authCtx = ctx;\n\n if (listenerCount(this, 'authentication'))\n this.emit('authentication', authCtx);\n else\n authCtx.reject();\n },\n USERAUTH_INFO_RESPONSE: (p, responses) => {\n if (authCtx && authCtx instanceof KeyboardAuthContext)\n authCtx._onInfoResponse(responses);\n },\n // End service/auth-related ============================================\n GLOBAL_REQUEST: (p, name, wantReply, data) => {\n const reply = {\n type: null,\n buf: null\n };\n\n function setReply(type, buf) {\n reply.type = type;\n reply.buf = buf;\n sendReplies();\n }\n\n if (wantReply)\n unsentGlobalRequestsReplies.push(reply);\n\n if ((name === 'tcpip-forward'\n || name === 'cancel-tcpip-forward'\n || name === 'no-more-sessions@openssh.com'\n || name === 'streamlocal-forward@openssh.com'\n || name === 'cancel-streamlocal-forward@openssh.com')\n && listenerCount(this, 'request')\n && this.authenticated) {\n let accept;\n let reject;\n\n if (wantReply) {\n let replied = false;\n accept = (chosenPort) => {\n if (replied)\n return;\n replied = true;\n let bufPort;\n if (name === 'tcpip-forward'\n && data.bindPort === 0\n && typeof chosenPort === 'number') {\n bufPort = Buffer.allocUnsafe(4);\n writeUInt32BE(bufPort, chosenPort, 0);\n }\n setReply('SUCCESS', bufPort);\n };\n reject = () => {\n if (replied)\n return;\n replied = true;\n setReply('FAILURE');\n };\n }\n\n if (name === 'no-more-sessions@openssh.com') {\n this.noMoreSessions = true;\n accept && accept();\n return;\n }\n\n this.emit('request', accept, reject, name, data);\n } else if (wantReply) {\n setReply('FAILURE');\n }\n },\n },\n });\n\n socket.pause();\n cryptoInit.then(() => {\n proto.start();\n socket.on('data', (data) => {\n try {\n proto.parse(data, 0, data.length);\n } catch (ex) {\n this.emit('error', ex);\n try {\n if (isWritable(socket))\n socket.end();\n } catch {}\n }\n });\n socket.resume();\n }).catch((err) => {\n this.emit('error', err);\n try {\n if (isWritable(socket))\n socket.end();\n } catch {}\n });\n socket.on('error', (err) => {\n err.level = 'socket';\n this.emit('error', err);\n }).once('end', () => {\n debug && debug('Socket ended');\n proto.cleanup();\n this.emit('end');\n }).once('close', () => {\n debug && debug('Socket closed');\n proto.cleanup();\n this.emit('close');\n\n const err = new Error('No response from server');\n\n // Simulate error for pending channels and close any open channels\n this._chanMgr.cleanup(err);\n });\n\n const onAuthDecide = (ctx, allowed, methodsLeft, isPartial) => {\n if (authCtx === ctx && !this.authenticated) {\n if (allowed) {\n authCtx = undefined;\n this.authenticated = true;\n proto.authSuccess();\n pendingAuths = [];\n this.emit('ready');\n } else {\n proto.authFailure(methodsLeft, isPartial);\n if (pendingAuths.length) {\n authCtx = pendingAuths.pop();\n if (listenerCount(this, 'authentication'))\n this.emit('authentication', authCtx);\n else\n authCtx.reject();\n }\n }\n }\n };\n\n function sendReplies() {\n while (unsentGlobalRequestsReplies.length > 0\n && unsentGlobalRequestsReplies[0].type) {\n const reply = unsentGlobalRequestsReplies.shift();\n if (reply.type === 'SUCCESS')\n proto.requestSuccess(reply.buf);\n if (reply.type === 'FAILURE')\n proto.requestFailure();\n }\n }\n }\n\n end() {\n if (this._sock && isWritable(this._sock)) {\n this._protocol.disconnect(DISCONNECT_REASON.BY_APPLICATION);\n this._sock.end();\n }\n return this;\n }\n\n x11(originAddr, originPort, cb) {\n const opts = { originAddr, originPort };\n openChannel(this, 'x11', opts, cb);\n return this;\n }\n\n forwardOut(boundAddr, boundPort, remoteAddr, remotePort, cb) {\n const opts = { boundAddr, boundPort, remoteAddr, remotePort };\n openChannel(this, 'forwarded-tcpip', opts, cb);\n return this;\n }\n\n openssh_forwardOutStreamLocal(socketPath, cb) {\n const opts = { socketPath };\n openChannel(this, 'forwarded-streamlocal@openssh.com', opts, cb);\n return this;\n }\n\n rekey(cb) {\n let error;\n\n try {\n this._protocol.rekey();\n } catch (ex) {\n error = ex;\n }\n\n // TODO: re-throw error if no callback?\n\n if (typeof cb === 'function') {\n if (error)\n process.nextTick(cb, error);\n else\n this.once('rekey', cb);\n }\n }\n}\n\n\nfunction openChannel(self, type, opts, cb) {\n // Ask the client to open a channel for some purpose (e.g. a forwarded TCP\n // connection)\n const initWindow = MAX_WINDOW;\n const maxPacket = PACKET_SIZE;\n\n if (typeof opts === 'function') {\n cb = opts;\n opts = {};\n }\n\n const wrapper = (err, stream) => {\n cb(err, stream);\n };\n wrapper.type = type;\n\n const localChan = self._chanMgr.add(wrapper);\n\n if (localChan === -1) {\n cb(new Error('No free channels available'));\n return;\n }\n\n switch (type) {\n case 'forwarded-tcpip':\n self._protocol.forwardedTcpip(localChan, initWindow, maxPacket, opts);\n break;\n case 'x11':\n self._protocol.x11(localChan, initWindow, maxPacket, opts);\n break;\n case 'forwarded-streamlocal@openssh.com':\n self._protocol.openssh_forwardedStreamLocal(\n localChan, initWindow, maxPacket, opts\n );\n break;\n default:\n throw new Error(`Unsupported channel type: ${type}`);\n }\n}\n\nfunction compareNumbers(a, b) {\n return a - b;\n}\n\nmodule.exports = Server;\nmodule.exports.IncomingClient = Client;\n","'use strict';\n\nconst { SFTP } = require('./protocol/SFTP.js');\n\nconst MAX_CHANNEL = 2 ** 32 - 1;\n\nfunction onChannelOpenFailure(self, recipient, info, cb) {\n self._chanMgr.remove(recipient);\n if (typeof cb !== 'function')\n return;\n\n let err;\n if (info instanceof Error) {\n err = info;\n } else if (typeof info === 'object' && info !== null) {\n err = new Error(`(SSH) Channel open failure: ${info.description}`);\n err.reason = info.reason;\n } else {\n err = new Error(\n '(SSH) Channel open failure: server closed channel unexpectedly'\n );\n err.reason = '';\n }\n\n cb(err);\n}\n\nfunction onCHANNEL_CLOSE(self, recipient, channel, err, dead) {\n if (typeof channel === 'function') {\n // We got CHANNEL_CLOSE instead of CHANNEL_OPEN_FAILURE when\n // requesting to open a channel\n onChannelOpenFailure(self, recipient, err, channel);\n return;\n }\n\n if (typeof channel !== 'object' || channel === null)\n return;\n\n if (channel.incoming && channel.incoming.state === 'closed')\n return;\n\n self._chanMgr.remove(recipient);\n\n if (channel.server && channel.constructor.name === 'Session')\n return;\n\n channel.incoming.state = 'closed';\n\n if (channel.readable)\n channel.push(null);\n if (channel.server) {\n if (channel.stderr.writable)\n channel.stderr.end();\n } else if (channel.stderr.readable) {\n channel.stderr.push(null);\n }\n\n if (channel.constructor !== SFTP\n && (channel.outgoing.state === 'open'\n || channel.outgoing.state === 'eof')\n && !dead) {\n channel.close();\n }\n if (channel.outgoing.state === 'closing')\n channel.outgoing.state = 'closed';\n\n const readState = channel._readableState;\n const writeState = channel._writableState;\n if (writeState && !writeState.ending && !writeState.finished && !dead)\n channel.end();\n\n // Take care of any outstanding channel requests\n const chanCallbacks = channel._callbacks;\n channel._callbacks = [];\n for (let i = 0; i < chanCallbacks.length; ++i)\n chanCallbacks[i](true);\n\n if (channel.server) {\n if (!channel.readable\n || channel.destroyed\n || (readState && readState.endEmitted)) {\n channel.emit('close');\n } else {\n channel.once('end', () => channel.emit('close'));\n }\n } else {\n let doClose;\n switch (channel.type) {\n case 'direct-streamlocal@openssh.com':\n case 'direct-tcpip':\n doClose = () => channel.emit('close');\n break;\n default: {\n // Align more with node child processes, where the close event gets\n // the same arguments as the exit event\n const exit = channel._exit;\n doClose = () => {\n if (exit.code === null)\n channel.emit('close', exit.code, exit.signal, exit.dump, exit.desc);\n else\n channel.emit('close', exit.code);\n };\n }\n }\n if (!channel.readable\n || channel.destroyed\n || (readState && readState.endEmitted)) {\n doClose();\n } else {\n channel.once('end', doClose);\n }\n\n const errReadState = channel.stderr._readableState;\n if (!channel.stderr.readable\n || channel.stderr.destroyed\n || (errReadState && errReadState.endEmitted)) {\n channel.stderr.emit('close');\n } else {\n channel.stderr.once('end', () => channel.stderr.emit('close'));\n }\n }\n}\n\nclass ChannelManager {\n constructor(client) {\n this._client = client;\n this._channels = {};\n this._cur = -1;\n this._count = 0;\n }\n add(val) {\n // Attempt to reserve an id\n\n let id;\n // Optimized paths\n if (this._cur < MAX_CHANNEL) {\n id = ++this._cur;\n } else if (this._count === 0) {\n // Revert and reset back to fast path once we no longer have any channels\n // open\n this._cur = 0;\n id = 0;\n } else {\n // Slower lookup path\n\n // This path is triggered we have opened at least MAX_CHANNEL channels\n // while having at least one channel open at any given time, so we have\n // to search for a free id.\n const channels = this._channels;\n for (let i = 0; i < MAX_CHANNEL; ++i) {\n if (channels[i] === undefined) {\n id = i;\n break;\n }\n }\n }\n\n if (id === undefined)\n return -1;\n\n this._channels[id] = (val || true);\n ++this._count;\n\n return id;\n }\n update(id, val) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n if (val && this._channels[id])\n this._channels[id] = val;\n }\n get(id) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n return this._channels[id];\n }\n remove(id) {\n if (typeof id !== 'number' || id < 0 || id >= MAX_CHANNEL || !isFinite(id))\n throw new Error(`Invalid channel id: ${id}`);\n\n if (this._channels[id]) {\n delete this._channels[id];\n if (this._count)\n --this._count;\n }\n }\n cleanup(err) {\n const channels = this._channels;\n this._channels = {};\n this._cur = -1;\n this._count = 0;\n\n const chanIDs = Object.keys(channels);\n const client = this._client;\n for (let i = 0; i < chanIDs.length; ++i) {\n const id = +chanIDs[i];\n const channel = channels[id];\n onCHANNEL_CLOSE(client, id, channel._channel || channel, err, true);\n }\n }\n}\n\nconst isRegExp = (() => {\n const toString = Object.prototype.toString;\n return (val) => toString.call(val) === '[object RegExp]';\n})();\n\nfunction generateAlgorithmList(algoList, defaultList, supportedList) {\n if (Array.isArray(algoList) && algoList.length > 0) {\n // Exact list\n for (let i = 0; i < algoList.length; ++i) {\n if (supportedList.indexOf(algoList[i]) === -1)\n throw new Error(`Unsupported algorithm: ${algoList[i]}`);\n }\n return algoList;\n }\n\n if (typeof algoList === 'object' && algoList !== null) {\n // Operations based on the default list\n const keys = Object.keys(algoList);\n let list = defaultList;\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n let val = algoList[key];\n switch (key) {\n case 'append':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = 0; j < val.length; ++j) {\n const append = val[j];\n if (typeof append === 'string') {\n if (!append || list.indexOf(append) !== -1)\n continue;\n if (supportedList.indexOf(append) === -1)\n throw new Error(`Unsupported algorithm: ${append}`);\n if (list === defaultList)\n list = list.slice();\n list.push(append);\n } else if (isRegExp(append)) {\n for (let k = 0; k < supportedList.length; ++k) {\n const algo = supportedList[k];\n if (append.test(algo)) {\n if (list.indexOf(algo) !== -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.push(algo);\n }\n }\n }\n }\n }\n break;\n case 'prepend':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = val.length; j >= 0; --j) {\n const prepend = val[j];\n if (typeof prepend === 'string') {\n if (!prepend || list.indexOf(prepend) !== -1)\n continue;\n if (supportedList.indexOf(prepend) === -1)\n throw new Error(`Unsupported algorithm: ${prepend}`);\n if (list === defaultList)\n list = list.slice();\n list.unshift(prepend);\n } else if (isRegExp(prepend)) {\n for (let k = supportedList.length; k >= 0; --k) {\n const algo = supportedList[k];\n if (prepend.test(algo)) {\n if (list.indexOf(algo) !== -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.unshift(algo);\n }\n }\n }\n }\n }\n break;\n case 'remove':\n if (!Array.isArray(val))\n val = [val];\n if (Array.isArray(val)) {\n for (let j = 0; j < val.length; ++j) {\n const search = val[j];\n if (typeof search === 'string') {\n if (!search)\n continue;\n const idx = list.indexOf(search);\n if (idx === -1)\n continue;\n if (list === defaultList)\n list = list.slice();\n list.splice(idx, 1);\n } else if (isRegExp(search)) {\n for (let k = 0; k < list.length; ++k) {\n if (search.test(list[k])) {\n if (list === defaultList)\n list = list.slice();\n list.splice(k, 1);\n --k;\n }\n }\n }\n }\n }\n break;\n }\n }\n\n return list;\n }\n\n return defaultList;\n}\n\nmodule.exports = {\n ChannelManager,\n generateAlgorithmList,\n onChannelOpenFailure,\n onCHANNEL_CLOSE,\n isWritable: (stream) => {\n // XXX: hack to workaround regression in node\n // See: https://github.com/nodejs/node/issues/36029\n return (stream\n && stream.writable\n && stream._readableState\n && stream._readableState.ended === false);\n },\n};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\n/**/\n\nvar isEncoding = Buffer.isEncoding || function (encoding) {\n encoding = '' + encoding;\n switch (encoding && encoding.toLowerCase()) {\n case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':\n return true;\n default:\n return false;\n }\n};\n\nfunction _normalizeEncoding(enc) {\n if (!enc) return 'utf8';\n var retried;\n while (true) {\n switch (enc) {\n case 'utf8':\n case 'utf-8':\n return 'utf8';\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return 'utf16le';\n case 'latin1':\n case 'binary':\n return 'latin1';\n case 'base64':\n case 'ascii':\n case 'hex':\n return enc;\n default:\n if (retried) return; // undefined\n enc = ('' + enc).toLowerCase();\n retried = true;\n }\n }\n};\n\n// Do not cache `Buffer.isEncoding` when checking encoding names as some\n// modules monkey-patch it to support additional encodings\nfunction normalizeEncoding(enc) {\n var nenc = _normalizeEncoding(enc);\n if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);\n return nenc || enc;\n}\n\n// StringDecoder provides an interface for efficiently splitting a series of\n// buffers into a series of JS strings without breaking apart multi-byte\n// characters.\nexports.StringDecoder = StringDecoder;\nfunction StringDecoder(encoding) {\n this.encoding = normalizeEncoding(encoding);\n var nb;\n switch (this.encoding) {\n case 'utf16le':\n this.text = utf16Text;\n this.end = utf16End;\n nb = 4;\n break;\n case 'utf8':\n this.fillLast = utf8FillLast;\n nb = 4;\n break;\n case 'base64':\n this.text = base64Text;\n this.end = base64End;\n nb = 3;\n break;\n default:\n this.write = simpleWrite;\n this.end = simpleEnd;\n return;\n }\n this.lastNeed = 0;\n this.lastTotal = 0;\n this.lastChar = Buffer.allocUnsafe(nb);\n}\n\nStringDecoder.prototype.write = function (buf) {\n if (buf.length === 0) return '';\n var r;\n var i;\n if (this.lastNeed) {\n r = this.fillLast(buf);\n if (r === undefined) return '';\n i = this.lastNeed;\n this.lastNeed = 0;\n } else {\n i = 0;\n }\n if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);\n return r || '';\n};\n\nStringDecoder.prototype.end = utf8End;\n\n// Returns only complete characters in a Buffer\nStringDecoder.prototype.text = utf8Text;\n\n// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer\nStringDecoder.prototype.fillLast = function (buf) {\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);\n this.lastNeed -= buf.length;\n};\n\n// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a\n// continuation byte. If an invalid byte is detected, -2 is returned.\nfunction utf8CheckByte(byte) {\n if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;\n return byte >> 6 === 0x02 ? -1 : -2;\n}\n\n// Checks at most 3 bytes at the end of a Buffer in order to detect an\n// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)\n// needed to complete the UTF-8 character (if applicable) are returned.\nfunction utf8CheckIncomplete(self, buf, i) {\n var j = buf.length - 1;\n if (j < i) return 0;\n var nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 1;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 2;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) {\n if (nb === 2) nb = 0;else self.lastNeed = nb - 3;\n }\n return nb;\n }\n return 0;\n}\n\n// Validates as many continuation bytes for a multi-byte UTF-8 character as\n// needed or are available. If we see a non-continuation byte where we expect\n// one, we \"replace\" the validated continuation bytes we've seen so far with\n// a single UTF-8 replacement character ('\\ufffd'), to match v8's UTF-8 decoding\n// behavior. The continuation byte check is included three times in the case\n// where all of the continuation bytes for a character exist in the same buffer.\n// It is also done this way as a slight performance increase instead of using a\n// loop.\nfunction utf8CheckExtraBytes(self, buf, p) {\n if ((buf[0] & 0xC0) !== 0x80) {\n self.lastNeed = 0;\n return '\\ufffd';\n }\n if (self.lastNeed > 1 && buf.length > 1) {\n if ((buf[1] & 0xC0) !== 0x80) {\n self.lastNeed = 1;\n return '\\ufffd';\n }\n if (self.lastNeed > 2 && buf.length > 2) {\n if ((buf[2] & 0xC0) !== 0x80) {\n self.lastNeed = 2;\n return '\\ufffd';\n }\n }\n }\n}\n\n// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.\nfunction utf8FillLast(buf) {\n var p = this.lastTotal - this.lastNeed;\n var r = utf8CheckExtraBytes(this, buf, p);\n if (r !== undefined) return r;\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, p, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, p, 0, buf.length);\n this.lastNeed -= buf.length;\n}\n\n// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a\n// partial character, the character's bytes are buffered until the required\n// number of bytes are available.\nfunction utf8Text(buf, i) {\n var total = utf8CheckIncomplete(this, buf, i);\n if (!this.lastNeed) return buf.toString('utf8', i);\n this.lastTotal = total;\n var end = buf.length - (total - this.lastNeed);\n buf.copy(this.lastChar, 0, end);\n return buf.toString('utf8', i, end);\n}\n\n// For UTF-8, a replacement character is added when ending on a partial\n// character.\nfunction utf8End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + '\\ufffd';\n return r;\n}\n\n// UTF-16LE typically needs two bytes per character, but even if we have an even\n// number of bytes available, we need to check if we end on a leading/high\n// surrogate. In that case, we need to wait for the next two bytes in order to\n// decode the last character properly.\nfunction utf16Text(buf, i) {\n if ((buf.length - i) % 2 === 0) {\n var r = buf.toString('utf16le', i);\n if (r) {\n var c = r.charCodeAt(r.length - 1);\n if (c >= 0xD800 && c <= 0xDBFF) {\n this.lastNeed = 2;\n this.lastTotal = 4;\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n return r.slice(0, -1);\n }\n }\n return r;\n }\n this.lastNeed = 1;\n this.lastTotal = 2;\n this.lastChar[0] = buf[buf.length - 1];\n return buf.toString('utf16le', i, buf.length - 1);\n}\n\n// For UTF-16LE we do not explicitly append special replacement characters if we\n// end on a partial character, we simply let v8 handle that.\nfunction utf16End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) {\n var end = this.lastTotal - this.lastNeed;\n return r + this.lastChar.toString('utf16le', 0, end);\n }\n return r;\n}\n\nfunction base64Text(buf, i) {\n var n = (buf.length - i) % 3;\n if (n === 0) return buf.toString('base64', i);\n this.lastNeed = 3 - n;\n this.lastTotal = 3;\n if (n === 1) {\n this.lastChar[0] = buf[buf.length - 1];\n } else {\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n }\n return buf.toString('base64', i, buf.length - n);\n}\n\nfunction base64End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);\n return r;\n}\n\n// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)\nfunction simpleWrite(buf) {\n return buf.toString(this.encoding);\n}\n\nfunction simpleEnd(buf) {\n return buf && buf.length ? this.write(buf) : '';\n}","/*! safe-buffer. MIT License. Feross Aboukhadijeh */\n/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.prototype = Object.create(Buffer.prototype)\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\nconst os = require('os');\nconst tty = require('tty');\nconst hasFlag = require('has-flag');\n\nconst {env} = process;\n\nlet forceColor;\nif (hasFlag('no-color') ||\n\thasFlag('no-colors') ||\n\thasFlag('color=false') ||\n\thasFlag('color=never')) {\n\tforceColor = 0;\n} else if (hasFlag('color') ||\n\thasFlag('colors') ||\n\thasFlag('color=true') ||\n\thasFlag('color=always')) {\n\tforceColor = 1;\n}\n\nif ('FORCE_COLOR' in env) {\n\tif (env.FORCE_COLOR === 'true') {\n\t\tforceColor = 1;\n\t} else if (env.FORCE_COLOR === 'false') {\n\t\tforceColor = 0;\n\t} else {\n\t\tforceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);\n\t}\n}\n\nfunction translateLevel(level) {\n\tif (level === 0) {\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tlevel,\n\t\thasBasic: true,\n\t\thas256: level >= 2,\n\t\thas16m: level >= 3\n\t};\n}\n\nfunction supportsColor(haveStream, streamIsTTY) {\n\tif (forceColor === 0) {\n\t\treturn 0;\n\t}\n\n\tif (hasFlag('color=16m') ||\n\t\thasFlag('color=full') ||\n\t\thasFlag('color=truecolor')) {\n\t\treturn 3;\n\t}\n\n\tif (hasFlag('color=256')) {\n\t\treturn 2;\n\t}\n\n\tif (haveStream && !streamIsTTY && forceColor === undefined) {\n\t\treturn 0;\n\t}\n\n\tconst min = forceColor || 0;\n\n\tif (env.TERM === 'dumb') {\n\t\treturn min;\n\t}\n\n\tif (process.platform === 'win32') {\n\t\t// Windows 10 build 10586 is the first Windows release that supports 256 colors.\n\t\t// Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n\t\tconst osRelease = os.release().split('.');\n\t\tif (\n\t\t\tNumber(osRelease[0]) >= 10 &&\n\t\t\tNumber(osRelease[2]) >= 10586\n\t\t) {\n\t\t\treturn Number(osRelease[2]) >= 14931 ? 3 : 2;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif ('CI' in env) {\n\t\tif (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn min;\n\t}\n\n\tif ('TEAMCITY_VERSION' in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;\n\t}\n\n\tif (env.COLORTERM === 'truecolor') {\n\t\treturn 3;\n\t}\n\n\tif ('TERM_PROGRAM' in env) {\n\t\tconst version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);\n\n\t\tswitch (env.TERM_PROGRAM) {\n\t\t\tcase 'iTerm.app':\n\t\t\t\treturn version >= 3 ? 3 : 2;\n\t\t\tcase 'Apple_Terminal':\n\t\t\t\treturn 2;\n\t\t\t// No default\n\t\t}\n\t}\n\n\tif (/-256(color)?$/i.test(env.TERM)) {\n\t\treturn 2;\n\t}\n\n\tif (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {\n\t\treturn 1;\n\t}\n\n\tif ('COLORTERM' in env) {\n\t\treturn 1;\n\t}\n\n\treturn min;\n}\n\nfunction getSupportLevel(stream) {\n\tconst level = supportsColor(stream, stream && stream.isTTY);\n\treturn translateLevel(level);\n}\n\nmodule.exports = {\n\tsupportsColor: getSupportLevel,\n\tstdout: translateLevel(supportsColor(true, tty.isatty(1))),\n\tstderr: translateLevel(supportsColor(true, tty.isatty(2)))\n};\n","var chownr = require('chownr')\nvar tar = require('tar-stream')\nvar pump = require('pump')\nvar mkdirp = require('mkdirp-classic')\nvar fs = require('fs')\nvar path = require('path')\nvar os = require('os')\n\nvar win32 = os.platform() === 'win32'\n\nvar noop = function () {}\n\nvar echo = function (name) {\n return name\n}\n\nvar normalize = !win32 ? echo : function (name) {\n return name.replace(/\\\\/g, '/').replace(/[:?<>|]/g, '_')\n}\n\nvar statAll = function (fs, stat, cwd, ignore, entries, sort) {\n var queue = entries || ['.']\n\n return function loop (callback) {\n if (!queue.length) return callback()\n var next = queue.shift()\n var nextAbs = path.join(cwd, next)\n\n stat(nextAbs, function (err, stat) {\n if (err) return callback(err)\n\n if (!stat.isDirectory()) return callback(null, next, stat)\n\n fs.readdir(nextAbs, function (err, files) {\n if (err) return callback(err)\n\n if (sort) files.sort()\n for (var i = 0; i < files.length; i++) {\n if (!ignore(path.join(cwd, next, files[i]))) queue.push(path.join(next, files[i]))\n }\n\n callback(null, next, stat)\n })\n })\n }\n}\n\nvar strip = function (map, level) {\n return function (header) {\n header.name = header.name.split('/').slice(level).join('/')\n\n var linkname = header.linkname\n if (linkname && (header.type === 'link' || path.isAbsolute(linkname))) {\n header.linkname = linkname.split('/').slice(level).join('/')\n }\n\n return map(header)\n }\n}\n\nexports.pack = function (cwd, opts) {\n if (!cwd) cwd = '.'\n if (!opts) opts = {}\n\n var xfs = opts.fs || fs\n var ignore = opts.ignore || opts.filter || noop\n var map = opts.map || noop\n var mapStream = opts.mapStream || echo\n var statNext = statAll(xfs, opts.dereference ? xfs.stat : xfs.lstat, cwd, ignore, opts.entries, opts.sort)\n var strict = opts.strict !== false\n var umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()\n var dmode = typeof opts.dmode === 'number' ? opts.dmode : 0\n var fmode = typeof opts.fmode === 'number' ? opts.fmode : 0\n var pack = opts.pack || tar.pack()\n var finish = opts.finish || noop\n\n if (opts.strip) map = strip(map, opts.strip)\n\n if (opts.readable) {\n dmode |= parseInt(555, 8)\n fmode |= parseInt(444, 8)\n }\n if (opts.writable) {\n dmode |= parseInt(333, 8)\n fmode |= parseInt(222, 8)\n }\n\n var onsymlink = function (filename, header) {\n xfs.readlink(path.join(cwd, filename), function (err, linkname) {\n if (err) return pack.destroy(err)\n header.linkname = normalize(linkname)\n pack.entry(header, onnextentry)\n })\n }\n\n var onstat = function (err, filename, stat) {\n if (err) return pack.destroy(err)\n if (!filename) {\n if (opts.finalize !== false) pack.finalize()\n return finish(pack)\n }\n\n if (stat.isSocket()) return onnextentry() // tar does not support sockets...\n\n var header = {\n name: normalize(filename),\n mode: (stat.mode | (stat.isDirectory() ? dmode : fmode)) & umask,\n mtime: stat.mtime,\n size: stat.size,\n type: 'file',\n uid: stat.uid,\n gid: stat.gid\n }\n\n if (stat.isDirectory()) {\n header.size = 0\n header.type = 'directory'\n header = map(header) || header\n return pack.entry(header, onnextentry)\n }\n\n if (stat.isSymbolicLink()) {\n header.size = 0\n header.type = 'symlink'\n header = map(header) || header\n return onsymlink(filename, header)\n }\n\n // TODO: add fifo etc...\n\n header = map(header) || header\n\n if (!stat.isFile()) {\n if (strict) return pack.destroy(new Error('unsupported type for ' + filename))\n return onnextentry()\n }\n\n var entry = pack.entry(header, onnextentry)\n if (!entry) return\n\n var rs = mapStream(xfs.createReadStream(path.join(cwd, filename)), header)\n\n rs.on('error', function (err) { // always forward errors on destroy\n entry.destroy(err)\n })\n\n pump(rs, entry)\n }\n\n var onnextentry = function (err) {\n if (err) return pack.destroy(err)\n statNext(onstat)\n }\n\n onnextentry()\n\n return pack\n}\n\nvar head = function (list) {\n return list.length ? list[list.length - 1] : null\n}\n\nvar processGetuid = function () {\n return process.getuid ? process.getuid() : -1\n}\n\nvar processUmask = function () {\n return process.umask ? process.umask() : 0\n}\n\nexports.extract = function (cwd, opts) {\n if (!cwd) cwd = '.'\n if (!opts) opts = {}\n\n var xfs = opts.fs || fs\n var ignore = opts.ignore || opts.filter || noop\n var map = opts.map || noop\n var mapStream = opts.mapStream || echo\n var own = opts.chown !== false && !win32 && processGetuid() === 0\n var extract = opts.extract || tar.extract()\n var stack = []\n var now = new Date()\n var umask = typeof opts.umask === 'number' ? ~opts.umask : ~processUmask()\n var dmode = typeof opts.dmode === 'number' ? opts.dmode : 0\n var fmode = typeof opts.fmode === 'number' ? opts.fmode : 0\n var strict = opts.strict !== false\n\n if (opts.strip) map = strip(map, opts.strip)\n\n if (opts.readable) {\n dmode |= parseInt(555, 8)\n fmode |= parseInt(444, 8)\n }\n if (opts.writable) {\n dmode |= parseInt(333, 8)\n fmode |= parseInt(222, 8)\n }\n\n var utimesParent = function (name, cb) { // we just set the mtime on the parent dir again everytime we write an entry\n var top\n while ((top = head(stack)) && name.slice(0, top[0].length) !== top[0]) stack.pop()\n if (!top) return cb()\n xfs.utimes(top[0], now, top[1], cb)\n }\n\n var utimes = function (name, header, cb) {\n if (opts.utimes === false) return cb()\n\n if (header.type === 'directory') return xfs.utimes(name, now, header.mtime, cb)\n if (header.type === 'symlink') return utimesParent(name, cb) // TODO: how to set mtime on link?\n\n xfs.utimes(name, now, header.mtime, function (err) {\n if (err) return cb(err)\n utimesParent(name, cb)\n })\n }\n\n var chperm = function (name, header, cb) {\n var link = header.type === 'symlink'\n\n /* eslint-disable node/no-deprecated-api */\n var chmod = link ? xfs.lchmod : xfs.chmod\n var chown = link ? xfs.lchown : xfs.chown\n /* eslint-enable node/no-deprecated-api */\n\n if (!chmod) return cb()\n\n var mode = (header.mode | (header.type === 'directory' ? dmode : fmode)) & umask\n chmod(name, mode, function (err) {\n if (err) return cb(err)\n if (!own) return cb()\n if (!chown) return cb()\n chown(name, header.uid, header.gid, cb)\n })\n }\n\n extract.on('entry', function (header, stream, next) {\n header = map(header) || header\n header.name = normalize(header.name)\n var name = path.join(cwd, path.join('/', header.name))\n\n if (ignore(name, header)) {\n stream.resume()\n return next()\n }\n\n var stat = function (err) {\n if (err) return next(err)\n utimes(name, header, function (err) {\n if (err) return next(err)\n if (win32) return next()\n chperm(name, header, next)\n })\n }\n\n var onsymlink = function () {\n if (win32) return next() // skip symlinks on win for now before it can be tested\n xfs.unlink(name, function () {\n xfs.symlink(header.linkname, name, stat)\n })\n }\n\n var onlink = function () {\n if (win32) return next() // skip links on win for now before it can be tested\n xfs.unlink(name, function () {\n var srcpath = path.join(cwd, path.join('/', header.linkname))\n\n xfs.link(srcpath, name, function (err) {\n if (err && err.code === 'EPERM' && opts.hardlinkAsFilesFallback) {\n stream = xfs.createReadStream(srcpath)\n return onfile()\n }\n\n stat(err)\n })\n })\n }\n\n var onfile = function () {\n var ws = xfs.createWriteStream(name)\n var rs = mapStream(stream, header)\n\n ws.on('error', function (err) { // always forward errors on destroy\n rs.destroy(err)\n })\n\n pump(rs, ws, function (err) {\n if (err) return next(err)\n ws.on('close', stat)\n })\n }\n\n if (header.type === 'directory') {\n stack.push([name, header.mtime])\n return mkdirfix(name, {\n fs: xfs, own: own, uid: header.uid, gid: header.gid\n }, stat)\n }\n\n var dir = path.dirname(name)\n\n validate(xfs, dir, path.join(cwd, '.'), function (err, valid) {\n if (err) return next(err)\n if (!valid) return next(new Error(dir + ' is not a valid path'))\n\n mkdirfix(dir, {\n fs: xfs, own: own, uid: header.uid, gid: header.gid\n }, function (err) {\n if (err) return next(err)\n\n switch (header.type) {\n case 'file': return onfile()\n case 'link': return onlink()\n case 'symlink': return onsymlink()\n }\n\n if (strict) return next(new Error('unsupported type for ' + name + ' (' + header.type + ')'))\n\n stream.resume()\n next()\n })\n })\n })\n\n if (opts.finish) extract.on('finish', opts.finish)\n\n return extract\n}\n\nfunction validate (fs, name, root, cb) {\n if (name === root) return cb(null, true)\n fs.lstat(name, function (err, st) {\n if (err && err.code !== 'ENOENT') return cb(err)\n if (err || st.isDirectory()) return validate(fs, path.join(name, '..'), root, cb)\n cb(null, false)\n })\n}\n\nfunction mkdirfix (name, opts, cb) {\n mkdirp(name, { fs: opts.fs }, function (err, made) {\n if (!err && made && opts.own) {\n chownr(made, opts.uid, opts.gid, cb)\n } else {\n cb(err)\n }\n })\n}\n","var util = require('util')\nvar bl = require('bl')\nvar headers = require('./headers')\n\nvar Writable = require('readable-stream').Writable\nvar PassThrough = require('readable-stream').PassThrough\n\nvar noop = function () {}\n\nvar overflow = function (size) {\n size &= 511\n return size && 512 - size\n}\n\nvar emptyStream = function (self, offset) {\n var s = new Source(self, offset)\n s.end()\n return s\n}\n\nvar mixinPax = function (header, pax) {\n if (pax.path) header.name = pax.path\n if (pax.linkpath) header.linkname = pax.linkpath\n if (pax.size) header.size = parseInt(pax.size, 10)\n header.pax = pax\n return header\n}\n\nvar Source = function (self, offset) {\n this._parent = self\n this.offset = offset\n PassThrough.call(this, { autoDestroy: false })\n}\n\nutil.inherits(Source, PassThrough)\n\nSource.prototype.destroy = function (err) {\n this._parent.destroy(err)\n}\n\nvar Extract = function (opts) {\n if (!(this instanceof Extract)) return new Extract(opts)\n Writable.call(this, opts)\n\n opts = opts || {}\n\n this._offset = 0\n this._buffer = bl()\n this._missing = 0\n this._partial = false\n this._onparse = noop\n this._header = null\n this._stream = null\n this._overflow = null\n this._cb = null\n this._locked = false\n this._destroyed = false\n this._pax = null\n this._paxGlobal = null\n this._gnuLongPath = null\n this._gnuLongLinkPath = null\n\n var self = this\n var b = self._buffer\n\n var oncontinue = function () {\n self._continue()\n }\n\n var onunlock = function (err) {\n self._locked = false\n if (err) return self.destroy(err)\n if (!self._stream) oncontinue()\n }\n\n var onstreamend = function () {\n self._stream = null\n var drain = overflow(self._header.size)\n if (drain) self._parse(drain, ondrain)\n else self._parse(512, onheader)\n if (!self._locked) oncontinue()\n }\n\n var ondrain = function () {\n self._buffer.consume(overflow(self._header.size))\n self._parse(512, onheader)\n oncontinue()\n }\n\n var onpaxglobalheader = function () {\n var size = self._header.size\n self._paxGlobal = headers.decodePax(b.slice(0, size))\n b.consume(size)\n onstreamend()\n }\n\n var onpaxheader = function () {\n var size = self._header.size\n self._pax = headers.decodePax(b.slice(0, size))\n if (self._paxGlobal) self._pax = Object.assign({}, self._paxGlobal, self._pax)\n b.consume(size)\n onstreamend()\n }\n\n var ongnulongpath = function () {\n var size = self._header.size\n this._gnuLongPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)\n b.consume(size)\n onstreamend()\n }\n\n var ongnulonglinkpath = function () {\n var size = self._header.size\n this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)\n b.consume(size)\n onstreamend()\n }\n\n var onheader = function () {\n var offset = self._offset\n var header\n try {\n header = self._header = headers.decode(b.slice(0, 512), opts.filenameEncoding, opts.allowUnknownFormat)\n } catch (err) {\n self.emit('error', err)\n }\n b.consume(512)\n\n if (!header) {\n self._parse(512, onheader)\n oncontinue()\n return\n }\n if (header.type === 'gnu-long-path') {\n self._parse(header.size, ongnulongpath)\n oncontinue()\n return\n }\n if (header.type === 'gnu-long-link-path') {\n self._parse(header.size, ongnulonglinkpath)\n oncontinue()\n return\n }\n if (header.type === 'pax-global-header') {\n self._parse(header.size, onpaxglobalheader)\n oncontinue()\n return\n }\n if (header.type === 'pax-header') {\n self._parse(header.size, onpaxheader)\n oncontinue()\n return\n }\n\n if (self._gnuLongPath) {\n header.name = self._gnuLongPath\n self._gnuLongPath = null\n }\n\n if (self._gnuLongLinkPath) {\n header.linkname = self._gnuLongLinkPath\n self._gnuLongLinkPath = null\n }\n\n if (self._pax) {\n self._header = header = mixinPax(header, self._pax)\n self._pax = null\n }\n\n self._locked = true\n\n if (!header.size || header.type === 'directory') {\n self._parse(512, onheader)\n self.emit('entry', header, emptyStream(self, offset), onunlock)\n return\n }\n\n self._stream = new Source(self, offset)\n\n self.emit('entry', header, self._stream, onunlock)\n self._parse(header.size, onstreamend)\n oncontinue()\n }\n\n this._onheader = onheader\n this._parse(512, onheader)\n}\n\nutil.inherits(Extract, Writable)\n\nExtract.prototype.destroy = function (err) {\n if (this._destroyed) return\n this._destroyed = true\n\n if (err) this.emit('error', err)\n this.emit('close')\n if (this._stream) this._stream.emit('close')\n}\n\nExtract.prototype._parse = function (size, onparse) {\n if (this._destroyed) return\n this._offset += size\n this._missing = size\n if (onparse === this._onheader) this._partial = false\n this._onparse = onparse\n}\n\nExtract.prototype._continue = function () {\n if (this._destroyed) return\n var cb = this._cb\n this._cb = noop\n if (this._overflow) this._write(this._overflow, undefined, cb)\n else cb()\n}\n\nExtract.prototype._write = function (data, enc, cb) {\n if (this._destroyed) return\n\n var s = this._stream\n var b = this._buffer\n var missing = this._missing\n if (data.length) this._partial = true\n\n // we do not reach end-of-chunk now. just forward it\n\n if (data.length < missing) {\n this._missing -= data.length\n this._overflow = null\n if (s) return s.write(data, cb)\n b.append(data)\n return cb()\n }\n\n // end-of-chunk. the parser should call cb.\n\n this._cb = cb\n this._missing = 0\n\n var overflow = null\n if (data.length > missing) {\n overflow = data.slice(missing)\n data = data.slice(0, missing)\n }\n\n if (s) s.end(data)\n else b.append(data)\n\n this._overflow = overflow\n this._onparse()\n}\n\nExtract.prototype._final = function (cb) {\n if (this._partial) return this.destroy(new Error('Unexpected end of data'))\n cb()\n}\n\nmodule.exports = Extract\n","var alloc = Buffer.alloc\n\nvar ZEROS = '0000000000000000000'\nvar SEVENS = '7777777777777777777'\nvar ZERO_OFFSET = '0'.charCodeAt(0)\nvar USTAR_MAGIC = Buffer.from('ustar\\x00', 'binary')\nvar USTAR_VER = Buffer.from('00', 'binary')\nvar GNU_MAGIC = Buffer.from('ustar\\x20', 'binary')\nvar GNU_VER = Buffer.from('\\x20\\x00', 'binary')\nvar MASK = parseInt('7777', 8)\nvar MAGIC_OFFSET = 257\nvar VERSION_OFFSET = 263\n\nvar clamp = function (index, len, defaultValue) {\n if (typeof index !== 'number') return defaultValue\n index = ~~index // Coerce to integer.\n if (index >= len) return len\n if (index >= 0) return index\n index += len\n if (index >= 0) return index\n return 0\n}\n\nvar toType = function (flag) {\n switch (flag) {\n case 0:\n return 'file'\n case 1:\n return 'link'\n case 2:\n return 'symlink'\n case 3:\n return 'character-device'\n case 4:\n return 'block-device'\n case 5:\n return 'directory'\n case 6:\n return 'fifo'\n case 7:\n return 'contiguous-file'\n case 72:\n return 'pax-header'\n case 55:\n return 'pax-global-header'\n case 27:\n return 'gnu-long-link-path'\n case 28:\n case 30:\n return 'gnu-long-path'\n }\n\n return null\n}\n\nvar toTypeflag = function (flag) {\n switch (flag) {\n case 'file':\n return 0\n case 'link':\n return 1\n case 'symlink':\n return 2\n case 'character-device':\n return 3\n case 'block-device':\n return 4\n case 'directory':\n return 5\n case 'fifo':\n return 6\n case 'contiguous-file':\n return 7\n case 'pax-header':\n return 72\n }\n\n return 0\n}\n\nvar indexOf = function (block, num, offset, end) {\n for (; offset < end; offset++) {\n if (block[offset] === num) return offset\n }\n return end\n}\n\nvar cksum = function (block) {\n var sum = 8 * 32\n for (var i = 0; i < 148; i++) sum += block[i]\n for (var j = 156; j < 512; j++) sum += block[j]\n return sum\n}\n\nvar encodeOct = function (val, n) {\n val = val.toString(8)\n if (val.length > n) return SEVENS.slice(0, n) + ' '\n else return ZEROS.slice(0, n - val.length) + val + ' '\n}\n\n/* Copied from the node-tar repo and modified to meet\n * tar-stream coding standard.\n *\n * Source: https://github.com/npm/node-tar/blob/51b6627a1f357d2eb433e7378e5f05e83b7aa6cd/lib/header.js#L349\n */\nfunction parse256 (buf) {\n // first byte MUST be either 80 or FF\n // 80 for positive, FF for 2's comp\n var positive\n if (buf[0] === 0x80) positive = true\n else if (buf[0] === 0xFF) positive = false\n else return null\n\n // build up a base-256 tuple from the least sig to the highest\n var tuple = []\n for (var i = buf.length - 1; i > 0; i--) {\n var byte = buf[i]\n if (positive) tuple.push(byte)\n else tuple.push(0xFF - byte)\n }\n\n var sum = 0\n var l = tuple.length\n for (i = 0; i < l; i++) {\n sum += tuple[i] * Math.pow(256, i)\n }\n\n return positive ? sum : -1 * sum\n}\n\nvar decodeOct = function (val, offset, length) {\n val = val.slice(offset, offset + length)\n offset = 0\n\n // If prefixed with 0x80 then parse as a base-256 integer\n if (val[offset] & 0x80) {\n return parse256(val)\n } else {\n // Older versions of tar can prefix with spaces\n while (offset < val.length && val[offset] === 32) offset++\n var end = clamp(indexOf(val, 32, offset, val.length), val.length, val.length)\n while (offset < end && val[offset] === 0) offset++\n if (end === offset) return 0\n return parseInt(val.slice(offset, end).toString(), 8)\n }\n}\n\nvar decodeStr = function (val, offset, length, encoding) {\n return val.slice(offset, indexOf(val, 0, offset, offset + length)).toString(encoding)\n}\n\nvar addLength = function (str) {\n var len = Buffer.byteLength(str)\n var digits = Math.floor(Math.log(len) / Math.log(10)) + 1\n if (len + digits >= Math.pow(10, digits)) digits++\n\n return (len + digits) + str\n}\n\nexports.decodeLongPath = function (buf, encoding) {\n return decodeStr(buf, 0, buf.length, encoding)\n}\n\nexports.encodePax = function (opts) { // TODO: encode more stuff in pax\n var result = ''\n if (opts.name) result += addLength(' path=' + opts.name + '\\n')\n if (opts.linkname) result += addLength(' linkpath=' + opts.linkname + '\\n')\n var pax = opts.pax\n if (pax) {\n for (var key in pax) {\n result += addLength(' ' + key + '=' + pax[key] + '\\n')\n }\n }\n return Buffer.from(result)\n}\n\nexports.decodePax = function (buf) {\n var result = {}\n\n while (buf.length) {\n var i = 0\n while (i < buf.length && buf[i] !== 32) i++\n var len = parseInt(buf.slice(0, i).toString(), 10)\n if (!len) return result\n\n var b = buf.slice(i + 1, len - 1).toString()\n var keyIndex = b.indexOf('=')\n if (keyIndex === -1) return result\n result[b.slice(0, keyIndex)] = b.slice(keyIndex + 1)\n\n buf = buf.slice(len)\n }\n\n return result\n}\n\nexports.encode = function (opts) {\n var buf = alloc(512)\n var name = opts.name\n var prefix = ''\n\n if (opts.typeflag === 5 && name[name.length - 1] !== '/') name += '/'\n if (Buffer.byteLength(name) !== name.length) return null // utf-8\n\n while (Buffer.byteLength(name) > 100) {\n var i = name.indexOf('/')\n if (i === -1) return null\n prefix += prefix ? '/' + name.slice(0, i) : name.slice(0, i)\n name = name.slice(i + 1)\n }\n\n if (Buffer.byteLength(name) > 100 || Buffer.byteLength(prefix) > 155) return null\n if (opts.linkname && Buffer.byteLength(opts.linkname) > 100) return null\n\n buf.write(name)\n buf.write(encodeOct(opts.mode & MASK, 6), 100)\n buf.write(encodeOct(opts.uid, 6), 108)\n buf.write(encodeOct(opts.gid, 6), 116)\n buf.write(encodeOct(opts.size, 11), 124)\n buf.write(encodeOct((opts.mtime.getTime() / 1000) | 0, 11), 136)\n\n buf[156] = ZERO_OFFSET + toTypeflag(opts.type)\n\n if (opts.linkname) buf.write(opts.linkname, 157)\n\n USTAR_MAGIC.copy(buf, MAGIC_OFFSET)\n USTAR_VER.copy(buf, VERSION_OFFSET)\n if (opts.uname) buf.write(opts.uname, 265)\n if (opts.gname) buf.write(opts.gname, 297)\n buf.write(encodeOct(opts.devmajor || 0, 6), 329)\n buf.write(encodeOct(opts.devminor || 0, 6), 337)\n\n if (prefix) buf.write(prefix, 345)\n\n buf.write(encodeOct(cksum(buf), 6), 148)\n\n return buf\n}\n\nexports.decode = function (buf, filenameEncoding, allowUnknownFormat) {\n var typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET\n\n var name = decodeStr(buf, 0, 100, filenameEncoding)\n var mode = decodeOct(buf, 100, 8)\n var uid = decodeOct(buf, 108, 8)\n var gid = decodeOct(buf, 116, 8)\n var size = decodeOct(buf, 124, 12)\n var mtime = decodeOct(buf, 136, 12)\n var type = toType(typeflag)\n var linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100, filenameEncoding)\n var uname = decodeStr(buf, 265, 32)\n var gname = decodeStr(buf, 297, 32)\n var devmajor = decodeOct(buf, 329, 8)\n var devminor = decodeOct(buf, 337, 8)\n\n var c = cksum(buf)\n\n // checksum is still initial value if header was null.\n if (c === 8 * 32) return null\n\n // valid checksum\n if (c !== decodeOct(buf, 148, 8)) throw new Error('Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?')\n\n if (USTAR_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0) {\n // ustar (posix) format.\n // prepend prefix, if present.\n if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + '/' + name\n } else if (GNU_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0 &&\n GNU_VER.compare(buf, VERSION_OFFSET, VERSION_OFFSET + 2) === 0) {\n // 'gnu'/'oldgnu' format. Similar to ustar, but has support for incremental and\n // multi-volume tarballs.\n } else {\n if (!allowUnknownFormat) {\n throw new Error('Invalid tar header: unknown format.')\n }\n }\n\n // to support old tar versions that use trailing / to indicate dirs\n if (typeflag === 0 && name && name[name.length - 1] === '/') typeflag = 5\n\n return {\n name,\n mode,\n uid,\n gid,\n size,\n mtime: new Date(1000 * mtime),\n type,\n linkname,\n uname,\n gname,\n devmajor,\n devminor\n }\n}\n","exports.extract = require('./extract')\nexports.pack = require('./pack')\n","var constants = require('fs-constants')\nvar eos = require('end-of-stream')\nvar inherits = require('inherits')\nvar alloc = Buffer.alloc\n\nvar Readable = require('readable-stream').Readable\nvar Writable = require('readable-stream').Writable\nvar StringDecoder = require('string_decoder').StringDecoder\n\nvar headers = require('./headers')\n\nvar DMODE = parseInt('755', 8)\nvar FMODE = parseInt('644', 8)\n\nvar END_OF_TAR = alloc(1024)\n\nvar noop = function () {}\n\nvar overflow = function (self, size) {\n size &= 511\n if (size) self.push(END_OF_TAR.slice(0, 512 - size))\n}\n\nfunction modeToType (mode) {\n switch (mode & constants.S_IFMT) {\n case constants.S_IFBLK: return 'block-device'\n case constants.S_IFCHR: return 'character-device'\n case constants.S_IFDIR: return 'directory'\n case constants.S_IFIFO: return 'fifo'\n case constants.S_IFLNK: return 'symlink'\n }\n\n return 'file'\n}\n\nvar Sink = function (to) {\n Writable.call(this)\n this.written = 0\n this._to = to\n this._destroyed = false\n}\n\ninherits(Sink, Writable)\n\nSink.prototype._write = function (data, enc, cb) {\n this.written += data.length\n if (this._to.push(data)) return cb()\n this._to._drain = cb\n}\n\nSink.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar LinkSink = function () {\n Writable.call(this)\n this.linkname = ''\n this._decoder = new StringDecoder('utf-8')\n this._destroyed = false\n}\n\ninherits(LinkSink, Writable)\n\nLinkSink.prototype._write = function (data, enc, cb) {\n this.linkname += this._decoder.write(data)\n cb()\n}\n\nLinkSink.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar Void = function () {\n Writable.call(this)\n this._destroyed = false\n}\n\ninherits(Void, Writable)\n\nVoid.prototype._write = function (data, enc, cb) {\n cb(new Error('No body allowed for this entry'))\n}\n\nVoid.prototype.destroy = function () {\n if (this._destroyed) return\n this._destroyed = true\n this.emit('close')\n}\n\nvar Pack = function (opts) {\n if (!(this instanceof Pack)) return new Pack(opts)\n Readable.call(this, opts)\n\n this._drain = noop\n this._finalized = false\n this._finalizing = false\n this._destroyed = false\n this._stream = null\n}\n\ninherits(Pack, Readable)\n\nPack.prototype.entry = function (header, buffer, callback) {\n if (this._stream) throw new Error('already piping an entry')\n if (this._finalized || this._destroyed) return\n\n if (typeof buffer === 'function') {\n callback = buffer\n buffer = null\n }\n\n if (!callback) callback = noop\n\n var self = this\n\n if (!header.size || header.type === 'symlink') header.size = 0\n if (!header.type) header.type = modeToType(header.mode)\n if (!header.mode) header.mode = header.type === 'directory' ? DMODE : FMODE\n if (!header.uid) header.uid = 0\n if (!header.gid) header.gid = 0\n if (!header.mtime) header.mtime = new Date()\n\n if (typeof buffer === 'string') buffer = Buffer.from(buffer)\n if (Buffer.isBuffer(buffer)) {\n header.size = buffer.length\n this._encode(header)\n var ok = this.push(buffer)\n overflow(self, header.size)\n if (ok) process.nextTick(callback)\n else this._drain = callback\n return new Void()\n }\n\n if (header.type === 'symlink' && !header.linkname) {\n var linkSink = new LinkSink()\n eos(linkSink, function (err) {\n if (err) { // stream was closed\n self.destroy()\n return callback(err)\n }\n\n header.linkname = linkSink.linkname\n self._encode(header)\n callback()\n })\n\n return linkSink\n }\n\n this._encode(header)\n\n if (header.type !== 'file' && header.type !== 'contiguous-file') {\n process.nextTick(callback)\n return new Void()\n }\n\n var sink = new Sink(this)\n\n this._stream = sink\n\n eos(sink, function (err) {\n self._stream = null\n\n if (err) { // stream was closed\n self.destroy()\n return callback(err)\n }\n\n if (sink.written !== header.size) { // corrupting tar\n self.destroy()\n return callback(new Error('size mismatch'))\n }\n\n overflow(self, header.size)\n if (self._finalizing) self.finalize()\n callback()\n })\n\n return sink\n}\n\nPack.prototype.finalize = function () {\n if (this._stream) {\n this._finalizing = true\n return\n }\n\n if (this._finalized) return\n this._finalized = true\n this.push(END_OF_TAR)\n this.push(null)\n}\n\nPack.prototype.destroy = function (err) {\n if (this._destroyed) return\n this._destroyed = true\n\n if (err) this.emit('error', err)\n this.emit('close')\n if (this._stream && this._stream.destroy) this._stream.destroy()\n}\n\nPack.prototype._encode = function (header) {\n if (!header.pax) {\n var buf = headers.encode(header)\n if (buf) {\n this.push(buf)\n return\n }\n }\n this._encodePax(header)\n}\n\nPack.prototype._encodePax = function (header) {\n var paxHeader = headers.encodePax({\n name: header.name,\n linkname: header.linkname,\n pax: header.pax\n })\n\n var newHeader = {\n name: 'PaxHeader',\n mode: header.mode,\n uid: header.uid,\n gid: header.gid,\n size: paxHeader.length,\n mtime: header.mtime,\n type: 'pax-header',\n linkname: header.linkname && 'PaxHeader',\n uname: header.uname,\n gname: header.gname,\n devmajor: header.devmajor,\n devminor: header.devminor\n }\n\n this.push(headers.encode(newHeader))\n this.push(paxHeader)\n overflow(this, paxHeader.length)\n\n newHeader.size = header.size\n newHeader.type = header.type\n this.push(headers.encode(newHeader))\n}\n\nPack.prototype._read = function (n) {\n var drain = this._drain\n this._drain = noop\n drain()\n}\n\nmodule.exports = Pack\n","module.exports = require('./lib/tunnel');\n","'use strict';\n\nvar net = require('net');\nvar tls = require('tls');\nvar http = require('http');\nvar https = require('https');\nvar events = require('events');\nvar assert = require('assert');\nvar util = require('util');\n\n\nexports.httpOverHttp = httpOverHttp;\nexports.httpsOverHttp = httpsOverHttp;\nexports.httpOverHttps = httpOverHttps;\nexports.httpsOverHttps = httpsOverHttps;\n\n\nfunction httpOverHttp(options) {\n var agent = new TunnelingAgent(options);\n agent.request = http.request;\n return agent;\n}\n\nfunction httpsOverHttp(options) {\n var agent = new TunnelingAgent(options);\n agent.request = http.request;\n agent.createSocket = createSecureSocket;\n agent.defaultPort = 443;\n return agent;\n}\n\nfunction httpOverHttps(options) {\n var agent = new TunnelingAgent(options);\n agent.request = https.request;\n return agent;\n}\n\nfunction httpsOverHttps(options) {\n var agent = new TunnelingAgent(options);\n agent.request = https.request;\n agent.createSocket = createSecureSocket;\n agent.defaultPort = 443;\n return agent;\n}\n\n\nfunction TunnelingAgent(options) {\n var self = this;\n self.options = options || {};\n self.proxyOptions = self.options.proxy || {};\n self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets;\n self.requests = [];\n self.sockets = [];\n\n self.on('free', function onFree(socket, host, port, localAddress) {\n var options = toOptions(host, port, localAddress);\n for (var i = 0, len = self.requests.length; i < len; ++i) {\n var pending = self.requests[i];\n if (pending.host === options.host && pending.port === options.port) {\n // Detect the request to connect same origin server,\n // reuse the connection.\n self.requests.splice(i, 1);\n pending.request.onSocket(socket);\n return;\n }\n }\n socket.destroy();\n self.removeSocket(socket);\n });\n}\nutil.inherits(TunnelingAgent, events.EventEmitter);\n\nTunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) {\n var self = this;\n var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress));\n\n if (self.sockets.length >= this.maxSockets) {\n // We are over limit so we'll add it to the queue.\n self.requests.push(options);\n return;\n }\n\n // If we are under maxSockets create a new one.\n self.createSocket(options, function(socket) {\n socket.on('free', onFree);\n socket.on('close', onCloseOrRemove);\n socket.on('agentRemove', onCloseOrRemove);\n req.onSocket(socket);\n\n function onFree() {\n self.emit('free', socket, options);\n }\n\n function onCloseOrRemove(err) {\n self.removeSocket(socket);\n socket.removeListener('free', onFree);\n socket.removeListener('close', onCloseOrRemove);\n socket.removeListener('agentRemove', onCloseOrRemove);\n }\n });\n};\n\nTunnelingAgent.prototype.createSocket = function createSocket(options, cb) {\n var self = this;\n var placeholder = {};\n self.sockets.push(placeholder);\n\n var connectOptions = mergeOptions({}, self.proxyOptions, {\n method: 'CONNECT',\n path: options.host + ':' + options.port,\n agent: false,\n headers: {\n host: options.host + ':' + options.port\n }\n });\n if (options.localAddress) {\n connectOptions.localAddress = options.localAddress;\n }\n if (connectOptions.proxyAuth) {\n connectOptions.headers = connectOptions.headers || {};\n connectOptions.headers['Proxy-Authorization'] = 'Basic ' +\n new Buffer(connectOptions.proxyAuth).toString('base64');\n }\n\n debug('making CONNECT request');\n var connectReq = self.request(connectOptions);\n connectReq.useChunkedEncodingByDefault = false; // for v0.6\n connectReq.once('response', onResponse); // for v0.6\n connectReq.once('upgrade', onUpgrade); // for v0.6\n connectReq.once('connect', onConnect); // for v0.7 or later\n connectReq.once('error', onError);\n connectReq.end();\n\n function onResponse(res) {\n // Very hacky. This is necessary to avoid http-parser leaks.\n res.upgrade = true;\n }\n\n function onUpgrade(res, socket, head) {\n // Hacky.\n process.nextTick(function() {\n onConnect(res, socket, head);\n });\n }\n\n function onConnect(res, socket, head) {\n connectReq.removeAllListeners();\n socket.removeAllListeners();\n\n if (res.statusCode !== 200) {\n debug('tunneling socket could not be established, statusCode=%d',\n res.statusCode);\n socket.destroy();\n var error = new Error('tunneling socket could not be established, ' +\n 'statusCode=' + res.statusCode);\n error.code = 'ECONNRESET';\n options.request.emit('error', error);\n self.removeSocket(placeholder);\n return;\n }\n if (head.length > 0) {\n debug('got illegal response body from proxy');\n socket.destroy();\n var error = new Error('got illegal response body from proxy');\n error.code = 'ECONNRESET';\n options.request.emit('error', error);\n self.removeSocket(placeholder);\n return;\n }\n debug('tunneling connection has established');\n self.sockets[self.sockets.indexOf(placeholder)] = socket;\n return cb(socket);\n }\n\n function onError(cause) {\n connectReq.removeAllListeners();\n\n debug('tunneling socket could not be established, cause=%s\\n',\n cause.message, cause.stack);\n var error = new Error('tunneling socket could not be established, ' +\n 'cause=' + cause.message);\n error.code = 'ECONNRESET';\n options.request.emit('error', error);\n self.removeSocket(placeholder);\n }\n};\n\nTunnelingAgent.prototype.removeSocket = function removeSocket(socket) {\n var pos = this.sockets.indexOf(socket)\n if (pos === -1) {\n return;\n }\n this.sockets.splice(pos, 1);\n\n var pending = this.requests.shift();\n if (pending) {\n // If we have pending requests and a socket gets closed a new one\n // needs to be created to take over in the pool for the one that closed.\n this.createSocket(pending, function(socket) {\n pending.request.onSocket(socket);\n });\n }\n};\n\nfunction createSecureSocket(options, cb) {\n var self = this;\n TunnelingAgent.prototype.createSocket.call(self, options, function(socket) {\n var hostHeader = options.request.getHeader('host');\n var tlsOptions = mergeOptions({}, self.options, {\n socket: socket,\n servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host\n });\n\n // 0 is dummy port for v0.6\n var secureSocket = tls.connect(0, tlsOptions);\n self.sockets[self.sockets.indexOf(socket)] = secureSocket;\n cb(secureSocket);\n });\n}\n\n\nfunction toOptions(host, port, localAddress) {\n if (typeof host === 'string') { // since v0.10\n return {\n host: host,\n port: port,\n localAddress: localAddress\n };\n }\n return host; // for v0.11 or later\n}\n\nfunction mergeOptions(target) {\n for (var i = 1, len = arguments.length; i < len; ++i) {\n var overrides = arguments[i];\n if (typeof overrides === 'object') {\n var keys = Object.keys(overrides);\n for (var j = 0, keyLen = keys.length; j < keyLen; ++j) {\n var k = keys[j];\n if (overrides[k] !== undefined) {\n target[k] = overrides[k];\n }\n }\n }\n }\n return target;\n}\n\n\nvar debug;\nif (process.env.NODE_DEBUG && /\\btunnel\\b/.test(process.env.NODE_DEBUG)) {\n debug = function() {\n var args = Array.prototype.slice.call(arguments);\n if (typeof args[0] === 'string') {\n args[0] = 'TUNNEL: ' + args[0];\n } else {\n args.unshift('TUNNEL:');\n }\n console.error.apply(console, args);\n }\n} else {\n debug = function() {};\n}\nexports.debug = debug; // for test\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = (x[j] + 128) >> 8;\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i, mlen;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n mlen = -1;\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n mlen = n;\n return mlen;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n var t, i;\n for (i = 0; i < arguments.length; i++) {\n if ((t = Object.prototype.toString.call(arguments[i])) !== '[object Uint8Array]')\n throw new TypeError('unexpected type ' + t + ', use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\n// TODO: Completely remove this in v0.15.\nif (!nacl.util) {\n nacl.util = {};\n nacl.util.decodeUTF8 = nacl.util.encodeUTF8 = nacl.util.encodeBase64 = nacl.util.decodeBase64 = function() {\n throw new Error('nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js');\n };\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return false;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return false;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n if (arguments.length !== 2)\n throw new Error('nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?');\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction getUserAgent() {\n if (typeof navigator === \"object\" && \"userAgent\" in navigator) {\n return navigator.userAgent;\n }\n\n if (typeof process === \"object\" && \"version\" in process) {\n return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`;\n }\n\n return \"\";\n}\n\nexports.getUserAgent = getUserAgent;\n//# sourceMappingURL=index.js.map\n","\n/**\n * For Node.js, simply re-export the core `util.deprecate` function.\n */\n\nmodule.exports = require('util').deprecate;\n","// Returns a wrapper function that returns a wrapped callback\n// The wrapper function should do some stuff, and return a\n// presumably different callback function.\n// This makes sure that own properties are retained, so that\n// decorations and such are not lost along the way.\nmodule.exports = wrappy\nfunction wrappy (fn, cb) {\n if (fn && cb) return wrappy(fn)(cb)\n\n if (typeof fn !== 'function')\n throw new TypeError('need wrapper function')\n\n Object.keys(fn).forEach(function (k) {\n wrapper[k] = fn[k]\n })\n\n return wrapper\n\n function wrapper() {\n var args = new Array(arguments.length)\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i]\n }\n var ret = fn.apply(this, args)\n var cb = args[args.length-1]\n if (typeof ret === 'function' && ret !== cb) {\n Object.keys(cb).forEach(function (k) {\n ret[k] = cb[k]\n })\n }\n return ret\n }\n}\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ApiClient = exports.CredentialFetchingError = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst axios_1 = __importDefault(require(\"axios\"));\nclass CredentialFetchingError extends Error {\n}\nexports.CredentialFetchingError = CredentialFetchingError;\nclass ApiClient {\n constructor(client, params) {\n this.client = client;\n this.params = params;\n // We use a static unknown SHA when marking a job as complete from the action\n // to remain in parity with the existing runner.\n this.UnknownSha = {\n 'base-commit-sha': 'unknown'\n };\n }\n getJobDetails() {\n return __awaiter(this, void 0, void 0, function* () {\n const detailsURL = `/update_jobs/${this.params.jobId}/details`;\n const res = yield this.client.get(detailsURL, {\n headers: { Authorization: this.params.jobToken }\n });\n if (res.status !== 200) {\n throw new Error(`Unexpected status code: ${res.status}`);\n }\n return res.data.data.attributes;\n });\n }\n getCredentials() {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n const credentialsURL = `/update_jobs/${this.params.jobId}/credentials`;\n try {\n const res = yield this.client.get(credentialsURL, {\n headers: { Authorization: this.params.credentialsToken }\n });\n // Mask any secrets we've just retrieved from Actions logs\n for (const credential of res.data.data.attributes.credentials) {\n if (credential.password) {\n core.setSecret(credential.password);\n }\n if (credential.token) {\n core.setSecret(credential.token);\n }\n }\n return res.data.data.attributes.credentials;\n }\n catch (error) {\n if (axios_1.default.isAxiosError(error)) {\n const err = error;\n throw new CredentialFetchingError(`fetching credentials: received code ${(_a = err.response) === null || _a === void 0 ? void 0 : _a.status}: ${JSON.stringify((_b = err.response) === null || _b === void 0 ? void 0 : _b.data)}`);\n }\n else {\n throw error;\n }\n }\n });\n }\n reportJobError(error) {\n return __awaiter(this, void 0, void 0, function* () {\n const recordErrorURL = `/update_jobs/${this.params.jobId}/record_update_job_error`;\n const res = yield this.client.post(recordErrorURL, { data: error }, {\n headers: { Authorization: this.params.jobToken }\n });\n if (res.status !== 204) {\n throw new Error(`Unexpected status code: ${res.status}`);\n }\n });\n }\n markJobAsProcessed() {\n return __awaiter(this, void 0, void 0, function* () {\n const markAsProcessedURL = `/update_jobs/${this.params.jobId}/mark_as_processed`;\n const res = yield this.client.patch(markAsProcessedURL, { data: this.UnknownSha }, {\n headers: { Authorization: this.params.jobToken }\n });\n if (res.status !== 204) {\n throw new Error(`Unexpected status code: ${res.status}`);\n }\n });\n }\n}\nexports.ApiClient = ApiClient;\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ContainerService = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst tar_stream_1 = require(\"tar-stream\");\nconst utils_1 = require(\"./utils\");\nclass ContainerRuntimeError extends Error {\n}\nexports.ContainerService = {\n storeInput(name, path, container, input) {\n return __awaiter(this, void 0, void 0, function* () {\n const tar = tar_stream_1.pack();\n tar.entry({ name }, JSON.stringify(input));\n tar.finalize();\n yield container.putArchive(tar, { path });\n });\n },\n storeCert(name, path, container, cert) {\n return __awaiter(this, void 0, void 0, function* () {\n const tar = tar_stream_1.pack();\n tar.entry({ name }, cert);\n tar.finalize();\n yield container.putArchive(tar, { path });\n });\n },\n run(container) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n const stream = yield container.attach({\n stream: true,\n stdout: true,\n stderr: true\n });\n container.modem.demuxStream(stream, utils_1.outStream('updater'), utils_1.errStream('updater'));\n yield container.start();\n const outcome = yield container.wait();\n if (outcome.StatusCode === 0) {\n return true;\n }\n else {\n throw new ContainerRuntimeError(`Failure running container ${container.id}`);\n }\n }\n finally {\n yield container.remove({ v: true });\n core.info(`Cleaned up container ${container.id}`);\n }\n });\n }\n};\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ImageService = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst dockerode_1 = __importDefault(require(\"dockerode\"));\nconst endOfStream = (docker, stream) => __awaiter(void 0, void 0, void 0, function* () {\n return new Promise((resolve, reject) => {\n docker.modem.followProgress(stream, (err) => err ? reject(err) : resolve(undefined));\n });\n});\nexports.ImageService = {\n /** Fetch the configured updater image, if it isn't already available. */\n pull(imageName, force = false) {\n return __awaiter(this, void 0, void 0, function* () {\n const docker = new dockerode_1.default();\n try {\n const image = yield docker.getImage(imageName).inspect();\n if (!force) {\n core.info(`Resolved ${imageName} to existing ${image.Id}`);\n return;\n } // else fallthrough to pull\n }\n catch (e) {\n if (!e.message.includes('no such image')) {\n throw e;\n } // else fallthrough to pull\n }\n core.info(`Pulling image ${imageName}...`);\n const auth = {\n username: 'x',\n password: process.env.GITHUB_TOKEN\n };\n const stream = yield docker.pull(imageName, { authconfig: auth });\n yield endOfStream(docker, stream);\n core.info(`Pulled image ${imageName}`);\n });\n }\n};\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getJobParameters = exports.JobParameters = void 0;\nconst fs_1 = __importDefault(require(\"fs\"));\nconst path_1 = __importDefault(require(\"path\"));\nconst core = __importStar(require(\"@actions/core\"));\nconst DYNAMIC = 'dynamic';\nconst DEPENDABOT_ACTOR = 'dependabot[bot]';\n// JobParameters are the Action inputs required to execute the job\nclass JobParameters {\n constructor(jobId, jobToken, credentialsToken, dependabotApiUrl, dependabotApiDockerUrl, workingDirectory) {\n this.jobId = jobId;\n this.jobToken = jobToken;\n this.credentialsToken = credentialsToken;\n this.dependabotApiUrl = dependabotApiUrl;\n this.dependabotApiDockerUrl = dependabotApiDockerUrl;\n this.workingDirectory = workingDirectory;\n }\n}\nexports.JobParameters = JobParameters;\nfunction getJobParameters(ctx) {\n checkEnvironmentAndContext(ctx);\n if (ctx.actor !== DEPENDABOT_ACTOR) {\n core.warning('This workflow can only be triggered by Dependabot.');\n return null;\n }\n if (ctx.eventName === DYNAMIC) {\n return fromWorkflowInputs(ctx);\n }\n else {\n core.warning(`Dependabot Updater Action does not support '${ctx.eventName}' events.`);\n return null;\n }\n}\nexports.getJobParameters = getJobParameters;\nfunction checkEnvironmentAndContext(ctx) {\n let valid = true;\n if (!ctx.actor) {\n core.error('GITHUB_ACTOR is not defined');\n valid = false;\n }\n if (!ctx.eventName) {\n core.error('GITHUB_EVENT_NAME is not defined');\n valid = false;\n }\n if (!process.env.GITHUB_WORKSPACE) {\n core.error('GITHUB_WORKSPACE is not defined');\n valid = false;\n }\n if (!valid) {\n throw new Error('Required Actions environment variables missing.');\n }\n else {\n return valid;\n }\n}\nfunction fromWorkflowInputs(ctx) {\n const evt = ctx.payload;\n if (!evt.inputs) {\n throw new Error('Event payload has no inputs');\n }\n const dependabotApiDockerUrl = evt.inputs.dependabotApiDockerUrl || evt.inputs.dependabotApiUrl;\n const workingDirectory = absoluteWorkingDirectory(evt.inputs.workingDirectory);\n return new JobParameters(parseInt(evt.inputs.jobId, 10), evt.inputs.jobToken, evt.inputs.credentialsToken, evt.inputs.dependabotApiUrl, dependabotApiDockerUrl, workingDirectory);\n}\nfunction absoluteWorkingDirectory(workingDirectory) {\n const workspace = process.env.GITHUB_WORKSPACE;\n if (!workingDirectory) {\n throw new Error('The workingDirectory input must not be blank.');\n }\n if (!directoryExistsSync(workspace)) {\n throw new Error('The GITHUB_WORKSPACE directory does not exist.');\n }\n const fullPath = path_1.default.join(workspace, workingDirectory);\n if (!directoryExistsSync(fullPath)) {\n throw new Error(`The workingDirectory '${workingDirectory}' does not exist in GITHUB_WORKSPACE`);\n }\n return fullPath;\n}\nfunction directoryExistsSync(directoryPath) {\n let stats;\n try {\n stats = fs_1.default.statSync(directoryPath);\n }\n catch (error) {\n if (error.code === 'ENOENT') {\n return false;\n }\n throw new Error(`Encountered an error when checking whether path '${directoryPath}' exists: ${error.message}`);\n }\n return stats.isDirectory();\n}\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.run = exports.DependabotErrorType = exports.PROXY_IMAGE_NAME = exports.UPDATER_IMAGE_NAME = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst github = __importStar(require(\"@actions/github\"));\nconst inputs_1 = require(\"./inputs\");\nconst image_service_1 = require(\"./image-service\");\nconst updater_1 = require(\"./updater\");\nconst api_client_1 = require(\"./api-client\");\nconst axios_1 = __importDefault(require(\"axios\"));\nexports.UPDATER_IMAGE_NAME = 'docker.pkg.github.com/dependabot/dependabot-updater:v1';\nexports.PROXY_IMAGE_NAME = 'docker.pkg.github.com/github/dependabot-update-job-proxy:v1';\nvar DependabotErrorType;\n(function (DependabotErrorType) {\n DependabotErrorType[\"Unknown\"] = \"actions_workflow_unknown\";\n DependabotErrorType[\"Image\"] = \"actions_workflow_image\";\n DependabotErrorType[\"UpdateRun\"] = \"actions_workflow_updater\";\n})(DependabotErrorType = exports.DependabotErrorType || (exports.DependabotErrorType = {}));\nlet jobId;\nfunction run(context) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n botSay('starting update');\n // Retrieve JobParameters from the Actions environment\n const params = inputs_1.getJobParameters(context);\n // The parameters will be null if the Action environment\n // is not a valid Dependabot-triggered dynamic event.\n if (params === null) {\n botSay('finished: nothing to do');\n return; // TODO: This should be setNeutral in future\n }\n jobId = params.jobId;\n core.setSecret(params.jobToken);\n core.setSecret(params.credentialsToken);\n const client = axios_1.default.create({ baseURL: params.dependabotApiUrl });\n const apiClient = new api_client_1.ApiClient(client, params);\n core.info('Fetching job details');\n // If we fail to succeed in fetching the job details, we cannot be sure the job has entered a 'processing' state,\n // so we do not try attempt to report back an exception if this fails and instead rely on the the workflow run\n // webhook as it anticipates scenarios where jobs have failed while 'enqueued'.\n const details = yield apiClient.getJobDetails();\n try {\n const credentials = yield apiClient.getCredentials();\n const updater = new updater_1.Updater(exports.UPDATER_IMAGE_NAME, exports.PROXY_IMAGE_NAME, apiClient, details, credentials, params.workingDirectory);\n core.startGroup('Pulling updater images');\n try {\n yield image_service_1.ImageService.pull(exports.UPDATER_IMAGE_NAME);\n yield image_service_1.ImageService.pull(exports.PROXY_IMAGE_NAME);\n }\n catch (error) {\n core.error('Error fetching updater images');\n yield failJob(apiClient, error, DependabotErrorType.Image);\n return;\n }\n core.endGroup();\n try {\n core.info('Starting update process');\n yield updater.runUpdater();\n }\n catch (error) {\n // If we have encountered a UpdaterFetchError, the Updater will already have\n // reported the error and marked the job as processed, so we only need to\n // set an exit status.\n if (error instanceof updater_1.UpdaterFetchError) {\n setFailed('Dependabot was unable to retrieve the files required to perform the update');\n botSay('finished: unable to fetch files');\n return;\n }\n else {\n core.error('Error performing update');\n yield failJob(apiClient, error, DependabotErrorType.UpdateRun);\n return;\n }\n }\n botSay('finished');\n }\n catch (error) {\n if (error instanceof api_client_1.CredentialFetchingError) {\n core.error('Error retrieving update job credentials');\n yield failJob(apiClient, error, DependabotErrorType.UpdateRun);\n }\n else {\n yield failJob(apiClient, error);\n }\n return;\n }\n }\n catch (error) {\n // If we've reached this point, we do not have a viable\n // API client to report back to Dependabot API.\n //\n // We output the raw error in the Action logs and defer\n // to workflow_run monitoring to detect the job failure.\n setFailed(error);\n botSay('finished: unexpected error');\n }\n });\n}\nexports.run = run;\nfunction failJob(apiClient, error, errorType = DependabotErrorType.Unknown) {\n return __awaiter(this, void 0, void 0, function* () {\n yield apiClient.reportJobError({\n 'error-type': errorType,\n 'error-details': {\n 'action-error': error.message\n }\n });\n yield apiClient.markJobAsProcessed();\n setFailed(error.message);\n botSay('finished: error reported to Dependabot');\n });\n}\nfunction botSay(message) {\n core.info(`🤖 ~ ${message} ~`);\n}\nfunction setFailed(message) {\n core.setFailed(message);\n if (jobId) {\n core.error(`For more information see: ${dependabotJobUrl(jobId)} (write access required)`);\n }\n}\nfunction dependabotJobUrl(id) {\n const url_parts = [\n process.env.GITHUB_SERVER_URL,\n process.env.GITHUB_REPOSITORY,\n 'network/updates',\n id\n ];\n return url_parts.filter(Boolean).join('/');\n}\nrun(github.context);\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ProxyBuilder = void 0;\nconst fs_1 = __importDefault(require(\"fs\"));\nconst core = __importStar(require(\"@actions/core\"));\nconst crypto_1 = __importDefault(require(\"crypto\"));\nconst container_service_1 = require(\"./container-service\");\nconst node_forge_1 = require(\"node-forge\");\nconst utils_1 = require(\"./utils\");\nconst KEY_SIZE = 2048;\nconst KEY_EXPIRY_YEARS = 2;\nconst CONFIG_FILE_PATH = '/';\nconst CONFIG_FILE_NAME = 'config.json';\nconst CA_CERT_INPUT_PATH = '/usr/local/share/ca-certificates';\nconst CUSTOM_CA_CERT_NAME = 'custom-ca-cert.crt';\nconst CERT_SUBJECT = [\n {\n name: 'commonName',\n value: 'Dependabot Internal CA'\n },\n {\n name: 'organizationName',\n value: 'GitHub ic.'\n },\n {\n shortName: 'OU',\n value: 'Dependabot'\n },\n {\n name: 'countryName',\n value: 'US'\n },\n {\n shortName: 'ST',\n value: 'California'\n },\n {\n name: 'localityName',\n value: 'San Francisco'\n }\n];\nclass ProxyBuilder {\n constructor(docker, proxyImage) {\n this.docker = docker;\n this.proxyImage = proxyImage;\n }\n run(jobId, credentials) {\n return __awaiter(this, void 0, void 0, function* () {\n const name = `dependabot-job-${jobId}-proxy`;\n const config = this.buildProxyConfig(credentials, jobId);\n const cert = config.ca.cert;\n const externalNetworkName = `dependabot-job-${jobId}-external-network`;\n const externalNetwork = yield this.ensureNetwork(externalNetworkName, false);\n const internalNetworkName = `dependabot-job-${jobId}-internal-network`;\n const internalNetwork = yield this.ensureNetwork(internalNetworkName, true);\n const container = yield this.createContainer(jobId, name, externalNetwork, internalNetwork, internalNetworkName);\n yield container_service_1.ContainerService.storeInput(CONFIG_FILE_NAME, CONFIG_FILE_PATH, container, config);\n if (process.env.CUSTOM_CA_PATH) {\n core.info('Detected custom CA certificate, adding to proxy');\n const customCert = fs_1.default\n .readFileSync(process.env.CUSTOM_CA_PATH, 'utf8')\n .toString();\n yield container_service_1.ContainerService.storeCert(CUSTOM_CA_CERT_NAME, CA_CERT_INPUT_PATH, container, customCert);\n }\n const stream = yield container.attach({\n stream: true,\n stdout: true,\n stderr: true\n });\n container.modem.demuxStream(stream, utils_1.outStream(' proxy'), utils_1.errStream(' proxy'));\n const url = `http://${config.proxy_auth.username}:${config.proxy_auth.password}@${name}:1080`;\n return {\n container,\n network: internalNetwork,\n networkName: internalNetworkName,\n url,\n cert,\n shutdown: () => __awaiter(this, void 0, void 0, function* () {\n yield container.stop();\n yield container.remove();\n yield externalNetwork.remove();\n yield internalNetwork.remove();\n })\n };\n });\n }\n ensureNetwork(name, internal = true) {\n return __awaiter(this, void 0, void 0, function* () {\n const networks = yield this.docker.listNetworks({\n filters: JSON.stringify({ name: [name] })\n });\n if (networks.length > 0) {\n return this.docker.getNetwork(networks[0].Id);\n }\n else {\n return yield this.docker.createNetwork({ Name: name, Internal: internal });\n }\n });\n }\n buildProxyConfig(credentials, jobId) {\n const ca = this.generateCertificateAuthority();\n const password = crypto_1.default.randomBytes(20).toString('hex');\n const proxy_auth = {\n username: `${jobId}`,\n password\n };\n const config = { all_credentials: credentials, ca, proxy_auth };\n return config;\n }\n generateCertificateAuthority() {\n const keys = node_forge_1.pki.rsa.generateKeyPair(KEY_SIZE);\n const cert = node_forge_1.pki.createCertificate();\n cert.publicKey = keys.publicKey;\n cert.serialNumber = '01';\n cert.validity.notBefore = new Date();\n cert.validity.notAfter = new Date();\n cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + KEY_EXPIRY_YEARS);\n cert.setSubject(CERT_SUBJECT);\n cert.setIssuer(CERT_SUBJECT);\n cert.setExtensions([{ name: 'basicConstraints', cA: true }]);\n cert.sign(keys.privateKey);\n const pem = node_forge_1.pki.certificateToPem(cert);\n const key = node_forge_1.pki.privateKeyToPem(keys.privateKey);\n return { cert: pem, key };\n }\n createContainer(jobId, containerName, externalNetwork, internalNetwork, internalNetworkName) {\n return __awaiter(this, void 0, void 0, function* () {\n const container = yield this.docker.createContainer({\n Image: this.proxyImage,\n name: containerName,\n AttachStdout: true,\n AttachStderr: true,\n Env: [`JOB_ID=${jobId}`],\n Entrypoint: [\n 'sh',\n '-c',\n '/usr/sbin/update-ca-certificates && /update-job-proxy'\n ],\n HostConfig: {\n NetworkMode: internalNetworkName\n }\n });\n yield externalNetwork.connect({ Container: container.id });\n core.info(`Created proxy container: ${container.id}`);\n return container;\n });\n }\n}\nexports.ProxyBuilder = ProxyBuilder;\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.UpdaterBuilder = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst container_service_1 = require(\"./container-service\");\nconst JOB_OUTPUT_FILENAME = 'output.json';\nconst JOB_OUTPUT_PATH = '/home/dependabot/dependabot-updater/output';\nconst JOB_INPUT_FILENAME = 'job.json';\nconst JOB_INPUT_PATH = `/home/dependabot/dependabot-updater`;\nconst REPO_CONTENTS_PATH = '/home/dependabot/dependabot-updater/repo';\nconst CA_CERT_INPUT_PATH = '/usr/local/share/ca-certificates';\nconst CA_CERT_FILENAME = 'dbot-ca.crt';\nconst UPDATER_MAX_MEMORY = 8 * 1024 * 1024 * 1024; // 8GB in bytes\nclass UpdaterBuilder {\n constructor(docker, jobParams, input, outputHostPath, proxy, repoHostPath, updaterImage) {\n this.docker = docker;\n this.jobParams = jobParams;\n this.input = input;\n this.outputHostPath = outputHostPath;\n this.proxy = proxy;\n this.repoHostPath = repoHostPath;\n this.updaterImage = updaterImage;\n }\n run(containerName, updaterCommand) {\n return __awaiter(this, void 0, void 0, function* () {\n const cmd = `(echo > /etc/ca-certificates.conf) &&\\\n rm -Rf /usr/share/ca-certificates/ &&\\\n /usr/sbin/update-ca-certificates &&\\\n $DEPENDABOT_HOME/dependabot-updater/bin/run ${updaterCommand}`;\n const container = yield this.docker.createContainer({\n Image: this.updaterImage,\n name: containerName,\n AttachStdout: true,\n AttachStderr: true,\n Env: [\n `GITHUB_ACTIONS=${process.env.GITHUB_ACTIONS}`,\n `DEPENDABOT_JOB_ID=${this.jobParams.jobId}`,\n `DEPENDABOT_JOB_TOKEN=${this.jobParams.jobToken}`,\n `DEPENDABOT_JOB_PATH=${JOB_INPUT_PATH}/${JOB_INPUT_FILENAME}`,\n `DEPENDABOT_OUTPUT_PATH=${JOB_OUTPUT_PATH}/${JOB_OUTPUT_FILENAME}`,\n `DEPENDABOT_REPO_CONTENTS_PATH=${REPO_CONTENTS_PATH}`,\n `DEPENDABOT_API_URL=${this.jobParams.dependabotApiDockerUrl}`,\n `SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt`,\n `http_proxy=${this.proxy.url}`,\n `HTTP_PROXY=${this.proxy.url}`,\n `https_proxy=${this.proxy.url}`,\n `HTTPS_PROXY=${this.proxy.url}`\n ],\n Cmd: ['sh', '-c', cmd],\n HostConfig: {\n Memory: UPDATER_MAX_MEMORY,\n NetworkMode: this.proxy.networkName,\n Binds: [\n `${this.outputHostPath}:${JOB_OUTPUT_PATH}:rw`,\n `${this.repoHostPath}:${REPO_CONTENTS_PATH}:rw`\n ]\n }\n });\n yield container_service_1.ContainerService.storeCert(CA_CERT_FILENAME, CA_CERT_INPUT_PATH, container, this.proxy.cert);\n yield container_service_1.ContainerService.storeInput(JOB_INPUT_FILENAME, JOB_INPUT_PATH, container, this.input);\n core.info(`Created ${updaterCommand} container: ${container.id}`);\n return container;\n });\n }\n}\nexports.UpdaterBuilder = UpdaterBuilder;\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Updater = exports.UpdaterFetchError = void 0;\nconst core = __importStar(require(\"@actions/core\"));\nconst dockerode_1 = __importDefault(require(\"dockerode\"));\nconst path_1 = __importDefault(require(\"path\"));\nconst fs_1 = __importDefault(require(\"fs\"));\nconst container_service_1 = require(\"./container-service\");\nconst utils_1 = require(\"./utils\");\nconst proxy_1 = require(\"./proxy\");\nconst updater_builder_1 = require(\"./updater-builder\");\nclass UpdaterFetchError extends Error {\n constructor(msg) {\n super(msg);\n Object.setPrototypeOf(this, UpdaterFetchError.prototype);\n }\n}\nexports.UpdaterFetchError = UpdaterFetchError;\nclass Updater {\n constructor(updaterImage, proxyImage, apiClient, details, credentials, workingDirectory) {\n this.updaterImage = updaterImage;\n this.proxyImage = proxyImage;\n this.apiClient = apiClient;\n this.details = details;\n this.credentials = credentials;\n this.workingDirectory = workingDirectory;\n this.docker = new dockerode_1.default();\n this.outputHostPath = path_1.default.join(workingDirectory, 'output');\n this.repoHostPath = path_1.default.join(workingDirectory, 'repo');\n }\n /**\n * Execute an update job and report the result to Dependabot API.\n */\n runUpdater() {\n return __awaiter(this, void 0, void 0, function* () {\n // Create required folders in the workingDirectory\n fs_1.default.mkdirSync(this.outputHostPath);\n fs_1.default.mkdirSync(this.repoHostPath);\n const proxy = yield new proxy_1.ProxyBuilder(this.docker, this.proxyImage).run(this.apiClient.params.jobId, this.credentials);\n proxy.container.start();\n try {\n const files = yield this.runFileFetcher(proxy);\n yield this.runFileUpdater(proxy, files);\n return true;\n }\n finally {\n yield this.cleanup(proxy);\n }\n });\n }\n runFileFetcher(proxy) {\n return __awaiter(this, void 0, void 0, function* () {\n const name = `dependabot-job-${this.apiClient.params.jobId}-file-fetcher`;\n const container = yield this.createContainer(proxy, name, 'fetch_files', {\n job: this.details\n });\n yield container_service_1.ContainerService.run(container);\n const outputPath = path_1.default.join(this.outputHostPath, 'output.json');\n if (!fs_1.default.existsSync(outputPath)) {\n throw new UpdaterFetchError('No output.json created by the fetcher container');\n }\n const fileFetcherSync = fs_1.default.readFileSync(outputPath).toString();\n const fileFetcherOutput = JSON.parse(fileFetcherSync);\n const fetchedFiles = {\n base_commit_sha: fileFetcherOutput.base_commit_sha,\n base64_dependency_files: fileFetcherOutput.base64_dependency_files,\n dependency_files: fileFetcherOutput.base64_dependency_files.map((file) => utils_1.base64DecodeDependencyFile(file))\n };\n return fetchedFiles;\n });\n }\n runFileUpdater(proxy, files) {\n return __awaiter(this, void 0, void 0, function* () {\n core.info(`Running update job ${this.apiClient.params.jobId}`);\n const name = `dependabot-job-${this.apiClient.params.jobId}-updater`;\n const containerInput = {\n base_commit_sha: files.base_commit_sha,\n base64_dependency_files: files.base64_dependency_files,\n dependency_files: files.dependency_files,\n job: this.details\n };\n const container = yield this.createContainer(proxy, name, 'update_files', containerInput);\n yield container_service_1.ContainerService.run(container);\n });\n }\n createContainer(proxy, containerName, updaterCommand, input) {\n return __awaiter(this, void 0, void 0, function* () {\n return new updater_builder_1.UpdaterBuilder(this.docker, this.apiClient.params, input, this.outputHostPath, proxy, this.repoHostPath, this.updaterImage).run(containerName, updaterCommand);\n });\n }\n cleanup(proxy) {\n return __awaiter(this, void 0, void 0, function* () {\n yield proxy.shutdown();\n if (fs_1.default.existsSync(this.outputHostPath)) {\n fs_1.default.rmdirSync(this.outputHostPath, { recursive: true });\n }\n if (fs_1.default.existsSync(this.repoHostPath)) {\n fs_1.default.rmdirSync(this.repoHostPath, { recursive: true });\n }\n });\n }\n}\nexports.Updater = Updater;\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.errStream = exports.outStream = exports.base64DecodeDependencyFile = void 0;\nconst stream_1 = __importDefault(require(\"stream\"));\nconst base64Decode = (str) => Buffer.from(str, 'base64').toString('binary');\nconst base64DecodeDependencyFile = (file) => {\n const fileCopy = JSON.parse(JSON.stringify(file));\n fileCopy.content = base64Decode(fileCopy.content);\n return fileCopy;\n};\nexports.base64DecodeDependencyFile = base64DecodeDependencyFile;\nconst outStream = (prefix) => {\n return new stream_1.default.Writable({\n write(chunk, _, next) {\n process.stderr.write(`${prefix} | ${chunk.toString()}`);\n next();\n }\n });\n};\nexports.outStream = outStream;\nconst errStream = (prefix) => {\n return new stream_1.default.Writable({\n write(chunk, _, next) {\n process.stderr.write(`${prefix} | ${chunk.toString()}`);\n next();\n }\n });\n};\nexports.errStream = errStream;\n","module.exports = __non_webpack_require__(__webpack_require__.ab + \"build/Release/cpufeatures.node\")","module.exports = __non_webpack_require__(__webpack_require__.ab + \"lib/protocol/crypto/build/Release/sshcrypto.node\")",null,"module.exports = require(\"assert\");","module.exports = require(\"buffer\");","module.exports = require(\"child_process\");","module.exports = require(\"constants\");","module.exports = require(\"crypto\");","module.exports = require(\"dns\");","module.exports = require(\"events\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","module.exports = require(\"net\");","module.exports = require(\"os\");","module.exports = require(\"path\");","module.exports = require(\"querystring\");","module.exports = require(\"stream\");","module.exports = require(\"string_decoder\");","module.exports = require(\"tls\");","module.exports = require(\"tty\");","module.exports = require(\"url\");","module.exports = require(\"util\");","module.exports = require(\"zlib\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\tvar threw = true;\n\ttry {\n\t\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\t\tthrew = false;\n\t} finally {\n\t\tif(threw) delete __webpack_module_cache__[moduleId];\n\t}\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","\nif (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = __dirname + \"/\";","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(399);\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AChTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC9KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC/IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxuCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5TA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnBA;;A;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1WA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtHA;AACA;AACA;AACA;AACA;;;A;;;;;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrIA;AACA;AACA;;A;;;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC5VA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3iBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC3YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtKA;AACA;AACA;;;A;;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5QA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACpQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1dA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5jCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzyDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzhBA;;;A;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChnDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClkCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC1FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/3CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACt+BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC7EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/eA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/iCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/uCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5TA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACnRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxuCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACrGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACxSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AClaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACj0DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9TA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3OA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACptBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzrIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC11FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACpwGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACnmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxrBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC9MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACjNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;ACvGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AC/DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;;AChGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;AC1BA;;;A;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC5EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtSA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;ACzNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC79DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC5hEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChsHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACvVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjkDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAGA;;;A;;;;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC7rCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACtyDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC18CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACt1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC/UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A;;;;;ACvSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC3VA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AChQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACtSA;AACA;;;A;;;;;ACDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC9PA;;;A;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACvQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACn1EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACjBA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AClHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC7EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACpEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACjKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACnLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;AC7FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;;ACrIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A;;;;;AC/BA;;A;;;;;ACAA;;A;;;;;ACAA;;;A;;;;;;A;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;;;ACAA;;A;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7BA;AACA;;;;ACDA;AACA;AACA;AACA;;;;A","sourceRoot":""} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index dc035ea46..93a521d4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3816,9 +3816,9 @@ } }, "dockerode": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/dockerode/-/dockerode-3.3.0.tgz", - "integrity": "sha512-St08lfOjpYCOXEM8XA0VLu3B3hRjtddODphNW5GFoA0AS3JHgoPQKOz0Qmdzg3P+hUPxhb02g1o1Cu1G+U3lRg==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/dockerode/-/dockerode-3.3.1.tgz", + "integrity": "sha512-AS2mr8Lp122aa5n6d99HkuTNdRV1wkkhHwBdcnY6V0+28D3DSYwhxAk85/mM9XwD3RMliTxyr63iuvn5ZblFYQ==", "requires": { "docker-modem": "^3.0.0", "tar-fs": "~2.0.1" @@ -13796,9 +13796,9 @@ "dev": true }, "ssh2": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/ssh2/-/ssh2-1.5.0.tgz", - "integrity": "sha512-iUmRkhH9KGeszQwDW7YyyqjsMTf4z+0o48Cp4xOwlY5LjtbIAvyd3fwnsoUZW/hXmTCRA3yt7S/Jb9uVjErVlA==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ssh2/-/ssh2-1.6.0.tgz", + "integrity": "sha512-lxc+uvXqOxyQ99N2M7k5o4pkYDO5GptOTYduWw7hIM41icxvoBcCNHcj+LTKrjkL0vFcAl+qfZekthoSFRJn2Q==", "requires": { "asn1": "^0.2.4", "bcrypt-pbkdf": "^1.0.2", diff --git a/package.json b/package.json index 521e2e4c5..9e1ce1e06 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@octokit/webhooks-types": "^4.8.0", "axios": "^0.23.0", "commander": "^8.2.0", - "dockerode": "^3.3.0", + "dockerode": "^3.3.1", "npm": "^6.14.15", "tar-stream": "^2.2.0" },